replace common qcom sources with samsung ones

This commit is contained in:
SaschaNes
2025-08-12 22:13:00 +02:00
parent ba24dcded9
commit 6f7753de11
5682 changed files with 2450203 additions and 103634 deletions

View File

@@ -0,0 +1,193 @@
/*
* Copyright (c) 2020 The Linux Foundation. All rights reserved.
*
* Copyright (c) 2022, 2024 Qualcomm Innovation Center, Inc. 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.
*
* Changes from Qualcomm Innovation Center are provided under the following license:
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#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_FINGERPRINT_MASK = 0x00002000, // Samsung Fingerprint Mask Feature
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_TILE_RENDERED = 0x02000000,
PRIV_FLAGS_UBWC_ALIGNED = 0x08000000,
PRIV_FLAGS_UBWC_ALIGNED_PI = 0x40000000, // PI format
};
// Metadata
static 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);
int getMetadataState(void *buffer, uint32_t type);
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_VideoTranscodeStats = {VENDOR_QTI,
QTI_VIDEO_TRANSCODE_STATS};
static const MetadataType MetadataType_VideoTimestampInfo = {VENDOR_QTI, QTI_VIDEO_TS_INFO};
static const MetadataType MetadataType_VideoEarlyNotifyLineCount = {VENDOR_QTI,
QTI_EARLYNOTIFY_LINECOUNT};
static const MetadataType MetadataType_FD = {VENDOR_QTI, QTI_FD};
static const MetadataType MetadataType_PrivateFlags = {VENDOR_QTI, QTI_PRIVATE_FLAGS};
static const MetadataType MetadataType_AlignedWidthInPixels = {VENDOR_QTI,
QTI_ALIGNED_WIDTH_IN_PIXELS};
static const MetadataType MetadataType_AlignedHeightInPixels = {VENDOR_QTI,
QTI_ALIGNED_HEIGHT_IN_PIXELS};
static const MetadataType MetadataType_StandardMetadataStatus = {VENDOR_QTI,
QTI_STANDARD_METADATA_STATUS};
static const MetadataType MetadataType_VendorMetadataStatus = {VENDOR_QTI,
QTI_VENDOR_METADATA_STATUS};
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};
static const MetadataType MetadataType_BufferPermission = {VENDOR_QTI, QTI_BUFFER_PERMISSION};
static const MetadataType MetadataType_HeapName = {VENDOR_QTI, QTI_HEAP_NAME};
static const MetadataType MetadataType_MemHandle = {VENDOR_QTI, QTI_MEM_HANDLE};
static const MetadataType MetadataType_TimedRendering = {VENDOR_QTI, QTI_TIMED_RENDERING};
static const MetadataType MetadataType_CustomContentMetadata = {VENDOR_QTI,
QTI_CUSTOM_CONTENT_METADATA};
static const MetadataType MetadataType_BufferDequeueDuration = {VENDOR_QTI,
QTI_BUFFER_DEQUEUE_DURATION};
static const MetadataType MetadataType_MultiViewInfo = {VENDOR_QTI, QTI_MULTI_VIEW_INFO};
static const MetadataType MetadataType_BaseView = {VENDOR_QTI, QTI_BASE_VIEW};
// 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 decodeMetadataState(hidl_vec<uint8_t> &in, bool *out);
Error encodeMetadataState(bool *in, hidl_vec<uint8_t> *out);
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 decodeGraphicsMetadataRaw(hidl_vec<uint8_t> &in, void *out);
Error encodeGraphicsMetadataRaw(void *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);
Error decodeVideoTranscodeStatsMetadata(hidl_vec<uint8_t> &in, VideoTranscodeStatsMetadata *out);
Error encodeVideoTranscodeStatsMetadata(VideoTranscodeStatsMetadata &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);
Error decodeBufferPermission(hidl_vec<uint8_t> &in, BufferPermission *out);
Error encodeBufferPermission(BufferPermission *in, hidl_vec<uint8_t> *out);
Error decodeCustomContentMetadata(hidl_vec<uint8_t> &in, void *out);
Error encodeCustomContentMetadata(const void *in, hidl_vec<uint8_t> *out);
} // namespace qtigralloc
#endif //__QTIGRALLOC_H__

View File

@@ -0,0 +1,216 @@
/*
* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
*
* Copyright (c) 2022, 2024 Qualcomm Innovation Center, Inc. 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.
*/
/*
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#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)
/* unused legacy flags */
#define GRALLOC_USAGE_PRIVATE_MM_HEAP 0
#define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP 0
#define GRALLOC_USAGE_PRIVATE_10BIT_TP 0
/* This flag is set for HEIF usecase */
#define GRALLOC_USAGE_PRIVATE_HEIF (UINT32_C(1) << 27)
/* Samsung MaskView for FingerPrint in display */
#define GRALLOC_USAGE_PRIVATE_FINGERPRINT_MASK 1ULL << 34
/* This flag is used to indicate video NV21 format */
#define GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER 1ULL << 48
/* 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
/* This flag is set for WFD usecase */
#define GRALLOC_USAGE_PRIVATE_WFD 1ULL << 51
/* This flag indicates video HW usage */
#define GRALLOC_USAGE_PRIVATE_VIDEO_HW 1ULL << 52
/* This flag indicates trusted VM use case */
#define GRALLOC_USAGE_PRIVATE_TRUSTED_VM 1ULL << 53
/* This flag is used to indicate No UBWC-P support */
#define GRALLOC_USAGE_PRIVATE_NO_UBWC_P 1ULL << 54
/* This flag is used to indicate UBWC_NV124R format usage */
#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_4R 1ULL << 55
/* Bit 56 is reserved */
/* This flag is used to indicate UBWC - 2:1 compression ratio */
#define GRALLOC_USAGE_PRIVATE_UBWC_L_2_TO_1 1ULL << 57
/* This flag is used to indicate multiview use case */
#define GRALLOC_USAGE_PRIVATE_MULTIVIEW 1ULL << 58
/* This flag is used to indicate UBWC - 8:5 compression ratio */
#define GRALLOC_USAGE_PRIVATE_UBWC_L_8_TO_5 1ULL << 59
// 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 0x36 // HAL_PIXEL_FORMAT_YCBCR_P010
#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
#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_2_BATCH 0x128
#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_4_BATCH 0x129
#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_8_BATCH 0x130
#define HAL_PIXEL_FORMAT_NV12_FLEX_2_BATCH 0x140
#define HAL_PIXEL_FORMAT_NV12_FLEX_4_BATCH 0x141
#define HAL_PIXEL_FORMAT_NV12_FLEX_8_BATCH 0x142
// FSC Formats
#define HAL_PIXEL_FORMAT_RGB888_UBWC_FSC 0x131
#define HAL_PIXEL_FORMAT_RGB101010_UBWC_FSC 0x132
// 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_SP_4R_UBWC 0x7FA30C07
#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
/*Legacy Colorspace values - Values maps to ColorSpace_t in qdMetadata.h*/
#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 HAL_CSC_ITU_R_709_FR 5
enum { BUFFER_TYPE_UI = 0, BUFFER_TYPE_VIDEO };
#endif //__QTIGRALLOCDEFS_H__

