Camera2: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
This commit is contained in:
parent
83d447f155
commit
26165a08a7
3 changed files with 32 additions and 22 deletions
|
@ -2666,14 +2666,16 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(
|
||||||
{
|
{
|
||||||
if (isNoDisplayMode()) {
|
if (isNoDisplayMode()) {
|
||||||
mem = new QCameraStreamMemory(mGetMemory,
|
mem = new QCameraStreamMemory(mGetMemory,
|
||||||
|
mCallbackCookie,
|
||||||
bCachedMem,
|
bCachedMem,
|
||||||
(bPoolMem) ? &m_memoryPool : NULL,
|
(bPoolMem) ? &m_memoryPool : NULL,
|
||||||
stream_type);
|
stream_type);
|
||||||
} else {
|
} else {
|
||||||
cam_dimension_t dim;
|
cam_dimension_t dim;
|
||||||
int minFPS, maxFPS;
|
int minFPS, maxFPS;
|
||||||
QCameraGrallocMemory *grallocMemory =
|
QCameraGrallocMemory *grallocMemory = NULL;
|
||||||
new QCameraGrallocMemory(mGetMemory);
|
|
||||||
|
grallocMemory = new QCameraGrallocMemory(mGetMemory, mCallbackCookie);
|
||||||
|
|
||||||
mParameters.getStreamDimension(stream_type, dim);
|
mParameters.getStreamDimension(stream_type, dim);
|
||||||
/* we are interested only in maxfps here */
|
/* we are interested only in maxfps here */
|
||||||
|
@ -2709,12 +2711,12 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(
|
||||||
case CAM_STREAM_TYPE_POSTVIEW:
|
case CAM_STREAM_TYPE_POSTVIEW:
|
||||||
{
|
{
|
||||||
if (isNoDisplayMode() || isPreviewRestartEnabled()) {
|
if (isNoDisplayMode() || isPreviewRestartEnabled()) {
|
||||||
mem = new QCameraStreamMemory(mGetMemory, bCachedMem);
|
mem = new QCameraStreamMemory(mGetMemory, mCallbackCookie, bCachedMem);
|
||||||
} else {
|
} else {
|
||||||
cam_dimension_t dim;
|
cam_dimension_t dim;
|
||||||
int minFPS, maxFPS;
|
int minFPS, maxFPS;
|
||||||
QCameraGrallocMemory *grallocMemory =
|
QCameraGrallocMemory *grallocMemory =
|
||||||
new QCameraGrallocMemory(mGetMemory);
|
new QCameraGrallocMemory(mGetMemory, mCallbackCookie);
|
||||||
|
|
||||||
mParameters.getStreamDimension(stream_type, dim);
|
mParameters.getStreamDimension(stream_type, dim);
|
||||||
/* we are interested only in maxfps here */
|
/* we are interested only in maxfps here */
|
||||||
|
@ -2733,6 +2735,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(
|
||||||
case CAM_STREAM_TYPE_RAW:
|
case CAM_STREAM_TYPE_RAW:
|
||||||
case CAM_STREAM_TYPE_OFFLINE_PROC:
|
case CAM_STREAM_TYPE_OFFLINE_PROC:
|
||||||
mem = new QCameraStreamMemory(mGetMemory,
|
mem = new QCameraStreamMemory(mGetMemory,
|
||||||
|
mCallbackCookie,
|
||||||
bCachedMem,
|
bCachedMem,
|
||||||
(bPoolMem) ? &m_memoryPool : NULL,
|
(bPoolMem) ? &m_memoryPool : NULL,
|
||||||
stream_type);
|
stream_type);
|
||||||
|
@ -2774,7 +2777,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(
|
||||||
QCameraVideoMemory *videoMemory = NULL;
|
QCameraVideoMemory *videoMemory = NULL;
|
||||||
if (mParameters.getVideoBatchSize()) {
|
if (mParameters.getVideoBatchSize()) {
|
||||||
videoMemory = new QCameraVideoMemory(
|
videoMemory = new QCameraVideoMemory(
|
||||||
mGetMemory, FALSE, QCAMERA_MEM_TYPE_BATCH);
|
mGetMemory, mCallbackCookie, FALSE, QCAMERA_MEM_TYPE_BATCH);
|
||||||
if (videoMemory == NULL) {
|
if (videoMemory == NULL) {
|
||||||
LOGE("Out of memory for video batching obj");
|
LOGE("Out of memory for video batching obj");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2793,7 +2796,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
videoMemory =
|
videoMemory =
|
||||||
new QCameraVideoMemory(mGetMemory, bCachedMem);
|
new QCameraVideoMemory(mGetMemory, mCallbackCookie, bCachedMem);
|
||||||
if (videoMemory == NULL) {
|
if (videoMemory == NULL) {
|
||||||
LOGE("Out of memory for video obj");
|
LOGE("Out of memory for video obj");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2812,6 +2815,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(
|
||||||
break;
|
break;
|
||||||
case CAM_STREAM_TYPE_CALLBACK:
|
case CAM_STREAM_TYPE_CALLBACK:
|
||||||
mem = new QCameraStreamMemory(mGetMemory,
|
mem = new QCameraStreamMemory(mGetMemory,
|
||||||
|
mCallbackCookie,
|
||||||
bCachedMem,
|
bCachedMem,
|
||||||
(bPoolMem) ? &m_memoryPool : NULL,
|
(bPoolMem) ? &m_memoryPool : NULL,
|
||||||
stream_type);
|
stream_type);
|
||||||
|
@ -3114,7 +3118,7 @@ QCameraMemory *QCamera2HardwareInterface::allocateStreamUserBuf(
|
||||||
switch (streamInfo->stream_type) {
|
switch (streamInfo->stream_type) {
|
||||||
case CAM_STREAM_TYPE_VIDEO: {
|
case CAM_STREAM_TYPE_VIDEO: {
|
||||||
QCameraVideoMemory *video_mem = new QCameraVideoMemory(
|
QCameraVideoMemory *video_mem = new QCameraVideoMemory(
|
||||||
mGetMemory, FALSE, QCAMERA_MEM_TYPE_BATCH);
|
mGetMemory, mCallbackCookie, FALSE, QCAMERA_MEM_TYPE_BATCH);
|
||||||
if (video_mem == NULL) {
|
if (video_mem == NULL) {
|
||||||
LOGE("Out of memory for video obj");
|
LOGE("Out of memory for video obj");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
|
@ -1050,11 +1050,13 @@ int QCameraMetadataStreamMemory::getRegFlags(uint8_t *regFlags) const
|
||||||
* RETURN : none
|
* RETURN : none
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
QCameraStreamMemory::QCameraStreamMemory(camera_request_memory memory,
|
QCameraStreamMemory::QCameraStreamMemory(camera_request_memory memory,
|
||||||
|
void* cbCookie,
|
||||||
bool cached,
|
bool cached,
|
||||||
QCameraMemoryPool *pool,
|
QCameraMemoryPool *pool,
|
||||||
cam_stream_type_t streamType, __unused cam_stream_buf_type bufType)
|
cam_stream_type_t streamType, __unused cam_stream_buf_type bufType)
|
||||||
:QCameraMemory(cached, pool, streamType),
|
:QCameraMemory(cached, pool, streamType),
|
||||||
mGetMemory(memory)
|
mGetMemory(memory),
|
||||||
|
mCallbackCookie(cbCookie)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MM_CAMERA_MAX_NUM_FRAMES; i ++)
|
for (int i = 0; i < MM_CAMERA_MAX_NUM_FRAMES; i ++)
|
||||||
mCameraMemory[i] = NULL;
|
mCameraMemory[i] = NULL;
|
||||||
|
@ -1100,7 +1102,7 @@ int QCameraStreamMemory::allocate(uint8_t count, size_t size, uint32_t isSecure)
|
||||||
if (isSecure == SECURE) {
|
if (isSecure == SECURE) {
|
||||||
mCameraMemory[i] = 0;
|
mCameraMemory[i] = 0;
|
||||||
} else {
|
} 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;
|
mBufferCount = count;
|
||||||
|
@ -1132,7 +1134,7 @@ int QCameraStreamMemory::allocateMore(uint8_t count, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = mBufferCount; i < mBufferCount + count; i++) {
|
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);
|
mBufferCount = (uint8_t)(mBufferCount + count);
|
||||||
ATRACE_END();
|
ATRACE_END();
|
||||||
|
@ -1280,9 +1282,9 @@ void *QCameraStreamMemory::getPtr(uint32_t index) const
|
||||||
*
|
*
|
||||||
* RETURN : none
|
* RETURN : none
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
QCameraVideoMemory::QCameraVideoMemory(camera_request_memory memory,
|
QCameraVideoMemory::QCameraVideoMemory(camera_request_memory memory, void* cbCookie,
|
||||||
bool cached, QCameraMemType bufType)
|
bool cached, QCameraMemType bufType)
|
||||||
: QCameraStreamMemory(memory, cached)
|
: QCameraStreamMemory(memory, cbCookie, cached)
|
||||||
{
|
{
|
||||||
memset(mMetadata, 0, sizeof(mMetadata));
|
memset(mMetadata, 0, sizeof(mMetadata));
|
||||||
memset(mNativeHandle, 0, sizeof(mNativeHandle));
|
memset(mNativeHandle, 0, sizeof(mNativeHandle));
|
||||||
|
@ -1385,7 +1387,7 @@ int QCameraVideoMemory::allocateMore(uint8_t count, size_t size)
|
||||||
if (!(mBufType & QCAMERA_MEM_TYPE_BATCH)) {
|
if (!(mBufType & QCAMERA_MEM_TYPE_BATCH)) {
|
||||||
for (int i = mBufferCount; i < count + mBufferCount; i ++) {
|
for (int i = mBufferCount; i < count + mBufferCount; i ++) {
|
||||||
mMetadata[i] = mGetMemory(-1,
|
mMetadata[i] = mGetMemory(-1,
|
||||||
sizeof(media_metadata_buffer), 1, this);
|
sizeof(media_metadata_buffer), 1, mCallbackCookie);
|
||||||
if (!mMetadata[i]) {
|
if (!mMetadata[i]) {
|
||||||
LOGE("allocation of video metadata failed.");
|
LOGE("allocation of video metadata failed.");
|
||||||
for (int j = mBufferCount; j <= i-1; j ++) {
|
for (int j = mBufferCount; j <= i-1; j ++) {
|
||||||
|
@ -1450,7 +1452,7 @@ int QCameraVideoMemory::allocateMeta(uint8_t buf_cnt, int numFDs, int numInts)
|
||||||
|
|
||||||
for (int i = 0; i < buf_cnt; i++) {
|
for (int i = 0; i < buf_cnt; i++) {
|
||||||
mMetadata[i] = mGetMemory(-1,
|
mMetadata[i] = mGetMemory(-1,
|
||||||
sizeof(media_metadata_buffer), 1, this);
|
sizeof(media_metadata_buffer), 1, mCallbackCookie);
|
||||||
if (!mMetadata[i]) {
|
if (!mMetadata[i]) {
|
||||||
LOGE("allocation of video metadata failed.");
|
LOGE("allocation of video metadata failed.");
|
||||||
for (int j = (i - 1); j >= 0; j--) {
|
for (int j = (i - 1); j >= 0; j--) {
|
||||||
|
@ -1790,7 +1792,7 @@ int QCameraVideoMemory::convCamtoOMXFormat(cam_format_t format)
|
||||||
*
|
*
|
||||||
* RETURN : none
|
* RETURN : none
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
QCameraGrallocMemory::QCameraGrallocMemory(camera_request_memory memory)
|
QCameraGrallocMemory::QCameraGrallocMemory(camera_request_memory memory, void* cbCookie)
|
||||||
: QCameraMemory(true), mColorSpace(ITU_R_601_FR)
|
: QCameraMemory(true), mColorSpace(ITU_R_601_FR)
|
||||||
{
|
{
|
||||||
mMinUndequeuedBuffers = 0;
|
mMinUndequeuedBuffers = 0;
|
||||||
|
@ -1798,6 +1800,7 @@ QCameraGrallocMemory::QCameraGrallocMemory(camera_request_memory memory)
|
||||||
mWindow = NULL;
|
mWindow = NULL;
|
||||||
mWidth = mHeight = mStride = mScanline = mUsage = 0;
|
mWidth = mHeight = mStride = mScanline = mUsage = 0;
|
||||||
mFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP;
|
mFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP;
|
||||||
|
mCallbackCookie = cbCookie;
|
||||||
mGetMemory = memory;
|
mGetMemory = memory;
|
||||||
for (int i = 0; i < MM_CAMERA_MAX_NUM_FRAMES; i ++) {
|
for (int i = 0; i < MM_CAMERA_MAX_NUM_FRAMES; i ++) {
|
||||||
mBufferHandle[i] = NULL;
|
mBufferHandle[i] = NULL;
|
||||||
|
@ -1948,7 +1951,7 @@ int QCameraGrallocMemory::displayBuffer(uint32_t index)
|
||||||
mGetMemory(mPrivateHandle[dequeuedIdx]->fd,
|
mGetMemory(mPrivateHandle[dequeuedIdx]->fd,
|
||||||
(size_t)mPrivateHandle[dequeuedIdx]->size,
|
(size_t)mPrivateHandle[dequeuedIdx]->size,
|
||||||
1,
|
1,
|
||||||
(void *)this);
|
mCallbackCookie);
|
||||||
LOGH("idx = %d, fd = %d, size = %d, offset = %d",
|
LOGH("idx = %d, fd = %d, size = %d, offset = %d",
|
||||||
dequeuedIdx, mPrivateHandle[dequeuedIdx]->fd,
|
dequeuedIdx, mPrivateHandle[dequeuedIdx]->fd,
|
||||||
mPrivateHandle[dequeuedIdx]->size,
|
mPrivateHandle[dequeuedIdx]->size,
|
||||||
|
@ -2069,7 +2072,7 @@ int32_t QCameraGrallocMemory::dequeueBuffer()
|
||||||
mGetMemory(mPrivateHandle[dequeuedIdx]->fd,
|
mGetMemory(mPrivateHandle[dequeuedIdx]->fd,
|
||||||
(size_t)mPrivateHandle[dequeuedIdx]->size,
|
(size_t)mPrivateHandle[dequeuedIdx]->size,
|
||||||
1,
|
1,
|
||||||
(void *)this);
|
mCallbackCookie);
|
||||||
LOGH("idx = %d, fd = %d, size = %d, offset = %d",
|
LOGH("idx = %d, fd = %d, size = %d, offset = %d",
|
||||||
dequeuedIdx, mPrivateHandle[dequeuedIdx]->fd,
|
dequeuedIdx, mPrivateHandle[dequeuedIdx]->fd,
|
||||||
mPrivateHandle[dequeuedIdx]->size,
|
mPrivateHandle[dequeuedIdx]->size,
|
||||||
|
@ -2268,7 +2271,7 @@ int QCameraGrallocMemory::allocate(uint8_t count, size_t /*size*/,
|
||||||
mGetMemory(mPrivateHandle[cnt]->fd,
|
mGetMemory(mPrivateHandle[cnt]->fd,
|
||||||
(size_t)mPrivateHandle[cnt]->size,
|
(size_t)mPrivateHandle[cnt]->size,
|
||||||
1,
|
1,
|
||||||
(void *)this);
|
mCallbackCookie);
|
||||||
LOGH("idx = %d, fd = %d, size = %d, offset = %d",
|
LOGH("idx = %d, fd = %d, size = %d, offset = %d",
|
||||||
cnt, mPrivateHandle[cnt]->fd,
|
cnt, mPrivateHandle[cnt]->fd,
|
||||||
mPrivateHandle[cnt]->size,
|
mPrivateHandle[cnt]->size,
|
||||||
|
|
|
@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
|
@ -194,6 +194,7 @@ public:
|
||||||
class QCameraStreamMemory : public QCameraMemory {
|
class QCameraStreamMemory : public QCameraMemory {
|
||||||
public:
|
public:
|
||||||
QCameraStreamMemory(camera_request_memory getMemory,
|
QCameraStreamMemory(camera_request_memory getMemory,
|
||||||
|
void* cbCookie,
|
||||||
bool cached,
|
bool cached,
|
||||||
QCameraMemoryPool *pool = NULL,
|
QCameraMemoryPool *pool = NULL,
|
||||||
cam_stream_type_t streamType = CAM_STREAM_TYPE_DEFAULT,
|
cam_stream_type_t streamType = CAM_STREAM_TYPE_DEFAULT,
|
||||||
|
@ -212,13 +213,14 @@ public:
|
||||||
protected:
|
protected:
|
||||||
camera_request_memory mGetMemory;
|
camera_request_memory mGetMemory;
|
||||||
camera_memory_t *mCameraMemory[MM_CAMERA_MAX_NUM_FRAMES];
|
camera_memory_t *mCameraMemory[MM_CAMERA_MAX_NUM_FRAMES];
|
||||||
|
void* mCallbackCookie;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Externel heap memory is used for memories shared with
|
// Externel heap memory is used for memories shared with
|
||||||
// framework. They are allocated from /dev/ion or gralloc.
|
// framework. They are allocated from /dev/ion or gralloc.
|
||||||
class QCameraVideoMemory : public QCameraStreamMemory {
|
class QCameraVideoMemory : public QCameraStreamMemory {
|
||||||
public:
|
public:
|
||||||
QCameraVideoMemory(camera_request_memory getMemory, bool cached,
|
QCameraVideoMemory(camera_request_memory getMemory, void* cbCookie, bool cached,
|
||||||
QCameraMemType bufType = QCAMERA_MEM_TYPE_DEFAULT);
|
QCameraMemType bufType = QCAMERA_MEM_TYPE_DEFAULT);
|
||||||
virtual ~QCameraVideoMemory();
|
virtual ~QCameraVideoMemory();
|
||||||
|
|
||||||
|
@ -251,7 +253,7 @@ class QCameraGrallocMemory : public QCameraMemory {
|
||||||
BUFFER_OWNED,
|
BUFFER_OWNED,
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
QCameraGrallocMemory(camera_request_memory getMemory);
|
QCameraGrallocMemory(camera_request_memory getMemory, void* cbCookie);
|
||||||
void setNativeWindow(preview_stream_ops_t *anw);
|
void setNativeWindow(preview_stream_ops_t *anw);
|
||||||
virtual ~QCameraGrallocMemory();
|
virtual ~QCameraGrallocMemory();
|
||||||
|
|
||||||
|
@ -285,6 +287,7 @@ private:
|
||||||
int mWidth, mHeight, mFormat, mStride, mScanline, mUsage;
|
int mWidth, mHeight, mFormat, mStride, mScanline, mUsage;
|
||||||
typeof (MetaData_t::refreshrate) mMaxFPS;
|
typeof (MetaData_t::refreshrate) mMaxFPS;
|
||||||
camera_request_memory mGetMemory;
|
camera_request_memory mGetMemory;
|
||||||
|
void* mCallbackCookie;
|
||||||
camera_memory_t *mCameraMemory[MM_CAMERA_MAX_NUM_FRAMES];
|
camera_memory_t *mCameraMemory[MM_CAMERA_MAX_NUM_FRAMES];
|
||||||
int mMinUndequeuedBuffers;
|
int mMinUndequeuedBuffers;
|
||||||
enum ColorSpace_t mColorSpace;
|
enum ColorSpace_t mColorSpace;
|
||||||
|
|
Loading…
Reference in a new issue