2 * Copyright © 2014 Broadcom
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #ifndef VC4_QPU_DEFINES_H
25 #define VC4_QPU_DEFINES_H
66 QPU_R_FRAG_PAYLOAD_ZW
= 15, /* W for A file, Z for B file */
67 /* 0-31 are the plain regfile a or b fields */
72 QPU_R_XY_PIXEL_COORD
= 41,
73 QPU_R_MS_REV_FLAGS
= 42,
81 /* 0-31 are the plain regfile a or b fields */
82 QPU_W_ACC0
= 32, /* aka r0 */
90 QPU_W_UNIFORMS_ADDRESS
,
91 QPU_W_QUAD_XY
, /* X for regfile a, Y for regfile b */
94 QPU_W_TLB_STENCIL_SETUP
= 43,
100 QPU_W_VPMVCD_SETUP
, /* LD for regfile a, ST for regfile b */
101 QPU_W_VPM_ADDR
, /* LD for regfile a, ST for regfile b */
118 QPU_SIG_SW_BREAKPOINT
,
120 QPU_SIG_THREAD_SWITCH
,
122 QPU_SIG_WAIT_FOR_SCOREBOARD
,
123 QPU_SIG_SCOREBOARD_UNLOCK
,
124 QPU_SIG_LAST_THREAD_SWITCH
,
125 QPU_SIG_COVERAGE_LOAD
,
127 QPU_SIG_COLOR_LOAD_END
,
130 QPU_SIG_ALPHA_MASK_LOAD
,
137 /* hardware mux values */
148 * Non-hardware mux value, stores a small immediate field to be
149 * programmed into raddr_b in the qpu_reg.index.
167 QPU_PACK_MUL_8888
= 3, /* replicated to each 8 bits of the 32-bit dst. */
176 /* convert to 16 bit float if float input, or to int16. */
179 /* replicated to each 8 bits of the 32-bit dst. */
181 /* Convert to 8-bit unsigned int. */
187 /* Saturating variants of the previous instructions. */
188 QPU_PACK_A_32_SAT
, /* int-only */
189 QPU_PACK_A_16A_SAT
, /* int or float */
209 #define QPU_MASK(high, low) ((((uint64_t)1<<((high)-(low)+1))-1)<<(low))
210 /* Using the GNU statement expression extension */
211 #define QPU_SET_FIELD(value, field) \
213 uint64_t fieldval = (uint64_t)(value) << field ## _SHIFT; \
214 assert((fieldval & ~ field ## _MASK) == 0); \
215 fieldval & field ## _MASK; \
218 #define QPU_GET_FIELD(word, field) ((uint32_t)(((word) & field ## _MASK) >> field ## _SHIFT))
220 #define QPU_UPDATE_FIELD(inst, value, field) \
221 (((inst) & ~(field ## _MASK)) | QPU_SET_FIELD(value, field))
223 #define QPU_SIG_SHIFT 60
224 #define QPU_SIG_MASK QPU_MASK(63, 60)
226 #define QPU_UNPACK_SHIFT 57
227 #define QPU_UNPACK_MASK QPU_MASK(59, 57)
230 * If set, the pack field means PACK_MUL or R4 packing, instead of normal
233 #define QPU_PM ((uint64_t)1 << 56)
235 #define QPU_PACK_SHIFT 52
236 #define QPU_PACK_MASK QPU_MASK(55, 52)
238 #define QPU_COND_ADD_SHIFT 49
239 #define QPU_COND_ADD_MASK QPU_MASK(51, 49)
240 #define QPU_COND_MUL_SHIFT 46
241 #define QPU_COND_MUL_MASK QPU_MASK(48, 46)
243 #define QPU_SF ((uint64_t)1 << 45)
245 #define QPU_WADDR_ADD_SHIFT 38
246 #define QPU_WADDR_ADD_MASK QPU_MASK(43, 38)
247 #define QPU_WADDR_MUL_SHIFT 32
248 #define QPU_WADDR_MUL_MASK QPU_MASK(37, 32)
250 #define QPU_OP_MUL_SHIFT 29
251 #define QPU_OP_MUL_MASK QPU_MASK(31, 29)
253 #define QPU_RADDR_A_SHIFT 18
254 #define QPU_RADDR_A_MASK QPU_MASK(23, 18)
255 #define QPU_RADDR_B_SHIFT 12
256 #define QPU_RADDR_B_MASK QPU_MASK(17, 12)
257 #define QPU_SMALL_IMM_SHIFT 12
258 #define QPU_SMALL_IMM_MASK QPU_MASK(17, 12)
260 #define QPU_ADD_A_SHIFT 9
261 #define QPU_ADD_A_MASK QPU_MASK(11, 9)
262 #define QPU_ADD_B_SHIFT 6
263 #define QPU_ADD_B_MASK QPU_MASK(8, 6)
264 #define QPU_MUL_A_SHIFT 3
265 #define QPU_MUL_A_MASK QPU_MASK(5, 3)
266 #define QPU_MUL_B_SHIFT 0
267 #define QPU_MUL_B_MASK QPU_MASK(2, 0)
269 #define QPU_WS ((uint64_t)1 << 44)
271 #define QPU_OP_ADD_SHIFT 24
272 #define QPU_OP_ADD_MASK QPU_MASK(28, 24)
274 #endif /* VC4_QPU_DEFINES_H */