blob: 6ae65c9bfbf1dbd7c14b583f0c118cb64030cdbe [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 __QTIGRALLOCMETADATA_H__
31#define __QTIGRALLOCMETADATA_H__
32
33#include <color_metadata.h>
Tharaga Balachandranaa640f72020-03-10 13:52:04 -040034
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -050035#define QTI_VT_TIMESTAMP 10000
36#define QTI_COLOR_METADATA 10001
37#define QTI_PP_PARAM_INTERLACED 10002
38#define QTI_VIDEO_PERF_MODE 10003
39#define QTI_GRAPHICS_METADATA 10004
40#define QTI_UBWC_CR_STATS_INFO 10005
41#define QTI_REFRESH_RATE 10006
42#define QTI_MAP_SECURE_BUFFER 10007
43#define QTI_LINEAR_FORMAT 10008
44#define QTI_SINGLE_BUFFER_MODE 10009
45#define QTI_CVP_METADATA 10010
46#define QTI_VIDEO_HISTOGRAM_STATS 10011
Tharaga Balachandranaa640f72020-03-10 13:52:04 -040047// File descriptor for allocated buffer
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -050048#define QTI_FD 10012
Tharaga Balachandranaa640f72020-03-10 13:52:04 -040049// Flags from the private handle of the allocated buffer
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -050050#define QTI_PRIVATE_FLAGS 10013
Tharaga Balachandranaa640f72020-03-10 13:52:04 -040051// Width of the allocated buffer in pixels
52#define QTI_ALIGNED_WIDTH_IN_PIXELS 10014
53// Height of the allocated buffer in pixels
54#define QTI_ALIGNED_HEIGHT_IN_PIXELS 10015
Tharaga Balachandran39810462020-06-16 09:34:34 -040055// Indicates whether metadata is using default value or has been set
56#define QTI_STANDARD_METADATA_STATUS 10016
57#define QTI_VENDOR_METADATA_STATUS 10017
Tharaga Balachandranbcd39b92020-04-22 16:40:30 -040058#define QTI_BUFFER_TYPE 10018
Shrikara B21c0d722020-08-27 18:23:10 +053059#define QTI_VIDEO_TS_INFO 10019
Baldev Sahu356869c2020-09-16 19:02:58 +053060// This is legacy format
61#define QTI_S3D_FORMAT 10020
Zube Molokwu10c74ab2020-11-06 15:41:40 -080062#define QTI_CUSTOM_DIMENSIONS_STRIDE 10021
63#define QTI_CUSTOM_DIMENSIONS_HEIGHT 10022
64#define QTI_RGB_DATA_ADDRESS 10023
65#define QTI_COLORSPACE 10024
66#define QTI_YUV_PLANE_INFO 10025
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -050067
68// Used to indicate to framework that internal definitions are used instead
69#define COMPRESSION_QTI_UBWC 20001
70#define INTERLACED_QTI 20002
71
72#define PLANE_COMPONENT_TYPE_RAW 20003
73#define PLANE_COMPONENT_TYPE_META 20004
74
75#define MAX_NAME_LEN 256
76
77// GRAPHICS_METADATA
78#define GRAPHICS_METADATA_SIZE 4096
Ravi Ranjanc74a80e2020-05-04 09:40:39 +053079#define GRAPHICS_METADATA_SIZE_IN_BYTES (GRAPHICS_METADATA_SIZE * sizeof(uint32_t))
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -050080typedef struct GraphicsMetadata {
Ravi Ranjanc74a80e2020-05-04 09:40:39 +053081 uint32_t size; //unused in Gralloc4, in Gralloc3 it was never returned on Get()
82 uint32_t data[GRAPHICS_METADATA_SIZE]; //Clients must set only raw data with Gralloc4
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -050083} GraphicsMetadata;
84
85// UBWC_CR_STATS_INFO
86#define MAX_UBWC_STATS_LENGTH 32
87enum UBWC_Version {
88 UBWC_UNUSED = 0,
89 UBWC_1_0 = 0x1,
90 UBWC_2_0 = 0x2,
91 UBWC_3_0 = 0x3,
92 UBWC_4_0 = 0x4,
93 UBWC_MAX_VERSION = 0xFF,
94};
95
96struct UBWC_2_0_Stats {
97 uint32_t nCRStatsTile32; /**< UBWC Stats info for 32 Byte Tile */
98 uint32_t nCRStatsTile64; /**< UBWC Stats info for 64 Byte Tile */
99 uint32_t nCRStatsTile96; /**< UBWC Stats info for 96 Byte Tile */
100 uint32_t nCRStatsTile128; /**< UBWC Stats info for 128 Byte Tile */
101 uint32_t nCRStatsTile160; /**< UBWC Stats info for 160 Byte Tile */
102 uint32_t nCRStatsTile192; /**< UBWC Stats info for 192 Byte Tile */
103 uint32_t nCRStatsTile256; /**< UBWC Stats info for 256 Byte Tile */
104};
105
106struct UBWCStats {
107 enum UBWC_Version version; /* Union depends on this version. */
108 uint8_t bDataValid; /* If [non-zero], CR Stats data is valid.
109 * Consumers may use stats data.
110 * If [zero], CR Stats data is invalid.
111 * Consumers *Shall* not use stats data */
112 union {
113 struct UBWC_2_0_Stats ubwc_stats;
114 uint32_t reserved[MAX_UBWC_STATS_LENGTH]; /* This is for future */
115 };
116};
117
118#define UBWC_STATS_ARRAY_SIZE 2
119struct CropRectangle_t {
120 int32_t left;
121 int32_t top;
122 int32_t right;
123 int32_t bottom;
124};
125
126// CVP_METADATA
127#define CVP_METADATA_SIZE 1024
128enum CVPMetadataFlags {
129 /* bit wise flags */
130 CVP_METADATA_FLAG_NONE = 0x00000000,
131 CVP_METADATA_FLAG_REPEAT = 0x00000001,
132};
133
134typedef struct CVPMetadata {
135 uint32_t size; /* payload size in bytes */
136 uint8_t payload[CVP_METADATA_SIZE];
137 uint32_t capture_frame_rate;
138 /* Frame rate in Q16 format.
139 Eg: fps = 7.5, then
140 capture_frame_rate = 7 << 16 --> Upper 16 bits to represent 7
141 capture_frame_rate |= 5 -------> Lower 16 bits to represent 5
142
143 If size > 0, framerate is valid
144 If size = 0, invalid data, so ignore all parameters */
145 uint32_t cvp_frame_rate;
146 enum CVPMetadataFlags flags;
147 uint32_t reserved[8];
148} CVPMetadata;
149
150// VIDEO_HISTOGRAM_STATS
151
152#define VIDEO_HISTOGRAM_STATS_SIZE (4 * 1024)
153struct VideoHistogramMetadata {
154 uint32_t stats_info[1024]; /* video stats payload */
155 uint32_t stat_len; /* Payload size in bytes */
156 uint32_t frame_type; /* bit mask to indicate frame type */
157 uint32_t display_width;
158 uint32_t display_height;
159 uint32_t decode_width;
160 uint32_t decode_height;
161 uint32_t reserved[12];
162};
163
Shrikara B21c0d722020-08-27 18:23:10 +0530164#define VIDEO_TIMESTAMP_INFO_SIZE 16
165struct VideoTimestampInfo {
166 uint32_t enable; /* Enable video timestamp info */
167 uint32_t frame_number; /* Frame number/counter */
168 int64_t frame_timestamp_us; /* Frame timestamp in us */
169};
170
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -0500171#define RESERVED_REGION_SIZE 4096
172typedef struct ReservedRegion {
173 uint32_t size;
174 uint8_t data[RESERVED_REGION_SIZE];
175} ReservedRegion;
176
Zube Molokwu10c74ab2020-11-06 15:41:40 -0800177#define YCBCR_LAYOUT_ARRAY_SIZE 2
178struct qti_ycbcr {
179 void *y;
180 void *cb;
181 void *cr;
182 uint32_t yStride;
183 uint32_t cStride;
184 uint32_t chromaStep;
185};
186
187/* Color Space Macros */
188#define HAL_CSC_ITU_R_601 0
189#define HAL_CSC_ITU_R_601_FR 1
190#define HAL_CSC_ITU_R_709 2
191#define HAL_CSC_ITU_R_2020 3
192#define HAL_CSC_ITU_R_2020_FR 4
193
Tharaga Balachandran39810462020-06-16 09:34:34 -0400194#define METADATA_SET_SIZE 512
195
196#define IS_VENDOR_METADATA_TYPE(x) (x >= QTI_VT_TIMESTAMP)
197
198#define GET_STANDARD_METADATA_STATUS_INDEX(x) x
199#define GET_VENDOR_METADATA_STATUS_INDEX(x) x - QTI_VT_TIMESTAMP
200
Tharaga Balachandrana069a7e2020-01-08 17:22:12 -0500201#endif //__QTIGRALLOCMETADATA_H__