2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 // FIXME: add well-defined names for cameras
19 #ifndef ANDROID_INCLUDE_CAMERA_COMMON_H
20 #define ANDROID_INCLUDE_CAMERA_COMMON_H
23 #include <sys/cdefs.h>
24 #include <sys/types.h>
25 #include <cutils/native_handle.h>
26 #include <system/camera.h>
27 #include <hardware/hardware.h>
28 #include <hardware/gralloc.h>
33 * The id of this module
35 #define CAMERA_HARDWARE_MODULE_ID "camera"
38 * Module versioning information for the Camera hardware module, based on
39 * camera_module_t.common.module_api_version. The two most significant hex
40 * digits represent the major version, and the two least significant represent
43 *******************************************************************************
44 * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0]
46 * Camera modules that report these version numbers implement the initial
47 * camera module HAL interface. All camera devices openable through this
48 * module support only version 1 of the camera device HAL. The device_version
49 * and static_camera_characteristics fields of camera_info are not valid. Only
50 * the android.hardware.Camera API can be supported by this module and its
53 *******************************************************************************
54 * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0]
56 * Camera modules that report this version number implement the second version
57 * of the camera module HAL interface. Camera devices openable through this
58 * module may support either version 1.0 or version 2.0 of the camera device
59 * HAL interface. The device_version field of camera_info is always valid; the
60 * static_camera_characteristics field of camera_info is valid if the
61 * device_version field is 2.0 or higher.
65 * Predefined macros for currently-defined version numbers
69 * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated
70 * as CAMERA_MODULE_API_VERSION_1_0
72 #define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
73 #define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
75 #define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_0
78 * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated
79 * as CAMERA_DEVICE_API_VERSION_1_0
81 #define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
82 #define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)
84 // Device version 2.0 is experimental
85 #define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_1_0
88 * Defined in /system/media/camera/include/system/camera_metadata.h
90 typedef struct camera_metadata camera_metadata_t
;
94 * The direction that the camera faces to. It should be CAMERA_FACING_BACK
95 * or CAMERA_FACING_FRONT.
97 * Version information:
98 * Valid in all camera_module versions
103 * The orientation of the camera image. The value is the angle that the
104 * camera image needs to be rotated clockwise so it shows correctly on the
105 * display in its natural orientation. It should be 0, 90, 180, or 270.
107 * For example, suppose a device has a naturally tall screen. The
108 * back-facing camera sensor is mounted in landscape. You are looking at
109 * the screen. If the top side of the camera sensor is aligned with the
110 * right edge of the screen in natural orientation, the value should be
111 * 90. If the top side of a front-facing camera sensor is aligned with the
112 * right of the screen, the value should be 270.
114 * Version information:
115 * Valid in all camera_module versions
120 * The value of camera_device_t.common.version.
122 * Version information (based on camera_module_t.common.module_api_version):
124 * CAMERA_MODULE_API_VERSION_1_0:
126 * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do
127 * not read this field.
129 * CAMERA_MODULE_API_VERSION_2_0:
134 uint32_t device_version
;
137 * The camera's fixed characteristics, which include all camera metadata in
138 * the android.*.info.* sections. This should be a sorted metadata buffer,
139 * and may not be modified or freed by the caller. The pointer should remain
140 * valid for the lifetime of the camera module.
142 * Version information (based on camera_module_t.common.module_api_version):
144 * CAMERA_MODULE_API_VERSION_1_0:
146 * Not valid. Extra characteristics are not available. Do not read this
149 * CAMERA_MODULE_API_VERSION_2_0:
151 * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read
155 const camera_metadata_t
*static_camera_characteristics
;
158 typedef struct camera_module
{
160 int (*get_number_of_cameras
)(void);
161 int (*get_camera_info
)(int camera_id
, struct camera_info
*info
);
166 #endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */