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 <engine/mpeg.h>
26 #include <subdev/bar.h>
27 #include <subdev/timer.h>
29 struct nv50_mpeg_chan {
30 struct nvkm_mpeg_chan base;
33 /*******************************************************************************
35 ******************************************************************************/
38 nv50_mpeg_object_ctor(struct nvkm_object *parent,
39 struct nvkm_object *engine,
40 struct nvkm_oclass *oclass, void *data, u32 size,
41 struct nvkm_object **pobject)
43 struct nvkm_gpuobj *obj;
46 ret = nvkm_gpuobj_create(parent, engine, oclass, 0, parent,
48 *pobject = nv_object(obj);
53 nvkm_wo32(obj, 0x00, nv_mclass(obj));
54 nvkm_wo32(obj, 0x04, 0x00000000);
55 nvkm_wo32(obj, 0x08, 0x00000000);
56 nvkm_wo32(obj, 0x0c, 0x00000000);
63 .ctor = nv50_mpeg_object_ctor,
64 .dtor = _nvkm_gpuobj_dtor,
65 .init = _nvkm_gpuobj_init,
66 .fini = _nvkm_gpuobj_fini,
67 .rd32 = _nvkm_gpuobj_rd32,
68 .wr32 = _nvkm_gpuobj_wr32,
71 static struct nvkm_oclass
72 nv50_mpeg_sclass[] = {
73 { 0x3174, &nv50_mpeg_ofuncs },
77 /*******************************************************************************
79 ******************************************************************************/
82 nv50_mpeg_context_ctor(struct nvkm_object *parent,
83 struct nvkm_object *engine,
84 struct nvkm_oclass *oclass, void *data, u32 size,
85 struct nvkm_object **pobject)
87 struct nvkm_bar *bar = nvkm_bar(parent);
88 struct nv50_mpeg_chan *chan;
89 struct nvkm_gpuobj *image;
92 ret = nvkm_mpeg_context_create(parent, engine, oclass, NULL, 128 * 4,
93 0, NVOBJ_FLAG_ZERO_ALLOC, &chan);
94 *pobject = nv_object(chan);
98 image = &chan->base.base.gpuobj;
101 nvkm_wo32(image, 0x0070, 0x00801ec1);
102 nvkm_wo32(image, 0x007c, 0x0000037c);
108 static struct nvkm_oclass
110 .handle = NV_ENGCTX(MPEG, 0x50),
111 .ofuncs = &(struct nvkm_ofuncs) {
112 .ctor = nv50_mpeg_context_ctor,
113 .dtor = _nvkm_mpeg_context_dtor,
114 .init = _nvkm_mpeg_context_init,
115 .fini = _nvkm_mpeg_context_fini,
116 .rd32 = _nvkm_mpeg_context_rd32,
117 .wr32 = _nvkm_mpeg_context_wr32,
121 /*******************************************************************************
122 * PMPEG engine/subdev functions
123 ******************************************************************************/
126 nv50_mpeg_intr(struct nvkm_subdev *subdev)
128 struct nvkm_mpeg *mpeg = (void *)subdev;
129 struct nvkm_device *device = mpeg->engine.subdev.device;
130 u32 stat = nvkm_rd32(device, 0x00b100);
131 u32 type = nvkm_rd32(device, 0x00b230);
132 u32 mthd = nvkm_rd32(device, 0x00b234);
133 u32 data = nvkm_rd32(device, 0x00b238);
136 if (stat & 0x01000000) {
137 /* happens on initial binding of the object */
138 if (type == 0x00000020 && mthd == 0x0000) {
139 nvkm_wr32(device, 0x00b308, 0x00000100);
145 nvkm_info(subdev, "%08x %08x %08x %08x\n",
146 stat, type, mthd, data);
149 nvkm_wr32(device, 0x00b100, stat);
150 nvkm_wr32(device, 0x00b230, 0x00000001);
154 nv50_vpe_intr(struct nvkm_subdev *subdev)
156 struct nvkm_device *device = subdev->device;
158 if (nvkm_rd32(device, 0x00b100))
159 nv50_mpeg_intr(subdev);
161 if (nvkm_rd32(device, 0x00b800)) {
162 u32 stat = nvkm_rd32(device, 0x00b800);
163 nvkm_info(subdev, "PMSRCH: %08x\n", stat);
164 nvkm_wr32(device, 0xb800, stat);
169 nv50_mpeg_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
170 struct nvkm_oclass *oclass, void *data, u32 size,
171 struct nvkm_object **pobject)
173 struct nvkm_mpeg *mpeg;
176 ret = nvkm_mpeg_create(parent, engine, oclass, &mpeg);
177 *pobject = nv_object(mpeg);
181 nv_subdev(mpeg)->unit = 0x00400002;
182 nv_subdev(mpeg)->intr = nv50_vpe_intr;
183 nv_engine(mpeg)->cclass = &nv50_mpeg_cclass;
184 nv_engine(mpeg)->sclass = nv50_mpeg_sclass;
189 nv50_mpeg_init(struct nvkm_object *object)
191 struct nvkm_mpeg *mpeg = (void *)object;
192 struct nvkm_subdev *subdev = &mpeg->engine.subdev;
193 struct nvkm_device *device = subdev->device;
196 ret = nvkm_mpeg_init(mpeg);
200 nvkm_wr32(device, 0x00b32c, 0x00000000);
201 nvkm_wr32(device, 0x00b314, 0x00000100);
202 nvkm_wr32(device, 0x00b0e0, 0x0000001a);
204 nvkm_wr32(device, 0x00b220, 0x00000044);
205 nvkm_wr32(device, 0x00b300, 0x00801ec1);
206 nvkm_wr32(device, 0x00b390, 0x00000000);
207 nvkm_wr32(device, 0x00b394, 0x00000000);
208 nvkm_wr32(device, 0x00b398, 0x00000000);
209 nvkm_mask(device, 0x00b32c, 0x00000001, 0x00000001);
211 nvkm_wr32(device, 0x00b100, 0xffffffff);
212 nvkm_wr32(device, 0x00b140, 0xffffffff);
214 if (nvkm_msec(device, 2000,
215 if (!(nvkm_rd32(device, 0x00b200) & 0x00000001))
218 nvkm_error(subdev, "timeout %08x\n",
219 nvkm_rd32(device, 0x00b200));
228 .handle = NV_ENGINE(MPEG, 0x50),
229 .ofuncs = &(struct nvkm_ofuncs) {
230 .ctor = nv50_mpeg_ctor,
231 .dtor = _nvkm_mpeg_dtor,
232 .init = nv50_mpeg_init,
233 .fini = _nvkm_mpeg_fini,