View File

@@ -0,0 +1,244 @@
/*
* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
*
* Copyright (c) 2022, 2024 Qualcomm Innovation Center, Inc. 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.
*
* Changes from Qualcomm Innovation Center are provided under the following license:
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#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
// File descriptor for allocated buffer
#define QTI_FD 10012
// Flags from the private handle of the allocated buffer
#define QTI_PRIVATE_FLAGS 10013
// Width of the allocated buffer in pixels
#define QTI_ALIGNED_WIDTH_IN_PIXELS 10014
// Height of the allocated buffer in pixels
#define QTI_ALIGNED_HEIGHT_IN_PIXELS 10015
// Indicates whether metadata is using default value or has been set
#define QTI_STANDARD_METADATA_STATUS 10016
#define QTI_VENDOR_METADATA_STATUS 10017
#define QTI_BUFFER_TYPE 10018
#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
// Indicates buffer access permission of its client
#define QTI_BUFFER_PERMISSION 10026
#define QTI_MEM_HANDLE 10027
#define QTI_TIMED_RENDERING 10028
#define QTI_CUSTOM_CONTENT_METADATA 10029
// Video transcode metadata stat
#define QTI_VIDEO_TRANSCODE_STATS 10030
// Early Notify line count
#define QTI_EARLYNOTIFY_LINECOUNT 10031
// Heap Name
#define QTI_HEAP_NAME 10032
#define QTI_BUFFER_DEQUEUE_DURATION 10033
#define QTI_BASE_VIEW 10047
#define QTI_MULTI_VIEW_INFO 10048
// 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
#define GRAPHICS_METADATA_SIZE_IN_BYTES (GRAPHICS_METADATA_SIZE * sizeof(uint32_t))
typedef struct GraphicsMetadata {
uint32_t size; //unused in Gralloc4, in Gralloc3 it was never returned on Get()
uint32_t data[GRAPHICS_METADATA_SIZE]; //Clients must set only raw data with Gralloc4
} 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 VIDEO_TRANSCODE_STATS_SIZE 128 //32 payloads with 4 bytes each: 4x32 = 128
#define VIDEO_TRANSCODE_PAYLOAD_NUM 32
struct VideoTranscodeStatsMetadata {
uint32_t stats_info[VIDEO_TRANSCODE_PAYLOAD_NUM]; /* Transcode stats payload */
uint32_t stat_len; /* Full payload size in bytes */
};
#define VIDEO_TIMESTAMP_INFO_SIZE 16
struct VideoTimestampInfo {
uint32_t enable; /* Enable video timestamp info */
uint32_t frame_number; /* Frame number/counter */
int64_t frame_timestamp_us; /* Frame timestamp in us */
};
#define RESERVED_REGION_SIZE 4096
typedef struct ReservedRegion {
uint32_t size;
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;
};
enum BufferClient {
BUFFER_CLIENT_INVALID = -1,
BUFFER_CLIENT_DPU = 0,
BUFFER_CLIENT_UNTRUSTED_VM = 1,
BUFFER_CLIENT_TRUSTED_VM = 2,
BUFFER_CLIENT_MAX,
};
union BufferPermission {
struct {
uint8_t read : 1;
uint8_t write : 1;
uint8_t execute : 1;
};
uint8_t permission;
};
#define METADATA_SET_SIZE 512
#define IS_VENDOR_METADATA_TYPE(x) (x >= QTI_VT_TIMESTAMP)
#define GET_STANDARD_METADATA_STATUS_INDEX(x) x
#define GET_VENDOR_METADATA_STATUS_INDEX(x) x - QTI_VT_TIMESTAMP
enum : uint32_t {
QTI_PRIV_VIEW_MASK_PRIMARY = 0x00000001,
QTI_PRIV_VIEW_MASK_SECONDARY = 0x00000002,
QTI_PRIV_VIEW_MASK_PRIMARY_DEPTH = 0x00000004,
QTI_PRIV_VIEW_MASK_SECONDARY_DEPTH = 0x00000008,
};
#endif //__QTIGRALLOCMETADATA_H__

