blob: 12370678e08ac58c16d2b3804930d77e8bbe67da [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>
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>
29
30__BEGIN_DECLS
31
32/**
33 * The id of this module
34 */
35#define CAMERA_HARDWARE_MODULE_ID "camera"
36
37/**
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
41 * the minor version.
42 *
43 *******************************************************************************
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -070044 * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0]
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -080045 *
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
51 * devices.
52 *
53 *******************************************************************************
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -070054 * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0]
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -080055 *
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.
62 */
63
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -070064/**
65 * Predefined macros for currently-defined version numbers
66 */
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -080067
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -070068/**
69 * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated
70 * as CAMERA_MODULE_API_VERSION_1_0
71 */
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)
74
75#define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_0
76
77/**
78 * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated
79 * as CAMERA_DEVICE_API_VERSION_1_0
80 */
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)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080083#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0)
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -070084
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080085// Device version 2.0 is outdated; device version 3.0 is experimental
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -070086#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_1_0
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -080087
88/**
James Dongd0ca70d2012-03-26 16:22:35 -070089 * Defined in /system/media/camera/include/system/camera_metadata.h
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -080090 */
91typedef struct camera_metadata camera_metadata_t;
92
Alex Ray18dff4e2013-02-13 17:12:52 -080093struct camera_info {
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -080094 /**
95 * The direction that the camera faces to. It should be CAMERA_FACING_BACK
96 * or CAMERA_FACING_FRONT.
97 *
98 * Version information:
99 * Valid in all camera_module versions
100 */
101 int facing;
102
103 /**
104 * The orientation of the camera image. The value is the angle that the
105 * camera image needs to be rotated clockwise so it shows correctly on the
106 * display in its natural orientation. It should be 0, 90, 180, or 270.
107 *
108 * For example, suppose a device has a naturally tall screen. The
109 * back-facing camera sensor is mounted in landscape. You are looking at
110 * the screen. If the top side of the camera sensor is aligned with the
111 * right edge of the screen in natural orientation, the value should be
112 * 90. If the top side of a front-facing camera sensor is aligned with the
113 * right of the screen, the value should be 270.
114 *
115 * Version information:
116 * Valid in all camera_module versions
117 */
118 int orientation;
119
120 /**
121 * The value of camera_device_t.common.version.
122 *
123 * Version information (based on camera_module_t.common.module_api_version):
124 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700125 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800126 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700127 * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800128 * not read this field.
129 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700130 * CAMERA_MODULE_API_VERSION_2_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800131 *
132 * Always valid
133 *
134 */
135 uint32_t device_version;
136
137 /**
138 * The camera's fixed characteristics, which include all camera metadata in
Eino-Ville Talvalab8b64392012-08-24 12:32:17 -0700139 * the android.*.info.* sections. This should be a sorted metadata buffer,
140 * and may not be modified or freed by the caller. The pointer should remain
141 * valid for the lifetime of the camera module.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800142 *
143 * Version information (based on camera_module_t.common.module_api_version):
144 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700145 * CAMERA_MODULE_API_VERSION_1_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800146 *
147 * Not valid. Extra characteristics are not available. Do not read this
148 * field.
149 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700150 * CAMERA_MODULE_API_VERSION_2_0:
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800151 *
Eino-Ville Talvaladdc026e2012-03-27 16:15:25 -0700152 * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read
153 * otherwise.
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800154 *
155 */
Eino-Ville Talvalab8b64392012-08-24 12:32:17 -0700156 const camera_metadata_t *static_camera_characteristics;
Alex Ray18dff4e2013-02-13 17:12:52 -0800157};
Eino-Ville Talvala8bf364e2011-12-22 13:50:37 -0800158
159typedef struct camera_module {
160 hw_module_t common;
161 int (*get_number_of_cameras)(void);
162 int (*get_camera_info)(int camera_id, struct camera_info *info);
163} camera_module_t;
164
165__END_DECLS
166
167#endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */