blob: b00372d68e2d0024e4331c778d3fc23a9f306cb5 [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
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800297 * callbacks except when HAL cannot keep multiple torch modes on
298 * simultaneously. In that case, HAL must notify the framework that any
299 * previously-on torch mode states have become TORCH_MODE_STATUS_OFF.
300 *
Chien-Yu Chen30159172015-01-08 11:06:38 -0800301 */
302typedef enum torch_mode_status {
303 /**
304 * The flash unit is available and the torch mode can be turned on by
305 * calling set_torch_mode(). By default, the framework will assume all
306 * flash units of all present camera devices are in this state if
307 * android.flash.info.available is reported as true via get_camera_info()
308 * call.
309 */
310 TORCH_MODE_STATUS_AVAILABLE = 0,
311
312 /**
313 * The flash unit is no longer available and the torch mode can not be
314 * turned on by calling set_torch_mode(). If the torch mode is on, it
315 * will be turned off by HAL before HAL calls torch_mode_status_change().
316 */
317 TORCH_MODE_STATUS_RESOURCE_BUSY = 1,
318
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800319 /**
320 * The previously-on torch mode has been turned off by HAL but the flash
321 * unit is still available for set_torch_mode(). This may happen after the
322 * framework turned on the torch mode of some other camera device and HAL
323 * had to turn off the torch modes of any camera devices that were
324 * previously on.
325 */
326 TORCH_MODE_STATUS_OFF = 2,
327
Chien-Yu Chen30159172015-01-08 11:06:38 -0800328} torch_mode_status_t;
329
330/**
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800331 * Callback functions for the camera HAL module to use to inform the framework
Chien-Yu Chen30159172015-01-08 11:06:38 -0800332 * of changes to the camera subsystem.
333 *
334 * Version information (based on camera_module_t.common.module_api_version):
335 *
336 * Each callback is called only by HAL modules implementing the indicated
337 * version or higher of the HAL module API interface.
338 *
339 * CAMERA_MODULE_API_VERSION_2_1:
340 * camera_device_status_change()
341 *
342 * CAMERA_MODULE_API_VERSION_2_4:
343 * torch_mode_status_change()
344
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800345 */
346typedef struct camera_module_callbacks {
347
348 /**
349 * camera_device_status_change:
350 *
351 * Callback to the framework to indicate that the state of a specific camera
352 * device has changed. At module load time, the framework will assume all
353 * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL
354 * must call this method to inform the framework of any initially
355 * NOT_PRESENT devices.
356 *
Chien-Yu Chen30159172015-01-08 11:06:38 -0800357 * This callback is added for CAMERA_MODULE_API_VERSION_2_1.
358 *
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800359 * camera_module_callbacks: The instance of camera_module_callbacks_t passed
360 * to the module with set_callbacks.
361 *
362 * camera_id: The ID of the camera device that has a new status.
363 *
364 * new_status: The new status code, one of the camera_device_status_t enums,
365 * or a platform-specific status.
366 *
367 */
368 void (*camera_device_status_change)(const struct camera_module_callbacks*,
369 int camera_id,
370 int new_status);
371
Chien-Yu Chen30159172015-01-08 11:06:38 -0800372 /**
373 * torch_mode_status_change:
374 *
375 * Callback to the framework to indicate that the state of the torch mode
376 * of the flash unit associated with a specific camera device has changed.
377 * At module load time, the framework will assume the torch modes are in
378 * the TORCH_MODE_STATUS_AVAILABLE state if android.flash.info.available
379 * is reported as true via get_camera_info() call.
380 *
381 * This callback is added for CAMERA_MODULE_API_VERSION_2_4.
382 *
383 * camera_module_callbacks: The instance of camera_module_callbacks_t
384 * passed to the module with set_callbacks.
385 *
386 * camera_id: The ID of camera device whose flash unit has a new torch mode
387 * status.
388 *
389 * new_status: The new status code, one of the torch_mode_status_t enums.
390 */
391 void (*torch_mode_status_change)(const struct camera_module_callbacks*,
392 const char* camera_id,
393 int new_status);
394
395
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800396} camera_module_callbacks_t;
397
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800398typedef struct camera_module {
Stewart Miles84d35492014-05-01 09:03:27 -0700399 /**
400 * Common methods of the camera module. This *must* be the first member of
401 * camera_module as users of this structure will cast a hw_module_t to
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700402 * camera_module pointer in contexts where it's known the hw_module_t
403 * references a camera_module.
404 *
405 * The return values for common.methods->open for camera_module are:
406 *
407 * 0: On a successful open of the camera device.
408 *
409 * -ENODEV: The camera device cannot be opened due to an internal
410 * error.
411 *
412 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
413 * and/or the module is invalid.
414 *
415 * -EBUSY: The camera device was already opened for this camera id
416 * (by using this method or open_legacy),
417 * regardless of the device HAL version it was opened as.
418 *
419 * -EUSERS: The maximal number of camera devices that can be
420 * opened concurrently were opened already, either by
421 * this method or the open_legacy method.
422 *
423 * All other return values from common.methods->open will be treated as
424 * -ENODEV.
Stewart Miles84d35492014-05-01 09:03:27 -0700425 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800426 hw_module_t common;
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800427
428 /**
429 * get_number_of_cameras:
430 *
431 * Returns the number of camera devices accessible through the camera
432 * module. The camera devices are numbered 0 through N-1, where N is the
433 * value returned by this call. The name of the camera device for open() is
434 * simply the number converted to a string. That is, "0" for camera ID 0,
435 * "1" for camera ID 1.
436 *
437 * The value here must be static, and cannot change after the first call to
438 * this method
439 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800440 int (*get_number_of_cameras)(void);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800441
442 /**
443 * get_camera_info:
444 *
445 * Return the static camera information for a given camera device. This
446 * information may not change for a camera device.
447 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700448 * Return values:
449 *
450 * 0: On a successful operation
451 *
452 * -ENODEV: The information cannot be provided due to an internal
453 * error.
454 *
455 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
456 * and/or the module is invalid.
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800457 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800458 int (*get_camera_info)(int camera_id, struct camera_info *info);
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800459
460 /**
461 * set_callbacks:
462 *
463 * Provide callback function pointers to the HAL module to inform framework
464 * of asynchronous camera module events. The framework will call this
465 * function once after initial camera HAL module load, after the
466 * get_number_of_cameras() method is called for the first time, and before
467 * any other calls to the module.
468 *
469 * Version information (based on camera_module_t.common.module_api_version):
470 *
471 * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0:
472 *
473 * Not provided by HAL module. Framework may not call this function.
474 *
475 * CAMERA_MODULE_API_VERSION_2_1:
476 *
477 * Valid to be called by the framework.
478 *
Eino-Ville Talvalac984be72014-07-24 16:44:56 -0700479 * Return values:
480 *
481 * 0: On a successful operation
482 *
483 * -ENODEV: The operation cannot be completed due to an internal
484 * error.
485 *
486 * -EINVAL: The input arguments are invalid, i.e. the callbacks are
487 * null
Eino-Ville Talvalad76f8af2013-02-13 15:29:48 -0800488 */
489 int (*set_callbacks)(const camera_module_callbacks_t *callbacks);
490
Alex Ray19b2cea2013-06-13 12:40:52 -0700491 /**
492 * get_vendor_tag_ops:
493 *
494 * Get methods to query for vendor extension metadata tag information. The
495 * HAL should fill in all the vendor tag operation methods, or leave ops
496 * unchanged if no vendor tags are defined.
497 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800498 * The vendor_tag_ops structure used here is defined in:
499 * system/media/camera/include/system/vendor_tags.h
500 *
Alex Ray19b2cea2013-06-13 12:40:52 -0700501 * Version information (based on camera_module_t.common.module_api_version):
502 *
503 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1:
504 * Not provided by HAL module. Framework may not call this function.
505 *
506 * CAMERA_MODULE_API_VERSION_2_2:
507 * Valid to be called by the framework.
508 */
509 void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops);
510
Zhijun Hebcdebf32014-06-06 15:42:17 -0700511 /**
512 * open_legacy:
513 *
514 * Open a specific legacy camera HAL device if multiple device HAL API
515 * versions are supported by this camera HAL module. For example, if the
516 * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and
517 * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id,
518 * framework can call this function to open the camera device as
519 * CAMERA_DEVICE_API_VERSION_1_0 device.
520 *
521 * This is an optional method. A Camera HAL module does not need to support
522 * more than one device HAL version per device, and such modules may return
523 * -ENOSYS for all calls to this method. For all older HAL device API
524 * versions that are not supported, it may return -EOPNOTSUPP. When above
525 * cases occur, The normal open() method (common.methods->open) will be
526 * used by the framework instead.
527 *
528 * Version information (based on camera_module_t.common.module_api_version):
529 *
530 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2:
531 * Not provided by HAL module. Framework will not call this function.
532 *
533 * CAMERA_MODULE_API_VERSION_2_3:
534 * Valid to be called by the framework.
535 *
536 * Return values:
537 *
538 * 0: On a successful open of the camera device.
539 *
540 * -ENOSYS This method is not supported.
541 *
542 * -EOPNOTSUPP: The requested HAL version is not supported by this method.
543 *
544 * -EINVAL: The input arguments are invalid, i.e. the id is invalid,
545 * and/or the module is invalid.
546 *
547 * -EBUSY: The camera device was already opened for this camera id
548 * (by using this method or common.methods->open method),
549 * regardless of the device HAL version it was opened as.
550 *
551 * -EUSERS: The maximal number of camera devices that can be
552 * opened concurrently were opened already, either by
553 * this method or common.methods->open method.
554 */
555 int (*open_legacy)(const struct hw_module_t* module, const char* id,
556 uint32_t halVersion, struct hw_device_t** device);
557
Chien-Yu Chen30159172015-01-08 11:06:38 -0800558 /**
559 * set_torch_mode:
560 *
561 * Turn on or off the torch mode of the flash unit associated with a given
562 * camera ID. This function is blocking until the operation completes or
563 * fails.
564 *
565 * The camera device has a higher priority accessing the flash unit. When
566 * there are any resource conflicts, such as open() is called to open a
567 * camera device, HAL module must notify the framework through
568 * camera_module_callbacks.torch_mode_status_change() that the
569 * torch mode has been turned off and the torch mode state has become
570 * TORCH_MODE_STATUS_RESOURCE_BUSY. When resources to turn on torch mode
571 * become available again, HAL module must notify the framework through
572 * camera_module_callbacks.torch_mode_status_change() that the torch mode
573 * state has become available for set_torch_mode() to be called.
574 *
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800575 * When the framework calls set_torch_mode() to turn on the torch mode of a
576 * flash unit, if HAL cannot keep multiple torch modes on simultaneously,
577 * HAL should turn off the torch mode that was turned on by
578 * a previous set_torch_mode() call and notify the framework that the torch
579 * mode state of that flash unit has become TORCH_MODE_STATUS_OFF.
580 *
Chien-Yu Chen30159172015-01-08 11:06:38 -0800581 * Version information (based on camera_module_t.common.module_api_version):
582 *
583 * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3:
584 * Not provided by HAL module. Framework will not call this function.
585 *
586 * CAMERA_MODULE_API_VERSION_2_4:
587 * Valid to be called by the framework.
588 *
589 * Return values:
590 *
591 * 0: On a successful operation.
592 *
593 * -ENOSYS: The camera device does not support this operation. It is
594 * returned if and only if android.flash.info.available is
595 * false.
596 *
597 * -EBUSY: The flash unit or the resource needed to turn on the torch
598 * mode is busy, typically because the camera device is already
599 * in use, or some other camera device is using enough
600 * resources to make using the flash unit not possible.
601 *
602 * -EINVAL: camera_id is invalid.
603 *
604 */
Chien-Yu Chen46edf1a2015-01-29 15:12:47 -0800605 int (*set_torch_mode)(const char* camera_id, bool enabled);
Chien-Yu Chen30159172015-01-08 11:06:38 -0800606
Alex Ray19b2cea2013-06-13 12:40:52 -0700607 /* reserved for future use */
Chien-Yu Chen30159172015-01-08 11:06:38 -0800608 void* reserved[6];
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800609} camera_module_t;
610
611__END_DECLS
612
613#endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */