1 /*
2 * Copyright 2012 Red Hat Inc.
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
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.
21 *
22 * Authors: Ben Skeggs
23 */
24
25 #include <core/os.h>
26 #include <core/engctx.h>
27
28 #include <subdev/vm.h>
29 #include <subdev/bar.h>
30 #include <subdev/timer.h>
31
32 #include <engine/mpeg.h>
33
34 struct nv84_mpeg_priv {
35 struct nouveau_mpeg base;
36 };
37
38 struct nv84_mpeg_chan {
39 struct nouveau_mpeg_chan base;
40 };
41
42 /*******************************************************************************
43 * MPEG object classes
44 ******************************************************************************/
45
46 static struct nouveau_oclass
47 nv84_mpeg_sclass[] = {
48 { 0x8274, &nv50_mpeg_ofuncs },
49 {}
50 };
51
52 /*******************************************************************************
53 * PMPEG context
54 ******************************************************************************/
55
56 static struct nouveau_oclass
57 nv84_mpeg_cclass = {
58 .handle = NV_ENGCTX(MPEG, 0x84),
59 .ofuncs = &(struct nouveau_ofuncs) {
60 .ctor = nv50_mpeg_context_ctor,
61 .dtor = _nouveau_mpeg_context_dtor,
62 .init = _nouveau_mpeg_context_init,
63 .fini = _nouveau_mpeg_context_fini,
64 .rd32 = _nouveau_mpeg_context_rd32,
65 .wr32 = _nouveau_mpeg_context_wr32,
66 },
67 };
68
69 /*******************************************************************************
70 * PMPEG engine/subdev functions
71 ******************************************************************************/
72
73 static int
nv84_mpeg_ctor(struct nouveau_object * parent,struct nouveau_object * engine,struct nouveau_oclass * oclass,void * data,u32 size,struct nouveau_object ** pobject)74 nv84_mpeg_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
75 struct nouveau_oclass *oclass, void *data, u32 size,
76 struct nouveau_object **pobject)
77 {
78 struct nv84_mpeg_priv *priv;
79 int ret;
80
81 ret = nouveau_mpeg_create(parent, engine, oclass, &priv);
82 *pobject = nv_object(priv);
83 if (ret)
84 return ret;
85
86 nv_subdev(priv)->unit = 0x00000002;
87 nv_subdev(priv)->intr = nv50_mpeg_intr;
88 nv_engine(priv)->cclass = &nv84_mpeg_cclass;
89 nv_engine(priv)->sclass = nv84_mpeg_sclass;
90 return 0;
91 }
92
93 struct nouveau_oclass
94 nv84_mpeg_oclass = {
95 .handle = NV_ENGINE(MPEG, 0x84),
96 .ofuncs = &(struct nouveau_ofuncs) {
97 .ctor = nv84_mpeg_ctor,
98 .dtor = _nouveau_mpeg_dtor,
99 .init = nv50_mpeg_init,
100 .fini = _nouveau_mpeg_fini,
101 },
102 };
103