18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright © 2014 Broadcom
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next
128c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
138c2ecf20Sopenharmony_ci * Software.
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
168c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
188c2ecf20Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
198c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
208c2ecf20Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
218c2ecf20Sopenharmony_ci * IN THE SOFTWARE.
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#ifndef VC4_PACKET_H
258c2ecf20Sopenharmony_ci#define VC4_PACKET_H
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#include "vc4_regs.h" /* for VC4_MASK, VC4_GET_FIELD, VC4_SET_FIELD */
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cienum vc4_packet {
308c2ecf20Sopenharmony_ci	VC4_PACKET_HALT = 0,
318c2ecf20Sopenharmony_ci	VC4_PACKET_NOP = 1,
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	VC4_PACKET_FLUSH = 4,
348c2ecf20Sopenharmony_ci	VC4_PACKET_FLUSH_ALL = 5,
358c2ecf20Sopenharmony_ci	VC4_PACKET_START_TILE_BINNING = 6,
368c2ecf20Sopenharmony_ci	VC4_PACKET_INCREMENT_SEMAPHORE = 7,
378c2ecf20Sopenharmony_ci	VC4_PACKET_WAIT_ON_SEMAPHORE = 8,
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	VC4_PACKET_BRANCH = 16,
408c2ecf20Sopenharmony_ci	VC4_PACKET_BRANCH_TO_SUB_LIST = 17,
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	VC4_PACKET_STORE_MS_TILE_BUFFER = 24,
438c2ecf20Sopenharmony_ci	VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF = 25,
448c2ecf20Sopenharmony_ci	VC4_PACKET_STORE_FULL_RES_TILE_BUFFER = 26,
458c2ecf20Sopenharmony_ci	VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER = 27,
468c2ecf20Sopenharmony_ci	VC4_PACKET_STORE_TILE_BUFFER_GENERAL = 28,
478c2ecf20Sopenharmony_ci	VC4_PACKET_LOAD_TILE_BUFFER_GENERAL = 29,
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	VC4_PACKET_GL_INDEXED_PRIMITIVE = 32,
508c2ecf20Sopenharmony_ci	VC4_PACKET_GL_ARRAY_PRIMITIVE = 33,
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	VC4_PACKET_COMPRESSED_PRIMITIVE = 48,
538c2ecf20Sopenharmony_ci	VC4_PACKET_CLIPPED_COMPRESSED_PRIMITIVE = 49,
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	VC4_PACKET_PRIMITIVE_LIST_FORMAT = 56,
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	VC4_PACKET_GL_SHADER_STATE = 64,
588c2ecf20Sopenharmony_ci	VC4_PACKET_NV_SHADER_STATE = 65,
598c2ecf20Sopenharmony_ci	VC4_PACKET_VG_SHADER_STATE = 66,
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	VC4_PACKET_CONFIGURATION_BITS = 96,
628c2ecf20Sopenharmony_ci	VC4_PACKET_FLAT_SHADE_FLAGS = 97,
638c2ecf20Sopenharmony_ci	VC4_PACKET_POINT_SIZE = 98,
648c2ecf20Sopenharmony_ci	VC4_PACKET_LINE_WIDTH = 99,
658c2ecf20Sopenharmony_ci	VC4_PACKET_RHT_X_BOUNDARY = 100,
668c2ecf20Sopenharmony_ci	VC4_PACKET_DEPTH_OFFSET = 101,
678c2ecf20Sopenharmony_ci	VC4_PACKET_CLIP_WINDOW = 102,
688c2ecf20Sopenharmony_ci	VC4_PACKET_VIEWPORT_OFFSET = 103,
698c2ecf20Sopenharmony_ci	VC4_PACKET_Z_CLIPPING = 104,
708c2ecf20Sopenharmony_ci	VC4_PACKET_CLIPPER_XY_SCALING = 105,
718c2ecf20Sopenharmony_ci	VC4_PACKET_CLIPPER_Z_SCALING = 106,
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	VC4_PACKET_TILE_BINNING_MODE_CONFIG = 112,
748c2ecf20Sopenharmony_ci	VC4_PACKET_TILE_RENDERING_MODE_CONFIG = 113,
758c2ecf20Sopenharmony_ci	VC4_PACKET_CLEAR_COLORS = 114,
768c2ecf20Sopenharmony_ci	VC4_PACKET_TILE_COORDINATES = 115,
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci	/* Not an actual hardware packet -- this is what we use to put
798c2ecf20Sopenharmony_ci	 * references to GEM bos in the command stream, since we need the u32
808c2ecf20Sopenharmony_ci	 * int the actual address packet in order to store the offset from the
818c2ecf20Sopenharmony_ci	 * start of the BO.
828c2ecf20Sopenharmony_ci	 */
838c2ecf20Sopenharmony_ci	VC4_PACKET_GEM_HANDLES = 254,
848c2ecf20Sopenharmony_ci} __attribute__ ((__packed__));
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define VC4_PACKET_HALT_SIZE						1
878c2ecf20Sopenharmony_ci#define VC4_PACKET_NOP_SIZE						1
888c2ecf20Sopenharmony_ci#define VC4_PACKET_FLUSH_SIZE						1
898c2ecf20Sopenharmony_ci#define VC4_PACKET_FLUSH_ALL_SIZE					1
908c2ecf20Sopenharmony_ci#define VC4_PACKET_START_TILE_BINNING_SIZE				1
918c2ecf20Sopenharmony_ci#define VC4_PACKET_INCREMENT_SEMAPHORE_SIZE				1
928c2ecf20Sopenharmony_ci#define VC4_PACKET_WAIT_ON_SEMAPHORE_SIZE				1
938c2ecf20Sopenharmony_ci#define VC4_PACKET_BRANCH_SIZE						5
948c2ecf20Sopenharmony_ci#define VC4_PACKET_BRANCH_TO_SUB_LIST_SIZE				5
958c2ecf20Sopenharmony_ci#define VC4_PACKET_STORE_MS_TILE_BUFFER_SIZE				1
968c2ecf20Sopenharmony_ci#define VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF_SIZE			1
978c2ecf20Sopenharmony_ci#define VC4_PACKET_STORE_FULL_RES_TILE_BUFFER_SIZE			5
988c2ecf20Sopenharmony_ci#define VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER_SIZE			5
998c2ecf20Sopenharmony_ci#define VC4_PACKET_STORE_TILE_BUFFER_GENERAL_SIZE			7
1008c2ecf20Sopenharmony_ci#define VC4_PACKET_LOAD_TILE_BUFFER_GENERAL_SIZE			7
1018c2ecf20Sopenharmony_ci#define VC4_PACKET_GL_INDEXED_PRIMITIVE_SIZE				14
1028c2ecf20Sopenharmony_ci#define VC4_PACKET_GL_ARRAY_PRIMITIVE_SIZE				10
1038c2ecf20Sopenharmony_ci#define VC4_PACKET_COMPRESSED_PRIMITIVE_SIZE				1
1048c2ecf20Sopenharmony_ci#define VC4_PACKET_CLIPPED_COMPRESSED_PRIMITIVE_SIZE			1
1058c2ecf20Sopenharmony_ci#define VC4_PACKET_PRIMITIVE_LIST_FORMAT_SIZE				2
1068c2ecf20Sopenharmony_ci#define VC4_PACKET_GL_SHADER_STATE_SIZE					5
1078c2ecf20Sopenharmony_ci#define VC4_PACKET_NV_SHADER_STATE_SIZE					5
1088c2ecf20Sopenharmony_ci#define VC4_PACKET_VG_SHADER_STATE_SIZE					5
1098c2ecf20Sopenharmony_ci#define VC4_PACKET_CONFIGURATION_BITS_SIZE				4
1108c2ecf20Sopenharmony_ci#define VC4_PACKET_FLAT_SHADE_FLAGS_SIZE				5
1118c2ecf20Sopenharmony_ci#define VC4_PACKET_POINT_SIZE_SIZE					5
1128c2ecf20Sopenharmony_ci#define VC4_PACKET_LINE_WIDTH_SIZE					5
1138c2ecf20Sopenharmony_ci#define VC4_PACKET_RHT_X_BOUNDARY_SIZE					3
1148c2ecf20Sopenharmony_ci#define VC4_PACKET_DEPTH_OFFSET_SIZE					5
1158c2ecf20Sopenharmony_ci#define VC4_PACKET_CLIP_WINDOW_SIZE					9
1168c2ecf20Sopenharmony_ci#define VC4_PACKET_VIEWPORT_OFFSET_SIZE					5
1178c2ecf20Sopenharmony_ci#define VC4_PACKET_Z_CLIPPING_SIZE					9
1188c2ecf20Sopenharmony_ci#define VC4_PACKET_CLIPPER_XY_SCALING_SIZE				9
1198c2ecf20Sopenharmony_ci#define VC4_PACKET_CLIPPER_Z_SCALING_SIZE				9
1208c2ecf20Sopenharmony_ci#define VC4_PACKET_TILE_BINNING_MODE_CONFIG_SIZE			16
1218c2ecf20Sopenharmony_ci#define VC4_PACKET_TILE_RENDERING_MODE_CONFIG_SIZE			11
1228c2ecf20Sopenharmony_ci#define VC4_PACKET_CLEAR_COLORS_SIZE					14
1238c2ecf20Sopenharmony_ci#define VC4_PACKET_TILE_COORDINATES_SIZE				3
1248c2ecf20Sopenharmony_ci#define VC4_PACKET_GEM_HANDLES_SIZE					9
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci/* Number of multisamples supported. */
1278c2ecf20Sopenharmony_ci#define VC4_MAX_SAMPLES							4
1288c2ecf20Sopenharmony_ci/* Size of a full resolution color or Z tile buffer load/store. */
1298c2ecf20Sopenharmony_ci#define VC4_TILE_BUFFER_SIZE			(64 * 64 * 4)
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/** @{
1328c2ecf20Sopenharmony_ci * Bits used by packets like VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
1338c2ecf20Sopenharmony_ci * VC4_PACKET_TILE_RENDERING_MODE_CONFIG.
1348c2ecf20Sopenharmony_ci*/
1358c2ecf20Sopenharmony_ci#define VC4_TILING_FORMAT_LINEAR    0
1368c2ecf20Sopenharmony_ci#define VC4_TILING_FORMAT_T         1
1378c2ecf20Sopenharmony_ci#define VC4_TILING_FORMAT_LT        2
1388c2ecf20Sopenharmony_ci/** @} */
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci/** @{
1418c2ecf20Sopenharmony_ci *
1428c2ecf20Sopenharmony_ci * low bits of VC4_PACKET_STORE_FULL_RES_TILE_BUFFER and
1438c2ecf20Sopenharmony_ci * VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER.
1448c2ecf20Sopenharmony_ci */
1458c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_FULL_RES_EOF                     BIT(3)
1468c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_FULL_RES_DISABLE_CLEAR_ALL       BIT(2)
1478c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_FULL_RES_DISABLE_ZS              BIT(1)
1488c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_FULL_RES_DISABLE_COLOR           BIT(0)
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci/** @{
1518c2ecf20Sopenharmony_ci *
1528c2ecf20Sopenharmony_ci * low bits of VC4_PACKET_STORE_FULL_RES_TILE_BUFFER and
1538c2ecf20Sopenharmony_ci * VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER.
1548c2ecf20Sopenharmony_ci */
1558c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_FULL_RES_EOF                     BIT(3)
1568c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_FULL_RES_DISABLE_CLEAR_ALL       BIT(2)
1578c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_FULL_RES_DISABLE_ZS              BIT(1)
1588c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_FULL_RES_DISABLE_COLOR           BIT(0)
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci/** @{
1618c2ecf20Sopenharmony_ci *
1628c2ecf20Sopenharmony_ci * byte 2 of VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
1638c2ecf20Sopenharmony_ci * VC4_PACKET_LOAD_TILE_BUFFER_GENERAL (low bits of the address)
1648c2ecf20Sopenharmony_ci */
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_EOF                  BIT(3)
1678c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_DISABLE_FULL_VG_MASK BIT(2)
1688c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_DISABLE_FULL_ZS      BIT(1)
1698c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_DISABLE_FULL_COLOR   BIT(0)
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci/** @} */
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci/** @{
1748c2ecf20Sopenharmony_ci *
1758c2ecf20Sopenharmony_ci * byte 0-1 of VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
1768c2ecf20Sopenharmony_ci * VC4_PACKET_LOAD_TILE_BUFFER_GENERAL
1778c2ecf20Sopenharmony_ci */
1788c2ecf20Sopenharmony_ci#define VC4_STORE_TILE_BUFFER_DISABLE_VG_MASK_CLEAR BIT(15)
1798c2ecf20Sopenharmony_ci#define VC4_STORE_TILE_BUFFER_DISABLE_ZS_CLEAR     BIT(14)
1808c2ecf20Sopenharmony_ci#define VC4_STORE_TILE_BUFFER_DISABLE_COLOR_CLEAR  BIT(13)
1818c2ecf20Sopenharmony_ci#define VC4_STORE_TILE_BUFFER_DISABLE_SWAP         BIT(12)
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_FORMAT_MASK      VC4_MASK(9, 8)
1848c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_FORMAT_SHIFT     8
1858c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_RGBA8888         0
1868c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_BGR565_DITHER    1
1878c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_BGR565           2
1888c2ecf20Sopenharmony_ci/** @} */
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci/** @{
1918c2ecf20Sopenharmony_ci *
1928c2ecf20Sopenharmony_ci * byte 0 of VC4_PACKET_STORE_TILE_BUFFER_GENERAL and
1938c2ecf20Sopenharmony_ci * VC4_PACKET_LOAD_TILE_BUFFER_GENERAL
1948c2ecf20Sopenharmony_ci */
1958c2ecf20Sopenharmony_ci#define VC4_STORE_TILE_BUFFER_MODE_MASK            VC4_MASK(7, 6)
1968c2ecf20Sopenharmony_ci#define VC4_STORE_TILE_BUFFER_MODE_SHIFT           6
1978c2ecf20Sopenharmony_ci#define VC4_STORE_TILE_BUFFER_MODE_SAMPLE0         (0 << 6)
1988c2ecf20Sopenharmony_ci#define VC4_STORE_TILE_BUFFER_MODE_DECIMATE_X4     (1 << 6)
1998c2ecf20Sopenharmony_ci#define VC4_STORE_TILE_BUFFER_MODE_DECIMATE_X16    (2 << 6)
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci/** The values of the field are VC4_TILING_FORMAT_* */
2028c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_TILING_MASK      VC4_MASK(5, 4)
2038c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_TILING_SHIFT     4
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_BUFFER_MASK      VC4_MASK(2, 0)
2068c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_BUFFER_SHIFT     0
2078c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_NONE             0
2088c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_COLOR            1
2098c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_ZS               2
2108c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_Z                3
2118c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_VG_MASK          4
2128c2ecf20Sopenharmony_ci#define VC4_LOADSTORE_TILE_BUFFER_FULL             5
2138c2ecf20Sopenharmony_ci/** @} */
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci#define VC4_INDEX_BUFFER_U8                        (0 << 4)
2168c2ecf20Sopenharmony_ci#define VC4_INDEX_BUFFER_U16                       (1 << 4)
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci/* This flag is only present in NV shader state. */
2198c2ecf20Sopenharmony_ci#define VC4_SHADER_FLAG_SHADED_CLIP_COORDS         BIT(3)
2208c2ecf20Sopenharmony_ci#define VC4_SHADER_FLAG_ENABLE_CLIPPING            BIT(2)
2218c2ecf20Sopenharmony_ci#define VC4_SHADER_FLAG_VS_POINT_SIZE              BIT(1)
2228c2ecf20Sopenharmony_ci#define VC4_SHADER_FLAG_FS_SINGLE_THREAD           BIT(0)
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci/** @{ byte 2 of config bits. */
2258c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_EARLY_Z_UPDATE             BIT(1)
2268c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_EARLY_Z                    BIT(0)
2278c2ecf20Sopenharmony_ci/** @} */
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci/** @{ byte 1 of config bits. */
2308c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_Z_UPDATE                   BIT(7)
2318c2ecf20Sopenharmony_ci/** same values in this 3-bit field as PIPE_FUNC_* */
2328c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_DEPTH_FUNC_SHIFT           4
2338c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_READ_LEAVE        BIT(3)
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_UPDATE_NONZERO    (0 << 1)
2368c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_UPDATE_ODD        (1 << 1)
2378c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_UPDATE_OR         (2 << 1)
2388c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_UPDATE_ZERO       (3 << 1)
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_COVERAGE_PIPE_SELECT       BIT(0)
2418c2ecf20Sopenharmony_ci/** @} */
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci/** @{ byte 0 of config bits. */
2448c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_NONE (0 << 6)
2458c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_4X   (1 << 6)
2468c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_16X  (2 << 6)
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_AA_POINTS_AND_LINES        BIT(4)
2498c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_ENABLE_DEPTH_OFFSET        BIT(3)
2508c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_CW_PRIMITIVES              BIT(2)
2518c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_ENABLE_PRIM_BACK           BIT(1)
2528c2ecf20Sopenharmony_ci#define VC4_CONFIG_BITS_ENABLE_PRIM_FRONT          BIT(0)
2538c2ecf20Sopenharmony_ci/** @} */
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci/** @{ bits in the last u8 of VC4_PACKET_TILE_BINNING_MODE_CONFIG */
2568c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_DB_NON_MS                   BIT(7)
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_MASK       VC4_MASK(6, 5)
2598c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_SHIFT      5
2608c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_32         0
2618c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_64         1
2628c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_128        2
2638c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_256        3
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_MASK  VC4_MASK(4, 3)
2668c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_SHIFT 3
2678c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_32    0
2688c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_64    1
2698c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_128   2
2708c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_256   3
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_AUTO_INIT_TSDA              BIT(2)
2738c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_TILE_BUFFER_64BIT           BIT(1)
2748c2ecf20Sopenharmony_ci#define VC4_BIN_CONFIG_MS_MODE_4X                  BIT(0)
2758c2ecf20Sopenharmony_ci/** @} */
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci/** @{ bits in the last u16 of VC4_PACKET_TILE_RENDERING_MODE_CONFIG */
2788c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_DB_NON_MS                BIT(12)
2798c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_EARLY_Z_COVERAGE_DISABLE BIT(11)
2808c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_EARLY_Z_DIRECTION_G      BIT(10)
2818c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_COVERAGE_MODE            BIT(9)
2828c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_ENABLE_VG_MASK           BIT(8)
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci/** The values of the field are VC4_TILING_FORMAT_* */
2858c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_MEMORY_FORMAT_MASK       VC4_MASK(7, 6)
2868c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_MEMORY_FORMAT_SHIFT      6
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_DECIMATE_MODE_1X         (0 << 4)
2898c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_DECIMATE_MODE_4X         (1 << 4)
2908c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_DECIMATE_MODE_16X        (2 << 4)
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_FORMAT_MASK              VC4_MASK(3, 2)
2938c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_FORMAT_SHIFT             2
2948c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_FORMAT_BGR565_DITHERED   0
2958c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_FORMAT_RGBA8888          1
2968c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_FORMAT_BGR565            2
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_TILE_BUFFER_64BIT        BIT(1)
2998c2ecf20Sopenharmony_ci#define VC4_RENDER_CONFIG_MS_MODE_4X               BIT(0)
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_16_INDEX         (1 << 4)
3028c2ecf20Sopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_32_XY            (3 << 4)
3038c2ecf20Sopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_POINTS      (0 << 0)
3048c2ecf20Sopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_LINES       (1 << 0)
3058c2ecf20Sopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_TRIANGLES   (2 << 0)
3068c2ecf20Sopenharmony_ci#define VC4_PRIMITIVE_LIST_FORMAT_TYPE_RHT         (3 << 0)
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_cienum vc4_texture_data_type {
3098c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_RGBA8888 = 0,
3108c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_RGBX8888 = 1,
3118c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_RGBA4444 = 2,
3128c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_RGBA5551 = 3,
3138c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_RGB565 = 4,
3148c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_LUMINANCE = 5,
3158c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_ALPHA = 6,
3168c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_LUMALPHA = 7,
3178c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_ETC1 = 8,
3188c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_S16F = 9,
3198c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_S8 = 10,
3208c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_S16 = 11,
3218c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_BW1 = 12,
3228c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_A4 = 13,
3238c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_A1 = 14,
3248c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_RGBA64 = 15,
3258c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_RGBA32R = 16,
3268c2ecf20Sopenharmony_ci	VC4_TEXTURE_TYPE_YUV422R = 17,
3278c2ecf20Sopenharmony_ci};
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci#define VC4_TEX_P0_OFFSET_MASK                     VC4_MASK(31, 12)
3308c2ecf20Sopenharmony_ci#define VC4_TEX_P0_OFFSET_SHIFT                    12
3318c2ecf20Sopenharmony_ci#define VC4_TEX_P0_CSWIZ_MASK                      VC4_MASK(11, 10)
3328c2ecf20Sopenharmony_ci#define VC4_TEX_P0_CSWIZ_SHIFT                     10
3338c2ecf20Sopenharmony_ci#define VC4_TEX_P0_CMMODE_MASK                     VC4_MASK(9, 9)
3348c2ecf20Sopenharmony_ci#define VC4_TEX_P0_CMMODE_SHIFT                    9
3358c2ecf20Sopenharmony_ci#define VC4_TEX_P0_FLIPY_MASK                      VC4_MASK(8, 8)
3368c2ecf20Sopenharmony_ci#define VC4_TEX_P0_FLIPY_SHIFT                     8
3378c2ecf20Sopenharmony_ci#define VC4_TEX_P0_TYPE_MASK                       VC4_MASK(7, 4)
3388c2ecf20Sopenharmony_ci#define VC4_TEX_P0_TYPE_SHIFT                      4
3398c2ecf20Sopenharmony_ci#define VC4_TEX_P0_MIPLVLS_MASK                    VC4_MASK(3, 0)
3408c2ecf20Sopenharmony_ci#define VC4_TEX_P0_MIPLVLS_SHIFT                   0
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci#define VC4_TEX_P1_TYPE4_MASK                      VC4_MASK(31, 31)
3438c2ecf20Sopenharmony_ci#define VC4_TEX_P1_TYPE4_SHIFT                     31
3448c2ecf20Sopenharmony_ci#define VC4_TEX_P1_HEIGHT_MASK                     VC4_MASK(30, 20)
3458c2ecf20Sopenharmony_ci#define VC4_TEX_P1_HEIGHT_SHIFT                    20
3468c2ecf20Sopenharmony_ci#define VC4_TEX_P1_ETCFLIP_MASK                    VC4_MASK(19, 19)
3478c2ecf20Sopenharmony_ci#define VC4_TEX_P1_ETCFLIP_SHIFT                   19
3488c2ecf20Sopenharmony_ci#define VC4_TEX_P1_WIDTH_MASK                      VC4_MASK(18, 8)
3498c2ecf20Sopenharmony_ci#define VC4_TEX_P1_WIDTH_SHIFT                     8
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci#define VC4_TEX_P1_MAGFILT_MASK                    VC4_MASK(7, 7)
3528c2ecf20Sopenharmony_ci#define VC4_TEX_P1_MAGFILT_SHIFT                   7
3538c2ecf20Sopenharmony_ci# define VC4_TEX_P1_MAGFILT_LINEAR                 0
3548c2ecf20Sopenharmony_ci# define VC4_TEX_P1_MAGFILT_NEAREST                1
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci#define VC4_TEX_P1_MINFILT_MASK                    VC4_MASK(6, 4)
3578c2ecf20Sopenharmony_ci#define VC4_TEX_P1_MINFILT_SHIFT                   4
3588c2ecf20Sopenharmony_ci# define VC4_TEX_P1_MINFILT_LINEAR                 0
3598c2ecf20Sopenharmony_ci# define VC4_TEX_P1_MINFILT_NEAREST                1
3608c2ecf20Sopenharmony_ci# define VC4_TEX_P1_MINFILT_NEAR_MIP_NEAR          2
3618c2ecf20Sopenharmony_ci# define VC4_TEX_P1_MINFILT_NEAR_MIP_LIN           3
3628c2ecf20Sopenharmony_ci# define VC4_TEX_P1_MINFILT_LIN_MIP_NEAR           4
3638c2ecf20Sopenharmony_ci# define VC4_TEX_P1_MINFILT_LIN_MIP_LIN            5
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci#define VC4_TEX_P1_WRAP_T_MASK                     VC4_MASK(3, 2)
3668c2ecf20Sopenharmony_ci#define VC4_TEX_P1_WRAP_T_SHIFT                    2
3678c2ecf20Sopenharmony_ci#define VC4_TEX_P1_WRAP_S_MASK                     VC4_MASK(1, 0)
3688c2ecf20Sopenharmony_ci#define VC4_TEX_P1_WRAP_S_SHIFT                    0
3698c2ecf20Sopenharmony_ci# define VC4_TEX_P1_WRAP_REPEAT                    0
3708c2ecf20Sopenharmony_ci# define VC4_TEX_P1_WRAP_CLAMP                     1
3718c2ecf20Sopenharmony_ci# define VC4_TEX_P1_WRAP_MIRROR                    2
3728c2ecf20Sopenharmony_ci# define VC4_TEX_P1_WRAP_BORDER                    3
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci#define VC4_TEX_P2_PTYPE_MASK                      VC4_MASK(31, 30)
3758c2ecf20Sopenharmony_ci#define VC4_TEX_P2_PTYPE_SHIFT                     30
3768c2ecf20Sopenharmony_ci# define VC4_TEX_P2_PTYPE_IGNORED                  0
3778c2ecf20Sopenharmony_ci# define VC4_TEX_P2_PTYPE_CUBE_MAP_STRIDE          1
3788c2ecf20Sopenharmony_ci# define VC4_TEX_P2_PTYPE_CHILD_IMAGE_DIMENSIONS   2
3798c2ecf20Sopenharmony_ci# define VC4_TEX_P2_PTYPE_CHILD_IMAGE_OFFSETS      3
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci/* VC4_TEX_P2_PTYPE_CUBE_MAP_STRIDE bits */
3828c2ecf20Sopenharmony_ci#define VC4_TEX_P2_CMST_MASK                       VC4_MASK(29, 12)
3838c2ecf20Sopenharmony_ci#define VC4_TEX_P2_CMST_SHIFT                      12
3848c2ecf20Sopenharmony_ci#define VC4_TEX_P2_BSLOD_MASK                      VC4_MASK(0, 0)
3858c2ecf20Sopenharmony_ci#define VC4_TEX_P2_BSLOD_SHIFT                     0
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_ci/* VC4_TEX_P2_PTYPE_CHILD_IMAGE_DIMENSIONS */
3888c2ecf20Sopenharmony_ci#define VC4_TEX_P2_CHEIGHT_MASK                    VC4_MASK(22, 12)
3898c2ecf20Sopenharmony_ci#define VC4_TEX_P2_CHEIGHT_SHIFT                   12
3908c2ecf20Sopenharmony_ci#define VC4_TEX_P2_CWIDTH_MASK                     VC4_MASK(10, 0)
3918c2ecf20Sopenharmony_ci#define VC4_TEX_P2_CWIDTH_SHIFT                    0
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci/* VC4_TEX_P2_PTYPE_CHILD_IMAGE_OFFSETS */
3948c2ecf20Sopenharmony_ci#define VC4_TEX_P2_CYOFF_MASK                      VC4_MASK(22, 12)
3958c2ecf20Sopenharmony_ci#define VC4_TEX_P2_CYOFF_SHIFT                     12
3968c2ecf20Sopenharmony_ci#define VC4_TEX_P2_CXOFF_MASK                      VC4_MASK(10, 0)
3978c2ecf20Sopenharmony_ci#define VC4_TEX_P2_CXOFF_SHIFT                     0
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_ci#endif /* VC4_PACKET_H */
400