qdMetadata: Add MetaData operation functions

1. Change frame rate to float since uint32_t can not
   match frame rate to standard.
2. Add function of getMetaData() for components to
   fetch params from MetaData.
2. Add function of CopyMetaData() for components to
   clone MetaData for different buffers.

Change-Id: Iba741215e524254b88f88058052fb6408e1f4a36
CRs-fixed: 1001500
This commit is contained in:
feifanz
2016-03-23 18:48:56 +08:00
committed by Gerrit - the friendly Code Review server
parent 0d362630e0
commit 9cc2303f90
2 changed files with 123 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. * Copyright (c) 2012-2016, 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
@@ -67,7 +67,7 @@ int setMetaData(private_handle_t *handle, DispParamType paramType,
data->bufferDim = *((BufferDim_t *)param); data->bufferDim = *((BufferDim_t *)param);
break; break;
case UPDATE_REFRESH_RATE: case UPDATE_REFRESH_RATE:
data->refreshrate = *((uint32_t *)param); data->refreshrate = *((float *)param);
break; break;
case UPDATE_COLOR_SPACE: case UPDATE_COLOR_SPACE:
data->colorSpace = *((ColorSpace_t *)param); data->colorSpace = *((ColorSpace_t *)param);
@@ -96,3 +96,106 @@ int setMetaData(private_handle_t *handle, DispParamType paramType,
errno); errno);
return 0; return 0;
} }
int getMetaData(private_handle_t *handle, DispFetchParamType paramType,
void *param) {
if (!handle) {
ALOGE("%s: Private handle is null!", __func__);
return -1;
}
if (handle->fd_metadata == -1) {
ALOGE("%s: Bad fd for extra data!", __func__);
return -1;
}
if (!param) {
ALOGE("%s: input param is null!", __func__);
return -1;
}
unsigned long size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
void *base = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED,
handle->fd_metadata, 0);
if (base == reinterpret_cast<void*>(MAP_FAILED)) {
ALOGE("%s: mmap() failed: error is %s!", __func__, strerror(errno));
return -1;
}
MetaData_t *data = reinterpret_cast <MetaData_t *>(base);
data->operation |= paramType;
switch (paramType) {
case GET_PP_PARAM_INTERLACED:
*((int32_t *)param) = data->interlaced;
break;
case GET_BUFFER_GEOMETRY:
*((BufferDim_t *)param) = data->bufferDim;
break;
case GET_REFRESH_RATE:
*((float *)param) = data->refreshrate;
break;
case GET_COLOR_SPACE:
*((ColorSpace_t *)param) = data->colorSpace;
break;
case GET_MAP_SECURE_BUFFER:
*((int32_t *)param) = data->mapSecureBuffer;
break;
case GET_S3D_FORMAT:
*((uint32_t *)param) = data->s3dFormat;
break;
case GET_LINEAR_FORMAT:
*((uint32_t *)param) = data->linearFormat;
break;
case GET_IGC:
*((IGC_t *)param) = data->igc;
break;
case GET_SINGLE_BUFFER_MODE:
*((uint32_t *)param) = data->isSingleBufferMode ;
break;
default:
ALOGE("Unknown paramType %d", paramType);
break;
}
if(munmap(base, size))
ALOGE("%s: failed to unmap ptr %p, err %d", __func__, (void*)base,
errno);
return 0;
}
int copyMetaData(struct private_handle_t *src, struct private_handle_t *dst) {
if (!src || !dst) {
ALOGE("%s: Private handle is null!", __func__);
return -1;
}
if (src->fd_metadata == -1) {
ALOGE("%s: Bad fd for src extra data!", __func__);
return -1;
}
if (dst->fd_metadata == -1) {
ALOGE("%s: Bad fd for dst extra data!", __func__);
return -1;
}
unsigned long size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
void *base_src = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED,
src->fd_metadata, 0);
if (base_src == reinterpret_cast<void*>(MAP_FAILED)) {
ALOGE("%s: src mmap() failed: error is %s!", __func__, strerror(errno));
return -1;
}
void *base_dst = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED,
dst->fd_metadata, 0);
if (base_dst == reinterpret_cast<void*>(MAP_FAILED)) {
ALOGE("%s: dst mmap() failed: error is %s!", __func__, strerror(errno));
return -1;
}
memcpy(base_dst, base_src, size);
if(munmap(base_src, size))
ALOGE("%s: failed to unmap src ptr %p, err %d", __func__, (void*)base_src,
errno);
if(munmap(base_dst, size))
ALOGE("%s: failed to unmap src ptr %p, err %d", __func__, (void*)base_dst,
errno);
return 0;
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. * Copyright (c) 2012-2016, 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
@@ -61,7 +61,7 @@ struct MetaData_t {
int32_t operation; int32_t operation;
int32_t interlaced; int32_t interlaced;
struct BufferDim_t bufferDim; struct BufferDim_t bufferDim;
uint32_t refreshrate; float refreshrate;
enum ColorSpace_t colorSpace; enum ColorSpace_t colorSpace;
enum IGC_t igc; enum IGC_t igc;
/* Gralloc sets PRIV_SECURE_BUFFER flag to inform that the buffers are from /* Gralloc sets PRIV_SECURE_BUFFER flag to inform that the buffers are from
@@ -99,10 +99,26 @@ enum DispParamType {
SET_SINGLE_BUFFER_MODE = 0x4000, SET_SINGLE_BUFFER_MODE = 0x4000,
}; };
enum DispFetchParamType {
GET_PP_PARAM_INTERLACED = 0x0004,
GET_BUFFER_GEOMETRY = 0x0080,
GET_REFRESH_RATE = 0x0100,
GET_COLOR_SPACE = 0x0200,
GET_MAP_SECURE_BUFFER = 0x400,
GET_S3D_FORMAT = 0x800,
GET_LINEAR_FORMAT = 0x1000,
GET_IGC = 0x2000,
GET_SINGLE_BUFFER_MODE = 0x4000,
};
struct private_handle_t; struct private_handle_t;
int setMetaData(struct private_handle_t *handle, enum DispParamType paramType, int setMetaData(struct private_handle_t *handle, enum DispParamType paramType,
void *param); void *param);
int getMetaData(struct private_handle_t *handle, enum DispFetchParamType paramType,
void *param);
int copyMetaData(struct private_handle_t *src, struct private_handle_t *dst);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif