Camera: fix HAL1 callback cookie

Test: HIDL HAL1 preview up and running
Bug: 30985004
Change-Id: I085f163de6c1c6552925c8241e744c723697d544
This commit is contained in:
Yin-Chia Yeh 2017-02-16 16:52:53 -08:00 committed by Artem Borisov
parent ae5c8b811e
commit 9547a44f41
4 changed files with 21 additions and 15 deletions

View File

@ -1357,11 +1357,11 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(cam_stream_type_t st
case CAM_STREAM_TYPE_PREVIEW:
{
if (isNoDisplayMode()) {
mem = new QCameraStreamMemory(mGetMemory, bCachedMem);
mem = new QCameraStreamMemory(mGetMemory, mCallbackCookie, bCachedMem);
} else {
cam_dimension_t dim;
QCameraGrallocMemory *grallocMemory =
new QCameraGrallocMemory(mGetMemory);
new QCameraGrallocMemory(mGetMemory, mCallbackCookie);
mParameters.getStreamDimension(stream_type, dim);
if (grallocMemory)
@ -1375,7 +1375,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(cam_stream_type_t st
{
cam_dimension_t dim;
QCameraGrallocMemory *grallocMemory =
new QCameraGrallocMemory(mGetMemory);
new QCameraGrallocMemory(mGetMemory, mCallbackCookie);
mParameters.getStreamDimension(stream_type, dim);
if (grallocMemory)
@ -1389,7 +1389,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(cam_stream_type_t st
case CAM_STREAM_TYPE_RAW:
case CAM_STREAM_TYPE_METADATA:
case CAM_STREAM_TYPE_OFFLINE_PROC:
mem = new QCameraStreamMemory(mGetMemory, bCachedMem);
mem = new QCameraStreamMemory(mGetMemory, mCallbackCookie, bCachedMem);
break;
case CAM_STREAM_TYPE_VIDEO:
{
@ -1399,7 +1399,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(cam_stream_type_t st
bCachedMem = QCAMERA_ION_USE_NOCACHE;
}
ALOGD("%s: vidoe buf using cached memory = %d", __func__, bCachedMem);
mem = new QCameraVideoMemory(mGetMemory, bCachedMem);
mem = new QCameraVideoMemory(mGetMemory, mCallbackCookie, bCachedMem);
}
break;
case CAM_STREAM_TYPE_DEFAULT:

View File

@ -579,9 +579,11 @@ int QCameraHeapMemory::getMatchBufIndex(const void *opaque,
* RETURN : none
*==========================================================================*/
QCameraStreamMemory::QCameraStreamMemory(camera_request_memory getMemory,
void* cbCookie,
bool cached)
:QCameraMemory(cached),
mGetMemory(getMemory)
mGetMemory(getMemory),
mCallbackCookie(cbCookie)
{
for (int i = 0; i < MM_CAMERA_MAX_NUM_FRAMES; i ++)
mCameraMemory[i] = NULL;
@ -621,7 +623,7 @@ int QCameraStreamMemory::allocate(int count, int size)
return rc;
for (int i = 0; i < count; i ++) {
mCameraMemory[i] = mGetMemory(mMemInfo[i].fd, mMemInfo[i].size, 1, this);
mCameraMemory[i] = mGetMemory(mMemInfo[i].fd, mMemInfo[i].size, 1, mCallbackCookie);
}
mBufferCount = count;
return NO_ERROR;
@ -764,8 +766,9 @@ void *QCameraStreamMemory::getPtr(int index) const
* RETURN : none
*==========================================================================*/
QCameraVideoMemory::QCameraVideoMemory(camera_request_memory getMemory,
void* cbCookie,
bool cached)
: QCameraStreamMemory(getMemory, cached)
: QCameraStreamMemory(getMemory, cbCookie, cached)
{
memset(mMetadata, 0, sizeof(mMetadata));
}
@ -804,7 +807,7 @@ int QCameraVideoMemory::allocate(int count, int size)
for (int i = 0; i < count; i ++) {
mMetadata[i] = mGetMemory(-1,
sizeof(struct encoder_media_buffer_type), 1, this);
sizeof(struct encoder_media_buffer_type), 1, mCallbackCookie);
if (!mMetadata[i]) {
ALOGE("allocation of video metadata failed.");
for (int j = 0; j < i-1; j ++)
@ -909,13 +912,14 @@ int QCameraVideoMemory::getMatchBufIndex(const void *opaque,
*
* RETURN : none
*==========================================================================*/
QCameraGrallocMemory::QCameraGrallocMemory(camera_request_memory getMemory)
QCameraGrallocMemory::QCameraGrallocMemory(camera_request_memory getMemory, void *cbCookie)
: QCameraMemory(true)
{
mMinUndequeuedBuffers = 0;
mWindow = NULL;
mWidth = mHeight = 0;
mFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP;
mCallbackCookie = cbCookie;
mGetMemory = getMemory;
for (int i = 0; i < MM_CAMERA_MAX_NUM_FRAMES; i ++) {
mBufferHandle[i] = NULL;
@ -1158,7 +1162,7 @@ int QCameraGrallocMemory::allocate(int count, int /*size*/)
mGetMemory(mPrivateHandle[cnt]->fd,
mPrivateHandle[cnt]->size,
1,
(void *)this);
mCallbackCookie);
ALOGD("%s: idx = %d, fd = %d, size = %d, offset = %d",
__func__, cnt, mPrivateHandle[cnt]->fd,
mPrivateHandle[cnt]->size,

View File

@ -108,7 +108,7 @@ private:
// framework. They are allocated from /dev/ion or gralloc.
class QCameraStreamMemory : public QCameraMemory {
public:
QCameraStreamMemory(camera_request_memory getMemory, bool cached);
QCameraStreamMemory(camera_request_memory getMemory, void* cbCookie, bool cached);
virtual ~QCameraStreamMemory();
virtual int allocate(int count, int size);
@ -121,6 +121,7 @@ public:
protected:
camera_request_memory mGetMemory;
void* mCallbackCookie;
camera_memory_t *mCameraMemory[MM_CAMERA_MAX_NUM_FRAMES];
};
@ -128,7 +129,7 @@ protected:
// framework. They are allocated from /dev/ion or gralloc.
class QCameraVideoMemory : public QCameraStreamMemory {
public:
QCameraVideoMemory(camera_request_memory getMemory, bool cached);
QCameraVideoMemory(camera_request_memory getMemory, void* cbCookie, bool cached);
virtual ~QCameraVideoMemory();
virtual int allocate(int count, int size);
@ -148,7 +149,7 @@ class QCameraGrallocMemory : public QCameraMemory {
BUFFER_OWNED,
};
public:
QCameraGrallocMemory(camera_request_memory getMemory);
QCameraGrallocMemory(camera_request_memory getMemory, void* cbCookie);
void setNativeWindow(preview_stream_ops_t *anw);
virtual ~QCameraGrallocMemory();
@ -173,6 +174,7 @@ private:
preview_stream_ops_t *mWindow;
int mWidth, mHeight, mFormat;
camera_request_memory mGetMemory;
void* mCallbackCookie;
camera_memory_t *mCameraMemory[MM_CAMERA_MAX_NUM_FRAMES];
int mMinUndequeuedBuffers;
};

View File

@ -328,7 +328,7 @@ int32_t QCameraPostProcessor::getJpegEncodingConfig(mm_jpeg_encode_params_t& enc
delete m_pJpegOutputMem;
m_pJpegOutputMem = NULL;
}
m_pJpegOutputMem = new QCameraStreamMemory(m_parent->mGetMemory,
m_pJpegOutputMem = new QCameraStreamMemory(m_parent->mGetMemory, m_parent->mCallbackCookie,
QCAMERA_ION_USE_CACHE);
if (NULL == m_pJpegOutputMem) {
ret = NO_MEMORY;