drm/nouveau: port all engines to new engine module format
[deliverable/linux.git] / drivers / gpu / drm / nouveau / core / engine / vp / nv84.c
1 /*
2 * Copyright 2012 Red Hat Inc.
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
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.
21 *
22 * Authors: Ben Skeggs
23 */
24
25 #include <core/os.h>
26 #include <core/class.h>
27 #include <core/engctx.h>
28
29 #include <engine/vp.h>
30
31 struct nv84_vp_priv {
32 struct nouveau_vp base;
33 };
34
35 struct nv84_vp_chan {
36 struct nouveau_vp_chan base;
37 };
38
39 /*******************************************************************************
40 * VP object classes
41 ******************************************************************************/
42
43 static struct nouveau_oclass
44 nv84_vp_sclass[] = {
45 {},
46 };
47
48 /*******************************************************************************
49 * PVP context
50 ******************************************************************************/
51
52 static int
53 nv84_vp_context_ctor(struct nouveau_object *parent,
54 struct nouveau_object *engine,
55 struct nouveau_oclass *oclass, void *data, u32 size,
56 struct nouveau_object **pobject)
57 {
58 struct nv84_vp_chan *priv;
59 int ret;
60
61 ret = nouveau_vp_context_create(parent, engine, oclass, NULL,
62 0, 0, 0, &priv);
63 *pobject = nv_object(priv);
64 if (ret)
65 return ret;
66
67 return 0;
68 }
69
70 static void
71 nv84_vp_context_dtor(struct nouveau_object *object)
72 {
73 struct nv84_vp_chan *priv = (void *)object;
74 nouveau_vp_context_destroy(&priv->base);
75 }
76
77 static int
78 nv84_vp_context_init(struct nouveau_object *object)
79 {
80 struct nv84_vp_chan *priv = (void *)object;
81 int ret;
82
83 ret = nouveau_vp_context_init(&priv->base);
84 if (ret)
85 return ret;
86
87 return 0;
88 }
89
90 static int
91 nv84_vp_context_fini(struct nouveau_object *object, bool suspend)
92 {
93 struct nv84_vp_chan *priv = (void *)object;
94 return nouveau_vp_context_fini(&priv->base, suspend);
95 }
96
97 static struct nouveau_oclass
98 nv84_vp_cclass = {
99 .handle = NV_ENGCTX(VP, 0x84),
100 .ofuncs = &(struct nouveau_ofuncs) {
101 .ctor = nv84_vp_context_ctor,
102 .dtor = nv84_vp_context_dtor,
103 .init = nv84_vp_context_init,
104 .fini = nv84_vp_context_fini,
105 .rd32 = _nouveau_vp_context_rd32,
106 .wr32 = _nouveau_vp_context_wr32,
107 },
108 };
109
110 /*******************************************************************************
111 * PVP engine/subdev functions
112 ******************************************************************************/
113
114 static void
115 nv84_vp_intr(struct nouveau_subdev *subdev)
116 {
117 }
118
119 static int
120 nv84_vp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
121 struct nouveau_oclass *oclass, void *data, u32 size,
122 struct nouveau_object **pobject)
123 {
124 struct nv84_vp_priv *priv;
125 int ret;
126
127 ret = nouveau_vp_create(parent, engine, oclass, &priv);
128 *pobject = nv_object(priv);
129 if (ret)
130 return ret;
131
132 nv_subdev(priv)->unit = 0x01020000;
133 nv_subdev(priv)->intr = nv84_vp_intr;
134 nv_engine(priv)->cclass = &nv84_vp_cclass;
135 nv_engine(priv)->sclass = nv84_vp_sclass;
136 return 0;
137 }
138
139 static void
140 nv84_vp_dtor(struct nouveau_object *object)
141 {
142 struct nv84_vp_priv *priv = (void *)object;
143 nouveau_vp_destroy(&priv->base);
144 }
145
146 static int
147 nv84_vp_init(struct nouveau_object *object)
148 {
149 struct nv84_vp_priv *priv = (void *)object;
150 int ret;
151
152 ret = nouveau_vp_init(&priv->base);
153 if (ret)
154 return ret;
155
156 return 0;
157 }
158
159 static int
160 nv84_vp_fini(struct nouveau_object *object, bool suspend)
161 {
162 struct nv84_vp_priv *priv = (void *)object;
163 return nouveau_vp_fini(&priv->base, suspend);
164 }
165
166 struct nouveau_oclass
167 nv84_vp_oclass = {
168 .handle = NV_ENGINE(VP, 0x84),
169 .ofuncs = &(struct nouveau_ofuncs) {
170 .ctor = nv84_vp_ctor,
171 .dtor = nv84_vp_dtor,
172 .init = nv84_vp_init,
173 .fini = nv84_vp_fini,
174 },
175 };
This page took 0.048275 seconds and 5 git commands to generate.