mirror of
https://github.com/followmsi/android_hardware_qcom_media.git
synced 2024-11-01 06:57:57 +00:00
Merge "mm-video-v4l2: Add support for AllocateNativeHandle extension" into video-userspace.lnx.2.1-dev
This commit is contained in:
commit
0127c5ebdb
4 changed files with 101 additions and 39 deletions
|
@ -691,6 +691,8 @@ class omx_video: public qc_omx_component
|
||||||
int pending_input_buffers;
|
int pending_input_buffers;
|
||||||
int pending_output_buffers;
|
int pending_output_buffers;
|
||||||
|
|
||||||
|
bool allocate_native_handle;
|
||||||
|
|
||||||
uint64_t m_out_bm_count;
|
uint64_t m_out_bm_count;
|
||||||
uint64_t m_inp_bm_count;
|
uint64_t m_inp_bm_count;
|
||||||
uint64_t m_flags;
|
uint64_t m_flags;
|
||||||
|
|
|
@ -2467,6 +2467,12 @@ OMX_ERRORTYPE omx_video::get_extension_index(OMX_IN OMX_HANDLETYPE hComp,
|
||||||
*indexType = (OMX_INDEXTYPE)OMX_QTIIndexConfigDescribeColorAspects;
|
*indexType = (OMX_INDEXTYPE)OMX_QTIIndexConfigDescribeColorAspects;
|
||||||
return OMX_ErrorNone;
|
return OMX_ErrorNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extn_equals(paramName, "OMX.google.android.index.allocateNativeHandle")) {
|
||||||
|
*indexType = (OMX_INDEXTYPE)OMX_GoogleAndroidIndexAllocateNativeHandle;
|
||||||
|
return OMX_ErrorNone;
|
||||||
|
}
|
||||||
|
|
||||||
return OMX_ErrorNotImplemented;
|
return OMX_ErrorNotImplemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3043,6 +3049,12 @@ OMX_ERRORTYPE omx_video::free_output_buffer(OMX_BUFFERHEADERTYPE *bufferHdr)
|
||||||
if(!secure_session) {
|
if(!secure_session) {
|
||||||
munmap (m_pOutput_pmem[index].buffer,
|
munmap (m_pOutput_pmem[index].buffer,
|
||||||
m_pOutput_pmem[index].size);
|
m_pOutput_pmem[index].size);
|
||||||
|
} else {
|
||||||
|
if (allocate_native_handle) {
|
||||||
|
native_handle_t *handle = NULL;
|
||||||
|
handle = (native_handle_t *)m_pOutput_pmem[index].buffer;
|
||||||
|
native_handle_close(handle);
|
||||||
|
native_handle_delete(handle);
|
||||||
} else {
|
} else {
|
||||||
char *data = (char*) m_pOutput_pmem[index].buffer;
|
char *data = (char*) m_pOutput_pmem[index].buffer;
|
||||||
native_handle_t *handle = NULL;
|
native_handle_t *handle = NULL;
|
||||||
|
@ -3050,6 +3062,7 @@ OMX_ERRORTYPE omx_video::free_output_buffer(OMX_BUFFERHEADERTYPE *bufferHdr)
|
||||||
native_handle_delete(handle);
|
native_handle_delete(handle);
|
||||||
free(m_pOutput_pmem[index].buffer);
|
free(m_pOutput_pmem[index].buffer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
close (m_pOutput_pmem[index].fd);
|
close (m_pOutput_pmem[index].fd);
|
||||||
#ifdef USE_ION
|
#ifdef USE_ION
|
||||||
free_ion_memory(&m_pOutput_ion[index]);
|
free_ion_memory(&m_pOutput_ion[index]);
|
||||||
|
@ -3439,6 +3452,18 @@ OMX_ERRORTYPE omx_video::allocate_output_buffer(
|
||||||
else {
|
else {
|
||||||
//This should only be used for passing reference to source type and
|
//This should only be used for passing reference to source type and
|
||||||
//secure handle fd struct native_handle_t*
|
//secure handle fd struct native_handle_t*
|
||||||
|
if (allocate_native_handle) {
|
||||||
|
native_handle_t *nh = native_handle_create(1 /*numFds*/, 3 /*numInts*/);
|
||||||
|
if (!nh) {
|
||||||
|
DEBUG_PRINT_ERROR("Native handle create failed");
|
||||||
|
return OMX_ErrorInsufficientResources;
|
||||||
|
}
|
||||||
|
nh->data[0] = m_pOutput_pmem[i].fd;
|
||||||
|
nh->data[1] = 0;
|
||||||
|
nh->data[2] = 0;
|
||||||
|
nh->data[3] = ALIGN(m_sOutPortDef.nBufferSize, 4096);
|
||||||
|
m_pOutput_pmem[i].buffer = (OMX_U8 *)nh;
|
||||||
|
} else {
|
||||||
native_handle_t *handle = native_handle_create(1, 3); //fd, offset, size, alloc length
|
native_handle_t *handle = native_handle_create(1, 3); //fd, offset, size, alloc length
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
DEBUG_PRINT_ERROR("ERROR: native handle creation failed");
|
DEBUG_PRINT_ERROR("ERROR: native handle creation failed");
|
||||||
|
@ -3458,6 +3483,7 @@ OMX_ERRORTYPE omx_video::allocate_output_buffer(
|
||||||
buffer->type = 1;
|
buffer->type = 1;
|
||||||
buffer->nh = handle;
|
buffer->nh = handle;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(*bufferHdr)->pBuffer = (OMX_U8 *)m_pOutput_pmem[i].buffer;
|
(*bufferHdr)->pBuffer = (OMX_U8 *)m_pOutput_pmem[i].buffer;
|
||||||
(*bufferHdr)->pAppPrivate = appData;
|
(*bufferHdr)->pAppPrivate = appData;
|
||||||
|
|
|
@ -1148,6 +1148,31 @@ OMX_ERRORTYPE omx_venc::set_parameter(OMX_IN OMX_HANDLETYPE hComp,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
case OMX_GoogleAndroidIndexAllocateNativeHandle:
|
||||||
|
{
|
||||||
|
VALIDATE_OMX_PARAM_DATA(paramData, AllocateNativeHandleParams);
|
||||||
|
|
||||||
|
AllocateNativeHandleParams* allocateNativeHandleParams = (AllocateNativeHandleParams *) paramData;
|
||||||
|
|
||||||
|
if (!secure_session) {
|
||||||
|
DEBUG_PRINT_ERROR("Enable/Disable allocate-native-handle allowed only in secure session");
|
||||||
|
eRet = OMX_ErrorUnsupportedSetting;
|
||||||
|
break;
|
||||||
|
} else if (allocateNativeHandleParams->nPortIndex != PORT_INDEX_OUT) {
|
||||||
|
DEBUG_PRINT_ERROR("Enable/Disable allocate-native-handle allowed only on Output port!");
|
||||||
|
eRet = OMX_ErrorUnsupportedSetting;
|
||||||
|
break;
|
||||||
|
} else if (m_out_mem_ptr) {
|
||||||
|
DEBUG_PRINT_ERROR("Enable/Disable allocate-native-handle is not allowed since Output port is not free !");
|
||||||
|
eRet = OMX_ErrorInvalidState;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allocateNativeHandleParams != NULL) {
|
||||||
|
allocate_native_handle = allocateNativeHandleParams->enable;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case OMX_IndexParamVideoQuantization:
|
case OMX_IndexParamVideoQuantization:
|
||||||
{
|
{
|
||||||
VALIDATE_OMX_PARAM_DATA(paramData, OMX_VIDEO_PARAM_QUANTIZATIONTYPE);
|
VALIDATE_OMX_PARAM_DATA(paramData, OMX_VIDEO_PARAM_QUANTIZATIONTYPE);
|
||||||
|
@ -1292,14 +1317,9 @@ OMX_ERRORTYPE omx_venc::set_parameter(OMX_IN OMX_HANDLETYPE hComp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pParam->nPortIndex == PORT_INDEX_OUT && secure_session) {
|
} else if (pParam->nPortIndex == PORT_INDEX_OUT && secure_session) {
|
||||||
if (pParam->bStoreMetaData != meta_mode_enable) {
|
DEBUG_PRINT_ERROR("set_parameter: metamode is "
|
||||||
if (!handle->venc_set_meta_mode(pParam->bStoreMetaData)) {
|
"valid for input port only in secure session");
|
||||||
DEBUG_PRINT_ERROR("\nERROR: set Metabuffer mode %d fail",
|
|
||||||
pParam->bStoreMetaData);
|
|
||||||
return OMX_ErrorUnsupportedSetting;
|
return OMX_ErrorUnsupportedSetting;
|
||||||
}
|
|
||||||
meta_mode_enable = pParam->bStoreMetaData;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_PRINT_ERROR("set_parameter: metamode is "
|
DEBUG_PRINT_ERROR("set_parameter: metamode is "
|
||||||
"valid for input port only");
|
"valid for input port only");
|
||||||
|
@ -2622,6 +2642,14 @@ int omx_venc::async_message_process (void *context, void* message)
|
||||||
m_sVenc_msg->buf.len);
|
m_sVenc_msg->buf.len);
|
||||||
}
|
}
|
||||||
} else if (omx->is_secure_session()) {
|
} else if (omx->is_secure_session()) {
|
||||||
|
if (omx->allocate_native_handle) {
|
||||||
|
native_handle_t *nh = (native_handle_t *)(omxhdr->pBuffer);
|
||||||
|
nh->data[1] = m_sVenc_msg->buf.offset;
|
||||||
|
nh->data[2] = m_sVenc_msg->buf.len;
|
||||||
|
omxhdr->nFilledLen = m_sVenc_msg->buf.len;
|
||||||
|
omxhdr->nTimeStamp = m_sVenc_msg->buf.timestamp;
|
||||||
|
omxhdr->nFlags = m_sVenc_msg->buf.flags;
|
||||||
|
} else {
|
||||||
output_metabuffer *meta_buf = (output_metabuffer *)(omxhdr->pBuffer);
|
output_metabuffer *meta_buf = (output_metabuffer *)(omxhdr->pBuffer);
|
||||||
native_handle_t *nh = meta_buf->nh;
|
native_handle_t *nh = meta_buf->nh;
|
||||||
nh->data[1] = m_sVenc_msg->buf.offset;
|
nh->data[1] = m_sVenc_msg->buf.offset;
|
||||||
|
@ -2629,6 +2657,7 @@ int omx_venc::async_message_process (void *context, void* message)
|
||||||
omxhdr->nFilledLen = sizeof(output_metabuffer);
|
omxhdr->nFilledLen = sizeof(output_metabuffer);
|
||||||
omxhdr->nTimeStamp = m_sVenc_msg->buf.timestamp;
|
omxhdr->nTimeStamp = m_sVenc_msg->buf.timestamp;
|
||||||
omxhdr->nFlags = m_sVenc_msg->buf.flags;
|
omxhdr->nFlags = m_sVenc_msg->buf.flags;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
omxhdr->nFilledLen = 0;
|
omxhdr->nFilledLen = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4251,10 +4251,15 @@ bool venc_dev::venc_fill_buf(void *buffer, void *pmem_data_buf,unsigned index,un
|
||||||
buf.flags = 0;
|
buf.flags = 0;
|
||||||
|
|
||||||
if (venc_handle->is_secure_session()) {
|
if (venc_handle->is_secure_session()) {
|
||||||
|
if (venc_handle->allocate_native_handle) {
|
||||||
|
native_handle_t *handle_t = (native_handle_t *)(bufhdr->pBuffer);
|
||||||
|
plane[0].length = handle_t->data[3];
|
||||||
|
} else {
|
||||||
output_metabuffer *meta_buf = (output_metabuffer *)(bufhdr->pBuffer);
|
output_metabuffer *meta_buf = (output_metabuffer *)(bufhdr->pBuffer);
|
||||||
native_handle_t *handle_t = meta_buf->nh;
|
native_handle_t *handle_t = meta_buf->nh;
|
||||||
plane[0].length = handle_t->data[3];
|
plane[0].length = handle_t->data[3];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mBatchSize) {
|
if (mBatchSize) {
|
||||||
// Should always mark first buffer as DEFER, since 0 % anything is 0, just offset by 1
|
// Should always mark first buffer as DEFER, since 0 % anything is 0, just offset by 1
|
||||||
|
|
Loading…
Reference in a new issue