aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nvd0_display.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/nouveau/nvd0_display.c')
-rw-r--r--drivers/gpu/drm/nouveau/nvd0_display.c336
1 files changed, 260 insertions, 76 deletions
diff --git a/drivers/gpu/drm/nouveau/nvd0_display.c b/drivers/gpu/drm/nouveau/nvd0_display.c
index d2ba2f07400b..dfb8a951cbbe 100644
--- a/drivers/gpu/drm/nouveau/nvd0_display.c
+++ b/drivers/gpu/drm/nouveau/nvd0_display.c
@@ -284,6 +284,8 @@ nvd0_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
284 u32 *push; 284 u32 *push;
285 int ret; 285 int ret;
286 286
287 evo_sync(crtc->dev, EVO_MASTER);
288
287 swap_interval <<= 4; 289 swap_interval <<= 4;
288 if (swap_interval == 0) 290 if (swap_interval == 0)
289 swap_interval |= 0x100; 291 swap_interval |= 0x100;
@@ -593,7 +595,7 @@ nvd0_crtc_commit(struct drm_crtc *crtc)
593 evo_kick(push, crtc->dev, EVO_MASTER); 595 evo_kick(push, crtc->dev, EVO_MASTER);
594 } 596 }
595 597
596 nvd0_crtc_cursor_show(nv_crtc, nv_crtc->cursor.visible, false); 598 nvd0_crtc_cursor_show(nv_crtc, nv_crtc->cursor.visible, true);
597 nvd0_display_flip_next(crtc, crtc->fb, NULL, 1); 599 nvd0_display_flip_next(crtc, crtc->fb, NULL, 1);
598} 600}
599 601
@@ -634,8 +636,7 @@ nvd0_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *umode,
634 u32 hactive, hsynce, hbackp, hfrontp, hblanke, hblanks; 636 u32 hactive, hsynce, hbackp, hfrontp, hblanke, hblanks;
635 u32 vactive, vsynce, vbackp, vfrontp, vblanke, vblanks; 637 u32 vactive, vsynce, vbackp, vfrontp, vblanke, vblanks;
636 u32 vblan2e = 0, vblan2s = 1; 638 u32 vblan2e = 0, vblan2s = 1;
637 u32 magic = 0x31ec6000; 639 u32 *push;
638 u32 syncs, *push;
639 int ret; 640 int ret;
640 641
641 hactive = mode->htotal; 642 hactive = mode->htotal;
@@ -655,15 +656,8 @@ nvd0_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *umode,
655 vblan2e = vactive + vsynce + vbackp; 656 vblan2e = vactive + vsynce + vbackp;
656 vblan2s = vblan2e + (mode->vdisplay * vscan / ilace); 657 vblan2s = vblan2e + (mode->vdisplay * vscan / ilace);
657 vactive = (vactive * 2) + 1; 658 vactive = (vactive * 2) + 1;
658 magic |= 0x00000001;
659 } 659 }
660 660
661 syncs = 0x00000001;
662 if (mode->flags & DRM_MODE_FLAG_NHSYNC)
663 syncs |= 0x00000008;
664 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
665 syncs |= 0x00000010;
666
667 ret = nvd0_crtc_swap_fbs(crtc, old_fb); 661 ret = nvd0_crtc_swap_fbs(crtc, old_fb);
668 if (ret) 662 if (ret)
669 return ret; 663 return ret;
@@ -683,9 +677,6 @@ nvd0_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *umode,
683 evo_data(push, mode->clock * 1000); 677 evo_data(push, mode->clock * 1000);
684 evo_data(push, 0x00200000); /* ??? */ 678 evo_data(push, 0x00200000); /* ??? */
685 evo_data(push, mode->clock * 1000); 679 evo_data(push, mode->clock * 1000);
686 evo_mthd(push, 0x0404 + (nv_crtc->index * 0x300), 2);
687 evo_data(push, syncs);
688 evo_data(push, magic);
689 evo_mthd(push, 0x04d0 + (nv_crtc->index * 0x300), 2); 680 evo_mthd(push, 0x04d0 + (nv_crtc->index * 0x300), 2);
690 evo_data(push, 0x00000311); 681 evo_data(push, 0x00000311);
691 evo_data(push, 0x00000100); 682 evo_data(push, 0x00000100);
@@ -959,11 +950,6 @@ nvd0_dac_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
959} 950}
960 951
961static void 952static void
962nvd0_dac_prepare(struct drm_encoder *encoder)
963{
964}
965
966static void
967nvd0_dac_commit(struct drm_encoder *encoder) 953nvd0_dac_commit(struct drm_encoder *encoder)
968{ 954{
969} 955}
@@ -974,13 +960,26 @@ nvd0_dac_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
974{ 960{
975 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 961 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
976 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 962 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
977 u32 *push; 963 u32 syncs, magic, *push;
964
965 syncs = 0x00000001;
966 if (mode->flags & DRM_MODE_FLAG_NHSYNC)
967 syncs |= 0x00000008;
968 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
969 syncs |= 0x00000010;
970
971 magic = 0x31ec6000 | (nv_crtc->index << 25);
972 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
973 magic |= 0x00000001;
978 974
979 nvd0_dac_dpms(encoder, DRM_MODE_DPMS_ON); 975 nvd0_dac_dpms(encoder, DRM_MODE_DPMS_ON);
980 976
981 push = evo_wait(encoder->dev, EVO_MASTER, 4); 977 push = evo_wait(encoder->dev, EVO_MASTER, 8);
982 if (push) { 978 if (push) {
983 evo_mthd(push, 0x0180 + (nv_encoder->or * 0x20), 2); 979 evo_mthd(push, 0x0404 + (nv_crtc->index * 0x300), 2);
980 evo_data(push, syncs);
981 evo_data(push, magic);
982 evo_mthd(push, 0x0180 + (nv_encoder->or * 0x020), 2);
984 evo_data(push, 1 << nv_crtc->index); 983 evo_data(push, 1 << nv_crtc->index);
985 evo_data(push, 0x00ff); 984 evo_data(push, 0x00ff);
986 evo_kick(push, encoder->dev, EVO_MASTER); 985 evo_kick(push, encoder->dev, EVO_MASTER);
@@ -1043,7 +1042,7 @@ nvd0_dac_destroy(struct drm_encoder *encoder)
1043static const struct drm_encoder_helper_funcs nvd0_dac_hfunc = { 1042static const struct drm_encoder_helper_funcs nvd0_dac_hfunc = {
1044 .dpms = nvd0_dac_dpms, 1043 .dpms = nvd0_dac_dpms,
1045 .mode_fixup = nvd0_dac_mode_fixup, 1044 .mode_fixup = nvd0_dac_mode_fixup,
1046 .prepare = nvd0_dac_prepare, 1045 .prepare = nvd0_dac_disconnect,
1047 .commit = nvd0_dac_commit, 1046 .commit = nvd0_dac_commit,
1048 .mode_set = nvd0_dac_mode_set, 1047 .mode_set = nvd0_dac_mode_set,
1049 .disable = nvd0_dac_disconnect, 1048 .disable = nvd0_dac_disconnect,
@@ -1183,6 +1182,143 @@ nvd0_hdmi_disconnect(struct drm_encoder *encoder)
1183/****************************************************************************** 1182/******************************************************************************
1184 * SOR 1183 * SOR
1185 *****************************************************************************/ 1184 *****************************************************************************/
1185static inline u32
1186nvd0_sor_dp_lane_map(struct drm_device *dev, struct dcb_entry *dcb, u8 lane)
1187{
1188 static const u8 nvd0[] = { 16, 8, 0, 24 };
1189 return nvd0[lane];
1190}
1191
1192static void
1193nvd0_sor_dp_train_set(struct drm_device *dev, struct dcb_entry *dcb, u8 pattern)
1194{
1195 const u32 or = ffs(dcb->or) - 1, link = !(dcb->sorconf.link & 1);
1196 const u32 loff = (or * 0x800) + (link * 0x80);
1197 nv_mask(dev, 0x61c110 + loff, 0x0f0f0f0f, 0x01010101 * pattern);
1198}
1199
1200static void
1201nvd0_sor_dp_train_adj(struct drm_device *dev, struct dcb_entry *dcb,
1202 u8 lane, u8 swing, u8 preem)
1203{
1204 const u32 or = ffs(dcb->or) - 1, link = !(dcb->sorconf.link & 1);
1205 const u32 loff = (or * 0x800) + (link * 0x80);
1206 u32 shift = nvd0_sor_dp_lane_map(dev, dcb, lane);
1207 u32 mask = 0x000000ff << shift;
1208 u8 *table, *entry, *config = NULL;
1209
1210 switch (swing) {
1211 case 0: preem += 0; break;
1212 case 1: preem += 4; break;
1213 case 2: preem += 7; break;
1214 case 3: preem += 9; break;
1215 }
1216
1217 table = nouveau_dp_bios_data(dev, dcb, &entry);
1218 if (table) {
1219 if (table[0] == 0x30) {
1220 config = entry + table[4];
1221 config += table[5] * preem;
1222 }
1223 }
1224
1225 if (!config) {
1226 NV_ERROR(dev, "PDISP: unsupported DP table for chipset\n");
1227 return;
1228 }
1229
1230 nv_mask(dev, 0x61c118 + loff, mask, config[1] << shift);
1231 nv_mask(dev, 0x61c120 + loff, mask, config[2] << shift);
1232 nv_mask(dev, 0x61c130 + loff, 0x0000ff00, config[3] << 8);
1233 nv_mask(dev, 0x61c13c + loff, 0x00000000, 0x00000000);
1234}
1235
1236static void
1237nvd0_sor_dp_link_set(struct drm_device *dev, struct dcb_entry *dcb, int crtc,
1238 int link_nr, u32 link_bw, bool enhframe)
1239{
1240 const u32 or = ffs(dcb->or) - 1, link = !(dcb->sorconf.link & 1);
1241 const u32 loff = (or * 0x800) + (link * 0x80);
1242 const u32 soff = (or * 0x800);
1243 u32 dpctrl = nv_rd32(dev, 0x61c10c + loff) & ~0x001f4000;
1244 u32 clksor = nv_rd32(dev, 0x612300 + soff) & ~0x007c0000;
1245 u32 script = 0x0000, lane_mask = 0;
1246 u8 *table, *entry;
1247 int i;
1248
1249 link_bw /= 27000;
1250
1251 table = nouveau_dp_bios_data(dev, dcb, &entry);
1252 if (table) {
1253 if (table[0] == 0x30) entry = ROMPTR(dev, entry[10]);
1254 else entry = NULL;
1255
1256 while (entry) {
1257 if (entry[0] >= link_bw)
1258 break;
1259 entry += 3;
1260 }
1261
1262 nouveau_bios_run_init_table(dev, script, dcb, crtc);
1263 }
1264
1265 clksor |= link_bw << 18;
1266 dpctrl |= ((1 << link_nr) - 1) << 16;
1267 if (enhframe)
1268 dpctrl |= 0x00004000;
1269
1270 for (i = 0; i < link_nr; i++)
1271 lane_mask |= 1 << (nvd0_sor_dp_lane_map(dev, dcb, i) >> 3);
1272
1273 nv_wr32(dev, 0x612300 + soff, clksor);
1274 nv_wr32(dev, 0x61c10c + loff, dpctrl);
1275 nv_mask(dev, 0x61c130 + loff, 0x0000000f, lane_mask);
1276}
1277
1278static void
1279nvd0_sor_dp_link_get(struct drm_device *dev, struct dcb_entry *dcb,
1280 u32 *link_nr, u32 *link_bw)
1281{
1282 const u32 or = ffs(dcb->or) - 1, link = !(dcb->sorconf.link & 1);
1283 const u32 loff = (or * 0x800) + (link * 0x80);
1284 const u32 soff = (or * 0x800);
1285 u32 dpctrl = nv_rd32(dev, 0x61c10c + loff) & 0x000f0000;
1286 u32 clksor = nv_rd32(dev, 0x612300 + soff);
1287
1288 if (dpctrl > 0x00030000) *link_nr = 4;
1289 else if (dpctrl > 0x00010000) *link_nr = 2;
1290 else *link_nr = 1;
1291
1292 *link_bw = (clksor & 0x007c0000) >> 18;
1293 *link_bw *= 27000;
1294}
1295
1296static void
1297nvd0_sor_dp_calc_tu(struct drm_device *dev, struct dcb_entry *dcb,
1298 u32 crtc, u32 datarate)
1299{
1300 const u32 symbol = 100000;
1301 const u32 TU = 64;
1302 u32 link_nr, link_bw;
1303 u64 ratio, value;
1304
1305 nvd0_sor_dp_link_get(dev, dcb, &link_nr, &link_bw);
1306
1307 ratio = datarate;
1308 ratio *= symbol;
1309 do_div(ratio, link_nr * link_bw);
1310
1311 value = (symbol - ratio) * TU;
1312 value *= ratio;
1313 do_div(value, symbol);
1314 do_div(value, symbol);
1315
1316 value += 5;
1317 value |= 0x08000000;
1318
1319 nv_wr32(dev, 0x616610 + (crtc * 0x800), value);
1320}
1321
1186static void 1322static void
1187nvd0_sor_dpms(struct drm_encoder *encoder, int mode) 1323nvd0_sor_dpms(struct drm_encoder *encoder, int mode)
1188{ 1324{
@@ -1215,6 +1351,16 @@ nvd0_sor_dpms(struct drm_encoder *encoder, int mode)
1215 nv_mask(dev, 0x61c004 + (or * 0x0800), 0x80000001, dpms_ctrl); 1351 nv_mask(dev, 0x61c004 + (or * 0x0800), 0x80000001, dpms_ctrl);
1216 nv_wait(dev, 0x61c004 + (or * 0x0800), 0x80000000, 0x00000000); 1352 nv_wait(dev, 0x61c004 + (or * 0x0800), 0x80000000, 0x00000000);
1217 nv_wait(dev, 0x61c030 + (or * 0x0800), 0x10000000, 0x00000000); 1353 nv_wait(dev, 0x61c030 + (or * 0x0800), 0x10000000, 0x00000000);
1354
1355 if (nv_encoder->dcb->type == OUTPUT_DP) {
1356 struct dp_train_func func = {
1357 .link_set = nvd0_sor_dp_link_set,
1358 .train_set = nvd0_sor_dp_train_set,
1359 .train_adj = nvd0_sor_dp_train_adj
1360 };
1361
1362 nouveau_dp_dpms(encoder, mode, nv_encoder->dp.datarate, &func);
1363 }
1218} 1364}
1219 1365
1220static bool 1366static bool
@@ -1237,8 +1383,37 @@ nvd0_sor_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
1237} 1383}
1238 1384
1239static void 1385static void
1386nvd0_sor_disconnect(struct drm_encoder *encoder)
1387{
1388 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1389 struct drm_device *dev = encoder->dev;
1390 u32 *push;
1391
1392 if (nv_encoder->crtc) {
1393 nvd0_crtc_prepare(nv_encoder->crtc);
1394
1395 push = evo_wait(dev, EVO_MASTER, 4);
1396 if (push) {
1397 evo_mthd(push, 0x0200 + (nv_encoder->or * 0x20), 1);
1398 evo_data(push, 0x00000000);
1399 evo_mthd(push, 0x0080, 1);
1400 evo_data(push, 0x00000000);
1401 evo_kick(push, dev, EVO_MASTER);
1402 }
1403
1404 nvd0_hdmi_disconnect(encoder);
1405
1406 nv_encoder->crtc = NULL;
1407 nv_encoder->last_dpms = DRM_MODE_DPMS_OFF;
1408 }
1409}
1410
1411static void
1240nvd0_sor_prepare(struct drm_encoder *encoder) 1412nvd0_sor_prepare(struct drm_encoder *encoder)
1241{ 1413{
1414 nvd0_sor_disconnect(encoder);
1415 if (nouveau_encoder(encoder)->dcb->type == OUTPUT_DP)
1416 evo_sync(encoder->dev, EVO_MASTER);
1242} 1417}
1243 1418
1244static void 1419static void
@@ -1257,7 +1432,18 @@ nvd0_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *umode,
1257 struct nouveau_connector *nv_connector; 1432 struct nouveau_connector *nv_connector;
1258 struct nvbios *bios = &dev_priv->vbios; 1433 struct nvbios *bios = &dev_priv->vbios;
1259 u32 mode_ctrl = (1 << nv_crtc->index); 1434 u32 mode_ctrl = (1 << nv_crtc->index);
1260 u32 *push, or_config; 1435 u32 syncs, magic, *push;
1436 u32 or_config;
1437
1438 syncs = 0x00000001;
1439 if (mode->flags & DRM_MODE_FLAG_NHSYNC)
1440 syncs |= 0x00000008;
1441 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
1442 syncs |= 0x00000010;
1443
1444 magic = 0x31ec6000 | (nv_crtc->index << 25);
1445 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
1446 magic |= 0x00000001;
1261 1447
1262 nv_connector = nouveau_encoder_connector_get(nv_encoder); 1448 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1263 switch (nv_encoder->dcb->type) { 1449 switch (nv_encoder->dcb->type) {
@@ -1306,6 +1492,22 @@ nvd0_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *umode,
1306 1492
1307 } 1493 }
1308 break; 1494 break;
1495 case OUTPUT_DP:
1496 if (nv_connector->base.display_info.bpc == 6) {
1497 nv_encoder->dp.datarate = mode->clock * 18 / 8;
1498 syncs |= 0x00000140;
1499 } else {
1500 nv_encoder->dp.datarate = mode->clock * 24 / 8;
1501 syncs |= 0x00000180;
1502 }
1503
1504 if (nv_encoder->dcb->sorconf.link & 1)
1505 mode_ctrl |= 0x00000800;
1506 else
1507 mode_ctrl |= 0x00000900;
1508
1509 or_config = (mode_ctrl & 0x00000f00) >> 8;
1510 break;
1309 default: 1511 default:
1310 BUG_ON(1); 1512 BUG_ON(1);
1311 break; 1513 break;
@@ -1313,9 +1515,17 @@ nvd0_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *umode,
1313 1515
1314 nvd0_sor_dpms(encoder, DRM_MODE_DPMS_ON); 1516 nvd0_sor_dpms(encoder, DRM_MODE_DPMS_ON);
1315 1517
1316 push = evo_wait(dev, EVO_MASTER, 4); 1518 if (nv_encoder->dcb->type == OUTPUT_DP) {
1519 nvd0_sor_dp_calc_tu(dev, nv_encoder->dcb, nv_crtc->index,
1520 nv_encoder->dp.datarate);
1521 }
1522
1523 push = evo_wait(dev, EVO_MASTER, 8);
1317 if (push) { 1524 if (push) {
1318 evo_mthd(push, 0x0200 + (nv_encoder->or * 0x20), 2); 1525 evo_mthd(push, 0x0404 + (nv_crtc->index * 0x300), 2);
1526 evo_data(push, syncs);
1527 evo_data(push, magic);
1528 evo_mthd(push, 0x0200 + (nv_encoder->or * 0x020), 2);
1319 evo_data(push, mode_ctrl); 1529 evo_data(push, mode_ctrl);
1320 evo_data(push, or_config); 1530 evo_data(push, or_config);
1321 evo_kick(push, dev, EVO_MASTER); 1531 evo_kick(push, dev, EVO_MASTER);
@@ -1325,32 +1535,6 @@ nvd0_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *umode,
1325} 1535}
1326 1536
1327static void 1537static void
1328nvd0_sor_disconnect(struct drm_encoder *encoder)
1329{
1330 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1331 struct drm_device *dev = encoder->dev;
1332 u32 *push;
1333
1334 if (nv_encoder->crtc) {
1335 nvd0_crtc_prepare(nv_encoder->crtc);
1336
1337 push = evo_wait(dev, EVO_MASTER, 4);
1338 if (push) {
1339 evo_mthd(push, 0x0200 + (nv_encoder->or * 0x20), 1);
1340 evo_data(push, 0x00000000);
1341 evo_mthd(push, 0x0080, 1);
1342 evo_data(push, 0x00000000);
1343 evo_kick(push, dev, EVO_MASTER);
1344 }
1345
1346 nvd0_hdmi_disconnect(encoder);
1347
1348 nv_encoder->crtc = NULL;
1349 nv_encoder->last_dpms = DRM_MODE_DPMS_OFF;
1350 }
1351}
1352
1353static void
1354nvd0_sor_destroy(struct drm_encoder *encoder) 1538nvd0_sor_destroy(struct drm_encoder *encoder)
1355{ 1539{
1356 drm_encoder_cleanup(encoder); 1540 drm_encoder_cleanup(encoder);
@@ -1402,17 +1586,19 @@ static struct dcb_entry *
1402lookup_dcb(struct drm_device *dev, int id, u32 mc) 1586lookup_dcb(struct drm_device *dev, int id, u32 mc)
1403{ 1587{
1404 struct drm_nouveau_private *dev_priv = dev->dev_private; 1588 struct drm_nouveau_private *dev_priv = dev->dev_private;
1405 int type, or, i; 1589 int type, or, i, link = -1;
1406 1590
1407 if (id < 4) { 1591 if (id < 4) {
1408 type = OUTPUT_ANALOG; 1592 type = OUTPUT_ANALOG;
1409 or = id; 1593 or = id;
1410 } else { 1594 } else {
1411 switch (mc & 0x00000f00) { 1595 switch (mc & 0x00000f00) {
1412 case 0x00000000: type = OUTPUT_LVDS; break; 1596 case 0x00000000: link = 0; type = OUTPUT_LVDS; break;
1413 case 0x00000100: type = OUTPUT_TMDS; break; 1597 case 0x00000100: link = 0; type = OUTPUT_TMDS; break;
1414 case 0x00000200: type = OUTPUT_TMDS; break; 1598 case 0x00000200: link = 1; type = OUTPUT_TMDS; break;
1415 case 0x00000500: type = OUTPUT_TMDS; break; 1599 case 0x00000500: link = 0; type = OUTPUT_TMDS; break;
1600 case 0x00000800: link = 0; type = OUTPUT_DP; break;
1601 case 0x00000900: link = 1; type = OUTPUT_DP; break;
1416 default: 1602 default:
1417 NV_ERROR(dev, "PDISP: unknown SOR mc 0x%08x\n", mc); 1603 NV_ERROR(dev, "PDISP: unknown SOR mc 0x%08x\n", mc);
1418 return NULL; 1604 return NULL;
@@ -1423,7 +1609,8 @@ lookup_dcb(struct drm_device *dev, int id, u32 mc)
1423 1609
1424 for (i = 0; i < dev_priv->vbios.dcb.entries; i++) { 1610 for (i = 0; i < dev_priv->vbios.dcb.entries; i++) {
1425 struct dcb_entry *dcb = &dev_priv->vbios.dcb.entry[i]; 1611 struct dcb_entry *dcb = &dev_priv->vbios.dcb.entry[i];
1426 if (dcb->type == type && (dcb->or & (1 << or))) 1612 if (dcb->type == type && (dcb->or & (1 << or)) &&
1613 (link < 0 || link == !(dcb->sorconf.link & 1)))
1427 return dcb; 1614 return dcb;
1428 } 1615 }
1429 1616
@@ -1498,6 +1685,7 @@ nvd0_display_unk2_handler(struct drm_device *dev, u32 crtc, u32 mask)
1498 break; 1685 break;
1499 case OUTPUT_TMDS: 1686 case OUTPUT_TMDS:
1500 case OUTPUT_LVDS: 1687 case OUTPUT_LVDS:
1688 case OUTPUT_DP:
1501 if (cfg & 0x00000100) 1689 if (cfg & 0x00000100)
1502 tmp = 0x00000101; 1690 tmp = 0x00000101;
1503 else 1691 else
@@ -1548,7 +1736,7 @@ nvd0_display_bh(unsigned long data)
1548{ 1736{
1549 struct drm_device *dev = (struct drm_device *)data; 1737 struct drm_device *dev = (struct drm_device *)data;
1550 struct nvd0_display *disp = nvd0_display(dev); 1738 struct nvd0_display *disp = nvd0_display(dev);
1551 u32 mask, crtc; 1739 u32 mask = 0, crtc = ~0;
1552 int i; 1740 int i;
1553 1741
1554 if (drm_debug & (DRM_UT_DRIVER | DRM_UT_KMS)) { 1742 if (drm_debug & (DRM_UT_DRIVER | DRM_UT_KMS)) {
@@ -1564,12 +1752,8 @@ nvd0_display_bh(unsigned long data)
1564 } 1752 }
1565 } 1753 }
1566 1754
1567 mask = nv_rd32(dev, 0x6101d4); 1755 while (!mask && ++crtc < dev->mode_config.num_crtc)
1568 crtc = 0; 1756 mask = nv_rd32(dev, 0x6101d4 + (crtc * 0x800));
1569 if (!mask) {
1570 mask = nv_rd32(dev, 0x6109d4);
1571 crtc = 1;
1572 }
1573 1757
1574 if (disp->modeset & 0x00000001) 1758 if (disp->modeset & 0x00000001)
1575 nvd0_display_unk1_handler(dev, crtc, mask); 1759 nvd0_display_unk1_handler(dev, crtc, mask);
@@ -1584,6 +1768,7 @@ nvd0_display_intr(struct drm_device *dev)
1584{ 1768{
1585 struct nvd0_display *disp = nvd0_display(dev); 1769 struct nvd0_display *disp = nvd0_display(dev);
1586 u32 intr = nv_rd32(dev, 0x610088); 1770 u32 intr = nv_rd32(dev, 0x610088);
1771 int i;
1587 1772
1588 if (intr & 0x00000001) { 1773 if (intr & 0x00000001) {
1589 u32 stat = nv_rd32(dev, 0x61008c); 1774 u32 stat = nv_rd32(dev, 0x61008c);
@@ -1628,16 +1813,13 @@ nvd0_display_intr(struct drm_device *dev)
1628 intr &= ~0x00100000; 1813 intr &= ~0x00100000;
1629 } 1814 }
1630 1815
1631 if (intr & 0x01000000) { 1816 for (i = 0; i < dev->mode_config.num_crtc; i++) {
1632 u32 stat = nv_rd32(dev, 0x6100bc); 1817 u32 mask = 0x01000000 << i;
1633 nv_wr32(dev, 0x6100bc, stat); 1818 if (intr & mask) {
1634 intr &= ~0x01000000; 1819 u32 stat = nv_rd32(dev, 0x6100bc + (i * 0x800));
1635 } 1820 nv_wr32(dev, 0x6100bc + (i * 0x800), stat);
1636 1821 intr &= ~mask;
1637 if (intr & 0x02000000) { 1822 }
1638 u32 stat = nv_rd32(dev, 0x6108bc);
1639 nv_wr32(dev, 0x6108bc, stat);
1640 intr &= ~0x02000000;
1641 } 1823 }
1642 1824
1643 if (intr) 1825 if (intr)
@@ -1774,7 +1956,7 @@ nvd0_display_create(struct drm_device *dev)
1774 struct pci_dev *pdev = dev->pdev; 1956 struct pci_dev *pdev = dev->pdev;
1775 struct nvd0_display *disp; 1957 struct nvd0_display *disp;
1776 struct dcb_entry *dcbe; 1958 struct dcb_entry *dcbe;
1777 int ret, i; 1959 int crtcs, ret, i;
1778 1960
1779 disp = kzalloc(sizeof(*disp), GFP_KERNEL); 1961 disp = kzalloc(sizeof(*disp), GFP_KERNEL);
1780 if (!disp) 1962 if (!disp)
@@ -1782,7 +1964,8 @@ nvd0_display_create(struct drm_device *dev)
1782 dev_priv->engine.display.priv = disp; 1964 dev_priv->engine.display.priv = disp;
1783 1965
1784 /* create crtc objects to represent the hw heads */ 1966 /* create crtc objects to represent the hw heads */
1785 for (i = 0; i < 2; i++) { 1967 crtcs = nv_rd32(dev, 0x022448);
1968 for (i = 0; i < crtcs; i++) {
1786 ret = nvd0_crtc_create(dev, i); 1969 ret = nvd0_crtc_create(dev, i);
1787 if (ret) 1970 if (ret)
1788 goto out; 1971 goto out;
@@ -1803,6 +1986,7 @@ nvd0_display_create(struct drm_device *dev)
1803 switch (dcbe->type) { 1986 switch (dcbe->type) {
1804 case OUTPUT_TMDS: 1987 case OUTPUT_TMDS:
1805 case OUTPUT_LVDS: 1988 case OUTPUT_LVDS:
1989 case OUTPUT_DP:
1806 nvd0_sor_create(connector, dcbe); 1990 nvd0_sor_create(connector, dcbe);
1807 break; 1991 break;
1808 case OUTPUT_ANALOG: 1992 case OUTPUT_ANALOG: