Snap for 4453288 from e159d7e6b2 to pi-release

Change-Id: Idbec5bb4da0d3db2bb37f6d1ba9eeb3ae70b0998
This commit is contained in:
android-build-team Robot 2017-11-15 08:31:03 +00:00
commit 0f43f2e9b1
3 changed files with 18 additions and 7 deletions

View file

@ -28,7 +28,7 @@ to load the V4L2 HAL instead of a default Camera HAL.
Devices and cameras wishing to use this HAL must meet
the following requirements:
* The camera must support BGR32, YUV420, and JPEG formats.
* The camera must support RGB24, YUV420, and JPEG formats.
* The gralloc and other graphics modules used by the device must use
`HAL_PIXEL_FORMAT_RGBA_8888` as the `HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED`
@ -146,6 +146,3 @@ is underfeatured compared to the ideal/what is possible.
* A variety of features are unimplemented: High speed capture,
flash torch mode, hotplugging/unplugging.
* The HAL uses BGR for RGBA. Again, the HAL was designed for the Raspberry Pi
camera, which doesn't support RGB, but RGB is a common default format for
graphics stacks.

View file

@ -57,7 +57,7 @@ FormatCategory StreamFormat::Category() const {
case V4L2_PIX_FMT_JPEG:
return kFormatCategoryStalling;
case V4L2_PIX_FMT_YUV420: // Fall through.
case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_RGB24:
return kFormatCategoryNonStalling;
default:
// Note: currently no supported RAW formats.
@ -87,7 +87,7 @@ int StreamFormat::V4L2ToHalPixelFormat(uint32_t v4l2_pixel_format) {
case V4L2_PIX_FMT_YUV420:
hal_pixel_format = HAL_PIXEL_FORMAT_YCbCr_420_888;
break;
case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_RGB24:
hal_pixel_format = HAL_PIXEL_FORMAT_RGBA_8888;
break;
default:
@ -106,7 +106,7 @@ uint32_t StreamFormat::HalToV4L2PixelFormat(int hal_pixel_format) {
case HAL_PIXEL_FORMAT_RGBA_8888:
// Should be RGB32, but RPi doesn't support that.
// For now we accept that the colors will be off.
v4l2_pixel_format = V4L2_PIX_FMT_BGR32;
v4l2_pixel_format = V4L2_PIX_FMT_RGB24;
break;
case HAL_PIXEL_FORMAT_YCbCr_420_888:
v4l2_pixel_format = V4L2_PIX_FMT_YUV420;

View file

@ -146,6 +146,7 @@ int V4L2Gralloc::lock(const camera3_stream_buffer_t* camera_buffer,
return ret;
}
break;
case V4L2_PIX_FMT_RGB24: // Fall-through.
case V4L2_PIX_FMT_BGR32: // Fall-through.
case V4L2_PIX_FMT_RGB32:
// RGB formats have nice agreed upon representation. Unless using android
@ -204,6 +205,19 @@ int V4L2Gralloc::unlock(const v4l2_buffer* device_buffer) {
const camera3_stream_buffer_t* camera_buffer = buffer_data->camera_buffer;
const buffer_handle_t buffer = *camera_buffer->buffer;
if (StreamFormat::HalToV4L2PixelFormat(camera_buffer->stream->format) == V4L2_PIX_FMT_RGB24) {
// Convert RGB24 to RGB32.
size_t rgb_size = camera_buffer->stream->width * camera_buffer->stream->height;
uint8_t* tail_rgb24 = (uint8_t*)data + 3 * rgb_size - 1;
uint8_t* tail_rgb32 = (uint8_t*)data + 4 * rgb_size - 1;
for (int i = 0; i < rgb_size; i++) {
*(tail_rgb32--) = 0xff;
*(tail_rgb32--) = *(tail_rgb24--);
*(tail_rgb32--) = *(tail_rgb24--);
*(tail_rgb32--) = *(tail_rgb24--);
}
}
// Check for transform.
if (buffer_data->transform_dest) {
HAL_LOGV("Transforming V4L2 YUV to gralloc YUV.");