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.
26 #include <core/class.h>
27 #include <core/client.h>
28 #include <core/engctx.h>
29 #include <core/handle.h>
31 #include <subdev/fb.h>
32 #include <subdev/timer.h>
33 #include <subdev/instmem.h>
35 #include <engine/fifo.h>
36 #include <engine/mpeg.h>
38 struct nv44_mpeg_priv {
39 struct nouveau_mpeg base;
42 struct nv44_mpeg_chan {
43 struct nouveau_mpeg_chan base;
46 /*******************************************************************************
48 ******************************************************************************/
51 nv44_mpeg_context_ctor(struct nouveau_object *parent,
52 struct nouveau_object *engine,
53 struct nouveau_oclass *oclass, void *data, u32 size,
54 struct nouveau_object **pobject)
56 struct nv44_mpeg_chan *chan;
59 ret = nouveau_mpeg_context_create(parent, engine, oclass, NULL,
61 NVOBJ_FLAG_ZERO_ALLOC, &chan);
62 *pobject = nv_object(chan);
66 nv_wo32(&chan->base.base, 0x78, 0x02001ec1);
71 nv44_mpeg_context_fini(struct nouveau_object *object, bool suspend)
74 struct nv44_mpeg_priv *priv = (void *)object->engine;
75 struct nv44_mpeg_chan *chan = (void *)object;
76 u32 inst = 0x80000000 | nv_gpuobj(chan)->addr >> 4;
78 nv_mask(priv, 0x00b32c, 0x00000001, 0x00000000);
79 if (nv_rd32(priv, 0x00b318) == inst)
80 nv_mask(priv, 0x00b318, 0x80000000, 0x00000000);
81 nv_mask(priv, 0x00b32c, 0x00000001, 0x00000001);
85 static struct nouveau_oclass
87 .handle = NV_ENGCTX(MPEG, 0x44),
88 .ofuncs = &(struct nouveau_ofuncs) {
89 .ctor = nv44_mpeg_context_ctor,
90 .dtor = _nouveau_mpeg_context_dtor,
91 .init = _nouveau_mpeg_context_init,
92 .fini = nv44_mpeg_context_fini,
93 .rd32 = _nouveau_mpeg_context_rd32,
94 .wr32 = _nouveau_mpeg_context_wr32,
98 /*******************************************************************************
99 * PMPEG engine/subdev functions
100 ******************************************************************************/
103 nv44_mpeg_intr(struct nouveau_subdev *subdev)
105 struct nouveau_fifo *pfifo = nouveau_fifo(subdev);
106 struct nouveau_engine *engine = nv_engine(subdev);
107 struct nouveau_object *engctx;
108 struct nouveau_handle *handle;
109 struct nv44_mpeg_priv *priv = (void *)subdev;
110 u32 inst = nv_rd32(priv, 0x00b318) & 0x000fffff;
111 u32 stat = nv_rd32(priv, 0x00b100);
112 u32 type = nv_rd32(priv, 0x00b230);
113 u32 mthd = nv_rd32(priv, 0x00b234);
114 u32 data = nv_rd32(priv, 0x00b238);
118 engctx = nouveau_engctx_get(engine, inst);
119 chid = pfifo->chid(pfifo, engctx);
121 if (stat & 0x01000000) {
122 /* happens on initial binding of the object */
123 if (type == 0x00000020 && mthd == 0x0000) {
124 nv_mask(priv, 0x00b308, 0x00000000, 0x00000000);
128 if (type == 0x00000010) {
129 handle = nouveau_handle_get_class(engctx, 0x3174);
130 if (handle && !nv_call(handle->object, mthd, data))
132 nouveau_handle_put(handle);
136 nv_wr32(priv, 0x00b100, stat);
137 nv_wr32(priv, 0x00b230, 0x00000001);
141 "ch %d [0x%08x %s] 0x%08x 0x%08x 0x%08x 0x%08x\n",
142 chid, inst << 4, nouveau_client_name(engctx), stat,
146 nouveau_engctx_put(engctx);
150 nv44_mpeg_me_intr(struct nouveau_subdev *subdev)
152 struct nv44_mpeg_priv *priv = (void *)subdev;
155 if ((stat = nv_rd32(priv, 0x00b100)))
156 nv44_mpeg_intr(subdev);
158 if ((stat = nv_rd32(priv, 0x00b800))) {
159 nv_error(priv, "PMSRCH 0x%08x\n", stat);
160 nv_wr32(priv, 0x00b800, stat);
165 nv44_mpeg_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
166 struct nouveau_oclass *oclass, void *data, u32 size,
167 struct nouveau_object **pobject)
169 struct nv44_mpeg_priv *priv;
172 ret = nouveau_mpeg_create(parent, engine, oclass, &priv);
173 *pobject = nv_object(priv);
177 nv_subdev(priv)->unit = 0x00000002;
178 nv_subdev(priv)->intr = nv44_mpeg_me_intr;
179 nv_engine(priv)->cclass = &nv44_mpeg_cclass;
180 nv_engine(priv)->sclass = nv40_mpeg_sclass;
181 nv_engine(priv)->tile_prog = nv31_mpeg_tile_prog;
185 struct nouveau_oclass
187 .handle = NV_ENGINE(MPEG, 0x44),
188 .ofuncs = &(struct nouveau_ofuncs) {
189 .ctor = nv44_mpeg_ctor,
190 .dtor = _nouveau_mpeg_dtor,
191 .init = nv31_mpeg_init,
192 .fini = _nouveau_mpeg_fini,