aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2011-04-04 02:10:00 -0400
committerBen Skeggs <bskeggs@redhat.com>2011-05-15 20:48:59 -0400
commitc0924326c8306249aaae27016b80f3c07bb51705 (patch)
treecdaa94061d073f4ee5d90f2fbb360c0c1a0c88c0 /drivers/gpu/drm
parenta02ccc7f97d9e9121aa641aca33ba2a2978aef31 (diff)
drm/nv84: add support for PMPEG
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/nouveau/Makefile2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c4
-rw-r--r--drivers/gpu/drm/nouveau/nv84_mpeg.c219
4 files changed, 227 insertions, 1 deletions
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile
index 11ff675ad6be..7b3f23a58993 100644
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -21,7 +21,7 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
21 nv40_grctx.o nv50_grctx.o nvc0_grctx.o \ 21 nv40_grctx.o nv50_grctx.o nvc0_grctx.o \
22 nv84_crypt.o \ 22 nv84_crypt.o \
23 nva3_copy.o nvc0_copy.o \ 23 nva3_copy.o nvc0_copy.o \
24 nv40_mpeg.o \ 24 nv40_mpeg.o nv84_mpeg.o \
25 nv04_instmem.o nv50_instmem.o nvc0_instmem.o \ 25 nv04_instmem.o nv50_instmem.o nvc0_instmem.o \
26 nv50_evo.o nv50_crtc.o nv50_dac.o nv50_sor.o \ 26 nv50_evo.o nv50_crtc.o nv50_dac.o nv50_sor.o \
27 nv50_cursor.o nv50_display.o \ 27 nv50_cursor.o nv50_display.o \
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index e1e29ba5939f..39cbb5179b36 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -1158,6 +1158,9 @@ extern int nvc0_copy_create(struct drm_device *dev, int engine);
1158/* nv40_mpeg.c */ 1158/* nv40_mpeg.c */
1159extern int nv40_mpeg_create(struct drm_device *dev); 1159extern int nv40_mpeg_create(struct drm_device *dev);
1160 1160
1161/* nv84_mpeg.c */
1162extern int nv84_mpeg_create(struct drm_device *dev);
1163
1161/* nv04_instmem.c */ 1164/* nv04_instmem.c */
1162extern int nv04_instmem_init(struct drm_device *); 1165extern int nv04_instmem_init(struct drm_device *);
1163extern void nv04_instmem_takedown(struct drm_device *); 1166extern void nv04_instmem_takedown(struct drm_device *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index f6c2535e766e..f2855b688095 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -619,6 +619,10 @@ nouveau_card_init(struct drm_device *dev)
619 619
620 if (dev_priv->card_type == NV_40) 620 if (dev_priv->card_type == NV_40)
621 nv40_mpeg_create(dev); 621 nv40_mpeg_create(dev);
622 else
623 if (dev_priv->card_type == NV_50 && dev_priv->chipset > 0x50 &&
624 (dev_priv->chipset < 0x98 || dev_priv->chipset == 0xa0))
625 nv84_mpeg_create(dev);
622 626
623 if (!nouveau_noaccel) { 627 if (!nouveau_noaccel) {
624 for (e = 0; e < NVOBJ_ENGINE_NR; e++) { 628 for (e = 0; e < NVOBJ_ENGINE_NR; e++) {
diff --git a/drivers/gpu/drm/nouveau/nv84_mpeg.c b/drivers/gpu/drm/nouveau/nv84_mpeg.c
new file mode 100644
index 000000000000..6c073edacbeb
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nv84_mpeg.c
@@ -0,0 +1,219 @@
1/*
2 * Copyright 2011 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 "drmP.h"
26#include "nouveau_drv.h"
27#include "nouveau_ramht.h"
28
29struct nv84_mpeg_engine {
30 struct nouveau_exec_engine base;
31};
32
33static int
34nv84_mpeg_context_new(struct nouveau_channel *chan, int engine)
35{
36 struct drm_device *dev = chan->dev;
37 struct drm_nouveau_private *dev_priv = dev->dev_private;
38 struct nouveau_gpuobj *ramin = chan->ramin;
39 struct nouveau_gpuobj *ctx = NULL;
40 int ret;
41
42 NV_DEBUG(dev, "ch%d\n", chan->id);
43
44 ret = nouveau_gpuobj_new(dev, chan, 128 * 4, 0, NVOBJ_FLAG_ZERO_ALLOC |
45 NVOBJ_FLAG_ZERO_FREE, &ctx);
46 if (ret)
47 return ret;
48
49 nv_wo32(ramin, 0x60, 0x80190002);
50 nv_wo32(ramin, 0x64, ctx->vinst + ctx->size - 1);
51 nv_wo32(ramin, 0x68, ctx->vinst);
52 nv_wo32(ramin, 0x6c, 0);
53 nv_wo32(ramin, 0x70, 0);
54 nv_wo32(ramin, 0x74, 0x00010000);
55
56 nv_wo32(ctx, 0x70, 0x00801ec1);
57 nv_wo32(ctx, 0x7c, 0x0000037c);
58 dev_priv->engine.instmem.flush(dev);
59
60 chan->engctx[engine] = ctx;
61 return 0;
62}
63
64static void
65nv84_mpeg_context_del(struct nouveau_channel *chan, int engine)
66{
67 struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
68 struct nouveau_gpuobj *ctx = chan->engctx[engine];
69 struct drm_device *dev = chan->dev;
70 unsigned long flags;
71 u32 inst, i;
72
73 if (!chan->ramin)
74 return;
75
76 inst = chan->ramin->vinst >> 12;
77 inst |= 0x80000000;
78
79 spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
80 nv_mask(dev, 0x00b32c, 0x00000001, 0x00000000);
81 if (nv_rd32(dev, 0x00b318) == inst)
82 nv_mask(dev, 0x00b318, 0x80000000, 0x00000000);
83 nv_mask(dev, 0x00b32c, 0x00000001, 0x00000001);
84 spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
85
86 for (i = 0x60; i <= 0x74; i += 4)
87 nv_wo32(chan->ramin, i, 0x00000000);
88 nouveau_gpuobj_ref(NULL, &ctx);
89 chan->engctx[engine] = NULL;
90}
91
92static int
93nv84_mpeg_object_new(struct nouveau_channel *chan, int engine,
94 u32 handle, u16 class)
95{
96 struct drm_device *dev = chan->dev;
97 struct drm_nouveau_private *dev_priv = dev->dev_private;
98 struct nouveau_gpuobj *obj = NULL;
99 int ret;
100
101 ret = nouveau_gpuobj_new(dev, chan, 16, 16, NVOBJ_FLAG_ZERO_FREE, &obj);
102 if (ret)
103 return ret;
104 obj->engine = 2;
105 obj->class = class;
106
107 nv_wo32(obj, 0x00, class);
108 nv_wo32(obj, 0x04, 0x00000000);
109 nv_wo32(obj, 0x08, 0x00000000);
110 nv_wo32(obj, 0x0c, 0x00000000);
111 dev_priv->engine.instmem.flush(dev);
112
113 ret = nouveau_ramht_insert(chan, handle, obj);
114 nouveau_gpuobj_ref(NULL, &obj);
115 return ret;
116}
117
118static void
119nv84_mpeg_tlb_flush(struct drm_device *dev, int engine)
120{
121 nv50_vm_flush_engine(dev, 0x08);
122}
123
124static int
125nv84_mpeg_init(struct drm_device *dev, int engine)
126{
127 nv_wr32(dev, 0x00b32c, 0x00000000);
128 nv_wr32(dev, 0x00b314, 0x00000100);
129 nv_wr32(dev, 0x00b0e0, 0x0000001a);
130
131 nv_wr32(dev, 0x00b220, 0x00000044);
132 nv_wr32(dev, 0x00b300, 0x00801ec1);
133 nv_wr32(dev, 0x00b390, 0x00000000);
134 nv_wr32(dev, 0x00b394, 0x00000000);
135 nv_wr32(dev, 0x00b398, 0x00000000);
136 nv_mask(dev, 0x00b32c, 0x00000001, 0x00000001);
137
138 nv_wr32(dev, 0x00b100, 0xffffffff);
139 nv_wr32(dev, 0x00b140, 0xffffffff);
140
141 if (!nv_wait(dev, 0x00b200, 0x00000001, 0x00000000)) {
142 NV_ERROR(dev, "PMPEG init: 0x%08x\n", nv_rd32(dev, 0x00b200));
143 return -EBUSY;
144 }
145
146 return 0;
147}
148
149static int
150nv84_mpeg_fini(struct drm_device *dev, int engine)
151{
152 /*XXX: context save for s/r */
153 nv_mask(dev, 0x00b32c, 0x00000001, 0x00000000);
154 nv_wr32(dev, 0x00b140, 0x00000000);
155 return 0;
156}
157
158static void
159nv84_mpeg_isr(struct drm_device *dev)
160{
161 u32 stat = nv_rd32(dev, 0x00b100);
162 u32 type = nv_rd32(dev, 0x00b230);
163 u32 mthd = nv_rd32(dev, 0x00b234);
164 u32 data = nv_rd32(dev, 0x00b238);
165 u32 show = stat;
166
167 if (stat & 0x01000000) {
168 /* happens on initial binding of the object */
169 if (type == 0x00000020 && mthd == 0x0000) {
170 nv_wr32(dev, 0x00b308, 0x00000100);
171 show &= ~0x01000000;
172 }
173 }
174
175 if (show && nouveau_ratelimit()) {
176 NV_INFO(dev, "PMPEG - 0x%08x 0x%08x 0x%08x 0x%08x\n",
177 stat, type, mthd, data);
178 }
179
180 nv_wr32(dev, 0x00b100, stat);
181 nv_wr32(dev, 0x00b230, 0x00000001);
182 nv50_fb_vm_trap(dev, 1);
183}
184
185static void
186nv84_mpeg_destroy(struct drm_device *dev, int engine)
187{
188 struct nv84_mpeg_engine *pmpeg = nv_engine(dev, engine);
189
190 nouveau_irq_unregister(dev, 0);
191
192 NVOBJ_ENGINE_DEL(dev, MPEG);
193 kfree(pmpeg);
194}
195
196int
197nv84_mpeg_create(struct drm_device *dev)
198{
199 struct nv84_mpeg_engine *pmpeg;
200
201 pmpeg = kzalloc(sizeof(*pmpeg), GFP_KERNEL);
202 if (!pmpeg)
203 return -ENOMEM;
204
205 pmpeg->base.destroy = nv84_mpeg_destroy;
206 pmpeg->base.init = nv84_mpeg_init;
207 pmpeg->base.fini = nv84_mpeg_fini;
208 pmpeg->base.context_new = nv84_mpeg_context_new;
209 pmpeg->base.context_del = nv84_mpeg_context_del;
210 pmpeg->base.object_new = nv84_mpeg_object_new;
211 pmpeg->base.tlb_flush = nv84_mpeg_tlb_flush;
212
213 nouveau_irq_register(dev, 0, nv84_mpeg_isr);
214
215 NVOBJ_ENGINE_ADD(dev, MPEG, &pmpeg->base);
216 NVOBJ_CLASS(dev, 0x8274, MPEG);
217 return 0;
218
219}