blob: 261cbf8d8fe568300117062975f2defcbbf0e1a3 [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 *
Shuzhen Wangfc590b62018-12-26 14:34:56 -0800124 * This camera module version adds below API changes:
Shuzhen Wanga8caa6a2018-08-24 11:07:50 -0700125 *
Shuzhen Wangfc590b62018-12-26 14:34:56 -0800126 * 1. Support to query characteristics of a non-standalone physical camera, which can
127 * only be accessed as part of a logical camera. It also adds camera stream combination
128 * query.
129 *
130 * 2. Ability to query whether a particular camera stream combination is
131 * supported by the camera device.
132 *
133 * 3. Device state change notification. This module version also supports
134 * notification about the overall device state change, such as
135 * folding/unfolding, or covering/uncovering of shutter.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800136 */
137
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700138/**
139 * Predefined macros for currently-defined version numbers
140 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800141
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700142/**
143 * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated
144 * as CAMERA_MODULE_API_VERSION_1_0
145 */
146#define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
147#define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800148#define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1)
Alex Ray19b2cea2013-06-13 12:40:52 -0700149#define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2)
Zhijun Hebcdebf32014-06-06 15:42:17 -0700150#define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3)
Chien-Yu Chen30159172015-01-08 11:06:38 -0800151#define CAMERA_MODULE_API_VERSION_2_4 HARDWARE_MODULE_API_VERSION(2, 4)
Shuzhen Wanga8caa6a2018-08-24 11:07:50 -0700152#define CAMERA_MODULE_API_VERSION_2_5 HARDWARE_MODULE_API_VERSION(2, 5)
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700153
Shuzhen Wanga8caa6a2018-08-24 11:07:50 -0700154#define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_5
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700155
156/**
157 * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated
158 * as CAMERA_DEVICE_API_VERSION_1_0
159 */
Eino-Ville Talvalad4392022015-11-25 13:51:51 -0800160#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) // DEPRECATED
161#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) // NO LONGER SUPPORTED
162#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) // NO LONGER SUPPORTED
Eino-Ville Talvala18782aa2016-12-19 16:35:29 -0800163#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) // NO LONGER SUPPORTED
164#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) // NO LONGER SUPPORTED
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800165#define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2)
Zhijun Heebdf1282015-01-16 16:44:40 -0800166#define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3)
Yin-Chia Yeh3e0b5f62015-12-07 16:31:09 -0800167#define CAMERA_DEVICE_API_VERSION_3_4 HARDWARE_DEVICE_API_VERSION(3, 4)
Emilian Peeveec2ee92017-11-08 19:33:27 +0000168#define CAMERA_DEVICE_API_VERSION_3_5 HARDWARE_DEVICE_API_VERSION(3, 5)
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700169
Emilian Peeveec2ee92017-11-08 19:33:27 +0000170// Device version 3.5 is current, older HAL camera device versions are not
Eino-Ville Talvalab5459832014-09-09 16:42:27 -0700171// recommended for new devices.
Emilian Peeveec2ee92017-11-08 19:33:27 +0000172#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_5
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800173
174/**
James Dongd0ca70d2012-03-26 16:22:35 -0700175 * Defined in /system/media/camera/include/system/camera_metadata.h
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800176 */
177typedef struct camera_metadata camera_metadata_t;
178
Alex Ray9acc7402013-02-07 15:44:24 -0800179typedef struct camera_info {
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800180 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800181 * The direction that the camera faces to. See system/core/include/system/camera.h
182 * for camera facing definitions.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800183 *
Zhijun He94e23b22015-01-12 14:45:33 -0800184 * Version information (based on camera_module_t.common.module_api_version):
185 *
186 * CAMERA_MODULE_API_VERSION_2_3 or lower:
187 *
188 * It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT.
189 *
190 * CAMERA_MODULE_API_VERSION_2_4 or higher:
191 *
192 * It should be CAMERA_FACING_BACK, CAMERA_FACING_FRONT or
193 * CAMERA_FACING_EXTERNAL.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800194 */
195 int facing;
196
197 /**
198 * The orientation of the camera image. The value is the angle that the
199 * camera image needs to be rotated clockwise so it shows correctly on the
200 * display in its natural orientation. It should be 0, 90, 180, or 270.
201 *
202 * For example, suppose a device has a naturally tall screen. The
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800203 * back-facing camera sensor is mounted in landscape. You are looking at the
204 * screen. If the top side of the camera sensor is aligned with the right
205 * edge of the screen in natural orientation, the value should be 90. If the
206 * top side of a front-facing camera sensor is aligned with the right of the
207 * screen, the value should be 270.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800208 *
Zhijun He94e23b22015-01-12 14:45:33 -0800209 * Version information (based on camera_module_t.common.module_api_version):
210 *
211 * CAMERA_MODULE_API_VERSION_2_3 or lower:
212 *
213 * Valid in all camera_module versions.
214 *
215 * CAMERA_MODULE_API_VERSION_2_4 or higher:
216 *
217 * Valid if camera facing is CAMERA_FACING_BACK or CAMERA_FACING_FRONT,
218 * not valid if camera facing is CAMERA_FACING_EXTERNAL.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800219 */
220 int orientation;
221
222 /**
223 * The value of camera_device_t.common.version.
224 *
225 * Version information (based on camera_module_t.common.module_api_version):
226 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700227 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800228 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700229 * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800230 * not read this field.
231 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800232 * CAMERA_MODULE_API_VERSION_2_0 or higher:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800233 *
234 * Always valid
235 *
236 */
237 uint32_t device_version;
238
239 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800240 * The camera's fixed characteristics, which include all static camera metadata
241 * specified in system/media/camera/docs/docs.html. This should be a sorted metadata
242 * buffer, and may not be modified or freed by the caller. The pointer should remain
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800243 * valid for the lifetime of the camera module, and values in it may not
244 * change after it is returned by get_camera_info().
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800245 *
246 * Version information (based on camera_module_t.common.module_api_version):
247 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700248 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800249 *
250 * Not valid. Extra characteristics are not available. Do not read this
251 * field.
252 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800253 * CAMERA_MODULE_API_VERSION_2_0 or higher:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800254 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700255 * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read
256 * otherwise.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800257 *
258 */
Eino-Ville Talvalab8b64392012-08-24 12:32:17 -0700259 const camera_metadata_t *static_camera_characteristics;
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800260
261 /**
Ruben Brunk1fa09022015-03-10 11:53:12 -0700262 * The total resource "cost" of using this camera, represented as an integer
263 * value in the range [0, 100] where 100 represents total usage of the shared
264 * resource that is the limiting bottleneck of the camera subsystem. This may
265 * be a very rough estimate, and is used as a hint to the camera service to
266 * determine when to disallow multiple applications from simultaneously
267 * opening different cameras advertised by the camera service.
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800268 *
269 * The camera service must be able to simultaneously open and use any
270 * combination of camera devices exposed by the HAL where the sum of
271 * the resource costs of these cameras is <= 100. For determining cost,
272 * each camera device must be assumed to be configured and operating at
273 * the maximally resource-consuming framerate and stream size settings
274 * available in the configuration settings exposed for that device through
275 * the camera metadata.
276 *
Ruben Brunk1fa09022015-03-10 11:53:12 -0700277 * The camera service may still attempt to simultaneously open combinations
278 * of camera devices with a total resource cost > 100. This may succeed or
279 * fail. If this succeeds, combinations of configurations that are not
280 * supported due to resource constraints from having multiple open devices
281 * should fail during the configure calls. If the total resource cost is
282 * <= 100, open and configure should never fail for any stream configuration
283 * settings or other device capabilities that would normally succeed for a
284 * device when it is the only open camera device.
285 *
286 * This field will be used to determine whether background applications are
287 * allowed to use this camera device while other applications are using other
288 * camera devices. Note: multiple applications will never be allowed by the
289 * camera service to simultaneously open the same camera device.
290 *
291 * Example use cases:
292 *
293 * Ex. 1: Camera Device 0 = Back Camera
294 * Camera Device 1 = Front Camera
295 * - Using both camera devices causes a large framerate slowdown due to
296 * limited ISP bandwidth.
297 *
298 * Configuration:
299 *
300 * Camera Device 0 - resource_cost = 51
301 * conflicting_devices = null
302 * Camera Device 1 - resource_cost = 51
303 * conflicting_devices = null
304 *
305 * Result:
306 *
307 * Since the sum of the resource costs is > 100, if a higher-priority
308 * application has either device open, no lower-priority applications will be
309 * allowed by the camera service to open either device. If a lower-priority
310 * application is using a device that a higher-priority subsequently attempts
311 * to open, the lower-priority application will be forced to disconnect the
312 * the device.
313 *
314 * If the highest-priority application chooses, it may still attempt to open
315 * both devices (since these devices are not listed as conflicting in the
316 * conflicting_devices fields), but usage of these devices may fail in the
317 * open or configure calls.
318 *
319 * Ex. 2: Camera Device 0 = Left Back Camera
320 * Camera Device 1 = Right Back Camera
321 * Camera Device 2 = Combined stereo camera using both right and left
322 * back camera sensors used by devices 0, and 1
323 * Camera Device 3 = Front Camera
324 * - Due to do hardware constraints, up to two cameras may be open at once. The
325 * combined stereo camera may never be used at the same time as either of the
326 * two back camera devices (device 0, 1), and typically requires too much
327 * bandwidth to use at the same time as the front camera (device 3).
328 *
329 * Configuration:
330 *
331 * Camera Device 0 - resource_cost = 50
332 * conflicting_devices = { 2 }
333 * Camera Device 1 - resource_cost = 50
334 * conflicting_devices = { 2 }
335 * Camera Device 2 - resource_cost = 100
336 * conflicting_devices = { 0, 1 }
337 * Camera Device 3 - resource_cost = 50
338 * conflicting_devices = null
339 *
340 * Result:
341 *
342 * Based on the conflicting_devices fields, the camera service guarantees that
343 * the following sets of open devices will never be allowed: { 1, 2 }, { 0, 2 }.
344 *
345 * Based on the resource_cost fields, if a high-priority foreground application
346 * is using camera device 0, a background application would be allowed to open
347 * camera device 1 or 3 (but would be forced to disconnect it again if the
348 * foreground application opened another device).
349 *
350 * The highest priority application may still attempt to simultaneously open
351 * devices 0, 2, and 3, but the HAL may fail in open or configure calls for
352 * this combination.
353 *
354 * Ex. 3: Camera Device 0 = Back Camera
355 * Camera Device 1 = Front Camera
356 * Camera Device 2 = Low-power Front Camera that uses the same
357 * sensor as device 1, but only exposes image stream
358 * resolutions that can be used in low-power mode
359 * - Using both front cameras (device 1, 2) at the same time is impossible due
360 * a shared physical sensor. Using the back and "high-power" front camera
361 * (device 1) may be impossible for some stream configurations due to hardware
362 * limitations, but the "low-power" front camera option may always be used as
363 * it has special dedicated hardware.
364 *
365 * Configuration:
366 *
367 * Camera Device 0 - resource_cost = 100
368 * conflicting_devices = null
369 * Camera Device 1 - resource_cost = 100
370 * conflicting_devices = { 2 }
371 * Camera Device 2 - resource_cost = 0
372 * conflicting_devices = { 1 }
373 * Result:
374 *
375 * Based on the conflicting_devices fields, the camera service guarantees that
376 * the following sets of open devices will never be allowed: { 1, 2 }.
377 *
378 * Based on the resource_cost fields, only the highest priority application
379 * may attempt to open both device 0 and 1 at the same time. If a higher-priority
380 * application is not using device 1 or 2, a low-priority background application
381 * may open device 2 (but will be forced to disconnect it if a higher-priority
382 * application subsequently opens device 1 or 2).
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800383 *
384 * Version information (based on camera_module_t.common.module_api_version):
385 *
386 * CAMERA_MODULE_API_VERSION_2_3 or lower:
387 *
388 * Not valid. Can be assumed to be 100. Do not read this field.
389 *
390 * CAMERA_MODULE_API_VERSION_2_4 or higher:
391 *
392 * Always valid.
393 */
394 int resource_cost;
395
396 /**
397 * An array of camera device IDs represented as NULL-terminated strings
398 * indicating other devices that cannot be simultaneously opened while this
399 * camera device is in use.
400 *
401 * This field is intended to be used to indicate that this camera device
402 * is a composite of several other camera devices, or otherwise has
403 * hardware dependencies that prohibit simultaneous usage. If there are no
404 * dependencies, a NULL may be returned in this field to indicate this.
405 *
406 * The camera service will never simultaneously open any of the devices
407 * in this list while this camera device is open.
408 *
Ruben Brunk1fa09022015-03-10 11:53:12 -0700409 * The strings pointed to in this field will not be cleaned up by the camera
410 * service, and must remain while this device is plugged in.
411 *
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800412 * Version information (based on camera_module_t.common.module_api_version):
413 *
414 * CAMERA_MODULE_API_VERSION_2_3 or lower:
415 *
416 * Not valid. Can be assumed to be NULL. Do not read this field.
417 *
418 * CAMERA_MODULE_API_VERSION_2_4 or higher:
419 *
420 * Always valid.
421 */
422 char** conflicting_devices;
423
424 /**
425 * The length of the array given in the conflicting_devices field.
426 *
427 * Version information (based on camera_module_t.common.module_api_version):
428 *
429 * CAMERA_MODULE_API_VERSION_2_3 or lower:
430 *
431 * Not valid. Can be assumed to be 0. Do not read this field.
432 *
433 * CAMERA_MODULE_API_VERSION_2_4 or higher:
434 *
435 * Always valid.
436 */
437 size_t conflicting_devices_length;
438
Alex Ray9acc7402013-02-07 15:44:24 -0800439} camera_info_t;
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800440
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800441/**
442 * camera_device_status_t:
443 *
444 * The current status of the camera device, as provided by the HAL through the
445 * camera_module_callbacks.camera_device_status_change() call.
Igor Murashkin152b50f2013-03-18 13:30:14 -0700446 *
447 * At module load time, the framework will assume all camera devices are in the
448 * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke
449 * camera_module_callbacks::camera_device_status_change to inform the framework
450 * of any initially NOT_PRESENT devices.
451 *
452 * Allowed transitions:
453 * PRESENT -> NOT_PRESENT
454 * NOT_PRESENT -> ENUMERATING
455 * NOT_PRESENT -> PRESENT
456 * ENUMERATING -> PRESENT
457 * ENUMERATING -> NOT_PRESENT
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800458 */
459typedef enum camera_device_status {
460 /**
461 * The camera device is not currently connected, and opening it will return
Zhijun He94e23b22015-01-12 14:45:33 -0800462 * failure.
463 *
464 * Version information (based on camera_module_t.common.module_api_version):
465 *
466 * CAMERA_MODULE_API_VERSION_2_3 or lower:
467 *
468 * Calls to get_camera_info must still succeed, and provide the same information
469 * it would if the camera were connected.
470 *
471 * CAMERA_MODULE_API_VERSION_2_4:
472 *
473 * The camera device at this status must return -EINVAL for get_camera_info call,
474 * as the device is not connected.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800475 */
476 CAMERA_DEVICE_STATUS_NOT_PRESENT = 0,
477
478 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800479 * The camera device is connected, and opening it will succeed.
480 *
481 * CAMERA_MODULE_API_VERSION_2_3 or lower:
482 *
483 * The information returned by get_camera_info cannot change due to this status
484 * change. By default, the framework will assume all devices are in this state.
485 *
486 * CAMERA_MODULE_API_VERSION_2_4:
487 *
488 * The information returned by get_camera_info will become valid after a device's
489 * status changes to this. By default, the framework will assume all devices are in
490 * this state.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800491 */
Igor Murashkin152b50f2013-03-18 13:30:14 -0700492 CAMERA_DEVICE_STATUS_PRESENT = 1,
493
494 /**
495 * The camera device is connected, but it is undergoing an enumeration and
Zhijun He94e23b22015-01-12 14:45:33 -0800496 * so opening the device will return -EBUSY.
497 *
498 * CAMERA_MODULE_API_VERSION_2_3 or lower:
499 *
500 * Calls to get_camera_info must still succeed, as if the camera was in the
501 * PRESENT status.
502 *
503 * CAMERA_MODULE_API_VERSION_2_4:
504 *
505 * The camera device at this status must return -EINVAL for get_camera_info for call,
506 * as the device is not ready.
Igor Murashkin152b50f2013-03-18 13:30:14 -0700507 */
508 CAMERA_DEVICE_STATUS_ENUMERATING = 2,
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800509
510} camera_device_status_t;
511
512/**
Chien-Yu Chen30159172015-01-08 11:06:38 -0800513 * torch_mode_status_t:
514 *
515 * The current status of the torch mode, as provided by the HAL through the
516 * camera_module_callbacks.torch_mode_status_change() call.
517 *
518 * The torch mode status of a camera device is applicable only when the camera
519 * device is present. The framework will not call set_torch_mode() to turn on
520 * torch mode of a camera device if the camera device is not present. At module
521 * load time, the framework will assume torch modes are in the
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700522 * TORCH_MODE_STATUS_AVAILABLE_OFF state if the camera device is present and
Chien-Yu Chen30159172015-01-08 11:06:38 -0800523 * android.flash.info.available is reported as true via get_camera_info() call.
524 *
525 * The behaviors of the camera HAL module that the framework expects in the
526 * following situations when a camera device's status changes:
527 * 1. A previously-disconnected camera device becomes connected.
528 * After camera_module_callbacks::camera_device_status_change() is invoked
529 * to inform the framework that the camera device is present, the framework
530 * will assume the camera device's torch mode is in
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700531 * TORCH_MODE_STATUS_AVAILABLE_OFF state. The camera HAL module does not need
Chien-Yu Chen30159172015-01-08 11:06:38 -0800532 * to invoke camera_module_callbacks::torch_mode_status_change() unless the
533 * flash unit is unavailable to use by set_torch_mode().
534 *
535 * 2. A previously-connected camera becomes disconnected.
536 * After camera_module_callbacks::camera_device_status_change() is invoked
537 * to inform the framework that the camera device is not present, the
538 * framework will not call set_torch_mode() for the disconnected camera
539 * device until its flash unit becomes available again. The camera HAL
540 * module does not need to invoke
541 * camera_module_callbacks::torch_mode_status_change() separately to inform
542 * that the flash unit has become unavailable.
543 *
544 * 3. open() is called to open a camera device.
545 * The camera HAL module must invoke
546 * camera_module_callbacks::torch_mode_status_change() for all flash units
Chien-Yu Chen85585102015-02-25 14:50:13 -0800547 * that have entered TORCH_MODE_STATUS_NOT_AVAILABLE state and can not be
Chien-Yu Chen30159172015-01-08 11:06:38 -0800548 * turned on by calling set_torch_mode() anymore due to this open() call.
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700549 * open() must not trigger TORCH_MODE_STATUS_AVAILABLE_OFF before
550 * TORCH_MODE_STATUS_NOT_AVAILABLE for all flash units that have become
551 * unavailable.
Chien-Yu Chen30159172015-01-08 11:06:38 -0800552 *
553 * 4. close() is called to close a camera device.
554 * The camera HAL module must invoke
555 * camera_module_callbacks::torch_mode_status_change() for all flash units
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700556 * that have entered TORCH_MODE_STATUS_AVAILABLE_OFF state and can be turned
Chien-Yu Chen30159172015-01-08 11:06:38 -0800557 * on by calling set_torch_mode() again because of enough resources freed
558 * up by this close() call.
559 *
Chien-Yu Chen85585102015-02-25 14:50:13 -0800560 * Note that the framework calling set_torch_mode() successfully must trigger
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700561 * TORCH_MODE_STATUS_AVAILABLE_OFF or TORCH_MODE_STATUS_AVAILABLE_ON callback
562 * for the given camera device. Additionally it must trigger
563 * TORCH_MODE_STATUS_AVAILABLE_OFF callbacks for other previously-on torch
564 * modes if HAL cannot keep multiple torch modes on simultaneously.
Chien-Yu Chen30159172015-01-08 11:06:38 -0800565 */
566typedef enum torch_mode_status {
Chien-Yu Chen30159172015-01-08 11:06:38 -0800567
568 /**
569 * The flash unit is no longer available and the torch mode can not be
570 * turned on by calling set_torch_mode(). If the torch mode is on, it
571 * will be turned off by HAL before HAL calls torch_mode_status_change().
572 */
Chien-Yu Chen85585102015-02-25 14:50:13 -0800573 TORCH_MODE_STATUS_NOT_AVAILABLE = 0,
Chien-Yu Chen30159172015-01-08 11:06:38 -0800574
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800575 /**
Chien-Yu Chen85585102015-02-25 14:50:13 -0800576 * A torch mode has become off and available to be turned on via
577 * set_torch_mode(). This may happen in the following
578 * cases:
579 * 1. After the resources to turn on the torch mode have become available.
580 * 2. After set_torch_mode() is called to turn off the torch mode.
581 * 3. After the framework turned on the torch mode of some other camera
582 * device and HAL had to turn off the torch modes of any camera devices
583 * that were previously on.
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800584 */
Chien-Yu Chen85585102015-02-25 14:50:13 -0800585 TORCH_MODE_STATUS_AVAILABLE_OFF = 1,
586
587 /**
588 * A torch mode has become on and available to be turned off via
589 * set_torch_mode(). This can happen only after set_torch_mode() is called
590 * to turn on the torch mode.
591 */
592 TORCH_MODE_STATUS_AVAILABLE_ON = 2,
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800593
Chien-Yu Chen30159172015-01-08 11:06:38 -0800594} torch_mode_status_t;
595
596/**
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800597 * Callback functions for the camera HAL module to use to inform the framework
Chien-Yu Chen30159172015-01-08 11:06:38 -0800598 * of changes to the camera subsystem.
599 *
600 * Version information (based on camera_module_t.common.module_api_version):
601 *
602 * Each callback is called only by HAL modules implementing the indicated
603 * version or higher of the HAL module API interface.
604 *
605 * CAMERA_MODULE_API_VERSION_2_1:
606 * camera_device_status_change()
607 *
608 * CAMERA_MODULE_API_VERSION_2_4:
609 * torch_mode_status_change()
610
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800611 */
612typedef struct camera_module_callbacks {
613
614 /**
615 * camera_device_status_change:
616 *
617 * Callback to the framework to indicate that the state of a specific camera
618 * device has changed. At module load time, the framework will assume all
619 * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL
620 * must call this method to inform the framework of any initially
621 * NOT_PRESENT devices.
622 *
Chien-Yu Chen30159172015-01-08 11:06:38 -0800623 * This callback is added for CAMERA_MODULE_API_VERSION_2_1.
624 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800625 * camera_module_callbacks: The instance of camera_module_callbacks_t passed
626 * to the module with set_callbacks.
627 *
628 * camera_id: The ID of the camera device that has a new status.
629 *
630 * new_status: The new status code, one of the camera_device_status_t enums,
631 * or a platform-specific status.
632 *
633 */
634 void (*camera_device_status_change)(const struct camera_module_callbacks*,
635 int camera_id,
636 int new_status);
637
Chien-Yu Chen30159172015-01-08 11:06:38 -0800638 /**
639 * torch_mode_status_change:
640 *
641 * Callback to the framework to indicate that the state of the torch mode
642 * of the flash unit associated with a specific camera device has changed.
643 * At module load time, the framework will assume the torch modes are in
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700644 * the TORCH_MODE_STATUS_AVAILABLE_OFF state if android.flash.info.available
Chien-Yu Chen30159172015-01-08 11:06:38 -0800645 * is reported as true via get_camera_info() call.
646 *
647 * This callback is added for CAMERA_MODULE_API_VERSION_2_4.
648 *
649 * camera_module_callbacks: The instance of camera_module_callbacks_t
650 * passed to the module with set_callbacks.
651 *
652 * camera_id: The ID of camera device whose flash unit has a new torch mode
653 * status.
654 *
655 * new_status: The new status code, one of the torch_mode_status_t enums.
656 */
657 void (*torch_mode_status_change)(const struct camera_module_callbacks*,
658 const char* camera_id,
659 int new_status);
660
661
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800662} camera_module_callbacks_t;
663
Emilian Peev8ca3c602018-10-29 09:37:04 +0000664/**
665 * camera_stream_t:
666 *
667 * A handle to a single camera input or output stream. A stream is defined by
668 * the framework by its buffer resolution and format and gralloc usage flags.
669 *
670 * The stream structures are owned by the framework and pointers to a
671 * camera_stream passed into the HAL by is_stream_combination_supported() are
672 * only valid within the scope of the call.
673 *
674 * All camera_stream members are immutable.
675 */
676typedef struct camera_stream {
677 /**
678 * The type of the stream, one of the camera3_stream_type_t values.
679 */
680 int stream_type;
681
682 /**
683 * The width in pixels of the buffers in this stream
684 */
685 uint32_t width;
686
687 /**
688 * The height in pixels of the buffers in this stream
689 */
690 uint32_t height;
691
692 /**
693 * The pixel format for the buffers in this stream. Format is a value from
694 * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or
695 * from device-specific headers.
696 *
697 * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
698 * gralloc module will select a format based on the usage flags provided by
699 * the camera device and the other endpoint of the stream.
700 *
701 */
702 int format;
703
704 /**
705 * The gralloc usage flags for this stream, as needed by the HAL. The usage
706 * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific
707 * headers.
708 *
709 * For output streams, these are the HAL's producer usage flags. For input
710 * streams, these are the HAL's consumer usage flags. The usage flags from
711 * the producer and the consumer will be combined together and then passed
712 * to the platform gralloc HAL module for allocating the gralloc buffers for
713 * each stream.
714 *
715 * The usage flag for an output stream may be bitwise
716 * combination of usage flags for multiple consumers, for the purpose of
717 * sharing one camera stream between those consumers. The HAL must fail
718 * the stream combination query call with -EINVAL if the combined flags cannot be
719 * supported due to imcompatible buffer format, dataSpace, or other hardware
720 * limitations.
721 */
722 uint32_t usage;
723
724 /**
725 * A field that describes the contents of the buffer. The format and buffer
726 * dimensions define the memory layout and structure of the stream buffers,
727 * while dataSpace defines the meaning of the data within the buffer.
728 *
729 * For most formats, dataSpace defines the color space of the image data.
730 * In addition, for some formats, dataSpace indicates whether image- or
731 * depth-based data is requested. See system/core/include/system/graphics.h
732 * for details of formats and valid dataSpace values for each format.
733 *
734 * Always set by the camera service. The dataspace values are set
735 * using the V0 dataspace definitions in graphics.h
736 */
737 android_dataspace_t data_space;
738
739 /**
740 * The required output rotation of the stream, one of
741 * the camera3_stream_rotation_t values. This must be inspected by HAL along
742 * with stream width and height. For example, if the rotation is 90 degree
743 * and the stream width and height is 720 and 1280 respectively, camera service
744 * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image
745 * and rotate the image by 90 degree counterclockwise. The rotation field is
746 * no-op when the stream type is input. Camera HAL must ignore the rotation
747 * field for an input stream.
748 *
749 * Always set by camera service. HAL must inspect this field during stream
750 * combination query and return -EINVAL if it cannot perform such rotation.
751 * HAL must always support CAMERA3_STREAM_ROTATION_0, so a
752 * is_stream_combination_supported() call must not fail for unsupported rotation if
753 * rotation field of all streams is CAMERA3_STREAM_ROTATION_0.
754 *
755 */
756 int rotation;
757
758 /**
759 * The physical camera id this stream belongs to.
760 * Always set by camera service. If the camera device is not a logical
761 * multi camera, or if the camera is a logical multi camera but the stream
762 * is not a physical output stream, this field will point to a 0-length
763 * string.
764 *
765 * A logical multi camera is a camera device backed by multiple physical
766 * cameras that are also exposed to the application. And for a logical
767 * multi camera, a physical output stream is an output stream specifically
768 * requested on an underlying physical camera.
769 *
770 * For an input stream, this field is guaranteed to be a 0-length string.
771 */
772 const char* physical_camera_id;
773
774} camera_stream_t;
775
776/**
777 * camera_stream_combination_t:
778 *
779 * A structure of stream definitions, used by is_stream_combination_supported(). This
780 * structure defines all the input & output streams for specific camera use case.
781 */
782typedef struct camera_stream_combination {
783 /**
784 * The total number of streams by the framework. This includes
785 * both input and output streams. The number of streams will be at least 1,
786 * and there will be at least one output-capable stream.
787 */
788 uint32_t num_streams;
789
790 /**
791 * An array of camera streams, defining the input/output
792 * stream combination for the camera HAL device.
793 *
794 * At most one input-capable stream may be defined.
795 *
796 * At least one output-capable stream must be defined.
797 */
798 camera_stream_t *streams;
799
800 /**
801 * The operation mode of streams in this stream combination, one of the value
802 * defined in camera3_stream_configuration_mode_t.
803 *
804 */
805 uint32_t operation_mode;
806
807} camera_stream_combination_t;
808
Shuzhen Wangfc590b62018-12-26 14:34:56 -0800809/**
810 * device_state_t:
811 *
812 * Possible physical states of the overall device, for use with
813 * notify_device_state_change.
814 */
815typedef enum device_state {
816 /**
817 * The device is in its normal physical configuration. This is the default if the
818 * device does not support multiple different states.
819 */
820 NORMAL = 0,
821
822 /**
823 * Camera device(s) facing backward are covered.
824 */
825 BACK_COVERED = 1 << 0,
826
827 /**
828 * Camera device(s) facing foward are covered.
829 */
830 FRONT_COVERED = 1 << 1,
831
832 /**
833 * The device is folded. If not set, the device is unfolded or does not
834 * support folding.
835 *
836 * The exact point when this status change happens during the folding
837 * operation is device-specific.
838 */
839 FOLDED = 1 << 2,
840
841 /**
842 * First vendor-specific device state. All bits above and including this one
843 * are for vendor state values. Values below this one must only be used
844 * for framework-defined states.
845 */
846 VENDOR_STATE_START = 1LL << 32
847
848} device_state_t;
849
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800850typedef struct camera_module {
Stewart Miles84d35492014-05-01 09:03:27 -0700851 /**
852 * Common methods of the camera module. This *must* be the first member of
853 * camera_module as users of this structure will cast a hw_module_t to
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700854 * camera_module pointer in contexts where it's known the hw_module_t
855 * references a camera_module.
856 *
857 * The return values for common.methods->open for camera_module are:
858 *
859 * 0: On a successful open of the camera device.
860 *
861 * -ENODEV: The camera device cannot be opened due to an internal
862 * error.
863 *
864 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
865 * and/or the module is invalid.
866 *
867 * -EBUSY: The camera device was already opened for this camera id
868 * (by using this method or open_legacy),
869 * regardless of the device HAL version it was opened as.
870 *
871 * -EUSERS: The maximal number of camera devices that can be
872 * opened concurrently were opened already, either by
873 * this method or the open_legacy method.
874 *
875 * All other return values from common.methods->open will be treated as
876 * -ENODEV.
Stewart Miles84d35492014-05-01 09:03:27 -0700877 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800878 hw_module_t common;
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800879
880 /**
881 * get_number_of_cameras:
882 *
883 * Returns the number of camera devices accessible through the camera
884 * module. The camera devices are numbered 0 through N-1, where N is the
885 * value returned by this call. The name of the camera device for open() is
886 * simply the number converted to a string. That is, "0" for camera ID 0,
887 * "1" for camera ID 1.
888 *
Zhijun He94e23b22015-01-12 14:45:33 -0800889 * Version information (based on camera_module_t.common.module_api_version):
890 *
891 * CAMERA_MODULE_API_VERSION_2_3 or lower:
892 *
893 * The value here must be static, and cannot change after the first call
894 * to this method.
895 *
896 * CAMERA_MODULE_API_VERSION_2_4 or higher:
897 *
898 * The value here must be static, and must count only built-in cameras,
899 * which have CAMERA_FACING_BACK or CAMERA_FACING_FRONT camera facing values
900 * (camera_info.facing). The HAL must not include the external cameras
901 * (camera_info.facing == CAMERA_FACING_EXTERNAL) into the return value
902 * of this call. Frameworks will use camera_device_status_change callback
903 * to manage number of external cameras.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800904 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800905 int (*get_number_of_cameras)(void);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800906
907 /**
908 * get_camera_info:
909 *
910 * Return the static camera information for a given camera device. This
911 * information may not change for a camera device.
912 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700913 * Return values:
914 *
915 * 0: On a successful operation
916 *
917 * -ENODEV: The information cannot be provided due to an internal
918 * error.
919 *
920 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
921 * and/or the module is invalid.
Zhijun He94e23b22015-01-12 14:45:33 -0800922 *
923 * Version information (based on camera_module_t.common.module_api_version):
924 *
925 * CAMERA_MODULE_API_VERSION_2_4 or higher:
926 *
927 * When a camera is disconnected, its camera id becomes invalid. Calling this
928 * this method with this invalid camera id will get -EINVAL and NULL camera
929 * static metadata (camera_info.static_camera_characteristics).
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800930 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800931 int (*get_camera_info)(int camera_id, struct camera_info *info);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800932
933 /**
934 * set_callbacks:
935 *
936 * Provide callback function pointers to the HAL module to inform framework
937 * of asynchronous camera module events. The framework will call this
938 * function once after initial camera HAL module load, after the
939 * get_number_of_cameras() method is called for the first time, and before
940 * any other calls to the module.
941 *
942 * Version information (based on camera_module_t.common.module_api_version):
943 *
944 * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0:
945 *
946 * Not provided by HAL module. Framework may not call this function.
947 *
948 * CAMERA_MODULE_API_VERSION_2_1:
949 *
950 * Valid to be called by the framework.
951 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700952 * Return values:
953 *
954 * 0: On a successful operation
955 *
956 * -ENODEV: The operation cannot be completed due to an internal
957 * error.
958 *
959 * -EINVAL: The input arguments are invalid, i.e. the callbacks are
960 * null
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800961 */
962 int (*set_callbacks)(const camera_module_callbacks_t *callbacks);
963
Alex Ray19b2cea2013-06-13 12:40:52 -0700964 /**
965 * get_vendor_tag_ops:
966 *
967 * Get methods to query for vendor extension metadata tag information. The
968 * HAL should fill in all the vendor tag operation methods, or leave ops
969 * unchanged if no vendor tags are defined.
970 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800971 * The vendor_tag_ops structure used here is defined in:
972 * system/media/camera/include/system/vendor_tags.h
973 *
Alex Ray19b2cea2013-06-13 12:40:52 -0700974 * Version information (based on camera_module_t.common.module_api_version):
975 *
976 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1:
977 * Not provided by HAL module. Framework may not call this function.
978 *
979 * CAMERA_MODULE_API_VERSION_2_2:
980 * Valid to be called by the framework.
981 */
982 void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops);
983
Zhijun Hebcdebf32014-06-06 15:42:17 -0700984 /**
985 * open_legacy:
986 *
987 * Open a specific legacy camera HAL device if multiple device HAL API
988 * versions are supported by this camera HAL module. For example, if the
989 * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and
990 * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id,
991 * framework can call this function to open the camera device as
992 * CAMERA_DEVICE_API_VERSION_1_0 device.
993 *
994 * This is an optional method. A Camera HAL module does not need to support
995 * more than one device HAL version per device, and such modules may return
996 * -ENOSYS for all calls to this method. For all older HAL device API
997 * versions that are not supported, it may return -EOPNOTSUPP. When above
998 * cases occur, The normal open() method (common.methods->open) will be
999 * used by the framework instead.
1000 *
1001 * Version information (based on camera_module_t.common.module_api_version):
1002 *
1003 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2:
1004 * Not provided by HAL module. Framework will not call this function.
1005 *
1006 * CAMERA_MODULE_API_VERSION_2_3:
1007 * Valid to be called by the framework.
1008 *
1009 * Return values:
1010 *
1011 * 0: On a successful open of the camera device.
1012 *
1013 * -ENOSYS This method is not supported.
1014 *
1015 * -EOPNOTSUPP: The requested HAL version is not supported by this method.
1016 *
1017 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
1018 * and/or the module is invalid.
1019 *
1020 * -EBUSY: The camera device was already opened for this camera id
1021 * (by using this method or common.methods->open method),
1022 * regardless of the device HAL version it was opened as.
1023 *
1024 * -EUSERS: The maximal number of camera devices that can be
1025 * opened concurrently were opened already, either by
1026 * this method or common.methods->open method.
1027 */
1028 int (*open_legacy)(const struct hw_module_t* module, const char* id,
1029 uint32_t halVersion, struct hw_device_t** device);
1030
Chien-Yu Chen30159172015-01-08 11:06:38 -08001031 /**
1032 * set_torch_mode:
1033 *
1034 * Turn on or off the torch mode of the flash unit associated with a given
Chien-Yu Chen85585102015-02-25 14:50:13 -08001035 * camera ID. If the operation is successful, HAL must notify the framework
1036 * torch state by invoking
1037 * camera_module_callbacks.torch_mode_status_change() with the new state.
Chien-Yu Chen30159172015-01-08 11:06:38 -08001038 *
1039 * The camera device has a higher priority accessing the flash unit. When
1040 * there are any resource conflicts, such as open() is called to open a
1041 * camera device, HAL module must notify the framework through
1042 * camera_module_callbacks.torch_mode_status_change() that the
1043 * torch mode has been turned off and the torch mode state has become
Chien-Yu Chen85585102015-02-25 14:50:13 -08001044 * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode
Chien-Yu Chen30159172015-01-08 11:06:38 -08001045 * become available again, HAL module must notify the framework through
1046 * camera_module_callbacks.torch_mode_status_change() that the torch mode
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -07001047 * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to
1048 * be called.
Chien-Yu Chen30159172015-01-08 11:06:38 -08001049 *
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -08001050 * When the framework calls set_torch_mode() to turn on the torch mode of a
1051 * flash unit, if HAL cannot keep multiple torch modes on simultaneously,
1052 * HAL should turn off the torch mode that was turned on by
1053 * a previous set_torch_mode() call and notify the framework that the torch
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -07001054 * mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF.
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -08001055 *
Chien-Yu Chen30159172015-01-08 11:06:38 -08001056 * Version information (based on camera_module_t.common.module_api_version):
1057 *
1058 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
1059 * Not provided by HAL module. Framework will not call this function.
1060 *
1061 * CAMERA_MODULE_API_VERSION_2_4:
1062 * Valid to be called by the framework.
1063 *
1064 * Return values:
1065 *
1066 * 0: On a successful operation.
1067 *
1068 * -ENOSYS: The camera device does not support this operation. It is
1069 * returned if and only if android.flash.info.available is
1070 * false.
1071 *
Chien-Yu Chen273def32015-02-11 11:31:12 -08001072 * -EBUSY: The camera device is already in use.
1073 *
1074 * -EUSERS: The resources needed to turn on the torch mode are not
1075 * available, typically because other camera devices are
1076 * holding the resources to make using the flash unit not
1077 * possible.
Chien-Yu Chen30159172015-01-08 11:06:38 -08001078 *
1079 * -EINVAL: camera_id is invalid.
1080 *
1081 */
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -08001082 int (*set_torch_mode)(const char* camera_id, bool enabled);
Chien-Yu Chen30159172015-01-08 11:06:38 -08001083
Eino-Ville Talvalaaee47822015-04-07 13:47:46 -07001084 /**
1085 * init:
1086 *
1087 * This method is called by the camera service before any other methods
1088 * are invoked, right after the camera HAL library has been successfully
1089 * loaded. It may be left as NULL by the HAL module, if no initialization
1090 * in needed.
1091 *
1092 * It can be used by HAL implementations to perform initialization and
1093 * other one-time operations.
1094 *
1095 * Version information (based on camera_module_t.common.module_api_version):
1096 *
1097 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
1098 * Not provided by HAL module. Framework will not call this function.
1099 *
1100 * CAMERA_MODULE_API_VERSION_2_4:
1101 * If not NULL, will always be called by the framework once after the HAL
1102 * module is loaded, before any other HAL module method is called.
1103 *
1104 * Return values:
1105 *
1106 * 0: On a successful operation.
1107 *
1108 * -ENODEV: Initialization cannot be completed due to an internal
1109 * error. The HAL must be assumed to be in a nonfunctional
1110 * state.
1111 *
1112 */
1113 int (*init)();
1114
Shuzhen Wanga8caa6a2018-08-24 11:07:50 -07001115 /**
1116 * get_physical_camera_info:
1117 *
1118 * Return the static metadata for a physical camera as a part of a logical
1119 * camera device. This function is only called for those physical camera
1120 * ID(s) that are not exposed independently. In other words, camera_id will
1121 * be greater or equal to the return value of get_number_of_cameras().
1122 *
1123 * Return values:
1124 *
1125 * 0: On a successful operation
1126 *
1127 * -ENODEV: The information cannot be provided due to an internal
1128 * error.
1129 *
1130 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
1131 * and/or the module is invalid.
1132 *
1133 * Version information (based on camera_module_t.common.module_api_version):
1134 *
1135 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3/2_4:
1136 * Not provided by HAL module. Framework will not call this function.
1137 *
1138 * CAMERA_MODULE_API_VERSION_2_5 or higher:
1139 * If any of the camera devices accessible through this camera module is
1140 * a logical multi-camera, and at least one of the physical cameras isn't
1141 * a stand-alone camera device, this function will be called by the camera
1142 * framework. Calling this function with invalid physical_camera_id will
1143 * get -EINVAL, and NULL static_metadata.
1144 */
1145 int (*get_physical_camera_info)(int physical_camera_id,
1146 camera_metadata_t **static_metadata);
1147
Emilian Peev8ca3c602018-10-29 09:37:04 +00001148 /**
1149 * is_stream_combination_supported:
1150 *
1151 * Check for device support of specific camera stream combination.
1152 *
1153 * Return values:
1154 *
1155 * 0: In case the stream combination is supported.
1156 *
1157 * -EINVAL: In case the stream combination is not supported.
1158 *
1159 * -ENOSYS: In case stream combination query is not supported.
1160 *
1161 * Version information (based on camera_module_t.common.module_api_version):
1162 *
1163 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3/2_4:
1164 * Not provided by HAL module. Framework will not call this function.
1165 *
1166 * CAMERA_MODULE_API_VERSION_2_5 or higher:
1167 * Valid to be called by the framework.
1168 */
1169 int (*is_stream_combination_supported)(int camera_id,
1170 const camera_stream_combination_t *streams);
1171
Shuzhen Wangfc590b62018-12-26 14:34:56 -08001172 /**
1173 * notify_device_state_change:
1174 *
1175 * Notify the camera module that the state of the overall device has
1176 * changed in some way that the HAL may want to know about.
1177 *
1178 * For example, a physical shutter may have been uncovered or covered,
1179 * or a camera may have been covered or uncovered by an add-on keyboard
1180 * or other accessory.
1181 *
1182 * The state is a bitfield of potential states, and some physical configurations
1183 * could plausibly correspond to multiple different combinations of state bits.
1184 * The HAL must ignore any state bits it is not actively using to determine
1185 * the appropriate camera configuration.
1186 *
1187 * For example, on some devices the FOLDED state could mean that
1188 * backward-facing cameras are covered by the fold, so FOLDED by itself implies
1189 * BACK_COVERED. But other devices may support folding but not cover any cameras
1190 * when folded, so for those FOLDED would not imply any of the other flags.
1191 * Since these relationships are very device-specific, it is difficult to specify
1192 * a comprehensive policy. But as a recommendation, it is suggested that if a flag
1193 * necessarily implies other flags are set as well, then those flags should be set.
1194 * So even though FOLDED would be enough to infer BACK_COVERED on some devices, the
1195 * BACK_COVERED flag should also be set for clarity.
1196 *
1197 * This method may be invoked by the HAL client at any time. It must not
1198 * cause any active camera device sessions to be closed, but may dynamically
1199 * change which physical camera a logical multi-camera is using for its
1200 * active and future output.
1201 *
1202 * The method must be invoked by the HAL client at least once before the
1203 * client calls ICameraDevice::open on any camera device interfaces listed
1204 * by this provider, to establish the initial device state.
1205 *
1206 * Note that the deviceState is 64-bit bitmask, with system defined states in
1207 * lower 32-bit and vendor defined states in upper 32-bit.
1208 */
1209 void (*notify_device_state_change)(uint64_t deviceState);
1210
Alex Ray19b2cea2013-06-13 12:40:52 -07001211 /* reserved for future use */
Shuzhen Wangfc590b62018-12-26 14:34:56 -08001212 void* reserved[2];
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -08001213} camera_module_t;
1214
1215__END_DECLS
1216
1217#endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */