diff options
| author | yin-chia yeh <yinchiachen@gmail.com> | 2017-08-26 21:34:40 +0530 |
|---|---|---|
| committer | dev-harsh1998 <harshitjain6751@gmail.com> | 2017-10-18 12:46:19 +0530 |
| commit | a5f44ddcacbb6b8d0582d414b962d3eb3bc90fab (patch) | |
| tree | b324558ef0aaf173afdfde4f64d5d0a397dd07f0 | |
| parent | 9a43daae8f83b5a9fe32f9b0423b1502209b4c7c (diff) | |
a6000: Camera: fix HAL1 callback cookie
@dev-harsh1998: adapt for our older Lenovo A6000's cam hal
Test: HIDL HAL1 preview up and running
Bug: 30985004
Change-Id: I085f163de6c1c6552925c8241e744c723697d544
| -rwxr-xr-x | camera/QCamera2/HAL/QCamera2HWI.cpp | 10 | ||||
| -rw-r--r-- | camera/QCamera2/HAL/QCameraMem.cpp | 23 | ||||
| -rw-r--r-- | camera/QCamera2/HAL/QCameraMem.h | 8 |
3 files changed, 25 insertions, 16 deletions
diff --git a/camera/QCamera2/HAL/QCamera2HWI.cpp b/camera/QCamera2/HAL/QCamera2HWI.cpp index 325f478..dfca482 100755 --- a/camera/QCamera2/HAL/QCamera2HWI.cpp +++ b/camera/QCamera2/HAL/QCamera2HWI.cpp @@ -1718,6 +1718,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( case CAM_STREAM_TYPE_PREVIEW: { if (isNoDisplayMode()) { + mCallbackCookie, mem = new QCameraStreamMemory(mGetMemory, bCachedMem, (bPoolMem) ? &m_memoryPool : NULL, @@ -1726,7 +1727,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( cam_dimension_t dim; int minFPS, maxFPS; QCameraGrallocMemory *grallocMemory = - new QCameraGrallocMemory(mGetMemory); + new QCameraGrallocMemory(mGetMemory, mCallbackCookie); mParameters.getStreamDimension(stream_type, dim); /* we are interested only in maxfps here */ @@ -1742,12 +1743,12 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( case CAM_STREAM_TYPE_POSTVIEW: { if (isPreviewRestartEnabled() || isNoDisplayMode()) { - mem = new QCameraStreamMemory(mGetMemory, bCachedMem); + mem = new QCameraStreamMemory(mGetMemory, mCallbackCookie, bCachedMem); } else { cam_dimension_t dim; int minFPS, maxFPS; QCameraGrallocMemory *grallocMemory = - new QCameraGrallocMemory(mGetMemory); + new QCameraGrallocMemory(mGetMemory, mCallbackCookie); mParameters.getStreamDimension(stream_type, dim); /* we are interested only in maxfps here */ @@ -1769,6 +1770,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( case CAM_STREAM_TYPE_METADATA: case CAM_STREAM_TYPE_OFFLINE_PROC: mem = new QCameraStreamMemory(mGetMemory, + mCallbackCookie, bCachedMem, (bPoolMem) ? &m_memoryPool : NULL, stream_type); @@ -1779,7 +1781,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( bCachedMem = mParameters.isVideoBuffersCached(); CDBG_HIGH("%s: %s video buf allocated ", __func__, (bCachedMem == 0) ? "Uncached" : "Cached" ); - mem = new QCameraVideoMemory(mGetMemory, bCachedMem); + mem = new QCameraVideoMemory(mGetMemory, mCallbackCookie, bCachedMem); } break; case CAM_STREAM_TYPE_DEFAULT: diff --git a/camera/QCamera2/HAL/QCameraMem.cpp b/camera/QCamera2/HAL/QCameraMem.cpp index 06f25c5..a0ef05f 100644 --- a/camera/QCamera2/HAL/QCameraMem.cpp +++ b/camera/QCamera2/HAL/QCameraMem.cpp @@ -871,11 +871,13 @@ int QCameraHeapMemory::getMatchBufIndex(const void *opaque, * RETURN : none *==========================================================================*/ QCameraStreamMemory::QCameraStreamMemory(camera_request_memory getMemory, + void* cbCookie, bool cached, QCameraMemoryPool *pool, cam_stream_type_t streamType) :QCameraMemory(cached, pool, streamType), - mGetMemory(getMemory) + mGetMemory(getMemory), + mCallbackCookie(cbCookie) { for (int i = 0; i < MM_CAMERA_MAX_NUM_FRAMES; i ++) mCameraMemory[i] = NULL; @@ -916,7 +918,7 @@ int QCameraStreamMemory::allocate(uint8_t count, size_t 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; traceLogAllocEnd((size * count)); @@ -945,7 +947,7 @@ int QCameraStreamMemory::allocateMore(uint8_t count, size_t size) return rc; for (int i = mBufferCount; i < mBufferCount + 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 = (uint8_t)(mBufferCount + count); traceLogAllocEnd((size * count)); @@ -1089,9 +1091,10 @@ void *QCameraStreamMemory::getPtr(uint32_t index) const * * RETURN : none *==========================================================================*/ -QCameraVideoMemory::QCameraVideoMemory(camera_request_memory getMemory, +QCameraVideoMemory::QCameraVideoMemory(camera_request_memory memory, + void* cbCookie, bool cached) - : QCameraStreamMemory(getMemory, cached) + : QCameraStreamMemory(memory, cbCookie, cached) { memset(mMetadata, 0, sizeof(mMetadata)); } @@ -1131,7 +1134,7 @@ int QCameraVideoMemory::allocate(uint8_t count, size_t 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 ++) @@ -1176,7 +1179,7 @@ int QCameraVideoMemory::allocateMore(uint8_t count, size_t size) for (int i = mBufferCount; i < count + mBufferCount; 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 = mBufferCount; j <= i-1; j ++) { @@ -1302,14 +1305,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 = mStride = mScanline = 0; mFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; - mGetMemory = getMemory; + mCallbackCookie = cbCookie; for (int i = 0; i < MM_CAMERA_MAX_NUM_FRAMES; i ++) { mBufferHandle[i] = NULL; mLocalFlag[i] = BUFFER_NOT_OWNED; @@ -1599,7 +1602,7 @@ int QCameraGrallocMemory::allocate(uint8_t count, size_t /*size*/) mGetMemory(mPrivateHandle[cnt]->fd, (size_t)mPrivateHandle[cnt]->size, 1, - (void *)this); + mCallbackCookie); CDBG("%s: idx = %d, fd = %d, size = %d, offset = %d", __func__, cnt, mPrivateHandle[cnt]->fd, mPrivateHandle[cnt]->size, diff --git a/camera/QCamera2/HAL/QCameraMem.h b/camera/QCamera2/HAL/QCameraMem.h index 52313e8..97a5dad 100644 --- a/camera/QCamera2/HAL/QCameraMem.h +++ b/camera/QCamera2/HAL/QCameraMem.h @@ -161,6 +161,7 @@ private: class QCameraStreamMemory : public QCameraMemory { public: QCameraStreamMemory(camera_request_memory getMemory, + void* cbCookie, bool cached, QCameraMemoryPool *pool = NULL, cam_stream_type_t streamType = CAM_STREAM_TYPE_DEFAULT); @@ -177,6 +178,7 @@ public: protected: camera_request_memory mGetMemory; + void* mCallbackCookie; camera_memory_t *mCameraMemory[MM_CAMERA_MAX_NUM_FRAMES]; }; @@ -184,7 +186,8 @@ 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(uint8_t count, size_t size); @@ -205,7 +208,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(); @@ -233,6 +236,7 @@ private: preview_stream_ops_t *mWindow; int mWidth, mHeight, mFormat, mStride, mScanline, mMaxFPS; camera_request_memory mGetMemory; + void* mCallbackCookie; camera_memory_t *mCameraMemory[MM_CAMERA_MAX_NUM_FRAMES]; int mMinUndequeuedBuffers; }; |
