blob: f428cfb4d6da8a88f2fa079b64525a0a7ea8f8e7 [file] [log] [blame]
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -08001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// FIXME: add well-defined names for cameras
18
19#ifndef ANDROID_INCLUDE_CAMERA_COMMON_H
20#define ANDROID_INCLUDE_CAMERA_COMMON_H
21
22#include <stdint.h>
Chien-Yu Chen30159172015-01-08 11:06:38 -080023#include <stdbool.h>
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -080024#include <sys/cdefs.h>
25#include <sys/types.h>
26#include <cutils/native_handle.h>
27#include <system/camera.h>
Ruben Brunk61cf9eb2014-01-14 15:27:58 -080028#include <system/camera_vendor_tags.h>
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -080029#include <hardware/hardware.h>
30#include <hardware/gralloc.h>
31
32__BEGIN_DECLS
33
34/**
35 * The id of this module
36 */
37#define CAMERA_HARDWARE_MODULE_ID "camera"
38
39/**
40 * Module versioning information for the Camera hardware module, based on
41 * camera_module_t.common.module_api_version. The two most significant hex
42 * digits represent the major version, and the two least significant represent
43 * the minor version.
44 *
45 *******************************************************************************
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -070046 * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0]
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -080047 *
48 * Camera modules that report these version numbers implement the initial
49 * camera module HAL interface. All camera devices openable through this
50 * module support only version 1 of the camera device HAL. The device_version
51 * and static_camera_characteristics fields of camera_info are not valid. Only
52 * the android.hardware.Camera API can be supported by this module and its
53 * devices.
54 *
55 *******************************************************************************
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -070056 * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0]
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -080057 *
58 * Camera modules that report this version number implement the second version
59 * of the camera module HAL interface. Camera devices openable through this
60 * module may support either version 1.0 or version 2.0 of the camera device
61 * HAL interface. The device_version field of camera_info is always valid; the
62 * static_camera_characteristics field of camera_info is valid if the
63 * device_version field is 2.0 or higher.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -080064 *
65 *******************************************************************************
66 * Version: 2.1 [CAMERA_MODULE_API_VERSION_2_1]
67 *
68 * This camera module version adds support for asynchronous callbacks to the
69 * framework from the camera HAL module, which is used to notify the framework
70 * about changes to the camera module state. Modules that provide a valid
71 * set_callbacks() method must report at least this version number.
Alex Ray19b2cea2013-06-13 12:40:52 -070072 *
73 *******************************************************************************
74 * Version: 2.2 [CAMERA_MODULE_API_VERSION_2_2]
75 *
76 * This camera module version adds vendor tag support from the module, and
77 * deprecates the old vendor_tag_query_ops that were previously only
78 * accessible with a device open.
Zhijun Hebcdebf32014-06-06 15:42:17 -070079 *
80 *******************************************************************************
81 * Version: 2.3 [CAMERA_MODULE_API_VERSION_2_3]
82 *
83 * This camera module version adds open legacy camera HAL device support.
84 * Framework can use it to open the camera device as lower device HAL version
85 * HAL device if the same device can support multiple device API versions.
86 * The standard hardware module open call (common.methods->open) continues
87 * to open the camera device with the latest supported version, which is
88 * also the version listed in camera_info_t.device_version.
Chien-Yu Chen30159172015-01-08 11:06:38 -080089 *
90 *******************************************************************************
91 * Version: 2.4 [CAMERA_MODULE_API_VERSION_2_4]
92 *
Zhijun He94e23b22015-01-12 14:45:33 -080093 * This camera module version adds below API changes:
94 *
95 * 1. Torch mode support. The framework can use it to turn on torch mode for
96 * any camera device that has a flash unit, without opening a camera device. The
97 * camera device has a higher priority accessing the flash unit than the camera
98 * module; opening a camera device will turn off the torch if it had been enabled
99 * through the module interface. When there are any resource conflicts, such as
100 * open() is called to open a camera device, the camera HAL module must notify the
101 * framework through the torch mode status callback that the torch mode has been
102 * turned off.
103 *
104 * 2. External camera (e.g. USB hot-plug camera) support. The API updates specify that
105 * the camera static info is only available when camera is connected and ready to
106 * use for external hot-plug cameras. Calls to get static info will be invalid
107 * calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The frameworks
108 * will only count on device status change callbacks to manage the available external
109 * camera list.
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800110 *
111 * 3. Camera arbitration hints. This module version adds support for explicitly
112 * indicating the number of camera devices that can be simultaneously opened and used.
113 * To specify valid combinations of devices, the resource_cost and conflicting_devices
114 * fields should always be set in the camera_info structure returned by the
115 * get_camera_info call.
Eino-Ville Talvalaaee47822015-04-07 13:47:46 -0700116 *
117 * 4. Module initialization method. This will be called by the camera service
118 * right after the HAL module is loaded, to allow for one-time initialization
119 * of the HAL. It is called before any other module methods are invoked.
Shuzhen Wanga8caa6a2018-08-24 11:07:50 -0700120 *
121 *******************************************************************************
122 * Version: 2.5 [CAMERA_MODULE_API_VERSION_2_5]
123 *
124 * This camera module version adds support to query characteristics of a
125 * non-standalone physical camera, which can only be accessed as part of a
Emilian Peev8ca3c602018-10-29 09:37:04 +0000126 * logical camera. It also adds camera stream combination query.
Shuzhen Wanga8caa6a2018-08-24 11:07:50 -0700127 *
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800128 */
129
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700130/**
131 * Predefined macros for currently-defined version numbers
132 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800133
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700134/**
135 * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated
136 * as CAMERA_MODULE_API_VERSION_1_0
137 */
138#define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
139#define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800140#define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1)
Alex Ray19b2cea2013-06-13 12:40:52 -0700141#define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2)
Zhijun Hebcdebf32014-06-06 15:42:17 -0700142#define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3)
Chien-Yu Chen30159172015-01-08 11:06:38 -0800143#define CAMERA_MODULE_API_VERSION_2_4 HARDWARE_MODULE_API_VERSION(2, 4)
Shuzhen Wanga8caa6a2018-08-24 11:07:50 -0700144#define CAMERA_MODULE_API_VERSION_2_5 HARDWARE_MODULE_API_VERSION(2, 5)
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700145
Shuzhen Wanga8caa6a2018-08-24 11:07:50 -0700146#define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_5
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700147
148/**
149 * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated
150 * as CAMERA_DEVICE_API_VERSION_1_0
151 */
Eino-Ville Talvalad4392022015-11-25 13:51:51 -0800152#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) // DEPRECATED
153#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) // NO LONGER SUPPORTED
154#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) // NO LONGER SUPPORTED
Eino-Ville Talvala18782aa2016-12-19 16:35:29 -0800155#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) // NO LONGER SUPPORTED
156#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) // NO LONGER SUPPORTED
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800157#define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2)
Zhijun Heebdf1282015-01-16 16:44:40 -0800158#define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3)
Yin-Chia Yeh3e0b5f62015-12-07 16:31:09 -0800159#define CAMERA_DEVICE_API_VERSION_3_4 HARDWARE_DEVICE_API_VERSION(3, 4)
Emilian Peeveec2ee92017-11-08 19:33:27 +0000160#define CAMERA_DEVICE_API_VERSION_3_5 HARDWARE_DEVICE_API_VERSION(3, 5)
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -0700161#define CAMERA_DEVICE_API_VERSION_3_6 HARDWARE_DEVICE_API_VERSION(3, 6)
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700162
Emilian Peeveec2ee92017-11-08 19:33:27 +0000163// Device version 3.5 is current, older HAL camera device versions are not
Eino-Ville Talvalab5459832014-09-09 16:42:27 -0700164// recommended for new devices.
Emilian Peeveec2ee92017-11-08 19:33:27 +0000165#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_5
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800166
167/**
James Dongd0ca70d2012-03-26 16:22:35 -0700168 * Defined in /system/media/camera/include/system/camera_metadata.h
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800169 */
170typedef struct camera_metadata camera_metadata_t;
171
Alex Ray9acc7402013-02-07 15:44:24 -0800172typedef struct camera_info {
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800173 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800174 * The direction that the camera faces to. See system/core/include/system/camera.h
175 * for camera facing definitions.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800176 *
Zhijun He94e23b22015-01-12 14:45:33 -0800177 * Version information (based on camera_module_t.common.module_api_version):
178 *
179 * CAMERA_MODULE_API_VERSION_2_3 or lower:
180 *
181 * It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT.
182 *
183 * CAMERA_MODULE_API_VERSION_2_4 or higher:
184 *
185 * It should be CAMERA_FACING_BACK, CAMERA_FACING_FRONT or
186 * CAMERA_FACING_EXTERNAL.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800187 */
188 int facing;
189
190 /**
191 * The orientation of the camera image. The value is the angle that the
192 * camera image needs to be rotated clockwise so it shows correctly on the
193 * display in its natural orientation. It should be 0, 90, 180, or 270.
194 *
195 * For example, suppose a device has a naturally tall screen. The
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800196 * back-facing camera sensor is mounted in landscape. You are looking at the
197 * screen. If the top side of the camera sensor is aligned with the right
198 * edge of the screen in natural orientation, the value should be 90. If the
199 * top side of a front-facing camera sensor is aligned with the right of the
200 * screen, the value should be 270.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800201 *
Zhijun He94e23b22015-01-12 14:45:33 -0800202 * Version information (based on camera_module_t.common.module_api_version):
203 *
204 * CAMERA_MODULE_API_VERSION_2_3 or lower:
205 *
206 * Valid in all camera_module versions.
207 *
208 * CAMERA_MODULE_API_VERSION_2_4 or higher:
209 *
210 * Valid if camera facing is CAMERA_FACING_BACK or CAMERA_FACING_FRONT,
211 * not valid if camera facing is CAMERA_FACING_EXTERNAL.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800212 */
213 int orientation;
214
215 /**
216 * The value of camera_device_t.common.version.
217 *
218 * Version information (based on camera_module_t.common.module_api_version):
219 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700220 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800221 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700222 * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800223 * not read this field.
224 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800225 * CAMERA_MODULE_API_VERSION_2_0 or higher:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800226 *
227 * Always valid
228 *
229 */
230 uint32_t device_version;
231
232 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800233 * The camera's fixed characteristics, which include all static camera metadata
234 * specified in system/media/camera/docs/docs.html. This should be a sorted metadata
235 * buffer, and may not be modified or freed by the caller. The pointer should remain
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800236 * valid for the lifetime of the camera module, and values in it may not
237 * change after it is returned by get_camera_info().
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800238 *
239 * Version information (based on camera_module_t.common.module_api_version):
240 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700241 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800242 *
243 * Not valid. Extra characteristics are not available. Do not read this
244 * field.
245 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800246 * CAMERA_MODULE_API_VERSION_2_0 or higher:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800247 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700248 * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read
249 * otherwise.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800250 *
251 */
Eino-Ville Talvalab8b64392012-08-24 12:32:17 -0700252 const camera_metadata_t *static_camera_characteristics;
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800253
254 /**
Ruben Brunk1fa09022015-03-10 11:53:12 -0700255 * The total resource "cost" of using this camera, represented as an integer
256 * value in the range [0, 100] where 100 represents total usage of the shared
257 * resource that is the limiting bottleneck of the camera subsystem. This may
258 * be a very rough estimate, and is used as a hint to the camera service to
259 * determine when to disallow multiple applications from simultaneously
260 * opening different cameras advertised by the camera service.
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800261 *
262 * The camera service must be able to simultaneously open and use any
263 * combination of camera devices exposed by the HAL where the sum of
264 * the resource costs of these cameras is <= 100. For determining cost,
265 * each camera device must be assumed to be configured and operating at
266 * the maximally resource-consuming framerate and stream size settings
267 * available in the configuration settings exposed for that device through
268 * the camera metadata.
269 *
Ruben Brunk1fa09022015-03-10 11:53:12 -0700270 * The camera service may still attempt to simultaneously open combinations
271 * of camera devices with a total resource cost > 100. This may succeed or
272 * fail. If this succeeds, combinations of configurations that are not
273 * supported due to resource constraints from having multiple open devices
274 * should fail during the configure calls. If the total resource cost is
275 * <= 100, open and configure should never fail for any stream configuration
276 * settings or other device capabilities that would normally succeed for a
277 * device when it is the only open camera device.
278 *
279 * This field will be used to determine whether background applications are
280 * allowed to use this camera device while other applications are using other
281 * camera devices. Note: multiple applications will never be allowed by the
282 * camera service to simultaneously open the same camera device.
283 *
284 * Example use cases:
285 *
286 * Ex. 1: Camera Device 0 = Back Camera
287 * Camera Device 1 = Front Camera
288 * - Using both camera devices causes a large framerate slowdown due to
289 * limited ISP bandwidth.
290 *
291 * Configuration:
292 *
293 * Camera Device 0 - resource_cost = 51
294 * conflicting_devices = null
295 * Camera Device 1 - resource_cost = 51
296 * conflicting_devices = null
297 *
298 * Result:
299 *
300 * Since the sum of the resource costs is > 100, if a higher-priority
301 * application has either device open, no lower-priority applications will be
302 * allowed by the camera service to open either device. If a lower-priority
303 * application is using a device that a higher-priority subsequently attempts
304 * to open, the lower-priority application will be forced to disconnect the
305 * the device.
306 *
307 * If the highest-priority application chooses, it may still attempt to open
308 * both devices (since these devices are not listed as conflicting in the
309 * conflicting_devices fields), but usage of these devices may fail in the
310 * open or configure calls.
311 *
312 * Ex. 2: Camera Device 0 = Left Back Camera
313 * Camera Device 1 = Right Back Camera
314 * Camera Device 2 = Combined stereo camera using both right and left
315 * back camera sensors used by devices 0, and 1
316 * Camera Device 3 = Front Camera
317 * - Due to do hardware constraints, up to two cameras may be open at once. The
318 * combined stereo camera may never be used at the same time as either of the
319 * two back camera devices (device 0, 1), and typically requires too much
320 * bandwidth to use at the same time as the front camera (device 3).
321 *
322 * Configuration:
323 *
324 * Camera Device 0 - resource_cost = 50
325 * conflicting_devices = { 2 }
326 * Camera Device 1 - resource_cost = 50
327 * conflicting_devices = { 2 }
328 * Camera Device 2 - resource_cost = 100
329 * conflicting_devices = { 0, 1 }
330 * Camera Device 3 - resource_cost = 50
331 * conflicting_devices = null
332 *
333 * Result:
334 *
335 * Based on the conflicting_devices fields, the camera service guarantees that
336 * the following sets of open devices will never be allowed: { 1, 2 }, { 0, 2 }.
337 *
338 * Based on the resource_cost fields, if a high-priority foreground application
339 * is using camera device 0, a background application would be allowed to open
340 * camera device 1 or 3 (but would be forced to disconnect it again if the
341 * foreground application opened another device).
342 *
343 * The highest priority application may still attempt to simultaneously open
344 * devices 0, 2, and 3, but the HAL may fail in open or configure calls for
345 * this combination.
346 *
347 * Ex. 3: Camera Device 0 = Back Camera
348 * Camera Device 1 = Front Camera
349 * Camera Device 2 = Low-power Front Camera that uses the same
350 * sensor as device 1, but only exposes image stream
351 * resolutions that can be used in low-power mode
352 * - Using both front cameras (device 1, 2) at the same time is impossible due
353 * a shared physical sensor. Using the back and "high-power" front camera
354 * (device 1) may be impossible for some stream configurations due to hardware
355 * limitations, but the "low-power" front camera option may always be used as
356 * it has special dedicated hardware.
357 *
358 * Configuration:
359 *
360 * Camera Device 0 - resource_cost = 100
361 * conflicting_devices = null
362 * Camera Device 1 - resource_cost = 100
363 * conflicting_devices = { 2 }
364 * Camera Device 2 - resource_cost = 0
365 * conflicting_devices = { 1 }
366 * Result:
367 *
368 * Based on the conflicting_devices fields, the camera service guarantees that
369 * the following sets of open devices will never be allowed: { 1, 2 }.
370 *
371 * Based on the resource_cost fields, only the highest priority application
372 * may attempt to open both device 0 and 1 at the same time. If a higher-priority
373 * application is not using device 1 or 2, a low-priority background application
374 * may open device 2 (but will be forced to disconnect it if a higher-priority
375 * application subsequently opens device 1 or 2).
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800376 *
377 * Version information (based on camera_module_t.common.module_api_version):
378 *
379 * CAMERA_MODULE_API_VERSION_2_3 or lower:
380 *
381 * Not valid. Can be assumed to be 100. Do not read this field.
382 *
383 * CAMERA_MODULE_API_VERSION_2_4 or higher:
384 *
385 * Always valid.
386 */
387 int resource_cost;
388
389 /**
390 * An array of camera device IDs represented as NULL-terminated strings
391 * indicating other devices that cannot be simultaneously opened while this
392 * camera device is in use.
393 *
394 * This field is intended to be used to indicate that this camera device
395 * is a composite of several other camera devices, or otherwise has
396 * hardware dependencies that prohibit simultaneous usage. If there are no
397 * dependencies, a NULL may be returned in this field to indicate this.
398 *
399 * The camera service will never simultaneously open any of the devices
400 * in this list while this camera device is open.
401 *
Ruben Brunk1fa09022015-03-10 11:53:12 -0700402 * The strings pointed to in this field will not be cleaned up by the camera
403 * service, and must remain while this device is plugged in.
404 *
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800405 * Version information (based on camera_module_t.common.module_api_version):
406 *
407 * CAMERA_MODULE_API_VERSION_2_3 or lower:
408 *
409 * Not valid. Can be assumed to be NULL. Do not read this field.
410 *
411 * CAMERA_MODULE_API_VERSION_2_4 or higher:
412 *
413 * Always valid.
414 */
415 char** conflicting_devices;
416
417 /**
418 * The length of the array given in the conflicting_devices field.
419 *
420 * Version information (based on camera_module_t.common.module_api_version):
421 *
422 * CAMERA_MODULE_API_VERSION_2_3 or lower:
423 *
424 * Not valid. Can be assumed to be 0. Do not read this field.
425 *
426 * CAMERA_MODULE_API_VERSION_2_4 or higher:
427 *
428 * Always valid.
429 */
430 size_t conflicting_devices_length;
431
Alex Ray9acc7402013-02-07 15:44:24 -0800432} camera_info_t;
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800433
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800434/**
435 * camera_device_status_t:
436 *
437 * The current status of the camera device, as provided by the HAL through the
438 * camera_module_callbacks.camera_device_status_change() call.
Igor Murashkin152b50f2013-03-18 13:30:14 -0700439 *
440 * At module load time, the framework will assume all camera devices are in the
441 * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke
442 * camera_module_callbacks::camera_device_status_change to inform the framework
443 * of any initially NOT_PRESENT devices.
444 *
445 * Allowed transitions:
446 * PRESENT -> NOT_PRESENT
447 * NOT_PRESENT -> ENUMERATING
448 * NOT_PRESENT -> PRESENT
449 * ENUMERATING -> PRESENT
450 * ENUMERATING -> NOT_PRESENT
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800451 */
452typedef enum camera_device_status {
453 /**
454 * The camera device is not currently connected, and opening it will return
Zhijun He94e23b22015-01-12 14:45:33 -0800455 * failure.
456 *
457 * Version information (based on camera_module_t.common.module_api_version):
458 *
459 * CAMERA_MODULE_API_VERSION_2_3 or lower:
460 *
461 * Calls to get_camera_info must still succeed, and provide the same information
462 * it would if the camera were connected.
463 *
464 * CAMERA_MODULE_API_VERSION_2_4:
465 *
466 * The camera device at this status must return -EINVAL for get_camera_info call,
467 * as the device is not connected.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800468 */
469 CAMERA_DEVICE_STATUS_NOT_PRESENT = 0,
470
471 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800472 * The camera device is connected, and opening it will succeed.
473 *
474 * CAMERA_MODULE_API_VERSION_2_3 or lower:
475 *
476 * The information returned by get_camera_info cannot change due to this status
477 * change. By default, the framework will assume all devices are in this state.
478 *
479 * CAMERA_MODULE_API_VERSION_2_4:
480 *
481 * The information returned by get_camera_info will become valid after a device's
482 * status changes to this. By default, the framework will assume all devices are in
483 * this state.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800484 */
Igor Murashkin152b50f2013-03-18 13:30:14 -0700485 CAMERA_DEVICE_STATUS_PRESENT = 1,
486
487 /**
488 * The camera device is connected, but it is undergoing an enumeration and
Zhijun He94e23b22015-01-12 14:45:33 -0800489 * so opening the device will return -EBUSY.
490 *
491 * CAMERA_MODULE_API_VERSION_2_3 or lower:
492 *
493 * Calls to get_camera_info must still succeed, as if the camera was in the
494 * PRESENT status.
495 *
496 * CAMERA_MODULE_API_VERSION_2_4:
497 *
498 * The camera device at this status must return -EINVAL for get_camera_info for call,
499 * as the device is not ready.
Igor Murashkin152b50f2013-03-18 13:30:14 -0700500 */
501 CAMERA_DEVICE_STATUS_ENUMERATING = 2,
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800502
503} camera_device_status_t;
504
505/**
Chien-Yu Chen30159172015-01-08 11:06:38 -0800506 * torch_mode_status_t:
507 *
508 * The current status of the torch mode, as provided by the HAL through the
509 * camera_module_callbacks.torch_mode_status_change() call.
510 *
511 * The torch mode status of a camera device is applicable only when the camera
512 * device is present. The framework will not call set_torch_mode() to turn on
513 * torch mode of a camera device if the camera device is not present. At module
514 * load time, the framework will assume torch modes are in the
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700515 * TORCH_MODE_STATUS_AVAILABLE_OFF state if the camera device is present and
Chien-Yu Chen30159172015-01-08 11:06:38 -0800516 * android.flash.info.available is reported as true via get_camera_info() call.
517 *
518 * The behaviors of the camera HAL module that the framework expects in the
519 * following situations when a camera device's status changes:
520 * 1. A previously-disconnected camera device becomes connected.
521 * After camera_module_callbacks::camera_device_status_change() is invoked
522 * to inform the framework that the camera device is present, the framework
523 * will assume the camera device's torch mode is in
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700524 * TORCH_MODE_STATUS_AVAILABLE_OFF state. The camera HAL module does not need
Chien-Yu Chen30159172015-01-08 11:06:38 -0800525 * to invoke camera_module_callbacks::torch_mode_status_change() unless the
526 * flash unit is unavailable to use by set_torch_mode().
527 *
528 * 2. A previously-connected camera becomes disconnected.
529 * After camera_module_callbacks::camera_device_status_change() is invoked
530 * to inform the framework that the camera device is not present, the
531 * framework will not call set_torch_mode() for the disconnected camera
532 * device until its flash unit becomes available again. The camera HAL
533 * module does not need to invoke
534 * camera_module_callbacks::torch_mode_status_change() separately to inform
535 * that the flash unit has become unavailable.
536 *
537 * 3. open() is called to open a camera device.
538 * The camera HAL module must invoke
539 * camera_module_callbacks::torch_mode_status_change() for all flash units
Chien-Yu Chen85585102015-02-25 14:50:13 -0800540 * that have entered TORCH_MODE_STATUS_NOT_AVAILABLE state and can not be
Chien-Yu Chen30159172015-01-08 11:06:38 -0800541 * turned on by calling set_torch_mode() anymore due to this open() call.
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700542 * open() must not trigger TORCH_MODE_STATUS_AVAILABLE_OFF before
543 * TORCH_MODE_STATUS_NOT_AVAILABLE for all flash units that have become
544 * unavailable.
Chien-Yu Chen30159172015-01-08 11:06:38 -0800545 *
546 * 4. close() is called to close a camera device.
547 * The camera HAL module must invoke
548 * camera_module_callbacks::torch_mode_status_change() for all flash units
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700549 * that have entered TORCH_MODE_STATUS_AVAILABLE_OFF state and can be turned
Chien-Yu Chen30159172015-01-08 11:06:38 -0800550 * on by calling set_torch_mode() again because of enough resources freed
551 * up by this close() call.
552 *
Chien-Yu Chen85585102015-02-25 14:50:13 -0800553 * Note that the framework calling set_torch_mode() successfully must trigger
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700554 * TORCH_MODE_STATUS_AVAILABLE_OFF or TORCH_MODE_STATUS_AVAILABLE_ON callback
555 * for the given camera device. Additionally it must trigger
556 * TORCH_MODE_STATUS_AVAILABLE_OFF callbacks for other previously-on torch
557 * modes if HAL cannot keep multiple torch modes on simultaneously.
Chien-Yu Chen30159172015-01-08 11:06:38 -0800558 */
559typedef enum torch_mode_status {
Chien-Yu Chen30159172015-01-08 11:06:38 -0800560
561 /**
562 * The flash unit is no longer available and the torch mode can not be
563 * turned on by calling set_torch_mode(). If the torch mode is on, it
564 * will be turned off by HAL before HAL calls torch_mode_status_change().
565 */
Chien-Yu Chen85585102015-02-25 14:50:13 -0800566 TORCH_MODE_STATUS_NOT_AVAILABLE = 0,
Chien-Yu Chen30159172015-01-08 11:06:38 -0800567
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800568 /**
Chien-Yu Chen85585102015-02-25 14:50:13 -0800569 * A torch mode has become off and available to be turned on via
570 * set_torch_mode(). This may happen in the following
571 * cases:
572 * 1. After the resources to turn on the torch mode have become available.
573 * 2. After set_torch_mode() is called to turn off the torch mode.
574 * 3. After the framework turned on the torch mode of some other camera
575 * device and HAL had to turn off the torch modes of any camera devices
576 * that were previously on.
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800577 */
Chien-Yu Chen85585102015-02-25 14:50:13 -0800578 TORCH_MODE_STATUS_AVAILABLE_OFF = 1,
579
580 /**
581 * A torch mode has become on and available to be turned off via
582 * set_torch_mode(). This can happen only after set_torch_mode() is called
583 * to turn on the torch mode.
584 */
585 TORCH_MODE_STATUS_AVAILABLE_ON = 2,
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800586
Chien-Yu Chen30159172015-01-08 11:06:38 -0800587} torch_mode_status_t;
588
589/**
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800590 * Callback functions for the camera HAL module to use to inform the framework
Chien-Yu Chen30159172015-01-08 11:06:38 -0800591 * of changes to the camera subsystem.
592 *
593 * Version information (based on camera_module_t.common.module_api_version):
594 *
595 * Each callback is called only by HAL modules implementing the indicated
596 * version or higher of the HAL module API interface.
597 *
598 * CAMERA_MODULE_API_VERSION_2_1:
599 * camera_device_status_change()
600 *
601 * CAMERA_MODULE_API_VERSION_2_4:
602 * torch_mode_status_change()
603
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800604 */
605typedef struct camera_module_callbacks {
606
607 /**
608 * camera_device_status_change:
609 *
610 * Callback to the framework to indicate that the state of a specific camera
611 * device has changed. At module load time, the framework will assume all
612 * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL
613 * must call this method to inform the framework of any initially
614 * NOT_PRESENT devices.
615 *
Chien-Yu Chen30159172015-01-08 11:06:38 -0800616 * This callback is added for CAMERA_MODULE_API_VERSION_2_1.
617 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800618 * camera_module_callbacks: The instance of camera_module_callbacks_t passed
619 * to the module with set_callbacks.
620 *
621 * camera_id: The ID of the camera device that has a new status.
622 *
623 * new_status: The new status code, one of the camera_device_status_t enums,
624 * or a platform-specific status.
625 *
626 */
627 void (*camera_device_status_change)(const struct camera_module_callbacks*,
628 int camera_id,
629 int new_status);
630
Chien-Yu Chen30159172015-01-08 11:06:38 -0800631 /**
632 * torch_mode_status_change:
633 *
634 * Callback to the framework to indicate that the state of the torch mode
635 * of the flash unit associated with a specific camera device has changed.
636 * At module load time, the framework will assume the torch modes are in
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700637 * the TORCH_MODE_STATUS_AVAILABLE_OFF state if android.flash.info.available
Chien-Yu Chen30159172015-01-08 11:06:38 -0800638 * is reported as true via get_camera_info() call.
639 *
640 * This callback is added for CAMERA_MODULE_API_VERSION_2_4.
641 *
642 * camera_module_callbacks: The instance of camera_module_callbacks_t
643 * passed to the module with set_callbacks.
644 *
645 * camera_id: The ID of camera device whose flash unit has a new torch mode
646 * status.
647 *
648 * new_status: The new status code, one of the torch_mode_status_t enums.
649 */
650 void (*torch_mode_status_change)(const struct camera_module_callbacks*,
651 const char* camera_id,
652 int new_status);
653
654
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800655} camera_module_callbacks_t;
656
Emilian Peev8ca3c602018-10-29 09:37:04 +0000657/**
658 * camera_stream_t:
659 *
660 * A handle to a single camera input or output stream. A stream is defined by
661 * the framework by its buffer resolution and format and gralloc usage flags.
662 *
663 * The stream structures are owned by the framework and pointers to a
664 * camera_stream passed into the HAL by is_stream_combination_supported() are
665 * only valid within the scope of the call.
666 *
667 * All camera_stream members are immutable.
668 */
669typedef struct camera_stream {
670 /**
671 * The type of the stream, one of the camera3_stream_type_t values.
672 */
673 int stream_type;
674
675 /**
676 * The width in pixels of the buffers in this stream
677 */
678 uint32_t width;
679
680 /**
681 * The height in pixels of the buffers in this stream
682 */
683 uint32_t height;
684
685 /**
686 * The pixel format for the buffers in this stream. Format is a value from
687 * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or
688 * from device-specific headers.
689 *
690 * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
691 * gralloc module will select a format based on the usage flags provided by
692 * the camera device and the other endpoint of the stream.
693 *
694 */
695 int format;
696
697 /**
698 * The gralloc usage flags for this stream, as needed by the HAL. The usage
699 * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific
700 * headers.
701 *
702 * For output streams, these are the HAL's producer usage flags. For input
703 * streams, these are the HAL's consumer usage flags. The usage flags from
704 * the producer and the consumer will be combined together and then passed
705 * to the platform gralloc HAL module for allocating the gralloc buffers for
706 * each stream.
707 *
708 * The usage flag for an output stream may be bitwise
709 * combination of usage flags for multiple consumers, for the purpose of
710 * sharing one camera stream between those consumers. The HAL must fail
711 * the stream combination query call with -EINVAL if the combined flags cannot be
712 * supported due to imcompatible buffer format, dataSpace, or other hardware
713 * limitations.
714 */
715 uint32_t usage;
716
717 /**
718 * A field that describes the contents of the buffer. The format and buffer
719 * dimensions define the memory layout and structure of the stream buffers,
720 * while dataSpace defines the meaning of the data within the buffer.
721 *
722 * For most formats, dataSpace defines the color space of the image data.
723 * In addition, for some formats, dataSpace indicates whether image- or
724 * depth-based data is requested. See system/core/include/system/graphics.h
725 * for details of formats and valid dataSpace values for each format.
726 *
727 * Always set by the camera service. The dataspace values are set
728 * using the V0 dataspace definitions in graphics.h
729 */
730 android_dataspace_t data_space;
731
732 /**
733 * The required output rotation of the stream, one of
734 * the camera3_stream_rotation_t values. This must be inspected by HAL along
735 * with stream width and height. For example, if the rotation is 90 degree
736 * and the stream width and height is 720 and 1280 respectively, camera service
737 * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image
738 * and rotate the image by 90 degree counterclockwise. The rotation field is
739 * no-op when the stream type is input. Camera HAL must ignore the rotation
740 * field for an input stream.
741 *
742 * Always set by camera service. HAL must inspect this field during stream
743 * combination query and return -EINVAL if it cannot perform such rotation.
744 * HAL must always support CAMERA3_STREAM_ROTATION_0, so a
745 * is_stream_combination_supported() call must not fail for unsupported rotation if
746 * rotation field of all streams is CAMERA3_STREAM_ROTATION_0.
747 *
748 */
749 int rotation;
750
751 /**
752 * The physical camera id this stream belongs to.
753 * Always set by camera service. If the camera device is not a logical
754 * multi camera, or if the camera is a logical multi camera but the stream
755 * is not a physical output stream, this field will point to a 0-length
756 * string.
757 *
758 * A logical multi camera is a camera device backed by multiple physical
759 * cameras that are also exposed to the application. And for a logical
760 * multi camera, a physical output stream is an output stream specifically
761 * requested on an underlying physical camera.
762 *
763 * For an input stream, this field is guaranteed to be a 0-length string.
764 */
765 const char* physical_camera_id;
766
767} camera_stream_t;
768
769/**
770 * camera_stream_combination_t:
771 *
772 * A structure of stream definitions, used by is_stream_combination_supported(). This
773 * structure defines all the input & output streams for specific camera use case.
774 */
775typedef struct camera_stream_combination {
776 /**
777 * The total number of streams by the framework. This includes
778 * both input and output streams. The number of streams will be at least 1,
779 * and there will be at least one output-capable stream.
780 */
781 uint32_t num_streams;
782
783 /**
784 * An array of camera streams, defining the input/output
785 * stream combination for the camera HAL device.
786 *
787 * At most one input-capable stream may be defined.
788 *
789 * At least one output-capable stream must be defined.
790 */
791 camera_stream_t *streams;
792
793 /**
794 * The operation mode of streams in this stream combination, one of the value
795 * defined in camera3_stream_configuration_mode_t.
796 *
797 */
798 uint32_t operation_mode;
799
800} camera_stream_combination_t;
801
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800802typedef struct camera_module {
Stewart Miles84d35492014-05-01 09:03:27 -0700803 /**
804 * Common methods of the camera module. This *must* be the first member of
805 * camera_module as users of this structure will cast a hw_module_t to
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700806 * camera_module pointer in contexts where it's known the hw_module_t
807 * references a camera_module.
808 *
809 * The return values for common.methods->open for camera_module are:
810 *
811 * 0: On a successful open of the camera device.
812 *
813 * -ENODEV: The camera device cannot be opened due to an internal
814 * error.
815 *
816 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
817 * and/or the module is invalid.
818 *
819 * -EBUSY: The camera device was already opened for this camera id
820 * (by using this method or open_legacy),
821 * regardless of the device HAL version it was opened as.
822 *
823 * -EUSERS: The maximal number of camera devices that can be
824 * opened concurrently were opened already, either by
825 * this method or the open_legacy method.
826 *
827 * All other return values from common.methods->open will be treated as
828 * -ENODEV.
Stewart Miles84d35492014-05-01 09:03:27 -0700829 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800830 hw_module_t common;
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800831
832 /**
833 * get_number_of_cameras:
834 *
835 * Returns the number of camera devices accessible through the camera
836 * module. The camera devices are numbered 0 through N-1, where N is the
837 * value returned by this call. The name of the camera device for open() is
838 * simply the number converted to a string. That is, "0" for camera ID 0,
839 * "1" for camera ID 1.
840 *
Zhijun He94e23b22015-01-12 14:45:33 -0800841 * Version information (based on camera_module_t.common.module_api_version):
842 *
843 * CAMERA_MODULE_API_VERSION_2_3 or lower:
844 *
845 * The value here must be static, and cannot change after the first call
846 * to this method.
847 *
848 * CAMERA_MODULE_API_VERSION_2_4 or higher:
849 *
850 * The value here must be static, and must count only built-in cameras,
851 * which have CAMERA_FACING_BACK or CAMERA_FACING_FRONT camera facing values
852 * (camera_info.facing). The HAL must not include the external cameras
853 * (camera_info.facing == CAMERA_FACING_EXTERNAL) into the return value
854 * of this call. Frameworks will use camera_device_status_change callback
855 * to manage number of external cameras.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800856 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800857 int (*get_number_of_cameras)(void);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800858
859 /**
860 * get_camera_info:
861 *
862 * Return the static camera information for a given camera device. This
863 * information may not change for a camera device.
864 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700865 * Return values:
866 *
867 * 0: On a successful operation
868 *
869 * -ENODEV: The information cannot be provided due to an internal
870 * error.
871 *
872 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
873 * and/or the module is invalid.
Zhijun He94e23b22015-01-12 14:45:33 -0800874 *
875 * Version information (based on camera_module_t.common.module_api_version):
876 *
877 * CAMERA_MODULE_API_VERSION_2_4 or higher:
878 *
879 * When a camera is disconnected, its camera id becomes invalid. Calling this
880 * this method with this invalid camera id will get -EINVAL and NULL camera
881 * static metadata (camera_info.static_camera_characteristics).
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800882 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800883 int (*get_camera_info)(int camera_id, struct camera_info *info);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800884
885 /**
886 * set_callbacks:
887 *
888 * Provide callback function pointers to the HAL module to inform framework
889 * of asynchronous camera module events. The framework will call this
890 * function once after initial camera HAL module load, after the
891 * get_number_of_cameras() method is called for the first time, and before
892 * any other calls to the module.
893 *
894 * Version information (based on camera_module_t.common.module_api_version):
895 *
896 * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0:
897 *
898 * Not provided by HAL module. Framework may not call this function.
899 *
900 * CAMERA_MODULE_API_VERSION_2_1:
901 *
902 * Valid to be called by the framework.
903 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700904 * Return values:
905 *
906 * 0: On a successful operation
907 *
908 * -ENODEV: The operation cannot be completed due to an internal
909 * error.
910 *
911 * -EINVAL: The input arguments are invalid, i.e. the callbacks are
912 * null
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800913 */
914 int (*set_callbacks)(const camera_module_callbacks_t *callbacks);
915
Alex Ray19b2cea2013-06-13 12:40:52 -0700916 /**
917 * get_vendor_tag_ops:
918 *
919 * Get methods to query for vendor extension metadata tag information. The
920 * HAL should fill in all the vendor tag operation methods, or leave ops
921 * unchanged if no vendor tags are defined.
922 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800923 * The vendor_tag_ops structure used here is defined in:
924 * system/media/camera/include/system/vendor_tags.h
925 *
Alex Ray19b2cea2013-06-13 12:40:52 -0700926 * Version information (based on camera_module_t.common.module_api_version):
927 *
928 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1:
929 * Not provided by HAL module. Framework may not call this function.
930 *
931 * CAMERA_MODULE_API_VERSION_2_2:
932 * Valid to be called by the framework.
933 */
934 void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops);
935
Zhijun Hebcdebf32014-06-06 15:42:17 -0700936 /**
937 * open_legacy:
938 *
939 * Open a specific legacy camera HAL device if multiple device HAL API
940 * versions are supported by this camera HAL module. For example, if the
941 * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and
942 * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id,
943 * framework can call this function to open the camera device as
944 * CAMERA_DEVICE_API_VERSION_1_0 device.
945 *
946 * This is an optional method. A Camera HAL module does not need to support
947 * more than one device HAL version per device, and such modules may return
948 * -ENOSYS for all calls to this method. For all older HAL device API
949 * versions that are not supported, it may return -EOPNOTSUPP. When above
950 * cases occur, The normal open() method (common.methods->open) will be
951 * used by the framework instead.
952 *
953 * Version information (based on camera_module_t.common.module_api_version):
954 *
955 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2:
956 * Not provided by HAL module. Framework will not call this function.
957 *
958 * CAMERA_MODULE_API_VERSION_2_3:
959 * Valid to be called by the framework.
960 *
961 * Return values:
962 *
963 * 0: On a successful open of the camera device.
964 *
965 * -ENOSYS This method is not supported.
966 *
967 * -EOPNOTSUPP: The requested HAL version is not supported by this method.
968 *
969 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
970 * and/or the module is invalid.
971 *
972 * -EBUSY: The camera device was already opened for this camera id
973 * (by using this method or common.methods->open method),
974 * regardless of the device HAL version it was opened as.
975 *
976 * -EUSERS: The maximal number of camera devices that can be
977 * opened concurrently were opened already, either by
978 * this method or common.methods->open method.
979 */
980 int (*open_legacy)(const struct hw_module_t* module, const char* id,
981 uint32_t halVersion, struct hw_device_t** device);
982
Chien-Yu Chen30159172015-01-08 11:06:38 -0800983 /**
984 * set_torch_mode:
985 *
986 * Turn on or off the torch mode of the flash unit associated with a given
Chien-Yu Chen85585102015-02-25 14:50:13 -0800987 * camera ID. If the operation is successful, HAL must notify the framework
988 * torch state by invoking
989 * camera_module_callbacks.torch_mode_status_change() with the new state.
Chien-Yu Chen30159172015-01-08 11:06:38 -0800990 *
991 * The camera device has a higher priority accessing the flash unit. When
992 * there are any resource conflicts, such as open() is called to open a
993 * camera device, HAL module must notify the framework through
994 * camera_module_callbacks.torch_mode_status_change() that the
995 * torch mode has been turned off and the torch mode state has become
Chien-Yu Chen85585102015-02-25 14:50:13 -0800996 * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode
Chien-Yu Chen30159172015-01-08 11:06:38 -0800997 * become available again, HAL module must notify the framework through
998 * camera_module_callbacks.torch_mode_status_change() that the torch mode
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700999 * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to
1000 * be called.
Chien-Yu Chen30159172015-01-08 11:06:38 -08001001 *
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -08001002 * When the framework calls set_torch_mode() to turn on the torch mode of a
1003 * flash unit, if HAL cannot keep multiple torch modes on simultaneously,
1004 * HAL should turn off the torch mode that was turned on by
1005 * a previous set_torch_mode() call and notify the framework that the torch
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -07001006 * mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF.
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -08001007 *
Chien-Yu Chen30159172015-01-08 11:06:38 -08001008 * Version information (based on camera_module_t.common.module_api_version):
1009 *
1010 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
1011 * Not provided by HAL module. Framework will not call this function.
1012 *
1013 * CAMERA_MODULE_API_VERSION_2_4:
1014 * Valid to be called by the framework.
1015 *
1016 * Return values:
1017 *
1018 * 0: On a successful operation.
1019 *
1020 * -ENOSYS: The camera device does not support this operation. It is
1021 * returned if and only if android.flash.info.available is
1022 * false.
1023 *
Chien-Yu Chen273def32015-02-11 11:31:12 -08001024 * -EBUSY: The camera device is already in use.
1025 *
1026 * -EUSERS: The resources needed to turn on the torch mode are not
1027 * available, typically because other camera devices are
1028 * holding the resources to make using the flash unit not
1029 * possible.
Chien-Yu Chen30159172015-01-08 11:06:38 -08001030 *
1031 * -EINVAL: camera_id is invalid.
1032 *
1033 */
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -08001034 int (*set_torch_mode)(const char* camera_id, bool enabled);
Chien-Yu Chen30159172015-01-08 11:06:38 -08001035
Eino-Ville Talvalaaee47822015-04-07 13:47:46 -07001036 /**
1037 * init:
1038 *
1039 * This method is called by the camera service before any other methods
1040 * are invoked, right after the camera HAL library has been successfully
1041 * loaded. It may be left as NULL by the HAL module, if no initialization
1042 * in needed.
1043 *
1044 * It can be used by HAL implementations to perform initialization and
1045 * other one-time operations.
1046 *
1047 * Version information (based on camera_module_t.common.module_api_version):
1048 *
1049 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
1050 * Not provided by HAL module. Framework will not call this function.
1051 *
1052 * CAMERA_MODULE_API_VERSION_2_4:
1053 * If not NULL, will always be called by the framework once after the HAL
1054 * module is loaded, before any other HAL module method is called.
1055 *
1056 * Return values:
1057 *
1058 * 0: On a successful operation.
1059 *
1060 * -ENODEV: Initialization cannot be completed due to an internal
1061 * error. The HAL must be assumed to be in a nonfunctional
1062 * state.
1063 *
1064 */
1065 int (*init)();
1066
Shuzhen Wanga8caa6a2018-08-24 11:07:50 -07001067 /**
1068 * get_physical_camera_info:
1069 *
1070 * Return the static metadata for a physical camera as a part of a logical
1071 * camera device. This function is only called for those physical camera
1072 * ID(s) that are not exposed independently. In other words, camera_id will
1073 * be greater or equal to the return value of get_number_of_cameras().
1074 *
1075 * Return values:
1076 *
1077 * 0: On a successful operation
1078 *
1079 * -ENODEV: The information cannot be provided due to an internal
1080 * error.
1081 *
1082 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
1083 * and/or the module is invalid.
1084 *
1085 * Version information (based on camera_module_t.common.module_api_version):
1086 *
1087 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3/2_4:
1088 * Not provided by HAL module. Framework will not call this function.
1089 *
1090 * CAMERA_MODULE_API_VERSION_2_5 or higher:
1091 * If any of the camera devices accessible through this camera module is
1092 * a logical multi-camera, and at least one of the physical cameras isn't
1093 * a stand-alone camera device, this function will be called by the camera
1094 * framework. Calling this function with invalid physical_camera_id will
1095 * get -EINVAL, and NULL static_metadata.
1096 */
1097 int (*get_physical_camera_info)(int physical_camera_id,
1098 camera_metadata_t **static_metadata);
1099
Emilian Peev8ca3c602018-10-29 09:37:04 +00001100 /**
1101 * is_stream_combination_supported:
1102 *
1103 * Check for device support of specific camera stream combination.
1104 *
1105 * Return values:
1106 *
1107 * 0: In case the stream combination is supported.
1108 *
1109 * -EINVAL: In case the stream combination is not supported.
1110 *
1111 * -ENOSYS: In case stream combination query is not supported.
1112 *
1113 * Version information (based on camera_module_t.common.module_api_version):
1114 *
1115 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3/2_4:
1116 * Not provided by HAL module. Framework will not call this function.
1117 *
1118 * CAMERA_MODULE_API_VERSION_2_5 or higher:
1119 * Valid to be called by the framework.
1120 */
1121 int (*is_stream_combination_supported)(int camera_id,
1122 const camera_stream_combination_t *streams);
1123
Alex Ray19b2cea2013-06-13 12:40:52 -07001124 /* reserved for future use */
Emilian Peev8ca3c602018-10-29 09:37:04 +00001125 void* reserved[3];
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -08001126} camera_module_t;
1127
1128__END_DECLS
1129
1130#endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */