blob: 88c437969284e5e910512a42eedf562a7f4503de [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.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800110 */
111
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700112/**
113 * Predefined macros for currently-defined version numbers
114 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800115
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700116/**
117 * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated
118 * as CAMERA_MODULE_API_VERSION_1_0
119 */
120#define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
121#define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800122#define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1)
Alex Ray19b2cea2013-06-13 12:40:52 -0700123#define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2)
Zhijun Hebcdebf32014-06-06 15:42:17 -0700124#define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3)
Chien-Yu Chen30159172015-01-08 11:06:38 -0800125#define CAMERA_MODULE_API_VERSION_2_4 HARDWARE_MODULE_API_VERSION(2, 4)
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700126
Chien-Yu Chen30159172015-01-08 11:06:38 -0800127#define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_4
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700128
129/**
130 * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated
131 * as CAMERA_DEVICE_API_VERSION_1_0
132 */
133#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
134#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800135#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800136#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0)
Eino-Ville Talvala9d518562013-07-30 14:58:31 -0700137#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1)
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800138#define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2)
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700139
Eino-Ville Talvalab5459832014-09-09 16:42:27 -0700140// Device version 3.2 is current, older HAL camera device versions are not
141// recommended for new devices.
142#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_2
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800143
144/**
James Dongd0ca70d2012-03-26 16:22:35 -0700145 * Defined in /system/media/camera/include/system/camera_metadata.h
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800146 */
147typedef struct camera_metadata camera_metadata_t;
148
Alex Ray9acc7402013-02-07 15:44:24 -0800149typedef struct camera_info {
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800150 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800151 * The direction that the camera faces to. See system/core/include/system/camera.h
152 * for camera facing definitions.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800153 *
Zhijun He94e23b22015-01-12 14:45:33 -0800154 * Version information (based on camera_module_t.common.module_api_version):
155 *
156 * CAMERA_MODULE_API_VERSION_2_3 or lower:
157 *
158 * It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT.
159 *
160 * CAMERA_MODULE_API_VERSION_2_4 or higher:
161 *
162 * It should be CAMERA_FACING_BACK, CAMERA_FACING_FRONT or
163 * CAMERA_FACING_EXTERNAL.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800164 */
165 int facing;
166
167 /**
168 * The orientation of the camera image. The value is the angle that the
169 * camera image needs to be rotated clockwise so it shows correctly on the
170 * display in its natural orientation. It should be 0, 90, 180, or 270.
171 *
172 * For example, suppose a device has a naturally tall screen. The
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800173 * back-facing camera sensor is mounted in landscape. You are looking at the
174 * screen. If the top side of the camera sensor is aligned with the right
175 * edge of the screen in natural orientation, the value should be 90. If the
176 * top side of a front-facing camera sensor is aligned with the right of the
177 * screen, the value should be 270.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800178 *
Zhijun He94e23b22015-01-12 14:45:33 -0800179 * Version information (based on camera_module_t.common.module_api_version):
180 *
181 * CAMERA_MODULE_API_VERSION_2_3 or lower:
182 *
183 * Valid in all camera_module versions.
184 *
185 * CAMERA_MODULE_API_VERSION_2_4 or higher:
186 *
187 * Valid if camera facing is CAMERA_FACING_BACK or CAMERA_FACING_FRONT,
188 * not valid if camera facing is CAMERA_FACING_EXTERNAL.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800189 */
190 int orientation;
191
192 /**
193 * The value of camera_device_t.common.version.
194 *
195 * Version information (based on camera_module_t.common.module_api_version):
196 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700197 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800198 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700199 * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800200 * not read this field.
201 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800202 * CAMERA_MODULE_API_VERSION_2_0 or higher:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800203 *
204 * Always valid
205 *
206 */
207 uint32_t device_version;
208
209 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800210 * The camera's fixed characteristics, which include all static camera metadata
211 * specified in system/media/camera/docs/docs.html. This should be a sorted metadata
212 * buffer, and may not be modified or freed by the caller. The pointer should remain
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800213 * valid for the lifetime of the camera module, and values in it may not
214 * change after it is returned by get_camera_info().
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800215 *
216 * Version information (based on camera_module_t.common.module_api_version):
217 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700218 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800219 *
220 * Not valid. Extra characteristics are not available. Do not read this
221 * field.
222 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800223 * CAMERA_MODULE_API_VERSION_2_0 or higher:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800224 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700225 * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read
226 * otherwise.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800227 *
228 */
Eino-Ville Talvalab8b64392012-08-24 12:32:17 -0700229 const camera_metadata_t *static_camera_characteristics;
Alex Ray9acc7402013-02-07 15:44:24 -0800230} camera_info_t;
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800231
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800232/**
233 * camera_device_status_t:
234 *
235 * The current status of the camera device, as provided by the HAL through the
236 * camera_module_callbacks.camera_device_status_change() call.
Igor Murashkin152b50f2013-03-18 13:30:14 -0700237 *
238 * At module load time, the framework will assume all camera devices are in the
239 * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke
240 * camera_module_callbacks::camera_device_status_change to inform the framework
241 * of any initially NOT_PRESENT devices.
242 *
243 * Allowed transitions:
244 * PRESENT -> NOT_PRESENT
245 * NOT_PRESENT -> ENUMERATING
246 * NOT_PRESENT -> PRESENT
247 * ENUMERATING -> PRESENT
248 * ENUMERATING -> NOT_PRESENT
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800249 */
250typedef enum camera_device_status {
251 /**
252 * The camera device is not currently connected, and opening it will return
Zhijun He94e23b22015-01-12 14:45:33 -0800253 * failure.
254 *
255 * Version information (based on camera_module_t.common.module_api_version):
256 *
257 * CAMERA_MODULE_API_VERSION_2_3 or lower:
258 *
259 * Calls to get_camera_info must still succeed, and provide the same information
260 * it would if the camera were connected.
261 *
262 * CAMERA_MODULE_API_VERSION_2_4:
263 *
264 * The camera device at this status must return -EINVAL for get_camera_info call,
265 * as the device is not connected.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800266 */
267 CAMERA_DEVICE_STATUS_NOT_PRESENT = 0,
268
269 /**
Zhijun He94e23b22015-01-12 14:45:33 -0800270 * The camera device is connected, and opening it will succeed.
271 *
272 * CAMERA_MODULE_API_VERSION_2_3 or lower:
273 *
274 * The information returned by get_camera_info cannot change due to this status
275 * change. By default, the framework will assume all devices are in this state.
276 *
277 * CAMERA_MODULE_API_VERSION_2_4:
278 *
279 * The information returned by get_camera_info will become valid after a device's
280 * status changes to this. By default, the framework will assume all devices are in
281 * this state.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800282 */
Igor Murashkin152b50f2013-03-18 13:30:14 -0700283 CAMERA_DEVICE_STATUS_PRESENT = 1,
284
285 /**
286 * The camera device is connected, but it is undergoing an enumeration and
Zhijun He94e23b22015-01-12 14:45:33 -0800287 * so opening the device will return -EBUSY.
288 *
289 * CAMERA_MODULE_API_VERSION_2_3 or lower:
290 *
291 * Calls to get_camera_info must still succeed, as if the camera was in the
292 * PRESENT status.
293 *
294 * CAMERA_MODULE_API_VERSION_2_4:
295 *
296 * The camera device at this status must return -EINVAL for get_camera_info for call,
297 * as the device is not ready.
Igor Murashkin152b50f2013-03-18 13:30:14 -0700298 */
299 CAMERA_DEVICE_STATUS_ENUMERATING = 2,
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800300
301} camera_device_status_t;
302
303/**
Chien-Yu Chen30159172015-01-08 11:06:38 -0800304 * torch_mode_status_t:
305 *
306 * The current status of the torch mode, as provided by the HAL through the
307 * camera_module_callbacks.torch_mode_status_change() call.
308 *
309 * The torch mode status of a camera device is applicable only when the camera
310 * device is present. The framework will not call set_torch_mode() to turn on
311 * torch mode of a camera device if the camera device is not present. At module
312 * load time, the framework will assume torch modes are in the
313 * TORCH_MODE_STATUS_AVAILABLE state if the camera device is present and
314 * android.flash.info.available is reported as true via get_camera_info() call.
315 *
316 * The behaviors of the camera HAL module that the framework expects in the
317 * following situations when a camera device's status changes:
318 * 1. A previously-disconnected camera device becomes connected.
319 * After camera_module_callbacks::camera_device_status_change() is invoked
320 * to inform the framework that the camera device is present, the framework
321 * will assume the camera device's torch mode is in
322 * TORCH_MODE_STATUS_AVAILABLE state. The camera HAL module does not need
323 * to invoke camera_module_callbacks::torch_mode_status_change() unless the
324 * flash unit is unavailable to use by set_torch_mode().
325 *
326 * 2. A previously-connected camera becomes disconnected.
327 * After camera_module_callbacks::camera_device_status_change() is invoked
328 * to inform the framework that the camera device is not present, the
329 * framework will not call set_torch_mode() for the disconnected camera
330 * device until its flash unit becomes available again. The camera HAL
331 * module does not need to invoke
332 * camera_module_callbacks::torch_mode_status_change() separately to inform
333 * that the flash unit has become unavailable.
334 *
335 * 3. open() is called to open a camera device.
336 * The camera HAL module must invoke
337 * camera_module_callbacks::torch_mode_status_change() for all flash units
338 * that have entered TORCH_MODE_STATUS_RESOURCE_BUSY state and can not be
339 * turned on by calling set_torch_mode() anymore due to this open() call.
340 *
341 * 4. close() is called to close a camera device.
342 * The camera HAL module must invoke
343 * camera_module_callbacks::torch_mode_status_change() for all flash units
344 * that have entered TORCH_MODE_STATUS_AVAILABLE state and can be turned
345 * on by calling set_torch_mode() again because of enough resources freed
346 * up by this close() call.
347 *
348 * Note that the framework calling set_torch_mode() should not trigger any
349 * callbacks.
350 */
351typedef enum torch_mode_status {
352 /**
353 * The flash unit is available and the torch mode can be turned on by
354 * calling set_torch_mode(). By default, the framework will assume all
355 * flash units of all present camera devices are in this state if
356 * android.flash.info.available is reported as true via get_camera_info()
357 * call.
358 */
359 TORCH_MODE_STATUS_AVAILABLE = 0,
360
361 /**
362 * The flash unit is no longer available and the torch mode can not be
363 * turned on by calling set_torch_mode(). If the torch mode is on, it
364 * will be turned off by HAL before HAL calls torch_mode_status_change().
365 */
366 TORCH_MODE_STATUS_RESOURCE_BUSY = 1,
367
368} torch_mode_status_t;
369
370/**
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800371 * Callback functions for the camera HAL module to use to inform the framework
Chien-Yu Chen30159172015-01-08 11:06:38 -0800372 * of changes to the camera subsystem.
373 *
374 * Version information (based on camera_module_t.common.module_api_version):
375 *
376 * Each callback is called only by HAL modules implementing the indicated
377 * version or higher of the HAL module API interface.
378 *
379 * CAMERA_MODULE_API_VERSION_2_1:
380 * camera_device_status_change()
381 *
382 * CAMERA_MODULE_API_VERSION_2_4:
383 * torch_mode_status_change()
384
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800385 */
386typedef struct camera_module_callbacks {
387
388 /**
389 * camera_device_status_change:
390 *
391 * Callback to the framework to indicate that the state of a specific camera
392 * device has changed. At module load time, the framework will assume all
393 * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL
394 * must call this method to inform the framework of any initially
395 * NOT_PRESENT devices.
396 *
Chien-Yu Chen30159172015-01-08 11:06:38 -0800397 * This callback is added for CAMERA_MODULE_API_VERSION_2_1.
398 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800399 * camera_module_callbacks: The instance of camera_module_callbacks_t passed
400 * to the module with set_callbacks.
401 *
402 * camera_id: The ID of the camera device that has a new status.
403 *
404 * new_status: The new status code, one of the camera_device_status_t enums,
405 * or a platform-specific status.
406 *
407 */
408 void (*camera_device_status_change)(const struct camera_module_callbacks*,
409 int camera_id,
410 int new_status);
411
Chien-Yu Chen30159172015-01-08 11:06:38 -0800412 /**
413 * torch_mode_status_change:
414 *
415 * Callback to the framework to indicate that the state of the torch mode
416 * of the flash unit associated with a specific camera device has changed.
417 * At module load time, the framework will assume the torch modes are in
418 * the TORCH_MODE_STATUS_AVAILABLE state if android.flash.info.available
419 * is reported as true via get_camera_info() call.
420 *
421 * This callback is added for CAMERA_MODULE_API_VERSION_2_4.
422 *
423 * camera_module_callbacks: The instance of camera_module_callbacks_t
424 * passed to the module with set_callbacks.
425 *
426 * camera_id: The ID of camera device whose flash unit has a new torch mode
427 * status.
428 *
429 * new_status: The new status code, one of the torch_mode_status_t enums.
430 */
431 void (*torch_mode_status_change)(const struct camera_module_callbacks*,
432 const char* camera_id,
433 int new_status);
434
435
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800436} camera_module_callbacks_t;
437
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800438typedef struct camera_module {
Stewart Miles84d35492014-05-01 09:03:27 -0700439 /**
440 * Common methods of the camera module. This *must* be the first member of
441 * camera_module as users of this structure will cast a hw_module_t to
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700442 * camera_module pointer in contexts where it's known the hw_module_t
443 * references a camera_module.
444 *
445 * The return values for common.methods->open for camera_module are:
446 *
447 * 0: On a successful open of the camera device.
448 *
449 * -ENODEV: The camera device cannot be opened due to an internal
450 * error.
451 *
452 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
453 * and/or the module is invalid.
454 *
455 * -EBUSY: The camera device was already opened for this camera id
456 * (by using this method or open_legacy),
457 * regardless of the device HAL version it was opened as.
458 *
459 * -EUSERS: The maximal number of camera devices that can be
460 * opened concurrently were opened already, either by
461 * this method or the open_legacy method.
462 *
463 * All other return values from common.methods->open will be treated as
464 * -ENODEV.
Stewart Miles84d35492014-05-01 09:03:27 -0700465 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800466 hw_module_t common;
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800467
468 /**
469 * get_number_of_cameras:
470 *
471 * Returns the number of camera devices accessible through the camera
472 * module. The camera devices are numbered 0 through N-1, where N is the
473 * value returned by this call. The name of the camera device for open() is
474 * simply the number converted to a string. That is, "0" for camera ID 0,
475 * "1" for camera ID 1.
476 *
Zhijun He94e23b22015-01-12 14:45:33 -0800477 * Version information (based on camera_module_t.common.module_api_version):
478 *
479 * CAMERA_MODULE_API_VERSION_2_3 or lower:
480 *
481 * The value here must be static, and cannot change after the first call
482 * to this method.
483 *
484 * CAMERA_MODULE_API_VERSION_2_4 or higher:
485 *
486 * The value here must be static, and must count only built-in cameras,
487 * which have CAMERA_FACING_BACK or CAMERA_FACING_FRONT camera facing values
488 * (camera_info.facing). The HAL must not include the external cameras
489 * (camera_info.facing == CAMERA_FACING_EXTERNAL) into the return value
490 * of this call. Frameworks will use camera_device_status_change callback
491 * to manage number of external cameras.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800492 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800493 int (*get_number_of_cameras)(void);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800494
495 /**
496 * get_camera_info:
497 *
498 * Return the static camera information for a given camera device. This
499 * information may not change for a camera device.
500 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700501 * Return values:
502 *
503 * 0: On a successful operation
504 *
505 * -ENODEV: The information cannot be provided due to an internal
506 * error.
507 *
508 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
509 * and/or the module is invalid.
Zhijun He94e23b22015-01-12 14:45:33 -0800510 *
511 * Version information (based on camera_module_t.common.module_api_version):
512 *
513 * CAMERA_MODULE_API_VERSION_2_4 or higher:
514 *
515 * When a camera is disconnected, its camera id becomes invalid. Calling this
516 * this method with this invalid camera id will get -EINVAL and NULL camera
517 * static metadata (camera_info.static_camera_characteristics).
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800518 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800519 int (*get_camera_info)(int camera_id, struct camera_info *info);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800520
521 /**
522 * set_callbacks:
523 *
524 * Provide callback function pointers to the HAL module to inform framework
525 * of asynchronous camera module events. The framework will call this
526 * function once after initial camera HAL module load, after the
527 * get_number_of_cameras() method is called for the first time, and before
528 * any other calls to the module.
529 *
530 * Version information (based on camera_module_t.common.module_api_version):
531 *
532 * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0:
533 *
534 * Not provided by HAL module. Framework may not call this function.
535 *
536 * CAMERA_MODULE_API_VERSION_2_1:
537 *
538 * Valid to be called by the framework.
539 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700540 * Return values:
541 *
542 * 0: On a successful operation
543 *
544 * -ENODEV: The operation cannot be completed due to an internal
545 * error.
546 *
547 * -EINVAL: The input arguments are invalid, i.e. the callbacks are
548 * null
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800549 */
550 int (*set_callbacks)(const camera_module_callbacks_t *callbacks);
551
Alex Ray19b2cea2013-06-13 12:40:52 -0700552 /**
553 * get_vendor_tag_ops:
554 *
555 * Get methods to query for vendor extension metadata tag information. The
556 * HAL should fill in all the vendor tag operation methods, or leave ops
557 * unchanged if no vendor tags are defined.
558 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800559 * The vendor_tag_ops structure used here is defined in:
560 * system/media/camera/include/system/vendor_tags.h
561 *
Alex Ray19b2cea2013-06-13 12:40:52 -0700562 * Version information (based on camera_module_t.common.module_api_version):
563 *
564 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1:
565 * Not provided by HAL module. Framework may not call this function.
566 *
567 * CAMERA_MODULE_API_VERSION_2_2:
568 * Valid to be called by the framework.
569 */
570 void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops);
571
Zhijun Hebcdebf32014-06-06 15:42:17 -0700572 /**
573 * open_legacy:
574 *
575 * Open a specific legacy camera HAL device if multiple device HAL API
576 * versions are supported by this camera HAL module. For example, if the
577 * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and
578 * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id,
579 * framework can call this function to open the camera device as
580 * CAMERA_DEVICE_API_VERSION_1_0 device.
581 *
582 * This is an optional method. A Camera HAL module does not need to support
583 * more than one device HAL version per device, and such modules may return
584 * -ENOSYS for all calls to this method. For all older HAL device API
585 * versions that are not supported, it may return -EOPNOTSUPP. When above
586 * cases occur, The normal open() method (common.methods->open) will be
587 * used by the framework instead.
588 *
589 * Version information (based on camera_module_t.common.module_api_version):
590 *
591 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2:
592 * Not provided by HAL module. Framework will not call this function.
593 *
594 * CAMERA_MODULE_API_VERSION_2_3:
595 * Valid to be called by the framework.
596 *
597 * Return values:
598 *
599 * 0: On a successful open of the camera device.
600 *
601 * -ENOSYS This method is not supported.
602 *
603 * -EOPNOTSUPP: The requested HAL version is not supported by this method.
604 *
605 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
606 * and/or the module is invalid.
607 *
608 * -EBUSY: The camera device was already opened for this camera id
609 * (by using this method or common.methods->open method),
610 * regardless of the device HAL version it was opened as.
611 *
612 * -EUSERS: The maximal number of camera devices that can be
613 * opened concurrently were opened already, either by
614 * this method or common.methods->open method.
615 */
616 int (*open_legacy)(const struct hw_module_t* module, const char* id,
617 uint32_t halVersion, struct hw_device_t** device);
618
Chien-Yu Chen30159172015-01-08 11:06:38 -0800619 /**
620 * set_torch_mode:
621 *
622 * Turn on or off the torch mode of the flash unit associated with a given
623 * camera ID. This function is blocking until the operation completes or
624 * fails.
625 *
626 * The camera device has a higher priority accessing the flash unit. When
627 * there are any resource conflicts, such as open() is called to open a
628 * camera device, HAL module must notify the framework through
629 * camera_module_callbacks.torch_mode_status_change() that the
630 * torch mode has been turned off and the torch mode state has become
631 * TORCH_MODE_STATUS_RESOURCE_BUSY. When resources to turn on torch mode
632 * become available again, HAL module must notify the framework through
633 * camera_module_callbacks.torch_mode_status_change() that the torch mode
634 * state has become available for set_torch_mode() to be called.
635 *
636 * Version information (based on camera_module_t.common.module_api_version):
637 *
638 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
639 * Not provided by HAL module. Framework will not call this function.
640 *
641 * CAMERA_MODULE_API_VERSION_2_4:
642 * Valid to be called by the framework.
643 *
644 * Return values:
645 *
646 * 0: On a successful operation.
647 *
648 * -ENOSYS: The camera device does not support this operation. It is
649 * returned if and only if android.flash.info.available is
650 * false.
651 *
652 * -EBUSY: The flash unit or the resource needed to turn on the torch
653 * mode is busy, typically because the camera device is already
654 * in use, or some other camera device is using enough
655 * resources to make using the flash unit not possible.
656 *
657 * -EINVAL: camera_id is invalid.
658 *
659 */
660 int (*set_torch_mode)(const char* camera_id, bool on);
661
Alex Ray19b2cea2013-06-13 12:40:52 -0700662 /* reserved for future use */
Chien-Yu Chen30159172015-01-08 11:06:38 -0800663 void* reserved[6];
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800664} camera_module_t;
665
666__END_DECLS
667
668#endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */