Commit | Line | Data |
---|---|---|
8f27c543 | 1 | /* |
ebb945a9 | 2 | * Copyright 2012 Red Hat Inc. |
8f27c543 BS |
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 | ||
ebb945a9 BS |
25 | #include <core/os.h> |
26 | #include <core/class.h> | |
27 | #include <core/engctx.h> | |
8f27c543 | 28 | |
ebb945a9 BS |
29 | #include <engine/vp.h> |
30 | ||
31 | struct nv84_vp_priv { | |
32 | struct nouveau_vp base; | |
33 | }; | |
8f27c543 | 34 | |
ebb945a9 BS |
35 | struct nv84_vp_chan { |
36 | struct nouveau_vp_chan base; | |
8f27c543 BS |
37 | }; |
38 | ||
ebb945a9 BS |
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 | ||
8f27c543 | 52 | static int |
ebb945a9 BS |
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) | |
8f27c543 | 57 | { |
ebb945a9 BS |
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; | |
8f27c543 | 66 | |
8f27c543 BS |
67 | return 0; |
68 | } | |
69 | ||
ebb945a9 BS |
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 | ||
8f27c543 | 77 | static int |
ebb945a9 | 78 | nv84_vp_context_init(struct nouveau_object *object) |
8f27c543 | 79 | { |
ebb945a9 BS |
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 | ||
8f27c543 BS |
87 | return 0; |
88 | } | |
89 | ||
ebb945a9 BS |
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 | ||
8f27c543 | 114 | static void |
ebb945a9 | 115 | nv84_vp_intr(struct nouveau_subdev *subdev) |
8f27c543 | 116 | { |
ebb945a9 | 117 | } |
8f27c543 | 118 | |
ebb945a9 BS |
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; | |
8f27c543 | 131 | |
ebb945a9 BS |
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; | |
8f27c543 BS |
137 | } |
138 | ||
ebb945a9 BS |
139 | static void |
140 | nv84_vp_dtor(struct nouveau_object *object) | |
8f27c543 | 141 | { |
ebb945a9 BS |
142 | struct nv84_vp_priv *priv = (void *)object; |
143 | nouveau_vp_destroy(&priv->base); | |
144 | } | |
8f27c543 | 145 | |
ebb945a9 BS |
146 | static int |
147 | nv84_vp_init(struct nouveau_object *object) | |
148 | { | |
149 | struct nv84_vp_priv *priv = (void *)object; | |
150 | int ret; | |
8f27c543 | 151 | |
ebb945a9 BS |
152 | ret = nouveau_vp_init(&priv->base); |
153 | if (ret) | |
154 | return ret; | |
8f27c543 | 155 | |
8f27c543 BS |
156 | return 0; |
157 | } | |
ebb945a9 BS |
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 | }; |