diff options
author | Tyler Luu <tluu@ti.com> | 2012-05-25 14:00:31 -0500 |
---|---|---|
committer | Daniel Levin <dendy@ti.com> | 2012-07-25 08:56:40 -0500 |
commit | 0816e63f87b9a9aff87467f961af24a07d8e80d4 (patch) | |
tree | 103abd18c284a06a4101165333b90e9e5921b1a8 /camera/BufferSourceAdapter.cpp | |
parent | 51d4191bd3e321fc7385eecbd18afcf36dfd1bab (diff) | |
download | hardware_ti_omap4-0816e63f87b9a9aff87467f961af24a07d8e80d4.tar.gz hardware_ti_omap4-0816e63f87b9a9aff87467f961af24a07d8e80d4.tar.bz2 hardware_ti_omap4-0816e63f87b9a9aff87467f961af24a07d8e80d4.zip |
camera: buffersource: changes to nv12 allocation
Adapting NV12 system heap allocations to gralloc changes.
NV12-1D format is no longer supported. Instead, we are using
existing NV12 format with the GRALLOC_USAGE_PRIVATE_0 usage
flag to signal to gralloc we want allocations to come from
the system heap.
Change-Id: I421a27b8cc0bb0e9dfe3b97290fe7114127be72f
Signed-off-by: Tyler Luu <tluu@ti.com>
Diffstat (limited to 'camera/BufferSourceAdapter.cpp')
-rw-r--r-- | camera/BufferSourceAdapter.cpp | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/camera/BufferSourceAdapter.cpp b/camera/BufferSourceAdapter.cpp index cd596d5..384307a 100644 --- a/camera/BufferSourceAdapter.cpp +++ b/camera/BufferSourceAdapter.cpp @@ -23,7 +23,7 @@ namespace android { static int getANWFormat(const char* parameters_format) { - int format = HAL_PIXEL_FORMAT_TI_NV12_1D; + int format = HAL_PIXEL_FORMAT_TI_NV12; if (parameters_format != NULL) { if (strcmp(parameters_format, CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { @@ -32,24 +32,42 @@ static int getANWFormat(const char* parameters_format) format = -1; } else if (strcmp(parameters_format, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { CAMHAL_LOGDA("YUV420SP format selected"); - format = HAL_PIXEL_FORMAT_TI_NV12_1D; + format = HAL_PIXEL_FORMAT_TI_NV12; } else if (strcmp(parameters_format, CameraParameters::PIXEL_FORMAT_RGB565) == 0) { CAMHAL_LOGDA("RGB565 format selected"); // TODO(XXX): not defined yet format = -1; } else { CAMHAL_LOGDA("Invalid format, NV12 format selected as default"); - format = HAL_PIXEL_FORMAT_TI_NV12_1D; + format = HAL_PIXEL_FORMAT_TI_NV12; } } return format; } +static int getUsageFromANW(int format) +{ + int usage = GRALLOC_USAGE_SW_READ_RARELY | + GRALLOC_USAGE_SW_WRITE_NEVER; + + switch (format) { + case HAL_PIXEL_FORMAT_TI_NV12: + // This usage flag indicates to gralloc we want the + // buffers to come from system heap + usage |= GRALLOC_USAGE_PRIVATE_0; + break; + default: + // No special flags needed + break; + } + return usage; +} + static const char* getFormatFromANW(int format) { switch (format) { - case HAL_PIXEL_FORMAT_TI_NV12_1D: + case HAL_PIXEL_FORMAT_TI_NV12: // Assuming NV12 1D is RAW or Image frame return CameraParameters::PIXEL_FORMAT_YUV420SP; default: @@ -60,12 +78,9 @@ static const char* getFormatFromANW(int format) static CameraFrame::FrameType formatToOutputFrameType(const char* format) { switch (getANWFormat(format)) { - case HAL_PIXEL_FORMAT_TI_NV12_1D: + case HAL_PIXEL_FORMAT_TI_NV12: // Assuming NV12 1D is RAW or Image frame return CameraFrame::RAW_FRAME; - case HAL_PIXEL_FORMAT_TI_NV12: - // Assuming NV12 2D is preview or postview frame - return CameraFrame::PREVIEW_FRAME_SYNC; default: break; } @@ -285,8 +300,11 @@ CameraBuffer* BufferSourceAdapter::allocateBufferList(int width, int height, con return NULL; } + int pixFormat = getANWFormat(format); + int usage = getUsageFromANW(pixFormat); + // Set gralloc usage bits for window. - err = mBufferSource->set_usage(mBufferSource, CAMHAL_GRALLOC_USAGE); + err = mBufferSource->set_usage(mBufferSource, usage); if (err != 0) { CAMHAL_LOGE("native_window_set_usage failed: %s (%d)", strerror(-err), -err); |