display: Adds additional APIs for gralloc4 support

Adds gralloc4 support for QtiMapperExtensions APIs

Change-Id: I2728f7dd7286702ae19f6fa1c0548027a2e12437
This commit is contained in:
Zube Molokwu
2020-11-06 15:41:40 -08:00
parent d831a3d42e
commit 10c74ab436
3 changed files with 81 additions and 0 deletions

View File

@@ -181,6 +181,24 @@ Error encodeVideoTimestampInfo(VideoTimestampInfo &in, hidl_vec<uint8_t> *out) {
return Error::NONE;
}
Error decodeYUVPlaneInfoMetadata(hidl_vec<uint8_t> &in, qti_ycbcr *out) {
if (!in.size() || !out) {
return Error::BAD_VALUE;
}
qti_ycbcr *p = reinterpret_cast<qti_ycbcr *>(in.data());
memcpy(out, in.data(), (YCBCR_LAYOUT_ARRAY_SIZE * sizeof(qti_ycbcr)));
return Error::NONE;
}
Error encodeYUVPlaneInfoMetadata(qti_ycbcr *in, hidl_vec<uint8_t> *out) {
if (!out) {
return Error::BAD_VALUE;
}
out->resize(YCBCR_LAYOUT_ARRAY_SIZE * sizeof(qti_ycbcr));
memcpy(out->data(), in, YCBCR_LAYOUT_ARRAY_SIZE * sizeof(qti_ycbcr));
return Error::NONE;
}
MetadataType getMetadataType(uint32_t in) {
switch (in) {
case QTI_VT_TIMESTAMP:
@@ -223,6 +241,16 @@ MetadataType getMetadataType(uint32_t in) {
return MetadataType_VendorMetadataStatus;
case QTI_BUFFER_TYPE:
return MetadataType_BufferType;
case QTI_CUSTOM_DIMENSIONS_STRIDE:
return MetadataType_CustomDimensionsStride;
case QTI_CUSTOM_DIMENSIONS_HEIGHT:
return MetadataType_CustomDimensionsHeight;
case QTI_RGB_DATA_ADDRESS:
return MetadataType_RgbDataAddress;
case QTI_COLORSPACE:
return MetadataType_ColorSpace;
case QTI_YUV_PLANE_INFO:
return MetadataType_YuvPlaneInfo;
default:
return MetadataType_Invalid;
}
@@ -319,6 +347,25 @@ Error get(void *buffer, uint32_t type, void *param) {
err = static_cast<Error>(android::gralloc4::decodeUint32(
qtigralloc::MetadataType_BufferType, bytestream, (uint32_t *)param));
break;
case QTI_CUSTOM_DIMENSIONS_STRIDE:
err = static_cast<Error>(android::gralloc4::decodeUint32(
qtigralloc::MetadataType_CustomDimensionsStride, bytestream, (uint32_t *)param));
break;
case QTI_CUSTOM_DIMENSIONS_HEIGHT:
err = static_cast<Error>(android::gralloc4::decodeUint32(
qtigralloc::MetadataType_CustomDimensionsHeight, bytestream, (uint32_t *)param));
break;
case QTI_RGB_DATA_ADDRESS:
err = static_cast<Error>(android::gralloc4::decodeUint64(
qtigralloc::MetadataType_RgbDataAddress, bytestream, (uint64_t *)param));
break;
case QTI_COLORSPACE:
err = static_cast<Error>(android::gralloc4::decodeUint32(qtigralloc::MetadataType_ColorSpace,
bytestream, (uint32_t *)param));
break;
case QTI_YUV_PLANE_INFO:
err = decodeYUVPlaneInfoMetadata(bytestream, (qti_ycbcr *)param);
break;
default:
param = nullptr;
return Error::UNSUPPORTED;

View File

@@ -115,6 +115,16 @@ static const MetadataType MetadataType_VendorMetadataStatus = {VENDOR_QTI,
static const MetadataType MetadataType_BufferType = {VENDOR_QTI,
QTI_BUFFER_TYPE};
static const MetadataType MetadataType_CustomDimensionsStride = {VENDOR_QTI,
QTI_CUSTOM_DIMENSIONS_STRIDE};
static const MetadataType MetadataType_CustomDimensionsHeight = {VENDOR_QTI,
QTI_CUSTOM_DIMENSIONS_HEIGHT};
static const MetadataType MetadataType_RgbDataAddress = {VENDOR_QTI, QTI_RGB_DATA_ADDRESS};
static const MetadataType MetadataType_ColorSpace = {VENDOR_QTI, QTI_COLORSPACE};
static const MetadataType MetadataType_YuvPlaneInfo = {VENDOR_QTI, QTI_YUV_PLANE_INFO};
// 0 is also used as invalid value in standard metadata
static const MetadataType MetadataType_Invalid = {VENDOR_QTI, 0};
@@ -144,6 +154,8 @@ Error decodeVideoHistogramMetadata(hidl_vec<uint8_t> &in, VideoHistogramMetadata
Error encodeVideoHistogramMetadata(VideoHistogramMetadata &in, hidl_vec<uint8_t> *out);
Error decodeVideoTimestampInfo(hidl_vec<uint8_t> &in, VideoTimestampInfo *out);
Error encodeVideoTimestampInfo(VideoTimestampInfo &in, hidl_vec<uint8_t> *out);
Error decodeYUVPlaneInfoMetadata(hidl_vec<uint8_t> &in, qti_ycbcr *out);
Error encodeYUVPlaneInfoMetadata(qti_ycbcr *in, hidl_vec<uint8_t> *out);
} // namespace qtigralloc
#endif //__QTIGRALLOC_H__

View File

@@ -59,6 +59,11 @@
#define QTI_VIDEO_TS_INFO 10019
// This is legacy format
#define QTI_S3D_FORMAT 10020
#define QTI_CUSTOM_DIMENSIONS_STRIDE 10021
#define QTI_CUSTOM_DIMENSIONS_HEIGHT 10022
#define QTI_RGB_DATA_ADDRESS 10023
#define QTI_COLORSPACE 10024
#define QTI_YUV_PLANE_INFO 10025
// Used to indicate to framework that internal definitions are used instead
#define COMPRESSION_QTI_UBWC 20001
@@ -169,6 +174,23 @@ typedef struct ReservedRegion {
uint8_t data[RESERVED_REGION_SIZE];
} ReservedRegion;
#define YCBCR_LAYOUT_ARRAY_SIZE 2
struct qti_ycbcr {
void *y;
void *cb;
void *cr;
uint32_t yStride;
uint32_t cStride;
uint32_t chromaStep;
};
/* Color Space Macros */
#define HAL_CSC_ITU_R_601 0
#define HAL_CSC_ITU_R_601_FR 1
#define HAL_CSC_ITU_R_709 2
#define HAL_CSC_ITU_R_2020 3
#define HAL_CSC_ITU_R_2020_FR 4
#define METADATA_SET_SIZE 512
#define IS_VENDOR_METADATA_TYPE(x) (x >= QTI_VT_TIMESTAMP)