diff options
author | Jason Macnak <natsu@google.com> | 2020-04-20 14:32:11 -0700 |
---|---|---|
committer | Jason Macnak <natsu@google.com> | 2020-05-13 08:47:39 -0700 |
commit | 23ea2f3155db32732e6ea9d24d7f69a065a15b3f (patch) | |
tree | 51c9749321b2e0af226c18ac9b0f9817b4185ba6 | |
parent | e2a94baf658a9b3e334c824c9d6c5bfa2923bd22 (diff) | |
download | camera-23ea2f3155db32732e6ea9d24d7f69a065a15b3f.tar.gz |
Update emulated camera to use gralloc lock w/ region
Gralloc buffers should be locked using proper regions. Prior to
this change, the emulated camera would try to lock 2D Y16 buffers
using a [total-byte-size,1] rectangle. Cuttlefish's existing
gralloc implementation does not perform any validation on the
supplied region. Cuttlefish is updating its gralloc implementation
to gralloc 4.0 on Minigbm which will start performing more
validation including validation the lock access region.
Bug: b/146515640
Test: cts -m CtsCameraTestCases
Change-Id: I35bc2c83d3ebbb59283122e1df6b87436427f974
-rw-r--r-- | devices/EmulatedCamera/hwl/EmulatedRequestProcessor.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/devices/EmulatedCamera/hwl/EmulatedRequestProcessor.cpp b/devices/EmulatedCamera/hwl/EmulatedRequestProcessor.cpp index 7acae76..e78d3c3 100644 --- a/devices/EmulatedCamera/hwl/EmulatedRequestProcessor.cpp +++ b/devices/EmulatedCamera/hwl/EmulatedRequestProcessor.cpp @@ -232,21 +232,25 @@ status_t EmulatedRequestProcessor::LockSensorBuffer( } else { uint32_t buffer_size = 0, stride = 0; auto ret = GetBufferSizeAndStride(stream, &buffer_size, &stride); - if (ret == OK) { + if (ret != OK) { + ALOGE("%s: Unsupported pixel format: 0x%x", __FUNCTION__, + stream.override_format); + return BAD_VALUE; + } + if (stream.override_format == HAL_PIXEL_FORMAT_BLOB) { sensor_buffer->plane.img.img = static_cast<uint8_t*>(importer.lock(buffer, usage, buffer_size)); - if (sensor_buffer->plane.img.img != nullptr) { - sensor_buffer->plane.img.stride = stride; - sensor_buffer->plane.img.buffer_size = buffer_size; - } else { - ALOGE("%s: Failed to lock output buffer!", __FUNCTION__); - return BAD_VALUE; - } } else { - ALOGE("%s: Unsupported pixel format: 0x%x", __FUNCTION__, - stream.override_format); + IMapper::Rect region{0, 0, width, height}; + sensor_buffer->plane.img.img = + static_cast<uint8_t*>(importer.lock(buffer, usage, region)); + } + if (sensor_buffer->plane.img.img == nullptr) { + ALOGE("%s: Failed to lock output buffer!", __FUNCTION__); return BAD_VALUE; } + sensor_buffer->plane.img.stride = stride; + sensor_buffer->plane.img.buffer_size = buffer_size; } return OK; |