Commit aa1321b0 authored by Jasmine Chen's avatar Jasmine Chen Committed by Commit Bot

camera: Enable ZSL for one shot requests

This CL enables ZSL for one shot requests. It sets
ANDROID_CONTROL_ENABLE_ZSL to true for still capture requests and a
private usage flag to still capture streams so that adapter recognizes
still capture output streams.

BUG=b:130851309
TEST=Enabled ZSL and verified still capture works with ZSL CLs.

Change-Id: Idb0741f56b55b93a157e7ee11aff4beff2024451
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1896480Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarWei Lee <wtlee@chromium.org>
Commit-Queue: Jasmine Chen <lnishan@google.com>
Cr-Commit-Position: refs/heads/master@{#713843}
parent 930b4b09
...@@ -591,6 +591,8 @@ void CameraDeviceDelegate::ConfigureStreams( ...@@ -591,6 +591,8 @@ void CameraDeviceDelegate::ConfigureStreams(
still_capture_stream->height = blob_height; still_capture_stream->height = blob_height;
still_capture_stream->format = still_capture_stream->format =
cros::mojom::HalPixelFormat::HAL_PIXEL_FORMAT_BLOB; cros::mojom::HalPixelFormat::HAL_PIXEL_FORMAT_BLOB;
// Set usage flag to allow HAL adapter to identify a still capture stream.
still_capture_stream->usage = cros::mojom::GRALLOC_USAGE_STILL_CAPTURE;
still_capture_stream->data_space = 0; still_capture_stream->data_space = 0;
still_capture_stream->rotation = still_capture_stream->rotation =
cros::mojom::Camera3StreamRotation::CAMERA3_STREAM_ROTATION_0; cros::mojom::Camera3StreamRotation::CAMERA3_STREAM_ROTATION_0;
...@@ -620,6 +622,9 @@ void CameraDeviceDelegate::ConfigureStreams( ...@@ -620,6 +622,9 @@ void CameraDeviceDelegate::ConfigureStreams(
reprocessing_stream_output->height = max_yuv_height; reprocessing_stream_output->height = max_yuv_height;
reprocessing_stream_output->format = reprocessing_stream_output->format =
cros::mojom::HalPixelFormat::HAL_PIXEL_FORMAT_YCbCr_420_888; cros::mojom::HalPixelFormat::HAL_PIXEL_FORMAT_YCbCr_420_888;
// Set usage flag to allow HAL adapter to identify a still capture stream.
reprocessing_stream_output->usage =
cros::mojom::GRALLOC_USAGE_STILL_CAPTURE;
reprocessing_stream_output->data_space = 0; reprocessing_stream_output->data_space = 0;
reprocessing_stream_output->rotation = reprocessing_stream_output->rotation =
cros::mojom::Camera3StreamRotation::CAMERA3_STREAM_ROTATION_0; cros::mojom::Camera3StreamRotation::CAMERA3_STREAM_ROTATION_0;
......
...@@ -18,6 +18,15 @@ const uint32 GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030; ...@@ -18,6 +18,15 @@ const uint32 GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030;
const uint32 GRALLOC_USAGE_HW_COMPOSER = 0x00000800; const uint32 GRALLOC_USAGE_HW_COMPOSER = 0x00000800;
const uint32 GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000; const uint32 GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000;
const uint32 GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000; const uint32 GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000;
// A private gralloc usage flag to force allocation of YUV420 buffer. This
// usage flag is only valid when allocating HAL_PIXEL_FORMAT_YCbCr_420_888
// flexible YUV buffers.
const uint32 GRALLOC_USAGE_FORCE_I420 = 0x10000000;
// Setting this flag means this stream is intended for still capture. We're
// using the usage flag as an indicator for an output stream that can be split
// into a new HAL request for Zero-Shutter Lag (ZSL). See crrev.com/c/1877636
// for the CL that does the aforementioned things.
const uint32 GRALLOC_USAGE_STILL_CAPTURE = 0x20000000;
[Extensible] [Extensible]
enum HalPixelFormat { enum HalPixelFormat {
......
...@@ -255,6 +255,18 @@ void RequestManager::SetSensorTimestamp( ...@@ -255,6 +255,18 @@ void RequestManager::SetSensorTimestamp(
AddOrUpdateMetadataEntry(settings, std::move(e)); AddOrUpdateMetadataEntry(settings, std::move(e));
} }
void RequestManager::SetZeroShutterLag(cros::mojom::CameraMetadataPtr* settings,
bool enabled) {
std::vector<uint8_t> control_enable_zsl = {static_cast<uint8_t>(enabled)};
cros::mojom::CameraMetadataEntryPtr e =
cros::mojom::CameraMetadataEntry::New();
e->tag = cros::mojom::CameraMetadataTag::ANDROID_CONTROL_ENABLE_ZSL;
e->type = cros::mojom::EntryType::TYPE_BYTE;
e->count = 1;
e->data = control_enable_zsl;
AddOrUpdateMetadataEntry(settings, std::move(e));
}
void RequestManager::PrepareCaptureRequest() { void RequestManager::PrepareCaptureRequest() {
DCHECK(ipc_task_runner_->BelongsToCurrentThread()); DCHECK(ipc_task_runner_->BelongsToCurrentThread());
...@@ -441,6 +453,7 @@ bool RequestManager::TryPrepareOneShotRequest( ...@@ -441,6 +453,7 @@ bool RequestManager::TryPrepareOneShotRequest(
*settings = std::move(take_photo_settings_queue_.front()); *settings = std::move(take_photo_settings_queue_.front());
SetJpegOrientation(settings); SetJpegOrientation(settings);
} }
SetZeroShutterLag(settings, true);
take_photo_settings_queue_.pop(); take_photo_settings_queue_.pop();
return true; return true;
} }
......
...@@ -220,6 +220,10 @@ class CAPTURE_EXPORT RequestManager final ...@@ -220,6 +220,10 @@ class CAPTURE_EXPORT RequestManager final
void SetSensorTimestamp(cros::mojom::CameraMetadataPtr* settings, void SetSensorTimestamp(cros::mojom::CameraMetadataPtr* settings,
uint64_t shutter_timestamp); uint64_t shutter_timestamp);
// Puts availability of Zero Shutter Lag into the metadata.
void SetZeroShutterLag(cros::mojom::CameraMetadataPtr* settings,
bool enabled);
// Prepares a capture request by mixing repeating request with one-shot // Prepares a capture request by mixing repeating request with one-shot
// request if it exists. If there are reprocess requests in the queue, just // request if it exists. If there are reprocess requests in the queue, just
// build the reprocess capture request without mixing the repeating request. // build the reprocess capture request without mixing the repeating request.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment