blob: 08053cc8f92c852963aa3155db76d528cf443057 [file] [log] [blame]
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -05001/*
2 * Copyright (c) 2020 The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation. nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef __QTIGRALLOC_H__
31#define __QTIGRALLOC_H__
32
33#include <android/hardware/graphics/mapper/4.0/IMapper.h>
34#include <gralloctypes/Gralloc4.h>
35#include <hidl/HidlSupport.h>
36#include <stdint.h>
37
38#include <string>
39
40#include "QtiGrallocDefs.h"
41#include "QtiGrallocMetadata.h"
42
43namespace qtigralloc {
44using android::sp;
45using android::hardware::hidl_vec;
46using MetadataType = android::hardware::graphics::mapper::V4_0::IMapper::MetadataType;
47using android::hardware::graphics::mapper::V4_0::Error;
48// from gr_priv_handle.h
49enum {
50 PRIV_FLAGS_USES_ION = 0x00000008,
51 PRIV_FLAGS_NEEDS_FLUSH = 0x00000020,
52 PRIV_FLAGS_NON_CPU_WRITER = 0x00000080,
53 PRIV_FLAGS_CACHED = 0x00000200,
54 PRIV_FLAGS_SECURE_BUFFER = 0x00000400,
55 PRIV_FLAGS_VIDEO_ENCODER = 0x00010000,
56 PRIV_FLAGS_CAMERA_WRITE = 0x00020000,
57 PRIV_FLAGS_CAMERA_READ = 0x00040000,
58 PRIV_FLAGS_HW_TEXTURE = 0x00100000,
59 PRIV_FLAGS_SECURE_DISPLAY = 0x01000000,
60 PRIV_FLAGS_UBWC_ALIGNED = 0x08000000,
61 PRIV_FLAGS_UBWC_ALIGNED_PI = 0x40000000, // PI format
62};
63
64// Metadata
Yichi Chenbddad072020-03-23 12:50:12 +080065static const std::string VENDOR_QTI = "QTI";
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -050066
67Error get(void *buffer, uint32_t type, void *param);
68Error set(void *buffer, uint32_t type, void *param);
69MetadataType getMetadataType(uint32_t in);
70
71static const MetadataType MetadataType_VTTimestamp = {VENDOR_QTI, QTI_VT_TIMESTAMP};
72
73static const MetadataType MetadataType_ColorMetadata = {VENDOR_QTI, QTI_COLOR_METADATA};
74
75static const MetadataType MetadataType_PPParamInterlaced = {VENDOR_QTI, QTI_PP_PARAM_INTERLACED};
76
77static const MetadataType MetadataType_VideoPerfMode = {VENDOR_QTI, QTI_VIDEO_PERF_MODE};
78
79static const MetadataType MetadataType_GraphicsMetadata = {VENDOR_QTI, QTI_GRAPHICS_METADATA};
80
81static const MetadataType MetadataType_UBWCCRStatsInfo = {VENDOR_QTI, QTI_UBWC_CR_STATS_INFO};
82
83static const MetadataType MetadataType_RefreshRate = {VENDOR_QTI, QTI_REFRESH_RATE};
84static const MetadataType MetadataType_MapSecureBuffer = {VENDOR_QTI, QTI_MAP_SECURE_BUFFER};
85
86static const MetadataType MetadataType_LinearFormat = {VENDOR_QTI, QTI_LINEAR_FORMAT};
87
88static const MetadataType MetadataType_SingleBufferMode = {VENDOR_QTI, QTI_SINGLE_BUFFER_MODE};
89
90static const MetadataType MetadataType_CVPMetadata = {VENDOR_QTI, QTI_CVP_METADATA};
91
92static const MetadataType MetadataType_VideoHistogramStats = {VENDOR_QTI,
93 QTI_VIDEO_HISTOGRAM_STATS};
94
95static const MetadataType MetadataType_FD = {VENDOR_QTI, QTI_FD};
96
97static const MetadataType MetadataType_PrivateFlags = {VENDOR_QTI, QTI_PRIVATE_FLAGS};
98
Tharaga Balachandranaa640f72020-03-10 13:52:04 -040099static const MetadataType MetadataType_AlignedWidthInPixels = {VENDOR_QTI,
100 QTI_ALIGNED_WIDTH_IN_PIXELS};
101
102static const MetadataType MetadataType_AlignedHeightInPixels = {VENDOR_QTI,
103 QTI_ALIGNED_HEIGHT_IN_PIXELS};
104
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -0500105// 0 is also used as invalid value in standard metadata
106static const MetadataType MetadataType_Invalid = {VENDOR_QTI, 0};
107
108static const aidl::android::hardware::graphics::common::ExtendableType Compression_QtiUBWC = {
109 VENDOR_QTI, COMPRESSION_QTI_UBWC};
110static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_Qti = {
111 VENDOR_QTI, INTERLACED_QTI};
112
113static const aidl::android::hardware::graphics::common::ExtendableType
114 PlaneLayoutComponentType_Raw = {VENDOR_QTI, PLANE_COMPONENT_TYPE_RAW};
115static const aidl::android::hardware::graphics::common::ExtendableType
116 PlaneLayoutComponentType_Meta = {VENDOR_QTI, PLANE_COMPONENT_TYPE_META};
117
118Error decodeColorMetadata(hidl_vec<uint8_t> &in, ColorMetaData *out);
119Error encodeColorMetadata(ColorMetaData &in, hidl_vec<uint8_t> *out);
120Error decodeGraphicsMetadata(hidl_vec<uint8_t> &in, GraphicsMetadata *out);
121Error encodeGraphicsMetadata(GraphicsMetadata &in, hidl_vec<uint8_t> *out);
122Error decodeUBWCStats(hidl_vec<uint8_t> &in, UBWCStats *out);
123Error encodeUBWCStats(UBWCStats *in, hidl_vec<uint8_t> *out);
124Error decodeCVPMetadata(hidl_vec<uint8_t> &in, CVPMetadata *out);
125Error encodeCVPMetadata(CVPMetadata &in, hidl_vec<uint8_t> *out);
126Error decodeVideoHistogramMetadata(hidl_vec<uint8_t> &in, VideoHistogramMetadata *out);
127Error encodeVideoHistogramMetadata(VideoHistogramMetadata &in, hidl_vec<uint8_t> *out);
128
129} // namespace qtigralloc
130
131#endif //__QTIGRALLOC_H__