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