display: Update metadata
This change adds libgralloc.qti to support Gralloc4 and the transition to standardized metadata. CRs-Fixed: 2619182 Change-Id: Ia43de9b1dc9da52affc508783c046b82cde1775e
This commit is contained in:
@@ -18,5 +18,6 @@ PRODUCT_PACKAGES += vendor.qti.hardware.display.allocator@1.0.vendor \
|
|||||||
vendor.qti.hardware.display.mapper@1.1.vendor \
|
vendor.qti.hardware.display.mapper@1.1.vendor \
|
||||||
vendor.qti.hardware.display.mapper@2.0.vendor \
|
vendor.qti.hardware.display.mapper@2.0.vendor \
|
||||||
vendor.qti.hardware.display.mapper@3.0.vendor \
|
vendor.qti.hardware.display.mapper@3.0.vendor \
|
||||||
|
vendor.qti.hardware.display.mapper@4.0.vendor \
|
||||||
vendor.qti.hardware.display.mapperextensions@1.0.vendor \
|
vendor.qti.hardware.display.mapperextensions@1.0.vendor \
|
||||||
vendor.qti.hardware.display.mapperextensions@1.1.vendor
|
vendor.qti.hardware.display.mapperextensions@1.1.vendor
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
PRODUCT_PACKAGES += libdisplayconfig \
|
PRODUCT_PACKAGES += libdisplayconfig \
|
||||||
libqdMetaData \
|
libqdMetaData \
|
||||||
libqdMetaData.system \
|
libqdMetaData.system \
|
||||||
|
libgralloc.qti \
|
||||||
libdrm \
|
libdrm \
|
||||||
vendor.display.config@1.0 \
|
vendor.display.config@1.0 \
|
||||||
vendor.display.config@1.1 \
|
vendor.display.config@1.1 \
|
||||||
|
|||||||
23
gralloc/Android.bp
Normal file
23
gralloc/Android.bp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
cc_library_shared {
|
||||||
|
name: "libgralloc.qti",
|
||||||
|
vendor_available: true,
|
||||||
|
product_specific: true,
|
||||||
|
cflags: [
|
||||||
|
"-Wno-sign-conversion",
|
||||||
|
"-DLOG_TAG=\"qtigralloc\"",
|
||||||
|
],
|
||||||
|
shared_libs: [
|
||||||
|
"liblog",
|
||||||
|
"libcutils",
|
||||||
|
"libutils",
|
||||||
|
"libgralloctypes",
|
||||||
|
"libhidlbase",
|
||||||
|
"libhardware",
|
||||||
|
"android.hardware.graphics.mapper@4.0"
|
||||||
|
],
|
||||||
|
|
||||||
|
srcs: ["QtiGralloc.cpp"],
|
||||||
|
|
||||||
|
header_libs: ["display_intf_headers"],
|
||||||
|
}
|
||||||
|
|
||||||
306
gralloc/QtiGralloc.cpp
Normal file
306
gralloc/QtiGralloc.cpp
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, 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
|
||||||
|
* met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above
|
||||||
|
* copyright notice, this list of conditions and the following
|
||||||
|
* disclaimer in the documentation and/or other materials provided
|
||||||
|
* with the distribution.
|
||||||
|
* * Neither the name of The Linux Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "QtiGralloc.h"
|
||||||
|
|
||||||
|
#include <log/log.h>
|
||||||
|
namespace qtigralloc {
|
||||||
|
|
||||||
|
using android::hardware::graphics::mapper::V4_0::IMapper;
|
||||||
|
static sp<IMapper> getInstance() {
|
||||||
|
static sp<IMapper> mapper = IMapper::getService();
|
||||||
|
return mapper;
|
||||||
|
}
|
||||||
|
Error decodeColorMetadata(hidl_vec<uint8_t> &in, ColorMetaData *out) {
|
||||||
|
if (!in.size() || !out) {
|
||||||
|
return Error::BAD_VALUE;
|
||||||
|
}
|
||||||
|
memcpy(out, in.data(), sizeof(ColorMetaData));
|
||||||
|
return Error::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error encodeColorMetadata(ColorMetaData &in, hidl_vec<uint8_t> *out) {
|
||||||
|
if (!out) {
|
||||||
|
return Error::BAD_VALUE;
|
||||||
|
}
|
||||||
|
out->resize(sizeof(ColorMetaData));
|
||||||
|
memcpy(out->data(), &in, sizeof(ColorMetaData));
|
||||||
|
return Error::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error decodeGraphicsMetadata(hidl_vec<uint8_t> &in, GraphicsMetadata *out) {
|
||||||
|
if (!in.size() || !out) {
|
||||||
|
return Error::BAD_VALUE;
|
||||||
|
}
|
||||||
|
memcpy(out, in.data(), sizeof(GraphicsMetadata));
|
||||||
|
return Error::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error encodeGraphicsMetadata(GraphicsMetadata &in, hidl_vec<uint8_t> *out) {
|
||||||
|
if (!out) {
|
||||||
|
return Error::BAD_VALUE;
|
||||||
|
}
|
||||||
|
out->resize(sizeof(GraphicsMetadata));
|
||||||
|
memcpy(out->data(), &in, sizeof(GraphicsMetadata));
|
||||||
|
return Error::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error decodeUBWCStats(hidl_vec<uint8_t> &in, UBWCStats *out) {
|
||||||
|
if (!in.size() || !out) {
|
||||||
|
return Error::BAD_VALUE;
|
||||||
|
}
|
||||||
|
memcpy(out, in.data(), UBWC_STATS_ARRAY_SIZE * sizeof(UBWCStats));
|
||||||
|
return Error::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error encodeUBWCStats(UBWCStats *in, hidl_vec<uint8_t> *out) {
|
||||||
|
if (!in || !out) {
|
||||||
|
return Error::BAD_VALUE;
|
||||||
|
}
|
||||||
|
out->resize(UBWC_STATS_ARRAY_SIZE * sizeof(UBWCStats));
|
||||||
|
memcpy(out->data(), &in[0], UBWC_STATS_ARRAY_SIZE * sizeof(UBWCStats));
|
||||||
|
return Error::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error decodeCVPMetadata(hidl_vec<uint8_t> &in, CVPMetadata *out) {
|
||||||
|
if (!in.size() || !out) {
|
||||||
|
return Error::BAD_VALUE;
|
||||||
|
}
|
||||||
|
memcpy(out, in.data(), sizeof(CVPMetadata));
|
||||||
|
return Error::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error encodeCVPMetadata(CVPMetadata &in, hidl_vec<uint8_t> *out) {
|
||||||
|
if (!out) {
|
||||||
|
return Error::BAD_VALUE;
|
||||||
|
}
|
||||||
|
out->resize(sizeof(CVPMetadata));
|
||||||
|
memcpy(out->data(), &in, sizeof(CVPMetadata));
|
||||||
|
return Error::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error decodeVideoHistogramMetadata(hidl_vec<uint8_t> &in, VideoHistogramMetadata *out) {
|
||||||
|
if (!in.size() || !out) {
|
||||||
|
return Error::BAD_VALUE;
|
||||||
|
}
|
||||||
|
memcpy(out, in.data(), sizeof(VideoHistogramMetadata));
|
||||||
|
return Error::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error encodeVideoHistogramMetadata(VideoHistogramMetadata &in, hidl_vec<uint8_t> *out) {
|
||||||
|
if (!out) {
|
||||||
|
return Error::BAD_VALUE;
|
||||||
|
}
|
||||||
|
out->resize(sizeof(VideoHistogramMetadata));
|
||||||
|
memcpy(out->data(), &in, sizeof(VideoHistogramMetadata));
|
||||||
|
return Error::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MetadataType getMetadataType(uint32_t in) {
|
||||||
|
switch (in) {
|
||||||
|
case QTI_VT_TIMESTAMP:
|
||||||
|
return MetadataType_VTTimestamp;
|
||||||
|
case QTI_VIDEO_PERF_MODE:
|
||||||
|
return MetadataType_VideoPerfMode;
|
||||||
|
case QTI_LINEAR_FORMAT:
|
||||||
|
return MetadataType_LinearFormat;
|
||||||
|
case QTI_SINGLE_BUFFER_MODE:
|
||||||
|
return MetadataType_SingleBufferMode;
|
||||||
|
case QTI_PP_PARAM_INTERLACED:
|
||||||
|
return MetadataType_PPParamInterlaced;
|
||||||
|
case QTI_MAP_SECURE_BUFFER:
|
||||||
|
return MetadataType_MapSecureBuffer;
|
||||||
|
case QTI_COLOR_METADATA:
|
||||||
|
return MetadataType_ColorMetadata;
|
||||||
|
case QTI_GRAPHICS_METADATA:
|
||||||
|
return MetadataType_GraphicsMetadata;
|
||||||
|
case QTI_UBWC_CR_STATS_INFO:
|
||||||
|
return MetadataType_UBWCCRStatsInfo;
|
||||||
|
case QTI_REFRESH_RATE:
|
||||||
|
return MetadataType_RefreshRate;
|
||||||
|
case QTI_CVP_METADATA:
|
||||||
|
return MetadataType_CVPMetadata;
|
||||||
|
case QTI_VIDEO_HISTOGRAM_STATS:
|
||||||
|
return MetadataType_VideoHistogramStats;
|
||||||
|
case QTI_FD:
|
||||||
|
return MetadataType_FD;
|
||||||
|
case QTI_PRIVATE_FLAGS:
|
||||||
|
return MetadataType_PrivateFlags;
|
||||||
|
default:
|
||||||
|
return MetadataType_Invalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Error get(void *buffer, uint32_t type, void *param) {
|
||||||
|
hidl_vec<uint8_t> bytestream;
|
||||||
|
sp<IMapper> mapper = getInstance();
|
||||||
|
|
||||||
|
MetadataType metadata_type = getMetadataType(type);
|
||||||
|
if (metadata_type == MetadataType_Invalid) {
|
||||||
|
param = nullptr;
|
||||||
|
return Error::UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto err = Error::UNSUPPORTED;
|
||||||
|
mapper->get(buffer, metadata_type, [&](const auto &tmpError, const auto &tmpByteStream) {
|
||||||
|
err = tmpError;
|
||||||
|
bytestream = tmpByteStream;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (err != Error::NONE) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case QTI_VT_TIMESTAMP:
|
||||||
|
err = static_cast<Error>(android::gralloc4::decodeUint64(qtigralloc::MetadataType_VTTimestamp,
|
||||||
|
bytestream, (uint64_t *)param));
|
||||||
|
break;
|
||||||
|
case QTI_VIDEO_PERF_MODE:
|
||||||
|
err = static_cast<Error>(android::gralloc4::decodeUint32(
|
||||||
|
qtigralloc::MetadataType_VideoPerfMode, bytestream, (uint32_t *)param));
|
||||||
|
break;
|
||||||
|
case QTI_LINEAR_FORMAT:
|
||||||
|
err = static_cast<Error>(android::gralloc4::decodeUint32(
|
||||||
|
qtigralloc::MetadataType_LinearFormat, bytestream, (uint32_t *)param));
|
||||||
|
break;
|
||||||
|
case QTI_SINGLE_BUFFER_MODE:
|
||||||
|
err = static_cast<Error>(android::gralloc4::decodeUint32(
|
||||||
|
qtigralloc::MetadataType_SingleBufferMode, bytestream, (uint32_t *)param));
|
||||||
|
break;
|
||||||
|
case QTI_PP_PARAM_INTERLACED:
|
||||||
|
err = static_cast<Error>(android::gralloc4::decodeInt32(
|
||||||
|
qtigralloc::MetadataType_PPParamInterlaced, bytestream, (int32_t *)param));
|
||||||
|
break;
|
||||||
|
case QTI_MAP_SECURE_BUFFER:
|
||||||
|
err = static_cast<Error>(android::gralloc4::decodeInt32(
|
||||||
|
qtigralloc::MetadataType_MapSecureBuffer, bytestream, (int32_t *)param));
|
||||||
|
break;
|
||||||
|
case QTI_COLOR_METADATA:
|
||||||
|
err = decodeColorMetadata(bytestream, (ColorMetaData *)param);
|
||||||
|
break;
|
||||||
|
case QTI_GRAPHICS_METADATA:
|
||||||
|
err = decodeGraphicsMetadata(bytestream, (GraphicsMetadata *)param);
|
||||||
|
break;
|
||||||
|
case QTI_UBWC_CR_STATS_INFO:
|
||||||
|
err = decodeUBWCStats(bytestream, (UBWCStats *)param);
|
||||||
|
break;
|
||||||
|
case QTI_REFRESH_RATE:
|
||||||
|
err = static_cast<Error>(android::gralloc4::decodeFloat(qtigralloc::MetadataType_RefreshRate,
|
||||||
|
bytestream, (float *)param));
|
||||||
|
break;
|
||||||
|
case QTI_CVP_METADATA:
|
||||||
|
err = decodeCVPMetadata(bytestream, (CVPMetadata *)param);
|
||||||
|
break;
|
||||||
|
case QTI_VIDEO_HISTOGRAM_STATS:
|
||||||
|
err = decodeVideoHistogramMetadata(bytestream, (VideoHistogramMetadata *)param);
|
||||||
|
break;
|
||||||
|
case QTI_FD:
|
||||||
|
err = static_cast<Error>(android::gralloc4::decodeInt32(qtigralloc::MetadataType_FD,
|
||||||
|
bytestream, (int32_t *)param));
|
||||||
|
break;
|
||||||
|
case QTI_PRIVATE_FLAGS:
|
||||||
|
err = static_cast<Error>(android::gralloc4::decodeInt32(qtigralloc::MetadataType_PrivateFlags,
|
||||||
|
bytestream, (int32_t *)param));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
param = nullptr;
|
||||||
|
return Error::UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error set(void *buffer, uint32_t type, void *param) {
|
||||||
|
hidl_vec<uint8_t> bytestream;
|
||||||
|
sp<IMapper> mapper = getInstance();
|
||||||
|
|
||||||
|
Error err = Error::UNSUPPORTED;
|
||||||
|
MetadataType metadata_type = getMetadataType(type);
|
||||||
|
if (metadata_type == MetadataType_Invalid) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case QTI_VT_TIMESTAMP:
|
||||||
|
err = static_cast<Error>(android::gralloc4::encodeUint64(qtigralloc::MetadataType_VTTimestamp,
|
||||||
|
*(uint64_t *)param, &bytestream));
|
||||||
|
break;
|
||||||
|
case QTI_VIDEO_PERF_MODE:
|
||||||
|
err = static_cast<Error>(android::gralloc4::encodeUint32(
|
||||||
|
qtigralloc::MetadataType_VideoPerfMode, *(uint32_t *)param, &bytestream));
|
||||||
|
break;
|
||||||
|
case QTI_LINEAR_FORMAT:
|
||||||
|
err = static_cast<Error>(android::gralloc4::encodeUint32(
|
||||||
|
qtigralloc::MetadataType_LinearFormat, *(uint32_t *)param, &bytestream));
|
||||||
|
break;
|
||||||
|
case QTI_SINGLE_BUFFER_MODE:
|
||||||
|
err = static_cast<Error>(android::gralloc4::encodeUint32(
|
||||||
|
qtigralloc::MetadataType_SingleBufferMode, *(uint32_t *)param, &bytestream));
|
||||||
|
break;
|
||||||
|
case QTI_PP_PARAM_INTERLACED:
|
||||||
|
err = static_cast<Error>(android::gralloc4::encodeInt32(
|
||||||
|
qtigralloc::MetadataType_PPParamInterlaced, *(int32_t *)param, &bytestream));
|
||||||
|
break;
|
||||||
|
case QTI_MAP_SECURE_BUFFER:
|
||||||
|
err = static_cast<Error>(android::gralloc4::encodeInt32(
|
||||||
|
qtigralloc::MetadataType_MapSecureBuffer, *(int32_t *)param, &bytestream));
|
||||||
|
break;
|
||||||
|
case QTI_COLOR_METADATA:
|
||||||
|
err = encodeColorMetadata(*(ColorMetaData *)param, &bytestream);
|
||||||
|
break;
|
||||||
|
case QTI_GRAPHICS_METADATA:
|
||||||
|
err = encodeGraphicsMetadata(*(GraphicsMetadata *)param, &bytestream);
|
||||||
|
break;
|
||||||
|
case QTI_UBWC_CR_STATS_INFO:
|
||||||
|
err = encodeUBWCStats((UBWCStats *)param, &bytestream);
|
||||||
|
break;
|
||||||
|
case QTI_REFRESH_RATE:
|
||||||
|
err = static_cast<Error>(android::gralloc4::encodeFloat(qtigralloc::MetadataType_RefreshRate,
|
||||||
|
*(float *)param, &bytestream));
|
||||||
|
break;
|
||||||
|
case QTI_CVP_METADATA:
|
||||||
|
err = encodeCVPMetadata(*(CVPMetadata *)param, &bytestream);
|
||||||
|
break;
|
||||||
|
case QTI_VIDEO_HISTOGRAM_STATS:
|
||||||
|
err = encodeVideoHistogramMetadata(*(VideoHistogramMetadata *)param, &bytestream);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
param = nullptr;
|
||||||
|
return Error::UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err != Error::NONE) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mapper->set((void *)buffer, metadata_type, bytestream);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace qtigralloc
|
||||||
125
gralloc/QtiGralloc.h
Normal file
125
gralloc/QtiGralloc.h
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020 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
|
||||||
|
* met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above
|
||||||
|
* copyright notice, this list of conditions and the following
|
||||||
|
* disclaimer in the documentation and/or other materials provided
|
||||||
|
* with the distribution.
|
||||||
|
* * Neither the name of The Linux Foundation. nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __QTIGRALLOC_H__
|
||||||
|
#define __QTIGRALLOC_H__
|
||||||
|
|
||||||
|
#include <android/hardware/graphics/mapper/4.0/IMapper.h>
|
||||||
|
#include <gralloctypes/Gralloc4.h>
|
||||||
|
#include <hidl/HidlSupport.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "QtiGrallocDefs.h"
|
||||||
|
#include "QtiGrallocMetadata.h"
|
||||||
|
|
||||||
|
namespace qtigralloc {
|
||||||
|
using android::sp;
|
||||||
|
using android::hardware::hidl_vec;
|
||||||
|
using MetadataType = android::hardware::graphics::mapper::V4_0::IMapper::MetadataType;
|
||||||
|
using android::hardware::graphics::mapper::V4_0::Error;
|
||||||
|
// from gr_priv_handle.h
|
||||||
|
enum {
|
||||||
|
PRIV_FLAGS_USES_ION = 0x00000008,
|
||||||
|
PRIV_FLAGS_NEEDS_FLUSH = 0x00000020,
|
||||||
|
PRIV_FLAGS_NON_CPU_WRITER = 0x00000080,
|
||||||
|
PRIV_FLAGS_CACHED = 0x00000200,
|
||||||
|
PRIV_FLAGS_SECURE_BUFFER = 0x00000400,
|
||||||
|
PRIV_FLAGS_VIDEO_ENCODER = 0x00010000,
|
||||||
|
PRIV_FLAGS_CAMERA_WRITE = 0x00020000,
|
||||||
|
PRIV_FLAGS_CAMERA_READ = 0x00040000,
|
||||||
|
PRIV_FLAGS_HW_TEXTURE = 0x00100000,
|
||||||
|
PRIV_FLAGS_SECURE_DISPLAY = 0x01000000,
|
||||||
|
PRIV_FLAGS_UBWC_ALIGNED = 0x08000000,
|
||||||
|
PRIV_FLAGS_UBWC_ALIGNED_PI = 0x40000000, // PI format
|
||||||
|
};
|
||||||
|
|
||||||
|
// Metadata
|
||||||
|
const std::string VENDOR_QTI = "QTI";
|
||||||
|
|
||||||
|
Error get(void *buffer, uint32_t type, void *param);
|
||||||
|
Error set(void *buffer, uint32_t type, void *param);
|
||||||
|
MetadataType getMetadataType(uint32_t in);
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_VTTimestamp = {VENDOR_QTI, QTI_VT_TIMESTAMP};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_ColorMetadata = {VENDOR_QTI, QTI_COLOR_METADATA};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_PPParamInterlaced = {VENDOR_QTI, QTI_PP_PARAM_INTERLACED};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_VideoPerfMode = {VENDOR_QTI, QTI_VIDEO_PERF_MODE};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_GraphicsMetadata = {VENDOR_QTI, QTI_GRAPHICS_METADATA};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_UBWCCRStatsInfo = {VENDOR_QTI, QTI_UBWC_CR_STATS_INFO};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_RefreshRate = {VENDOR_QTI, QTI_REFRESH_RATE};
|
||||||
|
static const MetadataType MetadataType_MapSecureBuffer = {VENDOR_QTI, QTI_MAP_SECURE_BUFFER};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_LinearFormat = {VENDOR_QTI, QTI_LINEAR_FORMAT};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_SingleBufferMode = {VENDOR_QTI, QTI_SINGLE_BUFFER_MODE};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_CVPMetadata = {VENDOR_QTI, QTI_CVP_METADATA};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_VideoHistogramStats = {VENDOR_QTI,
|
||||||
|
QTI_VIDEO_HISTOGRAM_STATS};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_FD = {VENDOR_QTI, QTI_FD};
|
||||||
|
|
||||||
|
static const MetadataType MetadataType_PrivateFlags = {VENDOR_QTI, QTI_PRIVATE_FLAGS};
|
||||||
|
|
||||||
|
// 0 is also used as invalid value in standard metadata
|
||||||
|
static const MetadataType MetadataType_Invalid = {VENDOR_QTI, 0};
|
||||||
|
|
||||||
|
static const aidl::android::hardware::graphics::common::ExtendableType Compression_QtiUBWC = {
|
||||||
|
VENDOR_QTI, COMPRESSION_QTI_UBWC};
|
||||||
|
static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_Qti = {
|
||||||
|
VENDOR_QTI, INTERLACED_QTI};
|
||||||
|
|
||||||
|
static const aidl::android::hardware::graphics::common::ExtendableType
|
||||||
|
PlaneLayoutComponentType_Raw = {VENDOR_QTI, PLANE_COMPONENT_TYPE_RAW};
|
||||||
|
static const aidl::android::hardware::graphics::common::ExtendableType
|
||||||
|
PlaneLayoutComponentType_Meta = {VENDOR_QTI, PLANE_COMPONENT_TYPE_META};
|
||||||
|
|
||||||
|
Error decodeColorMetadata(hidl_vec<uint8_t> &in, ColorMetaData *out);
|
||||||
|
Error encodeColorMetadata(ColorMetaData &in, hidl_vec<uint8_t> *out);
|
||||||
|
Error decodeGraphicsMetadata(hidl_vec<uint8_t> &in, GraphicsMetadata *out);
|
||||||
|
Error encodeGraphicsMetadata(GraphicsMetadata &in, hidl_vec<uint8_t> *out);
|
||||||
|
Error decodeUBWCStats(hidl_vec<uint8_t> &in, UBWCStats *out);
|
||||||
|
Error encodeUBWCStats(UBWCStats *in, hidl_vec<uint8_t> *out);
|
||||||
|
Error decodeCVPMetadata(hidl_vec<uint8_t> &in, CVPMetadata *out);
|
||||||
|
Error encodeCVPMetadata(CVPMetadata &in, hidl_vec<uint8_t> *out);
|
||||||
|
Error decodeVideoHistogramMetadata(hidl_vec<uint8_t> &in, VideoHistogramMetadata *out);
|
||||||
|
Error encodeVideoHistogramMetadata(VideoHistogramMetadata &in, hidl_vec<uint8_t> *out);
|
||||||
|
|
||||||
|
} // namespace qtigralloc
|
||||||
|
|
||||||
|
#endif //__QTIGRALLOC_H__
|
||||||
166
gralloc/QtiGrallocDefs.h
Normal file
166
gralloc/QtiGrallocDefs.h
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020 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
|
||||||
|
* met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above
|
||||||
|
* copyright notice, this list of conditions and the following
|
||||||
|
* disclaimer in the documentation and/or other materials provided
|
||||||
|
* with the distribution.
|
||||||
|
* * Neither the name of The Linux Foundation. nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __QTIGRALLOCDEFS_H__
|
||||||
|
#define __QTIGRALLOCDEFS_H__
|
||||||
|
|
||||||
|
// From gralloc_priv.h
|
||||||
|
|
||||||
|
/* Gralloc usage bits indicating the type of allocation that should be used */
|
||||||
|
/* Refer to BufferUsage in hardware/interfaces/graphics/common/<ver>/types.hal */
|
||||||
|
|
||||||
|
/* The bits below are in officially defined vendor space
|
||||||
|
* i.e bits 28-31 and 48-63*/
|
||||||
|
/* Non linear, Universal Bandwidth Compression */
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC (UINT32_C(1) << 28)
|
||||||
|
|
||||||
|
/* Set this for allocating uncached memory (using O_DSYNC),
|
||||||
|
* cannot be used with noncontiguous heaps */
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_UNCACHED (UINT32_C(1) << 29)
|
||||||
|
|
||||||
|
/* This flag is used to indicate 10 bit format.
|
||||||
|
* When both GRALLOC_USAGE_PRIVATE_ALLOC_UBWC & GRALLOC_USAGE_PRIVATE_10BIT
|
||||||
|
* are set then it will indicate UBWC_TP10 format.
|
||||||
|
* When only GRALLOC_USAGE_PRIVATE_10BIT is set it will indicate linear P010 format.
|
||||||
|
*/
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_10BIT (UINT32_C(1) << 30)
|
||||||
|
|
||||||
|
/* This flag is used for SECURE display usecase */
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY (UINT32_C(1) << 31)
|
||||||
|
|
||||||
|
/* This flag is used to indicate video NV21 format */
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER 1ULL << 48
|
||||||
|
|
||||||
|
/* unused legacy flags */
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_MM_HEAP 0
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP 0
|
||||||
|
|
||||||
|
/* This flag is set for WFD usecase */
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_WFD 1ULL << 51
|
||||||
|
|
||||||
|
/* This flag is set for HEIF usecase */
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_HEIF (UINT32_C(1) << 27)
|
||||||
|
|
||||||
|
/* TODO(user): Remove when clients stop referencing this flag */
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_10BIT_TP 0
|
||||||
|
|
||||||
|
/* This flag indicates PI format is being used */
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI 1ULL << 49
|
||||||
|
|
||||||
|
/* This flag is set while CDSP accesses the buffer */
|
||||||
|
#define GRALLOC_USAGE_PRIVATE_CDSP 1ULL << 50
|
||||||
|
|
||||||
|
// OEM specific HAL formats
|
||||||
|
#define HAL_PIXEL_FORMAT_RGBA_5551 6
|
||||||
|
#define HAL_PIXEL_FORMAT_RGBA_4444 7
|
||||||
|
#define HAL_PIXEL_FORMAT_NV12_ENCODEABLE 0x102
|
||||||
|
#define HAL_PIXEL_FORMAT_NV21_ENCODEABLE 0x7FA30C00
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 0x7FA30C04
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED 0x7FA30C03
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_420_SP 0x109
|
||||||
|
#define HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO 0x7FA30C01
|
||||||
|
#define HAL_PIXEL_FORMAT_YCrCb_422_SP 0x10B
|
||||||
|
#define HAL_PIXEL_FORMAT_R_8 0x10D
|
||||||
|
#define HAL_PIXEL_FORMAT_RG_88 0x10E
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_444_SP 0x10F
|
||||||
|
#define HAL_PIXEL_FORMAT_YCrCb_444_SP 0x110
|
||||||
|
#define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111
|
||||||
|
#define HAL_PIXEL_FORMAT_BGRX_8888 0x112
|
||||||
|
#define HAL_PIXEL_FORMAT_NV21_ZSL 0x113
|
||||||
|
#define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114
|
||||||
|
#define HAL_PIXEL_FORMAT_BGR_565 0x115
|
||||||
|
#define HAL_PIXEL_FORMAT_RAW8 0x123
|
||||||
|
#define HAL_PIXEL_FORMAT_NV12_HEIF 0x116
|
||||||
|
|
||||||
|
// 10 bit
|
||||||
|
#define HAL_PIXEL_FORMAT_ARGB_2101010 0x117
|
||||||
|
#define HAL_PIXEL_FORMAT_RGBX_1010102 0x118
|
||||||
|
#define HAL_PIXEL_FORMAT_XRGB_2101010 0x119
|
||||||
|
#define HAL_PIXEL_FORMAT_BGRA_1010102 0x11A
|
||||||
|
#define HAL_PIXEL_FORMAT_ABGR_2101010 0x11B
|
||||||
|
#define HAL_PIXEL_FORMAT_BGRX_1010102 0x11C
|
||||||
|
#define HAL_PIXEL_FORMAT_XBGR_2101010 0x11D
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_420_P010 0x11F
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC 0x124
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS 0x7FA30C0A
|
||||||
|
|
||||||
|
#define HAL_PIXEL_FORMAT_CbYCrY_422_I 0x120
|
||||||
|
#define HAL_PIXEL_FORMAT_BGR_888 0x121
|
||||||
|
|
||||||
|
#define HAL_PIXEL_FORMAT_INTERLACE 0x180
|
||||||
|
|
||||||
|
// Camera utils format
|
||||||
|
#define HAL_PIXEL_FORMAT_NV12_LINEAR_FLEX 0x125
|
||||||
|
#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX 0x126
|
||||||
|
#define HAL_PIXEL_FORMAT_MULTIPLANAR_FLEX 0x127
|
||||||
|
|
||||||
|
// v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT 0x4C595559
|
||||||
|
|
||||||
|
// v4l2_fourcc('Y', 'B', 'W', 'C'). 10 bit per component. This compressed
|
||||||
|
// format reduces the memory access bandwidth
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT_COMPRESSED 0x43574259
|
||||||
|
|
||||||
|
// UBWC aligned Venus format
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06
|
||||||
|
#define HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC 0x7FA30C09
|
||||||
|
|
||||||
|
// Khronos ASTC formats
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
|
||||||
|
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
|
||||||
|
|
||||||
|
enum { BUFFER_TYPE_UI = 0, BUFFER_TYPE_VIDEO };
|
||||||
|
|
||||||
|
#endif //__QTIGRALLOCDEFS_H__
|
||||||
150
gralloc/QtiGrallocMetadata.h
Normal file
150
gralloc/QtiGrallocMetadata.h
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020 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
|
||||||
|
* met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above
|
||||||
|
* copyright notice, this list of conditions and the following
|
||||||
|
* disclaimer in the documentation and/or other materials provided
|
||||||
|
* with the distribution.
|
||||||
|
* * Neither the name of The Linux Foundation. nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __QTIGRALLOCMETADATA_H__
|
||||||
|
#define __QTIGRALLOCMETADATA_H__
|
||||||
|
|
||||||
|
#include <color_metadata.h>
|
||||||
|
#define QTI_VT_TIMESTAMP 10000
|
||||||
|
#define QTI_COLOR_METADATA 10001
|
||||||
|
#define QTI_PP_PARAM_INTERLACED 10002
|
||||||
|
#define QTI_VIDEO_PERF_MODE 10003
|
||||||
|
#define QTI_GRAPHICS_METADATA 10004
|
||||||
|
#define QTI_UBWC_CR_STATS_INFO 10005
|
||||||
|
#define QTI_REFRESH_RATE 10006
|
||||||
|
#define QTI_MAP_SECURE_BUFFER 10007
|
||||||
|
#define QTI_LINEAR_FORMAT 10008
|
||||||
|
#define QTI_SINGLE_BUFFER_MODE 10009
|
||||||
|
#define QTI_CVP_METADATA 10010
|
||||||
|
#define QTI_VIDEO_HISTOGRAM_STATS 10011
|
||||||
|
#define QTI_FD 10012
|
||||||
|
#define QTI_PRIVATE_FLAGS 10013
|
||||||
|
|
||||||
|
// Used to indicate to framework that internal definitions are used instead
|
||||||
|
#define COMPRESSION_QTI_UBWC 20001
|
||||||
|
#define INTERLACED_QTI 20002
|
||||||
|
|
||||||
|
#define PLANE_COMPONENT_TYPE_RAW 20003
|
||||||
|
#define PLANE_COMPONENT_TYPE_META 20004
|
||||||
|
|
||||||
|
#define MAX_NAME_LEN 256
|
||||||
|
|
||||||
|
// GRAPHICS_METADATA
|
||||||
|
#define GRAPHICS_METADATA_SIZE 4096
|
||||||
|
typedef struct GraphicsMetadata {
|
||||||
|
uint32_t size;
|
||||||
|
uint32_t data[GRAPHICS_METADATA_SIZE];
|
||||||
|
} GraphicsMetadata;
|
||||||
|
|
||||||
|
// UBWC_CR_STATS_INFO
|
||||||
|
#define MAX_UBWC_STATS_LENGTH 32
|
||||||
|
enum UBWC_Version {
|
||||||
|
UBWC_UNUSED = 0,
|
||||||
|
UBWC_1_0 = 0x1,
|
||||||
|
UBWC_2_0 = 0x2,
|
||||||
|
UBWC_3_0 = 0x3,
|
||||||
|
UBWC_4_0 = 0x4,
|
||||||
|
UBWC_MAX_VERSION = 0xFF,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UBWC_2_0_Stats {
|
||||||
|
uint32_t nCRStatsTile32; /**< UBWC Stats info for 32 Byte Tile */
|
||||||
|
uint32_t nCRStatsTile64; /**< UBWC Stats info for 64 Byte Tile */
|
||||||
|
uint32_t nCRStatsTile96; /**< UBWC Stats info for 96 Byte Tile */
|
||||||
|
uint32_t nCRStatsTile128; /**< UBWC Stats info for 128 Byte Tile */
|
||||||
|
uint32_t nCRStatsTile160; /**< UBWC Stats info for 160 Byte Tile */
|
||||||
|
uint32_t nCRStatsTile192; /**< UBWC Stats info for 192 Byte Tile */
|
||||||
|
uint32_t nCRStatsTile256; /**< UBWC Stats info for 256 Byte Tile */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UBWCStats {
|
||||||
|
enum UBWC_Version version; /* Union depends on this version. */
|
||||||
|
uint8_t bDataValid; /* If [non-zero], CR Stats data is valid.
|
||||||
|
* Consumers may use stats data.
|
||||||
|
* If [zero], CR Stats data is invalid.
|
||||||
|
* Consumers *Shall* not use stats data */
|
||||||
|
union {
|
||||||
|
struct UBWC_2_0_Stats ubwc_stats;
|
||||||
|
uint32_t reserved[MAX_UBWC_STATS_LENGTH]; /* This is for future */
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#define UBWC_STATS_ARRAY_SIZE 2
|
||||||
|
struct CropRectangle_t {
|
||||||
|
int32_t left;
|
||||||
|
int32_t top;
|
||||||
|
int32_t right;
|
||||||
|
int32_t bottom;
|
||||||
|
};
|
||||||
|
|
||||||
|
// CVP_METADATA
|
||||||
|
#define CVP_METADATA_SIZE 1024
|
||||||
|
enum CVPMetadataFlags {
|
||||||
|
/* bit wise flags */
|
||||||
|
CVP_METADATA_FLAG_NONE = 0x00000000,
|
||||||
|
CVP_METADATA_FLAG_REPEAT = 0x00000001,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct CVPMetadata {
|
||||||
|
uint32_t size; /* payload size in bytes */
|
||||||
|
uint8_t payload[CVP_METADATA_SIZE];
|
||||||
|
uint32_t capture_frame_rate;
|
||||||
|
/* Frame rate in Q16 format.
|
||||||
|
Eg: fps = 7.5, then
|
||||||
|
capture_frame_rate = 7 << 16 --> Upper 16 bits to represent 7
|
||||||
|
capture_frame_rate |= 5 -------> Lower 16 bits to represent 5
|
||||||
|
|
||||||
|
If size > 0, framerate is valid
|
||||||
|
If size = 0, invalid data, so ignore all parameters */
|
||||||
|
uint32_t cvp_frame_rate;
|
||||||
|
enum CVPMetadataFlags flags;
|
||||||
|
uint32_t reserved[8];
|
||||||
|
} CVPMetadata;
|
||||||
|
|
||||||
|
// VIDEO_HISTOGRAM_STATS
|
||||||
|
|
||||||
|
#define VIDEO_HISTOGRAM_STATS_SIZE (4 * 1024)
|
||||||
|
struct VideoHistogramMetadata {
|
||||||
|
uint32_t stats_info[1024]; /* video stats payload */
|
||||||
|
uint32_t stat_len; /* Payload size in bytes */
|
||||||
|
uint32_t frame_type; /* bit mask to indicate frame type */
|
||||||
|
uint32_t display_width;
|
||||||
|
uint32_t display_height;
|
||||||
|
uint32_t decode_width;
|
||||||
|
uint32_t decode_height;
|
||||||
|
uint32_t reserved[12];
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RESERVED_REGION_SIZE 4096
|
||||||
|
typedef struct ReservedRegion {
|
||||||
|
uint32_t size;
|
||||||
|
uint8_t data[RESERVED_REGION_SIZE];
|
||||||
|
} ReservedRegion;
|
||||||
|
|
||||||
|
#endif //__QTIGRALLOCMETADATA_H__
|
||||||
198
gralloc/QtiGrallocPriv.h
Normal file
198
gralloc/QtiGrallocPriv.h
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020 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
|
||||||
|
* met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above
|
||||||
|
* copyright notice, this list of conditions and the following
|
||||||
|
* disclaimer in the documentation and/or other materials provided
|
||||||
|
* with the distribution.
|
||||||
|
* * Neither the name of The Linux Foundation. nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __QTIGRALLOCPRIV_H__
|
||||||
|
#define __QTIGRALLOCPRIV_H__
|
||||||
|
|
||||||
|
#include <color_metadata.h>
|
||||||
|
#include <cutils/native_handle.h>
|
||||||
|
#include <log/log.h>
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "QtiGrallocMetadata.h"
|
||||||
|
|
||||||
|
#ifndef __QTI_DISPLAY_GRALLOC__
|
||||||
|
#pragma message "QtiGrallocPriv.h should not be included"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* DISCLAIMER:
|
||||||
|
* INTERNAL GRALLOC USE ONLY - THIS FILE SHOULD NOT BE INCLUDED BY GRALLOC CLIENTS
|
||||||
|
* The location will be changed and this file will not be exposed
|
||||||
|
* once qdMetaData copy functions are deprecated
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: MetaData_t should be in qtigralloc namespace
|
||||||
|
struct MetaData_t {
|
||||||
|
int32_t operation;
|
||||||
|
int32_t interlaced;
|
||||||
|
float refreshrate;
|
||||||
|
int32_t mapSecureBuffer;
|
||||||
|
/* Deprecated */
|
||||||
|
uint32_t s3dFormat;
|
||||||
|
/* VENUS output buffer is linear for UBWC Interlaced video */
|
||||||
|
uint32_t linearFormat;
|
||||||
|
/* Set by graphics to indicate that this buffer will be written to but not
|
||||||
|
* swapped out */
|
||||||
|
uint32_t isSingleBufferMode;
|
||||||
|
|
||||||
|
/* Set by camera to program the VT Timestamp */
|
||||||
|
uint64_t vtTimeStamp;
|
||||||
|
/* Color Aspects + HDR info */
|
||||||
|
ColorMetaData color;
|
||||||
|
/* Consumer should read this data as follows based on
|
||||||
|
* Gralloc flag "interlaced" listed above.
|
||||||
|
* [0] : If it is progressive.
|
||||||
|
* [0] : Top field, if it is interlaced.
|
||||||
|
* [1] : Do not read, if it is progressive.
|
||||||
|
* [1] : Bottom field, if it is interlaced.
|
||||||
|
*/
|
||||||
|
struct UBWCStats ubwcCRStats[UBWC_STATS_ARRAY_SIZE];
|
||||||
|
/* Set by camera to indicate that this buffer will be used for a High
|
||||||
|
* Performance Video Usecase */
|
||||||
|
uint32_t isVideoPerfMode;
|
||||||
|
/* Populated and used by adreno during buffer size calculation.
|
||||||
|
* Set only for RGB formats. */
|
||||||
|
GraphicsMetadata graphics_metadata;
|
||||||
|
/* Video hisogram stats populated by video decoder */
|
||||||
|
struct VideoHistogramMetadata video_histogram_stats;
|
||||||
|
/*
|
||||||
|
* Producer (camera) will set cvp metadata and consumer (video) will
|
||||||
|
* use it. The format of metadata is known to producer and consumer.
|
||||||
|
*/
|
||||||
|
CVPMetadata cvpMetadata;
|
||||||
|
CropRectangle_t crop;
|
||||||
|
int32_t blendMode;
|
||||||
|
char name[MAX_NAME_LEN];
|
||||||
|
ReservedRegion reservedRegion;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace qtigralloc {
|
||||||
|
#define QTI_HANDLE_CONST(exp) static_cast<const private_handle_t *>(exp)
|
||||||
|
|
||||||
|
#pragma pack(push, 4)
|
||||||
|
struct private_handle_t : public native_handle_t {
|
||||||
|
// file-descriptors dup'd over IPC
|
||||||
|
int fd;
|
||||||
|
int fd_metadata;
|
||||||
|
|
||||||
|
// values sent over IPC
|
||||||
|
int magic;
|
||||||
|
int flags;
|
||||||
|
int width; // holds width of the actual buffer allocated
|
||||||
|
int height; // holds height of the actual buffer allocated
|
||||||
|
int unaligned_width; // holds width client asked to allocate
|
||||||
|
int unaligned_height; // holds height client asked to allocate
|
||||||
|
int format;
|
||||||
|
int buffer_type;
|
||||||
|
unsigned int layer_count;
|
||||||
|
uint64_t id;
|
||||||
|
uint64_t usage;
|
||||||
|
|
||||||
|
unsigned int size;
|
||||||
|
unsigned int offset;
|
||||||
|
unsigned int offset_metadata;
|
||||||
|
uint64_t base;
|
||||||
|
uint64_t base_metadata;
|
||||||
|
uint64_t gpuaddr;
|
||||||
|
static const int kNumFds = 2;
|
||||||
|
static const int kMagic = 'gmsm';
|
||||||
|
|
||||||
|
static inline int NumInts() {
|
||||||
|
return ((sizeof(private_handle_t) - sizeof(native_handle_t)) / sizeof(int)) - kNumFds;
|
||||||
|
}
|
||||||
|
|
||||||
|
private_handle_t(int fd, int meta_fd, int flags, int width, int height, int uw, int uh,
|
||||||
|
int format, int buf_type, unsigned int size, uint64_t usage = 0)
|
||||||
|
: fd(fd),
|
||||||
|
fd_metadata(meta_fd),
|
||||||
|
magic(kMagic),
|
||||||
|
flags(flags),
|
||||||
|
width(width),
|
||||||
|
height(height),
|
||||||
|
unaligned_width(uw),
|
||||||
|
unaligned_height(uh),
|
||||||
|
format(format),
|
||||||
|
buffer_type(buf_type),
|
||||||
|
layer_count(1),
|
||||||
|
id(0),
|
||||||
|
usage(usage),
|
||||||
|
size(size),
|
||||||
|
offset(0),
|
||||||
|
offset_metadata(0),
|
||||||
|
base(0),
|
||||||
|
base_metadata(0),
|
||||||
|
gpuaddr(0) {
|
||||||
|
version = static_cast<int>(sizeof(native_handle));
|
||||||
|
numInts = NumInts();
|
||||||
|
numFds = kNumFds;
|
||||||
|
}
|
||||||
|
|
||||||
|
~private_handle_t() { magic = 0; }
|
||||||
|
|
||||||
|
static int validate(const native_handle *h) {
|
||||||
|
auto *hnd = static_cast<const private_handle_t *>(h);
|
||||||
|
if (!h || h->version != sizeof(native_handle) || h->numInts != NumInts() ||
|
||||||
|
h->numFds != kNumFds) {
|
||||||
|
ALOGE("Invalid gralloc handle (at %p): ver(%d/%zu) ints(%d/%d) fds(%d/%d)", h,
|
||||||
|
h ? h->version : -1, sizeof(native_handle), h ? h->numInts : -1, NumInts(),
|
||||||
|
h ? h->numFds : -1, kNumFds);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (hnd->magic != kMagic) {
|
||||||
|
ALOGE("handle = %p invalid magic(%c%c%c%c/%c%c%c%c)", hnd,
|
||||||
|
hnd ? (((hnd->magic >> 24) & 0xFF) ? ((hnd->magic >> 24) & 0xFF) : '-') : '?',
|
||||||
|
hnd ? (((hnd->magic >> 16) & 0xFF) ? ((hnd->magic >> 16) & 0xFF) : '-') : '?',
|
||||||
|
hnd ? (((hnd->magic >> 8) & 0xFF) ? ((hnd->magic >> 8) & 0xFF) : '-') : '?',
|
||||||
|
hnd ? (((hnd->magic >> 0) & 0xFF) ? ((hnd->magic >> 0) & 0xFF) : '-') : '?',
|
||||||
|
(kMagic >> 24) & 0xFF, (kMagic >> 16) & 0xFF, (kMagic >> 8) & 0xFF,
|
||||||
|
(kMagic >> 0) & 0xFF);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Dump(const private_handle_t *hnd) {
|
||||||
|
ALOGD("handle id:%" PRIu64
|
||||||
|
" wxh:%dx%d uwxuh:%dx%d size: %d fd:%d fd_meta:%d flags:0x%x "
|
||||||
|
"usage:0x%" PRIx64 " format:0x%x layer_count: %d",
|
||||||
|
hnd->id, hnd->width, hnd->height, hnd->unaligned_width, hnd->unaligned_height, hnd->size,
|
||||||
|
hnd->fd, hnd->fd_metadata, hnd->flags, hnd->usage, hnd->format, hnd->layer_count);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
} // namespace qtigralloc
|
||||||
|
|
||||||
|
#endif //__QTIGRALLOCPRIV_H__
|
||||||
@@ -22,8 +22,12 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "QtiGrallocDefs.h"
|
||||||
#include "gr_priv_handle.h"
|
#include "gr_priv_handle.h"
|
||||||
|
|
||||||
|
#pragma message "Warning: gralloc_priv.h is deprecated"
|
||||||
|
|
||||||
#define GRALLOC_PROP_PREFIX "vendor.gralloc."
|
#define GRALLOC_PROP_PREFIX "vendor.gralloc."
|
||||||
#define GRALLOC_PROP(prop_name) GRALLOC_PROP_PREFIX prop_name
|
#define GRALLOC_PROP(prop_name) GRALLOC_PROP_PREFIX prop_name
|
||||||
|
|
||||||
@@ -38,50 +42,6 @@ inline int roundUpToPageSize(int x) {
|
|||||||
return (x + (getpagesize() - 1)) & ~(getpagesize() - 1);
|
return (x + (getpagesize() - 1)) & ~(getpagesize() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Gralloc usage bits indicating the type of allocation that should be used */
|
|
||||||
/* Refer to BufferUsage in hardware/interfaces/graphics/common/<ver>/types.hal */
|
|
||||||
|
|
||||||
/* The bits below are in officially defined vendor space
|
|
||||||
* i.e bits 28-31 and 48-63*/
|
|
||||||
/* Non linear, Universal Bandwidth Compression */
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC (UINT32_C(1) << 28)
|
|
||||||
|
|
||||||
/* Set this for allocating uncached memory (using O_DSYNC),
|
|
||||||
* cannot be used with noncontiguous heaps */
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_UNCACHED (UINT32_C(1) << 29)
|
|
||||||
|
|
||||||
/* This flag is used to indicate 10 bit format.
|
|
||||||
* When both GRALLOC_USAGE_PRIVATE_ALLOC_UBWC & GRALLOC_USAGE_PRIVATE_10BIT
|
|
||||||
* are set then it will indicate UBWC_TP10 format.
|
|
||||||
* When only GRALLOC_USAGE_PRIVATE_10BIT is set it will indicate linear P010 format.
|
|
||||||
*/
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_10BIT (UINT32_C(1) << 30)
|
|
||||||
|
|
||||||
/* This flag is used for SECURE display usecase */
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY (UINT32_C(1) << 31)
|
|
||||||
|
|
||||||
/* This flag is used to indicate video NV21 format */
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER 1ULL << 48
|
|
||||||
|
|
||||||
/* unused legacy flags */
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_MM_HEAP 0
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP 0
|
|
||||||
|
|
||||||
/* This flag is set for WFD usecase */
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_WFD 1ULL << 51
|
|
||||||
|
|
||||||
/* This flag is set for HEIF usecase */
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_HEIF (UINT32_C(1) << 27)
|
|
||||||
|
|
||||||
/* TODO(user): Remove when clients stop referencing this flag */
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_10BIT_TP 0
|
|
||||||
|
|
||||||
/* This flag indicates PI format is being used */
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI 1ULL << 49
|
|
||||||
|
|
||||||
/* This flag is set while CDSP accesses the buffer */
|
|
||||||
#define GRALLOC_USAGE_PRIVATE_CDSP 1ULL << 50
|
|
||||||
|
|
||||||
/* Legacy gralloc1 definitions */
|
/* Legacy gralloc1 definitions */
|
||||||
/* Some clients may still be using the old flags */
|
/* Some clients may still be using the old flags */
|
||||||
#define GRALLOC1_PRODUCER_USAGE_PRIVATE_ADSP_HEAP GRALLOC_USAGE_PRIVATE_ADSP_HEAP
|
#define GRALLOC1_PRODUCER_USAGE_PRIVATE_ADSP_HEAP GRALLOC_USAGE_PRIVATE_ADSP_HEAP
|
||||||
@@ -112,91 +72,6 @@ inline int roundUpToPageSize(int x) {
|
|||||||
#define GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG 15
|
#define GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG 15
|
||||||
#define GRALLOC_MODULE_PERFORM_GET_GRAPHICS_METADATA 16
|
#define GRALLOC_MODULE_PERFORM_GET_GRAPHICS_METADATA 16
|
||||||
|
|
||||||
// OEM specific HAL formats
|
|
||||||
#define HAL_PIXEL_FORMAT_RGBA_5551 6
|
|
||||||
#define HAL_PIXEL_FORMAT_RGBA_4444 7
|
|
||||||
#define HAL_PIXEL_FORMAT_NV12_ENCODEABLE 0x102
|
|
||||||
#define HAL_PIXEL_FORMAT_NV21_ENCODEABLE 0x7FA30C00
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 0x7FA30C04
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED 0x7FA30C03
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_420_SP 0x109
|
|
||||||
#define HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO 0x7FA30C01
|
|
||||||
#define HAL_PIXEL_FORMAT_YCrCb_422_SP 0x10B
|
|
||||||
#define HAL_PIXEL_FORMAT_R_8 0x10D
|
|
||||||
#define HAL_PIXEL_FORMAT_RG_88 0x10E
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_444_SP 0x10F
|
|
||||||
#define HAL_PIXEL_FORMAT_YCrCb_444_SP 0x110
|
|
||||||
#define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111
|
|
||||||
#define HAL_PIXEL_FORMAT_BGRX_8888 0x112
|
|
||||||
#define HAL_PIXEL_FORMAT_NV21_ZSL 0x113
|
|
||||||
#define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114
|
|
||||||
#define HAL_PIXEL_FORMAT_BGR_565 0x115
|
|
||||||
#define HAL_PIXEL_FORMAT_RAW8 0x123
|
|
||||||
#define HAL_PIXEL_FORMAT_NV12_HEIF 0x116
|
|
||||||
|
|
||||||
// 10 bit
|
|
||||||
#define HAL_PIXEL_FORMAT_ARGB_2101010 0x117
|
|
||||||
#define HAL_PIXEL_FORMAT_RGBX_1010102 0x118
|
|
||||||
#define HAL_PIXEL_FORMAT_XRGB_2101010 0x119
|
|
||||||
#define HAL_PIXEL_FORMAT_BGRA_1010102 0x11A
|
|
||||||
#define HAL_PIXEL_FORMAT_ABGR_2101010 0x11B
|
|
||||||
#define HAL_PIXEL_FORMAT_BGRX_1010102 0x11C
|
|
||||||
#define HAL_PIXEL_FORMAT_XBGR_2101010 0x11D
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_420_P010 0x11F
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC 0x124
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS 0x7FA30C0A
|
|
||||||
|
|
||||||
#define HAL_PIXEL_FORMAT_CbYCrY_422_I 0x120
|
|
||||||
#define HAL_PIXEL_FORMAT_BGR_888 0x121
|
|
||||||
|
|
||||||
#define HAL_PIXEL_FORMAT_INTERLACE 0x180
|
|
||||||
|
|
||||||
// Camera utils format
|
|
||||||
#define HAL_PIXEL_FORMAT_NV12_LINEAR_FLEX 0x125
|
|
||||||
#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX 0x126
|
|
||||||
#define HAL_PIXEL_FORMAT_MULTIPLANAR_FLEX 0x127
|
|
||||||
|
|
||||||
// v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT 0x4C595559
|
|
||||||
|
|
||||||
// v4l2_fourcc('Y', 'B', 'W', 'C'). 10 bit per component. This compressed
|
|
||||||
// format reduces the memory access bandwidth
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT_COMPRESSED 0x43574259
|
|
||||||
|
|
||||||
// UBWC aligned Venus format
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06
|
|
||||||
#define HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC 0x7FA30C09
|
|
||||||
|
|
||||||
// Khronos ASTC formats
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
|
|
||||||
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
|
|
||||||
|
|
||||||
/* possible values for inverse gamma correction */
|
/* possible values for inverse gamma correction */
|
||||||
#define HAL_IGC_NOT_SPECIFIED 0
|
#define HAL_IGC_NOT_SPECIFIED 0
|
||||||
#define HAL_IGC_s_RGB 1
|
#define HAL_IGC_s_RGB 1
|
||||||
@@ -217,8 +92,6 @@ enum {
|
|||||||
HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, // unused legacy format
|
HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, // unused legacy format
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { BUFFER_TYPE_UI = 0, BUFFER_TYPE_VIDEO };
|
|
||||||
|
|
||||||
/* Flag to determine interlaced content
|
/* Flag to determine interlaced content
|
||||||
* Value maps to Flags presents in types.hal of QtiMapperextensions
|
* Value maps to Flags presents in types.hal of QtiMapperextensions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,11 +5,14 @@ cc_library_shared {
|
|||||||
cflags: [
|
cflags: [
|
||||||
"-Wno-sign-conversion",
|
"-Wno-sign-conversion",
|
||||||
"-DLOG_TAG=\"qdmetadata\"",
|
"-DLOG_TAG=\"qdmetadata\"",
|
||||||
|
"-D__QTI_DISPLAY_GRALLOC__",
|
||||||
],
|
],
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"liblog",
|
"liblog",
|
||||||
"libcutils",
|
"libcutils",
|
||||||
"libutils",
|
"libutils",
|
||||||
|
"libhidlbase",
|
||||||
|
"libgralloc.qti",
|
||||||
],
|
],
|
||||||
header_libs: ["libhardware_headers", "display_intf_headers"],
|
header_libs: ["libhardware_headers", "display_intf_headers"],
|
||||||
srcs: ["qdMetaData.cpp", "qd_utils.cpp"],
|
srcs: ["qdMetaData.cpp", "qd_utils.cpp"],
|
||||||
|
|||||||
@@ -27,13 +27,16 @@
|
|||||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "qdMetaData.h"
|
||||||
|
|
||||||
|
#include <QtiGrallocPriv.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <gralloc_priv.h>
|
||||||
|
#include <log/log.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <log/log.h>
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <gralloc_priv.h>
|
|
||||||
#include "qdMetaData.h"
|
|
||||||
|
|
||||||
static int colorMetaDataToColorSpace(ColorMetaData in, ColorSpace_t *out) {
|
static int colorMetaDataToColorSpace(ColorMetaData in, ColorSpace_t *out) {
|
||||||
if (in.colorPrimaries == ColorPrimaries_BT601_6_525 ||
|
if (in.colorPrimaries == ColorPrimaries_BT601_6_525 ||
|
||||||
@@ -151,9 +154,11 @@ int setMetaDataVa(MetaData_t *data, DispParamType paramType,
|
|||||||
case PP_PARAM_INTERLACED:
|
case PP_PARAM_INTERLACED:
|
||||||
data->interlaced = *((int32_t *)param);
|
data->interlaced = *((int32_t *)param);
|
||||||
break;
|
break;
|
||||||
case UPDATE_BUFFER_GEOMETRY:
|
case UPDATE_BUFFER_GEOMETRY: {
|
||||||
data->bufferDim = *((BufferDim_t *)param);
|
BufferDim_t in = *((BufferDim_t *)param);
|
||||||
break;
|
data->crop = {0, 0, in.sliceWidth, in.sliceHeight};
|
||||||
|
break;
|
||||||
|
}
|
||||||
case UPDATE_REFRESH_RATE:
|
case UPDATE_REFRESH_RATE:
|
||||||
data->refreshrate = *((float *)param);
|
data->refreshrate = *((float *)param);
|
||||||
break;
|
break;
|
||||||
@@ -301,8 +306,8 @@ int getMetaDataVa(MetaData_t *data, DispFetchParamType paramType,
|
|||||||
break;
|
break;
|
||||||
case GET_BUFFER_GEOMETRY:
|
case GET_BUFFER_GEOMETRY:
|
||||||
if (data->operation & UPDATE_BUFFER_GEOMETRY) {
|
if (data->operation & UPDATE_BUFFER_GEOMETRY) {
|
||||||
*((BufferDim_t *)param) = data->bufferDim;
|
*((BufferDim_t *)param) = {data->crop.right, data->crop.bottom};
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GET_REFRESH_RATE:
|
case GET_REFRESH_RATE:
|
||||||
|
|||||||
@@ -30,146 +30,38 @@
|
|||||||
#ifndef _QDMETADATA_H
|
#ifndef _QDMETADATA_H
|
||||||
#define _QDMETADATA_H
|
#define _QDMETADATA_H
|
||||||
|
|
||||||
|
#include <QtiGrallocMetadata.h>
|
||||||
#include <color_metadata.h>
|
#include <color_metadata.h>
|
||||||
|
|
||||||
|
/* TODO: This conditional include is to prevent breaking video and camera test cases using
|
||||||
|
* MetaData_t - camxchinodedewarp.cpp, vtest_EncoderFileSource.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#include <QtiGrallocPriv.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __QTI_DISPLAY_GRALLOC__
|
||||||
|
#pragma message "qdMetaData.h is being deprecated"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_UBWC_STATS_LENGTH 32
|
struct MetaData_t;
|
||||||
#define GRAPHICS_METADATA_SIZE 4096
|
|
||||||
#define CVP_METADATA_SIZE 1024
|
|
||||||
|
|
||||||
enum ColorSpace_t{
|
enum ColorSpace_t {
|
||||||
ITU_R_601,
|
ITU_R_601,
|
||||||
ITU_R_601_FR,
|
ITU_R_601_FR,
|
||||||
ITU_R_709,
|
ITU_R_709,
|
||||||
ITU_R_2020,
|
ITU_R_2020,
|
||||||
ITU_R_2020_FR,
|
ITU_R_2020_FR,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BufferDim_t {
|
struct BufferDim_t {
|
||||||
int32_t sliceWidth;
|
int32_t sliceWidth;
|
||||||
int32_t sliceHeight;
|
int32_t sliceHeight;
|
||||||
};
|
|
||||||
|
|
||||||
enum UBWC_Version {
|
|
||||||
UBWC_UNUSED = 0,
|
|
||||||
UBWC_1_0 = 0x1,
|
|
||||||
UBWC_2_0 = 0x2,
|
|
||||||
UBWC_3_0 = 0x3,
|
|
||||||
UBWC_4_0 = 0x4,
|
|
||||||
UBWC_MAX_VERSION = 0xFF,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UBWC_2_0_Stats {
|
|
||||||
uint32_t nCRStatsTile32; /**< UBWC Stats info for 32 Byte Tile */
|
|
||||||
uint32_t nCRStatsTile64; /**< UBWC Stats info for 64 Byte Tile */
|
|
||||||
uint32_t nCRStatsTile96; /**< UBWC Stats info for 96 Byte Tile */
|
|
||||||
uint32_t nCRStatsTile128; /**< UBWC Stats info for 128 Byte Tile */
|
|
||||||
uint32_t nCRStatsTile160; /**< UBWC Stats info for 160 Byte Tile */
|
|
||||||
uint32_t nCRStatsTile192; /**< UBWC Stats info for 192 Byte Tile */
|
|
||||||
uint32_t nCRStatsTile256; /**< UBWC Stats info for 256 Byte Tile */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UBWCStats {
|
|
||||||
enum UBWC_Version version; /* Union depends on this version. */
|
|
||||||
uint8_t bDataValid; /* If [non-zero], CR Stats data is valid.
|
|
||||||
* Consumers may use stats data.
|
|
||||||
* If [zero], CR Stats data is invalid.
|
|
||||||
* Consumers *Shall* not use stats data */
|
|
||||||
union {
|
|
||||||
struct UBWC_2_0_Stats ubwc_stats;
|
|
||||||
uint32_t reserved[MAX_UBWC_STATS_LENGTH]; /* This is for future */
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct GraphicsMetadata {
|
|
||||||
uint32_t size;
|
|
||||||
uint32_t data[GRAPHICS_METADATA_SIZE];
|
|
||||||
} GraphicsMetadata;
|
|
||||||
|
|
||||||
#define VIDEO_HISTOGRAM_STATS_SIZE (4 * 1024)
|
|
||||||
/* Frame type bit mask */
|
|
||||||
#define QD_SYNC_FRAME (0x1 << 0)
|
|
||||||
struct VideoHistogramMetadata {
|
|
||||||
uint32_t stats_info[1024]; /* video stats payload */
|
|
||||||
uint32_t stat_len; /* Payload size in bytes */
|
|
||||||
uint32_t frame_type; /* bit mask to indicate frame type */
|
|
||||||
uint32_t display_width;
|
|
||||||
uint32_t display_height;
|
|
||||||
uint32_t decode_width;
|
|
||||||
uint32_t decode_height;
|
|
||||||
uint32_t reserved[12];
|
|
||||||
};
|
|
||||||
|
|
||||||
enum CVPMetadataFlags {
|
|
||||||
/* bit wise flags */
|
|
||||||
CVP_METADATA_FLAG_NONE = 0x00000000,
|
|
||||||
CVP_METADATA_FLAG_REPEAT = 0x00000001,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct CVPMetadata {
|
|
||||||
uint32_t size; /* payload size in bytes */
|
|
||||||
uint8_t payload[CVP_METADATA_SIZE];
|
|
||||||
uint32_t capture_frame_rate;
|
|
||||||
/* Frame rate in Q16 format.
|
|
||||||
Eg: fps = 7.5, then
|
|
||||||
capture_frame_rate = 7 << 16 --> Upper 16 bits to represent 7
|
|
||||||
capture_frame_rate |= 5 -------> Lower 16 bits to represent 5
|
|
||||||
|
|
||||||
If size > 0, framerate is valid
|
|
||||||
If size = 0, invalid data, so ignore all parameters */
|
|
||||||
uint32_t cvp_frame_rate;
|
|
||||||
enum CVPMetadataFlags flags;
|
|
||||||
uint32_t reserved[8];
|
|
||||||
} CVPMetadata;
|
|
||||||
|
|
||||||
struct MetaData_t {
|
|
||||||
int32_t operation;
|
|
||||||
int32_t interlaced;
|
|
||||||
struct BufferDim_t bufferDim;
|
|
||||||
float refreshrate;
|
|
||||||
/* Gralloc sets PRIV_SECURE_BUFFER flag to inform that the buffers are from
|
|
||||||
* ION_SECURE. which should not be mapped. However, for GPU post proc
|
|
||||||
* feature, GFX needs to map this buffer, in the client context and in SF
|
|
||||||
* context, it should not. Hence to differentiate, add this metadata field
|
|
||||||
* for clients to set, and GPU will to read and know when to map the
|
|
||||||
* SECURE_BUFFER(ION) */
|
|
||||||
int32_t mapSecureBuffer;
|
|
||||||
/* The supported formats are defined in gralloc_priv.h to
|
|
||||||
* support legacy code*/
|
|
||||||
uint32_t s3dFormat;
|
|
||||||
/* VENUS output buffer is linear for UBWC Interlaced video */
|
|
||||||
uint32_t linearFormat;
|
|
||||||
/* Set by graphics to indicate that this buffer will be written to but not
|
|
||||||
* swapped out */
|
|
||||||
uint32_t isSingleBufferMode;
|
|
||||||
/* Set by camera to program the VT Timestamp */
|
|
||||||
uint64_t vtTimeStamp;
|
|
||||||
/* Color Aspects + HDR info */
|
|
||||||
ColorMetaData color;
|
|
||||||
/* Consumer should read this data as follows based on
|
|
||||||
* Gralloc flag "interlaced" listed above.
|
|
||||||
* [0] : If it is progressive.
|
|
||||||
* [0] : Top field, if it is interlaced.
|
|
||||||
* [1] : Do not read, if it is progressive.
|
|
||||||
* [1] : Bottom field, if it is interlaced.
|
|
||||||
*/
|
|
||||||
struct UBWCStats ubwcCRStats[2];
|
|
||||||
/* Set by camera to indicate that this buffer will be used for a High
|
|
||||||
* Performance Video Usecase */
|
|
||||||
uint32_t isVideoPerfMode;
|
|
||||||
/* Populated and used by adreno during buffer size calculation.
|
|
||||||
* Set only for RGB formats. */
|
|
||||||
GraphicsMetadata graphics_metadata;
|
|
||||||
/* Video hisogram stats populated by video decoder */
|
|
||||||
struct VideoHistogramMetadata video_histogram_stats;
|
|
||||||
/*
|
|
||||||
* Producer (camera) will set cvp metadata and consumer (video) will
|
|
||||||
* use it. The format of metadata is known to producer and consumer.
|
|
||||||
*/
|
|
||||||
CVPMetadata cvpMetadata;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DispParamType {
|
enum DispParamType {
|
||||||
@@ -214,6 +106,9 @@ enum DispFetchParamType {
|
|||||||
GET_VIDEO_HISTOGRAM_STATS = 0x00020000
|
GET_VIDEO_HISTOGRAM_STATS = 0x00020000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Frame type bit mask */
|
||||||
|
#define QD_SYNC_FRAME (0x1 << 0)
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user