| 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 // (https://goo.gl/jciSjC). |
| 24 |
| 25 enum CameraFacing { |
| 26 CAMERA_FACING_BACK = 0, |
| 27 CAMERA_FACING_FRONT = 1, |
| 28 CAMERA_FACING_EXTERNAL = 2, |
| 29 }; |
| 30 |
| 31 enum Camera3StreamType { |
| 32 CAMERA3_STREAM_OUTPUT = 0, |
| 33 CAMERA3_STREAM_INPUT = 1, |
| 34 CAMERA3_STREAM_BIDIRECTIONAL = 2, |
| 35 CAMERA3_NUM_STREAM_TYPES, |
| 36 }; |
| 37 |
| 38 enum Camera3StreamRotation { |
| 39 CAMERA3_STREAM_ROTATION_0 = 0, |
| 40 CAMERA3_STREAM_ROTATION_90 = 1, |
| 41 CAMERA3_STREAM_ROTATION_180 = 2, |
| 42 CAMERA3_STREAM_ROTATION_270 = 3, |
| 43 }; |
| 44 |
| 45 [Extensible] |
| 46 enum Camera3StreamConfigurationMode { |
| 47 CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE = 0, |
| 48 CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE =1, |
| 49 CAMERA3_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000, |
| 50 }; |
| 51 |
| 52 [Extensible] |
| 53 enum Camera3RequestTemplate { |
| 54 CAMERA3_TEMPLATE_PREVIEW = 1, |
| 55 CAMERA3_TEMPLATE_STILL_CAPTURE = 2, |
| 56 CAMERA3_TEMPLATE_VIDEO_RECORD = 3, |
| 57 CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, |
| 58 CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, |
| 59 CAMERA3_TEMPLATE_MANUAL = 6, |
| 60 CAMERA3_TEMPLATE_COUNT, |
| 61 CAMERA3_VENDOR_TEMPLATE_START = 0x40000000, |
| 62 }; |
| 63 |
| 64 enum Camera3BufferStatus { |
| 65 CAMERA3_BUFFER_STATUS_OK = 0, |
| 66 CAMERA3_BUFFER_STATUS_ERROR = 1, |
| 67 }; |
| 68 |
| 69 enum Camera3MsgType { |
| 70 CAMERA3_MSG_ERROR = 1, |
| 71 CAMERA3_MSG_SHUTTER = 2, |
| 72 CAMEAR3_NUM_MESSAGES, |
| 73 }; |
| 74 |
| 75 struct Camera3Stream { |
| 76 uint64 id; |
| 77 Camera3StreamType stream_type; |
| 78 uint32 width; |
| 79 uint32 height; |
| 80 HalPixelFormat format; |
| 81 uint32 usage; |
| 82 uint32 max_buffers; |
| 83 uint32 data_space; |
| 84 Camera3StreamRotation rotation; |
| 85 }; |
| 86 |
| 87 struct Camera3StreamConfiguration { |
| 88 uint32 num_streams; |
| 89 array<Camera3Stream> streams; |
| 90 Camera3StreamConfigurationMode operation_mode; |
| 91 int32 error; // Used to piggyback error code returned by driver. |
| 92 }; |
| 93 |
| 94 struct Camera3StreamBuffer { |
| 95 uint64 stream_id; |
| 96 uint64 buffer_id; |
| 97 Camera3BufferStatus status; |
| 98 handle? acquire_fence; |
| 99 handle? release_fence; |
| 100 }; |
| 101 |
| 102 struct Camera3CaptureRequest { |
| 103 uint32 frame_number; |
| 104 CameraMetadata settings; |
| 105 Camera3StreamBuffer? input_buffer; |
| 106 uint32 num_output_buffers; |
| 107 array<Camera3StreamBuffer> output_buffers; |
| 108 }; |
| 109 |
| 110 // Camera3DeviceOps is mostly a translation of the camera3_device_ops_t API from |
| 111 // Android camera HAL v3, with the additional RegisterBuffer() function to pass |
| 112 // buffer handles across processes. This is the interface to interact with a |
| 113 // camera device in the camera HAL. |
| 114 // |
| 115 // The work flow of the Camera3DeviceOps is: |
| 116 // |
| 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 // small buffer for the low-resolution preview stream and one large |
| 136 // buffer for the high-resolution 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 through Notify() of the shutter |
| 152 // time of the captured frame. If an error happens while capturing a |
| 153 // frame or filling a buffer, the camera HAL notifies the client |
| 154 // through Notify() of the error. |
| 155 // b. The camera HAL returns the capture result with various result |
| 156 // metadata and the filled buffers to the client in |
| 157 // ProcessCaptureResult(). The result metadata may be sent in |
| 158 // partially in multiple stages, and the client must wait until all |
| 159 // the partial metadata are received before handing the capture result |
| 160 // to upper layer. |
| 161 // |
| 162 // 5. Dump() can be used to dump various information of the camera HAL for |
| 163 // debug purpose. |
| 164 // |
| 165 // 6. Flush() tells the camera HAL to finish processing or discard the |
| 166 // current on-going capture requests and return to the state where |
| 167 // ConfigureStreams() can be called again to set up new streams. |
| 168 // |
| 169 // 7. Close() closes the camera device. |
| 170 interface Camera3DeviceOps { |
| 171 Initialize@0(Camera3CallbackOps callback_ops) => (int32 result); |
| 172 |
| 173 ConfigureStreams@1(Camera3StreamConfiguration config) => |
| 174 (Camera3StreamConfiguration updated_config); |
| 175 |
| 176 ConstructDefaultRequestSettings@2(Camera3RequestTemplate type) => |
| 177 (CameraMetadata? settings); |
| 178 |
| 179 ProcessCaptureRequest@3(Camera3CaptureRequest request) => (int32 result); |
| 180 |
| 181 Dump@4(handle fd); |
| 182 |
| 183 Flush@5() => (int32 result); |
| 184 |
| 185 enum BufferType { |
| 186 GRALLOC = 0, // gralloc buffer. Needs to be imported through GBM. |
| 187 SHM = 1, // shared memory buffer. Can be mmapped directly. |
| 188 // Add DMABUF when needed. |
| 189 }; |
| 190 |
| 191 RegisterBuffer@6(uint64 buffer_id, BufferType type, array<handle> fds, |
| 192 uint32 drm_format, HalPixelFormat hal_pixel_format, |
| 193 uint32 width, uint32 height, array<uint32> strides, |
| 194 array<uint32> offsets) => |
| 195 (int32 result); |
| 196 |
| 197 Close@7() => (int32 result); |
| 198 }; |
| 199 |
| 200 struct Camera3CaptureResult { |
| 201 uint32 frame_number; |
| 202 CameraMetadata result; |
| 203 uint32 num_output_buffers; |
| 204 array<Camera3StreamBuffer>? output_buffers; |
| 205 Camera3StreamBuffer? input_buffer; |
| 206 uint32 partial_result; |
| 207 }; |
| 208 |
| 209 struct Camera3ErrorMsg { |
| 210 uint32 frame_number; |
| 211 uint64 error_stream_id; |
| 212 int32 error_code; |
| 213 }; |
| 214 |
| 215 struct Camera3ShutterMsg { |
| 216 uint32 frame_number; |
| 217 uint64 timestamp; |
| 218 }; |
| 219 |
| 220 union Camera3NotifyMsgMessage { |
| 221 Camera3ErrorMsg error; |
| 222 Camera3ShutterMsg shutter; |
| 223 array<uint8> generic; |
| 224 }; |
| 225 |
| 226 struct Camera3NotifyMsg { |
| 227 Camera3MsgType type; |
| 228 Camera3NotifyMsgMessage message; |
| 229 }; |
| 230 |
| 231 // Camera3CallbackOps is a translation of the camera3_callback_ops_t API |
| 232 // in Android camera HAL v3. For the work flow of the functions in |
| 233 // Camera3CallbackOps, see the comments about Camear3DeviceOps above. |
| 234 interface Camera3CallbackOps { |
| 235 ProcessCaptureResult@0(Camera3CaptureResult result); |
| 236 |
| 237 Notify@1(Camera3NotifyMsg msg); |
| 238 }; |
| 239 |
| 240 struct CameraInfo { |
| 241 CameraFacing facing; |
| 242 int32 orientation; |
| 243 uint32 device_version; |
| 244 CameraMetadata static_camera_characteristics; |
| 245 // resource cost is not valid in CAMERA_MODULE_API_VERSION_2_3 or lower. |
| 246 // conflicting_devices is not valid in CAMERA_MODULE_API_VERSION_2_3 or lower. |
| 247 // conflicting_devices_length is not valid in CAMERA_MODULE_API_VERSION_2_3 or |
| 248 // lower. |
| 249 }; |
| 250 |
| 251 // CameraModule is a translation of the camera_module_t API |
| 252 // (https://goo.gl/8Hf8S8). CameraModule is the interface to interact with a |
| 253 // camera HAL. |
| 254 interface CameraModule { |
| 255 // Opens the camera device specified by |camera_id|. On success, the camera |
| 256 // device is accessible through the |device_ops| returned. |
| 257 OpenDevice@0(int32 camera_id) => (int32 result, Camera3DeviceOps? device_ops); |
| 258 |
| 259 // Gets the number of cameras currently present on the system. |
| 260 GetNumberOfCameras@1() => (int32 result); |
| 261 |
| 262 // Gets various info about a camera specified by |camera_id|. |
| 263 GetCameraInfo@2(int32 camera_id) => (int32 result, CameraInfo? camera_info); |
| 264 |
| 265 // Registers the CameraModuleCallbacks interface with the camera HAL. |
| 266 SetCallbacks@3(CameraModuleCallbacks callbacks) => (int32 result); |
| 267 }; |
| 268 |
| 269 enum CameraDeviceStatus { |
| 270 CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, |
| 271 CAMERA_DEVICE_STATUS_PRESENT = 1, |
| 272 CAMERA_DEVICE_STATUS_ENUMERATING = 2, |
| 273 }; |
| 274 |
| 275 // CameraModuleCallbacks is a translation of the camera_module_callbacks_t API |
| 276 // (https://goo.gl/8Hf8S8). CameraModuleCallbacks is used by the camera HAL to |
| 277 // inform the client of the 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 |