android: Implement flush() camera operation

Implement the flush() camera operation in the CameraDevice class
and make it available to the camera framework by implementing the
operation wrapper in camera_ops.cpp.

Introduce a new camera state State::Flushing to handle concurrent
flush() and process_capture_request() calls.

As flush() can race with processCaptureRequest() protect it
by introducing a new State::Flushing state that
processCaptureRequest() inspects before queuing the Request to the
Camera. If flush() is in progress while processCaptureRequest() is
called, return the current Request immediately in error state. If
flush() has completed and a new call to processCaptureRequest() is
made just after, start the camera again before queuing the request.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jacopo Mondi 2021-05-10 10:13:36 +02:00
parent 103dfb85a7
commit efd5fb7288
3 changed files with 72 additions and 18 deletions

View file

@ -66,8 +66,14 @@ static void hal_dev_dump([[maybe_unused]] const struct camera3_device *dev,
{
}
static int hal_dev_flush([[maybe_unused]] const struct camera3_device *dev)
static int hal_dev_flush(const struct camera3_device *dev)
{
if (!dev)
return -EINVAL;
CameraDevice *camera = reinterpret_cast<CameraDevice *>(dev->priv);
camera->flush();
return 0;
}