| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 module arc.mojom; |
| 6 |
| 7 import "arc_camera3_metadata.mojom"; |
| 8 |
| 9 [Extensible] |
| 10 enum HalPixelFormat { |
| 11 HAL_PIXEL_FORMAT_RGBA_8888 = 0x1, |
| 12 HAL_PIXEL_FORMAT_RGBX_8888 = 0x2, |
| 13 HAL_PIXEL_FORMAT_BGRA_8888 = 0x5, |
| 14 HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, |
| 15 HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, |
| 16 HAL_PIXEL_FORMAT_BLOB = 0x21, |
| 17 HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, |
| 18 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, |
| 19 HAL_PIXEL_FORMAT_YV12 = 0x32315659, |
| 20 }; |
| 21 |
| 22 // The following enums are from Android's camera HAL v3 API header: |
| 23 // include/hardware/camera3.h under |
| 24 // https://android.googlesource.com/platform/hardware/libhardware. |
| 25 |
| 26 enum CameraFacing { |
| 27 CAMERA_FACING_BACK = 0, |
| 28 CAMERA_FACING_FRONT = 1, |
| 29 CAMERA_FACING_EXTERNAL = 2, |
| 30 }; |
| 31 |
| 32 enum Camera3StreamType { |
| 33 CAMERA3_STREAM_OUTPUT = 0, |
| 34 CAMERA3_STREAM_INPUT = 1, |
| 35 CAMERA3_STREAM_BIDIRECTIONAL = 2, |
| 36 CAMERA3_NUM_STREAM_TYPES, |
| 37 }; |
| 38 |
| 39 enum Camera3StreamRotation { |
| 40 CAMERA3_STREAM_ROTATION_0 = 0, |
| 41 CAMERA3_STREAM_ROTATION_90 = 1, |
| 42 CAMERA3_STREAM_ROTATION_180 = 2, |
| 43 CAMERA3_STREAM_ROTATION_270 = 3, |
| 44 }; |
| 45 |
| 46 [Extensible] |
| 47 enum Camera3StreamConfigurationMode { |
| 48 CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE = 0, |
| 49 CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE =1, |
| 50 CAMERA3_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000, |
| 51 }; |
| 52 |
| 53 [Extensible] |
| 54 enum Camera3RequestTemplate { |
| 55 CAMERA3_TEMPLATE_PREVIEW = 1, |
| 56 CAMERA3_TEMPLATE_STILL_CAPTURE = 2, |
| 57 CAMERA3_TEMPLATE_VIDEO_RECORD = 3, |
| 58 CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, |
| 59 CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, |
| 60 CAMERA3_TEMPLATE_MANUAL = 6, |
| 61 CAMERA3_TEMPLATE_COUNT, |
| 62 CAMERA3_VENDOR_TEMPLATE_START = 0x40000000, |
| 63 }; |
| 64 |
| 65 enum Camera3BufferStatus { |
| 66 CAMERA3_BUFFER_STATUS_OK = 0, |
| 67 CAMERA3_BUFFER_STATUS_ERROR = 1, |
| 68 }; |
| 69 |
| 70 enum Camera3MsgType { |
| 71 CAMERA3_MSG_ERROR = 1, |
| 72 CAMERA3_MSG_SHUTTER = 2, |
| 73 CAMEAR3_NUM_MESSAGES, |
| 74 }; |
| 75 |
| 76 struct Camera3Stream { |
| 77 uint64 id; |
| 78 Camera3StreamType stream_type; |
| 79 uint32 width; |
| 80 uint32 height; |
| 81 HalPixelFormat format; |
| 82 uint32 usage; |
| 83 uint32 max_buffers; |
| 84 uint32 data_space; |
| 85 Camera3StreamRotation rotation; |
| 86 }; |
| 87 |
| 88 struct Camera3StreamConfiguration { |
| 89 uint32 num_streams; |
| 90 array<Camera3Stream> streams; |
| 91 Camera3StreamConfigurationMode operation_mode; |
| 92 int32 error; // Used to piggyback error code returned by driver. |
| 93 }; |
| 94 |
| 95 struct Camera3StreamBuffer { |
| 96 uint64 stream_id; |
| 97 uint64 buffer_id; |
| 98 Camera3BufferStatus status; |
| 99 handle? acquire_fence; |
| 100 handle? release_fence; |
| 101 }; |
| 102 |
| 103 struct Camera3CaptureRequest { |
| 104 uint32 frame_number; |
| 105 CameraMetadata settings; |
| 106 Camera3StreamBuffer? input_buffer; |
| 107 uint32 num_output_buffers; |
| 108 array<Camera3StreamBuffer> output_buffers; |
| 109 }; |
| 110 |
| 111 // Camera3DeviceOps is mostly a direct translation of the camera3_device_ops_t |
| 112 // API from Android camera HAL v3, with the additional RegisterBuffer() function |
| 113 // to pass buffer handles across processes. This is the interface to interact |
| 114 // with a camera device in the camera HAL. |
| 115 // |
| 116 // The work flow of the Camera3DeviceOps is: |
| 117 // 1. Call Initialize() to register the Camera3CallbackOps interface with the |
| 118 // camera HAL. |
| 119 // |
| 120 // 2. Call ConfigureStreams() to negotiate the set of usable video streams |
| 121 // with the camera HAL. |
| 122 // |
| 123 // 3. After the video streams are successfully configured, call |
| 124 // ConstructDefaultRequestSettings() to get the capture settings for each |
| 125 // stream. The capture settings of a stream should be associated with the |
| 126 // capture requests of the stream. |
| 127 // |
| 128 // 4. Start the capture loop. The capture loop is composed of a series of |
| 129 // capture requests and results. |
| 130 // |
| 131 // For each capture request: |
| 132 // a. Call RegisterBuffer() for each buffer associated with the request |
| 133 // to register the buffers which will later be filled by the camera |
| 134 // HAL with capture result. For example, the client may register one |
| 135 // low-resolution buffer for the preview stream, and a high-resolution |
| 136 // buffer for the still capture stream. |
| 137 // b. Call ProcessCaptureRequest() to request capturing one frame. A |
| 138 // request may contain multiple streams and the camera HAL would fill |
| 139 // the buffers of each streams per requirements specified in |
| 140 // ConfigureStreams() and RegisterBuffer(). For example, the camera |
| 141 // HAL may fill a frame to a still capture buffer with the native |
| 142 // capture resolution, and down-scale the same frame to a lower |
| 143 // resolution for the preview buffer. |
| 144 // The client may continue with RegisterBuffer() -> ProcessCaptureRequest() |
| 145 // up to the pipe-line depth configured in ConfigureStreams(). |
| 146 // |
| 147 // When the camera HAL is done with a capture request, the capture result |
| 148 // is sent back to the client through the callbacks in Camera3CallbackOps. |
| 149 // |
| 150 // For each capture result: |
| 151 // a. The camera HAL notifies the client of the shutter time of the |
| 152 // capture through Notify(). |
| 153 // b. The camera HAL returns the capture result with various result |
| 154 // metadata and the filled buffers to the client in |
| 155 // ProcessCaptureResult(). The result metadata may be sent in |
| 156 // partially in multiple stages, and the client must wait until all |
| 157 // the partial metadata are received before handing the capture result |
| 158 // to upper layer. |
| 159 // |
| 160 // 5. Dump() can be used to dump various information of the camera HAL for |
| 161 // debug purpose. |
| 162 // |
| 163 // 6. Flush() tells the camera HAL to finish processing or discard the |
| 164 // current on-going capture requests and return to the state where |
| 165 // ConfigureStreams() can be called to set up new streams. |
| 166 // |
| 167 // 7. Close() closes the camera device. |
| 168 interface Camera3DeviceOps { |
| 169 Initialize@0(Camera3CallbackOps callback_ops) => (int32 result); |
| 170 |
| 171 ConfigureStreams@1(Camera3StreamConfiguration config) => |
| 172 (Camera3StreamConfiguration updated_config); |
| 173 |
| 174 ConstructDefaultRequestSettings@2(Camera3RequestTemplate type) => |
| 175 (CameraMetadata? settings); |
| 176 |
| 177 ProcessCaptureRequest@3(Camera3CaptureRequest request) => (int32 result); |
| 178 |
| 179 Dump@4(handle fd); |
| 180 |
| 181 Flush@5() => (int32 result); |
| 182 |
| 183 enum BufferType { |
| 184 GRALLOC = 0, // gralloc buffer. Needs to be imported through GBM. |
| 185 SHM = 1, // shared memory buffer. Can be mmapped directly. |
| 186 // Add DMABUF when needed. |
| 187 }; |
| 188 |
| 189 RegisterBuffer@6(uint64 buffer_id, BufferType type, array<handle> fds, |
| 190 uint32 drm_format, HalPixelFormat hal_pixel_format, |
| 191 uint32 width, uint32 height, array<uint32> strides, |
| 192 array<uint32> offsets) => |
| 193 (int32 result); |
| 194 |
| 195 Close@7() => (int32 result); |
| 196 }; |
| 197 |
| 198 struct Camera3CaptureResult { |
| 199 uint32 frame_number; |
| 200 CameraMetadata result; |
| 201 uint32 num_output_buffers; |
| 202 array<Camera3StreamBuffer>? output_buffers; |
| 203 Camera3StreamBuffer? input_buffer; |
| 204 uint32 partial_result; |
| 205 }; |
| 206 |
| 207 struct Camera3ErrorMsg { |
| 208 uint32 frame_number; |
| 209 uint64 error_stream_id; |
| 210 int32 error_code; |
| 211 }; |
| 212 |
| 213 struct Camera3ShutterMsg { |
| 214 uint32 frame_number; |
| 215 uint64 timestamp; |
| 216 }; |
| 217 |
| 218 union Camera3NotifyMsgMessage { |
| 219 Camera3ErrorMsg error; |
| 220 Camera3ShutterMsg shutter; |
| 221 array<uint8> generic; |
| 222 }; |
| 223 |
| 224 struct Camera3NotifyMsg { |
| 225 Camera3MsgType type; |
| 226 Camera3NotifyMsgMessage message; |
| 227 }; |
| 228 |
| 229 // Camera3CallbackOps is a direct translation of the camera3_callback_ops_t API |
| 230 // in Android camera HAL v3. For the work flow of the functions in |
| 231 // Camera3CallbackOps, see the comments about Camear3DeviceOps above. |
| 232 interface Camera3CallbackOps { |
| 233 ProcessCaptureResult@0(Camera3CaptureResult result); |
| 234 |
| 235 Notify@1(Camera3NotifyMsg msg); |
| 236 }; |
| 237 |
| 238 struct CameraInfo { |
| 239 CameraFacing facing; |
| 240 int32 orientation; |
| 241 uint32 device_version; |
| 242 CameraMetadata static_camera_characteristics; |
| 243 // resource cost is not valid in CAMERA_MODULE_API_VERSION_2_3 or lower. |
| 244 // conflicting_devices is not valid in CAMERA_MODULE_API_VERSION_2_3 or lower. |
| 245 // conflicting_devices_length is not valid in CAMERA_MODULE_API_VERSION_2_3 or
lower. |
| 246 }; |
| 247 |
| 248 // CameraModule is a translation of the camera_module_t API in the file |
| 249 // include/hardware/camera_common.h under |
| 250 // https://android.googlesource.com/platform/hardware/libhardware. |
| 251 // CameraModule is the interface to interact with a camera HAL. |
| 252 interface CameraModule { |
| 253 // Opens the camera device specified by |camera_id|. On success, the camera |
| 254 // device is accessible through the |device_ops| returned. |
| 255 OpenDevice@0(int32 camera_id) => (int32 result, Camera3DeviceOps? device_ops); |
| 256 |
| 257 // Gets the number of cameras currently present on the system. |
| 258 GetNumberOfCameras@1() => (int32 result); |
| 259 |
| 260 // Gets various info about a camera specified by |camera_id|. |
| 261 GetCameraInfo@2(int32 camera_id) => (int32 result, CameraInfo? camera_info); |
| 262 |
| 263 // Registers the CameraModuleCallbacks interface with the camera HAL. |
| 264 SetCallbacks@3(CameraModuleCallbacks callbacks) => (int32 result); |
| 265 }; |
| 266 |
| 267 enum CameraDeviceStatus { |
| 268 CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, |
| 269 CAMERA_DEVICE_STATUS_PRESENT = 1, |
| 270 CAMERA_DEVICE_STATUS_ENUMERATING = 2, |
| 271 }; |
| 272 |
| 273 // CameraModuleCallbacks is a translation of the camera_module_callbacks_t API |
| 274 // in the file include/hardware/camera_common.h under |
| 275 // https://android.googlesource.com/platform/hardware/libhardware. |
| 276 // CameraModuleCallbacks is used by the camera HAL to inform the client of the |
| 277 // various status change. |
| 278 interface CameraModuleCallbacks { |
| 279 // Notifies the client about the new status of the camera device specified |
| 280 // by |camera_id|. |
| 281 CameraDeviceStatusChange@0(int32 camera_id, CameraDeviceStatus new_status); |
| 282 }; |
| OLD | NEW |