1*4d7e907cSAndroid Build Coastguard Worker/* 2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2016 The Android Open Source Project 3*4d7e907cSAndroid Build Coastguard Worker * 4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*4d7e907cSAndroid Build Coastguard Worker * 8*4d7e907cSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*4d7e907cSAndroid Build Coastguard Worker * 10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License. 15*4d7e907cSAndroid Build Coastguard Worker */ 16*4d7e907cSAndroid Build Coastguard Worker 17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected]; 18*4d7e907cSAndroid Build Coastguard Worker 19*4d7e907cSAndroid Build Coastguard Workerimport [email protected]::types; 20*4d7e907cSAndroid Build Coastguard Worker 21*4d7e907cSAndroid Build Coastguard Worker/** 22*4d7e907cSAndroid Build Coastguard Worker * Camera device active session interface. 23*4d7e907cSAndroid Build Coastguard Worker * 24*4d7e907cSAndroid Build Coastguard Worker * Obtained via ICameraDevice::open(), this interface contains the methods to 25*4d7e907cSAndroid Build Coastguard Worker * configure and request captures from an active camera device. 26*4d7e907cSAndroid Build Coastguard Worker * 27*4d7e907cSAndroid Build Coastguard Worker */ 28*4d7e907cSAndroid Build Coastguard Workerinterface ICameraDeviceSession { 29*4d7e907cSAndroid Build Coastguard Worker 30*4d7e907cSAndroid Build Coastguard Worker /** 31*4d7e907cSAndroid Build Coastguard Worker * constructDefaultRequestSettings: 32*4d7e907cSAndroid Build Coastguard Worker * 33*4d7e907cSAndroid Build Coastguard Worker * Create capture settings for standard camera use cases. 34*4d7e907cSAndroid Build Coastguard Worker * 35*4d7e907cSAndroid Build Coastguard Worker * The device must return a settings buffer that is configured to meet the 36*4d7e907cSAndroid Build Coastguard Worker * requested use case, which must be one of the CAMERA3_TEMPLATE_* 37*4d7e907cSAndroid Build Coastguard Worker * enums. All request control fields must be included. 38*4d7e907cSAndroid Build Coastguard Worker * 39*4d7e907cSAndroid Build Coastguard Worker * Performance requirements: 40*4d7e907cSAndroid Build Coastguard Worker * 41*4d7e907cSAndroid Build Coastguard Worker * This must be a non-blocking call. The HAL should return from this call 42*4d7e907cSAndroid Build Coastguard Worker * in 1ms, and must return from this call in 5ms. 43*4d7e907cSAndroid Build Coastguard Worker * 44*4d7e907cSAndroid Build Coastguard Worker * Return values: 45*4d7e907cSAndroid Build Coastguard Worker * @return status Status code for the operation, one of: 46*4d7e907cSAndroid Build Coastguard Worker * OK: 47*4d7e907cSAndroid Build Coastguard Worker * On a successful construction of default settings. 48*4d7e907cSAndroid Build Coastguard Worker * INTERNAL_ERROR: 49*4d7e907cSAndroid Build Coastguard Worker * An unexpected internal error occurred, and the default settings 50*4d7e907cSAndroid Build Coastguard Worker * are not available. 51*4d7e907cSAndroid Build Coastguard Worker * ILLEGAL_ARGUMENT: 52*4d7e907cSAndroid Build Coastguard Worker * The camera HAL does not support the input template type 53*4d7e907cSAndroid Build Coastguard Worker * CAMERA_DISCONNECTED: 54*4d7e907cSAndroid Build Coastguard Worker * An external camera device has been disconnected, and is no longer 55*4d7e907cSAndroid Build Coastguard Worker * available. This camera device interface is now stale, and a new 56*4d7e907cSAndroid Build Coastguard Worker * instance must be acquired if the device is reconnected. All 57*4d7e907cSAndroid Build Coastguard Worker * subsequent calls on this interface must return 58*4d7e907cSAndroid Build Coastguard Worker * CAMERA_DISCONNECTED. 59*4d7e907cSAndroid Build Coastguard Worker * @return template The default capture request settings for the requested 60*4d7e907cSAndroid Build Coastguard Worker * use case, or an empty metadata structure if status is not OK. 61*4d7e907cSAndroid Build Coastguard Worker * 62*4d7e907cSAndroid Build Coastguard Worker */ 63*4d7e907cSAndroid Build Coastguard Worker constructDefaultRequestSettings(RequestTemplate type) generates 64*4d7e907cSAndroid Build Coastguard Worker (Status status, CameraMetadata requestTemplate); 65*4d7e907cSAndroid Build Coastguard Worker 66*4d7e907cSAndroid Build Coastguard Worker /** 67*4d7e907cSAndroid Build Coastguard Worker * configureStreams: 68*4d7e907cSAndroid Build Coastguard Worker * 69*4d7e907cSAndroid Build Coastguard Worker * Reset the HAL camera device processing pipeline and set up new input and 70*4d7e907cSAndroid Build Coastguard Worker * output streams. This call replaces any existing stream configuration with 71*4d7e907cSAndroid Build Coastguard Worker * the streams defined in the streamList. This method must be called at 72*4d7e907cSAndroid Build Coastguard Worker * least once before a request is submitted with processCaptureRequest(). 73*4d7e907cSAndroid Build Coastguard Worker * 74*4d7e907cSAndroid Build Coastguard Worker * The streamList must contain at least one output-capable stream, and may 75*4d7e907cSAndroid Build Coastguard Worker * not contain more than one input-capable stream. 76*4d7e907cSAndroid Build Coastguard Worker * 77*4d7e907cSAndroid Build Coastguard Worker * The streamList may contain streams that are also in the currently-active 78*4d7e907cSAndroid Build Coastguard Worker * set of streams (from the previous call to configureStreams()). These 79*4d7e907cSAndroid Build Coastguard Worker * streams must already have valid values for usage, maxBuffers, and the 80*4d7e907cSAndroid Build Coastguard Worker * private pointer. 81*4d7e907cSAndroid Build Coastguard Worker * 82*4d7e907cSAndroid Build Coastguard Worker * If the HAL needs to change the stream configuration for an existing 83*4d7e907cSAndroid Build Coastguard Worker * stream due to the new configuration, it may rewrite the values of usage 84*4d7e907cSAndroid Build Coastguard Worker * and/or maxBuffers during the configure call. 85*4d7e907cSAndroid Build Coastguard Worker * 86*4d7e907cSAndroid Build Coastguard Worker * The framework must detect such a change, and may then reallocate the 87*4d7e907cSAndroid Build Coastguard Worker * stream buffers before using buffers from that stream in a request. 88*4d7e907cSAndroid Build Coastguard Worker * 89*4d7e907cSAndroid Build Coastguard Worker * If a currently-active stream is not included in streamList, the HAL may 90*4d7e907cSAndroid Build Coastguard Worker * safely remove any references to that stream. It must not be reused in a 91*4d7e907cSAndroid Build Coastguard Worker * later configureStreams() call by the framework, and all the gralloc 92*4d7e907cSAndroid Build Coastguard Worker * buffers for it must be freed after the configureStreams() call returns. 93*4d7e907cSAndroid Build Coastguard Worker * 94*4d7e907cSAndroid Build Coastguard Worker * If the stream is new, the client must set the consumer usage flags in 95*4d7e907cSAndroid Build Coastguard Worker * requestedConfiguration. Upon return, the HAL device must set producerUsage, 96*4d7e907cSAndroid Build Coastguard Worker * maxBuffers, and other fields in the configureStreams() return values. These 97*4d7e907cSAndroid Build Coastguard Worker * fields are then used by the framework and the platform gralloc module to 98*4d7e907cSAndroid Build Coastguard Worker * allocate the gralloc buffers for each stream. 99*4d7e907cSAndroid Build Coastguard Worker * 100*4d7e907cSAndroid Build Coastguard Worker * Newly allocated buffers may be included in a capture request at any time 101*4d7e907cSAndroid Build Coastguard Worker * by the framework. Once a gralloc buffer is returned to the framework 102*4d7e907cSAndroid Build Coastguard Worker * with processCaptureResult (and its respective releaseFence has been 103*4d7e907cSAndroid Build Coastguard Worker * signaled) the framework may free or reuse it at any time. 104*4d7e907cSAndroid Build Coastguard Worker * 105*4d7e907cSAndroid Build Coastguard Worker * ------------------------------------------------------------------------ 106*4d7e907cSAndroid Build Coastguard Worker * 107*4d7e907cSAndroid Build Coastguard Worker * Preconditions: 108*4d7e907cSAndroid Build Coastguard Worker * 109*4d7e907cSAndroid Build Coastguard Worker * The framework must only call this method when no captures are being 110*4d7e907cSAndroid Build Coastguard Worker * processed. That is, all results have been returned to the framework, and 111*4d7e907cSAndroid Build Coastguard Worker * all in-flight input and output buffers have been returned and their 112*4d7e907cSAndroid Build Coastguard Worker * release sync fences have been signaled by the HAL. The framework must not 113*4d7e907cSAndroid Build Coastguard Worker * submit new requests for capture while the configureStreams() call is 114*4d7e907cSAndroid Build Coastguard Worker * underway. 115*4d7e907cSAndroid Build Coastguard Worker * 116*4d7e907cSAndroid Build Coastguard Worker * Postconditions: 117*4d7e907cSAndroid Build Coastguard Worker * 118*4d7e907cSAndroid Build Coastguard Worker * The HAL device must configure itself to provide maximum possible output 119*4d7e907cSAndroid Build Coastguard Worker * frame rate given the sizes and formats of the output streams, as 120*4d7e907cSAndroid Build Coastguard Worker * documented in the camera device's static metadata. 121*4d7e907cSAndroid Build Coastguard Worker * 122*4d7e907cSAndroid Build Coastguard Worker * Performance requirements: 123*4d7e907cSAndroid Build Coastguard Worker * 124*4d7e907cSAndroid Build Coastguard Worker * This call is expected to be heavyweight and possibly take several hundred 125*4d7e907cSAndroid Build Coastguard Worker * milliseconds to complete, since it may require resetting and 126*4d7e907cSAndroid Build Coastguard Worker * reconfiguring the image sensor and the camera processing pipeline. 127*4d7e907cSAndroid Build Coastguard Worker * Nevertheless, the HAL device should attempt to minimize the 128*4d7e907cSAndroid Build Coastguard Worker * reconfiguration delay to minimize the user-visible pauses during 129*4d7e907cSAndroid Build Coastguard Worker * application operational mode changes (such as switching from still 130*4d7e907cSAndroid Build Coastguard Worker * capture to video recording). 131*4d7e907cSAndroid Build Coastguard Worker * 132*4d7e907cSAndroid Build Coastguard Worker * The HAL should return from this call in 500ms, and must return from this 133*4d7e907cSAndroid Build Coastguard Worker * call in 1000ms. 134*4d7e907cSAndroid Build Coastguard Worker * 135*4d7e907cSAndroid Build Coastguard Worker * @return Status Status code for the operation, one of: 136*4d7e907cSAndroid Build Coastguard Worker * OK: 137*4d7e907cSAndroid Build Coastguard Worker * On successful stream configuration. 138*4d7e907cSAndroid Build Coastguard Worker * INTERNAL_ERROR: 139*4d7e907cSAndroid Build Coastguard Worker * If there has been a fatal error and the device is no longer 140*4d7e907cSAndroid Build Coastguard Worker * operational. Only close() can be called successfully by the 141*4d7e907cSAndroid Build Coastguard Worker * framework after this error is returned. 142*4d7e907cSAndroid Build Coastguard Worker * ILLEGAL_ARGUMENT: 143*4d7e907cSAndroid Build Coastguard Worker * If the requested stream configuration is invalid. Some examples 144*4d7e907cSAndroid Build Coastguard Worker * of invalid stream configurations include: 145*4d7e907cSAndroid Build Coastguard Worker * - Including more than 1 INPUT stream 146*4d7e907cSAndroid Build Coastguard Worker * - Not including any OUTPUT streams 147*4d7e907cSAndroid Build Coastguard Worker * - Including streams with unsupported formats, or an unsupported 148*4d7e907cSAndroid Build Coastguard Worker * size for that format. 149*4d7e907cSAndroid Build Coastguard Worker * - Including too many output streams of a certain format. 150*4d7e907cSAndroid Build Coastguard Worker * - Unsupported rotation configuration 151*4d7e907cSAndroid Build Coastguard Worker * - Stream sizes/formats don't satisfy the 152*4d7e907cSAndroid Build Coastguard Worker * StreamConfigurationMode requirements for non-NORMAL mode, or 153*4d7e907cSAndroid Build Coastguard Worker * the requested operation_mode is not supported by the HAL. 154*4d7e907cSAndroid Build Coastguard Worker * - Unsupported usage flag 155*4d7e907cSAndroid Build Coastguard Worker * The camera service cannot filter out all possible illegal stream 156*4d7e907cSAndroid Build Coastguard Worker * configurations, since some devices may support more simultaneous 157*4d7e907cSAndroid Build Coastguard Worker * streams or larger stream resolutions than the minimum required 158*4d7e907cSAndroid Build Coastguard Worker * for a given camera device hardware level. The HAL must return an 159*4d7e907cSAndroid Build Coastguard Worker * ILLEGAL_ARGUMENT for any unsupported stream set, and then be 160*4d7e907cSAndroid Build Coastguard Worker * ready to accept a future valid stream configuration in a later 161*4d7e907cSAndroid Build Coastguard Worker * configureStreams call. 162*4d7e907cSAndroid Build Coastguard Worker * @return finalConfiguration The stream parameters desired by the HAL for 163*4d7e907cSAndroid Build Coastguard Worker * each stream, including maximum buffers, the usage flags, and the 164*4d7e907cSAndroid Build Coastguard Worker * override format. 165*4d7e907cSAndroid Build Coastguard Worker * 166*4d7e907cSAndroid Build Coastguard Worker */ 167*4d7e907cSAndroid Build Coastguard Worker configureStreams(StreamConfiguration requestedConfiguration) 168*4d7e907cSAndroid Build Coastguard Worker generates (Status status, 169*4d7e907cSAndroid Build Coastguard Worker HalStreamConfiguration halConfiguration); 170*4d7e907cSAndroid Build Coastguard Worker 171*4d7e907cSAndroid Build Coastguard Worker /** 172*4d7e907cSAndroid Build Coastguard Worker * processCaptureRequest: 173*4d7e907cSAndroid Build Coastguard Worker * 174*4d7e907cSAndroid Build Coastguard Worker * Send a list of capture requests to the HAL. The HAL must not return from 175*4d7e907cSAndroid Build Coastguard Worker * this call until it is ready to accept the next set of requests to 176*4d7e907cSAndroid Build Coastguard Worker * process. Only one call to processCaptureRequest() must be made at a time 177*4d7e907cSAndroid Build Coastguard Worker * by the framework, and the calls must all be from the same thread. The 178*4d7e907cSAndroid Build Coastguard Worker * next call to processCaptureRequest() must be made as soon as a new 179*4d7e907cSAndroid Build Coastguard Worker * request and its associated buffers are available. In a normal preview 180*4d7e907cSAndroid Build Coastguard Worker * scenario, this means the function is generally called again by the 181*4d7e907cSAndroid Build Coastguard Worker * framework almost instantly. If more than one request is provided by the 182*4d7e907cSAndroid Build Coastguard Worker * client, the HAL must process the requests in order of lowest index to 183*4d7e907cSAndroid Build Coastguard Worker * highest index. 184*4d7e907cSAndroid Build Coastguard Worker * 185*4d7e907cSAndroid Build Coastguard Worker * The cachesToRemove argument contains a list of buffer caches (see 186*4d7e907cSAndroid Build Coastguard Worker * StreamBuffer document for more information on buffer cache) to be removed 187*4d7e907cSAndroid Build Coastguard Worker * by camera HAL. Camera HAL must remove these cache entries whether or not 188*4d7e907cSAndroid Build Coastguard Worker * this method returns OK. 189*4d7e907cSAndroid Build Coastguard Worker * 190*4d7e907cSAndroid Build Coastguard Worker * The actual request processing is asynchronous, with the results of 191*4d7e907cSAndroid Build Coastguard Worker * capture being returned by the HAL through the processCaptureResult() 192*4d7e907cSAndroid Build Coastguard Worker * call. This call requires the result metadata to be available, but output 193*4d7e907cSAndroid Build Coastguard Worker * buffers may simply provide sync fences to wait on. Multiple requests are 194*4d7e907cSAndroid Build Coastguard Worker * expected to be in flight at once, to maintain full output frame rate. 195*4d7e907cSAndroid Build Coastguard Worker * 196*4d7e907cSAndroid Build Coastguard Worker * The framework retains ownership of the request structure. It is only 197*4d7e907cSAndroid Build Coastguard Worker * guaranteed to be valid during this call. The HAL device must make copies 198*4d7e907cSAndroid Build Coastguard Worker * of the information it needs to retain for the capture processing. The HAL 199*4d7e907cSAndroid Build Coastguard Worker * is responsible for waiting on and closing the buffers' fences and 200*4d7e907cSAndroid Build Coastguard Worker * returning the buffer handles to the framework. 201*4d7e907cSAndroid Build Coastguard Worker * 202*4d7e907cSAndroid Build Coastguard Worker * The HAL must write the file descriptor for the input buffer's release 203*4d7e907cSAndroid Build Coastguard Worker * sync fence into input_buffer->release_fence, if input_buffer is not 204*4d7e907cSAndroid Build Coastguard Worker * valid. If the HAL returns -1 for the input buffer release sync fence, the 205*4d7e907cSAndroid Build Coastguard Worker * framework is free to immediately reuse the input buffer. Otherwise, the 206*4d7e907cSAndroid Build Coastguard Worker * framework must wait on the sync fence before refilling and reusing the 207*4d7e907cSAndroid Build Coastguard Worker * input buffer. 208*4d7e907cSAndroid Build Coastguard Worker * 209*4d7e907cSAndroid Build Coastguard Worker * The input/output buffers provided by the framework in each request 210*4d7e907cSAndroid Build Coastguard Worker * may be brand new (having never before seen by the HAL). 211*4d7e907cSAndroid Build Coastguard Worker * 212*4d7e907cSAndroid Build Coastguard Worker * ------------------------------------------------------------------------ 213*4d7e907cSAndroid Build Coastguard Worker * Performance considerations: 214*4d7e907cSAndroid Build Coastguard Worker * 215*4d7e907cSAndroid Build Coastguard Worker * Handling a new buffer should be extremely lightweight and there must be 216*4d7e907cSAndroid Build Coastguard Worker * no frame rate degradation or frame jitter introduced. 217*4d7e907cSAndroid Build Coastguard Worker * 218*4d7e907cSAndroid Build Coastguard Worker * This call must return fast enough to ensure that the requested frame 219*4d7e907cSAndroid Build Coastguard Worker * rate can be sustained, especially for streaming cases (post-processing 220*4d7e907cSAndroid Build Coastguard Worker * quality settings set to FAST). The HAL should return this call in 1 221*4d7e907cSAndroid Build Coastguard Worker * frame interval, and must return from this call in 4 frame intervals. 222*4d7e907cSAndroid Build Coastguard Worker * 223*4d7e907cSAndroid Build Coastguard Worker * @return status Status code for the operation, one of: 224*4d7e907cSAndroid Build Coastguard Worker * OK: 225*4d7e907cSAndroid Build Coastguard Worker * On a successful start to processing the capture request 226*4d7e907cSAndroid Build Coastguard Worker * ILLEGAL_ARGUMENT: 227*4d7e907cSAndroid Build Coastguard Worker * If the input is malformed (the settings are empty when not 228*4d7e907cSAndroid Build Coastguard Worker * allowed, there are 0 output buffers, etc) and capture processing 229*4d7e907cSAndroid Build Coastguard Worker * cannot start. Failures during request processing must be 230*4d7e907cSAndroid Build Coastguard Worker * handled by calling ICameraDeviceCallback::notify(). In case of 231*4d7e907cSAndroid Build Coastguard Worker * this error, the framework retains responsibility for the 232*4d7e907cSAndroid Build Coastguard Worker * stream buffers' fences and the buffer handles; the HAL must not 233*4d7e907cSAndroid Build Coastguard Worker * close the fences or return these buffers with 234*4d7e907cSAndroid Build Coastguard Worker * ICameraDeviceCallback::processCaptureResult(). 235*4d7e907cSAndroid Build Coastguard Worker * INTERNAL_ERROR: 236*4d7e907cSAndroid Build Coastguard Worker * If the camera device has encountered a serious error. After this 237*4d7e907cSAndroid Build Coastguard Worker * error is returned, only the close() method can be successfully 238*4d7e907cSAndroid Build Coastguard Worker * called by the framework. 239*4d7e907cSAndroid Build Coastguard Worker * @return numRequestProcessed Number of requests successfully processed by 240*4d7e907cSAndroid Build Coastguard Worker * camera HAL. When status is OK, this must be equal to the size of 241*4d7e907cSAndroid Build Coastguard Worker * requests. When the call fails, this number is the number of requests 242*4d7e907cSAndroid Build Coastguard Worker * that HAL processed successfully before HAL runs into an error. 243*4d7e907cSAndroid Build Coastguard Worker * 244*4d7e907cSAndroid Build Coastguard Worker */ 245*4d7e907cSAndroid Build Coastguard Worker processCaptureRequest(vec<CaptureRequest> requests, 246*4d7e907cSAndroid Build Coastguard Worker vec<BufferCache> cachesToRemove) 247*4d7e907cSAndroid Build Coastguard Worker generates (Status status, uint32_t numRequestProcessed); 248*4d7e907cSAndroid Build Coastguard Worker 249*4d7e907cSAndroid Build Coastguard Worker /** 250*4d7e907cSAndroid Build Coastguard Worker * getCaptureRequestMetadataQueue: 251*4d7e907cSAndroid Build Coastguard Worker * 252*4d7e907cSAndroid Build Coastguard Worker * Retrieves the queue used along with processCaptureRequest. If 253*4d7e907cSAndroid Build Coastguard Worker * client decides to use fast message queue to pass request metadata, 254*4d7e907cSAndroid Build Coastguard Worker * it must: 255*4d7e907cSAndroid Build Coastguard Worker * - Call getCaptureRequestMetadataQueue to retrieve the fast message queue; 256*4d7e907cSAndroid Build Coastguard Worker * - In each of the requests sent in processCaptureRequest, set 257*4d7e907cSAndroid Build Coastguard Worker * fmqSettingsSize field of CaptureRequest to be the size to read from the 258*4d7e907cSAndroid Build Coastguard Worker * fast message queue; leave settings field of CaptureRequest empty. 259*4d7e907cSAndroid Build Coastguard Worker * 260*4d7e907cSAndroid Build Coastguard Worker * @return queue the queue that client writes request metadata to. 261*4d7e907cSAndroid Build Coastguard Worker */ 262*4d7e907cSAndroid Build Coastguard Worker getCaptureRequestMetadataQueue() generates (fmq_sync<uint8_t> queue); 263*4d7e907cSAndroid Build Coastguard Worker 264*4d7e907cSAndroid Build Coastguard Worker /** 265*4d7e907cSAndroid Build Coastguard Worker * getCaptureResultMetadataQueue: 266*4d7e907cSAndroid Build Coastguard Worker * 267*4d7e907cSAndroid Build Coastguard Worker * Retrieves the queue used along with 268*4d7e907cSAndroid Build Coastguard Worker * ICameraDeviceCallback.processCaptureResult. 269*4d7e907cSAndroid Build Coastguard Worker * 270*4d7e907cSAndroid Build Coastguard Worker * Clients to ICameraDeviceSession must: 271*4d7e907cSAndroid Build Coastguard Worker * - Call getCaptureRequestMetadataQueue to retrieve the fast message queue; 272*4d7e907cSAndroid Build Coastguard Worker * - In implementation of ICameraDeviceCallback, test whether 273*4d7e907cSAndroid Build Coastguard Worker * .fmqResultSize field is zero. 274*4d7e907cSAndroid Build Coastguard Worker * - If .fmqResultSize != 0, read result metadata from the fast message 275*4d7e907cSAndroid Build Coastguard Worker * queue; 276*4d7e907cSAndroid Build Coastguard Worker * - otherwise, read result metadata in CaptureResult.result. 277*4d7e907cSAndroid Build Coastguard Worker * 278*4d7e907cSAndroid Build Coastguard Worker * @return queue the queue that implementation writes result metadata to. 279*4d7e907cSAndroid Build Coastguard Worker */ 280*4d7e907cSAndroid Build Coastguard Worker getCaptureResultMetadataQueue() generates (fmq_sync<uint8_t> queue); 281*4d7e907cSAndroid Build Coastguard Worker 282*4d7e907cSAndroid Build Coastguard Worker /** 283*4d7e907cSAndroid Build Coastguard Worker * flush: 284*4d7e907cSAndroid Build Coastguard Worker * 285*4d7e907cSAndroid Build Coastguard Worker * Flush all currently in-process captures and all buffers in the pipeline 286*4d7e907cSAndroid Build Coastguard Worker * on the given device. Generally, this method is used to dump all state as 287*4d7e907cSAndroid Build Coastguard Worker * quickly as possible in order to prepare for a configure_streams() call. 288*4d7e907cSAndroid Build Coastguard Worker * 289*4d7e907cSAndroid Build Coastguard Worker * No buffers are required to be successfully returned, so every buffer 290*4d7e907cSAndroid Build Coastguard Worker * held at the time of flush() (whether successfully filled or not) may be 291*4d7e907cSAndroid Build Coastguard Worker * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed 292*4d7e907cSAndroid Build Coastguard Worker * to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call, 293*4d7e907cSAndroid Build Coastguard Worker * provided they are successfully filled. 294*4d7e907cSAndroid Build Coastguard Worker * 295*4d7e907cSAndroid Build Coastguard Worker * All requests currently in the HAL are expected to be returned as soon as 296*4d7e907cSAndroid Build Coastguard Worker * possible. Not-in-process requests must return errors immediately. Any 297*4d7e907cSAndroid Build Coastguard Worker * interruptible hardware blocks must be stopped, and any uninterruptible 298*4d7e907cSAndroid Build Coastguard Worker * blocks must be waited on. 299*4d7e907cSAndroid Build Coastguard Worker * 300*4d7e907cSAndroid Build Coastguard Worker * flush() may be called concurrently to processCaptureRequest(), with the 301*4d7e907cSAndroid Build Coastguard Worker * expectation that processCaptureRequest returns quickly and the 302*4d7e907cSAndroid Build Coastguard Worker * request submitted in that processCaptureRequest call is treated like 303*4d7e907cSAndroid Build Coastguard Worker * all other in-flight requests. Due to concurrency issues, it is possible 304*4d7e907cSAndroid Build Coastguard Worker * that from the HAL's point of view, a processCaptureRequest() call may 305*4d7e907cSAndroid Build Coastguard Worker * be started after flush has been invoked but has not returned yet. If such 306*4d7e907cSAndroid Build Coastguard Worker * a call happens before flush() returns, the HAL must treat the new 307*4d7e907cSAndroid Build Coastguard Worker * capture request like other in-flight pending requests (see #4 below). 308*4d7e907cSAndroid Build Coastguard Worker * 309*4d7e907cSAndroid Build Coastguard Worker * More specifically, the HAL must follow below requirements for various 310*4d7e907cSAndroid Build Coastguard Worker * cases: 311*4d7e907cSAndroid Build Coastguard Worker * 312*4d7e907cSAndroid Build Coastguard Worker * 1. For captures that are too late for the HAL to cancel/stop, and must be 313*4d7e907cSAndroid Build Coastguard Worker * completed normally by the HAL; i.e. the HAL can send shutter/notify 314*4d7e907cSAndroid Build Coastguard Worker * and processCaptureResult and buffers as normal. 315*4d7e907cSAndroid Build Coastguard Worker * 316*4d7e907cSAndroid Build Coastguard Worker * 2. For pending requests that have not done any processing, the HAL must 317*4d7e907cSAndroid Build Coastguard Worker * call notify CAMERA3_MSG_ERROR_REQUEST, and return all the output 318*4d7e907cSAndroid Build Coastguard Worker * buffers with processCaptureResult in the error state 319*4d7e907cSAndroid Build Coastguard Worker * (CAMERA3_BUFFER_STATUS_ERROR). The HAL must not place the release 320*4d7e907cSAndroid Build Coastguard Worker * fence into an error state, instead, the release fences must be set to 321*4d7e907cSAndroid Build Coastguard Worker * the acquire fences passed by the framework, or -1 if they have been 322*4d7e907cSAndroid Build Coastguard Worker * waited on by the HAL already. This is also the path to follow for any 323*4d7e907cSAndroid Build Coastguard Worker * captures for which the HAL already called notify() with 324*4d7e907cSAndroid Build Coastguard Worker * CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers 325*4d7e907cSAndroid Build Coastguard Worker * for. After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only 326*4d7e907cSAndroid Build Coastguard Worker * processCaptureResults with buffers in CAMERA3_BUFFER_STATUS_ERROR 327*4d7e907cSAndroid Build Coastguard Worker * are allowed. No further notifys or processCaptureResult with 328*4d7e907cSAndroid Build Coastguard Worker * non-empty metadata is allowed. 329*4d7e907cSAndroid Build Coastguard Worker * 330*4d7e907cSAndroid Build Coastguard Worker * 3. For partially completed pending requests that do not have all the 331*4d7e907cSAndroid Build Coastguard Worker * output buffers or perhaps missing metadata, the HAL must follow 332*4d7e907cSAndroid Build Coastguard Worker * below: 333*4d7e907cSAndroid Build Coastguard Worker * 334*4d7e907cSAndroid Build Coastguard Worker * 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected 335*4d7e907cSAndroid Build Coastguard Worker * result metadata (i.e. one or more partial metadata) won't be 336*4d7e907cSAndroid Build Coastguard Worker * available for the capture. 337*4d7e907cSAndroid Build Coastguard Worker * 338*4d7e907cSAndroid Build Coastguard Worker * 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that 339*4d7e907cSAndroid Build Coastguard Worker * won't be produced for the capture. 340*4d7e907cSAndroid Build Coastguard Worker * 341*4d7e907cSAndroid Build Coastguard Worker * 3.3. Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp 342*4d7e907cSAndroid Build Coastguard Worker * before any buffers/metadata are returned with 343*4d7e907cSAndroid Build Coastguard Worker * processCaptureResult. 344*4d7e907cSAndroid Build Coastguard Worker * 345*4d7e907cSAndroid Build Coastguard Worker * 3.4. For captures that will produce some results, the HAL must not 346*4d7e907cSAndroid Build Coastguard Worker * call CAMERA3_MSG_ERROR_REQUEST, since that indicates complete 347*4d7e907cSAndroid Build Coastguard Worker * failure. 348*4d7e907cSAndroid Build Coastguard Worker * 349*4d7e907cSAndroid Build Coastguard Worker * 3.5. Valid buffers/metadata must be passed to the framework as 350*4d7e907cSAndroid Build Coastguard Worker * normal. 351*4d7e907cSAndroid Build Coastguard Worker * 352*4d7e907cSAndroid Build Coastguard Worker * 3.6. Failed buffers must be returned to the framework as described 353*4d7e907cSAndroid Build Coastguard Worker * for case 2. But failed buffers do not have to follow the strict 354*4d7e907cSAndroid Build Coastguard Worker * ordering valid buffers do, and may be out-of-order with respect 355*4d7e907cSAndroid Build Coastguard Worker * to valid buffers. For example, if buffers A, B, C, D, E are sent, 356*4d7e907cSAndroid Build Coastguard Worker * D and E are failed, then A, E, B, D, C is an acceptable return 357*4d7e907cSAndroid Build Coastguard Worker * order. 358*4d7e907cSAndroid Build Coastguard Worker * 359*4d7e907cSAndroid Build Coastguard Worker * 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is 360*4d7e907cSAndroid Build Coastguard Worker * sufficient, no need to call processCaptureResult with empty 361*4d7e907cSAndroid Build Coastguard Worker * metadata or equivalent. 362*4d7e907cSAndroid Build Coastguard Worker * 363*4d7e907cSAndroid Build Coastguard Worker * 4. If a flush() is invoked while a processCaptureRequest() invocation 364*4d7e907cSAndroid Build Coastguard Worker * is active, that process call must return as soon as possible. In 365*4d7e907cSAndroid Build Coastguard Worker * addition, if a processCaptureRequest() call is made after flush() 366*4d7e907cSAndroid Build Coastguard Worker * has been invoked but before flush() has returned, the capture request 367*4d7e907cSAndroid Build Coastguard Worker * provided by the late processCaptureRequest call must be treated 368*4d7e907cSAndroid Build Coastguard Worker * like a pending request in case #2 above. 369*4d7e907cSAndroid Build Coastguard Worker * 370*4d7e907cSAndroid Build Coastguard Worker * flush() must only return when there are no more outstanding buffers or 371*4d7e907cSAndroid Build Coastguard Worker * requests left in the HAL. The framework may call configure_streams (as 372*4d7e907cSAndroid Build Coastguard Worker * the HAL state is now quiesced) or may issue new requests. 373*4d7e907cSAndroid Build Coastguard Worker * 374*4d7e907cSAndroid Build Coastguard Worker * Note that it's sufficient to only support fully-succeeded and 375*4d7e907cSAndroid Build Coastguard Worker * fully-failed result cases. However, it is highly desirable to support 376*4d7e907cSAndroid Build Coastguard Worker * the partial failure cases as well, as it could help improve the flush 377*4d7e907cSAndroid Build Coastguard Worker * call overall performance. 378*4d7e907cSAndroid Build Coastguard Worker * 379*4d7e907cSAndroid Build Coastguard Worker * Performance requirements: 380*4d7e907cSAndroid Build Coastguard Worker * 381*4d7e907cSAndroid Build Coastguard Worker * The HAL should return from this call in 100ms, and must return from this 382*4d7e907cSAndroid Build Coastguard Worker * call in 1000ms. And this call must not be blocked longer than pipeline 383*4d7e907cSAndroid Build Coastguard Worker * latency (see S7 for definition). 384*4d7e907cSAndroid Build Coastguard Worker * 385*4d7e907cSAndroid Build Coastguard Worker * @return status Status code for the operation, one of: 386*4d7e907cSAndroid Build Coastguard Worker * OK: 387*4d7e907cSAndroid Build Coastguard Worker * On a successful flush of the camera HAL. 388*4d7e907cSAndroid Build Coastguard Worker * INTERNAL_ERROR: 389*4d7e907cSAndroid Build Coastguard Worker * If the camera device has encountered a serious error. After this 390*4d7e907cSAndroid Build Coastguard Worker * error is returned, only the close() method can be successfully 391*4d7e907cSAndroid Build Coastguard Worker * called by the framework. 392*4d7e907cSAndroid Build Coastguard Worker */ 393*4d7e907cSAndroid Build Coastguard Worker flush() generates (Status status); 394*4d7e907cSAndroid Build Coastguard Worker 395*4d7e907cSAndroid Build Coastguard Worker /** 396*4d7e907cSAndroid Build Coastguard Worker * close: 397*4d7e907cSAndroid Build Coastguard Worker * 398*4d7e907cSAndroid Build Coastguard Worker * Shut down the camera device. 399*4d7e907cSAndroid Build Coastguard Worker * 400*4d7e907cSAndroid Build Coastguard Worker * After this call, all calls to this session instance must return 401*4d7e907cSAndroid Build Coastguard Worker * INTERNAL_ERROR. 402*4d7e907cSAndroid Build Coastguard Worker * 403*4d7e907cSAndroid Build Coastguard Worker * This method must always succeed, even if the device has encountered a 404*4d7e907cSAndroid Build Coastguard Worker * serious error. 405*4d7e907cSAndroid Build Coastguard Worker */ 406*4d7e907cSAndroid Build Coastguard Worker close(); 407*4d7e907cSAndroid Build Coastguard Worker}; 408