1 #include "libdrm_macros.h"
2 #include <stdio.h>
3 #include "radeon_cs.h"
4 #include "radeon_cs_int.h"
5
6 struct radeon_cs *
radeon_cs_create(struct radeon_cs_manager * csm,uint32_t ndw)7 radeon_cs_create(struct radeon_cs_manager *csm, uint32_t ndw)
8 {
9 struct radeon_cs_int *csi = csm->funcs->cs_create(csm, ndw);
10 return (struct radeon_cs *)csi;
11 }
12
13 int
radeon_cs_write_reloc(struct radeon_cs * cs,struct radeon_bo * bo,uint32_t read_domain,uint32_t write_domain,uint32_t flags)14 radeon_cs_write_reloc(struct radeon_cs *cs, struct radeon_bo *bo,
15 uint32_t read_domain, uint32_t write_domain,
16 uint32_t flags)
17 {
18 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
19
20 return csi->csm->funcs->cs_write_reloc(csi,
21 bo,
22 read_domain,
23 write_domain,
24 flags);
25 }
26
27 int
radeon_cs_begin(struct radeon_cs * cs,uint32_t ndw,const char * file,const char * func,int line)28 radeon_cs_begin(struct radeon_cs *cs, uint32_t ndw,
29 const char *file, const char *func, int line)
30 {
31 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
32 return csi->csm->funcs->cs_begin(csi, ndw, file, func, line);
33 }
34
35 int
radeon_cs_end(struct radeon_cs * cs,const char * file,const char * func,int line)36 radeon_cs_end(struct radeon_cs *cs,
37 const char *file, const char *func, int line)
38 {
39 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
40 return csi->csm->funcs->cs_end(csi, file, func, line);
41 }
42
radeon_cs_emit(struct radeon_cs * cs)43 int radeon_cs_emit(struct radeon_cs *cs)
44 {
45 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
46 return csi->csm->funcs->cs_emit(csi);
47 }
48
radeon_cs_destroy(struct radeon_cs * cs)49 int radeon_cs_destroy(struct radeon_cs *cs)
50 {
51 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
52 return csi->csm->funcs->cs_destroy(csi);
53 }
54
radeon_cs_erase(struct radeon_cs * cs)55 int radeon_cs_erase(struct radeon_cs *cs)
56 {
57 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
58 return csi->csm->funcs->cs_erase(csi);
59 }
60
radeon_cs_need_flush(struct radeon_cs * cs)61 int radeon_cs_need_flush(struct radeon_cs *cs)
62 {
63 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
64 return csi->csm->funcs->cs_need_flush(csi);
65 }
66
radeon_cs_print(struct radeon_cs * cs,FILE * file)67 void radeon_cs_print(struct radeon_cs *cs, FILE *file)
68 {
69 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
70 csi->csm->funcs->cs_print(csi, file);
71 }
72
73 void
radeon_cs_set_limit(struct radeon_cs * cs,uint32_t domain,uint32_t limit)74 radeon_cs_set_limit(struct radeon_cs *cs, uint32_t domain, uint32_t limit)
75 {
76 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
77 if (domain == RADEON_GEM_DOMAIN_VRAM)
78 csi->csm->vram_limit = limit;
79 else
80 csi->csm->gart_limit = limit;
81 }
82
radeon_cs_space_set_flush(struct radeon_cs * cs,void (* fn)(void *),void * data)83 void radeon_cs_space_set_flush(struct radeon_cs *cs,
84 void (*fn)(void *), void *data)
85 {
86 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
87 csi->space_flush_fn = fn;
88 csi->space_flush_data = data;
89 }
90
radeon_cs_get_id(struct radeon_cs * cs)91 uint32_t radeon_cs_get_id(struct radeon_cs *cs)
92 {
93 struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
94 return csi->id;
95 }
96