2 * Copyright 2015 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
24 #include <core/oproxy.h>
27 nvkm_oproxy_mthd(struct nvkm_object
*object
, u32 mthd
, void *data
, u32 size
)
29 return nvkm_object_mthd(nvkm_oproxy(object
)->object
, mthd
, data
, size
);
33 nvkm_oproxy_ntfy(struct nvkm_object
*object
, u32 mthd
,
34 struct nvkm_event
**pevent
)
36 return nvkm_object_ntfy(nvkm_oproxy(object
)->object
, mthd
, pevent
);
40 nvkm_oproxy_map(struct nvkm_object
*object
, void *argv
, u32 argc
,
41 enum nvkm_object_map
*type
, u64
*addr
, u64
*size
)
43 struct nvkm_oproxy
*oproxy
= nvkm_oproxy(object
);
44 return nvkm_object_map(oproxy
->object
, argv
, argc
, type
, addr
, size
);
48 nvkm_oproxy_unmap(struct nvkm_object
*object
)
50 return nvkm_object_unmap(nvkm_oproxy(object
)->object
);
54 nvkm_oproxy_rd08(struct nvkm_object
*object
, u64 addr
, u8
*data
)
56 return nvkm_object_rd08(nvkm_oproxy(object
)->object
, addr
, data
);
60 nvkm_oproxy_rd16(struct nvkm_object
*object
, u64 addr
, u16
*data
)
62 return nvkm_object_rd16(nvkm_oproxy(object
)->object
, addr
, data
);
66 nvkm_oproxy_rd32(struct nvkm_object
*object
, u64 addr
, u32
*data
)
68 return nvkm_object_rd32(nvkm_oproxy(object
)->object
, addr
, data
);
72 nvkm_oproxy_wr08(struct nvkm_object
*object
, u64 addr
, u8 data
)
74 return nvkm_object_wr08(nvkm_oproxy(object
)->object
, addr
, data
);
78 nvkm_oproxy_wr16(struct nvkm_object
*object
, u64 addr
, u16 data
)
80 return nvkm_object_wr16(nvkm_oproxy(object
)->object
, addr
, data
);
84 nvkm_oproxy_wr32(struct nvkm_object
*object
, u64 addr
, u32 data
)
86 return nvkm_object_wr32(nvkm_oproxy(object
)->object
, addr
, data
);
90 nvkm_oproxy_bind(struct nvkm_object
*object
, struct nvkm_gpuobj
*parent
,
91 int align
, struct nvkm_gpuobj
**pgpuobj
)
93 return nvkm_object_bind(nvkm_oproxy(object
)->object
,
94 parent
, align
, pgpuobj
);
98 nvkm_oproxy_sclass(struct nvkm_object
*object
, int index
,
99 struct nvkm_oclass
*oclass
)
101 struct nvkm_oproxy
*oproxy
= nvkm_oproxy(object
);
102 oclass
->parent
= oproxy
->object
;
103 if (!oproxy
->object
->func
->sclass
)
105 return oproxy
->object
->func
->sclass(oproxy
->object
, index
, oclass
);
109 nvkm_oproxy_fini(struct nvkm_object
*object
, bool suspend
)
111 struct nvkm_oproxy
*oproxy
= nvkm_oproxy(object
);
114 if (oproxy
->func
->fini
[0]) {
115 ret
= oproxy
->func
->fini
[0](oproxy
, suspend
);
120 if (oproxy
->object
->func
->fini
) {
121 ret
= oproxy
->object
->func
->fini(oproxy
->object
, suspend
);
126 if (oproxy
->func
->fini
[1]) {
127 ret
= oproxy
->func
->fini
[1](oproxy
, suspend
);
136 nvkm_oproxy_init(struct nvkm_object
*object
)
138 struct nvkm_oproxy
*oproxy
= nvkm_oproxy(object
);
141 if (oproxy
->func
->init
[0]) {
142 ret
= oproxy
->func
->init
[0](oproxy
);
147 if (oproxy
->object
->func
->init
) {
148 ret
= oproxy
->object
->func
->init(oproxy
->object
);
153 if (oproxy
->func
->init
[1]) {
154 ret
= oproxy
->func
->init
[1](oproxy
);
163 nvkm_oproxy_dtor(struct nvkm_object
*object
)
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
);
174 static const struct nvkm_object_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
,
194 nvkm_oproxy_ctor(const struct nvkm_oproxy_func
*func
,
195 const struct nvkm_oclass
*oclass
, struct nvkm_oproxy
*oproxy
)
197 nvkm_object_ctor(&nvkm_oproxy_func
, oclass
, &oproxy
->base
);
202 nvkm_oproxy_new_(const struct nvkm_oproxy_func
*func
,
203 const struct nvkm_oclass
*oclass
, struct nvkm_oproxy
**poproxy
)
205 if (!(*poproxy
= kzalloc(sizeof(**poproxy
), GFP_KERNEL
)))
207 nvkm_oproxy_ctor(func
, oclass
, *poproxy
);