blob: db100a8f231e05dfa06fddd5ee74f0a032023ef2 [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 Skeggsa8eaebc2010-09-01 15:24:31 +100033#include "nouveau_ramht.h"
Ben Skeggs6ee73862009-12-11 19:24:15 +100034#include "drm_crtc_helper.h"
35
Ben Skeggs8597a1b2010-09-06 11:39:25 +100036static inline int
37nv50_sor_nr(struct drm_device *dev)
38{
39 struct drm_nouveau_private *dev_priv = dev->dev_private;
40
41 if (dev_priv->chipset < 0x90 ||
42 dev_priv->chipset == 0x92 ||
43 dev_priv->chipset == 0xa0)
44 return 2;
45
46 return 4;
47}
48
Ben Skeggs6ee73862009-12-11 19:24:15 +100049int
Francisco Jerezc88c2e02010-07-24 17:37:33 +020050nv50_display_early_init(struct drm_device *dev)
51{
52 return 0;
53}
54
55void
56nv50_display_late_takedown(struct drm_device *dev)
57{
58}
59
60int
Ben Skeggs6ee73862009-12-11 19:24:15 +100061nv50_display_init(struct drm_device *dev)
62{
63 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggsee2e0132010-07-26 09:28:25 +100064 struct nouveau_gpio_engine *pgpio = &dev_priv->engine.gpio;
Ben Skeggs6ee73862009-12-11 19:24:15 +100065 struct drm_connector *connector;
Ben Skeggsb7bc6132010-10-19 13:05:51 +100066 struct nouveau_channel *evo;
Ben Skeggs6ee73862009-12-11 19:24:15 +100067 int ret, i;
Ben Skeggscbb4b602010-10-18 12:34:04 +100068 u32 val;
Ben Skeggs6ee73862009-12-11 19:24:15 +100069
Maarten Maathuisef2bb502009-12-13 16:53:12 +010070 NV_DEBUG_KMS(dev, "\n");
Ben Skeggs6ee73862009-12-11 19:24:15 +100071
72 nv_wr32(dev, 0x00610184, nv_rd32(dev, 0x00614004));
Ben Skeggs106ddad2010-10-19 11:14:17 +100073
Ben Skeggs6ee73862009-12-11 19:24:15 +100074 /*
75 * I think the 0x006101XX range is some kind of main control area
76 * that enables things.
77 */
78 /* CRTC? */
79 for (i = 0; i < 2; i++) {
80 val = nv_rd32(dev, 0x00616100 + (i * 0x800));
81 nv_wr32(dev, 0x00610190 + (i * 0x10), val);
82 val = nv_rd32(dev, 0x00616104 + (i * 0x800));
83 nv_wr32(dev, 0x00610194 + (i * 0x10), val);
84 val = nv_rd32(dev, 0x00616108 + (i * 0x800));
85 nv_wr32(dev, 0x00610198 + (i * 0x10), val);
86 val = nv_rd32(dev, 0x0061610c + (i * 0x800));
87 nv_wr32(dev, 0x0061019c + (i * 0x10), val);
88 }
Ben Skeggs106ddad2010-10-19 11:14:17 +100089
Ben Skeggs6ee73862009-12-11 19:24:15 +100090 /* DAC */
91 for (i = 0; i < 3; i++) {
92 val = nv_rd32(dev, 0x0061a000 + (i * 0x800));
93 nv_wr32(dev, 0x006101d0 + (i * 0x04), val);
94 }
Ben Skeggs106ddad2010-10-19 11:14:17 +100095
Ben Skeggs6ee73862009-12-11 19:24:15 +100096 /* SOR */
Ben Skeggs8597a1b2010-09-06 11:39:25 +100097 for (i = 0; i < nv50_sor_nr(dev); i++) {
Ben Skeggs6ee73862009-12-11 19:24:15 +100098 val = nv_rd32(dev, 0x0061c000 + (i * 0x800));
99 nv_wr32(dev, 0x006101e0 + (i * 0x04), val);
100 }
Ben Skeggs106ddad2010-10-19 11:14:17 +1000101
Ben Skeggs8597a1b2010-09-06 11:39:25 +1000102 /* EXT */
Ben Skeggs6ee73862009-12-11 19:24:15 +1000103 for (i = 0; i < 3; i++) {
104 val = nv_rd32(dev, 0x0061e000 + (i * 0x800));
105 nv_wr32(dev, 0x006101f0 + (i * 0x04), val);
106 }
107
108 for (i = 0; i < 3; i++) {
109 nv_wr32(dev, NV50_PDISPLAY_DAC_DPMS_CTRL(i), 0x00550000 |
110 NV50_PDISPLAY_DAC_DPMS_CTRL_PENDING);
111 nv_wr32(dev, NV50_PDISPLAY_DAC_CLK_CTRL1(i), 0x00000001);
112 }
113
Ben Skeggs6ee73862009-12-11 19:24:15 +1000114 /* The precise purpose is unknown, i suspect it has something to do
115 * with text mode.
116 */
117 if (nv_rd32(dev, NV50_PDISPLAY_INTR_1) & 0x100) {
118 nv_wr32(dev, NV50_PDISPLAY_INTR_1, 0x100);
119 nv_wr32(dev, 0x006194e8, nv_rd32(dev, 0x006194e8) & ~1);
Francisco Jerez4b5c1522010-09-07 17:34:44 +0200120 if (!nv_wait(dev, 0x006194e8, 2, 0)) {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000121 NV_ERROR(dev, "timeout: (0x6194e8 & 2) != 0\n");
122 NV_ERROR(dev, "0x6194e8 = 0x%08x\n",
123 nv_rd32(dev, 0x6194e8));
124 return -EBUSY;
125 }
126 }
127
Ben Skeggs6ee73862009-12-11 19:24:15 +1000128 for (i = 0; i < 2; i++) {
129 nv_wr32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i), 0x2000);
Francisco Jerez4b5c1522010-09-07 17:34:44 +0200130 if (!nv_wait(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i),
Ben Skeggs6ee73862009-12-11 19:24:15 +1000131 NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS, 0)) {
132 NV_ERROR(dev, "timeout: CURSOR_CTRL2_STATUS == 0\n");
133 NV_ERROR(dev, "CURSOR_CTRL2 = 0x%08x\n",
134 nv_rd32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i)));
135 return -EBUSY;
136 }
137
138 nv_wr32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i),
139 NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_ON);
Francisco Jerez4b5c1522010-09-07 17:34:44 +0200140 if (!nv_wait(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i),
Ben Skeggs6ee73862009-12-11 19:24:15 +1000141 NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS,
142 NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS_ACTIVE)) {
143 NV_ERROR(dev, "timeout: "
144 "CURSOR_CTRL2_STATUS_ACTIVE(%d)\n", i);
145 NV_ERROR(dev, "CURSOR_CTRL2(%d) = 0x%08x\n", i,
146 nv_rd32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(i)));
147 return -EBUSY;
148 }
149 }
150
Ben Skeggs106ddad2010-10-19 11:14:17 +1000151 nv_wr32(dev, NV50_PDISPLAY_PIO_CTRL, 0x00000000);
152 nv_wr32(dev, 0x610028, 0x00000000);
153 nv_mask(dev, NV50_PDISPLAY_INTR_0, 0x00000000, 0x00000000);
154 nv_mask(dev, NV50_PDISPLAY_INTR_1, 0x00000000, 0x00000000);
155 nv_wr32(dev, NV50_PDISPLAY_INTR_EN,
156 NV50_PDISPLAY_INTR_EN_CLK_UNK10 |
157 NV50_PDISPLAY_INTR_EN_CLK_UNK20 |
158 NV50_PDISPLAY_INTR_EN_CLK_UNK40);
159
160 /* enable hotplug interrupts */
161 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
162 struct nouveau_connector *conn = nouveau_connector(connector);
163
164 if (conn->dcb->gpio_tag == 0xff)
165 continue;
166
167 pgpio->irq_enable(dev, conn->dcb->gpio_tag, true);
168 }
169
Ben Skeggsb7bc6132010-10-19 13:05:51 +1000170 ret = nv50_evo_init(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000171 if (ret)
172 return ret;
Ben Skeggsb7bc6132010-10-19 13:05:51 +1000173 evo = dev_priv->evo;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000174
Ben Skeggsb7bc6132010-10-19 13:05:51 +1000175 nv_wr32(dev, NV50_PDISPLAY_OBJECTS, (evo->ramin->vinst >> 8) | 9);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000176
177 ret = RING_SPACE(evo, 11);
178 if (ret)
179 return ret;
180 BEGIN_RING(evo, 0, NV50_EVO_UNK84, 2);
181 OUT_RING(evo, NV50_EVO_UNK84_NOTIFY_DISABLED);
182 OUT_RING(evo, NV50_EVO_DMA_NOTIFY_HANDLE_NONE);
183 BEGIN_RING(evo, 0, NV50_EVO_CRTC(0, FB_DMA), 1);
184 OUT_RING(evo, NV50_EVO_CRTC_FB_DMA_HANDLE_NONE);
185 BEGIN_RING(evo, 0, NV50_EVO_CRTC(0, UNK0800), 1);
186 OUT_RING(evo, 0);
187 BEGIN_RING(evo, 0, NV50_EVO_CRTC(0, DISPLAY_START), 1);
188 OUT_RING(evo, 0);
189 BEGIN_RING(evo, 0, NV50_EVO_CRTC(0, UNK082C), 1);
190 OUT_RING(evo, 0);
191 FIRE_RING(evo);
Francisco Jerez4b5c1522010-09-07 17:34:44 +0200192 if (!nv_wait(dev, 0x640004, 0xffffffff, evo->dma.put << 2))
Ben Skeggs6ee73862009-12-11 19:24:15 +1000193 NV_ERROR(dev, "evo pushbuf stalled\n");
194
Ben Skeggs6ee73862009-12-11 19:24:15 +1000195
196 return 0;
197}
198
199static int nv50_display_disable(struct drm_device *dev)
200{
201 struct drm_nouveau_private *dev_priv = dev->dev_private;
202 struct drm_crtc *drm_crtc;
203 int ret, i;
204
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100205 NV_DEBUG_KMS(dev, "\n");
Ben Skeggs6ee73862009-12-11 19:24:15 +1000206
207 list_for_each_entry(drm_crtc, &dev->mode_config.crtc_list, head) {
208 struct nouveau_crtc *crtc = nouveau_crtc(drm_crtc);
209
210 nv50_crtc_blank(crtc, true);
211 }
212
213 ret = RING_SPACE(dev_priv->evo, 2);
214 if (ret == 0) {
215 BEGIN_RING(dev_priv->evo, 0, NV50_EVO_UPDATE, 1);
216 OUT_RING(dev_priv->evo, 0);
217 }
218 FIRE_RING(dev_priv->evo);
219
220 /* Almost like ack'ing a vblank interrupt, maybe in the spirit of
221 * cleaning up?
222 */
223 list_for_each_entry(drm_crtc, &dev->mode_config.crtc_list, head) {
224 struct nouveau_crtc *crtc = nouveau_crtc(drm_crtc);
225 uint32_t mask = NV50_PDISPLAY_INTR_1_VBLANK_CRTC_(crtc->index);
226
227 if (!crtc->base.enabled)
228 continue;
229
230 nv_wr32(dev, NV50_PDISPLAY_INTR_1, mask);
Francisco Jerez4b5c1522010-09-07 17:34:44 +0200231 if (!nv_wait(dev, NV50_PDISPLAY_INTR_1, mask, mask)) {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000232 NV_ERROR(dev, "timeout: (0x610024 & 0x%08x) == "
233 "0x%08x\n", mask, mask);
234 NV_ERROR(dev, "0x610024 = 0x%08x\n",
235 nv_rd32(dev, NV50_PDISPLAY_INTR_1));
236 }
237 }
238
Ben Skeggsb7bc6132010-10-19 13:05:51 +1000239 nv50_evo_fini(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000240
241 for (i = 0; i < 3; i++) {
Francisco Jerez4b5c1522010-09-07 17:34:44 +0200242 if (!nv_wait(dev, NV50_PDISPLAY_SOR_DPMS_STATE(i),
Ben Skeggs6ee73862009-12-11 19:24:15 +1000243 NV50_PDISPLAY_SOR_DPMS_STATE_WAIT, 0)) {
244 NV_ERROR(dev, "timeout: SOR_DPMS_STATE_WAIT(%d) == 0\n", i);
245 NV_ERROR(dev, "SOR_DPMS_STATE(%d) = 0x%08x\n", i,
246 nv_rd32(dev, NV50_PDISPLAY_SOR_DPMS_STATE(i)));
247 }
248 }
249
250 /* disable interrupts. */
251 nv_wr32(dev, NV50_PDISPLAY_INTR_EN, 0x00000000);
252
253 /* disable hotplug interrupts */
254 nv_wr32(dev, 0xe054, 0xffffffff);
255 nv_wr32(dev, 0xe050, 0x00000000);
256 if (dev_priv->chipset >= 0x90) {
257 nv_wr32(dev, 0xe074, 0xffffffff);
258 nv_wr32(dev, 0xe070, 0x00000000);
259 }
260 return 0;
261}
262
263int nv50_display_create(struct drm_device *dev)
264{
265 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggs04a39c52010-02-24 10:03:05 +1000266 struct dcb_table *dcb = &dev_priv->vbios.dcb;
Ben Skeggs8f1a6082010-06-28 14:35:50 +1000267 struct drm_connector *connector, *ct;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000268 int ret, i;
269
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100270 NV_DEBUG_KMS(dev, "\n");
Ben Skeggs6ee73862009-12-11 19:24:15 +1000271
272 /* init basic kernel modesetting */
273 drm_mode_config_init(dev);
274
275 /* Initialise some optional connector properties. */
276 drm_mode_create_scaling_mode_property(dev);
277 drm_mode_create_dithering_property(dev);
278
279 dev->mode_config.min_width = 0;
280 dev->mode_config.min_height = 0;
281
282 dev->mode_config.funcs = (void *)&nouveau_mode_config_funcs;
283
284 dev->mode_config.max_width = 8192;
285 dev->mode_config.max_height = 8192;
286
287 dev->mode_config.fb_base = dev_priv->fb_phys;
288
Ben Skeggs6ee73862009-12-11 19:24:15 +1000289 /* Create CRTC objects */
290 for (i = 0; i < 2; i++)
291 nv50_crtc_create(dev, i);
292
293 /* We setup the encoders from the BIOS table */
294 for (i = 0 ; i < dcb->entries; i++) {
295 struct dcb_entry *entry = &dcb->entry[i];
296
297 if (entry->location != DCB_LOC_ON_CHIP) {
298 NV_WARN(dev, "Off-chip encoder %d/%d unsupported\n",
299 entry->type, ffs(entry->or) - 1);
300 continue;
301 }
302
Ben Skeggs8f1a6082010-06-28 14:35:50 +1000303 connector = nouveau_connector_create(dev, entry->connector);
304 if (IS_ERR(connector))
305 continue;
306
Ben Skeggs6ee73862009-12-11 19:24:15 +1000307 switch (entry->type) {
308 case OUTPUT_TMDS:
309 case OUTPUT_LVDS:
310 case OUTPUT_DP:
Ben Skeggs8f1a6082010-06-28 14:35:50 +1000311 nv50_sor_create(connector, entry);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000312 break;
313 case OUTPUT_ANALOG:
Ben Skeggs8f1a6082010-06-28 14:35:50 +1000314 nv50_dac_create(connector, entry);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000315 break;
316 default:
317 NV_WARN(dev, "DCB encoder %d unknown\n", entry->type);
318 continue;
319 }
Ben Skeggs6ee73862009-12-11 19:24:15 +1000320 }
321
Ben Skeggs8f1a6082010-06-28 14:35:50 +1000322 list_for_each_entry_safe(connector, ct,
323 &dev->mode_config.connector_list, head) {
324 if (!connector->encoder_ids[0]) {
325 NV_WARN(dev, "%s has no encoders, removing\n",
326 drm_get_connector_name(connector));
327 connector->funcs->destroy(connector);
328 }
Ben Skeggs6ee73862009-12-11 19:24:15 +1000329 }
330
331 ret = nv50_display_init(dev);
Ben Skeggsa1663ed2010-03-25 16:01:04 +1000332 if (ret) {
333 nv50_display_destroy(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000334 return ret;
Ben Skeggsa1663ed2010-03-25 16:01:04 +1000335 }
Ben Skeggs6ee73862009-12-11 19:24:15 +1000336
337 return 0;
338}
339
Francisco Jerezc88c2e02010-07-24 17:37:33 +0200340void
341nv50_display_destroy(struct drm_device *dev)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000342{
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100343 NV_DEBUG_KMS(dev, "\n");
Ben Skeggs6ee73862009-12-11 19:24:15 +1000344
345 drm_mode_config_cleanup(dev);
346
347 nv50_display_disable(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000348}
349
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000350static u16
351nv50_display_script_select(struct drm_device *dev, struct dcb_entry *dcb,
352 u32 mc, int pxclk)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000353{
354 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggs75c722d2009-12-21 12:16:52 +1000355 struct nouveau_connector *nv_connector = NULL;
356 struct drm_encoder *encoder;
Ben Skeggs04a39c52010-02-24 10:03:05 +1000357 struct nvbios *bios = &dev_priv->vbios;
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000358 u32 script = 0, or;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000359
Ben Skeggs75c722d2009-12-21 12:16:52 +1000360 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
361 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
362
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000363 if (nv_encoder->dcb != dcb)
Ben Skeggs75c722d2009-12-21 12:16:52 +1000364 continue;
365
366 nv_connector = nouveau_encoder_connector_get(nv_encoder);
367 break;
368 }
369
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000370 or = ffs(dcb->or) - 1;
371 switch (dcb->type) {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000372 case OUTPUT_LVDS:
373 script = (mc >> 8) & 0xf;
Ben Skeggs04a39c52010-02-24 10:03:05 +1000374 if (bios->fp_no_ddc) {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000375 if (bios->fp.dual_link)
376 script |= 0x0100;
377 if (bios->fp.if_is_24bit)
378 script |= 0x0200;
379 } else {
380 if (pxclk >= bios->fp.duallink_transition_clk) {
381 script |= 0x0100;
382 if (bios->fp.strapless_is_24bit & 2)
383 script |= 0x0200;
384 } else
385 if (bios->fp.strapless_is_24bit & 1)
386 script |= 0x0200;
Ben Skeggs75c722d2009-12-21 12:16:52 +1000387
388 if (nv_connector && nv_connector->edid &&
389 (nv_connector->edid->revision >= 4) &&
390 (nv_connector->edid->input & 0x70) >= 0x20)
391 script |= 0x0200;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000392 }
393
394 if (nouveau_uscript_lvds >= 0) {
395 NV_INFO(dev, "override script 0x%04x with 0x%04x "
396 "for output LVDS-%d\n", script,
397 nouveau_uscript_lvds, or);
398 script = nouveau_uscript_lvds;
399 }
400 break;
401 case OUTPUT_TMDS:
402 script = (mc >> 8) & 0xf;
403 if (pxclk >= 165000)
404 script |= 0x0100;
405
406 if (nouveau_uscript_tmds >= 0) {
407 NV_INFO(dev, "override script 0x%04x with 0x%04x "
408 "for output TMDS-%d\n", script,
409 nouveau_uscript_tmds, or);
410 script = nouveau_uscript_tmds;
411 }
412 break;
413 case OUTPUT_DP:
414 script = (mc >> 8) & 0xf;
415 break;
416 case OUTPUT_ANALOG:
417 script = 0xff;
418 break;
419 default:
420 NV_ERROR(dev, "modeset on unsupported output type!\n");
421 break;
422 }
423
424 return script;
425}
426
427static void
428nv50_display_vblank_crtc_handler(struct drm_device *dev, int crtc)
429{
430 struct drm_nouveau_private *dev_priv = dev->dev_private;
431 struct nouveau_channel *chan;
432 struct list_head *entry, *tmp;
433
434 list_for_each_safe(entry, tmp, &dev_priv->vbl_waiting) {
435 chan = list_entry(entry, struct nouveau_channel, nvsw.vbl_wait);
436
437 nouveau_bo_wr32(chan->notifier_bo, chan->nvsw.vblsem_offset,
438 chan->nvsw.vblsem_rval);
439 list_del(&chan->nvsw.vbl_wait);
440 }
441}
442
443static void
444nv50_display_vblank_handler(struct drm_device *dev, uint32_t intr)
445{
446 intr &= NV50_PDISPLAY_INTR_1_VBLANK_CRTC;
447
448 if (intr & NV50_PDISPLAY_INTR_1_VBLANK_CRTC_0)
449 nv50_display_vblank_crtc_handler(dev, 0);
450
451 if (intr & NV50_PDISPLAY_INTR_1_VBLANK_CRTC_1)
452 nv50_display_vblank_crtc_handler(dev, 1);
453
454 nv_wr32(dev, NV50_PDISPLAY_INTR_EN, nv_rd32(dev,
455 NV50_PDISPLAY_INTR_EN) & ~intr);
456 nv_wr32(dev, NV50_PDISPLAY_INTR_1, intr);
457}
458
459static void
460nv50_display_unk10_handler(struct drm_device *dev)
461{
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000462 struct drm_nouveau_private *dev_priv = dev->dev_private;
463 u32 unk30 = nv_rd32(dev, 0x610030), mc;
464 int i, crtc, or, type = OUTPUT_ANY;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000465
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000466 NV_DEBUG_KMS(dev, "0x610030: 0x%08x\n", unk30);
467 dev_priv->evo_irq.dcb = NULL;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000468
469 nv_wr32(dev, 0x619494, nv_rd32(dev, 0x619494) & ~8);
470
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000471 /* Determine which CRTC we're dealing with, only 1 ever will be
472 * signalled at the same time with the current nouveau code.
473 */
474 crtc = ffs((unk30 & 0x00000060) >> 5) - 1;
475 if (crtc < 0)
476 goto ack;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000477
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000478 /* Nothing needs to be done for the encoder */
479 crtc = ffs((unk30 & 0x00000180) >> 7) - 1;
480 if (crtc < 0)
481 goto ack;
482
483 /* Find which encoder was connected to the CRTC */
484 for (i = 0; type == OUTPUT_ANY && i < 3; i++) {
485 mc = nv_rd32(dev, NV50_PDISPLAY_DAC_MODE_CTRL_C(i));
486 NV_DEBUG_KMS(dev, "DAC-%d mc: 0x%08x\n", i, mc);
487 if (!(mc & (1 << crtc)))
488 continue;
489
490 switch ((mc & 0x00000f00) >> 8) {
491 case 0: type = OUTPUT_ANALOG; break;
492 case 1: type = OUTPUT_TV; break;
493 default:
494 NV_ERROR(dev, "invalid mc, DAC-%d: 0x%08x\n", i, mc);
495 goto ack;
496 }
497
498 or = i;
499 }
500
Ben Skeggs8597a1b2010-09-06 11:39:25 +1000501 for (i = 0; type == OUTPUT_ANY && i < nv50_sor_nr(dev); i++) {
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000502 if (dev_priv->chipset < 0x90 ||
503 dev_priv->chipset == 0x92 ||
504 dev_priv->chipset == 0xa0)
505 mc = nv_rd32(dev, NV50_PDISPLAY_SOR_MODE_CTRL_C(i));
506 else
507 mc = nv_rd32(dev, NV90_PDISPLAY_SOR_MODE_CTRL_C(i));
508
509 NV_DEBUG_KMS(dev, "SOR-%d mc: 0x%08x\n", i, mc);
510 if (!(mc & (1 << crtc)))
511 continue;
512
513 switch ((mc & 0x00000f00) >> 8) {
514 case 0: type = OUTPUT_LVDS; break;
515 case 1: type = OUTPUT_TMDS; break;
516 case 2: type = OUTPUT_TMDS; break;
517 case 5: type = OUTPUT_TMDS; break;
518 case 8: type = OUTPUT_DP; break;
519 case 9: type = OUTPUT_DP; break;
520 default:
521 NV_ERROR(dev, "invalid mc, SOR-%d: 0x%08x\n", i, mc);
522 goto ack;
523 }
524
525 or = i;
526 }
527
528 /* There was no encoder to disable */
529 if (type == OUTPUT_ANY)
530 goto ack;
531
532 /* Disable the encoder */
533 for (i = 0; i < dev_priv->vbios.dcb.entries; i++) {
534 struct dcb_entry *dcb = &dev_priv->vbios.dcb.entry[i];
535
536 if (dcb->type == type && (dcb->or & (1 << or))) {
537 nouveau_bios_run_display_table(dev, dcb, 0, -1);
538 dev_priv->evo_irq.dcb = dcb;
539 goto ack;
540 }
541 }
542
543 NV_ERROR(dev, "no dcb for %d %d 0x%08x\n", or, type, mc);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000544ack:
545 nv_wr32(dev, NV50_PDISPLAY_INTR_1, NV50_PDISPLAY_INTR_1_CLK_UNK10);
546 nv_wr32(dev, 0x610030, 0x80000000);
547}
548
549static void
Ben Skeggsafa3b4c2010-04-23 08:21:48 +1000550nv50_display_unk20_dp_hack(struct drm_device *dev, struct dcb_entry *dcb)
551{
552 int or = ffs(dcb->or) - 1, link = !(dcb->dpconf.sor.link & 1);
553 struct drm_encoder *encoder;
554 uint32_t tmp, unk0 = 0, unk1 = 0;
555
556 if (dcb->type != OUTPUT_DP)
557 return;
558
559 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
560 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
561
562 if (nv_encoder->dcb == dcb) {
563 unk0 = nv_encoder->dp.unk0;
564 unk1 = nv_encoder->dp.unk1;
565 break;
566 }
567 }
568
569 if (unk0 || unk1) {
570 tmp = nv_rd32(dev, NV50_SOR_DP_CTRL(or, link));
571 tmp &= 0xfffffe03;
572 nv_wr32(dev, NV50_SOR_DP_CTRL(or, link), tmp | unk0);
573
574 tmp = nv_rd32(dev, NV50_SOR_DP_UNK128(or, link));
575 tmp &= 0xfef080c0;
576 nv_wr32(dev, NV50_SOR_DP_UNK128(or, link), tmp | unk1);
577 }
578}
579
580static void
Ben Skeggs6ee73862009-12-11 19:24:15 +1000581nv50_display_unk20_handler(struct drm_device *dev)
582{
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000583 struct drm_nouveau_private *dev_priv = dev->dev_private;
584 u32 unk30 = nv_rd32(dev, 0x610030), tmp, pclk, script, mc;
585 struct dcb_entry *dcb;
586 int i, crtc, or, type = OUTPUT_ANY;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000587
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000588 NV_DEBUG_KMS(dev, "0x610030: 0x%08x\n", unk30);
589 dcb = dev_priv->evo_irq.dcb;
590 if (dcb) {
591 nouveau_bios_run_display_table(dev, dcb, 0, -2);
592 dev_priv->evo_irq.dcb = NULL;
593 }
594
595 /* CRTC clock change requested? */
596 crtc = ffs((unk30 & 0x00000600) >> 9) - 1;
597 if (crtc >= 0) {
598 pclk = nv_rd32(dev, NV50_PDISPLAY_CRTC_P(crtc, CLOCK));
599 pclk &= 0x003fffff;
600
601 nv50_crtc_set_clock(dev, crtc, pclk);
602
603 tmp = nv_rd32(dev, NV50_PDISPLAY_CRTC_CLK_CTRL2(crtc));
604 tmp &= ~0x000000f;
605 nv_wr32(dev, NV50_PDISPLAY_CRTC_CLK_CTRL2(crtc), tmp);
606 }
607
608 /* Nothing needs to be done for the encoder */
609 crtc = ffs((unk30 & 0x00000180) >> 7) - 1;
610 if (crtc < 0)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000611 goto ack;
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000612 pclk = nv_rd32(dev, NV50_PDISPLAY_CRTC_P(crtc, CLOCK)) & 0x003fffff;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000613
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000614 /* Find which encoder is connected to the CRTC */
615 for (i = 0; type == OUTPUT_ANY && i < 3; i++) {
616 mc = nv_rd32(dev, NV50_PDISPLAY_DAC_MODE_CTRL_P(i));
617 NV_DEBUG_KMS(dev, "DAC-%d mc: 0x%08x\n", i, mc);
618 if (!(mc & (1 << crtc)))
619 continue;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000620
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000621 switch ((mc & 0x00000f00) >> 8) {
622 case 0: type = OUTPUT_ANALOG; break;
623 case 1: type = OUTPUT_TV; break;
624 default:
625 NV_ERROR(dev, "invalid mc, DAC-%d: 0x%08x\n", i, mc);
626 goto ack;
627 }
Ben Skeggs6ee73862009-12-11 19:24:15 +1000628
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000629 or = i;
630 }
Ben Skeggs6ee73862009-12-11 19:24:15 +1000631
Ben Skeggs8597a1b2010-09-06 11:39:25 +1000632 for (i = 0; type == OUTPUT_ANY && i < nv50_sor_nr(dev); i++) {
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000633 if (dev_priv->chipset < 0x90 ||
634 dev_priv->chipset == 0x92 ||
635 dev_priv->chipset == 0xa0)
636 mc = nv_rd32(dev, NV50_PDISPLAY_SOR_MODE_CTRL_P(i));
637 else
638 mc = nv_rd32(dev, NV90_PDISPLAY_SOR_MODE_CTRL_P(i));
Ben Skeggs6ee73862009-12-11 19:24:15 +1000639
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000640 NV_DEBUG_KMS(dev, "SOR-%d mc: 0x%08x\n", i, mc);
641 if (!(mc & (1 << crtc)))
642 continue;
Ben Skeggsafa3b4c2010-04-23 08:21:48 +1000643
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000644 switch ((mc & 0x00000f00) >> 8) {
645 case 0: type = OUTPUT_LVDS; break;
646 case 1: type = OUTPUT_TMDS; break;
647 case 2: type = OUTPUT_TMDS; break;
648 case 5: type = OUTPUT_TMDS; break;
649 case 8: type = OUTPUT_DP; break;
650 case 9: type = OUTPUT_DP; break;
651 default:
652 NV_ERROR(dev, "invalid mc, SOR-%d: 0x%08x\n", i, mc);
653 goto ack;
654 }
Ben Skeggs6ee73862009-12-11 19:24:15 +1000655
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000656 or = i;
657 }
658
659 if (type == OUTPUT_ANY)
660 goto ack;
661
662 /* Enable the encoder */
663 for (i = 0; i < dev_priv->vbios.dcb.entries; i++) {
664 dcb = &dev_priv->vbios.dcb.entry[i];
665 if (dcb->type == type && (dcb->or & (1 << or)))
666 break;
667 }
668
669 if (i == dev_priv->vbios.dcb.entries) {
670 NV_ERROR(dev, "no dcb for %d %d 0x%08x\n", or, type, mc);
671 goto ack;
672 }
673
674 script = nv50_display_script_select(dev, dcb, mc, pclk);
675 nouveau_bios_run_display_table(dev, dcb, script, pclk);
676
677 nv50_display_unk20_dp_hack(dev, dcb);
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000678
679 if (dcb->type != OUTPUT_ANALOG) {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000680 tmp = nv_rd32(dev, NV50_PDISPLAY_SOR_CLK_CTRL2(or));
681 tmp &= ~0x00000f0f;
682 if (script & 0x0100)
683 tmp |= 0x00000101;
684 nv_wr32(dev, NV50_PDISPLAY_SOR_CLK_CTRL2(or), tmp);
685 } else {
686 nv_wr32(dev, NV50_PDISPLAY_DAC_CLK_CTRL2(or), 0);
687 }
688
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000689 dev_priv->evo_irq.dcb = dcb;
690 dev_priv->evo_irq.pclk = pclk;
691 dev_priv->evo_irq.script = script;
692
Ben Skeggs6ee73862009-12-11 19:24:15 +1000693ack:
694 nv_wr32(dev, NV50_PDISPLAY_INTR_1, NV50_PDISPLAY_INTR_1_CLK_UNK20);
695 nv_wr32(dev, 0x610030, 0x80000000);
696}
697
Ben Skeggs271f29e2010-07-09 10:37:42 +1000698/* If programming a TMDS output on a SOR that can also be configured for
699 * DisplayPort, make sure NV50_SOR_DP_CTRL_ENABLE is forced off.
700 *
701 * It looks like the VBIOS TMDS scripts make an attempt at this, however,
702 * the VBIOS scripts on at least one board I have only switch it off on
703 * link 0, causing a blank display if the output has previously been
704 * programmed for DisplayPort.
705 */
706static void
707nv50_display_unk40_dp_set_tmds(struct drm_device *dev, struct dcb_entry *dcb)
708{
709 int or = ffs(dcb->or) - 1, link = !(dcb->dpconf.sor.link & 1);
710 struct drm_encoder *encoder;
711 u32 tmp;
712
713 if (dcb->type != OUTPUT_TMDS)
714 return;
715
716 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
717 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
718
719 if (nv_encoder->dcb->type == OUTPUT_DP &&
720 nv_encoder->dcb->or & (1 << or)) {
721 tmp = nv_rd32(dev, NV50_SOR_DP_CTRL(or, link));
722 tmp &= ~NV50_SOR_DP_CTRL_ENABLED;
723 nv_wr32(dev, NV50_SOR_DP_CTRL(or, link), tmp);
724 break;
725 }
726 }
727}
728
Ben Skeggs6ee73862009-12-11 19:24:15 +1000729static void
730nv50_display_unk40_handler(struct drm_device *dev)
731{
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000732 struct drm_nouveau_private *dev_priv = dev->dev_private;
733 struct dcb_entry *dcb = dev_priv->evo_irq.dcb;
734 u16 script = dev_priv->evo_irq.script;
735 u32 unk30 = nv_rd32(dev, 0x610030), pclk = dev_priv->evo_irq.pclk;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000736
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000737 NV_DEBUG_KMS(dev, "0x610030: 0x%08x\n", unk30);
738 dev_priv->evo_irq.dcb = NULL;
739 if (!dcb)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000740 goto ack;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000741
Ben Skeggs87c0e0e2010-07-06 08:54:34 +1000742 nouveau_bios_run_display_table(dev, dcb, script, -pclk);
Ben Skeggs271f29e2010-07-09 10:37:42 +1000743 nv50_display_unk40_dp_set_tmds(dev, dcb);
744
Ben Skeggs6ee73862009-12-11 19:24:15 +1000745ack:
746 nv_wr32(dev, NV50_PDISPLAY_INTR_1, NV50_PDISPLAY_INTR_1_CLK_UNK40);
747 nv_wr32(dev, 0x610030, 0x80000000);
748 nv_wr32(dev, 0x619494, nv_rd32(dev, 0x619494) | 8);
749}
750
751void
752nv50_display_irq_handler_bh(struct work_struct *work)
753{
754 struct drm_nouveau_private *dev_priv =
755 container_of(work, struct drm_nouveau_private, irq_work);
756 struct drm_device *dev = dev_priv->dev;
757
758 for (;;) {
759 uint32_t intr0 = nv_rd32(dev, NV50_PDISPLAY_INTR_0);
760 uint32_t intr1 = nv_rd32(dev, NV50_PDISPLAY_INTR_1);
761
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100762 NV_DEBUG_KMS(dev, "PDISPLAY_INTR_BH 0x%08x 0x%08x\n", intr0, intr1);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000763
764 if (intr1 & NV50_PDISPLAY_INTR_1_CLK_UNK10)
765 nv50_display_unk10_handler(dev);
766 else
767 if (intr1 & NV50_PDISPLAY_INTR_1_CLK_UNK20)
768 nv50_display_unk20_handler(dev);
769 else
770 if (intr1 & NV50_PDISPLAY_INTR_1_CLK_UNK40)
771 nv50_display_unk40_handler(dev);
772 else
773 break;
774 }
775
776 nv_wr32(dev, NV03_PMC_INTR_EN_0, 1);
777}
778
779static void
780nv50_display_error_handler(struct drm_device *dev)
781{
782 uint32_t addr, data;
783
784 nv_wr32(dev, NV50_PDISPLAY_INTR_0, 0x00010000);
785 addr = nv_rd32(dev, NV50_PDISPLAY_TRAPPED_ADDR);
786 data = nv_rd32(dev, NV50_PDISPLAY_TRAPPED_DATA);
787
788 NV_ERROR(dev, "EvoCh %d Mthd 0x%04x Data 0x%08x (0x%04x 0x%02x)\n",
789 0, addr & 0xffc, data, addr >> 16, (addr >> 12) & 0xf);
790
791 nv_wr32(dev, NV50_PDISPLAY_TRAPPED_ADDR, 0x90000000);
792}
793
Ben Skeggsa5acac62010-03-30 15:14:41 +1000794void
795nv50_display_irq_hotplug_bh(struct work_struct *work)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000796{
Ben Skeggsa5acac62010-03-30 15:14:41 +1000797 struct drm_nouveau_private *dev_priv =
798 container_of(work, struct drm_nouveau_private, hpd_work);
799 struct drm_device *dev = dev_priv->dev;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000800 struct drm_connector *connector;
801 const uint32_t gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 };
802 uint32_t unplug_mask, plug_mask, change_mask;
Andy Lutomirskiab838332010-11-16 18:40:52 -0500803 uint32_t hpd0, hpd1;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000804
Andy Lutomirskiab838332010-11-16 18:40:52 -0500805 spin_lock_irq(&dev_priv->hpd_state.lock);
806 hpd0 = dev_priv->hpd_state.hpd0_bits;
807 dev_priv->hpd_state.hpd0_bits = 0;
808 hpd1 = dev_priv->hpd_state.hpd1_bits;
809 dev_priv->hpd_state.hpd1_bits = 0;
810 spin_unlock_irq(&dev_priv->hpd_state.lock);
811
812 hpd0 &= nv_rd32(dev, 0xe050);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000813 if (dev_priv->chipset >= 0x90)
Andy Lutomirskiab838332010-11-16 18:40:52 -0500814 hpd1 &= nv_rd32(dev, 0xe070);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000815
816 plug_mask = (hpd0 & 0x0000ffff) | (hpd1 << 16);
817 unplug_mask = (hpd0 >> 16) | (hpd1 & 0xffff0000);
818 change_mask = plug_mask | unplug_mask;
819
820 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
821 struct drm_encoder_helper_funcs *helper;
822 struct nouveau_connector *nv_connector =
823 nouveau_connector(connector);
824 struct nouveau_encoder *nv_encoder;
825 struct dcb_gpio_entry *gpio;
826 uint32_t reg;
827 bool plugged;
828
829 if (!nv_connector->dcb)
830 continue;
831
832 gpio = nouveau_bios_gpio_entry(dev, nv_connector->dcb->gpio_tag);
833 if (!gpio || !(change_mask & (1 << gpio->line)))
834 continue;
835
836 reg = nv_rd32(dev, gpio_reg[gpio->line >> 3]);
837 plugged = !!(reg & (4 << ((gpio->line & 7) << 2)));
838 NV_INFO(dev, "%splugged %s\n", plugged ? "" : "un",
839 drm_get_connector_name(connector)) ;
840
841 if (!connector->encoder || !connector->encoder->crtc ||
842 !connector->encoder->crtc->enabled)
843 continue;
844 nv_encoder = nouveau_encoder(connector->encoder);
845 helper = connector->encoder->helper_private;
846
847 if (nv_encoder->dcb->type != OUTPUT_DP)
848 continue;
849
850 if (plugged)
851 helper->dpms(connector->encoder, DRM_MODE_DPMS_ON);
852 else
853 helper->dpms(connector->encoder, DRM_MODE_DPMS_OFF);
854 }
855
Dave Airlieeb1f8e42010-05-07 06:42:51 +0000856 drm_helper_hpd_irq_event(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000857}
858
859void
860nv50_display_irq_handler(struct drm_device *dev)
861{
862 struct drm_nouveau_private *dev_priv = dev->dev_private;
863 uint32_t delayed = 0;
864
Ben Skeggsa5acac62010-03-30 15:14:41 +1000865 if (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_HOTPLUG) {
Andy Lutomirskiab838332010-11-16 18:40:52 -0500866 uint32_t hpd0_bits, hpd1_bits = 0;
867
868 hpd0_bits = nv_rd32(dev, 0xe054);
869 nv_wr32(dev, 0xe054, hpd0_bits);
870
871 if (dev_priv->chipset >= 0x90) {
872 hpd1_bits = nv_rd32(dev, 0xe074);
873 nv_wr32(dev, 0xe074, hpd1_bits);
874 }
875
876 spin_lock(&dev_priv->hpd_state.lock);
877 dev_priv->hpd_state.hpd0_bits |= hpd0_bits;
878 dev_priv->hpd_state.hpd1_bits |= hpd1_bits;
879 spin_unlock(&dev_priv->hpd_state.lock);
880
881 queue_work(dev_priv->wq, &dev_priv->hpd_work);
Ben Skeggsa5acac62010-03-30 15:14:41 +1000882 }
Ben Skeggs6ee73862009-12-11 19:24:15 +1000883
884 while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) {
885 uint32_t intr0 = nv_rd32(dev, NV50_PDISPLAY_INTR_0);
886 uint32_t intr1 = nv_rd32(dev, NV50_PDISPLAY_INTR_1);
887 uint32_t clock;
888
Maarten Maathuisef2bb502009-12-13 16:53:12 +0100889 NV_DEBUG_KMS(dev, "PDISPLAY_INTR 0x%08x 0x%08x\n", intr0, intr1);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000890
891 if (!intr0 && !(intr1 & ~delayed))
892 break;
893
894 if (intr0 & 0x00010000) {
895 nv50_display_error_handler(dev);
896 intr0 &= ~0x00010000;
897 }
898
899 if (intr1 & NV50_PDISPLAY_INTR_1_VBLANK_CRTC) {
900 nv50_display_vblank_handler(dev, intr1);
901 intr1 &= ~NV50_PDISPLAY_INTR_1_VBLANK_CRTC;
902 }
903
904 clock = (intr1 & (NV50_PDISPLAY_INTR_1_CLK_UNK10 |
905 NV50_PDISPLAY_INTR_1_CLK_UNK20 |
906 NV50_PDISPLAY_INTR_1_CLK_UNK40));
907 if (clock) {
908 nv_wr32(dev, NV03_PMC_INTR_EN_0, 0);
909 if (!work_pending(&dev_priv->irq_work))
910 queue_work(dev_priv->wq, &dev_priv->irq_work);
911 delayed |= clock;
912 intr1 &= ~clock;
913 }
914
915 if (intr0) {
916 NV_ERROR(dev, "unknown PDISPLAY_INTR_0: 0x%08x\n", intr0);
917 nv_wr32(dev, NV50_PDISPLAY_INTR_0, intr0);
918 }
919
920 if (intr1) {
921 NV_ERROR(dev,
922 "unknown PDISPLAY_INTR_1: 0x%08x\n", intr1);
923 nv_wr32(dev, NV50_PDISPLAY_INTR_1, intr1);
924 }
925 }
926}
927