2 * Copyright 2012 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.
24 #include <core/parent.h>
25 #include <core/client.h>
26 #include <core/engine.h>
29 nvkm_parent_sclass(struct nvkm_object *parent, u16 handle,
30 struct nvkm_object **pengine,
31 struct nvkm_oclass **poclass)
33 struct nvkm_oclass *sclass, *oclass;
34 struct nvkm_engine *engine;
38 sclass = nv_parent(parent)->sclass;
39 while ((oclass = sclass++) && oclass->ofuncs) {
40 if (oclass->handle == handle) {
41 *pengine = &parent->engine->subdev.object;
47 mask = nv_parent(parent)->engine;
48 while (i = __ffs64(mask), mask) {
49 engine = nvkm_engine(parent, i);
51 oclass = engine->sclass;
52 while (oclass->ofuncs) {
53 if (oclass->handle == handle) {
54 *pengine = nv_object(engine);
69 nvkm_parent_lclass(struct nvkm_object *parent, u32 *lclass, int size)
71 struct nvkm_oclass *sclass, *oclass;
72 struct nvkm_engine *engine;
76 sclass = nv_parent(parent)->sclass;
77 while ((oclass = sclass++) && oclass->ofuncs) {
79 lclass[nr] = oclass->handle;
82 mask = nv_parent(parent)->engine;
83 while (i = __ffs64(mask), mask) {
84 engine = nvkm_engine(parent, i);
85 if (engine && (oclass = engine->sclass)) {
86 while (oclass->ofuncs) {
88 lclass[nr] = oclass->handle;
100 nvkm_parent_create_(struct nvkm_object *parent, struct nvkm_object *engine,
101 struct nvkm_oclass *oclass, u32 pclass,
102 struct nvkm_oclass *sclass, u64 engcls,
103 int size, void **pobject)
105 struct nvkm_parent *object;
108 ret = nvkm_object_create_(parent, engine, oclass, pclass |
109 NV_PARENT_CLASS, size, pobject);
114 object->sclass = sclass;
115 object->engine = engcls;
120 nvkm_parent_destroy(struct nvkm_parent *parent)
122 nvkm_object_destroy(&parent->object);
127 _nvkm_parent_dtor(struct nvkm_object *object)
129 nvkm_parent_destroy(nv_parent(object));