summaryrefslogtreecommitdiff
path: root/camera
diff options
context:
space:
mode:
authorShuzhen Wang <shuzhenw@codeaurora.org>2014-09-26 10:14:22 -0700
committerZhijun He <zhijunhe@google.com>2014-09-30 16:45:38 +0000
commitdaec9d40b65d53fdca0229ff89a9bb875ca68067 (patch)
tree48b4b97e890a129d4d071aa9492839c96100c259 /camera
parent0d5d76cd2ee9558b451c6adb67510f6a627c6824 (diff)
downloadshamu-daec9d40b65d53fdca0229ff89a9bb875ca68067.tar.gz
camera: Add color space info for gralloc buffer
This makes sure other subsystem (display/video encoder) can interprete buffers properly in the correct color space. Bug: 17700720 Change-Id: I7eae741fb7167bd8bdecd1fb026e2bb34f04ec2c
Diffstat (limited to 'camera')
-rw-r--r--camera/QCamera2/Android.mk3
-rw-r--r--camera/QCamera2/HAL3/QCamera3Channel.cpp8
-rw-r--r--camera/QCamera2/HAL3/QCamera3Mem.cpp21
-rw-r--r--camera/QCamera2/HAL3/QCamera3Mem.h2
4 files changed, 29 insertions, 5 deletions
diff --git a/camera/QCamera2/Android.mk b/camera/QCamera2/Android.mk
index ab8f3a54..9cf55098 100644
--- a/camera/QCamera2/Android.mk
+++ b/camera/QCamera2/Android.mk
@@ -57,9 +57,12 @@ LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
#LOCAL_STATIC_LIBRARIES := libqcamera2_util
LOCAL_C_INCLUDES += \
hardware/qcom/display/$(TARGET_BOARD_PLATFORM)/libgralloc
+LOCAL_C_INCLUDES += \
+ hardware/qcom/display/$(TARGET_BOARD_PLATFORM)/libqdutils
LOCAL_SHARED_LIBRARIES := libcamera_client liblog libhardware libutils libcutils libdl
LOCAL_SHARED_LIBRARIES += libmmcamera_interface libmmjpeg_interface libui libcamera_metadata
+LOCAL_SHARED_LIBRARIES += libqdMetaData
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM)
diff --git a/camera/QCamera2/HAL3/QCamera3Channel.cpp b/camera/QCamera2/HAL3/QCamera3Channel.cpp
index 89d3331c..7d000f91 100644
--- a/camera/QCamera2/HAL3/QCamera3Channel.cpp
+++ b/camera/QCamera2/HAL3/QCamera3Channel.cpp
@@ -750,6 +750,7 @@ int32_t QCamera3RegularChannel::registerBuffer(buffer_handle_t *buffer, cam_is_t
ATRACE_CALL();
int rc = 0;
mIsType = isType;
+ cam_stream_type_t streamType;
if ((uint32_t)mMemory.getCnt() > (mNumBufs - 1)) {
ALOGE("%s: Trying to register more buffers than initially requested",
@@ -766,7 +767,8 @@ int32_t QCamera3RegularChannel::registerBuffer(buffer_handle_t *buffer, cam_is_t
}
}
- rc = mMemory.registerBuffer(buffer);
+ streamType = mStreams[0]->getMyType();
+ rc = mMemory.registerBuffer(buffer, streamType);
if (ALREADY_EXISTS == rc) {
return NO_ERROR;
} else if (NO_ERROR != rc) {
@@ -1698,7 +1700,7 @@ int32_t QCamera3PicChannel::request(buffer_handle_t *buffer,
int input_index = mOfflineMemory.getMatchBufIndex((void*)pInputBuffer->buffer);
if(input_index < 0) {
- rc = mOfflineMemory.registerBuffer(pInputBuffer->buffer);
+ rc = mOfflineMemory.registerBuffer(pInputBuffer->buffer, mStreamType);
if (NO_ERROR != rc) {
ALOGE("%s: On-the-fly input buffer registration failed %d",
__func__, rc);
@@ -1862,7 +1864,7 @@ int32_t QCamera3PicChannel::registerBuffer(buffer_handle_t *buffer, cam_is_type_
return rc;
}
}
- rc = mMemory.registerBuffer(buffer);
+ rc = mMemory.registerBuffer(buffer, mStreamType);
if (ALREADY_EXISTS == rc) {
return NO_ERROR;
} else if (NO_ERROR != rc) {
diff --git a/camera/QCamera2/HAL3/QCamera3Mem.cpp b/camera/QCamera2/HAL3/QCamera3Mem.cpp
index 05b47a00..fb7de07a 100644
--- a/camera/QCamera2/HAL3/QCamera3Mem.cpp
+++ b/camera/QCamera2/HAL3/QCamera3Mem.cpp
@@ -35,6 +35,7 @@
#include <utils/Log.h>
#include <utils/Errors.h>
#include <gralloc_priv.h>
+#include <qdMetaData.h>
#include "QCamera3Mem.h"
#include "QCamera3HWI.h"
@@ -596,16 +597,19 @@ QCamera3GrallocMemory::~QCamera3GrallocMemory()
*
* PARAMETERS :
* @buffers : buffer_handle_t pointer
+ * @type : cam_stream_type_t
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCamera3GrallocMemory::registerBuffer(buffer_handle_t *buffer)
+int QCamera3GrallocMemory::registerBuffer(buffer_handle_t *buffer,
+ cam_stream_type_t type)
{
status_t ret = NO_ERROR;
struct ion_fd_data ion_info_fd;
void *vaddr = NULL;
+ int32_t colorSpace = ITU_R_601;
CDBG(" %s : E ", __FUNCTION__);
memset(&ion_info_fd, 0, sizeof(ion_info_fd));
@@ -624,6 +628,21 @@ int QCamera3GrallocMemory::registerBuffer(buffer_handle_t *buffer)
mBufferHandle[mBufferCount] = buffer;
mPrivateHandle[mBufferCount] =
(struct private_handle_t *)(*mBufferHandle[mBufferCount]);
+
+ switch (type) {
+ case CAM_STREAM_TYPE_PREVIEW:
+ case CAM_STREAM_TYPE_POSTVIEW:
+ case CAM_STREAM_TYPE_SNAPSHOT:
+ case CAM_STREAM_TYPE_VIDEO:
+ colorSpace = ITU_R_601;
+ break;
+ default:
+ colorSpace = ITU_R_601;
+ break;
+ }
+ ALOGE("%s: setting colorSpace to %d for stream type %d", __func__, colorSpace, type);
+ setMetaData(mPrivateHandle[mBufferCount], UPDATE_COLOR_SPACE, &colorSpace);
+
mMemInfo[mBufferCount].main_ion_fd = open("/dev/ion", O_RDONLY);
if (mMemInfo[mBufferCount].main_ion_fd < 0) {
ALOGE("%s: failed: could not open ion device", __func__);
diff --git a/camera/QCamera2/HAL3/QCamera3Mem.h b/camera/QCamera2/HAL3/QCamera3Mem.h
index c79efe8f..a4034f2c 100644
--- a/camera/QCamera2/HAL3/QCamera3Mem.h
+++ b/camera/QCamera2/HAL3/QCamera3Mem.h
@@ -107,7 +107,7 @@ public:
QCamera3GrallocMemory();
virtual ~QCamera3GrallocMemory();
- int registerBuffer(buffer_handle_t *buffer);
+ int registerBuffer(buffer_handle_t *buffer, cam_stream_type_t type);
void unregisterBuffers();
virtual int cacheOps(int index, unsigned int cmd);
virtual int getRegFlags(uint8_t *regFlags) const;