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 <core/client.h>
27 #include <core/handle.h>
28 #include <engine/fifo.h>
30 struct nv44_mpeg_priv {
31 struct nvkm_mpeg base;
34 struct nv44_mpeg_chan {
35 struct nvkm_mpeg_chan base;
38 /*******************************************************************************
40 ******************************************************************************/
43 nv44_mpeg_context_ctor(struct nvkm_object *parent,
44 struct nvkm_object *engine,
45 struct nvkm_oclass *oclass, void *data, u32 size,
46 struct nvkm_object **pobject)
48 struct nv44_mpeg_chan *chan;
51 ret = nvkm_mpeg_context_create(parent, engine, oclass, NULL, 264 * 4,
52 16, NVOBJ_FLAG_ZERO_ALLOC, &chan);
53 *pobject = nv_object(chan);
57 nv_wo32(&chan->base.base, 0x78, 0x02001ec1);
62 nv44_mpeg_context_fini(struct nvkm_object *object, bool suspend)
65 struct nv44_mpeg_priv *priv = (void *)object->engine;
66 struct nv44_mpeg_chan *chan = (void *)object;
67 u32 inst = 0x80000000 | nv_gpuobj(chan)->addr >> 4;
69 nv_mask(priv, 0x00b32c, 0x00000001, 0x00000000);
70 if (nv_rd32(priv, 0x00b318) == inst)
71 nv_mask(priv, 0x00b318, 0x80000000, 0x00000000);
72 nv_mask(priv, 0x00b32c, 0x00000001, 0x00000001);
76 static struct nvkm_oclass
78 .handle = NV_ENGCTX(MPEG, 0x44),
79 .ofuncs = &(struct nvkm_ofuncs) {
80 .ctor = nv44_mpeg_context_ctor,
81 .dtor = _nvkm_mpeg_context_dtor,
82 .init = _nvkm_mpeg_context_init,
83 .fini = nv44_mpeg_context_fini,
84 .rd32 = _nvkm_mpeg_context_rd32,
85 .wr32 = _nvkm_mpeg_context_wr32,
89 /*******************************************************************************
90 * PMPEG engine/subdev functions
91 ******************************************************************************/
94 nv44_mpeg_intr(struct nvkm_subdev *subdev)
96 struct nvkm_fifo *pfifo = nvkm_fifo(subdev);
97 struct nvkm_engine *engine = nv_engine(subdev);
98 struct nvkm_object *engctx;
99 struct nvkm_handle *handle;
100 struct nv44_mpeg_priv *priv = (void *)subdev;
101 u32 inst = nv_rd32(priv, 0x00b318) & 0x000fffff;
102 u32 stat = nv_rd32(priv, 0x00b100);
103 u32 type = nv_rd32(priv, 0x00b230);
104 u32 mthd = nv_rd32(priv, 0x00b234);
105 u32 data = nv_rd32(priv, 0x00b238);
109 engctx = nvkm_engctx_get(engine, inst);
110 chid = pfifo->chid(pfifo, engctx);
112 if (stat & 0x01000000) {
113 /* happens on initial binding of the object */
114 if (type == 0x00000020 && mthd == 0x0000) {
115 nv_mask(priv, 0x00b308, 0x00000000, 0x00000000);
119 if (type == 0x00000010) {
120 handle = nvkm_handle_get_class(engctx, 0x3174);
121 if (handle && !nv_call(handle->object, mthd, data))
123 nvkm_handle_put(handle);
127 nv_wr32(priv, 0x00b100, stat);
128 nv_wr32(priv, 0x00b230, 0x00000001);
132 "ch %d [0x%08x %s] 0x%08x 0x%08x 0x%08x 0x%08x\n",
133 chid, inst << 4, nvkm_client_name(engctx), stat,
137 nvkm_engctx_put(engctx);
141 nv44_mpeg_me_intr(struct nvkm_subdev *subdev)
143 struct nv44_mpeg_priv *priv = (void *)subdev;
146 if ((stat = nv_rd32(priv, 0x00b100)))
147 nv44_mpeg_intr(subdev);
149 if ((stat = nv_rd32(priv, 0x00b800))) {
150 nv_error(priv, "PMSRCH 0x%08x\n", stat);
151 nv_wr32(priv, 0x00b800, stat);
156 nv44_mpeg_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
157 struct nvkm_oclass *oclass, void *data, u32 size,
158 struct nvkm_object **pobject)
160 struct nv44_mpeg_priv *priv;
163 ret = nvkm_mpeg_create(parent, engine, oclass, &priv);
164 *pobject = nv_object(priv);
168 nv_subdev(priv)->unit = 0x00000002;
169 nv_subdev(priv)->intr = nv44_mpeg_me_intr;
170 nv_engine(priv)->cclass = &nv44_mpeg_cclass;
171 nv_engine(priv)->sclass = nv40_mpeg_sclass;
172 nv_engine(priv)->tile_prog = nv31_mpeg_tile_prog;
178 .handle = NV_ENGINE(MPEG, 0x44),
179 .ofuncs = &(struct nvkm_ofuncs) {
180 .ctor = nv44_mpeg_ctor,
181 .dtor = _nvkm_mpeg_dtor,
182 .init = nv31_mpeg_init,
183 .fini = _nvkm_mpeg_fini,