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/engctx.h>
29 #include <subdev/fb.h>
30 #include <subdev/timer.h>
31 #include <subdev/instmem.h>
33 #include <engine/mpeg.h>
34 #include <engine/graph/nv40.h>
36 struct nv40_mpeg_priv {
37 struct nouveau_mpeg base;
40 struct nv40_mpeg_chan {
41 struct nouveau_mpeg_chan base;
44 /*******************************************************************************
46 ******************************************************************************/
49 nv40_mpeg_context_ctor(struct nouveau_object *parent,
50 struct nouveau_object *engine,
51 struct nouveau_oclass *oclass, void *data, u32 size,
52 struct nouveau_object **pobject)
54 struct nv40_mpeg_chan *chan;
57 ret = nouveau_mpeg_context_create(parent, engine, oclass, NULL,
59 NVOBJ_FLAG_ZERO_ALLOC, &chan);
60 *pobject = nv_object(chan);
68 nv40_mpeg_context_fini(struct nouveau_object *object, bool suspend)
71 struct nv40_mpeg_priv *priv = (void *)object->engine;
72 struct nv40_mpeg_chan *chan = (void *)object;
73 u32 inst = 0x80000000 | nv_gpuobj(chan)->addr >> 4;
75 nv_mask(priv, 0x00b32c, 0x00000001, 0x00000000);
76 if (nv_rd32(priv, 0x00b318) == inst)
77 nv_mask(priv, 0x00b318, 0x80000000, 0x00000000);
78 nv_mask(priv, 0x00b32c, 0x00000001, 0x00000001);
82 static struct nouveau_oclass
84 .handle = NV_ENGCTX(MPEG, 0x40),
85 .ofuncs = &(struct nouveau_ofuncs) {
86 .ctor = nv40_mpeg_context_ctor,
87 .dtor = _nouveau_mpeg_context_dtor,
88 .init = _nouveau_mpeg_context_init,
89 .fini = nv40_mpeg_context_fini,
90 .rd32 = _nouveau_mpeg_context_rd32,
91 .wr32 = _nouveau_mpeg_context_wr32,
95 /*******************************************************************************
96 * PMPEG engine/subdev functions
97 ******************************************************************************/
100 nv40_mpeg_intr(struct nouveau_subdev *subdev)
102 struct nv40_mpeg_priv *priv = (void *)subdev;
105 if ((stat = nv_rd32(priv, 0x00b100)))
106 nv31_mpeg_intr(subdev);
108 if ((stat = nv_rd32(priv, 0x00b800))) {
109 nv_error(priv, "PMSRCH 0x%08x\n", stat);
110 nv_wr32(priv, 0x00b800, stat);
115 nv40_mpeg_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
116 struct nouveau_oclass *oclass, void *data, u32 size,
117 struct nouveau_object **pobject)
119 struct nv40_mpeg_priv *priv;
122 ret = nouveau_mpeg_create(parent, engine, oclass, &priv);
123 *pobject = nv_object(priv);
127 nv_subdev(priv)->unit = 0x00000002;
128 nv_subdev(priv)->intr = nv40_mpeg_intr;
129 nv_engine(priv)->cclass = &nv40_mpeg_cclass;
130 nv_engine(priv)->sclass = nv31_mpeg_sclass;
131 nv_engine(priv)->tile_prog = nv31_mpeg_tile_prog;
135 struct nouveau_oclass
137 .handle = NV_ENGINE(MPEG, 0x40),
138 .ofuncs = &(struct nouveau_ofuncs) {
139 .ctor = nv40_mpeg_ctor,
140 .dtor = _nouveau_mpeg_dtor,
141 .init = nv31_mpeg_init,
142 .fini = _nouveau_mpeg_fini,