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
);
64 nv_wo32(&chan
->base
.base
, 0x78, 0x02001ec1);
69 nv40_mpeg_context_fini(struct nouveau_object
*object
, bool suspend
)
72 struct nv40_mpeg_priv
*priv
= (void *)object
->engine
;
73 struct nv40_mpeg_chan
*chan
= (void *)object
;
74 u32 inst
= 0x80000000 | nv_gpuobj(chan
)->addr
>> 4;
76 nv_mask(priv
, 0x00b32c, 0x00000001, 0x00000000);
77 if (nv_rd32(priv
, 0x00b318) == inst
)
78 nv_mask(priv
, 0x00b318, 0x80000000, 0x00000000);
79 nv_mask(priv
, 0x00b32c, 0x00000001, 0x00000001);
83 static struct nouveau_oclass
85 .handle
= NV_ENGCTX(MPEG
, 0x40),
86 .ofuncs
= &(struct nouveau_ofuncs
) {
87 .ctor
= nv40_mpeg_context_ctor
,
88 .dtor
= _nouveau_mpeg_context_dtor
,
89 .init
= _nouveau_mpeg_context_init
,
90 .fini
= nv40_mpeg_context_fini
,
91 .rd32
= _nouveau_mpeg_context_rd32
,
92 .wr32
= _nouveau_mpeg_context_wr32
,
96 /*******************************************************************************
97 * PMPEG engine/subdev functions
98 ******************************************************************************/
101 nv40_mpeg_intr(struct nouveau_subdev
*subdev
)
103 struct nv40_mpeg_priv
*priv
= (void *)subdev
;
106 if ((stat
= nv_rd32(priv
, 0x00b100)))
107 nv31_mpeg_intr(subdev
);
109 if ((stat
= nv_rd32(priv
, 0x00b800))) {
110 nv_error(priv
, "PMSRCH 0x%08x\n", stat
);
111 nv_wr32(priv
, 0x00b800, stat
);
116 nv40_mpeg_ctor(struct nouveau_object
*parent
, struct nouveau_object
*engine
,
117 struct nouveau_oclass
*oclass
, void *data
, u32 size
,
118 struct nouveau_object
**pobject
)
120 struct nv40_mpeg_priv
*priv
;
123 ret
= nouveau_mpeg_create(parent
, engine
, oclass
, &priv
);
124 *pobject
= nv_object(priv
);
128 nv_subdev(priv
)->unit
= 0x00000002;
129 nv_subdev(priv
)->intr
= nv40_mpeg_intr
;
130 nv_engine(priv
)->cclass
= &nv40_mpeg_cclass
;
131 nv_engine(priv
)->sclass
= nv31_mpeg_sclass
;
132 nv_engine(priv
)->tile_prog
= nv31_mpeg_tile_prog
;
136 struct nouveau_oclass
138 .handle
= NV_ENGINE(MPEG
, 0x40),
139 .ofuncs
= &(struct nouveau_ofuncs
) {
140 .ctor
= nv40_mpeg_ctor
,
141 .dtor
= _nouveau_mpeg_dtor
,
142 .init
= nv31_mpeg_init
,
143 .fini
= _nouveau_mpeg_fini
,