Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 1 | /* |
| 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 | ******************************************************************************* |
| 44 | * Versions: 0.X-1.X |
| 45 | * |
| 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 | ******************************************************************************* |
| 54 | * Version: 2.0 |
| 55 | * |
| 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 | |
| 64 | |
| 65 | #define CAMERA_MODULE_API_VERSION HARDWARE_MODULE_API_VERSION(2, 0) |
| 66 | // Stable version for device, version 2.0 is experimental |
| 67 | #define CAMERA_DEVICE_API_VERSION HARDWARE_DEVICE_API_VERSION(1, 0) |
| 68 | |
| 69 | /** |
James Dong | d0ca70d | 2012-03-26 16:22:35 -0700 | [diff] [blame^] | 70 | * Defined in /system/media/camera/include/system/camera_metadata.h |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 71 | */ |
| 72 | typedef struct camera_metadata camera_metadata_t; |
| 73 | |
| 74 | struct camera_info { |
| 75 | /** |
| 76 | * The direction that the camera faces to. It should be CAMERA_FACING_BACK |
| 77 | * or CAMERA_FACING_FRONT. |
| 78 | * |
| 79 | * Version information: |
| 80 | * Valid in all camera_module versions |
| 81 | */ |
| 82 | int facing; |
| 83 | |
| 84 | /** |
| 85 | * The orientation of the camera image. The value is the angle that the |
| 86 | * camera image needs to be rotated clockwise so it shows correctly on the |
| 87 | * display in its natural orientation. It should be 0, 90, 180, or 270. |
| 88 | * |
| 89 | * For example, suppose a device has a naturally tall screen. The |
| 90 | * back-facing camera sensor is mounted in landscape. You are looking at |
| 91 | * the screen. If the top side of the camera sensor is aligned with the |
| 92 | * right edge of the screen in natural orientation, the value should be |
| 93 | * 90. If the top side of a front-facing camera sensor is aligned with the |
| 94 | * right of the screen, the value should be 270. |
| 95 | * |
| 96 | * Version information: |
| 97 | * Valid in all camera_module versions |
| 98 | */ |
| 99 | int orientation; |
| 100 | |
| 101 | /** |
| 102 | * The value of camera_device_t.common.version. |
| 103 | * |
| 104 | * Version information (based on camera_module_t.common.module_api_version): |
| 105 | * |
| 106 | * HARDWARE_MODULE_API_VERSION(0, 0)-(1, FF): |
| 107 | * |
| 108 | * Not valid. Can be assumed to be HARDWARE_DEVICE_API_VERSION(1,0). Do |
| 109 | * not read this field. |
| 110 | * |
| 111 | * HARDWARE_MODULE_API_VERSION(2, 0): |
| 112 | * |
| 113 | * Always valid |
| 114 | * |
| 115 | */ |
| 116 | uint32_t device_version; |
| 117 | |
| 118 | /** |
| 119 | * The camera's fixed characteristics, which include all camera metadata in |
| 120 | * the android.*.info.* sections. |
| 121 | * |
| 122 | * Version information (based on camera_module_t.common.module_api_version): |
| 123 | * |
| 124 | * HARDWARE_MODULE_API_VERSION(0, 0)-(1, FF): |
| 125 | * |
| 126 | * Not valid. Extra characteristics are not available. Do not read this |
| 127 | * field. |
| 128 | * |
| 129 | * HARDWARE_MODULE_API_VERSION(2, 0): |
| 130 | * |
| 131 | * Valid if device_version >= HARDWARE_DEVICE_API_VERSION(2,0). Do not |
| 132 | * read otherwise. |
| 133 | * |
| 134 | */ |
| 135 | camera_metadata_t *static_camera_characteristics; |
| 136 | }; |
| 137 | |
| 138 | typedef struct camera_module { |
| 139 | hw_module_t common; |
| 140 | int (*get_number_of_cameras)(void); |
| 141 | int (*get_camera_info)(int camera_id, struct camera_info *info); |
| 142 | } camera_module_t; |
| 143 | |
| 144 | __END_DECLS |
| 145 | |
| 146 | #endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */ |