forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/nouveau/nouveau_connector.c
....@@ -29,15 +29,16 @@
2929 #include <linux/pm_runtime.h>
3030 #include <linux/vga_switcheroo.h>
3131
32
-#include <drm/drmP.h>
3332 #include <drm/drm_atomic_helper.h>
3433 #include <drm/drm_edid.h>
3534 #include <drm/drm_crtc_helper.h>
35
+#include <drm/drm_probe_helper.h>
3636 #include <drm/drm_atomic.h>
3737
3838 #include "nouveau_reg.h"
3939 #include "nouveau_drv.h"
4040 #include "dispnv04/hw.h"
41
+#include "dispnv50/disp.h"
4142 #include "nouveau_acpi.h"
4243
4344 #include "nouveau_display.h"
....@@ -59,7 +60,6 @@
5960 int high_w = 0, high_h = 0, high_v = 0;
6061
6162 list_for_each_entry(mode, &connector->probed_modes, head) {
62
- mode->vrefresh = drm_mode_vrefresh(mode);
6363 if (helper->mode_valid(connector, mode) != MODE_OK ||
6464 (mode->flags & DRM_MODE_FLAG_INTERLACE))
6565 continue;
....@@ -80,12 +80,12 @@
8080 continue;
8181
8282 if (mode->hdisplay == high_w && mode->vdisplay == high_h &&
83
- mode->vrefresh < high_v)
83
+ drm_mode_vrefresh(mode) < high_v)
8484 continue;
8585
8686 high_w = mode->hdisplay;
8787 high_h = mode->vdisplay;
88
- high_v = mode->vrefresh;
88
+ high_v = drm_mode_vrefresh(mode);
8989 largest = mode;
9090 }
9191
....@@ -245,14 +245,22 @@
245245 void
246246 nouveau_conn_reset(struct drm_connector *connector)
247247 {
248
+ struct nouveau_connector *nv_connector = nouveau_connector(connector);
248249 struct nouveau_conn_atom *asyc;
249250
250
- if (WARN_ON(!(asyc = kzalloc(sizeof(*asyc), GFP_KERNEL))))
251
- return;
251
+ if (drm_drv_uses_atomic_modeset(connector->dev)) {
252
+ if (WARN_ON(!(asyc = kzalloc(sizeof(*asyc), GFP_KERNEL))))
253
+ return;
252254
253
- if (connector->state)
254
- nouveau_conn_atomic_destroy_state(connector, connector->state);
255
- __drm_atomic_helper_connector_reset(connector, &asyc->state);
255
+ if (connector->state)
256
+ nouveau_conn_atomic_destroy_state(connector,
257
+ connector->state);
258
+
259
+ __drm_atomic_helper_connector_reset(connector, &asyc->state);
260
+ } else {
261
+ asyc = &nv_connector->properties_state;
262
+ }
263
+
256264 asyc->dither.mode = DITHERING_MODE_AUTO;
257265 asyc->dither.depth = DITHERING_DEPTH_AUTO;
258266 asyc->scaler.mode = DRM_MODE_SCALE_NONE;
....@@ -276,8 +284,14 @@
276284 nouveau_conn_attach_properties(struct drm_connector *connector)
277285 {
278286 struct drm_device *dev = connector->dev;
279
- struct nouveau_conn_atom *armc = nouveau_conn_atom(connector->state);
280287 struct nouveau_display *disp = nouveau_display(dev);
288
+ struct nouveau_connector *nv_connector = nouveau_connector(connector);
289
+ struct nouveau_conn_atom *armc;
290
+
291
+ if (drm_drv_uses_atomic_modeset(connector->dev))
292
+ armc = nouveau_conn_atom(connector->state);
293
+ else
294
+ armc = &nv_connector->properties_state;
281295
282296 /* Init DVI-I specific properties. */
283297 if (connector->connector_type == DRM_MODE_CONNECTOR_DVII)
....@@ -316,7 +330,7 @@
316330 case DRM_MODE_CONNECTOR_VGA:
317331 if (disp->disp.object.oclass < NV50_DISP)
318332 break; /* Can only scale on DFPs. */
319
- /* Fall-through. */
333
+ fallthrough;
320334 default:
321335 drm_object_attach_property(&connector->base, dev->mode_config.
322336 scaling_mode_property,
....@@ -365,9 +379,8 @@
365379 {
366380 struct nouveau_encoder *nv_encoder;
367381 struct drm_encoder *enc;
368
- int i;
369382
370
- drm_connector_for_each_possible_encoder(connector, enc, i) {
383
+ drm_connector_for_each_possible_encoder(connector, enc) {
371384 nv_encoder = nouveau_encoder(enc);
372385
373386 if (type == DCB_OUTPUT_ANY ||
....@@ -378,30 +391,19 @@
378391 return NULL;
379392 }
380393
381
-struct nouveau_connector *
382
-nouveau_encoder_connector_get(struct nouveau_encoder *encoder)
383
-{
384
- struct drm_device *dev = to_drm_encoder(encoder)->dev;
385
- struct drm_connector *drm_connector;
386
-
387
- list_for_each_entry(drm_connector, &dev->mode_config.connector_list, head) {
388
- if (drm_connector->encoder == to_drm_encoder(encoder))
389
- return nouveau_connector(drm_connector);
390
- }
391
-
392
- return NULL;
393
-}
394
-
395394 static void
396395 nouveau_connector_destroy(struct drm_connector *connector)
397396 {
398397 struct nouveau_connector *nv_connector = nouveau_connector(connector);
399
- nvif_notify_fini(&nv_connector->hpd);
398
+ nvif_notify_dtor(&nv_connector->hpd);
400399 kfree(nv_connector->edid);
401400 drm_connector_unregister(connector);
402401 drm_connector_cleanup(connector);
403
- if (nv_connector->aux.transfer)
402
+ if (nv_connector->aux.transfer) {
403
+ drm_dp_cec_unregister_connector(&nv_connector->aux);
404404 drm_dp_aux_unregister(&nv_connector->aux);
405
+ kfree(nv_connector->aux.name);
406
+ }
405407 kfree(connector);
406408 }
407409
....@@ -411,15 +413,16 @@
411413 struct drm_device *dev = connector->dev;
412414 struct nouveau_encoder *nv_encoder = NULL, *found = NULL;
413415 struct drm_encoder *encoder;
414
- int i, ret;
416
+ int ret;
415417 bool switcheroo_ddc = false;
416418
417
- drm_connector_for_each_possible_encoder(connector, encoder, i) {
419
+ drm_connector_for_each_possible_encoder(connector, encoder) {
418420 nv_encoder = nouveau_encoder(encoder);
419421
420422 switch (nv_encoder->dcb->type) {
421423 case DCB_OUTPUT_DP:
422
- ret = nouveau_dp_detect(nv_encoder);
424
+ ret = nouveau_dp_detect(nouveau_connector(connector),
425
+ nv_encoder);
423426 if (ret == NOUVEAU_DP_MST)
424427 return NULL;
425428 else if (ret == NOUVEAU_DP_SST)
....@@ -429,7 +432,7 @@
429432 case DCB_OUTPUT_LVDS:
430433 switcheroo_ddc = !!(vga_switcheroo_handler_flags() &
431434 VGA_SWITCHEROO_CAN_SWITCH_DDC);
432
- /* fall-through */
435
+ fallthrough;
433436 default:
434437 if (!nv_encoder->i2c)
435438 break;
....@@ -493,7 +496,12 @@
493496 nv_connector->detected_encoder = nv_encoder;
494497
495498 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
496
- connector->interlace_allowed = true;
499
+ if (nv_encoder->dcb->type == DCB_OUTPUT_DP)
500
+ connector->interlace_allowed =
501
+ nv_encoder->caps.dp_interlace;
502
+ else
503
+ connector->interlace_allowed =
504
+ drm->client.device.info.family < NV_DEVICE_INFO_V0_VOLTA;
497505 connector->doublescan_allowed = true;
498506 } else
499507 if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS ||
....@@ -521,6 +529,19 @@
521529 }
522530 }
523531
532
+static void
533
+nouveau_connector_set_edid(struct nouveau_connector *nv_connector,
534
+ struct edid *edid)
535
+{
536
+ if (nv_connector->edid != edid) {
537
+ struct edid *old_edid = nv_connector->edid;
538
+
539
+ drm_connector_update_edid_property(&nv_connector->base, edid);
540
+ kfree(old_edid);
541
+ nv_connector->edid = edid;
542
+ }
543
+}
544
+
524545 static enum drm_connector_status
525546 nouveau_connector_detect(struct drm_connector *connector, bool force)
526547 {
....@@ -534,13 +555,6 @@
534555 int ret;
535556 enum drm_connector_status conn_status = connector_status_disconnected;
536557
537
- /* Cleanup the previous EDID block. */
538
- if (nv_connector->edid) {
539
- drm_connector_update_edid_property(connector, NULL);
540
- kfree(nv_connector->edid);
541
- nv_connector->edid = NULL;
542
- }
543
-
544558 /* Outputs are only polled while runtime active, so resuming the
545559 * device here is unnecessary (and would deadlock upon runtime suspend
546560 * because it waits for polling to finish). We do however, want to
....@@ -553,22 +567,23 @@
553567 ret = pm_runtime_get_sync(dev->dev);
554568 if (ret < 0 && ret != -EACCES) {
555569 pm_runtime_put_autosuspend(dev->dev);
570
+ nouveau_connector_set_edid(nv_connector, NULL);
556571 return conn_status;
557572 }
558573 }
559574
560575 nv_encoder = nouveau_connector_ddc_detect(connector);
561576 if (nv_encoder && (i2c = nv_encoder->i2c) != NULL) {
577
+ struct edid *new_edid;
578
+
562579 if ((vga_switcheroo_handler_flags() &
563580 VGA_SWITCHEROO_CAN_SWITCH_DDC) &&
564581 nv_connector->type == DCB_CONNECTOR_LVDS)
565
- nv_connector->edid = drm_get_edid_switcheroo(connector,
566
- i2c);
582
+ new_edid = drm_get_edid_switcheroo(connector, i2c);
567583 else
568
- nv_connector->edid = drm_get_edid(connector, i2c);
584
+ new_edid = drm_get_edid(connector, i2c);
569585
570
- drm_connector_update_edid_property(connector,
571
- nv_connector->edid);
586
+ nouveau_connector_set_edid(nv_connector, new_edid);
572587 if (!nv_connector->edid) {
573588 NV_ERROR(drm, "DDC responded, but no EDID for %s\n",
574589 connector->name);
....@@ -600,7 +615,10 @@
600615
601616 nouveau_connector_set_encoder(connector, nv_encoder);
602617 conn_status = connector_status_connected;
618
+ drm_dp_cec_set_edid(&nv_connector->aux, nv_connector->edid);
603619 goto out;
620
+ } else {
621
+ nouveau_connector_set_edid(nv_connector, NULL);
604622 }
605623
606624 nv_encoder = nouveau_connector_of_detect(connector);
....@@ -625,10 +643,11 @@
625643 conn_status = connector_status_connected;
626644 goto out;
627645 }
628
-
629646 }
630647
631648 out:
649
+ if (!nv_connector->edid)
650
+ drm_dp_cec_unset_edid(&nv_connector->aux);
632651
633652 pm_runtime_mark_last_busy(dev->dev);
634653 pm_runtime_put_autosuspend(dev->dev);
....@@ -643,24 +662,20 @@
643662 struct nouveau_drm *drm = nouveau_drm(dev);
644663 struct nouveau_connector *nv_connector = nouveau_connector(connector);
645664 struct nouveau_encoder *nv_encoder = NULL;
665
+ struct edid *edid = NULL;
646666 enum drm_connector_status status = connector_status_disconnected;
647
-
648
- /* Cleanup the previous EDID block. */
649
- if (nv_connector->edid) {
650
- drm_connector_update_edid_property(connector, NULL);
651
- kfree(nv_connector->edid);
652
- nv_connector->edid = NULL;
653
- }
654667
655668 nv_encoder = find_encoder(connector, DCB_OUTPUT_LVDS);
656669 if (!nv_encoder)
657
- return connector_status_disconnected;
670
+ goto out;
658671
659672 /* Try retrieving EDID via DDC */
660673 if (!drm->vbios.fp_no_ddc) {
661674 status = nouveau_connector_detect(connector, force);
662
- if (status == connector_status_connected)
675
+ if (status == connector_status_connected) {
676
+ edid = nv_connector->edid;
663677 goto out;
678
+ }
664679 }
665680
666681 /* On some laptops (Sony, i'm looking at you) there appears to
....@@ -673,7 +688,8 @@
673688 * valid - it's not (rh#613284)
674689 */
675690 if (nv_encoder->dcb->lvdsconf.use_acpi_for_edid) {
676
- if ((nv_connector->edid = nouveau_acpi_edid(dev, connector))) {
691
+ edid = nouveau_acpi_edid(dev, connector);
692
+ if (edid) {
677693 status = connector_status_connected;
678694 goto out;
679695 }
....@@ -693,12 +709,10 @@
693709 * stored for the panel stored in them.
694710 */
695711 if (!drm->vbios.fp_no_ddc) {
696
- struct edid *edid =
697
- (struct edid *)nouveau_bios_embedded_edid(dev);
712
+ edid = (struct edid *)nouveau_bios_embedded_edid(dev);
698713 if (edid) {
699
- nv_connector->edid =
700
- kmemdup(edid, EDID_LENGTH, GFP_KERNEL);
701
- if (nv_connector->edid)
714
+ edid = kmemdup(edid, EDID_LENGTH, GFP_KERNEL);
715
+ if (edid)
702716 status = connector_status_connected;
703717 }
704718 }
....@@ -711,8 +725,9 @@
711725 status = connector_status_unknown;
712726 #endif
713727
714
- drm_connector_update_edid_property(connector, nv_connector->edid);
715
- nouveau_connector_set_encoder(connector, nv_encoder);
728
+ nouveau_connector_set_edid(nv_connector, edid);
729
+ if (nv_encoder)
730
+ nouveau_connector_set_encoder(connector, nv_encoder);
716731 return status;
717732 }
718733
....@@ -747,9 +762,9 @@
747762 nouveau_connector_set_property(struct drm_connector *connector,
748763 struct drm_property *property, uint64_t value)
749764 {
750
- struct nouveau_conn_atom *asyc = nouveau_conn_atom(connector->state);
751765 struct nouveau_connector *nv_connector = nouveau_connector(connector);
752766 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
767
+ struct nouveau_conn_atom *asyc = &nv_connector->properties_state;
753768 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
754769 int ret;
755770
....@@ -885,6 +900,22 @@
885900 }
886901
887902 static int
903
+nouveau_connector_late_register(struct drm_connector *connector)
904
+{
905
+ int ret;
906
+
907
+ ret = nouveau_backlight_init(connector);
908
+
909
+ return ret;
910
+}
911
+
912
+static void
913
+nouveau_connector_early_unregister(struct drm_connector *connector)
914
+{
915
+ nouveau_backlight_fini(connector);
916
+}
917
+
918
+static int
888919 nouveau_connector_get_modes(struct drm_connector *connector)
889920 {
890921 struct drm_device *dev = connector->dev;
....@@ -937,7 +968,7 @@
937968 * "native" mode as some VBIOS tables require us to use the
938969 * pixel clock as part of the lookup...
939970 */
940
- if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)
971
+ if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS && nv_connector->native_mode)
941972 nouveau_connector_detect_depth(connector);
942973
943974 if (nv_encoder->dcb->type == DCB_OUTPUT_TV)
....@@ -952,32 +983,50 @@
952983 }
953984
954985 static unsigned
955
-get_tmds_link_bandwidth(struct drm_connector *connector, bool hdmi)
986
+get_tmds_link_bandwidth(struct drm_connector *connector)
956987 {
957988 struct nouveau_connector *nv_connector = nouveau_connector(connector);
989
+ struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
958990 struct nouveau_drm *drm = nouveau_drm(connector->dev);
959991 struct dcb_output *dcb = nv_connector->detected_encoder->dcb;
992
+ struct drm_display_info *info = NULL;
993
+ unsigned duallink_scale =
994
+ nouveau_duallink && nv_encoder->dcb->duallink_possible ? 2 : 1;
960995
961
- if (hdmi) {
996
+ if (drm_detect_hdmi_monitor(nv_connector->edid)) {
997
+ info = &nv_connector->base.display_info;
998
+ duallink_scale = 1;
999
+ }
1000
+
1001
+ if (info) {
9621002 if (nouveau_hdmimhz > 0)
9631003 return nouveau_hdmimhz * 1000;
9641004 /* Note: these limits are conservative, some Fermi's
9651005 * can do 297 MHz. Unclear how this can be determined.
9661006 */
1007
+ if (drm->client.device.info.chipset >= 0x120) {
1008
+ const int max_tmds_clock =
1009
+ info->hdmi.scdc.scrambling.supported ?
1010
+ 594000 : 340000;
1011
+ return info->max_tmds_clock ?
1012
+ min(info->max_tmds_clock, max_tmds_clock) :
1013
+ max_tmds_clock;
1014
+ }
9671015 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_KEPLER)
9681016 return 297000;
9691017 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_FERMI)
9701018 return 225000;
9711019 }
1020
+
9721021 if (dcb->location != DCB_LOC_ON_CHIP ||
9731022 drm->client.device.info.chipset >= 0x46)
974
- return 165000;
1023
+ return 165000 * duallink_scale;
9751024 else if (drm->client.device.info.chipset >= 0x40)
976
- return 155000;
1025
+ return 155000 * duallink_scale;
9771026 else if (drm->client.device.info.chipset >= 0x18)
978
- return 135000;
1027
+ return 135000 * duallink_scale;
9791028 else
980
- return 112000;
1029
+ return 112000 * duallink_scale;
9811030 }
9821031
9831032 static enum drm_mode_status
....@@ -987,9 +1036,7 @@
9871036 struct nouveau_connector *nv_connector = nouveau_connector(connector);
9881037 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
9891038 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
990
- unsigned min_clock = 25000, max_clock = min_clock;
991
- unsigned clock = mode->clock;
992
- bool hdmi;
1039
+ unsigned int min_clock = 25000, max_clock = min_clock, clock = mode->clock;
9931040
9941041 switch (nv_encoder->dcb->type) {
9951042 case DCB_OUTPUT_LVDS:
....@@ -1002,11 +1049,7 @@
10021049 max_clock = 400000;
10031050 break;
10041051 case DCB_OUTPUT_TMDS:
1005
- hdmi = drm_detect_hdmi_monitor(nv_connector->edid);
1006
- max_clock = get_tmds_link_bandwidth(connector, hdmi);
1007
- if (!hdmi && nouveau_duallink &&
1008
- nv_encoder->dcb->duallink_possible)
1009
- max_clock *= 2;
1052
+ max_clock = get_tmds_link_bandwidth(connector);
10101053 break;
10111054 case DCB_OUTPUT_ANALOG:
10121055 max_clock = nv_encoder->dcb->crtconf.maxfreq;
....@@ -1016,10 +1059,7 @@
10161059 case DCB_OUTPUT_TV:
10171060 return get_slave_funcs(encoder)->mode_valid(encoder, mode);
10181061 case DCB_OUTPUT_DP:
1019
- max_clock = nv_encoder->dp.link_nr;
1020
- max_clock *= nv_encoder->dp.link_bw;
1021
- clock = clock * (connector->display_info.bpc * 3) / 10;
1022
- break;
1062
+ return nv50_dp_mode_valid(connector, nv_encoder, mode, NULL);
10231063 default:
10241064 BUG();
10251065 return MODE_BAD;
....@@ -1030,7 +1070,6 @@
10301070
10311071 if (clock < min_clock)
10321072 return MODE_CLOCK_LOW;
1033
-
10341073 if (clock > max_clock)
10351074 return MODE_CLOCK_HIGH;
10361075
....@@ -1068,6 +1107,8 @@
10681107 .atomic_destroy_state = nouveau_conn_atomic_destroy_state,
10691108 .atomic_set_property = nouveau_conn_atomic_set_property,
10701109 .atomic_get_property = nouveau_conn_atomic_get_property,
1110
+ .late_register = nouveau_connector_late_register,
1111
+ .early_unregister = nouveau_connector_early_unregister,
10711112 };
10721113
10731114 static const struct drm_connector_funcs
....@@ -1083,7 +1124,23 @@
10831124 .atomic_destroy_state = nouveau_conn_atomic_destroy_state,
10841125 .atomic_set_property = nouveau_conn_atomic_set_property,
10851126 .atomic_get_property = nouveau_conn_atomic_get_property,
1127
+ .late_register = nouveau_connector_late_register,
1128
+ .early_unregister = nouveau_connector_early_unregister,
10861129 };
1130
+
1131
+void
1132
+nouveau_connector_hpd(struct drm_connector *connector)
1133
+{
1134
+ struct nouveau_drm *drm = nouveau_drm(connector->dev);
1135
+ u32 mask = drm_connector_mask(connector);
1136
+
1137
+ mutex_lock(&drm->hpd_lock);
1138
+ if (!(drm->hpd_pending & mask)) {
1139
+ drm->hpd_pending |= mask;
1140
+ schedule_work(&drm->hpd_work);
1141
+ }
1142
+ mutex_unlock(&drm->hpd_lock);
1143
+}
10871144
10881145 static int
10891146 nouveau_connector_hotplug(struct nvif_notify *notify)
....@@ -1091,49 +1148,19 @@
10911148 struct nouveau_connector *nv_connector =
10921149 container_of(notify, typeof(*nv_connector), hpd);
10931150 struct drm_connector *connector = &nv_connector->base;
1094
- struct nouveau_drm *drm = nouveau_drm(connector->dev);
1151
+ struct drm_device *dev = connector->dev;
1152
+ struct nouveau_drm *drm = nouveau_drm(dev);
10951153 const struct nvif_notify_conn_rep_v0 *rep = notify->data;
1096
- const char *name = connector->name;
1097
- struct nouveau_encoder *nv_encoder;
1098
- int ret;
1099
-
1100
- ret = pm_runtime_get(drm->dev->dev);
1101
- if (ret == 0) {
1102
- /* We can't block here if there's a pending PM request
1103
- * running, as we'll deadlock nouveau_display_fini() when it
1104
- * calls nvif_put() on our nvif_notify struct. So, simply
1105
- * defer the hotplug event until the device finishes resuming
1106
- */
1107
- NV_DEBUG(drm, "Deferring HPD on %s until runtime resume\n",
1108
- name);
1109
- schedule_work(&drm->hpd_work);
1110
-
1111
- pm_runtime_put_noidle(drm->dev->dev);
1112
- return NVIF_NOTIFY_KEEP;
1113
- } else if (ret != 1 && ret != -EACCES) {
1114
- NV_WARN(drm, "HPD on %s dropped due to RPM failure: %d\n",
1115
- name, ret);
1116
- return NVIF_NOTIFY_DROP;
1117
- }
1154
+ bool plugged = (rep->mask != NVIF_NOTIFY_CONN_V0_UNPLUG);
11181155
11191156 if (rep->mask & NVIF_NOTIFY_CONN_V0_IRQ) {
1120
- NV_DEBUG(drm, "service %s\n", name);
1121
- if ((nv_encoder = find_encoder(connector, DCB_OUTPUT_DP)))
1122
- nv50_mstm_service(nv_encoder->dp.mstm);
1123
- } else {
1124
- bool plugged = (rep->mask != NVIF_NOTIFY_CONN_V0_UNPLUG);
1125
-
1126
- NV_DEBUG(drm, "%splugged %s\n", plugged ? "" : "un", name);
1127
- if ((nv_encoder = find_encoder(connector, DCB_OUTPUT_DP))) {
1128
- if (!plugged)
1129
- nv50_mstm_remove(nv_encoder->dp.mstm);
1130
- }
1131
-
1132
- drm_helper_hpd_irq_event(connector->dev);
1157
+ nouveau_dp_irq(drm, nv_connector);
1158
+ return NVIF_NOTIFY_KEEP;
11331159 }
11341160
1135
- pm_runtime_mark_last_busy(drm->dev->dev);
1136
- pm_runtime_put_autosuspend(drm->dev->dev);
1161
+ NV_DEBUG(drm, "%splugged %s\n", plugged ? "" : "un", connector->name);
1162
+ nouveau_connector_hpd(connector);
1163
+
11371164 return NVIF_NOTIFY_KEEP;
11381165 }
11391166
....@@ -1184,7 +1211,9 @@
11841211 case DCB_CONNECTOR_LVDS_SPWG: return DRM_MODE_CONNECTOR_LVDS;
11851212 case DCB_CONNECTOR_DMS59_DP0:
11861213 case DCB_CONNECTOR_DMS59_DP1:
1187
- case DCB_CONNECTOR_DP : return DRM_MODE_CONNECTOR_DisplayPort;
1214
+ case DCB_CONNECTOR_DP :
1215
+ case DCB_CONNECTOR_mDP :
1216
+ case DCB_CONNECTOR_USB_C : return DRM_MODE_CONNECTOR_DisplayPort;
11881217 case DCB_CONNECTOR_eDP : return DRM_MODE_CONNECTOR_eDP;
11891218 case DCB_CONNECTOR_HDMI_0 :
11901219 case DCB_CONNECTOR_HDMI_1 :
....@@ -1198,7 +1227,8 @@
11981227 }
11991228
12001229 struct drm_connector *
1201
-nouveau_connector_create(struct drm_device *dev, int index)
1230
+nouveau_connector_create(struct drm_device *dev,
1231
+ const struct dcb_output *dcbe)
12021232 {
12031233 const struct drm_connector_funcs *funcs = &nouveau_connector_funcs;
12041234 struct nouveau_drm *drm = nouveau_drm(dev);
....@@ -1206,6 +1236,8 @@
12061236 struct nouveau_connector *nv_connector = NULL;
12071237 struct drm_connector *connector;
12081238 struct drm_connector_list_iter conn_iter;
1239
+ char aux_name[48] = {0};
1240
+ int index = dcbe->connector;
12091241 int type, ret = 0;
12101242 bool dummy;
12111243
....@@ -1306,15 +1338,17 @@
13061338 break;
13071339 case DRM_MODE_CONNECTOR_DisplayPort:
13081340 case DRM_MODE_CONNECTOR_eDP:
1309
- nv_connector->aux.dev = dev->dev;
1341
+ nv_connector->aux.dev = connector->kdev;
13101342 nv_connector->aux.transfer = nouveau_connector_aux_xfer;
1343
+ snprintf(aux_name, sizeof(aux_name), "sor-%04x-%04x",
1344
+ dcbe->hasht, dcbe->hashm);
1345
+ nv_connector->aux.name = kstrdup(aux_name, GFP_KERNEL);
13111346 ret = drm_dp_aux_register(&nv_connector->aux);
13121347 if (ret) {
13131348 NV_ERROR(drm, "failed to register aux channel\n");
13141349 kfree(nv_connector);
13151350 return ERR_PTR(ret);
13161351 }
1317
-
13181352 funcs = &nouveau_connector_funcs;
13191353 break;
13201354 default:
....@@ -1368,7 +1402,15 @@
13681402 break;
13691403 }
13701404
1371
- ret = nvif_notify_init(&disp->disp.object, nouveau_connector_hotplug,
1405
+ switch (type) {
1406
+ case DRM_MODE_CONNECTOR_DisplayPort:
1407
+ case DRM_MODE_CONNECTOR_eDP:
1408
+ drm_dp_cec_register_connector(&nv_connector->aux, connector);
1409
+ break;
1410
+ }
1411
+
1412
+ ret = nvif_notify_ctor(&disp->disp.object, "kmsHotplug",
1413
+ nouveau_connector_hotplug,
13721414 true, NV04_DISP_NTFY_CONN,
13731415 &(struct nvif_notify_conn_req_v0) {
13741416 .mask = NVIF_NOTIFY_CONN_V0_ANY,