diff options
Diffstat (limited to 'lib/mesa/src/gallium/drivers/freedreno/a6xx/fd6_pack.h')
-rw-r--r-- | lib/mesa/src/gallium/drivers/freedreno/a6xx/fd6_pack.h | 209 |
1 files changed, 73 insertions, 136 deletions
diff --git a/lib/mesa/src/gallium/drivers/freedreno/a6xx/fd6_pack.h b/lib/mesa/src/gallium/drivers/freedreno/a6xx/fd6_pack.h index f6d1fbf09..b3b9bf924 100644 --- a/lib/mesa/src/gallium/drivers/freedreno/a6xx/fd6_pack.h +++ b/lib/mesa/src/gallium/drivers/freedreno/a6xx/fd6_pack.h @@ -27,149 +27,86 @@ #include "a6xx.xml.h" struct fd_reg_pair { - uint32_t reg; - uint64_t value; - struct fd_bo *bo; - bool is_address; - bool bo_write; - uint32_t bo_offset; - uint32_t bo_shift; + uint32_t reg; + uint64_t value; + struct fd_bo *bo; + bool is_address; + bool bo_write; + uint32_t bo_offset; + uint32_t bo_shift; }; #define __bo_type struct fd_bo * #include "a6xx-pack.xml.h" -#include "adreno-pm4-pack.xml.h" -#define __assert_eq(a, b) \ - do { \ - if ((a) != (b)) { \ - fprintf(stderr, "assert failed: " #a " (0x%x) != " #b " (0x%x)\n", a, \ - b); \ - assert((a) == (b)); \ - } \ - } while (0) +#define __assert_eq(a, b) \ + do { \ + if ((a) != (b)) { \ + fprintf(stderr, "assert failed: " #a " (0x%x) != " #b " (0x%x)\n", a, b); \ + assert((a) == (b)); \ + } \ + } while (0) -#if !FD_BO_NO_HARDPIN -# error 'Hardpin unsupported' -#endif +#define __ONE_REG(i, ...) \ + do { \ + const struct fd_reg_pair regs[] = { __VA_ARGS__ }; \ + if (i < ARRAY_SIZE(regs) && regs[i].reg > 0) { \ + __assert_eq(regs[0].reg + i, regs[i].reg); \ + if (regs[i].bo) { \ + struct fd_reloc reloc = { \ + .bo = regs[i].bo, \ + .flags = FD_RELOC_READ | \ + (regs[i].bo_write ? FD_RELOC_WRITE : 0), \ + \ + .offset = regs[i].bo_offset, \ + .or = regs[i].value, \ + .shift = regs[i].bo_shift, \ + .orhi = regs[i].value >> 32 \ + }; \ + ring->cur = p; \ + p += 2; \ + fd_ringbuffer_reloc(ring, &reloc); \ + } else { \ + *p++ = regs[i].value; \ + if (regs[i].is_address) \ + *p++ = regs[i].value >> 32; \ + } \ + } \ + } while (0) -#define __ONE_REG(i, ...) \ - do { \ - const struct fd_reg_pair regs[] = {__VA_ARGS__}; \ - /* NOTE: allow regs[0].reg==0, this happens in OUT_PKT() */ \ - if (i < ARRAY_SIZE(regs) && (i == 0 || regs[i].reg > 0)) { \ - __assert_eq(regs[0].reg + i, regs[i].reg); \ - if (regs[i].bo) { \ - uint64_t *p64 = (uint64_t *)p; \ - *p64 = __reloc_iova(regs[i].bo, regs[i].bo_offset, regs[i].value, \ - regs[i].bo_shift); \ - p += 2; \ - fd_ringbuffer_attach_bo(ring, regs[i].bo); \ - } else { \ - *p++ = regs[i].value; \ - if (regs[i].is_address) \ - *p++ = regs[i].value >> 32; \ - } \ - } \ - } while (0) - -#define OUT_REG(ring, ...) \ - do { \ - const struct fd_reg_pair regs[] = {__VA_ARGS__}; \ - unsigned count = ARRAY_SIZE(regs); \ - \ - STATIC_ASSERT(ARRAY_SIZE(regs) > 0); \ - STATIC_ASSERT(ARRAY_SIZE(regs) <= 16); \ - \ - BEGIN_RING(ring, count + 1); \ - uint32_t *p = ring->cur; \ - *p++ = pm4_pkt4_hdr(regs[0].reg, count); \ - \ - __ONE_REG(0, __VA_ARGS__); \ - __ONE_REG(1, __VA_ARGS__); \ - __ONE_REG(2, __VA_ARGS__); \ - __ONE_REG(3, __VA_ARGS__); \ - __ONE_REG(4, __VA_ARGS__); \ - __ONE_REG(5, __VA_ARGS__); \ - __ONE_REG(6, __VA_ARGS__); \ - __ONE_REG(7, __VA_ARGS__); \ - __ONE_REG(8, __VA_ARGS__); \ - __ONE_REG(9, __VA_ARGS__); \ - __ONE_REG(10, __VA_ARGS__); \ - __ONE_REG(11, __VA_ARGS__); \ - __ONE_REG(12, __VA_ARGS__); \ - __ONE_REG(13, __VA_ARGS__); \ - __ONE_REG(14, __VA_ARGS__); \ - __ONE_REG(15, __VA_ARGS__); \ - ring->cur = p; \ - } while (0) - -#define OUT_PKT(ring, opcode, ...) \ - do { \ - const struct fd_reg_pair regs[] = {__VA_ARGS__}; \ - unsigned count = ARRAY_SIZE(regs); \ - \ - STATIC_ASSERT(ARRAY_SIZE(regs) <= 16); \ - \ - BEGIN_RING(ring, count + 1); \ - uint32_t *p = ring->cur; \ - *p++ = pm4_pkt7_hdr(opcode, count); \ - \ - __ONE_REG(0, __VA_ARGS__); \ - __ONE_REG(1, __VA_ARGS__); \ - __ONE_REG(2, __VA_ARGS__); \ - __ONE_REG(3, __VA_ARGS__); \ - __ONE_REG(4, __VA_ARGS__); \ - __ONE_REG(5, __VA_ARGS__); \ - __ONE_REG(6, __VA_ARGS__); \ - __ONE_REG(7, __VA_ARGS__); \ - __ONE_REG(8, __VA_ARGS__); \ - __ONE_REG(9, __VA_ARGS__); \ - __ONE_REG(10, __VA_ARGS__); \ - __ONE_REG(11, __VA_ARGS__); \ - __ONE_REG(12, __VA_ARGS__); \ - __ONE_REG(13, __VA_ARGS__); \ - __ONE_REG(14, __VA_ARGS__); \ - __ONE_REG(15, __VA_ARGS__); \ - ring->cur = p; \ - } while (0) - -/* similar to OUT_PKT() but appends specified # of dwords - * copied for buf to the end of the packet (ie. for use- - * cases like CP_LOAD_STATE) - */ -#define OUT_PKTBUF(ring, opcode, dwords, sizedwords, ...) \ - do { \ - const struct fd_reg_pair regs[] = {__VA_ARGS__}; \ - unsigned count = ARRAY_SIZE(regs); \ - \ - STATIC_ASSERT(ARRAY_SIZE(regs) <= 16); \ - count += sizedwords; \ - \ - BEGIN_RING(ring, count + 1); \ - uint32_t *p = ring->cur; \ - *p++ = pm4_pkt7_hdr(opcode, count); \ - \ - __ONE_REG(0, __VA_ARGS__); \ - __ONE_REG(1, __VA_ARGS__); \ - __ONE_REG(2, __VA_ARGS__); \ - __ONE_REG(3, __VA_ARGS__); \ - __ONE_REG(4, __VA_ARGS__); \ - __ONE_REG(5, __VA_ARGS__); \ - __ONE_REG(6, __VA_ARGS__); \ - __ONE_REG(7, __VA_ARGS__); \ - __ONE_REG(8, __VA_ARGS__); \ - __ONE_REG(9, __VA_ARGS__); \ - __ONE_REG(10, __VA_ARGS__); \ - __ONE_REG(11, __VA_ARGS__); \ - __ONE_REG(12, __VA_ARGS__); \ - __ONE_REG(13, __VA_ARGS__); \ - __ONE_REG(14, __VA_ARGS__); \ - __ONE_REG(15, __VA_ARGS__); \ - memcpy(p, dwords, 4 * sizedwords); \ - p += sizedwords; \ - ring->cur = p; \ - } while (0) +#define OUT_REG(ring, ...) \ + do { \ + const struct fd_reg_pair regs[] = { __VA_ARGS__ }; \ + unsigned count = ARRAY_SIZE(regs); \ + \ + STATIC_ASSERT(count > 0); \ + STATIC_ASSERT(count <= 16); \ + \ + BEGIN_RING(ring, count + 1); \ + uint32_t *p = ring->cur; \ + *p++ = CP_TYPE4_PKT | count | \ + (_odd_parity_bit(count) << 7) | \ + ((regs[0].reg & 0x3ffff) << 8) | \ + ((_odd_parity_bit(regs[0].reg) << 27)); \ + \ + __ONE_REG( 0, __VA_ARGS__); \ + __ONE_REG( 1, __VA_ARGS__); \ + __ONE_REG( 2, __VA_ARGS__); \ + __ONE_REG( 3, __VA_ARGS__); \ + __ONE_REG( 4, __VA_ARGS__); \ + __ONE_REG( 5, __VA_ARGS__); \ + __ONE_REG( 6, __VA_ARGS__); \ + __ONE_REG( 7, __VA_ARGS__); \ + __ONE_REG( 8, __VA_ARGS__); \ + __ONE_REG( 9, __VA_ARGS__); \ + __ONE_REG(10, __VA_ARGS__); \ + __ONE_REG(11, __VA_ARGS__); \ + __ONE_REG(12, __VA_ARGS__); \ + __ONE_REG(13, __VA_ARGS__); \ + __ONE_REG(14, __VA_ARGS__); \ + __ONE_REG(15, __VA_ARGS__); \ + ring->cur = p; \ + } while (0) #endif /* FD6_PACK_H */ |