View File

@@ -0,0 +1,232 @@
/*
* Copyright (c) 2020 The Linux Foundation. All rights reserved.
*
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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.
*/
/*
* Changes from Qualcomm Innovation Center are provided under the following license:
*
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#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"
/*
*
* 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
*
*/
#define METADATA_V2
// 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 histogram 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;
bool isStandardMetadataSet[METADATA_SET_SIZE];
bool isVendorMetadataSet[METADATA_SET_SIZE];
uint64_t reservedSize;
VideoTimestampInfo videoTsInfo;
BufferPermission bufferPerm[BUFFER_CLIENT_MAX];
int64_t memHandle;
/* Set by clients to indicate that timed rendering will be enabled
* or disabled for this buffer. */
uint32_t timedRendering;
/* Video transcode stat populated by video decoder */
struct VideoTranscodeStatsMetadata video_transcode_stats;
int32_t videoEarlyNotifyLineCount;
char heapName[MAX_NAME_LEN];
/* Last buffer dequeue duration used by SmoMo to detect blocking */
int64_t bufferDequeueDuration;
};
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;
unsigned int reserved_size;
unsigned int custom_content_md_reserved_size;
static const int kNumFds = 2;
static const int kMagic = 'gmsm';
unsigned int linear_size;
int ubwcp_format;
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),
reserved_size(0),
custom_content_md_reserved_size(0),
linear_size(0),
ubwcp_format(format) {
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) {
ALOGW("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 reserved_size = %d "
"custom_content_md_reserved_size = %u",
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,
hnd->reserved_size, hnd->custom_content_md_reserved_size);
}
};
#pragma pack(pop)
} // namespace qtigralloc
#endif //__QTIGRALLOCPRIV_H__

View File

