This source file includes following definitions.
- nvkm_oproxy_mthd
- nvkm_oproxy_ntfy
- nvkm_oproxy_map
- nvkm_oproxy_unmap
- nvkm_oproxy_rd08
- nvkm_oproxy_rd16
- nvkm_oproxy_rd32
- nvkm_oproxy_wr08
- nvkm_oproxy_wr16
- nvkm_oproxy_wr32
- nvkm_oproxy_bind
- nvkm_oproxy_sclass
- nvkm_oproxy_fini
- nvkm_oproxy_init
- nvkm_oproxy_dtor
- nvkm_oproxy_ctor
- nvkm_oproxy_new_
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #include <core/oproxy.h>
25
26 static int
27 nvkm_oproxy_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
28 {
29 return nvkm_object_mthd(nvkm_oproxy(object)->object, mthd, data, size);
30 }
31
32 static int
33 nvkm_oproxy_ntfy(struct nvkm_object *object, u32 mthd,
34 struct nvkm_event **pevent)
35 {
36 return nvkm_object_ntfy(nvkm_oproxy(object)->object, mthd, pevent);
37 }
38
39 static int
40 nvkm_oproxy_map(struct nvkm_object *object, void *argv, u32 argc,
41 enum nvkm_object_map *type, u64 *addr, u64 *size)
42 {
43 struct nvkm_oproxy *oproxy = nvkm_oproxy(object);
44 return nvkm_object_map(oproxy->object, argv, argc, type, addr, size);
45 }
46
47 static int
48 nvkm_oproxy_unmap(struct nvkm_object *object)
49 {
50 return nvkm_object_unmap(nvkm_oproxy(object)->object);
51 }
52
53 static int
54 nvkm_oproxy_rd08(struct nvkm_object *object, u64 addr, u8 *data)
55 {
56 return nvkm_object_rd08(nvkm_oproxy(object)->object, addr, data);
57 }
58
59 static int
60 nvkm_oproxy_rd16(struct nvkm_object *object, u64 addr, u16 *data)
61 {
62 return nvkm_object_rd16(nvkm_oproxy(object)->object, addr, data);
63 }
64
65 static int
66 nvkm_oproxy_rd32(struct nvkm_object *object, u64 addr, u32 *data)
67 {
68 return nvkm_object_rd32(nvkm_oproxy(object)->object, addr, data);
69 }
70
71 static int
72 nvkm_oproxy_wr08(struct nvkm_object *object, u64 addr, u8 data)
73 {
74 return nvkm_object_wr08(nvkm_oproxy(object)->object, addr, data);
75 }
76
77 static int
78 nvkm_oproxy_wr16(struct nvkm_object *object, u64 addr, u16 data)
79 {
80 return nvkm_object_wr16(nvkm_oproxy(object)->object, addr, data);
81 }
82
83 static int
84 nvkm_oproxy_wr32(struct nvkm_object *object, u64 addr, u32 data)
85 {
86 return nvkm_object_wr32(nvkm_oproxy(object)->object, addr, data);
87 }
88
89 static int
90 nvkm_oproxy_bind(struct nvkm_object *object, struct nvkm_gpuobj *parent,
91 int align, struct nvkm_gpuobj **pgpuobj)
92 {
93 return nvkm_object_bind(nvkm_oproxy(object)->object,
94 parent, align, pgpuobj);
95 }
96
97 static int
98 nvkm_oproxy_sclass(struct nvkm_object *object, int index,
99 struct nvkm_oclass *oclass)
100 {
101 struct nvkm_oproxy *oproxy = nvkm_oproxy(object);
102 oclass->parent = oproxy->object;
103 if (!oproxy->object->func->sclass)
104 return -ENODEV;
105 return oproxy->object->func->sclass(oproxy->object, index, oclass);
106 }
107
108 static int
109 nvkm_oproxy_fini(struct nvkm_object *object, bool suspend)
110 {
111 struct nvkm_oproxy *oproxy = nvkm_oproxy(object);
112 int ret;
113
114 if (oproxy->func->fini[0]) {
115 ret = oproxy->func->fini[0](oproxy, suspend);
116 if (ret && suspend)
117 return ret;
118 }
119
120 if (oproxy->object->func->fini) {
121 ret = oproxy->object->func->fini(oproxy->object, suspend);
122 if (ret && suspend)
123 return ret;
124 }
125
126 if (oproxy->func->fini[1]) {
127 ret = oproxy->func->fini[1](oproxy, suspend);
128 if (ret && suspend)
129 return ret;
130 }
131
132 return 0;
133 }
134
135 static int
136 nvkm_oproxy_init(struct nvkm_object *object)
137 {
138 struct nvkm_oproxy *oproxy = nvkm_oproxy(object);
139 int ret;
140
141 if (oproxy->func->init[0]) {
142 ret = oproxy->func->init[0](oproxy);
143 if (ret)
144 return ret;
145 }
146
147 if (oproxy->object->func->init) {
148 ret = oproxy->object->func->init(oproxy->object);
149 if (ret)
150 return ret;
151 }
152
153 if (oproxy->func->init[1]) {
154 ret = oproxy->func->init[1](oproxy);
155 if (ret)
156 return ret;
157 }
158
159 return 0;
160 }
161
162 static void *
163 nvkm_oproxy_dtor(struct nvkm_object *object)
164 {
165 struct nvkm_oproxy *oproxy = nvkm_oproxy(object);
166 if (oproxy->func->dtor[0])
167 oproxy->func->dtor[0](oproxy);
168 nvkm_object_del(&oproxy->object);
169 if (oproxy->func->dtor[1])
170 oproxy->func->dtor[1](oproxy);
171 return oproxy;
172 }
173
174 static const struct nvkm_object_func
175 nvkm_oproxy_func = {
176 .dtor = nvkm_oproxy_dtor,
177 .init = nvkm_oproxy_init,
178 .fini = nvkm_oproxy_fini,
179 .mthd = nvkm_oproxy_mthd,
180 .ntfy = nvkm_oproxy_ntfy,
181 .map = nvkm_oproxy_map,
182 .unmap = nvkm_oproxy_unmap,
183 .rd08 = nvkm_oproxy_rd08,
184 .rd16 = nvkm_oproxy_rd16,
185 .rd32 = nvkm_oproxy_rd32,
186 .wr08 = nvkm_oproxy_wr08,
187 .wr16 = nvkm_oproxy_wr16,
188 .wr32 = nvkm_oproxy_wr32,
189 .bind = nvkm_oproxy_bind,
190 .sclass = nvkm_oproxy_sclass,
191 };
192
193 void
194 nvkm_oproxy_ctor(const struct nvkm_oproxy_func *func,
195 const struct nvkm_oclass *oclass, struct nvkm_oproxy *oproxy)
196 {
197 nvkm_object_ctor(&nvkm_oproxy_func, oclass, &oproxy->base);
198 oproxy->func = func;
199 }
200
201 int
202 nvkm_oproxy_new_(const struct nvkm_oproxy_func *func,
203 const struct nvkm_oclass *oclass, struct nvkm_oproxy **poproxy)
204 {
205 if (!(*poproxy = kzalloc(sizeof(**poproxy), GFP_KERNEL)))
206 return -ENOMEM;
207 nvkm_oproxy_ctor(func, oclass, *poproxy);
208 return 0;
209 }