blob: 16651a94b0cdb819a369d5d32d2098498b3e6669 [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)
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -0700169#define CAMERA_DEVICE_API_VERSION_3_6 HARDWARE_DEVICE_API_VERSION(3, 6)
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700170
Emilian Peeveec2ee92017-11-08 19:33:27 +0000171// Device version 3.5 is current, older HAL camera device versions are not
Eino-Ville Talvalab5459832014-09-09 16:42:27 -0700172// recommended for new devices.
Emilian Peeveec2ee92017-11-08 19:33:27 +0000173#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_5
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800174
175/**
James Dongd0ca70d2012-03-26 16:22:35 -0700176 * Defined in /system/media/camera/include/system/camera_metadata.h
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800177 */
178typedef struct camera_metadata camera_metadata_t;
179
Alex Ray9acc7402013-02-07 15:44:24 -0800180typedef struct camera_info {
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800181 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800182 * The direction that the camera faces to. See system/core/include/system/camera.h
183 * for camera facing definitions.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800184 *
Zhijun He94e23b22015-01-12 14:45:33 -0800185 * Version information (based on camera_module_t.common.module_api_version):
186 *
187 * CAMERA_MODULE_API_VERSION_2_3 or lower:
188 *
189 * It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT.
190 *
191 * CAMERA_MODULE_API_VERSION_2_4 or higher:
192 *
193 * It should be CAMERA_FACING_BACK, CAMERA_FACING_FRONT or
194 * CAMERA_FACING_EXTERNAL.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800195 */
196 int facing;
197
198 /**
199 * The orientation of the camera image. The value is the angle that the
200 * camera image needs to be rotated clockwise so it shows correctly on the
201 * display in its natural orientation. It should be 0, 90, 180, or 270.
202 *
203 * For example, suppose a device has a naturally tall screen. The
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800204 * back-facing camera sensor is mounted in landscape. You are looking at the
205 * screen. If the top side of the camera sensor is aligned with the right
206 * edge of the screen in natural orientation, the value should be 90. If the
207 * top side of a front-facing camera sensor is aligned with the right of the
208 * screen, the value should be 270.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800209 *
Zhijun He94e23b22015-01-12 14:45:33 -0800210 * Version information (based on camera_module_t.common.module_api_version):
211 *
212 * CAMERA_MODULE_API_VERSION_2_3 or lower:
213 *
214 * Valid in all camera_module versions.
215 *
216 * CAMERA_MODULE_API_VERSION_2_4 or higher:
217 *
218 * Valid if camera facing is CAMERA_FACING_BACK or CAMERA_FACING_FRONT,
219 * not valid if camera facing is CAMERA_FACING_EXTERNAL.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800220 */
221 int orientation;
222
223 /**
224 * The value of camera_device_t.common.version.
225 *
226 * Version information (based on camera_module_t.common.module_api_version):
227 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700228 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800229 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700230 * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800231 * not read this field.
232 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800233 * CAMERA_MODULE_API_VERSION_2_0 or higher:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800234 *
235 * Always valid
236 *
237 */
238 uint32_t device_version;
239
240 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800241 * The camera's fixed characteristics, which include all static camera metadata
242 * specified in system/media/camera/docs/docs.html. This should be a sorted metadata
243 * buffer, and may not be modified or freed by the caller. The pointer should remain
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800244 * valid for the lifetime of the camera module, and values in it may not
245 * change after it is returned by get_camera_info().
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800246 *
247 * Version information (based on camera_module_t.common.module_api_version):
248 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700249 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800250 *
251 * Not valid. Extra characteristics are not available. Do not read this
252 * field.
253 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800254 * CAMERA_MODULE_API_VERSION_2_0 or higher:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800255 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700256 * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read
257 * otherwise.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800258 *
259 */
Eino-Ville Talvalab8b64392012-08-24 12:32:17 -0700260 const camera_metadata_t *static_camera_characteristics;
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800261
262 /**
Ruben Brunk1fa09022015-03-10 11:53:12 -0700263 * The total resource "cost" of using this camera, represented as an integer
264 * value in the range [0, 100] where 100 represents total usage of the shared
265 * resource that is the limiting bottleneck of the camera subsystem. This may
266 * be a very rough estimate, and is used as a hint to the camera service to
267 * determine when to disallow multiple applications from simultaneously
268 * opening different cameras advertised by the camera service.
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800269 *
270 * The camera service must be able to simultaneously open and use any
271 * combination of camera devices exposed by the HAL where the sum of
272 * the resource costs of these cameras is <= 100. For determining cost,
273 * each camera device must be assumed to be configured and operating at
274 * the maximally resource-consuming framerate and stream size settings
275 * available in the configuration settings exposed for that device through
276 * the camera metadata.
277 *
Ruben Brunk1fa09022015-03-10 11:53:12 -0700278 * The camera service may still attempt to simultaneously open combinations
279 * of camera devices with a total resource cost > 100. This may succeed or
280 * fail. If this succeeds, combinations of configurations that are not
281 * supported due to resource constraints from having multiple open devices
282 * should fail during the configure calls. If the total resource cost is
283 * <= 100, open and configure should never fail for any stream configuration
284 * settings or other device capabilities that would normally succeed for a
285 * device when it is the only open camera device.
286 *
287 * This field will be used to determine whether background applications are
288 * allowed to use this camera device while other applications are using other
289 * camera devices. Note: multiple applications will never be allowed by the
290 * camera service to simultaneously open the same camera device.
291 *
292 * Example use cases:
293 *
294 * Ex. 1: Camera Device 0 = Back Camera
295 * Camera Device 1 = Front Camera
296 * - Using both camera devices causes a large framerate slowdown due to
297 * limited ISP bandwidth.
298 *
299 * Configuration:
300 *
301 * Camera Device 0 - resource_cost = 51
302 * conflicting_devices = null
303 * Camera Device 1 - resource_cost = 51
304 * conflicting_devices = null
305 *
306 * Result:
307 *
308 * Since the sum of the resource costs is > 100, if a higher-priority
309 * application has either device open, no lower-priority applications will be
310 * allowed by the camera service to open either device. If a lower-priority
311 * application is using a device that a higher-priority subsequently attempts
312 * to open, the lower-priority application will be forced to disconnect the
313 * the device.
314 *
315 * If the highest-priority application chooses, it may still attempt to open
316 * both devices (since these devices are not listed as conflicting in the
317 * conflicting_devices fields), but usage of these devices may fail in the
318 * open or configure calls.
319 *
320 * Ex. 2: Camera Device 0 = Left Back Camera
321 * Camera Device 1 = Right Back Camera
322 * Camera Device 2 = Combined stereo camera using both right and left
323 * back camera sensors used by devices 0, and 1
324 * Camera Device 3 = Front Camera
325 * - Due to do hardware constraints, up to two cameras may be open at once. The
326 * combined stereo camera may never be used at the same time as either of the
327 * two back camera devices (device 0, 1), and typically requires too much
328 * bandwidth to use at the same time as the front camera (device 3).
329 *
330 * Configuration:
331 *
332 * Camera Device 0 - resource_cost = 50
333 * conflicting_devices = { 2 }
334 * Camera Device 1 - resource_cost = 50
335 * conflicting_devices = { 2 }
336 * Camera Device 2 - resource_cost = 100
337 * conflicting_devices = { 0, 1 }
338 * Camera Device 3 - resource_cost = 50
339 * conflicting_devices = null
340 *
341 * Result:
342 *
343 * Based on the conflicting_devices fields, the camera service guarantees that
344 * the following sets of open devices will never be allowed: { 1, 2 }, { 0, 2 }.
345 *
346 * Based on the resource_cost fields, if a high-priority foreground application
347 * is using camera device 0, a background application would be allowed to open
348 * camera device 1 or 3 (but would be forced to disconnect it again if the
349 * foreground application opened another device).
350 *
351 * The highest priority application may still attempt to simultaneously open
352 * devices 0, 2, and 3, but the HAL may fail in open or configure calls for
353 * this combination.
354 *
355 * Ex. 3: Camera Device 0 = Back Camera
356 * Camera Device 1 = Front Camera
357 * Camera Device 2 = Low-power Front Camera that uses the same
358 * sensor as device 1, but only exposes image stream
359 * resolutions that can be used in low-power mode
360 * - Using both front cameras (device 1, 2) at the same time is impossible due
361 * a shared physical sensor. Using the back and "high-power" front camera
362 * (device 1) may be impossible for some stream configurations due to hardware
363 * limitations, but the "low-power" front camera option may always be used as
364 * it has special dedicated hardware.
365 *
366 * Configuration:
367 *
368 * Camera Device 0 - resource_cost = 100
369 * conflicting_devices = null
370 * Camera Device 1 - resource_cost = 100
371 * conflicting_devices = { 2 }
372 * Camera Device 2 - resource_cost = 0
373 * conflicting_devices = { 1 }
374 * Result:
375 *
376 * Based on the conflicting_devices fields, the camera service guarantees that
377 * the following sets of open devices will never be allowed: { 1, 2 }.
378 *
379 * Based on the resource_cost fields, only the highest priority application
380 * may attempt to open both device 0 and 1 at the same time. If a higher-priority
381 * application is not using device 1 or 2, a low-priority background application
382 * may open device 2 (but will be forced to disconnect it if a higher-priority
383 * application subsequently opens device 1 or 2).
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800384 *
385 * Version information (based on camera_module_t.common.module_api_version):
386 *
387 * CAMERA_MODULE_API_VERSION_2_3 or lower:
388 *
389 * Not valid. Can be assumed to be 100. Do not read this field.
390 *
391 * CAMERA_MODULE_API_VERSION_2_4 or higher:
392 *
393 * Always valid.
394 */
395 int resource_cost;
396
397 /**
398 * An array of camera device IDs represented as NULL-terminated strings
399 * indicating other devices that cannot be simultaneously opened while this
400 * camera device is in use.
401 *
402 * This field is intended to be used to indicate that this camera device
403 * is a composite of several other camera devices, or otherwise has
404 * hardware dependencies that prohibit simultaneous usage. If there are no
405 * dependencies, a NULL may be returned in this field to indicate this.
406 *
407 * The camera service will never simultaneously open any of the devices
408 * in this list while this camera device is open.
409 *
Ruben Brunk1fa09022015-03-10 11:53:12 -0700410 * The strings pointed to in this field will not be cleaned up by the camera
411 * service, and must remain while this device is plugged in.
412 *
Ruben Brunk0388bcd2015-01-16 14:29:21 -0800413 * Version information (based on camera_module_t.common.module_api_version):
414 *
415 * CAMERA_MODULE_API_VERSION_2_3 or lower:
416 *
417 * Not valid. Can be assumed to be NULL. Do not read this field.
418 *
419 * CAMERA_MODULE_API_VERSION_2_4 or higher:
420 *
421 * Always valid.
422 */
423 char** conflicting_devices;
424
425 /**
426 * The length of the array given in the conflicting_devices field.
427 *
428 * Version information (based on camera_module_t.common.module_api_version):
429 *
430 * CAMERA_MODULE_API_VERSION_2_3 or lower:
431 *
432 * Not valid. Can be assumed to be 0. Do not read this field.
433 *
434 * CAMERA_MODULE_API_VERSION_2_4 or higher:
435 *
436 * Always valid.
437 */
438 size_t conflicting_devices_length;
439
Alex Ray9acc7402013-02-07 15:44:24 -0800440} camera_info_t;
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800441
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800442/**
443 * camera_device_status_t:
444 *
445 * The current status of the camera device, as provided by the HAL through the
446 * camera_module_callbacks.camera_device_status_change() call.
Igor Murashkin152b50f2013-03-18 13:30:14 -0700447 *
448 * At module load time, the framework will assume all camera devices are in the
449 * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke
450 * camera_module_callbacks::camera_device_status_change to inform the framework
451 * of any initially NOT_PRESENT devices.
452 *
453 * Allowed transitions:
454 * PRESENT -> NOT_PRESENT
455 * NOT_PRESENT -> ENUMERATING
456 * NOT_PRESENT -> PRESENT
457 * ENUMERATING -> PRESENT
458 * ENUMERATING -> NOT_PRESENT
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800459 */
460typedef enum camera_device_status {
461 /**
462 * The camera device is not currently connected, and opening it will return
Zhijun He94e23b22015-01-12 14:45:33 -0800463 * failure.
464 *
465 * Version information (based on camera_module_t.common.module_api_version):
466 *
467 * CAMERA_MODULE_API_VERSION_2_3 or lower:
468 *
469 * Calls to get_camera_info must still succeed, and provide the same information
470 * it would if the camera were connected.
471 *
472 * CAMERA_MODULE_API_VERSION_2_4:
473 *
474 * The camera device at this status must return -EINVAL for get_camera_info call,
475 * as the device is not connected.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800476 */
477 CAMERA_DEVICE_STATUS_NOT_PRESENT = 0,
478
479 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800480 * The camera device is connected, and opening it will succeed.
481 *
482 * CAMERA_MODULE_API_VERSION_2_3 or lower:
483 *
484 * The information returned by get_camera_info cannot change due to this status
485 * change. By default, the framework will assume all devices are in this state.
486 *
487 * CAMERA_MODULE_API_VERSION_2_4:
488 *
489 * The information returned by get_camera_info will become valid after a device's
490 * status changes to this. By default, the framework will assume all devices are in
491 * this state.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800492 */
Igor Murashkin152b50f2013-03-18 13:30:14 -0700493 CAMERA_DEVICE_STATUS_PRESENT = 1,
494
495 /**
496 * The camera device is connected, but it is undergoing an enumeration and
Zhijun He94e23b22015-01-12 14:45:33 -0800497 * so opening the device will return -EBUSY.
498 *
499 * CAMERA_MODULE_API_VERSION_2_3 or lower:
500 *
501 * Calls to get_camera_info must still succeed, as if the camera was in the
502 * PRESENT status.
503 *
504 * CAMERA_MODULE_API_VERSION_2_4:
505 *
506 * The camera device at this status must return -EINVAL for get_camera_info for call,
507 * as the device is not ready.
Igor Murashkin152b50f2013-03-18 13:30:14 -0700508 */
509 CAMERA_DEVICE_STATUS_ENUMERATING = 2,
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800510
511} camera_device_status_t;
512
513/**
Chien-Yu Chen30159172015-01-08 11:06:38 -0800514 * torch_mode_status_t:
515 *
516 * The current status of the torch mode, as provided by the HAL through the
517 * camera_module_callbacks.torch_mode_status_change() call.
518 *
519 * The torch mode status of a camera device is applicable only when the camera
520 * device is present. The framework will not call set_torch_mode() to turn on
521 * torch mode of a camera device if the camera device is not present. At module
522 * load time, the framework will assume torch modes are in the
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700523 * TORCH_MODE_STATUS_AVAILABLE_OFF state if the camera device is present and
Chien-Yu Chen30159172015-01-08 11:06:38 -0800524 * android.flash.info.available is reported as true via get_camera_info() call.
525 *
526 * The behaviors of the camera HAL module that the framework expects in the
527 * following situations when a camera device's status changes:
528 * 1. A previously-disconnected camera device becomes connected.
529 * After camera_module_callbacks::camera_device_status_change() is invoked
530 * to inform the framework that the camera device is present, the framework
531 * will assume the camera device's torch mode is in
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700532 * TORCH_MODE_STATUS_AVAILABLE_OFF state. The camera HAL module does not need
Chien-Yu Chen30159172015-01-08 11:06:38 -0800533 * to invoke camera_module_callbacks::torch_mode_status_change() unless the
534 * flash unit is unavailable to use by set_torch_mode().
535 *
536 * 2. A previously-connected camera becomes disconnected.
537 * After camera_module_callbacks::camera_device_status_change() is invoked
538 * to inform the framework that the camera device is not present, the
539 * framework will not call set_torch_mode() for the disconnected camera
540 * device until its flash unit becomes available again. The camera HAL
541 * module does not need to invoke
542 * camera_module_callbacks::torch_mode_status_change() separately to inform
543 * that the flash unit has become unavailable.
544 *
545 * 3. open() is called to open a camera device.
546 * The camera HAL module must invoke
547 * camera_module_callbacks::torch_mode_status_change() for all flash units
Chien-Yu Chen85585102015-02-25 14:50:13 -0800548 * that have entered TORCH_MODE_STATUS_NOT_AVAILABLE state and can not be
Chien-Yu Chen30159172015-01-08 11:06:38 -0800549 * turned on by calling set_torch_mode() anymore due to this open() call.
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700550 * open() must not trigger TORCH_MODE_STATUS_AVAILABLE_OFF before
551 * TORCH_MODE_STATUS_NOT_AVAILABLE for all flash units that have become
552 * unavailable.
Chien-Yu Chen30159172015-01-08 11:06:38 -0800553 *
554 * 4. close() is called to close a camera device.
555 * The camera HAL module must invoke
556 * camera_module_callbacks::torch_mode_status_change() for all flash units
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700557 * that have entered TORCH_MODE_STATUS_AVAILABLE_OFF state and can be turned
Chien-Yu Chen30159172015-01-08 11:06:38 -0800558 * on by calling set_torch_mode() again because of enough resources freed
559 * up by this close() call.
560 *
Chien-Yu Chen85585102015-02-25 14:50:13 -0800561 * Note that the framework calling set_torch_mode() successfully must trigger
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700562 * TORCH_MODE_STATUS_AVAILABLE_OFF or TORCH_MODE_STATUS_AVAILABLE_ON callback
563 * for the given camera device. Additionally it must trigger
564 * TORCH_MODE_STATUS_AVAILABLE_OFF callbacks for other previously-on torch
565 * modes if HAL cannot keep multiple torch modes on simultaneously.
Chien-Yu Chen30159172015-01-08 11:06:38 -0800566 */
567typedef enum torch_mode_status {
Chien-Yu Chen30159172015-01-08 11:06:38 -0800568
569 /**
570 * The flash unit is no longer available and the torch mode can not be
571 * turned on by calling set_torch_mode(). If the torch mode is on, it
572 * will be turned off by HAL before HAL calls torch_mode_status_change().
573 */
Chien-Yu Chen85585102015-02-25 14:50:13 -0800574 TORCH_MODE_STATUS_NOT_AVAILABLE = 0,
Chien-Yu Chen30159172015-01-08 11:06:38 -0800575
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800576 /**
Chien-Yu Chen85585102015-02-25 14:50:13 -0800577 * A torch mode has become off and available to be turned on via
578 * set_torch_mode(). This may happen in the following
579 * cases:
580 * 1. After the resources to turn on the torch mode have become available.
581 * 2. After set_torch_mode() is called to turn off the torch mode.
582 * 3. After the framework turned on the torch mode of some other camera
583 * device and HAL had to turn off the torch modes of any camera devices
584 * that were previously on.
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800585 */
Chien-Yu Chen85585102015-02-25 14:50:13 -0800586 TORCH_MODE_STATUS_AVAILABLE_OFF = 1,
587
588 /**
589 * A torch mode has become on and available to be turned off via
590 * set_torch_mode(). This can happen only after set_torch_mode() is called
591 * to turn on the torch mode.
592 */
593 TORCH_MODE_STATUS_AVAILABLE_ON = 2,
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800594
Chien-Yu Chen30159172015-01-08 11:06:38 -0800595} torch_mode_status_t;
596
597/**
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800598 * Callback functions for the camera HAL module to use to inform the framework
Chien-Yu Chen30159172015-01-08 11:06:38 -0800599 * of changes to the camera subsystem.
600 *
601 * Version information (based on camera_module_t.common.module_api_version):
602 *
603 * Each callback is called only by HAL modules implementing the indicated
604 * version or higher of the HAL module API interface.
605 *
606 * CAMERA_MODULE_API_VERSION_2_1:
607 * camera_device_status_change()
608 *
609 * CAMERA_MODULE_API_VERSION_2_4:
610 * torch_mode_status_change()
611
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800612 */
613typedef struct camera_module_callbacks {
614
615 /**
616 * camera_device_status_change:
617 *
618 * Callback to the framework to indicate that the state of a specific camera
619 * device has changed. At module load time, the framework will assume all
620 * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL
621 * must call this method to inform the framework of any initially
622 * NOT_PRESENT devices.
623 *
Chien-Yu Chen30159172015-01-08 11:06:38 -0800624 * This callback is added for CAMERA_MODULE_API_VERSION_2_1.
625 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800626 * camera_module_callbacks: The instance of camera_module_callbacks_t passed
627 * to the module with set_callbacks.
628 *
629 * camera_id: The ID of the camera device that has a new status.
630 *
631 * new_status: The new status code, one of the camera_device_status_t enums,
632 * or a platform-specific status.
633 *
634 */
635 void (*camera_device_status_change)(const struct camera_module_callbacks*,
636 int camera_id,
637 int new_status);
638
Chien-Yu Chen30159172015-01-08 11:06:38 -0800639 /**
640 * torch_mode_status_change:
641 *
642 * Callback to the framework to indicate that the state of the torch mode
643 * of the flash unit associated with a specific camera device has changed.
644 * At module load time, the framework will assume the torch modes are in
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -0700645 * the TORCH_MODE_STATUS_AVAILABLE_OFF state if android.flash.info.available
Chien-Yu Chen30159172015-01-08 11:06:38 -0800646 * is reported as true via get_camera_info() call.
647 *
648 * This callback is added for CAMERA_MODULE_API_VERSION_2_4.
649 *
650 * camera_module_callbacks: The instance of camera_module_callbacks_t
651 * passed to the module with set_callbacks.
652 *
653 * camera_id: The ID of camera device whose flash unit has a new torch mode
654 * status.
655 *
656 * new_status: The new status code, one of the torch_mode_status_t enums.
657 */
658 void (*torch_mode_status_change)(const struct camera_module_callbacks*,
659 const char* camera_id,
660 int new_status);
661
662
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800663} camera_module_callbacks_t;
664
Emilian Peev8ca3c602018-10-29 09:37:04 +0000665/**
666 * camera_stream_t:
667 *
668 * A handle to a single camera input or output stream. A stream is defined by
669 * the framework by its buffer resolution and format and gralloc usage flags.
670 *
671 * The stream structures are owned by the framework and pointers to a
672 * camera_stream passed into the HAL by is_stream_combination_supported() are
673 * only valid within the scope of the call.
674 *
675 * All camera_stream members are immutable.
676 */
677typedef struct camera_stream {
678 /**
679 * The type of the stream, one of the camera3_stream_type_t values.
680 */
681 int stream_type;
682
683 /**
684 * The width in pixels of the buffers in this stream
685 */
686 uint32_t width;
687
688 /**
689 * The height in pixels of the buffers in this stream
690 */
691 uint32_t height;
692
693 /**
694 * The pixel format for the buffers in this stream. Format is a value from
695 * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or
696 * from device-specific headers.
697 *
698 * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
699 * gralloc module will select a format based on the usage flags provided by
700 * the camera device and the other endpoint of the stream.
701 *
702 */
703 int format;
704
705 /**
706 * The gralloc usage flags for this stream, as needed by the HAL. The usage
707 * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific
708 * headers.
709 *
710 * For output streams, these are the HAL's producer usage flags. For input
711 * streams, these are the HAL's consumer usage flags. The usage flags from
712 * the producer and the consumer will be combined together and then passed
713 * to the platform gralloc HAL module for allocating the gralloc buffers for
714 * each stream.
715 *
716 * The usage flag for an output stream may be bitwise
717 * combination of usage flags for multiple consumers, for the purpose of
718 * sharing one camera stream between those consumers. The HAL must fail
719 * the stream combination query call with -EINVAL if the combined flags cannot be
720 * supported due to imcompatible buffer format, dataSpace, or other hardware
721 * limitations.
722 */
723 uint32_t usage;
724
725 /**
726 * A field that describes the contents of the buffer. The format and buffer
727 * dimensions define the memory layout and structure of the stream buffers,
728 * while dataSpace defines the meaning of the data within the buffer.
729 *
730 * For most formats, dataSpace defines the color space of the image data.
731 * In addition, for some formats, dataSpace indicates whether image- or
732 * depth-based data is requested. See system/core/include/system/graphics.h
733 * for details of formats and valid dataSpace values for each format.
734 *
735 * Always set by the camera service. The dataspace values are set
736 * using the V0 dataspace definitions in graphics.h
737 */
738 android_dataspace_t data_space;
739
740 /**
741 * The required output rotation of the stream, one of
742 * the camera3_stream_rotation_t values. This must be inspected by HAL along
743 * with stream width and height. For example, if the rotation is 90 degree
744 * and the stream width and height is 720 and 1280 respectively, camera service
745 * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image
746 * and rotate the image by 90 degree counterclockwise. The rotation field is
747 * no-op when the stream type is input. Camera HAL must ignore the rotation
748 * field for an input stream.
749 *
750 * Always set by camera service. HAL must inspect this field during stream
751 * combination query and return -EINVAL if it cannot perform such rotation.
752 * HAL must always support CAMERA3_STREAM_ROTATION_0, so a
753 * is_stream_combination_supported() call must not fail for unsupported rotation if
754 * rotation field of all streams is CAMERA3_STREAM_ROTATION_0.
755 *
756 */
757 int rotation;
758
759 /**
760 * The physical camera id this stream belongs to.
761 * Always set by camera service. If the camera device is not a logical
762 * multi camera, or if the camera is a logical multi camera but the stream
763 * is not a physical output stream, this field will point to a 0-length
764 * string.
765 *
766 * A logical multi camera is a camera device backed by multiple physical
767 * cameras that are also exposed to the application. And for a logical
768 * multi camera, a physical output stream is an output stream specifically
769 * requested on an underlying physical camera.
770 *
771 * For an input stream, this field is guaranteed to be a 0-length string.
772 */
773 const char* physical_camera_id;
774
775} camera_stream_t;
776
777/**
778 * camera_stream_combination_t:
779 *
780 * A structure of stream definitions, used by is_stream_combination_supported(). This
781 * structure defines all the input & output streams for specific camera use case.
782 */
783typedef struct camera_stream_combination {
784 /**
785 * The total number of streams by the framework. This includes
786 * both input and output streams. The number of streams will be at least 1,
787 * and there will be at least one output-capable stream.
788 */
789 uint32_t num_streams;
790
791 /**
792 * An array of camera streams, defining the input/output
793 * stream combination for the camera HAL device.
794 *
795 * At most one input-capable stream may be defined.
796 *
797 * At least one output-capable stream must be defined.
798 */
799 camera_stream_t *streams;
800
801 /**
802 * The operation mode of streams in this stream combination, one of the value
803 * defined in camera3_stream_configuration_mode_t.
804 *
805 */
806 uint32_t operation_mode;
807
808} camera_stream_combination_t;
809
Shuzhen Wangfc590b62018-12-26 14:34:56 -0800810/**
811 * device_state_t:
812 *
813 * Possible physical states of the overall device, for use with
814 * notify_device_state_change.
815 */
816typedef enum device_state {
817 /**
818 * The device is in its normal physical configuration. This is the default if the
819 * device does not support multiple different states.
820 */
821 NORMAL = 0,
822
823 /**
824 * Camera device(s) facing backward are covered.
825 */
826 BACK_COVERED = 1 << 0,
827
828 /**
829 * Camera device(s) facing foward are covered.
830 */
831 FRONT_COVERED = 1 << 1,
832
833 /**
834 * The device is folded. If not set, the device is unfolded or does not
835 * support folding.
836 *
837 * The exact point when this status change happens during the folding
838 * operation is device-specific.
839 */
840 FOLDED = 1 << 2,
841
842 /**
843 * First vendor-specific device state. All bits above and including this one
844 * are for vendor state values. Values below this one must only be used
845 * for framework-defined states.
846 */
847 VENDOR_STATE_START = 1LL << 32
848
849} device_state_t;
850
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800851typedef struct camera_module {
Stewart Miles84d35492014-05-01 09:03:27 -0700852 /**
853 * Common methods of the camera module. This *must* be the first member of
854 * camera_module as users of this structure will cast a hw_module_t to
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700855 * camera_module pointer in contexts where it's known the hw_module_t
856 * references a camera_module.
857 *
858 * The return values for common.methods->open for camera_module are:
859 *
860 * 0: On a successful open of the camera device.
861 *
862 * -ENODEV: The camera device cannot be opened due to an internal
863 * error.
864 *
865 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
866 * and/or the module is invalid.
867 *
868 * -EBUSY: The camera device was already opened for this camera id
869 * (by using this method or open_legacy),
870 * regardless of the device HAL version it was opened as.
871 *
872 * -EUSERS: The maximal number of camera devices that can be
873 * opened concurrently were opened already, either by
874 * this method or the open_legacy method.
875 *
876 * All other return values from common.methods->open will be treated as
877 * -ENODEV.
Stewart Miles84d35492014-05-01 09:03:27 -0700878 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800879 hw_module_t common;
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800880
881 /**
882 * get_number_of_cameras:
883 *
884 * Returns the number of camera devices accessible through the camera
885 * module. The camera devices are numbered 0 through N-1, where N is the
886 * value returned by this call. The name of the camera device for open() is
887 * simply the number converted to a string. That is, "0" for camera ID 0,
888 * "1" for camera ID 1.
889 *
Zhijun He94e23b22015-01-12 14:45:33 -0800890 * Version information (based on camera_module_t.common.module_api_version):
891 *
892 * CAMERA_MODULE_API_VERSION_2_3 or lower:
893 *
894 * The value here must be static, and cannot change after the first call
895 * to this method.
896 *
897 * CAMERA_MODULE_API_VERSION_2_4 or higher:
898 *
899 * The value here must be static, and must count only built-in cameras,
900 * which have CAMERA_FACING_BACK or CAMERA_FACING_FRONT camera facing values
901 * (camera_info.facing). The HAL must not include the external cameras
902 * (camera_info.facing == CAMERA_FACING_EXTERNAL) into the return value
903 * of this call. Frameworks will use camera_device_status_change callback
904 * to manage number of external cameras.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800905 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800906 int (*get_number_of_cameras)(void);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800907
908 /**
909 * get_camera_info:
910 *
911 * Return the static camera information for a given camera device. This
912 * information may not change for a camera device.
913 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700914 * Return values:
915 *
916 * 0: On a successful operation
917 *
918 * -ENODEV: The information cannot be provided due to an internal
919 * error.
920 *
921 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
922 * and/or the module is invalid.
Zhijun He94e23b22015-01-12 14:45:33 -0800923 *
924 * Version information (based on camera_module_t.common.module_api_version):
925 *
926 * CAMERA_MODULE_API_VERSION_2_4 or higher:
927 *
928 * When a camera is disconnected, its camera id becomes invalid. Calling this
929 * this method with this invalid camera id will get -EINVAL and NULL camera
930 * static metadata (camera_info.static_camera_characteristics).
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800931 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800932 int (*get_camera_info)(int camera_id, struct camera_info *info);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800933
934 /**
935 * set_callbacks:
936 *
937 * Provide callback function pointers to the HAL module to inform framework
938 * of asynchronous camera module events. The framework will call this
939 * function once after initial camera HAL module load, after the
940 * get_number_of_cameras() method is called for the first time, and before
941 * any other calls to the module.
942 *
943 * Version information (based on camera_module_t.common.module_api_version):
944 *
945 * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0:
946 *
947 * Not provided by HAL module. Framework may not call this function.
948 *
949 * CAMERA_MODULE_API_VERSION_2_1:
950 *
951 * Valid to be called by the framework.
952 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700953 * Return values:
954 *
955 * 0: On a successful operation
956 *
957 * -ENODEV: The operation cannot be completed due to an internal
958 * error.
959 *
960 * -EINVAL: The input arguments are invalid, i.e. the callbacks are
961 * null
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800962 */
963 int (*set_callbacks)(const camera_module_callbacks_t *callbacks);
964
Alex Ray19b2cea2013-06-13 12:40:52 -0700965 /**
966 * get_vendor_tag_ops:
967 *
968 * Get methods to query for vendor extension metadata tag information. The
969 * HAL should fill in all the vendor tag operation methods, or leave ops
970 * unchanged if no vendor tags are defined.
971 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800972 * The vendor_tag_ops structure used here is defined in:
973 * system/media/camera/include/system/vendor_tags.h
974 *
Alex Ray19b2cea2013-06-13 12:40:52 -0700975 * Version information (based on camera_module_t.common.module_api_version):
976 *
977 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1:
978 * Not provided by HAL module. Framework may not call this function.
979 *
980 * CAMERA_MODULE_API_VERSION_2_2:
981 * Valid to be called by the framework.
982 */
983 void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops);
984
Zhijun Hebcdebf32014-06-06 15:42:17 -0700985 /**
986 * open_legacy:
987 *
988 * Open a specific legacy camera HAL device if multiple device HAL API
989 * versions are supported by this camera HAL module. For example, if the
990 * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and
991 * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id,
992 * framework can call this function to open the camera device as
993 * CAMERA_DEVICE_API_VERSION_1_0 device.
994 *
995 * This is an optional method. A Camera HAL module does not need to support
996 * more than one device HAL version per device, and such modules may return
997 * -ENOSYS for all calls to this method. For all older HAL device API
998 * versions that are not supported, it may return -EOPNOTSUPP. When above
999 * cases occur, The normal open() method (common.methods->open) will be
1000 * used by the framework instead.
1001 *
1002 * Version information (based on camera_module_t.common.module_api_version):
1003 *
1004 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2:
1005 * Not provided by HAL module. Framework will not call this function.
1006 *
1007 * CAMERA_MODULE_API_VERSION_2_3:
1008 * Valid to be called by the framework.
1009 *
1010 * Return values:
1011 *
1012 * 0: On a successful open of the camera device.
1013 *
1014 * -ENOSYS This method is not supported.
1015 *
1016 * -EOPNOTSUPP: The requested HAL version is not supported by this method.
1017 *
1018 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
1019 * and/or the module is invalid.
1020 *
1021 * -EBUSY: The camera device was already opened for this camera id
1022 * (by using this method or common.methods->open method),
1023 * regardless of the device HAL version it was opened as.
1024 *
1025 * -EUSERS: The maximal number of camera devices that can be
1026 * opened concurrently were opened already, either by
1027 * this method or common.methods->open method.
1028 */
1029 int (*open_legacy)(const struct hw_module_t* module, const char* id,
1030 uint32_t halVersion, struct hw_device_t** device);
1031
Chien-Yu Chen30159172015-01-08 11:06:38 -08001032 /**
1033 * set_torch_mode:
1034 *
1035 * Turn on or off the torch mode of the flash unit associated with a given
Chien-Yu Chen85585102015-02-25 14:50:13 -08001036 * camera ID. If the operation is successful, HAL must notify the framework
1037 * torch state by invoking
1038 * camera_module_callbacks.torch_mode_status_change() with the new state.
Chien-Yu Chen30159172015-01-08 11:06:38 -08001039 *
1040 * The camera device has a higher priority accessing the flash unit. When
1041 * there are any resource conflicts, such as open() is called to open a
1042 * camera device, HAL module must notify the framework through
1043 * camera_module_callbacks.torch_mode_status_change() that the
1044 * torch mode has been turned off and the torch mode state has become
Chien-Yu Chen85585102015-02-25 14:50:13 -08001045 * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode
Chien-Yu Chen30159172015-01-08 11:06:38 -08001046 * become available again, HAL module must notify the framework through
1047 * camera_module_callbacks.torch_mode_status_change() that the torch mode
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -07001048 * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to
1049 * be called.
Chien-Yu Chen30159172015-01-08 11:06:38 -08001050 *
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -08001051 * When the framework calls set_torch_mode() to turn on the torch mode of a
1052 * flash unit, if HAL cannot keep multiple torch modes on simultaneously,
1053 * HAL should turn off the torch mode that was turned on by
1054 * a previous set_torch_mode() call and notify the framework that the torch
Chien-Yu Chen5c6230e2015-06-03 13:36:33 -07001055 * mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF.
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -08001056 *
Chien-Yu Chen30159172015-01-08 11:06:38 -08001057 * Version information (based on camera_module_t.common.module_api_version):
1058 *
1059 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
1060 * Not provided by HAL module. Framework will not call this function.
1061 *
1062 * CAMERA_MODULE_API_VERSION_2_4:
1063 * Valid to be called by the framework.
1064 *
1065 * Return values:
1066 *
1067 * 0: On a successful operation.
1068 *
1069 * -ENOSYS: The camera device does not support this operation. It is
1070 * returned if and only if android.flash.info.available is
1071 * false.
1072 *
Chien-Yu Chen273def32015-02-11 11:31:12 -08001073 * -EBUSY: The camera device is already in use.
1074 *
1075 * -EUSERS: The resources needed to turn on the torch mode are not
1076 * available, typically because other camera devices are
1077 * holding the resources to make using the flash unit not
1078 * possible.
Chien-Yu Chen30159172015-01-08 11:06:38 -08001079 *
1080 * -EINVAL: camera_id is invalid.
1081 *
1082 */
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -08001083 int (*set_torch_mode)(const char* camera_id, bool enabled);
Chien-Yu Chen30159172015-01-08 11:06:38 -08001084
Eino-Ville Talvalaaee47822015-04-07 13:47:46 -07001085 /**
1086 * init:
1087 *
1088 * This method is called by the camera service before any other methods
1089 * are invoked, right after the camera HAL library has been successfully
1090 * loaded. It may be left as NULL by the HAL module, if no initialization
1091 * in needed.
1092 *
1093 * It can be used by HAL implementations to perform initialization and
1094 * other one-time operations.
1095 *
1096 * Version information (based on camera_module_t.common.module_api_version):
1097 *
1098 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
1099 * Not provided by HAL module. Framework will not call this function.
1100 *
1101 * CAMERA_MODULE_API_VERSION_2_4:
1102 * If not NULL, will always be called by the framework once after the HAL
1103 * module is loaded, before any other HAL module method is called.
1104 *
1105 * Return values:
1106 *
1107 * 0: On a successful operation.
1108 *
1109 * -ENODEV: Initialization cannot be completed due to an internal
1110 * error. The HAL must be assumed to be in a nonfunctional
1111 * state.
1112 *
1113 */
1114 int (*init)();
1115
Shuzhen Wanga8caa6a2018-08-24 11:07:50 -07001116 /**
1117 * get_physical_camera_info:
1118 *
1119 * Return the static metadata for a physical camera as a part of a logical
1120 * camera device. This function is only called for those physical camera
1121 * ID(s) that are not exposed independently. In other words, camera_id will
1122 * be greater or equal to the return value of get_number_of_cameras().
1123 *
1124 * Return values:
1125 *
1126 * 0: On a successful operation
1127 *
1128 * -ENODEV: The information cannot be provided due to an internal
1129 * error.
1130 *
1131 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
1132 * and/or the module is invalid.
1133 *
1134 * Version information (based on camera_module_t.common.module_api_version):
1135 *
1136 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3/2_4:
1137 * Not provided by HAL module. Framework will not call this function.
1138 *
1139 * CAMERA_MODULE_API_VERSION_2_5 or higher:
1140 * If any of the camera devices accessible through this camera module is
1141 * a logical multi-camera, and at least one of the physical cameras isn't
1142 * a stand-alone camera device, this function will be called by the camera
1143 * framework. Calling this function with invalid physical_camera_id will
1144 * get -EINVAL, and NULL static_metadata.
1145 */
1146 int (*get_physical_camera_info)(int physical_camera_id,
1147 camera_metadata_t **static_metadata);
1148
Emilian Peev8ca3c602018-10-29 09:37:04 +00001149 /**
1150 * is_stream_combination_supported:
1151 *
1152 * Check for device support of specific camera stream combination.
1153 *
1154 * Return values:
1155 *
1156 * 0: In case the stream combination is supported.
1157 *
1158 * -EINVAL: In case the stream combination is not supported.
1159 *
1160 * -ENOSYS: In case stream combination query is not supported.
1161 *
1162 * Version information (based on camera_module_t.common.module_api_version):
1163 *
1164 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3/2_4:
1165 * Not provided by HAL module. Framework will not call this function.
1166 *
1167 * CAMERA_MODULE_API_VERSION_2_5 or higher:
1168 * Valid to be called by the framework.
1169 */
1170 int (*is_stream_combination_supported)(int camera_id,
1171 const camera_stream_combination_t *streams);
1172
Shuzhen Wangfc590b62018-12-26 14:34:56 -08001173 /**
1174 * notify_device_state_change:
1175 *
1176 * Notify the camera module that the state of the overall device has
1177 * changed in some way that the HAL may want to know about.
1178 *
1179 * For example, a physical shutter may have been uncovered or covered,
1180 * or a camera may have been covered or uncovered by an add-on keyboard
1181 * or other accessory.
1182 *
1183 * The state is a bitfield of potential states, and some physical configurations
1184 * could plausibly correspond to multiple different combinations of state bits.
1185 * The HAL must ignore any state bits it is not actively using to determine
1186 * the appropriate camera configuration.
1187 *
1188 * For example, on some devices the FOLDED state could mean that
1189 * backward-facing cameras are covered by the fold, so FOLDED by itself implies
1190 * BACK_COVERED. But other devices may support folding but not cover any cameras
1191 * when folded, so for those FOLDED would not imply any of the other flags.
1192 * Since these relationships are very device-specific, it is difficult to specify
1193 * a comprehensive policy. But as a recommendation, it is suggested that if a flag
1194 * necessarily implies other flags are set as well, then those flags should be set.
1195 * So even though FOLDED would be enough to infer BACK_COVERED on some devices, the
1196 * BACK_COVERED flag should also be set for clarity.
1197 *
1198 * This method may be invoked by the HAL client at any time. It must not
1199 * cause any active camera device sessions to be closed, but may dynamically
1200 * change which physical camera a logical multi-camera is using for its
1201 * active and future output.
1202 *
1203 * The method must be invoked by the HAL client at least once before the
1204 * client calls ICameraDevice::open on any camera device interfaces listed
1205 * by this provider, to establish the initial device state.
1206 *
1207 * Note that the deviceState is 64-bit bitmask, with system defined states in
1208 * lower 32-bit and vendor defined states in upper 32-bit.
1209 */
1210 void (*notify_device_state_change)(uint64_t deviceState);
1211
Alex Ray19b2cea2013-06-13 12:40:52 -07001212 /* reserved for future use */
Shuzhen Wangfc590b62018-12-26 14:34:56 -08001213 void* reserved[2];
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -08001214} camera_module_t;
1215
1216__END_DECLS
1217
1218#endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */