turnip: add more tu_cs helpers
authorChia-I Wu <olvaffe@gmail.com>
Wed, 16 Jan 2019 22:40:37 +0000 (14:40 -0800)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 11 Mar 2019 17:01:41 +0000 (10:01 -0700)
src/freedreno/vulkan/tu_cs.h

index a81652ce353096836b4e0345ae3ac10fd1e3da8d..94d9bf7cddeba4074cb24b16f237655adfd28ebb 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "tu_private.h"
 
-#include "adreno_pm4.xml.h"
+#include "registers/adreno_pm4.xml.h"
 
 void
 tu_cs_init(struct tu_cs *cs);
@@ -101,9 +101,35 @@ tu_cs_emit_pkt7(struct tu_cs *cs, uint8_t opcode, uint16_t cnt)
 }
 
 static inline void
-tu_cs_emit_wfi5(struct tu_cs *cs)
+tu_cs_emit_wfi(struct tu_cs *cs)
 {
    tu_cs_emit_pkt7(cs, CP_WAIT_FOR_IDLE, 0);
 }
 
+static inline void
+tu_cs_emit_qw(struct tu_cs *cs, uint64_t value)
+{
+   tu_cs_emit(cs, (uint32_t) value);
+   tu_cs_emit(cs, (uint32_t) (value >> 32));
+}
+
+static inline void
+tu_cs_emit_write_reg(struct tu_cs *cs, uint16_t reg, uint32_t value)
+{
+   tu_cs_emit_pkt4(cs, reg, 1);
+   tu_cs_emit(cs, value);
+}
+
+static inline void
+tu_cs_emit_ib(struct tu_cs *cs, const struct tu_cs *target)
+{
+   for (uint32_t i = 0; i < target->entry_count; i++) {
+      const struct tu_cs_entry *entry = target->entries + i;
+
+      tu_cs_emit_pkt7(cs, CP_INDIRECT_BUFFER, 3);
+      tu_cs_emit_qw(cs, entry->bo->iova + entry->offset);
+      tu_cs_emit(cs, entry->size / sizeof(uint32_t));
+   }
+}
+
 #endif /* TU_CS_H */