@@ -0,0 +1,18 @@
/*
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#include <cstdint>
#ifndef __COLOREXTENSIONS_H__
#define __COLOREXTENSIONS_H__
#define CUSTOM_METADATA_SIZE_BYTES 1024*42
typedef struct CustomContentMetadata {
uint64_t size;
uint8_t metadataPayload[CUSTOM_METADATA_SIZE_BYTES];
} CustomContentMetadata;
#endif // __COLOREXTENSIONS_H__

View File

@@ -0,0 +1,205 @@
/*
* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Changes from Qualcomm Innovation Center are provided under the following license:
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef __GR_PRIV_HANDLE_H__
#define __GR_PRIV_HANDLE_H__
#include <log/log.h>
#include <hardware/gralloc.h>
#include <hardware/gralloc1.h>
#ifdef __cplusplus
#include <cinttypes>
#endif
#define GRALLOC1_FUNCTION_PERFORM 0x00001000
#define DBG_HANDLE false
typedef gralloc1_error_t (*GRALLOC1_PFN_PERFORM)(gralloc1_device_t *device, int operation, ...);
#define PRIV_HANDLE_CONST(exp) static_cast<const private_handle_t *>(exp)
#pragma pack(push, 4)
#ifdef __cplusplus
struct private_handle_t : public native_handle_t {
#else
struct private_handle_t {
native_handle_t nativeHandle;
#endif
enum {
PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
PRIV_FLAGS_USES_ION = 0x00000008,
PRIV_FLAGS_NEEDS_FLUSH = 0x00000020,
PRIV_FLAGS_INTERNAL_ONLY = 0x00000040,
PRIV_FLAGS_NON_CPU_WRITER = 0x00000080,
PRIV_FLAGS_CACHED = 0x00000200,
PRIV_FLAGS_SECURE_BUFFER = 0x00000400,
PRIV_FLAGS_FINGERPRINT_MASK = 0x00002000, // Samsung replaced PRIV_FLAGS_EXTERNAL_ONLY = 0x00002000,
PRIV_FLAGS_PROTECTED_BUFFER = 0x00004000,
PRIV_FLAGS_VIDEO_ENCODER = 0x00010000,
PRIV_FLAGS_CAMERA_WRITE = 0x00020000,
PRIV_FLAGS_CAMERA_READ = 0x00040000,
PRIV_FLAGS_HW_COMPOSER = 0x00080000,
PRIV_FLAGS_HW_TEXTURE = 0x00100000,
PRIV_FLAGS_ITU_R_601 = 0x00200000, // Unused from display
PRIV_FLAGS_ITU_R_601_FR = 0x00400000, // Unused from display
PRIV_FLAGS_ITU_R_709 = 0x00800000, // Unused from display
PRIV_FLAGS_SECURE_DISPLAY = 0x01000000,
PRIV_FLAGS_TILE_RENDERED = 0x02000000,
PRIV_FLAGS_CPU_RENDERED = 0x04000000,
PRIV_FLAGS_UBWC_ALIGNED = 0x08000000,
PRIV_FLAGS_DISP_CONSUMER = 0x10000000,
PRIV_FLAGS_CLIENT_ALLOCATED = 0x20000000, // Ion buffer allocated outside of gralloc
PRIV_FLAGS_UBWC_ALIGNED_PI = 0x40000000, // PI format
};
// 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;
unsigned int reserved_size;
unsigned int custom_content_md_reserved_size;
#ifdef __cplusplus
static const int kNumFds = 2;
static const int kMagic = 'gmsm';
unsigned int linear_size;
int ubwcp_format;
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),
reserved_size(0),
custom_content_md_reserved_size(0),
linear_size(0),
ubwcp_format(format) {
version = static_cast<int>(sizeof(native_handle));
numInts = NumInts();
numFds = kNumFds;
}
// Legacy constructor used by some clients
private_handle_t(int fd, unsigned int size, int usage, int buf_type, int format, int w, int h)
: private_handle_t(fd, -1, PRIV_FLAGS_CLIENT_ALLOCATED, w, h, 0, 0, format, buf_type, size,
static_cast<uint64_t>(usage)) {}
~private_handle_t() {
magic = 0;
ALOGE_IF(DBG_HANDLE, "Deleting buffer handle %p", this);
}
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 -EINVAL;
}
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 -EINVAL;
}
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 reserved_size = %d "
"custom_content_md_reserved_size = %u",
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,
hnd->reserved_size, hnd->custom_content_md_reserved_size);
}
int GetUnalignedWidth() const { return unaligned_width; }
int GetUnalignedHeight() const { return unaligned_height; }
int GetColorFormat() const { return format; }
unsigned int GetLayerCount() const { return layer_count; }
int GetStride() const {
// In handle we currently store aligned width after allocation.
return width;
}
uint64_t GetUsage() const { return usage; }
uint64_t GetBackingstore() const { return id; }
#endif
};
#pragma pack(pop)
#endif // __GR_PRIV_HANDLE_H__

View File

@@ -0,0 +1,145 @@
/*
* Copyright (c) 2011-2021, The Linux Foundation. All rights reserved.
* Not a Contribution
*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Changes from Qualcomm Innovation Center are provided under the following license:
*
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
* disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
*/
/*
* Changes from Qualcomm Innovation Center are provided under the following license:
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef __GRALLOC_PRIV_H__
#define __GRALLOC_PRIV_H__
#include <errno.h>
#include <unistd.h>
#include "QtiGrallocDefs.h"
#include "gr_priv_handle.h"
#define GRALLOC_PROP_PREFIX "vendor.gralloc."
#define GRALLOC_PROP(prop_name) GRALLOC_PROP_PREFIX prop_name
#define DISABLE_UBWC_PROP GRALLOC_PROP("disable_ubwc")
#define DISABLE_AHARDWAREBUFFER_PROP GRALLOC_PROP("disable_ahardware_buffer")
#define ENABLE_FB_UBWC_PROP GRALLOC_PROP("enable_fb_ubwc")
#define MAP_FB_MEMORY_PROP GRALLOC_PROP("map_fb_memory")
#define USE_SYSTEM_HEAP_FOR_SENSORS GRALLOC_PROP("use_system_heap_for_sensors")
#define ROUND_UP_PAGESIZE(x) roundUpToPageSize(x)
inline size_t roundUpToPageSize(size_t x) {
return (x + ((size_t)(getpagesize()) - 1)) & ~((size_t)(getpagesize()) - 1);
}
/* Legacy gralloc1 definitions */
/* 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_ALLOC_UBWC GRALLOC_USAGE_PRIVATE_ALLOC_UBWC
#define GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED GRALLOC_USAGE_PRIVATE_UNCACHED
#define GRALLOC1_CONSUMER_USAGE_PRIVATE_SECURE_DISPLAY GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY
#define GRALLOC1_PRODUCER_USAGE_PRIVATE_MM_HEAP GRALLOC_USAGE_PRIVATE_MM_HEAP
#define GRALLOC1_PRODUCER_USAGE_PRIVATE_10BIT GRALLOC_USAGE_PRIVATE_10BIT
#define GRALLOC1_PRODUCER_USAGE_PRIVATE_10BIT_TP GRALLOC_USAGE_PRIVATE_10BIT_TP
#define GRALLOC1_CONSUMER_USAGE_PRIVATE_10BIT_TP GRALLOC_USAGE_PRIVATE_10BIT_TP
#define GRALLOC1_PRODUCER_USAGE_PRIVATE_VIDEO_NV21_ENCODER GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER
// for PERFORM API :
#define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1
#define GRALLOC_MODULE_PERFORM_GET_STRIDE 2
#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE 3
#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE 4
#define GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES 5
#define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6
#define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7
#define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8
#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9
#define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10
#define GRALLOC_MODULE_PERFORM_GET_IGC 11
#define GRALLOC_MODULE_PERFORM_SET_IGC 12
#define GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE 13
#define GRALLOC1_MODULE_PERFORM_GET_BUFFER_SIZE_AND_DIMENSIONS 14
#define GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG 15
#define GRALLOC_MODULE_PERFORM_GET_GRAPHICS_METADATA 16
/* possible values for inverse gamma correction */
#define HAL_IGC_NOT_SPECIFIED 0
#define HAL_IGC_s_RGB 1
/* Color Space: Values maps to ColorSpace_t in qdMetadata.h */
#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 HAL_CSC_ITU_R_709_FR 5
/* possible formats for 3D content*/
enum {
HAL_NO_3D = 0x0,
HAL_3D_SIDE_BY_SIDE_L_R = 0x1,
HAL_3D_SIDE_BY_SIDE_R_L = 0x2,
HAL_3D_TOP_BOTTOM = 0x4,
HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, // unused legacy format
};
/* Flag to determine interlaced content
* Value maps to Flags presents in types.hal of QtiMapperextensions
*/
enum {
LAYOUT_INTERLACED_FLAG = 1 << 0,
};
#endif // __GRALLOC_PRIV_H__