1d722e3fbSopenharmony_ci/*
2d722e3fbSopenharmony_ci * Copyright © 2014 Broadcom
3d722e3fbSopenharmony_ci *
4d722e3fbSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5d722e3fbSopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6d722e3fbSopenharmony_ci * to deal in the Software without restriction, including without limitation
7d722e3fbSopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8d722e3fbSopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9d722e3fbSopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10d722e3fbSopenharmony_ci *
11d722e3fbSopenharmony_ci * The above copyright notice and this permission notice (including the next
12d722e3fbSopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13d722e3fbSopenharmony_ci * Software.
14d722e3fbSopenharmony_ci *
15d722e3fbSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16d722e3fbSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17d722e3fbSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18d722e3fbSopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19d722e3fbSopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20d722e3fbSopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21d722e3fbSopenharmony_ci * IN THE SOFTWARE.
22d722e3fbSopenharmony_ci */
23d722e3fbSopenharmony_ci
24d722e3fbSopenharmony_ci#ifndef VC4_PACKET_H
25d722e3fbSopenharmony_ci#define VC4_PACKET_H
26d722e3fbSopenharmony_ci
27d722e3fbSopenharmony_cienum vc4_packet {
28d722e3fbSopenharmony_ci        VC4_PACKET_HALT = 0,
29d722e3fbSopenharmony_ci        VC4_PACKET_NOP = 1,
30d722e3fbSopenharmony_ci
31d722e3fbSopenharmony_ci        VC4_PACKET_FLUSH = 4,
32d722e3fbSopenharmony_ci        VC4_PACKET_FLUSH_ALL = 5,
33d722e3fbSopenharmony_ci        VC4_PACKET_START_TILE_BINNING = 6,
34d722e3fbSopenharmony_ci        VC4_PACKET_INCREMENT_SEMAPHORE = 7,
35d722e3fbSopenharmony_ci        VC4_PACKET_WAIT_ON_SEMAPHORE = 8,
36d722e3fbSopenharmony_ci
37d722e3fbSopenharmony_ci        VC4_PACKET_BRANCH = 16,
38d722e3fbSopenharmony_ci        VC4_PACKET_BRANCH_TO_SUB_LIST = 17,
39d722e3fbSopenharmony_ci        VC4_PACKET_RETURN_FROM_SUB_LIST = 18,
40d722e3fbSopenharmony_ci
41d722e3fbSopenharmony_ci        VC4_PACKET_STORE_MS_TILE_BUFFER = 24,
42d722e3fbSopenharmony_ci        VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF = 25,
43d722e3fbSopenharmony_ci        VC4_PACKET_STORE_FULL_RES_TILE_BUFFER = 26,
44d722e3fbSopenharmony_ci        VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER = 27,
45d722e3fbSopenharmony_ci        VC4_PACKET_STORE_TILE_BUFFER_GENERAL = 28,
46d722e3fbSopenharmony_ci        VC4_PACKET_LOAD_TILE_BUFFER_GENERAL = 29,
47d722e3fbSopenharmony_ci
48d722e3fbSopenharmony_ci        VC4_PACKET_GL_INDEXED_PRIMITIVE = 32,
49d722e3fbSopenharmony_ci        VC4_PACKET_GL_ARRAY_PRIMITIVE = 33,
50d722e3fbSopenharmony_ci
51d722e3fbSopenharmony_ci        VC4_PACKET_COMPRESSED_PRIMITIVE = 48,
52d722e3fbSopenharmony_ci        VC4_PACKET_CLIPPED_COMPRESSED_PRIMITIVE = 49,
53d722e3fbSopenharmony_ci
54d722e3fbSopenharmony_ci        VC4_PACKET_PRIMITIVE_LIST_FORMAT = 56,
55d722e3fbSopenharmony_ci
56d722e3fbSopenharmony_ci        VC4_PACKET_GL_SHADER_STATE = 64,
57d722e3fbSopenharmony_ci        VC4_PACKET_NV_SHADER_STATE = 65,
58d722e3fbSopenharmony_ci        VC4_PACKET_VG_SHADER_STATE = 66,
59d722e3fbSopenharmony_ci
60d722e3fbSopenharmony_ci        VC4_PACKET_CONFIGURATION_BITS = 96,
61d722e3fbSopenharmony_ci        VC4_PACKET_FLAT_SHADE_FLAGS = 97,
62d722e3fbSopenharmony_ci        VC4_PACKET_POINT_SIZE = 98,
63d722e3fbSopenharmony_ci        VC4_PACKET_LINE_WIDTH = 99,
64d722e3fbSopenharmony_ci        VC4_PACKET_RHT_X_BOUNDARY = 100,
65d722e3fbSopenharmony_ci        VC4_PACKET_DEPTH_OFFSET = 101,
66d722e3fbSopenharmony_ci        VC4_PACKET_CLIP_WINDOW = 102,
67d722e3fbSopenharmony_ci        VC4_PACKET_VIEWPORT_OFFSET = 103,
68d722e3fbSopenharmony_ci        VC4_PACKET_Z_CLIPPING = 104,
69d722e3fbSopenharmony_ci        VC4_PACKET_CLIPPER_XY_SCALING = 105,
70d722e3fbSopenharmony_ci        VC4_PACKET_CLIPPER_Z_SCALING = 106,
71d722e3fbSopenharmony_ci
72d722e3fbSopenharmony_ci        VC4_PACKET_TILE_BINNING_MODE_CONFIG = 112,
73d722e3fbSopenharmony_ci        VC4_PACKET_TILE_RENDERING_MODE_CONFIG = 113,
74d722e3fbSopenharmony_ci        VC4_PACKET_CLEAR_COLORS = 114,
75d722e3fbSopenharmony_ci        VC4_PACKET_TILE_COORDINATES = 115,
76d722e3fbSopenharmony_ci
77d722e3fbSopenharmony_ci        /* Not an actual hardware packet -- this is what we use to put
78d722e3fbSopenharmony_ci         * references to GEM bos in the command stream, since we need the u32
79d722e3fbSopenharmony_ci         * int the actual address packet in order to store the offset from the
80d722e3fbSopenharmony_ci         * start of the BO.
81d722e3fbSopenharmony_ci         */
82d722e3fbSopenharmony_ci        VC4_PACKET_GEM_HANDLES = 254,
83d722e3fbSopenharmony_ci} __attribute__ ((__packed__));
84d722e3fbSopenharmony_ci
85d722e3fbSopenharmony_ci#define VC4_PACKET_HALT_SIZE						1
86d722e3fbSopenharmony_ci#define VC4_PACKET_NOP_SIZE						1
87d722e3fbSopenharmony_ci#define VC4_PACKET_FLUSH_SIZE						1
88d722e3fbSopenharmony_ci#define VC4_PACKET_FLUSH_ALL_SIZE					1
89d722e3fbSopenharmony_ci#define VC4_PACKET_START_TILE_BINNING_SIZE				1
90d722e3fbSopenharmony_ci#define VC4_PACKET_INCREMENT_SEMAPHORE_SIZE				1
91d722e3fbSopenharmony_ci#define VC4_PACKET_WAIT_ON_SEMAPHORE_SIZE				1
92d722e3fbSopenharmony_ci#define VC4_PACKET_BRANCH_SIZE						5
93d722e3fbSopenharmony_ci#define VC4_PACKET_BRANCH_TO_SUB_LIST_SIZE				5
94d722e3fbSopenharmony_ci#define VC4_PACKET_RETURN_FROM_SUB_LIST_SIZE				1
95d722e3fbSopenharmony_ci#define VC4_PACKET_STORE_MS_TILE_BUFFER_SIZE				1
96d722e3fbSopenharmony_ci#define VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF_SIZE			1
97d722e3fbSopenharmony_ci#define VC4_PACKET_STORE_FULL_RES_TILE_BUFFER_SIZE			5
98d722e3fbSopenharmony_ci#define VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER_SIZE			5
99d722e3fbSopenharmony_ci#define VC4_PACKET_STORE_TILE_BUFFER_GENERAL_SIZE			7
100d722e3fbSopenharmony_ci#define VC4_PACKET_LOAD_TILE_BUFFER_GENERAL_SIZE			7
101d722e3fbSopenharmony_ci#define VC4_PACKET_GL_INDEXED_PRIMITIVE_SIZE				14
102d722e3fbSopenharmony_ci#define VC4_PACKET_GL_ARRAY_PRIMITIVE_SIZE				10
103d722e3fbSopenharmony_ci#define VC4_PACKET_COMPRESSED_PRIMITIVE_SIZE				1
104d722e3fbSopenharmony_ci#define VC4_PACKET_CLIPPED_COMPRESSED_PRIMITIVE_SIZE			1
105d722e3fbSopenharmony_ci#define VC4_PACKET_PRIMITIVE_LIST_FORMAT_SIZE				2
106d722e3fbSopenharmony_ci#define VC4_PACKET_GL_SHADER_STATE_SIZE					5
107d722e3fbSopenharmony_ci#define VC4_PACKET_NV_SHADER_STATE_SIZE					5
108d722e3fbSopenharmony_ci#define VC4_PACKET_VG_SHADER_STATE_SIZE					5
109d722e3fbSopenharmony_ci#define VC4_PACKET_CONFIGURATION_BITS_SIZE				4
110d722e3fbSopenharmony_ci#define VC4_PACKET_FLAT_SHADE_FLAGS_SIZE				5
111d722e3fbSopenharmony_ci#define VC4_PACKET_POINT_SIZE_SIZE					5
112d722e3fbSopenharmony_ci#define VC4_PACKET_LINE_WIDTH_SIZE					5
113d722e3fbSopenharmony_ci#define VC4_PACKET_RHT_X_BOUNDARY_SIZE					3
114d722e3fbSopenharmony_ci#define VC4_PACKET_DEPTH_OFFSET_SIZE					5
115d722e3fbSopenharmony_ci#define VC4_PACKET_CLIP_WINDOW_SIZE					9
116d722e3fbSopenharmony_ci#define VC4_PACKET_VIEWPORT_OFFSET_SIZE					5
117d722e3fbSopenharmony_ci#define VC4_PACKET_Z_CLIPPING_SIZE					9
118d722e3fbSopenharmony_ci#define VC4_PACKET_CLIPPER_XY_SCALING_SIZE				9
119d722e3fbSopenharmony_ci#define VC4_PACKET_CLIPPER_Z_SCALING_SIZE				9
120d722e3fbSopenharmony_ci#define VC4_PACKET_TILE_BINNING_MODE_CONFIG_SIZE			16
121d722e3fbSopenharmony_ci#define VC4_PACKET_TILE_RENDERING_MODE_CONFIG_SIZE			11
122d722e3fbSopenharmony_ci#define VC4_PACKET_CLEAR_COLORS_SIZE					14
123d722e3fbSopenharmony_ci#define VC4_PACKET_TILE_COORDINATES_SIZE				3
124d722e3fbSopenharmony_ci#define VC4_PACKET_GEM_HANDLES_SIZE					9
125d722e3fbSopenharmony_ci
126d722e3fbSopenharmony_ci#define VC4_MASK(high, low) (((1 << ((high) - (low) + 1)) - 1) << (low))
127d722e3fbSopenharmony_ci/* Using the GNU statement expression extension */
128d722e3fbSopenharmony_ci#define VC4_SET_FIELD(value, field)                                       \
129d722e3fbSopenharmony_ci        ({                                                                \
130d722e3fbSopenharmony_ci                uint32_t fieldval = (value) << field ## _SHIFT;		  \
131d722e3fbSopenharmony_ci                assert((fieldval & ~ field ## _MASK) == 0);               \
132d722e3fbSopenharmony_ci                fieldval & field ## _MASK;                                \
133d722e3fbSopenharmony_ci         })
134d722e3fbSopenharmony_ci
135d722e3fbSopenharmony_ci#define VC4_GET_FIELD(word, field) (((word)  & field ## _MASK) >> field ## _SHIFT)
136d722e3fbSopenharmony_ci
137d722e3fbSopenharmony_ci/** @{
138d722e3fbSopenharmony_ci * Bits used by packets like VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
139d722e3fbSopenharmony_ci * VC4_PACKET_TILE_RENDERING_MODE_CONFIG.
140d722e3fbSopenharmony_ci*/
141d722e3fbSopenharmony_ci#define VC4_TILING_FORMAT_LINEAR    0
142d722e3fbSopenharmony_ci#define VC4_TILING_FORMAT_T         1
143d722e3fbSopenharmony_ci#define VC4_TILING_FORMAT_LT        2
144d722e3fbSopenharmony_ci/** @} */
145d722e3fbSopenharmony_ci
146d722e3fbSopenharmony_ci/** @{
147d722e3fbSopenharmony_ci *
148d722e3fbSopenharmony_ci * low bits of VC4_PACKET_STORE_FULL_RES_TILE_BUFFER and
149d722e3fbSopenharmony_ci * VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER.
150d722e3fbSopenharmony_ci */
151d722e3fbSopenharmony_ci#define VC4_LOADSTORE_FULL_RES_EOF                     (1 << 3)
152d722e3fbSopenharmony_ci#define VC4_LOADSTORE_FULL_RES_DISABLE_CLEAR_ALL       (1 << 2)
153d722e3fbSopenharmony_ci#define VC4_LOADSTORE_FULL_RES_DISABLE_ZS              (1 << 1)
154d722e3fbSopenharmony_ci#define VC4_LOADSTORE_FULL_RES_DISABLE_COLOR           (1 << 0)
155d722e3fbSopenharmony_ci
156d722e3fbSopenharmony_ci/** @{
157d722e3fbSopenharmony_ci *
158d722e3fbSopenharmony_ci * byte 2 of VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
159d722e3fbSopenharmony_ci * VC4_PACKET_LOAD_TILE_BUFFER_GENERAL (low bits of the address)
160d722e3fbSopenharmony_ci */
161d722e3fbSopenharmony_ci
162d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_EOF                  (1 << 3)
163d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_DISABLE_FULL_VG_MASK (1 << 2)
164d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_DISABLE_FULL_ZS      (1 << 1)
165d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_DISABLE_FULL_COLOR   (1 << 0)
166d722e3fbSopenharmony_ci
167d722e3fbSopenharmony_ci/** @} */
168d722e3fbSopenharmony_ci
169d722e3fbSopenharmony_ci/** @{
170d722e3fbSopenharmony_ci *
171d722e3fbSopenharmony_ci * byte 0-1 of VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
172d722e3fbSopenharmony_ci * VC4_PACKET_LOAD_TILE_BUFFER_GENERAL
173d722e3fbSopenharmony_ci */
174d722e3fbSopenharmony_ci#define VC4_STORE_TILE_BUFFER_DISABLE_VG_MASK_CLEAR (1 << 15)
175d722e3fbSopenharmony_ci#define VC4_STORE_TILE_BUFFER_DISABLE_ZS_CLEAR     (1 << 14)
176d722e3fbSopenharmony_ci#define VC4_STORE_TILE_BUFFER_DISABLE_COLOR_CLEAR  (1 << 13)
177d722e3fbSopenharmony_ci#define VC4_STORE_TILE_BUFFER_DISABLE_SWAP         (1 << 12)
178d722e3fbSopenharmony_ci
179d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_FORMAT_MASK      VC4_MASK(9, 8)
180d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_FORMAT_SHIFT     8
181d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_RGBA8888         0
182d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_BGR565_DITHER    1
183d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_BGR565           2
184d722e3fbSopenharmony_ci/** @} */
185d722e3fbSopenharmony_ci
186d722e3fbSopenharmony_ci/** @{
187d722e3fbSopenharmony_ci *
188d722e3fbSopenharmony_ci * byte 0 of VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
189d722e3fbSopenharmony_ci * VC4_PACKET_LOAD_TILE_BUFFER_GENERAL
190d722e3fbSopenharmony_ci */
191d722e3fbSopenharmony_ci#define VC4_STORE_TILE_BUFFER_MODE_MASK            VC4_MASK(7, 6)
192d722e3fbSopenharmony_ci#define VC4_STORE_TILE_BUFFER_MODE_SHIFT           6
193d722e3fbSopenharmony_ci#define VC4_STORE_TILE_BUFFER_MODE_SAMPLE0         (0 << 6)
194d722e3fbSopenharmony_ci#define VC4_STORE_TILE_BUFFER_MODE_DECIMATE_X4     (1 << 6)
195d722e3fbSopenharmony_ci#define VC4_STORE_TILE_BUFFER_MODE_DECIMATE_X16    (2 << 6)
196d722e3fbSopenharmony_ci
197d722e3fbSopenharmony_ci/** The values of the field are VC4_TILING_FORMAT_* */
198d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_TILING_MASK      VC4_MASK(5, 4)
199d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_TILING_SHIFT     4
200d722e3fbSopenharmony_ci
201d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_BUFFER_MASK      VC4_MASK(2, 0)
202d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_BUFFER_SHIFT     0
203d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_NONE             0
204d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_COLOR            1
205d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_ZS               2
206d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_Z                3
207d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_VG_MASK          4
208d722e3fbSopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_FULL             5
209d722e3fbSopenharmony_ci/** @} */
210d722e3fbSopenharmony_ci
211d722e3fbSopenharmony_ci#define VC4_INDEX_BUFFER_U8                        (0 << 4)
212d722e3fbSopenharmony_ci#define VC4_INDEX_BUFFER_U16                       (1 << 4)
213d722e3fbSopenharmony_ci
214d722e3fbSopenharmony_ci/* This flag is only present in NV shader state. */
215d722e3fbSopenharmony_ci#define VC4_SHADER_FLAG_SHADED_CLIP_COORDS         (1 << 3)
216d722e3fbSopenharmony_ci#define VC4_SHADER_FLAG_ENABLE_CLIPPING            (1 << 2)
217d722e3fbSopenharmony_ci#define VC4_SHADER_FLAG_VS_POINT_SIZE              (1 << 1)
218d722e3fbSopenharmony_ci#define VC4_SHADER_FLAG_FS_SINGLE_THREAD           (1 << 0)
219d722e3fbSopenharmony_ci
220d722e3fbSopenharmony_ci/** @{ byte 2 of config bits. */
221d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_EARLY_Z_UPDATE             (1 << 1)
222d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_EARLY_Z                    (1 << 0)
223d722e3fbSopenharmony_ci/** @} */
224d722e3fbSopenharmony_ci
225d722e3fbSopenharmony_ci/** @{ byte 1 of config bits. */
226d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_Z_UPDATE                   (1 << 7)
227d722e3fbSopenharmony_ci/** same values in this 3-bit field as PIPE_FUNC_* */
228d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_DEPTH_FUNC_SHIFT           4
229d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_READ_LEAVE        (1 << 3)
230d722e3fbSopenharmony_ci
231d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_UPDATE_NONZERO    (0 << 1)
232d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_UPDATE_ODD        (1 << 1)
233d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_UPDATE_OR         (2 << 1)
234d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_UPDATE_ZERO       (3 << 1)
235d722e3fbSopenharmony_ci
236d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_PIPE_SELECT       (1 << 0)
237d722e3fbSopenharmony_ci/** @} */
238d722e3fbSopenharmony_ci
239d722e3fbSopenharmony_ci/** @{ byte 0 of config bits. */
240d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_NONE (0 << 6)
241d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_4X   (1 << 6)
242d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_16X  (2 << 6)
243d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_MASK (3 << 6)
244d722e3fbSopenharmony_ci
245d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_AA_POINTS_AND_LINES        (1 << 4)
246d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_ENABLE_DEPTH_OFFSET        (1 << 3)
247d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_CW_PRIMITIVES              (1 << 2)
248d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_ENABLE_PRIM_BACK           (1 << 1)
249d722e3fbSopenharmony_ci#define VC4_CONFIG_BITS_ENABLE_PRIM_FRONT          (1 << 0)
250d722e3fbSopenharmony_ci/** @} */
251d722e3fbSopenharmony_ci
252d722e3fbSopenharmony_ci/** @{ bits in the last u8 of VC4_PACKET_TILE_BINNING_MODE_CONFIG */
253d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_DB_NON_MS                   (1 << 7)
254d722e3fbSopenharmony_ci
255d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_MASK       VC4_MASK(6, 5)
256d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_SHIFT      5
257d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_32         0
258d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_64         1
259d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_128        2
260d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_256        3
261d722e3fbSopenharmony_ci
262d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_MASK  VC4_MASK(4, 3)
263d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_SHIFT 3
264d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_32    0
265d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_64    1
266d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_128   2
267d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_256   3
268d722e3fbSopenharmony_ci
269d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_AUTO_INIT_TSDA              (1 << 2)
270d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_TILE_BUFFER_64BIT           (1 << 1)
271d722e3fbSopenharmony_ci#define VC4_BIN_CONFIG_MS_MODE_4X                  (1 << 0)
272d722e3fbSopenharmony_ci/** @} */
273d722e3fbSopenharmony_ci
274d722e3fbSopenharmony_ci/** @{ bits in the last u16 of VC4_PACKET_TILE_RENDERING_MODE_CONFIG */
275d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_DB_NON_MS                (1 << 12)
276d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_EARLY_Z_COVERAGE_DISABLE (1 << 11)
277d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_EARLY_Z_DIRECTION_G      (1 << 10)
278d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_COVERAGE_MODE            (1 << 9)
279d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_ENABLE_VG_MASK           (1 << 8)
280d722e3fbSopenharmony_ci
281d722e3fbSopenharmony_ci/** The values of the field are VC4_TILING_FORMAT_* */
282d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_MEMORY_FORMAT_MASK       VC4_MASK(7, 6)
283d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_MEMORY_FORMAT_SHIFT      6
284d722e3fbSopenharmony_ci
285d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_DECIMATE_MODE_1X         (0 << 4)
286d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_DECIMATE_MODE_4X         (1 << 4)
287d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_DECIMATE_MODE_16X        (2 << 4)
288d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_DECIMATE_MODE_MASK       (3 << 4)
289d722e3fbSopenharmony_ci
290d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_FORMAT_MASK              VC4_MASK(3, 2)
291d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_FORMAT_SHIFT             2
292d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_FORMAT_BGR565_DITHERED   0
293d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_FORMAT_RGBA8888          1
294d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_FORMAT_BGR565            2
295d722e3fbSopenharmony_ci
296d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_TILE_BUFFER_64BIT        (1 << 1)
297d722e3fbSopenharmony_ci#define VC4_RENDER_CONFIG_MS_MODE_4X               (1 << 0)
298d722e3fbSopenharmony_ci
299d722e3fbSopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_16_INDEX         (1 << 4)
300d722e3fbSopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_32_XY            (3 << 4)
301d722e3fbSopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_POINTS      (0 << 0)
302d722e3fbSopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_LINES       (1 << 0)
303d722e3fbSopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_TRIANGLES   (2 << 0)
304d722e3fbSopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_RHT         (3 << 0)
305d722e3fbSopenharmony_ci
306d722e3fbSopenharmony_cienum vc4_texture_data_type {
307d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_RGBA8888 = 0,
308d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_RGBX8888 = 1,
309d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_RGBA4444 = 2,
310d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_RGBA5551 = 3,
311d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_RGB565 = 4,
312d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_LUMINANCE = 5,
313d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_ALPHA = 6,
314d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_LUMALPHA = 7,
315d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_ETC1 = 8,
316d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_S16F = 9,
317d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_S8 = 10,
318d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_S16 = 11,
319d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_BW1 = 12,
320d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_A4 = 13,
321d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_A1 = 14,
322d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_RGBA64 = 15,
323d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_RGBA32R = 16,
324d722e3fbSopenharmony_ci        VC4_TEXTURE_TYPE_YUV422R = 17,
325d722e3fbSopenharmony_ci};
326d722e3fbSopenharmony_ci
327d722e3fbSopenharmony_ci#define VC4_TEX_P0_OFFSET_MASK                     VC4_MASK(31, 12)
328d722e3fbSopenharmony_ci#define VC4_TEX_P0_OFFSET_SHIFT                    12
329d722e3fbSopenharmony_ci#define VC4_TEX_P0_CSWIZ_MASK                      VC4_MASK(11, 10)
330d722e3fbSopenharmony_ci#define VC4_TEX_P0_CSWIZ_SHIFT                     10
331d722e3fbSopenharmony_ci#define VC4_TEX_P0_CMMODE_MASK                     VC4_MASK(9, 9)
332d722e3fbSopenharmony_ci#define VC4_TEX_P0_CMMODE_SHIFT                    9
333d722e3fbSopenharmony_ci#define VC4_TEX_P0_FLIPY_MASK                      VC4_MASK(8, 8)
334d722e3fbSopenharmony_ci#define VC4_TEX_P0_FLIPY_SHIFT                     8
335d722e3fbSopenharmony_ci#define VC4_TEX_P0_TYPE_MASK                       VC4_MASK(7, 4)
336d722e3fbSopenharmony_ci#define VC4_TEX_P0_TYPE_SHIFT                      4
337d722e3fbSopenharmony_ci#define VC4_TEX_P0_MIPLVLS_MASK                    VC4_MASK(3, 0)
338d722e3fbSopenharmony_ci#define VC4_TEX_P0_MIPLVLS_SHIFT                   0
339d722e3fbSopenharmony_ci
340d722e3fbSopenharmony_ci#define VC4_TEX_P1_TYPE4_MASK                      VC4_MASK(31, 31)
341d722e3fbSopenharmony_ci#define VC4_TEX_P1_TYPE4_SHIFT                     31
342d722e3fbSopenharmony_ci#define VC4_TEX_P1_HEIGHT_MASK                     VC4_MASK(30, 20)
343d722e3fbSopenharmony_ci#define VC4_TEX_P1_HEIGHT_SHIFT                    20
344d722e3fbSopenharmony_ci#define VC4_TEX_P1_ETCFLIP_MASK                    VC4_MASK(19, 19)
345d722e3fbSopenharmony_ci#define VC4_TEX_P1_ETCFLIP_SHIFT                   19
346d722e3fbSopenharmony_ci#define VC4_TEX_P1_WIDTH_MASK                      VC4_MASK(18, 8)
347d722e3fbSopenharmony_ci#define VC4_TEX_P1_WIDTH_SHIFT                     8
348d722e3fbSopenharmony_ci
349d722e3fbSopenharmony_ci#define VC4_TEX_P1_MAGFILT_MASK                    VC4_MASK(7, 7)
350d722e3fbSopenharmony_ci#define VC4_TEX_P1_MAGFILT_SHIFT                   7
351d722e3fbSopenharmony_ci# define VC4_TEX_P1_MAGFILT_LINEAR                 0
352d722e3fbSopenharmony_ci# define VC4_TEX_P1_MAGFILT_NEAREST                1
353d722e3fbSopenharmony_ci
354d722e3fbSopenharmony_ci#define VC4_TEX_P1_MINFILT_MASK                    VC4_MASK(6, 4)
355d722e3fbSopenharmony_ci#define VC4_TEX_P1_MINFILT_SHIFT                   4
356d722e3fbSopenharmony_ci# define VC4_TEX_P1_MINFILT_LINEAR                 0
357d722e3fbSopenharmony_ci# define VC4_TEX_P1_MINFILT_NEAREST                1
358d722e3fbSopenharmony_ci# define VC4_TEX_P1_MINFILT_NEAR_MIP_NEAR          2
359d722e3fbSopenharmony_ci# define VC4_TEX_P1_MINFILT_NEAR_MIP_LIN           3
360d722e3fbSopenharmony_ci# define VC4_TEX_P1_MINFILT_LIN_MIP_NEAR           4
361d722e3fbSopenharmony_ci# define VC4_TEX_P1_MINFILT_LIN_MIP_LIN            5
362d722e3fbSopenharmony_ci
363d722e3fbSopenharmony_ci#define VC4_TEX_P1_WRAP_T_MASK                     VC4_MASK(3, 2)
364d722e3fbSopenharmony_ci#define VC4_TEX_P1_WRAP_T_SHIFT                    2
365d722e3fbSopenharmony_ci#define VC4_TEX_P1_WRAP_S_MASK                     VC4_MASK(1, 0)
366d722e3fbSopenharmony_ci#define VC4_TEX_P1_WRAP_S_SHIFT                    0
367d722e3fbSopenharmony_ci# define VC4_TEX_P1_WRAP_REPEAT                    0
368d722e3fbSopenharmony_ci# define VC4_TEX_P1_WRAP_CLAMP                     1
369d722e3fbSopenharmony_ci# define VC4_TEX_P1_WRAP_MIRROR                    2
370d722e3fbSopenharmony_ci# define VC4_TEX_P1_WRAP_BORDER                    3
371d722e3fbSopenharmony_ci
372d722e3fbSopenharmony_ci#define VC4_TEX_P2_PTYPE_MASK                      VC4_MASK(31, 30)
373d722e3fbSopenharmony_ci#define VC4_TEX_P2_PTYPE_SHIFT                     30
374d722e3fbSopenharmony_ci# define VC4_TEX_P2_PTYPE_IGNORED                  0
375d722e3fbSopenharmony_ci# define VC4_TEX_P2_PTYPE_CUBE_MAP_STRIDE          1
376d722e3fbSopenharmony_ci# define VC4_TEX_P2_PTYPE_CHILD_IMAGE_DIMENSIONS   2
377d722e3fbSopenharmony_ci# define VC4_TEX_P2_PTYPE_CHILD_IMAGE_OFFSETS      3
378d722e3fbSopenharmony_ci
379d722e3fbSopenharmony_ci/* VC4_TEX_P2_PTYPE_CUBE_MAP_STRIDE bits */
380d722e3fbSopenharmony_ci#define VC4_TEX_P2_CMST_MASK                       VC4_MASK(29, 12)
381d722e3fbSopenharmony_ci#define VC4_TEX_P2_CMST_SHIFT                      12
382d722e3fbSopenharmony_ci#define VC4_TEX_P2_BSLOD_MASK                      VC4_MASK(0, 0)
383d722e3fbSopenharmony_ci#define VC4_TEX_P2_BSLOD_SHIFT                     0
384d722e3fbSopenharmony_ci
385d722e3fbSopenharmony_ci/* VC4_TEX_P2_PTYPE_CHILD_IMAGE_DIMENSIONS */
386d722e3fbSopenharmony_ci#define VC4_TEX_P2_CHEIGHT_MASK                    VC4_MASK(22, 12)
387d722e3fbSopenharmony_ci#define VC4_TEX_P2_CHEIGHT_SHIFT                   12
388d722e3fbSopenharmony_ci#define VC4_TEX_P2_CWIDTH_MASK                     VC4_MASK(10, 0)
389d722e3fbSopenharmony_ci#define VC4_TEX_P2_CWIDTH_SHIFT                    0
390d722e3fbSopenharmony_ci
391d722e3fbSopenharmony_ci/* VC4_TEX_P2_PTYPE_CHILD_IMAGE_OFFSETS */
392d722e3fbSopenharmony_ci#define VC4_TEX_P2_CYOFF_MASK                      VC4_MASK(22, 12)
393d722e3fbSopenharmony_ci#define VC4_TEX_P2_CYOFF_SHIFT                     12
394d722e3fbSopenharmony_ci#define VC4_TEX_P2_CXOFF_MASK                      VC4_MASK(10, 0)
395d722e3fbSopenharmony_ci#define VC4_TEX_P2_CXOFF_SHIFT                     0
396d722e3fbSopenharmony_ci
397d722e3fbSopenharmony_ci#endif /* VC4_PACKET_H */
398