diff options
author | Lida Wang <lidaw@codeaurora.org> | 2017-03-24 18:11:28 -0700 |
---|---|---|
committer | Cosme Domínguez Díaz <cosme.ddiaz@gmail.com> | 2018-02-25 16:27:05 +0100 |
commit | 9c51d07b50544dff993f498fdc2addd26267d94b (patch) | |
tree | 5a410691de4d57c87e54586c98f0439b6aa81ad4 /camera/QCamera2 | |
parent | 5d6afff28bd6b64109fc69dc637ce1e249385714 (diff) |
msm8996-common: camera: HAL1: fix HAL1 callback cookie
1. fix HAL1 memory callback cookie for Treble change
2. remove checking for VANILLA_HAL definition for O upgrade now
for initial bring up, until the removal of the TARGET_USE_AOSP
flag in devie mkfile.
Change-Id: Iedf5a97e9890bc7216a3008373ddef5005836a01
Diffstat (limited to 'camera/QCamera2')
-rw-r--r-- | camera/QCamera2/HAL/QCamera2HWI.cpp | 18 | ||||
-rwxr-xr-x | camera/QCamera2/HAL/QCameraMem.cpp | 29 | ||||
-rw-r--r-- | camera/QCamera2/HAL/QCameraMem.h | 9 |
3 files changed, 32 insertions, 24 deletions
diff --git a/camera/QCamera2/HAL/QCamera2HWI.cpp b/camera/QCamera2/HAL/QCamera2HWI.cpp index bc97c07..7066805 100644 --- a/camera/QCamera2/HAL/QCamera2HWI.cpp +++ b/camera/QCamera2/HAL/QCamera2HWI.cpp @@ -2715,14 +2715,16 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( { if (isNoDisplayMode()) { mem = new QCameraStreamMemory(mGetMemory, + mCallbackCookie, bCachedMem, (bPoolMem) ? &m_memoryPool : NULL, stream_type); } else { cam_dimension_t dim; int minFPS, maxFPS; - QCameraGrallocMemory *grallocMemory = - new QCameraGrallocMemory(mGetMemory); + QCameraGrallocMemory *grallocMemory = NULL; + + grallocMemory = new QCameraGrallocMemory(mGetMemory, mCallbackCookie); mParameters.getStreamDimension(stream_type, dim); /* we are interested only in maxfps here */ @@ -2758,12 +2760,12 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( case CAM_STREAM_TYPE_POSTVIEW: { if (isNoDisplayMode() || isPreviewRestartEnabled()) { - 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 */ @@ -2782,6 +2784,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( case CAM_STREAM_TYPE_RAW: case CAM_STREAM_TYPE_OFFLINE_PROC: mem = new QCameraStreamMemory(mGetMemory, + mCallbackCookie, bCachedMem, (bPoolMem) ? &m_memoryPool : NULL, stream_type); @@ -2823,7 +2826,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( QCameraVideoMemory *videoMemory = NULL; if (mParameters.getVideoBatchSize()) { videoMemory = new QCameraVideoMemory( - mGetMemory, FALSE, QCAMERA_MEM_TYPE_BATCH); + mGetMemory, mCallbackCookie, FALSE, QCAMERA_MEM_TYPE_BATCH); if (videoMemory == NULL) { LOGE("Out of memory for video batching obj"); return NULL; @@ -2842,7 +2845,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( } } else { videoMemory = - new QCameraVideoMemory(mGetMemory, bCachedMem); + new QCameraVideoMemory(mGetMemory, mCallbackCookie, bCachedMem); if (videoMemory == NULL) { LOGE("Out of memory for video obj"); return NULL; @@ -2862,6 +2865,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf( break; case CAM_STREAM_TYPE_CALLBACK: mem = new QCameraStreamMemory(mGetMemory, + mCallbackCookie, bCachedMem, (bPoolMem) ? &m_memoryPool : NULL, stream_type); @@ -3175,7 +3179,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamUserBuf( switch (streamInfo->stream_type) { case CAM_STREAM_TYPE_VIDEO: { QCameraVideoMemory *video_mem = new QCameraVideoMemory( - mGetMemory, FALSE, QCAMERA_MEM_TYPE_BATCH); + mGetMemory, mCallbackCookie, FALSE, QCAMERA_MEM_TYPE_BATCH); if (video_mem == NULL) { LOGE("Out of memory for video obj"); return NULL; diff --git a/camera/QCamera2/HAL/QCameraMem.cpp b/camera/QCamera2/HAL/QCameraMem.cpp index f4c239a..2502cf3 100755 --- a/camera/QCamera2/HAL/QCameraMem.cpp +++ b/camera/QCamera2/HAL/QCameraMem.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -1050,11 +1050,13 @@ int QCameraMetadataStreamMemory::getRegFlags(uint8_t *regFlags) const * RETURN : none *==========================================================================*/ QCameraStreamMemory::QCameraStreamMemory(camera_request_memory memory, + void* cbCookie, bool cached, QCameraMemoryPool *pool, cam_stream_type_t streamType, __unused cam_stream_buf_type bufType) :QCameraMemory(cached, pool, streamType), - mGetMemory(memory) + mGetMemory(memory), + mCallbackCookie(cbCookie) { for (int i = 0; i < MM_CAMERA_MAX_NUM_FRAMES; i ++) mCameraMemory[i] = NULL; @@ -1100,7 +1102,7 @@ int QCameraStreamMemory::allocate(uint8_t count, size_t size, uint32_t isSecure) if (isSecure == SECURE) { mCameraMemory[i] = 0; } else { - mCameraMemory[i] = mGetMemory(mMemInfo[i].fd, mMemInfo[i].size, 1, this); + mCameraMemory[i] = mGetMemory(mMemInfo[i].fd, mMemInfo[i].size, 1, mCallbackCookie); } } mBufferCount = count; @@ -1132,7 +1134,7 @@ int QCameraStreamMemory::allocateMore(uint8_t count, size_t size) } 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); ATRACE_END(); @@ -1280,9 +1282,9 @@ void *QCameraStreamMemory::getPtr(uint32_t index) const * * RETURN : none *==========================================================================*/ -QCameraVideoMemory::QCameraVideoMemory(camera_request_memory memory, +QCameraVideoMemory::QCameraVideoMemory(camera_request_memory memory, void* cbCookie, bool cached, QCameraMemType bufType) - : QCameraStreamMemory(memory, cached) + : QCameraStreamMemory(memory, cbCookie, cached) { memset(mMetadata, 0, sizeof(mMetadata)); memset(mNativeHandle, 0, sizeof(mNativeHandle)); @@ -1385,7 +1387,7 @@ int QCameraVideoMemory::allocateMore(uint8_t count, size_t size) if (!(mBufType & QCAMERA_MEM_TYPE_BATCH)) { for (int i = mBufferCount; i < count + mBufferCount; i ++) { mMetadata[i] = mGetMemory(-1, - sizeof(media_metadata_buffer), 1, this); + sizeof(media_metadata_buffer), 1, mCallbackCookie); if (!mMetadata[i]) { LOGE("allocation of video metadata failed."); for (int j = mBufferCount; j <= i-1; j ++) { @@ -1447,7 +1449,7 @@ int QCameraVideoMemory::allocateMeta(uint8_t buf_cnt, int numFDs, int numInts) for (int i = 0; i < buf_cnt; i++) { mMetadata[i] = mGetMemory(-1, - sizeof(media_metadata_buffer), 1, this); + sizeof(media_metadata_buffer), 1, mCallbackCookie); if (!mMetadata[i]) { LOGE("allocation of video metadata failed."); for (int j = (i - 1); j >= 0; j--) { @@ -1709,11 +1711,9 @@ int QCameraVideoMemory::convCamtoOMXFormat(cam_format_t format) case CAM_FORMAT_YUV_420_NV12_VENUS: omxFormat = OMX_COLOR_FormatYUV420SemiPlanar; break; -#ifndef VANILLA_HAL case CAM_FORMAT_YUV_420_NV12_UBWC: omxFormat = QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mCompressed; break; -#endif default: omxFormat = OMX_COLOR_FormatYUV420SemiPlanar; } @@ -1731,7 +1731,7 @@ int QCameraVideoMemory::convCamtoOMXFormat(cam_format_t format) * * RETURN : none *==========================================================================*/ -QCameraGrallocMemory::QCameraGrallocMemory(camera_request_memory memory) +QCameraGrallocMemory::QCameraGrallocMemory(camera_request_memory memory, void* cbCookie) : QCameraMemory(true), mColorSpace(ITU_R_601_FR) { mMinUndequeuedBuffers = 0; @@ -1739,6 +1739,7 @@ QCameraGrallocMemory::QCameraGrallocMemory(camera_request_memory memory) mWindow = NULL; mWidth = mHeight = mStride = mScanline = mUsage = 0; mFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; + mCallbackCookie = cbCookie; mGetMemory = memory; for (int i = 0; i < MM_CAMERA_MAX_NUM_FRAMES; i ++) { mBufferHandle[i] = NULL; @@ -1889,7 +1890,7 @@ int QCameraGrallocMemory::displayBuffer(uint32_t index) mGetMemory(mPrivateHandle[dequeuedIdx]->fd, (size_t)mPrivateHandle[dequeuedIdx]->size, 1, - (void *)this); + mCallbackCookie); LOGH("idx = %d, fd = %d, size = %d, offset = %d", dequeuedIdx, mPrivateHandle[dequeuedIdx]->fd, mPrivateHandle[dequeuedIdx]->size, @@ -2010,7 +2011,7 @@ int32_t QCameraGrallocMemory::dequeueBuffer() mGetMemory(mPrivateHandle[dequeuedIdx]->fd, (size_t)mPrivateHandle[dequeuedIdx]->size, 1, - (void *)this); + mCallbackCookie); LOGH("idx = %d, fd = %d, size = %d, offset = %d", dequeuedIdx, mPrivateHandle[dequeuedIdx]->fd, mPrivateHandle[dequeuedIdx]->size, @@ -2201,7 +2202,7 @@ int QCameraGrallocMemory::allocate(uint8_t count, size_t /*size*/, mGetMemory(mPrivateHandle[cnt]->fd, (size_t)mPrivateHandle[cnt]->size, 1, - (void *)this); + mCallbackCookie); LOGH("idx = %d, fd = %d, size = %d, offset = %d", cnt, mPrivateHandle[cnt]->fd, mPrivateHandle[cnt]->size, diff --git a/camera/QCamera2/HAL/QCameraMem.h b/camera/QCamera2/HAL/QCameraMem.h index a20e29a..ec75e51 100644 --- a/camera/QCamera2/HAL/QCameraMem.h +++ b/camera/QCamera2/HAL/QCameraMem.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -192,6 +192,7 @@ public: 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, @@ -210,13 +211,14 @@ public: protected: camera_request_memory mGetMemory; camera_memory_t *mCameraMemory[MM_CAMERA_MAX_NUM_FRAMES]; + void* mCallbackCookie; }; // Externel heap memory is used for memories shared with // 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, QCameraMemType bufType = QCAMERA_MEM_TYPE_DEFAULT); virtual ~QCameraVideoMemory(); @@ -248,7 +250,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(); @@ -282,6 +284,7 @@ private: preview_stream_ops_t *mWindow; int mWidth, mHeight, mFormat, mStride, mScanline, mUsage, mMaxFPS; camera_request_memory mGetMemory; + void* mCallbackCookie; camera_memory_t *mCameraMemory[MM_CAMERA_MAX_NUM_FRAMES]; int mMinUndequeuedBuffers; enum ColorSpace_t mColorSpace; |