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