| 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 enum Camera3StreamConfigurationMode { | |
| 46 CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE = 0, | |
| 47 CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE =1, | |
| 48 }; | |
| 49 | |
| 50 enum Camera3RequestTemplate { | |
| 51 CAMERA3_TEMPLATE_PREVIEW = 1, | |
| 52 CAMERA3_TEMPLATE_STILL_CAPTURE = 2, | |
| 53 CAMERA3_TEMPLATE_VIDEO_RECORD = 3, | |
| 54 CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, | |
| 55 CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, | |
| 56 CAMERA3_TEMPLATE_MANUAL = 6, | |
| 57 CAMERA3_TEMPLATE_COUNT, | |
| 58 }; | |
| 59 | |
| 60 enum Camera3BufferStatus { | |
| 61 CAMERA3_BUFFER_STATUS_OK = 0, | |
| 62 CAMERA3_BUFFER_STATUS_ERROR = 1, | |
| 63 }; | |
| 64 | |
| 65 enum Camera3MsgType { | |
| 66 CAMERA3_MSG_ERROR = 1, | |
| 67 CAMERA3_MSG_SHUTTER = 2, | |
| 68 CAMERA3_NUM_MESSAGES, | |
| 69 }; | |
| 70 | |
| 71 struct Camera3Stream { | |
| 72 uint64 id; | |
| 73 Camera3StreamType stream_type; | |
| 74 uint32 width; | |
| 75 uint32 height; | |
| 76 HalPixelFormat format; | |
| 77 uint32 usage; | |
| 78 uint32 max_buffers; | |
| 79 uint32 data_space; | |
| 80 Camera3StreamRotation rotation; | |
| 81 }; | |
| 82 | |
| 83 struct Camera3StreamConfiguration { | |
| 84 array<Camera3Stream> streams; | |
| 85 Camera3StreamConfigurationMode operation_mode; | |
| 86 }; | |
| 87 | |
| 88 struct Camera3StreamBuffer { | |
| 89 uint64 stream_id; | |
| 90 uint64 buffer_id; | |
| 91 Camera3BufferStatus status; | |
| 92 handle? acquire_fence; | |
| 93 handle? release_fence; | |
| 94 }; | |
| 95 | |
| 96 struct Camera3CaptureRequest { | |
| 97 uint32 frame_number; | |
| 98 CameraMetadata settings; | |
| 99 Camera3StreamBuffer? input_buffer; | |
| 100 array<Camera3StreamBuffer> output_buffers; | |
| 101 }; | |
| 102 | |
| 103 // Camera3DeviceOps is mostly a translation of the camera3_device_ops_t API from | |
| 104 // Android camera HAL v3, with the additional RegisterBuffer() function to pass | |
| 105 // buffer handles across processes. This is the interface to interact with a | |
| 106 // camera device in the camera HAL. | |
| 107 // | |
| 108 // The work flow of the Camera3DeviceOps is: | |
| 109 // | |
| 110 // 1. Call Initialize() to register the Camera3CallbackOps interface with the | |
| 111 // camera HAL. | |
| 112 // | |
| 113 // 2. Call ConfigureStreams() to negotiate the set of usable video streams | |
| 114 // with the camera HAL. | |
| 115 // | |
| 116 // 3. After the video streams are successfully configured, call | |
| 117 // ConstructDefaultRequestSettings() to get the capture settings for each | |
| 118 // stream. The capture settings of a stream will be associated with the | |
| 119 // capture requests of the stream. | |
| 120 // | |
| 121 // 4. Start the capture loop. The capture loop is composed of a series of | |
| 122 // capture requests and results. | |
| 123 // | |
| 124 // For each capture request: | |
| 125 // a. Call RegisterBuffer() for each buffer associated with the request | |
| 126 // to register the buffers which will later be filled by the camera | |
| 127 // HAL with capture result. For example, the client may register one | |
| 128 // small buffer for the low-resolution preview stream and one large | |
| 129 // buffer for the high-resolution still capture stream. | |
| 130 // b. Call ProcessCaptureRequest() to request capturing one frame. A | |
| 131 // request may contain multiple streams and the camera HAL would fill | |
| 132 // the buffers of each streams per requirements specified in | |
| 133 // ConfigureStreams() and RegisterBuffer(). For example, the camera | |
| 134 // HAL may fill a frame to a still capture buffer with the native | |
| 135 // capture resolution, and down-scale the same frame to a lower | |
| 136 // resolution for the preview buffer. | |
| 137 // The client may continue with RegisterBuffer() -> ProcessCaptureRequest() | |
| 138 // up to the pipe-line depth configured in ConfigureStreams(). | |
| 139 // | |
| 140 // When the camera HAL is done with a capture request, the capture result | |
| 141 // is sent back to the client through the callbacks in Camera3CallbackOps. | |
| 142 // | |
| 143 // For each capture result: | |
| 144 // a. The camera HAL notifies the client through Notify() of the shutter | |
| 145 // time of the captured frame. If an error happens while capturing a | |
| 146 // frame or filling a buffer, the camera HAL notifies the client | |
| 147 // through Notify() of the error. | |
| 148 // b. The camera HAL returns the capture result with various result | |
| 149 // metadata and the filled buffers to the client in | |
| 150 // ProcessCaptureResult(). The result metadata may be sent partially | |
| 151 // in multiple stages, and the client must wait until all the partial | |
| 152 // metadata are received before handing the capture result to upper | |
| 153 // layer. | |
| 154 // | |
| 155 // 5. Dump() can be used to dump various information of the camera HAL for | |
| 156 // debug purpose. | |
| 157 // | |
| 158 // 6. Flush() tells the camera HAL to finish processing or discard the | |
| 159 // current on-going capture requests and return to the state where | |
| 160 // ConfigureStreams() can be called again to set up new streams. | |
| 161 // | |
| 162 // 7. Close() closes the camera device. | |
| 163 | |
| 164 interface Camera3DeviceOps { | |
| 165 // Initialize() is called once after the camera device is opened to register | |
| 166 // the Camera3CallbackOps handle. | |
| 167 Initialize@0(Camera3CallbackOps callback_ops) => (int32 result); | |
| 168 | |
| 169 // ConfigureStreams() is called every time the client needs to set up new set | |
| 170 // of streams. | |
| 171 ConfigureStreams@1(Camera3StreamConfiguration config) => | |
| 172 (int32 result, Camera3StreamConfiguration? updated_config); | |
| 173 | |
| 174 // ConstructDefaultRequestSettings() is called to get the request settings for | |
| 175 // common use cases, e.g. preview, still capture, video recording...etc. | |
| 176 ConstructDefaultRequestSettings@2(Camera3RequestTemplate type) => | |
| 177 (CameraMetadata? settings); | |
| 178 | |
| 179 // ProcessCaptureRequest() is the core method and is called for every captured | |
| 180 // frame to provide the camera HAL with the capture settings and the | |
| 181 // associated buffers to fill. | |
| 182 ProcessCaptureRequest@3(Camera3CaptureRequest request) => (int32 result); | |
| 183 | |
| 184 // Dump() is called to gather various states and information about the camera | |
| 185 // HAL; it is mainly for debug purpose. | |
| 186 Dump@4(handle fd); | |
| 187 | |
| 188 // Flush() is called to clear out any in-progress captures and return the | |
| 189 // camera HAL to idle state. | |
| 190 Flush@5() => (int32 result); | |
| 191 | |
| 192 // The type of buffers the ARC++ camera service currently supports. | |
| 193 // GRALLOC is for the platform-specific gralloc buffer allocated by Android. | |
| 194 // SHM is for the shared memory buffer allocated by Chrome. | |
| 195 enum BufferType { | |
| 196 GRALLOC = 0, // gralloc buffer. Needs to be imported through GBM. | |
| 197 SHM = 1, // shared memory buffer. Can be mmapped directly. | |
| 198 // Add DMABUF when needed. | |
| 199 }; | |
| 200 | |
| 201 // RegisterBuffer() is called to register a buffer with the camera HAL. The | |
| 202 // registered buffer can then be specified in ProcessCaptureRequest() for the | |
| 203 // camera HAL to fill captured frame. RegisterBuffer() is not part of the | |
| 204 // Android camera HAL v3 API; it is added for ARC++ camera service to pass | |
| 205 // buffer handles across different processes. | |
| 206 RegisterBuffer@6(uint64 buffer_id, BufferType type, array<handle> fds, | |
| 207 uint32 drm_format, HalPixelFormat hal_pixel_format, | |
| 208 uint32 width, uint32 height, array<uint32> strides, | |
| 209 array<uint32> offsets) => | |
| 210 (int32 result); | |
| 211 | |
| 212 // Close() is called to close the camera device. | |
| 213 Close@7() => (int32 result); | |
| 214 }; | |
| 215 | |
| 216 struct Camera3CaptureResult { | |
| 217 uint32 frame_number; | |
| 218 CameraMetadata result; | |
| 219 array<Camera3StreamBuffer>? output_buffers; | |
| 220 Camera3StreamBuffer? input_buffer; | |
| 221 uint32 partial_result; | |
| 222 }; | |
| 223 | |
| 224 enum Camera3ErrorMsgCode { | |
| 225 CAMERA3_MSG_ERROR_DEVICE = 1, | |
| 226 CAMERA3_MSG_ERROR_REQUEST = 2, | |
| 227 CAMERA3_MSG_ERROR_RESULT = 3, | |
| 228 CAMERA3_MSG_ERROR_BUFFER = 4, | |
| 229 CAMERA3_MSG_NUM_ERRORS, | |
| 230 }; | |
| 231 | |
| 232 struct Camera3ErrorMsg { | |
| 233 uint32 frame_number; | |
| 234 uint64 error_stream_id; | |
| 235 Camera3ErrorMsgCode error_code; | |
| 236 }; | |
| 237 | |
| 238 struct Camera3ShutterMsg { | |
| 239 uint32 frame_number; | |
| 240 uint64 timestamp; | |
| 241 }; | |
| 242 | |
| 243 union Camera3NotifyMsgMessage { | |
| 244 Camera3ErrorMsg error; | |
| 245 Camera3ShutterMsg shutter; | |
| 246 array<uint8> generic; | |
| 247 }; | |
| 248 | |
| 249 struct Camera3NotifyMsg { | |
| 250 Camera3MsgType type; | |
| 251 Camera3NotifyMsgMessage message; | |
| 252 }; | |
| 253 | |
| 254 // Camera3CallbackOps is a translation of the camera3_callback_ops_t API | |
| 255 // in Android camera HAL v3. For the work flow of the functions in | |
| 256 // Camera3CallbackOps, see the comments about Camera3DeviceOps above. | |
| 257 interface Camera3CallbackOps { | |
| 258 // ProcessCaptureResult() is called by the camera HAL to send result metadata | |
| 259 // and filled buffer to the client. | |
| 260 ProcessCaptureResult@0(Camera3CaptureResult result); | |
| 261 | |
| 262 // Notify() is called by the camera HAL to notify the client of the start of | |
| 263 // each capture, and of errors encountered. | |
| 264 Notify@1(Camera3NotifyMsg msg); | |
| 265 }; | |
| 266 | |
| 267 struct CameraInfo { | |
| 268 CameraFacing facing; | |
| 269 int32 orientation; | |
| 270 uint32 device_version; | |
| 271 CameraMetadata static_camera_characteristics; | |
| 272 // resource cost is not valid in CAMERA_MODULE_API_VERSION_2_3 or lower. | |
| 273 // conflicting_devices is not valid in CAMERA_MODULE_API_VERSION_2_3 or lower. | |
| 274 // conflicting_devices_length is not valid in CAMERA_MODULE_API_VERSION_2_3 or | |
| 275 // lower. | |
| 276 }; | |
| 277 | |
| 278 // CameraModule is a translation of the camera_module_t API | |
| 279 // (https://goo.gl/8Hf8S8). CameraModule is the interface to interact with a | |
| 280 // camera HAL to query device info and open camera devices. | |
| 281 interface CameraModule { | |
| 282 // Opens the camera device specified by |camera_id|. On success, the camera | |
| 283 // device is accessible through the |device_ops| returned. | |
| 284 OpenDevice@0(int32 camera_id, Camera3DeviceOps& device_ops_request) | |
| 285 => (int32 result); | |
| 286 | |
| 287 // Gets the number of cameras currently present on the system. | |
| 288 GetNumberOfCameras@1() => (int32 result); | |
| 289 | |
| 290 // Gets various info about the camera specified by |camera_id|. | |
| 291 GetCameraInfo@2(int32 camera_id) => (int32 result, CameraInfo? camera_info); | |
| 292 | |
| 293 // Registers the CameraModuleCallbacks interface with the camera HAL. | |
| 294 SetCallbacks@3(CameraModuleCallbacks callbacks) => (int32 result); | |
| 295 }; | |
| 296 | |
| 297 enum CameraDeviceStatus { | |
| 298 CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, | |
| 299 CAMERA_DEVICE_STATUS_PRESENT = 1, | |
| 300 CAMERA_DEVICE_STATUS_ENUMERATING = 2, | |
| 301 }; | |
| 302 | |
| 303 // CameraModuleCallbacks is a translation of the camera_module_callbacks_t API | |
| 304 // (https://goo.gl/8Hf8S8). CameraModuleCallbacks is used by the camera HAL to | |
| 305 // inform the client of the various status change of a camera. | |
| 306 interface CameraModuleCallbacks { | |
| 307 // CameraDeviceStatusChange() is called by the camera HAL to notify the client | |
| 308 // of the new status of the camera device specified by |camera_id|. | |
| 309 CameraDeviceStatusChange@0(int32 camera_id, CameraDeviceStatus new_status); | |
| 310 }; | |
| OLD | NEW |