blob: e031904ef7a78407115dec45110d9d74637718de [file] [log] [blame]
Ben Skeggs6ee73862009-12-11 19:24:15 +10001/*
2 * Copyright (C) 2008 Maarten Maathuis.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 */
26
27#include "nv50_display.h"
28#include "nouveau_crtc.h"
29#include "nouveau_encoder.h"
30#include "nouveau_connector.h"
31#include "nouveau_fb.h"
Dave Airlie4abe3522010-03-30 05:34:18 +000032#include "nouveau_fbcon.h"
Ben Skeggs6ee73862009-12-11 19:24:15 +100033#include "drm_crtc_helper.h"
34
35static void
36nv50_evo_channel_del(struct nouveau_channel **pchan)
37{
38 struct nouveau_channel *chan = *pchan;
39
40 if (!chan)
41 return;
42 *pchan = NULL;
43
44 nouveau_gpuobj_channel_takedown(chan);
45 nouveau_bo_ref(NULL, &chan->pushbuf_bo);
46
47 if (chan->user)
48 iounmap(chan->user);
49
50 kfree(chan);
51}
52
53static int
54nv50_evo_dmaobj_new(struct nouveau_channel *evo, uint32_t class, uint32_t name,
55 uint32_t tile_flags, uint32_t magic_flags,
56 uint32_t offset, uint32_t limit)
57{
58 struct drm_nouveau_private *dev_priv = evo->dev->dev_private;
59 struct drm_device *dev = evo->dev;
60 struct nouveau_gpuobj *obj = NULL;
61 int ret;
62
63 ret = nouveau_gpuobj_new(dev, evo, 6*4, 32, 0, &obj);
64 if (ret)
65 return ret;
66 obj->engine = NVOBJ_ENGINE_DISPLAY;
67
68 ret = nouveau_gpuobj_ref_add(dev, evo, name, obj, NULL);
69 if (ret) {
70 nouveau_gpuobj_del(dev, &obj);
71 return ret;
72 }
73
74 dev_priv->engine.instmem.prepare_access(dev, true);
75 nv_wo32(dev, obj, 0, (tile_flags << 22) | (magic_flags << 16) | class);
76 nv_wo32(dev, obj, 1, limit);
77 nv_wo32(dev, obj, 2, offset);
78 nv_wo32(dev, obj, 3, 0x00000000);
79 nv_wo32(dev, obj, 4, 0x00000000);
80 nv_wo32(dev, obj, 5, 0x00010000);
81 dev_priv->engine.instmem.finish_access(dev);
82
83 return 0;
84}
85
86static int
87nv50_evo_channel_new(struct drm_device *dev, struct nouveau_channel **pchan)
88{
89 struct drm_nouveau_private *dev_priv = dev->dev_private;
90 struct nouveau_channel *chan;
91 int ret;
92
93 chan = kzalloc(sizeof(struct nouveau_channel), GFP_KERNEL);
94 if (!chan)
95 return -ENOMEM;
96 *pchan = chan;
97
98 chan->id = -1;
99 chan->dev = dev;
100 chan->user_get = 4;
101 chan->user_put = 0;
102
103 INIT_LIST_HEAD(&chan->ramht_refs);
104
105 ret = nouveau_gpuobj_new_ref(dev, NULL, NULL, 0, 32768, 0x1000,
106 NVOBJ_FLAG_ZERO_ALLOC, &chan->ramin);
107 if (ret) {
108 NV_ERROR(dev, "Error allocating EVO channel memory: %d\n", ret);
109 nv50_evo_channel_del(pchan);
110 return ret;
111 }
112
Ben Skeggsb833ac22010-06-01 15:32:24 +1000113 ret = drm_mm_init(&chan->ramin_heap,
114 chan->ramin->gpuobj->im_pramin->start, 32768);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000115 if (ret) {
116 NV_ERROR(dev, "Error initialising EVO PRAMIN heap: %d\n", ret);
117 nv50_evo_channel_del(pchan);
118 return ret;
119 }
120
121 ret = nouveau_gpuobj_new_ref(dev, chan, chan, 0, 4096, 16,
122 0, &chan->ramht);
123 if (ret) {
124 NV_ERROR(dev, "Unable to allocate EVO RAMHT: %d\n", ret);
125 nv50_evo_channel_del(pchan);
126 return ret;
127 }
128
129 if (dev_priv->chipset != 0x50) {
130 ret = nv50_evo_dmaobj_new(chan, 0x3d, NvEvoFB16, 0x70, 0x19,
131 0, 0xffffffff);
132 if (ret) {
133 nv50_evo_channel_del(pchan);
134 return ret;
135 }
136
137
138 ret = nv50_evo_dmaobj_new(chan, 0x3d, NvEvoFB32, 0x7a, 0x19,
139 0, 0xffffffff);
140 if (ret) {
141 nv50_evo_channel_del(pchan);
142 return ret;
143 }
144 }
145
146 ret = nv50_evo_dmaobj_new(chan, 0x3d, NvEvoVRAM, 0, 0x19,
Ben Skeggsa76fb4e2010-03-18 09:45:20 +1000147 0, dev_priv->vram_size);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000148 if (ret) {
149 nv50_evo_channel_del(pchan);
150 return ret;
151 }
152
153 ret = nouveau_bo_new(dev, NULL, 4096, 0, TTM_PL_FLAG_VRAM, 0, 0,
154 false, true, &chan->pushbuf_bo);
155 if (ret == 0)
156 ret = nouveau_bo_pin(chan->pushbuf_bo, TTM_PL_FLAG_VRAM);
157 if (ret) {
158 NV_ERROR(dev, "Error creating EVO DMA push buffer: %d\n", ret);
159 nv50_evo_channel_del(pchan);
160 return ret;
161 }
162
163 ret = nouveau_bo_map(chan->pushbuf_bo);
164 if (ret) {
165 NV_ERROR(dev, "Error mapping EVO DMA push buffer: %d\n", ret);
166 nv50_evo_channel_del(pchan);
167 return ret;
168 }
169
170 chan->user = ioremap(pci_resource_start(dev->pdev, 0) +
171 NV50_PDISPLAY_USER(0), PAGE_SIZE);
172 if (!chan->user) {
173 NV_ERROR(dev, "Error mapping EVO control regs.\n");
174 nv50_evo_channel_del(pchan);
175 return -ENOMEM;
176 }
177
178 return 0;
179}
180
181int
182nv50_display_init(struct drm_device *dev)
183{
184 struct drm_nouveau_private *dev_priv = dev->dev_private;
185 struct nouveau_timer_engine *ptimer = &dev_priv->engine.timer;
186 struct nouveau_channel *evo = dev_priv->evo;
187 struct drm_connector *connector;
188 uint32_t val, ram_amount, hpd_en[2];
189 uint64_t start;
190 int ret, i;
191
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100192 NV_DEBUG_KMS(dev, "\n");
Ben Skeggs6ee73862009-12-11 19:24:15 +1000193
194 nv_wr32(dev, 0x00610184, nv_rd32(dev, 0x00614004));
195 /*
196 * I think the 0x006101XX range is some kind of main control area
197 * that enables things.
198 */
199 /* CRTC? */
200 for (i = 0; i < 2; i++) {
201 val = nv_rd32(dev, 0x00616100 + (i * 0x800));
202 nv_wr32(dev, 0x00610190 + (i * 0x10), val);
203 val = nv_rd32(dev, 0x00616104 + (i * 0x800));
204 nv_wr32(dev, 0x00610194 + (i * 0x10), val);
205 val = nv_rd32(dev, 0x00616108 + (i * 0x800));
206 nv_wr32(dev, 0x00610198 + (i * 0x10), val);
207 val = nv_rd32(dev, 0x0061610c + (i * 0x800));
208 nv_wr32(dev, 0x0061019c + (i * 0x10), val);
209 }
210 /* DAC */
211 for (i = 0; i < 3; i++) {
212 val = nv_rd32(dev, 0x0061a000 + (i * 0x800));
213 nv_wr32(dev, 0x006101d0 + (i * 0x04), val);
214 }
215 /* SOR */
216 for (i = 0; i < 4; i++) {
217 val = nv_rd32(dev, 0x0061c000 + (i * 0x800));
218 nv_wr32(dev, 0x006101e0 + (i * 0x04), val);
219 }
220 /* Something not yet in use, tv-out maybe. */
221 for (i = 0; i < 3; i++) {
222 val = nv_rd32(dev, 0x0061e000 + (i * 0x800));
223 nv_wr32(dev, 0x006101f0 + (i * 0x04), val);
224 }
225
226 for (i = 0; i < 3; i++) {
227 nv_wr32(dev, NV50_PDISPLAY_DAC_DPMS_CTRL(i), 0x00550000 |
228 NV50_PDISPLAY_DAC_DPMS_CTRL_PENDING);
229 nv_wr32(dev, NV50_PDISPLAY_DAC_CLK_CTRL1(i), 0x00000001);
230 }
231
232 /* This used to be in crtc unblank, but seems out of place there. */
233 nv_wr32(dev, NV50_PDISPLAY_UNK_380, 0);
234 /* RAM is clamped to 256 MiB. */
Ben Skeggsa76fb4e2010-03-18 09:45:20 +1000235 ram_amount = dev_priv->vram_size;
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100236 NV_DEBUG_KMS(dev, "ram_amount %d\n", ram_amount);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000237 if (ram_amount > 256*1024*1024)
238 ram_amount = 256*1024*1024;
239 nv_wr32(dev, NV50_PDISPLAY_RAM_AMOUNT, ram_amount - 1);
240 nv_wr32(dev, NV50_PDISPLAY_UNK_388, 0x150000);
241 nv_wr32(dev, NV50_PDISPLAY_UNK_38C, 0);
242
243 /* The precise purpose is unknown, i suspect it has something to do
244 * with text mode.
245 */
246 if (nv_rd32(dev, NV50_PDISPLAY_INTR_1) & 0x100) {
247 nv_wr32(dev, NV50_PDISPLAY_INTR_1, 0x100);
248 nv_wr32(dev, 0x006194e8, nv_rd32(dev, 0x006194e8) & ~1);
249 if (!nv_wait(0x006194e8, 2, 0)) {
250 NV_ERROR(dev, "timeout: (0x6194e8 & 2) != 0\n");
251 NV_ERROR(dev, "0x6194e8 = 0x%08x\n",
252 nv_rd32(dev, 0x6194e8));
253 return -EBUSY;
254 }
255 }
256
257 /* taken from nv bug #12637, attempts to un-wedge the hw if it's
258 * stuck in some unspecified state
259 */
260 start = ptimer->read(dev);
261 nv_wr32(dev, NV50_PDISPLAY_CHANNEL_STAT(0), 0x2b00);
262 while ((val = nv_rd32(dev, NV50_PDISPLAY_CHANNEL_STAT(0))) & 0x1e0000) {
263 if ((val & 0x9f0000) == 0x20000)
264 nv_wr32(dev, NV50_PDISPLAY_CHANNEL_STAT(0),
265 val | 0x800000);
266
267 if ((val & 0x3f0000) == 0x30000)
268 nv_wr32(dev, NV50_PDISPLAY_CHANNEL_STAT(0),
269 val | 0x200000);
270
271 if (ptimer->read(dev) - start > 1000000000ULL) {
272 NV_ERROR(dev, "timeout: (0x610200 & 0x1e0000) != 0\n");
273 NV_ERROR(dev, "0x610200 = 0x%08x\n", val);
274 return -EBUSY;
275 }
276 }
277
278 nv_wr32(dev, NV50_PDISPLAY_CTRL_STATE, NV50_PDISPLAY_CTRL_STATE_ENABLE);
279 nv_wr32(dev, NV50_PDISPLAY_CHANNEL_STAT(0), 0x1000b03);
280 if (!nv_wait(NV50_PDISPLAY_CHANNEL_STAT(0), 0x40000000, 0x40000000)) {
281 NV_ERROR(dev, "timeout: (0x610200 & 0x40000000) == 0x40000000\n");
282 NV_ERROR(dev, "0x610200 = 0x%08x\n",
283 nv_rd32(dev, NV50_PDISPLAY_CHANNEL_STAT(0)));
284 return -EBUSY;
285 }
286
287 for (i = 0; i < 2; i++) {
288 nv_wr32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i), 0x2000);
289 if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i),
290 NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS, 0)) {
291 NV_ERROR(dev, "timeout: CURSOR_CTRL2_STATUS == 0\n");
292 NV_ERROR(dev, "CURSOR_CTRL2 = 0x%08x\n",
293 nv_rd32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i)));
294 return -EBUSY;
295 }
296
297 nv_wr32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i),
298 NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_ON);
299 if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i),
300 NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS,
301 NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS_ACTIVE)) {
302 NV_ERROR(dev, "timeout: "
303 "CURSOR_CTRL2_STATUS_ACTIVE(%d)\n", i);
304 NV_ERROR(dev, "CURSOR_CTRL2(%d) = 0x%08x\n", i,
305 nv_rd32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i)));
306 return -EBUSY;
307 }
308 }
309
310 nv_wr32(dev, NV50_PDISPLAY_OBJECTS, (evo->ramin->instance >> 8) | 9);
311
312 /* initialise fifo */
313 nv_wr32(dev, NV50_PDISPLAY_CHANNEL_DMA_CB(0),
314 ((evo->pushbuf_bo->bo.mem.mm_node->start << PAGE_SHIFT) >> 8) |
315 NV50_PDISPLAY_CHANNEL_DMA_CB_LOCATION_VRAM |
316 NV50_PDISPLAY_CHANNEL_DMA_CB_VALID);
317 nv_wr32(dev, NV50_PDISPLAY_CHANNEL_UNK2(0), 0x00010000);
318 nv_wr32(dev, NV50_PDISPLAY_CHANNEL_UNK3(0), 0x00000002);
319 if (!nv_wait(0x610200, 0x80000000, 0x00000000)) {
320 NV_ERROR(dev, "timeout: (0x610200 & 0x80000000) == 0\n");
321 NV_ERROR(dev, "0x610200 = 0x%08x\n", nv_rd32(dev, 0x610200));
322 return -EBUSY;
323 }
324 nv_wr32(dev, NV50_PDISPLAY_CHANNEL_STAT(0),
325 (nv_rd32(dev, NV50_PDISPLAY_CHANNEL_STAT(0)) & ~0x00000003) |
326 NV50_PDISPLAY_CHANNEL_STAT_DMA_ENABLED);
327 nv_wr32(dev, NV50_PDISPLAY_USER_PUT(0), 0);
328 nv_wr32(dev, NV50_PDISPLAY_CHANNEL_STAT(0), 0x01000003 |
329 NV50_PDISPLAY_CHANNEL_STAT_DMA_ENABLED);
330 nv_wr32(dev, 0x610300, nv_rd32(dev, 0x610300) & ~1);
331
332 evo->dma.max = (4096/4) - 2;
333 evo->dma.put = 0;
334 evo->dma.cur = evo->dma.put;
335 evo->dma.free = evo->dma.max - evo->dma.cur;
336
337 ret = RING_SPACE(evo, NOUVEAU_DMA_SKIPS);
338 if (ret)
339 return ret;
340
341 for (i = 0; i < NOUVEAU_DMA_SKIPS; i++)
342 OUT_RING(evo, 0);
343
344 ret = RING_SPACE(evo, 11);
345 if (ret)
346 return ret;
347 BEGIN_RING(evo, 0, NV50_EVO_UNK84, 2);
348 OUT_RING(evo, NV50_EVO_UNK84_NOTIFY_DISABLED);
349 OUT_RING(evo, NV50_EVO_DMA_NOTIFY_HANDLE_NONE);
350 BEGIN_RING(evo, 0, NV50_EVO_CRTC(0, FB_DMA), 1);
351 OUT_RING(evo, NV50_EVO_CRTC_FB_DMA_HANDLE_NONE);
352 BEGIN_RING(evo, 0, NV50_EVO_CRTC(0, UNK0800), 1);
353 OUT_RING(evo, 0);
354 BEGIN_RING(evo, 0, NV50_EVO_CRTC(0, DISPLAY_START), 1);
355 OUT_RING(evo, 0);
356 BEGIN_RING(evo, 0, NV50_EVO_CRTC(0, UNK082C), 1);
357 OUT_RING(evo, 0);
358 FIRE_RING(evo);
359 if (!nv_wait(0x640004, 0xffffffff, evo->dma.put << 2))
360 NV_ERROR(dev, "evo pushbuf stalled\n");
361
362 /* enable clock change interrupts. */
363 nv_wr32(dev, 0x610028, 0x00010001);
364 nv_wr32(dev, NV50_PDISPLAY_INTR_EN, (NV50_PDISPLAY_INTR_EN_CLK_UNK10 |
365 NV50_PDISPLAY_INTR_EN_CLK_UNK20 |
366 NV50_PDISPLAY_INTR_EN_CLK_UNK40));
367
368 /* enable hotplug interrupts */
369 hpd_en[0] = hpd_en[1] = 0;
370 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
371 struct nouveau_connector *conn = nouveau_connector(connector);
372 struct dcb_gpio_entry *gpio;
373
Ben Skeggs11575632010-02-24 13:45:57 +1000374 if (conn->dcb->gpio_tag == 0xff)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000375 continue;
376
377 gpio = nouveau_bios_gpio_entry(dev, conn->dcb->gpio_tag);
378 if (!gpio)
379 continue;
380
381 hpd_en[gpio->line >> 4] |= (0x00010001 << (gpio->line & 0xf));
382 }
383
384 nv_wr32(dev, 0xe054, 0xffffffff);
385 nv_wr32(dev, 0xe050, hpd_en[0]);
386 if (dev_priv->chipset >= 0x90) {
387 nv_wr32(dev, 0xe074, 0xffffffff);
388 nv_wr32(dev, 0xe070, hpd_en[1]);
389 }
390
391 return 0;
392}
393
394static int nv50_display_disable(struct drm_device *dev)
395{
396 struct drm_nouveau_private *dev_priv = dev->dev_private;
397 struct drm_crtc *drm_crtc;
398 int ret, i;
399
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100400 NV_DEBUG_KMS(dev, "\n");
Ben Skeggs6ee73862009-12-11 19:24:15 +1000401
402 list_for_each_entry(drm_crtc, &dev->mode_config.crtc_list, head) {
403 struct nouveau_crtc *crtc = nouveau_crtc(drm_crtc);
404
405 nv50_crtc_blank(crtc, true);
406 }
407
408 ret = RING_SPACE(dev_priv->evo, 2);
409 if (ret == 0) {
410 BEGIN_RING(dev_priv->evo, 0, NV50_EVO_UPDATE, 1);
411 OUT_RING(dev_priv->evo, 0);
412 }
413 FIRE_RING(dev_priv->evo);
414
415 /* Almost like ack'ing a vblank interrupt, maybe in the spirit of
416 * cleaning up?
417 */
418 list_for_each_entry(drm_crtc, &dev->mode_config.crtc_list, head) {
419 struct nouveau_crtc *crtc = nouveau_crtc(drm_crtc);
420 uint32_t mask = NV50_PDISPLAY_INTR_1_VBLANK_CRTC_(crtc->index);
421
422 if (!crtc->base.enabled)
423 continue;
424
425 nv_wr32(dev, NV50_PDISPLAY_INTR_1, mask);
426 if (!nv_wait(NV50_PDISPLAY_INTR_1, mask, mask)) {
427 NV_ERROR(dev, "timeout: (0x610024 & 0x%08x) == "
428 "0x%08x\n", mask, mask);
429 NV_ERROR(dev, "0x610024 = 0x%08x\n",
430 nv_rd32(dev, NV50_PDISPLAY_INTR_1));
431 }
432 }
433
434 nv_wr32(dev, NV50_PDISPLAY_CHANNEL_STAT(0), 0);
435 nv_wr32(dev, NV50_PDISPLAY_CTRL_STATE, 0);
436 if (!nv_wait(NV50_PDISPLAY_CHANNEL_STAT(0), 0x1e0000, 0)) {
437 NV_ERROR(dev, "timeout: (0x610200 & 0x1e0000) == 0\n");
438 NV_ERROR(dev, "0x610200 = 0x%08x\n",
439 nv_rd32(dev, NV50_PDISPLAY_CHANNEL_STAT(0)));
440 }
441
442 for (i = 0; i < 3; i++) {
443 if (!nv_wait(NV50_PDISPLAY_SOR_DPMS_STATE(i),
444 NV50_PDISPLAY_SOR_DPMS_STATE_WAIT, 0)) {
445 NV_ERROR(dev, "timeout: SOR_DPMS_STATE_WAIT(%d) == 0\n", i);
446 NV_ERROR(dev, "SOR_DPMS_STATE(%d) = 0x%08x\n", i,
447 nv_rd32(dev, NV50_PDISPLAY_SOR_DPMS_STATE(i)));
448 }
449 }
450
451 /* disable interrupts. */
452 nv_wr32(dev, NV50_PDISPLAY_INTR_EN, 0x00000000);
453
454 /* disable hotplug interrupts */
455 nv_wr32(dev, 0xe054, 0xffffffff);
456 nv_wr32(dev, 0xe050, 0x00000000);
457 if (dev_priv->chipset >= 0x90) {
458 nv_wr32(dev, 0xe074, 0xffffffff);
459 nv_wr32(dev, 0xe070, 0x00000000);
460 }
461 return 0;
462}
463
464int nv50_display_create(struct drm_device *dev)
465{
466 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggs04a39c52010-02-24 10:03:05 +1000467 struct dcb_table *dcb = &dev_priv->vbios.dcb;
Ben Skeggs8f1a6082010-06-28 14:35:50 +1000468 struct drm_connector *connector, *ct;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000469 int ret, i;
470
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100471 NV_DEBUG_KMS(dev, "\n");
Ben Skeggs6ee73862009-12-11 19:24:15 +1000472
473 /* init basic kernel modesetting */
474 drm_mode_config_init(dev);
475
476 /* Initialise some optional connector properties. */
477 drm_mode_create_scaling_mode_property(dev);
478 drm_mode_create_dithering_property(dev);
479
480 dev->mode_config.min_width = 0;
481 dev->mode_config.min_height = 0;
482
483 dev->mode_config.funcs = (void *)&nouveau_mode_config_funcs;
484
485 dev->mode_config.max_width = 8192;
486 dev->mode_config.max_height = 8192;
487
488 dev->mode_config.fb_base = dev_priv->fb_phys;
489
490 /* Create EVO channel */
491 ret = nv50_evo_channel_new(dev, &dev_priv->evo);
492 if (ret) {
493 NV_ERROR(dev, "Error creating EVO channel: %d\n", ret);
494 return ret;
495 }
496
497 /* Create CRTC objects */
498 for (i = 0; i < 2; i++)
499 nv50_crtc_create(dev, i);
500
501 /* We setup the encoders from the BIOS table */
502 for (i = 0 ; i < dcb->entries; i++) {
503 struct dcb_entry *entry = &dcb->entry[i];
504
505 if (entry->location != DCB_LOC_ON_CHIP) {
506 NV_WARN(dev, "Off-chip encoder %d/%d unsupported\n",
507 entry->type, ffs(entry->or) - 1);
508 continue;
509 }
510
Ben Skeggs8f1a6082010-06-28 14:35:50 +1000511 connector = nouveau_connector_create(dev, entry->connector);
512 if (IS_ERR(connector))
513 continue;
514
Ben Skeggs6ee73862009-12-11 19:24:15 +1000515 switch (entry->type) {
516 case OUTPUT_TMDS:
517 case OUTPUT_LVDS:
518 case OUTPUT_DP:
Ben Skeggs8f1a6082010-06-28 14:35:50 +1000519 nv50_sor_create(connector, entry);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000520 break;
521 case OUTPUT_ANALOG:
Ben Skeggs8f1a6082010-06-28 14:35:50 +1000522 nv50_dac_create(connector, entry);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000523 break;
524 default:
525 NV_WARN(dev, "DCB encoder %d unknown\n", entry->type);
526 continue;
527 }
Ben Skeggs6ee73862009-12-11 19:24:15 +1000528 }
529
Ben Skeggs8f1a6082010-06-28 14:35:50 +1000530 list_for_each_entry_safe(connector, ct,
531 &dev->mode_config.connector_list, head) {
532 if (!connector->encoder_ids[0]) {
533 NV_WARN(dev, "%s has no encoders, removing\n",
534 drm_get_connector_name(connector));
535 connector->funcs->destroy(connector);
536 }
Ben Skeggs6ee73862009-12-11 19:24:15 +1000537 }
538
539 ret = nv50_display_init(dev);
Ben Skeggsa1663ed2010-03-25 16:01:04 +1000540 if (ret) {
541 nv50_display_destroy(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000542 return ret;
Ben Skeggsa1663ed2010-03-25 16:01:04 +1000543 }
Ben Skeggs6ee73862009-12-11 19:24:15 +1000544
545 return 0;
546}
547
548int nv50_display_destroy(struct drm_device *dev)
549{
550 struct drm_nouveau_private *dev_priv = dev->dev_private;
551
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100552 NV_DEBUG_KMS(dev, "\n");
Ben Skeggs6ee73862009-12-11 19:24:15 +1000553
554 drm_mode_config_cleanup(dev);
555
556 nv50_display_disable(dev);
557 nv50_evo_channel_del(&dev_priv->evo);
558
559 return 0;
560}
561
562static inline uint32_t
563nv50_display_mode_ctrl(struct drm_device *dev, bool sor, int or)
564{
565 struct drm_nouveau_private *dev_priv = dev->dev_private;
566 uint32_t mc;
567
568 if (sor) {
569 if (dev_priv->chipset < 0x90 ||
570 dev_priv->chipset == 0x92 || dev_priv->chipset == 0xa0)
571 mc = nv_rd32(dev, NV50_PDISPLAY_SOR_MODE_CTRL_P(or));
572 else
573 mc = nv_rd32(dev, NV90_PDISPLAY_SOR_MODE_CTRL_P(or));
574 } else {
575 mc = nv_rd32(dev, NV50_PDISPLAY_DAC_MODE_CTRL_P(or));
576 }
577
578 return mc;
579}
580
581static int
582nv50_display_irq_head(struct drm_device *dev, int *phead,
583 struct dcb_entry **pdcbent)
584{
585 struct drm_nouveau_private *dev_priv = dev->dev_private;
586 uint32_t unk30 = nv_rd32(dev, NV50_PDISPLAY_UNK30_CTRL);
587 uint32_t dac = 0, sor = 0;
588 int head, i, or = 0, type = OUTPUT_ANY;
589
590 /* We're assuming that head 0 *or* head 1 will be active here,
591 * and not both. I'm not sure if the hw will even signal both
592 * ever, but it definitely shouldn't for us as we commit each
593 * CRTC separately, and submission will be blocked by the GPU
594 * until we handle each in turn.
595 */
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100596 NV_DEBUG_KMS(dev, "0x610030: 0x%08x\n", unk30);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000597 head = ffs((unk30 >> 9) & 3) - 1;
598 if (head < 0)
599 return -EINVAL;
600
601 /* This assumes CRTCs are never bound to multiple encoders, which
602 * should be the case.
603 */
604 for (i = 0; i < 3 && type == OUTPUT_ANY; i++) {
605 uint32_t mc = nv50_display_mode_ctrl(dev, false, i);
606 if (!(mc & (1 << head)))
607 continue;
608
609 switch ((mc >> 8) & 0xf) {
610 case 0: type = OUTPUT_ANALOG; break;
611 case 1: type = OUTPUT_TV; break;
612 default:
613 NV_ERROR(dev, "unknown dac mode_ctrl: 0x%08x\n", dac);
614 return -1;
615 }
616
617 or = i;
618 }
619
620 for (i = 0; i < 4 && type == OUTPUT_ANY; i++) {
621 uint32_t mc = nv50_display_mode_ctrl(dev, true, i);
622 if (!(mc & (1 << head)))
623 continue;
624
625 switch ((mc >> 8) & 0xf) {
626 case 0: type = OUTPUT_LVDS; break;
627 case 1: type = OUTPUT_TMDS; break;
628 case 2: type = OUTPUT_TMDS; break;
629 case 5: type = OUTPUT_TMDS; break;
630 case 8: type = OUTPUT_DP; break;
631 case 9: type = OUTPUT_DP; break;
632 default:
633 NV_ERROR(dev, "unknown sor mode_ctrl: 0x%08x\n", sor);
634 return -1;
635 }
636
637 or = i;
638 }
639
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100640 NV_DEBUG_KMS(dev, "type %d, or %d\n", type, or);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000641 if (type == OUTPUT_ANY) {
642 NV_ERROR(dev, "unknown encoder!!\n");
643 return -1;
644 }
645
Ben Skeggs04a39c52010-02-24 10:03:05 +1000646 for (i = 0; i < dev_priv->vbios.dcb.entries; i++) {
647 struct dcb_entry *dcbent = &dev_priv->vbios.dcb.entry[i];
Ben Skeggs6ee73862009-12-11 19:24:15 +1000648
649 if (dcbent->type != type)
650 continue;
651
652 if (!(dcbent->or & (1 << or)))
653 continue;
654
655 *phead = head;
656 *pdcbent = dcbent;
657 return 0;
658 }
659
660 NV_ERROR(dev, "no DCB entry for %d %d\n", dac != 0, or);
661 return 0;
662}
663
664static uint32_t
665nv50_display_script_select(struct drm_device *dev, struct dcb_entry *dcbent,
666 int pxclk)
667{
668 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggs75c722d2009-12-21 12:16:52 +1000669 struct nouveau_connector *nv_connector = NULL;
670 struct drm_encoder *encoder;
Ben Skeggs04a39c52010-02-24 10:03:05 +1000671 struct nvbios *bios = &dev_priv->vbios;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000672 uint32_t mc, script = 0, or;
673
Ben Skeggs75c722d2009-12-21 12:16:52 +1000674 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
675 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
676
677 if (nv_encoder->dcb != dcbent)
678 continue;
679
680 nv_connector = nouveau_encoder_connector_get(nv_encoder);
681 break;
682 }
683
Ben Skeggs6ee73862009-12-11 19:24:15 +1000684 or = ffs(dcbent->or) - 1;
685 mc = nv50_display_mode_ctrl(dev, dcbent->type != OUTPUT_ANALOG, or);
686 switch (dcbent->type) {
687 case OUTPUT_LVDS:
688 script = (mc >> 8) & 0xf;
Ben Skeggs04a39c52010-02-24 10:03:05 +1000689 if (bios->fp_no_ddc) {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000690 if (bios->fp.dual_link)
691 script |= 0x0100;
692 if (bios->fp.if_is_24bit)
693 script |= 0x0200;
694 } else {
695 if (pxclk >= bios->fp.duallink_transition_clk) {
696 script |= 0x0100;
697 if (bios->fp.strapless_is_24bit & 2)
698 script |= 0x0200;
699 } else
700 if (bios->fp.strapless_is_24bit & 1)
701 script |= 0x0200;
Ben Skeggs75c722d2009-12-21 12:16:52 +1000702
703 if (nv_connector && nv_connector->edid &&
704 (nv_connector->edid->revision >= 4) &&
705 (nv_connector->edid->input & 0x70) >= 0x20)
706 script |= 0x0200;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000707 }
708
709 if (nouveau_uscript_lvds >= 0) {
710 NV_INFO(dev, "override script 0x%04x with 0x%04x "
711 "for output LVDS-%d\n", script,
712 nouveau_uscript_lvds, or);
713 script = nouveau_uscript_lvds;
714 }
715 break;
716 case OUTPUT_TMDS:
717 script = (mc >> 8) & 0xf;
718 if (pxclk >= 165000)
719 script |= 0x0100;
720
721 if (nouveau_uscript_tmds >= 0) {
722 NV_INFO(dev, "override script 0x%04x with 0x%04x "
723 "for output TMDS-%d\n", script,
724 nouveau_uscript_tmds, or);
725 script = nouveau_uscript_tmds;
726 }
727 break;
728 case OUTPUT_DP:
729 script = (mc >> 8) & 0xf;
730 break;
731 case OUTPUT_ANALOG:
732 script = 0xff;
733 break;
734 default:
735 NV_ERROR(dev, "modeset on unsupported output type!\n");
736 break;
737 }
738
739 return script;
740}
741
742static void
743nv50_display_vblank_crtc_handler(struct drm_device *dev, int crtc)
744{
745 struct drm_nouveau_private *dev_priv = dev->dev_private;
746 struct nouveau_channel *chan;
747 struct list_head *entry, *tmp;
748
749 list_for_each_safe(entry, tmp, &dev_priv->vbl_waiting) {
750 chan = list_entry(entry, struct nouveau_channel, nvsw.vbl_wait);
751
752 nouveau_bo_wr32(chan->notifier_bo, chan->nvsw.vblsem_offset,
753 chan->nvsw.vblsem_rval);
754 list_del(&chan->nvsw.vbl_wait);
755 }
756}
757
758static void
759nv50_display_vblank_handler(struct drm_device *dev, uint32_t intr)
760{
761 intr &= NV50_PDISPLAY_INTR_1_VBLANK_CRTC;
762
763 if (intr & NV50_PDISPLAY_INTR_1_VBLANK_CRTC_0)
764 nv50_display_vblank_crtc_handler(dev, 0);
765
766 if (intr & NV50_PDISPLAY_INTR_1_VBLANK_CRTC_1)
767 nv50_display_vblank_crtc_handler(dev, 1);
768
769 nv_wr32(dev, NV50_PDISPLAY_INTR_EN, nv_rd32(dev,
770 NV50_PDISPLAY_INTR_EN) & ~intr);
771 nv_wr32(dev, NV50_PDISPLAY_INTR_1, intr);
772}
773
774static void
775nv50_display_unk10_handler(struct drm_device *dev)
776{
777 struct dcb_entry *dcbent;
778 int head, ret;
779
780 ret = nv50_display_irq_head(dev, &head, &dcbent);
781 if (ret)
782 goto ack;
783
784 nv_wr32(dev, 0x619494, nv_rd32(dev, 0x619494) & ~8);
785
786 nouveau_bios_run_display_table(dev, dcbent, 0, -1);
787
788ack:
789 nv_wr32(dev, NV50_PDISPLAY_INTR_1, NV50_PDISPLAY_INTR_1_CLK_UNK10);
790 nv_wr32(dev, 0x610030, 0x80000000);
791}
792
793static void
Ben Skeggsafa3b4c2010-04-23 08:21:48 +1000794nv50_display_unk20_dp_hack(struct drm_device *dev, struct dcb_entry *dcb)
795{
796 int or = ffs(dcb->or) - 1, link = !(dcb->dpconf.sor.link & 1);
797 struct drm_encoder *encoder;
798 uint32_t tmp, unk0 = 0, unk1 = 0;
799
800 if (dcb->type != OUTPUT_DP)
801 return;
802
803 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
804 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
805
806 if (nv_encoder->dcb == dcb) {
807 unk0 = nv_encoder->dp.unk0;
808 unk1 = nv_encoder->dp.unk1;
809 break;
810 }
811 }
812
813 if (unk0 || unk1) {
814 tmp = nv_rd32(dev, NV50_SOR_DP_CTRL(or, link));
815 tmp &= 0xfffffe03;
816 nv_wr32(dev, NV50_SOR_DP_CTRL(or, link), tmp | unk0);
817
818 tmp = nv_rd32(dev, NV50_SOR_DP_UNK128(or, link));
819 tmp &= 0xfef080c0;
820 nv_wr32(dev, NV50_SOR_DP_UNK128(or, link), tmp | unk1);
821 }
822}
823
824static void
Ben Skeggs6ee73862009-12-11 19:24:15 +1000825nv50_display_unk20_handler(struct drm_device *dev)
826{
827 struct dcb_entry *dcbent;
828 uint32_t tmp, pclk, script;
829 int head, or, ret;
830
831 ret = nv50_display_irq_head(dev, &head, &dcbent);
832 if (ret)
833 goto ack;
834 or = ffs(dcbent->or) - 1;
835 pclk = nv_rd32(dev, NV50_PDISPLAY_CRTC_P(head, CLOCK)) & 0x3fffff;
836 script = nv50_display_script_select(dev, dcbent, pclk);
837
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100838 NV_DEBUG_KMS(dev, "head %d pxclk: %dKHz\n", head, pclk);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000839
840 if (dcbent->type != OUTPUT_DP)
841 nouveau_bios_run_display_table(dev, dcbent, 0, -2);
842
843 nv50_crtc_set_clock(dev, head, pclk);
844
845 nouveau_bios_run_display_table(dev, dcbent, script, pclk);
846
Ben Skeggsafa3b4c2010-04-23 08:21:48 +1000847 nv50_display_unk20_dp_hack(dev, dcbent);
848
Ben Skeggs6ee73862009-12-11 19:24:15 +1000849 tmp = nv_rd32(dev, NV50_PDISPLAY_CRTC_CLK_CTRL2(head));
850 tmp &= ~0x000000f;
851 nv_wr32(dev, NV50_PDISPLAY_CRTC_CLK_CTRL2(head), tmp);
852
853 if (dcbent->type != OUTPUT_ANALOG) {
854 tmp = nv_rd32(dev, NV50_PDISPLAY_SOR_CLK_CTRL2(or));
855 tmp &= ~0x00000f0f;
856 if (script & 0x0100)
857 tmp |= 0x00000101;
858 nv_wr32(dev, NV50_PDISPLAY_SOR_CLK_CTRL2(or), tmp);
859 } else {
860 nv_wr32(dev, NV50_PDISPLAY_DAC_CLK_CTRL2(or), 0);
861 }
862
863ack:
864 nv_wr32(dev, NV50_PDISPLAY_INTR_1, NV50_PDISPLAY_INTR_1_CLK_UNK20);
865 nv_wr32(dev, 0x610030, 0x80000000);
866}
867
868static void
869nv50_display_unk40_handler(struct drm_device *dev)
870{
871 struct dcb_entry *dcbent;
872 int head, pclk, script, ret;
873
874 ret = nv50_display_irq_head(dev, &head, &dcbent);
875 if (ret)
876 goto ack;
877 pclk = nv_rd32(dev, NV50_PDISPLAY_CRTC_P(head, CLOCK)) & 0x3fffff;
878 script = nv50_display_script_select(dev, dcbent, pclk);
879
880 nouveau_bios_run_display_table(dev, dcbent, script, -pclk);
881
882ack:
883 nv_wr32(dev, NV50_PDISPLAY_INTR_1, NV50_PDISPLAY_INTR_1_CLK_UNK40);
884 nv_wr32(dev, 0x610030, 0x80000000);
885 nv_wr32(dev, 0x619494, nv_rd32(dev, 0x619494) | 8);
886}
887
888void
889nv50_display_irq_handler_bh(struct work_struct *work)
890{
891 struct drm_nouveau_private *dev_priv =
892 container_of(work, struct drm_nouveau_private, irq_work);
893 struct drm_device *dev = dev_priv->dev;
894
895 for (;;) {
896 uint32_t intr0 = nv_rd32(dev, NV50_PDISPLAY_INTR_0);
897 uint32_t intr1 = nv_rd32(dev, NV50_PDISPLAY_INTR_1);
898
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100899 NV_DEBUG_KMS(dev, "PDISPLAY_INTR_BH 0x%08x 0x%08x\n", intr0, intr1);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000900
901 if (intr1 & NV50_PDISPLAY_INTR_1_CLK_UNK10)
902 nv50_display_unk10_handler(dev);
903 else
904 if (intr1 & NV50_PDISPLAY_INTR_1_CLK_UNK20)
905 nv50_display_unk20_handler(dev);
906 else
907 if (intr1 & NV50_PDISPLAY_INTR_1_CLK_UNK40)
908 nv50_display_unk40_handler(dev);
909 else
910 break;
911 }
912
913 nv_wr32(dev, NV03_PMC_INTR_EN_0, 1);
914}
915
916static void
917nv50_display_error_handler(struct drm_device *dev)
918{
919 uint32_t addr, data;
920
921 nv_wr32(dev, NV50_PDISPLAY_INTR_0, 0x00010000);
922 addr = nv_rd32(dev, NV50_PDISPLAY_TRAPPED_ADDR);
923 data = nv_rd32(dev, NV50_PDISPLAY_TRAPPED_DATA);
924
925 NV_ERROR(dev, "EvoCh %d Mthd 0x%04x Data 0x%08x (0x%04x 0x%02x)\n",
926 0, addr & 0xffc, data, addr >> 16, (addr >> 12) & 0xf);
927
928 nv_wr32(dev, NV50_PDISPLAY_TRAPPED_ADDR, 0x90000000);
929}
930
Ben Skeggsa5acac62010-03-30 15:14:41 +1000931void
932nv50_display_irq_hotplug_bh(struct work_struct *work)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000933{
Ben Skeggsa5acac62010-03-30 15:14:41 +1000934 struct drm_nouveau_private *dev_priv =
935 container_of(work, struct drm_nouveau_private, hpd_work);
936 struct drm_device *dev = dev_priv->dev;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000937 struct drm_connector *connector;
938 const uint32_t gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 };
939 uint32_t unplug_mask, plug_mask, change_mask;
940 uint32_t hpd0, hpd1 = 0;
941
942 hpd0 = nv_rd32(dev, 0xe054) & nv_rd32(dev, 0xe050);
943 if (dev_priv->chipset >= 0x90)
944 hpd1 = nv_rd32(dev, 0xe074) & nv_rd32(dev, 0xe070);
945
946 plug_mask = (hpd0 & 0x0000ffff) | (hpd1 << 16);
947 unplug_mask = (hpd0 >> 16) | (hpd1 & 0xffff0000);
948 change_mask = plug_mask | unplug_mask;
949
950 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
951 struct drm_encoder_helper_funcs *helper;
952 struct nouveau_connector *nv_connector =
953 nouveau_connector(connector);
954 struct nouveau_encoder *nv_encoder;
955 struct dcb_gpio_entry *gpio;
956 uint32_t reg;
957 bool plugged;
958
959 if (!nv_connector->dcb)
960 continue;
961
962 gpio = nouveau_bios_gpio_entry(dev, nv_connector->dcb->gpio_tag);
963 if (!gpio || !(change_mask & (1 << gpio->line)))
964 continue;
965
966 reg = nv_rd32(dev, gpio_reg[gpio->line >> 3]);
967 plugged = !!(reg & (4 << ((gpio->line & 7) << 2)));
968 NV_INFO(dev, "%splugged %s\n", plugged ? "" : "un",
969 drm_get_connector_name(connector)) ;
970
971 if (!connector->encoder || !connector->encoder->crtc ||
972 !connector->encoder->crtc->enabled)
973 continue;
974 nv_encoder = nouveau_encoder(connector->encoder);
975 helper = connector->encoder->helper_private;
976
977 if (nv_encoder->dcb->type != OUTPUT_DP)
978 continue;
979
980 if (plugged)
981 helper->dpms(connector->encoder, DRM_MODE_DPMS_ON);
982 else
983 helper->dpms(connector->encoder, DRM_MODE_DPMS_OFF);
984 }
985
986 nv_wr32(dev, 0xe054, nv_rd32(dev, 0xe054));
987 if (dev_priv->chipset >= 0x90)
988 nv_wr32(dev, 0xe074, nv_rd32(dev, 0xe074));
Dave Airlie4abe3522010-03-30 05:34:18 +0000989
Dave Airlieeb1f8e42010-05-07 06:42:51 +0000990 drm_helper_hpd_irq_event(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000991}
992
993void
994nv50_display_irq_handler(struct drm_device *dev)
995{
996 struct drm_nouveau_private *dev_priv = dev->dev_private;
997 uint32_t delayed = 0;
998
Ben Skeggsa5acac62010-03-30 15:14:41 +1000999 if (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_HOTPLUG) {
1000 if (!work_pending(&dev_priv->hpd_work))
1001 queue_work(dev_priv->wq, &dev_priv->hpd_work);
1002 }
Ben Skeggs6ee73862009-12-11 19:24:15 +10001003
1004 while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) {
1005 uint32_t intr0 = nv_rd32(dev, NV50_PDISPLAY_INTR_0);
1006 uint32_t intr1 = nv_rd32(dev, NV50_PDISPLAY_INTR_1);
1007 uint32_t clock;
1008
Maarten Maathuisef2bb502009-12-13 16:53:12 +01001009 NV_DEBUG_KMS(dev, "PDISPLAY_INTR 0x%08x 0x%08x\n", intr0, intr1);
Ben Skeggs6ee73862009-12-11 19:24:15 +10001010
1011 if (!intr0 && !(intr1 & ~delayed))
1012 break;
1013
1014 if (intr0 & 0x00010000) {
1015 nv50_display_error_handler(dev);
1016 intr0 &= ~0x00010000;
1017 }
1018
1019 if (intr1 & NV50_PDISPLAY_INTR_1_VBLANK_CRTC) {
1020 nv50_display_vblank_handler(dev, intr1);
1021 intr1 &= ~NV50_PDISPLAY_INTR_1_VBLANK_CRTC;
1022 }
1023
1024 clock = (intr1 & (NV50_PDISPLAY_INTR_1_CLK_UNK10 |
1025 NV50_PDISPLAY_INTR_1_CLK_UNK20 |
1026 NV50_PDISPLAY_INTR_1_CLK_UNK40));
1027 if (clock) {
1028 nv_wr32(dev, NV03_PMC_INTR_EN_0, 0);
1029 if (!work_pending(&dev_priv->irq_work))
1030 queue_work(dev_priv->wq, &dev_priv->irq_work);
1031 delayed |= clock;
1032 intr1 &= ~clock;
1033 }
1034
1035 if (intr0) {
1036 NV_ERROR(dev, "unknown PDISPLAY_INTR_0: 0x%08x\n", intr0);
1037 nv_wr32(dev, NV50_PDISPLAY_INTR_0, intr0);
1038 }
1039
1040 if (intr1) {
1041 NV_ERROR(dev,
1042 "unknown PDISPLAY_INTR_1: 0x%08x\n", intr1);
1043 nv_wr32(dev, NV50_PDISPLAY_INTR_1, intr1);
1044 }
1045 }
1046}
1047