blob: f9419914c60ea94293f55c47278070c5dabf6aa3 [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 *
93 * This camera module version adds torch mode support. The framework can
94 * use it to turn on torch mode for any camera device that has a flash unit,
95 * without opening a camera device. The camera device has a higher priority
96 * accessing the flash unit than the camera module; opening a camera device
97 * will turn off the torch if it had been enabled through the module
98 * interface. When there are any resource conflicts, such as open() is called
99 * to open a camera device, the camera HAL module must notify the framework
100 * through the torch mode status callback that the torch mode has been turned
101 * off.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800102 */
103
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700104/**
105 * Predefined macros for currently-defined version numbers
106 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800107
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700108/**
109 * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated
110 * as CAMERA_MODULE_API_VERSION_1_0
111 */
112#define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
113#define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800114#define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1)
Alex Ray19b2cea2013-06-13 12:40:52 -0700115#define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2)
Zhijun Hebcdebf32014-06-06 15:42:17 -0700116#define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3)
Chien-Yu Chen30159172015-01-08 11:06:38 -0800117#define CAMERA_MODULE_API_VERSION_2_4 HARDWARE_MODULE_API_VERSION(2, 4)
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700118
Chien-Yu Chen30159172015-01-08 11:06:38 -0800119#define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_4
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700120
121/**
122 * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated
123 * as CAMERA_DEVICE_API_VERSION_1_0
124 */
125#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
126#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800127#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800128#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0)
Eino-Ville Talvala9d518562013-07-30 14:58:31 -0700129#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1)
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800130#define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2)
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700131
Eino-Ville Talvalab5459832014-09-09 16:42:27 -0700132// Device version 3.2 is current, older HAL camera device versions are not
133// recommended for new devices.
134#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_2
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800135
136/**
James Dongd0ca70d2012-03-26 16:22:35 -0700137 * Defined in /system/media/camera/include/system/camera_metadata.h
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800138 */
139typedef struct camera_metadata camera_metadata_t;
140
Alex Ray9acc7402013-02-07 15:44:24 -0800141typedef struct camera_info {
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800142 /**
143 * The direction that the camera faces to. It should be CAMERA_FACING_BACK
144 * or CAMERA_FACING_FRONT.
145 *
146 * Version information:
147 * Valid in all camera_module versions
148 */
149 int facing;
150
151 /**
152 * The orientation of the camera image. The value is the angle that the
153 * camera image needs to be rotated clockwise so it shows correctly on the
154 * display in its natural orientation. It should be 0, 90, 180, or 270.
155 *
156 * For example, suppose a device has a naturally tall screen. The
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800157 * back-facing camera sensor is mounted in landscape. You are looking at the
158 * screen. If the top side of the camera sensor is aligned with the right
159 * edge of the screen in natural orientation, the value should be 90. If the
160 * top side of a front-facing camera sensor is aligned with the right of the
161 * screen, the value should be 270.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800162 *
163 * Version information:
164 * Valid in all camera_module versions
165 */
166 int orientation;
167
168 /**
169 * The value of camera_device_t.common.version.
170 *
171 * Version information (based on camera_module_t.common.module_api_version):
172 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700173 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800174 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700175 * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800176 * not read this field.
177 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800178 * CAMERA_MODULE_API_VERSION_2_0 or higher:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800179 *
180 * Always valid
181 *
182 */
183 uint32_t device_version;
184
185 /**
186 * The camera's fixed characteristics, which include all camera metadata in
Eino-Ville Talvalab8b64392012-08-24 12:32:17 -0700187 * the android.*.info.* sections. This should be a sorted metadata buffer,
188 * and may not be modified or freed by the caller. The pointer should remain
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800189 * valid for the lifetime of the camera module, and values in it may not
190 * change after it is returned by get_camera_info().
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800191 *
192 * Version information (based on camera_module_t.common.module_api_version):
193 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700194 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800195 *
196 * Not valid. Extra characteristics are not available. Do not read this
197 * field.
198 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800199 * CAMERA_MODULE_API_VERSION_2_0 or higher:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800200 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700201 * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read
202 * otherwise.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800203 *
204 */
Eino-Ville Talvalab8b64392012-08-24 12:32:17 -0700205 const camera_metadata_t *static_camera_characteristics;
Alex Ray9acc7402013-02-07 15:44:24 -0800206} camera_info_t;
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800207
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800208/**
209 * camera_device_status_t:
210 *
211 * The current status of the camera device, as provided by the HAL through the
212 * camera_module_callbacks.camera_device_status_change() call.
Igor Murashkin152b50f2013-03-18 13:30:14 -0700213 *
214 * At module load time, the framework will assume all camera devices are in the
215 * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke
216 * camera_module_callbacks::camera_device_status_change to inform the framework
217 * of any initially NOT_PRESENT devices.
218 *
219 * Allowed transitions:
220 * PRESENT -> NOT_PRESENT
221 * NOT_PRESENT -> ENUMERATING
222 * NOT_PRESENT -> PRESENT
223 * ENUMERATING -> PRESENT
224 * ENUMERATING -> NOT_PRESENT
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800225 */
226typedef enum camera_device_status {
227 /**
228 * The camera device is not currently connected, and opening it will return
229 * failure. Calls to get_camera_info must still succeed, and provide the
230 * same information it would if the camera were connected
231 */
232 CAMERA_DEVICE_STATUS_NOT_PRESENT = 0,
233
234 /**
235 * The camera device is connected, and opening it will succeed. The
236 * information returned by get_camera_info cannot change due to this status
237 * change. By default, the framework will assume all devices are in this
238 * state.
239 */
Igor Murashkin152b50f2013-03-18 13:30:14 -0700240 CAMERA_DEVICE_STATUS_PRESENT = 1,
241
242 /**
243 * The camera device is connected, but it is undergoing an enumeration and
244 * so opening the device will return -EBUSY. Calls to get_camera_info
245 * must still succeed, as if the camera was in the PRESENT status.
246 */
247 CAMERA_DEVICE_STATUS_ENUMERATING = 2,
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800248
249} camera_device_status_t;
250
251/**
Chien-Yu Chen30159172015-01-08 11:06:38 -0800252 * torch_mode_status_t:
253 *
254 * The current status of the torch mode, as provided by the HAL through the
255 * camera_module_callbacks.torch_mode_status_change() call.
256 *
257 * The torch mode status of a camera device is applicable only when the camera
258 * device is present. The framework will not call set_torch_mode() to turn on
259 * torch mode of a camera device if the camera device is not present. At module
260 * load time, the framework will assume torch modes are in the
261 * TORCH_MODE_STATUS_AVAILABLE state if the camera device is present and
262 * android.flash.info.available is reported as true via get_camera_info() call.
263 *
264 * The behaviors of the camera HAL module that the framework expects in the
265 * following situations when a camera device's status changes:
266 * 1. A previously-disconnected camera device becomes connected.
267 * After camera_module_callbacks::camera_device_status_change() is invoked
268 * to inform the framework that the camera device is present, the framework
269 * will assume the camera device's torch mode is in
270 * TORCH_MODE_STATUS_AVAILABLE state. The camera HAL module does not need
271 * to invoke camera_module_callbacks::torch_mode_status_change() unless the
272 * flash unit is unavailable to use by set_torch_mode().
273 *
274 * 2. A previously-connected camera becomes disconnected.
275 * After camera_module_callbacks::camera_device_status_change() is invoked
276 * to inform the framework that the camera device is not present, the
277 * framework will not call set_torch_mode() for the disconnected camera
278 * device until its flash unit becomes available again. The camera HAL
279 * module does not need to invoke
280 * camera_module_callbacks::torch_mode_status_change() separately to inform
281 * that the flash unit has become unavailable.
282 *
283 * 3. open() is called to open a camera device.
284 * The camera HAL module must invoke
285 * camera_module_callbacks::torch_mode_status_change() for all flash units
286 * that have entered TORCH_MODE_STATUS_RESOURCE_BUSY state and can not be
287 * turned on by calling set_torch_mode() anymore due to this open() call.
288 *
289 * 4. close() is called to close a camera device.
290 * The camera HAL module must invoke
291 * camera_module_callbacks::torch_mode_status_change() for all flash units
292 * that have entered TORCH_MODE_STATUS_AVAILABLE state and can be turned
293 * on by calling set_torch_mode() again because of enough resources freed
294 * up by this close() call.
295 *
296 * Note that the framework calling set_torch_mode() should not trigger any
297 * callbacks.
298 */
299typedef enum torch_mode_status {
300 /**
301 * The flash unit is available and the torch mode can be turned on by
302 * calling set_torch_mode(). By default, the framework will assume all
303 * flash units of all present camera devices are in this state if
304 * android.flash.info.available is reported as true via get_camera_info()
305 * call.
306 */
307 TORCH_MODE_STATUS_AVAILABLE = 0,
308
309 /**
310 * The flash unit is no longer available and the torch mode can not be
311 * turned on by calling set_torch_mode(). If the torch mode is on, it
312 * will be turned off by HAL before HAL calls torch_mode_status_change().
313 */
314 TORCH_MODE_STATUS_RESOURCE_BUSY = 1,
315
316} torch_mode_status_t;
317
318/**
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800319 * Callback functions for the camera HAL module to use to inform the framework
Chien-Yu Chen30159172015-01-08 11:06:38 -0800320 * of changes to the camera subsystem.
321 *
322 * Version information (based on camera_module_t.common.module_api_version):
323 *
324 * Each callback is called only by HAL modules implementing the indicated
325 * version or higher of the HAL module API interface.
326 *
327 * CAMERA_MODULE_API_VERSION_2_1:
328 * camera_device_status_change()
329 *
330 * CAMERA_MODULE_API_VERSION_2_4:
331 * torch_mode_status_change()
332
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800333 */
334typedef struct camera_module_callbacks {
335
336 /**
337 * camera_device_status_change:
338 *
339 * Callback to the framework to indicate that the state of a specific camera
340 * device has changed. At module load time, the framework will assume all
341 * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL
342 * must call this method to inform the framework of any initially
343 * NOT_PRESENT devices.
344 *
Chien-Yu Chen30159172015-01-08 11:06:38 -0800345 * This callback is added for CAMERA_MODULE_API_VERSION_2_1.
346 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800347 * camera_module_callbacks: The instance of camera_module_callbacks_t passed
348 * to the module with set_callbacks.
349 *
350 * camera_id: The ID of the camera device that has a new status.
351 *
352 * new_status: The new status code, one of the camera_device_status_t enums,
353 * or a platform-specific status.
354 *
355 */
356 void (*camera_device_status_change)(const struct camera_module_callbacks*,
357 int camera_id,
358 int new_status);
359
Chien-Yu Chen30159172015-01-08 11:06:38 -0800360 /**
361 * torch_mode_status_change:
362 *
363 * Callback to the framework to indicate that the state of the torch mode
364 * of the flash unit associated with a specific camera device has changed.
365 * At module load time, the framework will assume the torch modes are in
366 * the TORCH_MODE_STATUS_AVAILABLE state if android.flash.info.available
367 * is reported as true via get_camera_info() call.
368 *
369 * This callback is added for CAMERA_MODULE_API_VERSION_2_4.
370 *
371 * camera_module_callbacks: The instance of camera_module_callbacks_t
372 * passed to the module with set_callbacks.
373 *
374 * camera_id: The ID of camera device whose flash unit has a new torch mode
375 * status.
376 *
377 * new_status: The new status code, one of the torch_mode_status_t enums.
378 */
379 void (*torch_mode_status_change)(const struct camera_module_callbacks*,
380 const char* camera_id,
381 int new_status);
382
383
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800384} camera_module_callbacks_t;
385
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800386typedef struct camera_module {
Stewart Miles84d35492014-05-01 09:03:27 -0700387 /**
388 * Common methods of the camera module. This *must* be the first member of
389 * camera_module as users of this structure will cast a hw_module_t to
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700390 * camera_module pointer in contexts where it's known the hw_module_t
391 * references a camera_module.
392 *
393 * The return values for common.methods->open for camera_module are:
394 *
395 * 0: On a successful open of the camera device.
396 *
397 * -ENODEV: The camera device cannot be opened due to an internal
398 * error.
399 *
400 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
401 * and/or the module is invalid.
402 *
403 * -EBUSY: The camera device was already opened for this camera id
404 * (by using this method or open_legacy),
405 * regardless of the device HAL version it was opened as.
406 *
407 * -EUSERS: The maximal number of camera devices that can be
408 * opened concurrently were opened already, either by
409 * this method or the open_legacy method.
410 *
411 * All other return values from common.methods->open will be treated as
412 * -ENODEV.
Stewart Miles84d35492014-05-01 09:03:27 -0700413 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800414 hw_module_t common;
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800415
416 /**
417 * get_number_of_cameras:
418 *
419 * Returns the number of camera devices accessible through the camera
420 * module. The camera devices are numbered 0 through N-1, where N is the
421 * value returned by this call. The name of the camera device for open() is
422 * simply the number converted to a string. That is, "0" for camera ID 0,
423 * "1" for camera ID 1.
424 *
425 * The value here must be static, and cannot change after the first call to
426 * this method
427 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800428 int (*get_number_of_cameras)(void);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800429
430 /**
431 * get_camera_info:
432 *
433 * Return the static camera information for a given camera device. This
434 * information may not change for a camera device.
435 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700436 * Return values:
437 *
438 * 0: On a successful operation
439 *
440 * -ENODEV: The information cannot be provided due to an internal
441 * error.
442 *
443 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
444 * and/or the module is invalid.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800445 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800446 int (*get_camera_info)(int camera_id, struct camera_info *info);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800447
448 /**
449 * set_callbacks:
450 *
451 * Provide callback function pointers to the HAL module to inform framework
452 * of asynchronous camera module events. The framework will call this
453 * function once after initial camera HAL module load, after the
454 * get_number_of_cameras() method is called for the first time, and before
455 * any other calls to the module.
456 *
457 * Version information (based on camera_module_t.common.module_api_version):
458 *
459 * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0:
460 *
461 * Not provided by HAL module. Framework may not call this function.
462 *
463 * CAMERA_MODULE_API_VERSION_2_1:
464 *
465 * Valid to be called by the framework.
466 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700467 * Return values:
468 *
469 * 0: On a successful operation
470 *
471 * -ENODEV: The operation cannot be completed due to an internal
472 * error.
473 *
474 * -EINVAL: The input arguments are invalid, i.e. the callbacks are
475 * null
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800476 */
477 int (*set_callbacks)(const camera_module_callbacks_t *callbacks);
478
Alex Ray19b2cea2013-06-13 12:40:52 -0700479 /**
480 * get_vendor_tag_ops:
481 *
482 * Get methods to query for vendor extension metadata tag information. The
483 * HAL should fill in all the vendor tag operation methods, or leave ops
484 * unchanged if no vendor tags are defined.
485 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800486 * The vendor_tag_ops structure used here is defined in:
487 * system/media/camera/include/system/vendor_tags.h
488 *
Alex Ray19b2cea2013-06-13 12:40:52 -0700489 * Version information (based on camera_module_t.common.module_api_version):
490 *
491 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1:
492 * Not provided by HAL module. Framework may not call this function.
493 *
494 * CAMERA_MODULE_API_VERSION_2_2:
495 * Valid to be called by the framework.
496 */
497 void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops);
498
Zhijun Hebcdebf32014-06-06 15:42:17 -0700499 /**
500 * open_legacy:
501 *
502 * Open a specific legacy camera HAL device if multiple device HAL API
503 * versions are supported by this camera HAL module. For example, if the
504 * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and
505 * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id,
506 * framework can call this function to open the camera device as
507 * CAMERA_DEVICE_API_VERSION_1_0 device.
508 *
509 * This is an optional method. A Camera HAL module does not need to support
510 * more than one device HAL version per device, and such modules may return
511 * -ENOSYS for all calls to this method. For all older HAL device API
512 * versions that are not supported, it may return -EOPNOTSUPP. When above
513 * cases occur, The normal open() method (common.methods->open) will be
514 * used by the framework instead.
515 *
516 * Version information (based on camera_module_t.common.module_api_version):
517 *
518 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2:
519 * Not provided by HAL module. Framework will not call this function.
520 *
521 * CAMERA_MODULE_API_VERSION_2_3:
522 * Valid to be called by the framework.
523 *
524 * Return values:
525 *
526 * 0: On a successful open of the camera device.
527 *
528 * -ENOSYS This method is not supported.
529 *
530 * -EOPNOTSUPP: The requested HAL version is not supported by this method.
531 *
532 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
533 * and/or the module is invalid.
534 *
535 * -EBUSY: The camera device was already opened for this camera id
536 * (by using this method or common.methods->open method),
537 * regardless of the device HAL version it was opened as.
538 *
539 * -EUSERS: The maximal number of camera devices that can be
540 * opened concurrently were opened already, either by
541 * this method or common.methods->open method.
542 */
543 int (*open_legacy)(const struct hw_module_t* module, const char* id,
544 uint32_t halVersion, struct hw_device_t** device);
545
Chien-Yu Chen30159172015-01-08 11:06:38 -0800546 /**
547 * set_torch_mode:
548 *
549 * Turn on or off the torch mode of the flash unit associated with a given
550 * camera ID. This function is blocking until the operation completes or
551 * fails.
552 *
553 * The camera device has a higher priority accessing the flash unit. When
554 * there are any resource conflicts, such as open() is called to open a
555 * camera device, HAL module must notify the framework through
556 * camera_module_callbacks.torch_mode_status_change() that the
557 * torch mode has been turned off and the torch mode state has become
558 * TORCH_MODE_STATUS_RESOURCE_BUSY. When resources to turn on torch mode
559 * become available again, HAL module must notify the framework through
560 * camera_module_callbacks.torch_mode_status_change() that the torch mode
561 * state has become available for set_torch_mode() to be called.
562 *
563 * Version information (based on camera_module_t.common.module_api_version):
564 *
565 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
566 * Not provided by HAL module. Framework will not call this function.
567 *
568 * CAMERA_MODULE_API_VERSION_2_4:
569 * Valid to be called by the framework.
570 *
571 * Return values:
572 *
573 * 0: On a successful operation.
574 *
575 * -ENOSYS: The camera device does not support this operation. It is
576 * returned if and only if android.flash.info.available is
577 * false.
578 *
579 * -EBUSY: The flash unit or the resource needed to turn on the torch
580 * mode is busy, typically because the camera device is already
581 * in use, or some other camera device is using enough
582 * resources to make using the flash unit not possible.
583 *
584 * -EINVAL: camera_id is invalid.
585 *
586 */
587 int (*set_torch_mode)(const char* camera_id, bool on);
588
Alex Ray19b2cea2013-06-13 12:40:52 -0700589 /* reserved for future use */
Chien-Yu Chen30159172015-01-08 11:06:38 -0800590 void* reserved[6];
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800591} camera_module_t;
592
593__END_DECLS
594
595#endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */