drm/nouveau/kms: allow 225/297MHz pixel clocks for HDMI on Fermi/Kepler
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nouveau_connector.c
1 /*
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 <acpi/button.h>
28
29 #include <linux/pm_runtime.h>
30
31 #include <drm/drmP.h>
32 #include <drm/drm_edid.h>
33 #include <drm/drm_crtc_helper.h>
34
35 #include "nouveau_reg.h"
36 #include "nouveau_drm.h"
37 #include "dispnv04/hw.h"
38 #include "nouveau_acpi.h"
39
40 #include "nouveau_display.h"
41 #include "nouveau_connector.h"
42 #include "nouveau_encoder.h"
43 #include "nouveau_crtc.h"
44
45 #include <nvif/event.h>
46
47 MODULE_PARM_DESC(tv_disable, "Disable TV-out detection");
48 int nouveau_tv_disable = 0;
49 module_param_named(tv_disable, nouveau_tv_disable, int, 0400);
50
51 MODULE_PARM_DESC(ignorelid, "Ignore ACPI lid status");
52 int nouveau_ignorelid = 0;
53 module_param_named(ignorelid, nouveau_ignorelid, int, 0400);
54
55 MODULE_PARM_DESC(duallink, "Allow dual-link TMDS (default: enabled)");
56 int nouveau_duallink = 1;
57 module_param_named(duallink, nouveau_duallink, int, 0400);
58
59 MODULE_PARM_DESC(hdmimhz, "Force a maximum HDMI pixel clock (in MHz)");
60 int nouveau_hdmimhz = 0;
61 module_param_named(hdmimhz, nouveau_hdmimhz, int, 0400);
62
63 struct nouveau_encoder *
64 find_encoder(struct drm_connector *connector, int type)
65 {
66 struct drm_device *dev = connector->dev;
67 struct nouveau_encoder *nv_encoder;
68 struct drm_encoder *enc;
69 int i, id;
70
71 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
72 id = connector->encoder_ids[i];
73 if (!id)
74 break;
75
76 enc = drm_encoder_find(dev, id);
77 if (!enc)
78 continue;
79 nv_encoder = nouveau_encoder(enc);
80
81 if (type == DCB_OUTPUT_ANY ||
82 (nv_encoder->dcb && nv_encoder->dcb->type == type))
83 return nv_encoder;
84 }
85
86 return NULL;
87 }
88
89 struct nouveau_connector *
90 nouveau_encoder_connector_get(struct nouveau_encoder *encoder)
91 {
92 struct drm_device *dev = to_drm_encoder(encoder)->dev;
93 struct drm_connector *drm_connector;
94
95 list_for_each_entry(drm_connector, &dev->mode_config.connector_list, head) {
96 if (drm_connector->encoder == to_drm_encoder(encoder))
97 return nouveau_connector(drm_connector);
98 }
99
100 return NULL;
101 }
102
103 static void
104 nouveau_connector_destroy(struct drm_connector *connector)
105 {
106 struct nouveau_connector *nv_connector = nouveau_connector(connector);
107 nvif_notify_fini(&nv_connector->hpd);
108 kfree(nv_connector->edid);
109 drm_connector_unregister(connector);
110 drm_connector_cleanup(connector);
111 if (nv_connector->aux.transfer)
112 drm_dp_aux_unregister(&nv_connector->aux);
113 kfree(connector);
114 }
115
116 static struct nouveau_encoder *
117 nouveau_connector_ddc_detect(struct drm_connector *connector)
118 {
119 struct drm_device *dev = connector->dev;
120 struct nouveau_connector *nv_connector = nouveau_connector(connector);
121 struct nouveau_drm *drm = nouveau_drm(dev);
122 struct nvkm_gpio *gpio = nvxx_gpio(&drm->device);
123 struct nouveau_encoder *nv_encoder;
124 struct drm_encoder *encoder;
125 int i, panel = -ENODEV;
126
127 /* eDP panels need powering on by us (if the VBIOS doesn't default it
128 * to on) before doing any AUX channel transactions. LVDS panel power
129 * is handled by the SOR itself, and not required for LVDS DDC.
130 */
131 if (nv_connector->type == DCB_CONNECTOR_eDP) {
132 panel = nvkm_gpio_get(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff);
133 if (panel == 0) {
134 nvkm_gpio_set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, 1);
135 msleep(300);
136 }
137 }
138
139 for (i = 0; nv_encoder = NULL, i < DRM_CONNECTOR_MAX_ENCODER; i++) {
140 int id = connector->encoder_ids[i];
141 if (id == 0)
142 break;
143
144 encoder = drm_encoder_find(dev, id);
145 if (!encoder)
146 continue;
147 nv_encoder = nouveau_encoder(encoder);
148
149 if (nv_encoder->dcb->type == DCB_OUTPUT_DP) {
150 int ret = nouveau_dp_detect(nv_encoder);
151 if (ret == 0)
152 break;
153 } else
154 if (nv_encoder->i2c) {
155 if (nvkm_probe_i2c(nv_encoder->i2c, 0x50))
156 break;
157 }
158 }
159
160 /* eDP panel not detected, restore panel power GPIO to previous
161 * state to avoid confusing the SOR for other output types.
162 */
163 if (!nv_encoder && panel == 0)
164 nvkm_gpio_set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, panel);
165
166 return nv_encoder;
167 }
168
169 static struct nouveau_encoder *
170 nouveau_connector_of_detect(struct drm_connector *connector)
171 {
172 #ifdef __powerpc__
173 struct drm_device *dev = connector->dev;
174 struct nouveau_connector *nv_connector = nouveau_connector(connector);
175 struct nouveau_encoder *nv_encoder;
176 struct device_node *cn, *dn = pci_device_to_OF_node(dev->pdev);
177
178 if (!dn ||
179 !((nv_encoder = find_encoder(connector, DCB_OUTPUT_TMDS)) ||
180 (nv_encoder = find_encoder(connector, DCB_OUTPUT_ANALOG))))
181 return NULL;
182
183 for_each_child_of_node(dn, cn) {
184 const char *name = of_get_property(cn, "name", NULL);
185 const void *edid = of_get_property(cn, "EDID", NULL);
186 int idx = name ? name[strlen(name) - 1] - 'A' : 0;
187
188 if (nv_encoder->dcb->i2c_index == idx && edid) {
189 nv_connector->edid =
190 kmemdup(edid, EDID_LENGTH, GFP_KERNEL);
191 of_node_put(cn);
192 return nv_encoder;
193 }
194 }
195 #endif
196 return NULL;
197 }
198
199 static void
200 nouveau_connector_set_encoder(struct drm_connector *connector,
201 struct nouveau_encoder *nv_encoder)
202 {
203 struct nouveau_connector *nv_connector = nouveau_connector(connector);
204 struct nouveau_drm *drm = nouveau_drm(connector->dev);
205 struct drm_device *dev = connector->dev;
206
207 if (nv_connector->detected_encoder == nv_encoder)
208 return;
209 nv_connector->detected_encoder = nv_encoder;
210
211 if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
212 connector->interlace_allowed = true;
213 connector->doublescan_allowed = true;
214 } else
215 if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS ||
216 nv_encoder->dcb->type == DCB_OUTPUT_TMDS) {
217 connector->doublescan_allowed = false;
218 connector->interlace_allowed = false;
219 } else {
220 connector->doublescan_allowed = true;
221 if (drm->device.info.family == NV_DEVICE_INFO_V0_KELVIN ||
222 (drm->device.info.family == NV_DEVICE_INFO_V0_CELSIUS &&
223 (dev->pdev->device & 0x0ff0) != 0x0100 &&
224 (dev->pdev->device & 0x0ff0) != 0x0150))
225 /* HW is broken */
226 connector->interlace_allowed = false;
227 else
228 connector->interlace_allowed = true;
229 }
230
231 if (nv_connector->type == DCB_CONNECTOR_DVI_I) {
232 drm_object_property_set_value(&connector->base,
233 dev->mode_config.dvi_i_subconnector_property,
234 nv_encoder->dcb->type == DCB_OUTPUT_TMDS ?
235 DRM_MODE_SUBCONNECTOR_DVID :
236 DRM_MODE_SUBCONNECTOR_DVIA);
237 }
238 }
239
240 static enum drm_connector_status
241 nouveau_connector_detect(struct drm_connector *connector, bool force)
242 {
243 struct drm_device *dev = connector->dev;
244 struct nouveau_drm *drm = nouveau_drm(dev);
245 struct nouveau_connector *nv_connector = nouveau_connector(connector);
246 struct nouveau_encoder *nv_encoder = NULL;
247 struct nouveau_encoder *nv_partner;
248 struct i2c_adapter *i2c;
249 int type;
250 int ret;
251 enum drm_connector_status conn_status = connector_status_disconnected;
252
253 /* Cleanup the previous EDID block. */
254 if (nv_connector->edid) {
255 drm_mode_connector_update_edid_property(connector, NULL);
256 kfree(nv_connector->edid);
257 nv_connector->edid = NULL;
258 }
259
260 ret = pm_runtime_get_sync(connector->dev->dev);
261 if (ret < 0 && ret != -EACCES)
262 return conn_status;
263
264 nv_encoder = nouveau_connector_ddc_detect(connector);
265 if (nv_encoder && (i2c = nv_encoder->i2c) != NULL) {
266 nv_connector->edid = drm_get_edid(connector, i2c);
267 drm_mode_connector_update_edid_property(connector,
268 nv_connector->edid);
269 if (!nv_connector->edid) {
270 NV_ERROR(drm, "DDC responded, but no EDID for %s\n",
271 connector->name);
272 goto detect_analog;
273 }
274
275 /* Override encoder type for DVI-I based on whether EDID
276 * says the display is digital or analog, both use the
277 * same i2c channel so the value returned from ddc_detect
278 * isn't necessarily correct.
279 */
280 nv_partner = NULL;
281 if (nv_encoder->dcb->type == DCB_OUTPUT_TMDS)
282 nv_partner = find_encoder(connector, DCB_OUTPUT_ANALOG);
283 if (nv_encoder->dcb->type == DCB_OUTPUT_ANALOG)
284 nv_partner = find_encoder(connector, DCB_OUTPUT_TMDS);
285
286 if (nv_partner && ((nv_encoder->dcb->type == DCB_OUTPUT_ANALOG &&
287 nv_partner->dcb->type == DCB_OUTPUT_TMDS) ||
288 (nv_encoder->dcb->type == DCB_OUTPUT_TMDS &&
289 nv_partner->dcb->type == DCB_OUTPUT_ANALOG))) {
290 if (nv_connector->edid->input & DRM_EDID_INPUT_DIGITAL)
291 type = DCB_OUTPUT_TMDS;
292 else
293 type = DCB_OUTPUT_ANALOG;
294
295 nv_encoder = find_encoder(connector, type);
296 }
297
298 nouveau_connector_set_encoder(connector, nv_encoder);
299 conn_status = connector_status_connected;
300 goto out;
301 }
302
303 nv_encoder = nouveau_connector_of_detect(connector);
304 if (nv_encoder) {
305 nouveau_connector_set_encoder(connector, nv_encoder);
306 conn_status = connector_status_connected;
307 goto out;
308 }
309
310 detect_analog:
311 nv_encoder = find_encoder(connector, DCB_OUTPUT_ANALOG);
312 if (!nv_encoder && !nouveau_tv_disable)
313 nv_encoder = find_encoder(connector, DCB_OUTPUT_TV);
314 if (nv_encoder && force) {
315 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
316 const struct drm_encoder_helper_funcs *helper =
317 encoder->helper_private;
318
319 if (helper->detect(encoder, connector) ==
320 connector_status_connected) {
321 nouveau_connector_set_encoder(connector, nv_encoder);
322 conn_status = connector_status_connected;
323 goto out;
324 }
325
326 }
327
328 out:
329
330 pm_runtime_mark_last_busy(connector->dev->dev);
331 pm_runtime_put_autosuspend(connector->dev->dev);
332
333 return conn_status;
334 }
335
336 static enum drm_connector_status
337 nouveau_connector_detect_lvds(struct drm_connector *connector, bool force)
338 {
339 struct drm_device *dev = connector->dev;
340 struct nouveau_drm *drm = nouveau_drm(dev);
341 struct nouveau_connector *nv_connector = nouveau_connector(connector);
342 struct nouveau_encoder *nv_encoder = NULL;
343 enum drm_connector_status status = connector_status_disconnected;
344
345 /* Cleanup the previous EDID block. */
346 if (nv_connector->edid) {
347 drm_mode_connector_update_edid_property(connector, NULL);
348 kfree(nv_connector->edid);
349 nv_connector->edid = NULL;
350 }
351
352 nv_encoder = find_encoder(connector, DCB_OUTPUT_LVDS);
353 if (!nv_encoder)
354 return connector_status_disconnected;
355
356 /* Try retrieving EDID via DDC */
357 if (!drm->vbios.fp_no_ddc) {
358 status = nouveau_connector_detect(connector, force);
359 if (status == connector_status_connected)
360 goto out;
361 }
362
363 /* On some laptops (Sony, i'm looking at you) there appears to
364 * be no direct way of accessing the panel's EDID. The only
365 * option available to us appears to be to ask ACPI for help..
366 *
367 * It's important this check's before trying straps, one of the
368 * said manufacturer's laptops are configured in such a way
369 * the nouveau decides an entry in the VBIOS FP mode table is
370 * valid - it's not (rh#613284)
371 */
372 if (nv_encoder->dcb->lvdsconf.use_acpi_for_edid) {
373 if ((nv_connector->edid = nouveau_acpi_edid(dev, connector))) {
374 status = connector_status_connected;
375 goto out;
376 }
377 }
378
379 /* If no EDID found above, and the VBIOS indicates a hardcoded
380 * modeline is avalilable for the panel, set it as the panel's
381 * native mode and exit.
382 */
383 if (nouveau_bios_fp_mode(dev, NULL) && (drm->vbios.fp_no_ddc ||
384 nv_encoder->dcb->lvdsconf.use_straps_for_mode)) {
385 status = connector_status_connected;
386 goto out;
387 }
388
389 /* Still nothing, some VBIOS images have a hardcoded EDID block
390 * stored for the panel stored in them.
391 */
392 if (!drm->vbios.fp_no_ddc) {
393 struct edid *edid =
394 (struct edid *)nouveau_bios_embedded_edid(dev);
395 if (edid) {
396 nv_connector->edid =
397 kmemdup(edid, EDID_LENGTH, GFP_KERNEL);
398 if (nv_connector->edid)
399 status = connector_status_connected;
400 }
401 }
402
403 out:
404 #if defined(CONFIG_ACPI_BUTTON) || \
405 (defined(CONFIG_ACPI_BUTTON_MODULE) && defined(MODULE))
406 if (status == connector_status_connected &&
407 !nouveau_ignorelid && !acpi_lid_open())
408 status = connector_status_unknown;
409 #endif
410
411 drm_mode_connector_update_edid_property(connector, nv_connector->edid);
412 nouveau_connector_set_encoder(connector, nv_encoder);
413 return status;
414 }
415
416 static void
417 nouveau_connector_force(struct drm_connector *connector)
418 {
419 struct nouveau_drm *drm = nouveau_drm(connector->dev);
420 struct nouveau_connector *nv_connector = nouveau_connector(connector);
421 struct nouveau_encoder *nv_encoder;
422 int type;
423
424 if (nv_connector->type == DCB_CONNECTOR_DVI_I) {
425 if (connector->force == DRM_FORCE_ON_DIGITAL)
426 type = DCB_OUTPUT_TMDS;
427 else
428 type = DCB_OUTPUT_ANALOG;
429 } else
430 type = DCB_OUTPUT_ANY;
431
432 nv_encoder = find_encoder(connector, type);
433 if (!nv_encoder) {
434 NV_ERROR(drm, "can't find encoder to force %s on!\n",
435 connector->name);
436 connector->status = connector_status_disconnected;
437 return;
438 }
439
440 nouveau_connector_set_encoder(connector, nv_encoder);
441 }
442
443 static int
444 nouveau_connector_set_property(struct drm_connector *connector,
445 struct drm_property *property, uint64_t value)
446 {
447 struct nouveau_display *disp = nouveau_display(connector->dev);
448 struct nouveau_connector *nv_connector = nouveau_connector(connector);
449 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
450 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
451 struct drm_device *dev = connector->dev;
452 struct nouveau_crtc *nv_crtc;
453 int ret;
454
455 nv_crtc = NULL;
456 if (connector->encoder && connector->encoder->crtc)
457 nv_crtc = nouveau_crtc(connector->encoder->crtc);
458
459 /* Scaling mode */
460 if (property == dev->mode_config.scaling_mode_property) {
461 bool modeset = false;
462
463 switch (value) {
464 case DRM_MODE_SCALE_NONE:
465 /* We allow 'None' for EDID modes, even on a fixed
466 * panel (some exist with support for lower refresh
467 * rates, which people might want to use for power
468 * saving purposes).
469 *
470 * Non-EDID modes will force the use of GPU scaling
471 * to the native mode regardless of this setting.
472 */
473 switch (nv_connector->type) {
474 case DCB_CONNECTOR_LVDS:
475 case DCB_CONNECTOR_LVDS_SPWG:
476 case DCB_CONNECTOR_eDP:
477 /* ... except prior to G80, where the code
478 * doesn't support such things.
479 */
480 if (disp->disp.oclass < NV50_DISP)
481 return -EINVAL;
482 break;
483 default:
484 break;
485 }
486 break;
487 case DRM_MODE_SCALE_FULLSCREEN:
488 case DRM_MODE_SCALE_CENTER:
489 case DRM_MODE_SCALE_ASPECT:
490 break;
491 default:
492 return -EINVAL;
493 }
494
495 /* Changing between GPU and panel scaling requires a full
496 * modeset
497 */
498 if ((nv_connector->scaling_mode == DRM_MODE_SCALE_NONE) ||
499 (value == DRM_MODE_SCALE_NONE))
500 modeset = true;
501 nv_connector->scaling_mode = value;
502
503 if (!nv_crtc)
504 return 0;
505
506 if (modeset || !nv_crtc->set_scale) {
507 ret = drm_crtc_helper_set_mode(&nv_crtc->base,
508 &nv_crtc->base.mode,
509 nv_crtc->base.x,
510 nv_crtc->base.y, NULL);
511 if (!ret)
512 return -EINVAL;
513 } else {
514 ret = nv_crtc->set_scale(nv_crtc, true);
515 if (ret)
516 return ret;
517 }
518
519 return 0;
520 }
521
522 /* Underscan */
523 if (property == disp->underscan_property) {
524 if (nv_connector->underscan != value) {
525 nv_connector->underscan = value;
526 if (!nv_crtc || !nv_crtc->set_scale)
527 return 0;
528
529 return nv_crtc->set_scale(nv_crtc, true);
530 }
531
532 return 0;
533 }
534
535 if (property == disp->underscan_hborder_property) {
536 if (nv_connector->underscan_hborder != value) {
537 nv_connector->underscan_hborder = value;
538 if (!nv_crtc || !nv_crtc->set_scale)
539 return 0;
540
541 return nv_crtc->set_scale(nv_crtc, true);
542 }
543
544 return 0;
545 }
546
547 if (property == disp->underscan_vborder_property) {
548 if (nv_connector->underscan_vborder != value) {
549 nv_connector->underscan_vborder = value;
550 if (!nv_crtc || !nv_crtc->set_scale)
551 return 0;
552
553 return nv_crtc->set_scale(nv_crtc, true);
554 }
555
556 return 0;
557 }
558
559 /* Dithering */
560 if (property == disp->dithering_mode) {
561 nv_connector->dithering_mode = value;
562 if (!nv_crtc || !nv_crtc->set_dither)
563 return 0;
564
565 return nv_crtc->set_dither(nv_crtc, true);
566 }
567
568 if (property == disp->dithering_depth) {
569 nv_connector->dithering_depth = value;
570 if (!nv_crtc || !nv_crtc->set_dither)
571 return 0;
572
573 return nv_crtc->set_dither(nv_crtc, true);
574 }
575
576 if (nv_crtc && nv_crtc->set_color_vibrance) {
577 /* Hue */
578 if (property == disp->vibrant_hue_property) {
579 nv_crtc->vibrant_hue = value - 90;
580 return nv_crtc->set_color_vibrance(nv_crtc, true);
581 }
582 /* Saturation */
583 if (property == disp->color_vibrance_property) {
584 nv_crtc->color_vibrance = value - 100;
585 return nv_crtc->set_color_vibrance(nv_crtc, true);
586 }
587 }
588
589 if (nv_encoder && nv_encoder->dcb->type == DCB_OUTPUT_TV)
590 return get_slave_funcs(encoder)->set_property(
591 encoder, connector, property, value);
592
593 return -EINVAL;
594 }
595
596 static struct drm_display_mode *
597 nouveau_connector_native_mode(struct drm_connector *connector)
598 {
599 const struct drm_connector_helper_funcs *helper = connector->helper_private;
600 struct nouveau_drm *drm = nouveau_drm(connector->dev);
601 struct nouveau_connector *nv_connector = nouveau_connector(connector);
602 struct drm_device *dev = connector->dev;
603 struct drm_display_mode *mode, *largest = NULL;
604 int high_w = 0, high_h = 0, high_v = 0;
605
606 list_for_each_entry(mode, &nv_connector->base.probed_modes, head) {
607 mode->vrefresh = drm_mode_vrefresh(mode);
608 if (helper->mode_valid(connector, mode) != MODE_OK ||
609 (mode->flags & DRM_MODE_FLAG_INTERLACE))
610 continue;
611
612 /* Use preferred mode if there is one.. */
613 if (mode->type & DRM_MODE_TYPE_PREFERRED) {
614 NV_DEBUG(drm, "native mode from preferred\n");
615 return drm_mode_duplicate(dev, mode);
616 }
617
618 /* Otherwise, take the resolution with the largest width, then
619 * height, then vertical refresh
620 */
621 if (mode->hdisplay < high_w)
622 continue;
623
624 if (mode->hdisplay == high_w && mode->vdisplay < high_h)
625 continue;
626
627 if (mode->hdisplay == high_w && mode->vdisplay == high_h &&
628 mode->vrefresh < high_v)
629 continue;
630
631 high_w = mode->hdisplay;
632 high_h = mode->vdisplay;
633 high_v = mode->vrefresh;
634 largest = mode;
635 }
636
637 NV_DEBUG(drm, "native mode from largest: %dx%d@%d\n",
638 high_w, high_h, high_v);
639 return largest ? drm_mode_duplicate(dev, largest) : NULL;
640 }
641
642 struct moderec {
643 int hdisplay;
644 int vdisplay;
645 };
646
647 static struct moderec scaler_modes[] = {
648 { 1920, 1200 },
649 { 1920, 1080 },
650 { 1680, 1050 },
651 { 1600, 1200 },
652 { 1400, 1050 },
653 { 1280, 1024 },
654 { 1280, 960 },
655 { 1152, 864 },
656 { 1024, 768 },
657 { 800, 600 },
658 { 720, 400 },
659 { 640, 480 },
660 { 640, 400 },
661 { 640, 350 },
662 {}
663 };
664
665 static int
666 nouveau_connector_scaler_modes_add(struct drm_connector *connector)
667 {
668 struct nouveau_connector *nv_connector = nouveau_connector(connector);
669 struct drm_display_mode *native = nv_connector->native_mode, *m;
670 struct drm_device *dev = connector->dev;
671 struct moderec *mode = &scaler_modes[0];
672 int modes = 0;
673
674 if (!native)
675 return 0;
676
677 while (mode->hdisplay) {
678 if (mode->hdisplay <= native->hdisplay &&
679 mode->vdisplay <= native->vdisplay &&
680 (mode->hdisplay != native->hdisplay ||
681 mode->vdisplay != native->vdisplay)) {
682 m = drm_cvt_mode(dev, mode->hdisplay, mode->vdisplay,
683 drm_mode_vrefresh(native), false,
684 false, false);
685 if (!m)
686 continue;
687
688 drm_mode_probed_add(connector, m);
689 modes++;
690 }
691
692 mode++;
693 }
694
695 return modes;
696 }
697
698 static void
699 nouveau_connector_detect_depth(struct drm_connector *connector)
700 {
701 struct nouveau_drm *drm = nouveau_drm(connector->dev);
702 struct nouveau_connector *nv_connector = nouveau_connector(connector);
703 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
704 struct nvbios *bios = &drm->vbios;
705 struct drm_display_mode *mode = nv_connector->native_mode;
706 bool duallink;
707
708 /* if the edid is feeling nice enough to provide this info, use it */
709 if (nv_connector->edid && connector->display_info.bpc)
710 return;
711
712 /* EDID 1.4 is *supposed* to be supported on eDP, but, Apple... */
713 if (nv_connector->type == DCB_CONNECTOR_eDP) {
714 connector->display_info.bpc = 6;
715 return;
716 }
717
718 /* we're out of options unless we're LVDS, default to 8bpc */
719 if (nv_encoder->dcb->type != DCB_OUTPUT_LVDS) {
720 connector->display_info.bpc = 8;
721 return;
722 }
723
724 connector->display_info.bpc = 6;
725
726 /* LVDS: panel straps */
727 if (bios->fp_no_ddc) {
728 if (bios->fp.if_is_24bit)
729 connector->display_info.bpc = 8;
730 return;
731 }
732
733 /* LVDS: DDC panel, need to first determine the number of links to
734 * know which if_is_24bit flag to check...
735 */
736 if (nv_connector->edid &&
737 nv_connector->type == DCB_CONNECTOR_LVDS_SPWG)
738 duallink = ((u8 *)nv_connector->edid)[121] == 2;
739 else
740 duallink = mode->clock >= bios->fp.duallink_transition_clk;
741
742 if ((!duallink && (bios->fp.strapless_is_24bit & 1)) ||
743 ( duallink && (bios->fp.strapless_is_24bit & 2)))
744 connector->display_info.bpc = 8;
745 }
746
747 static int
748 nouveau_connector_get_modes(struct drm_connector *connector)
749 {
750 struct drm_device *dev = connector->dev;
751 struct nouveau_drm *drm = nouveau_drm(dev);
752 struct nouveau_connector *nv_connector = nouveau_connector(connector);
753 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
754 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
755 int ret = 0;
756
757 /* destroy the native mode, the attached monitor could have changed.
758 */
759 if (nv_connector->native_mode) {
760 drm_mode_destroy(dev, nv_connector->native_mode);
761 nv_connector->native_mode = NULL;
762 }
763
764 if (nv_connector->edid)
765 ret = drm_add_edid_modes(connector, nv_connector->edid);
766 else
767 if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS &&
768 (nv_encoder->dcb->lvdsconf.use_straps_for_mode ||
769 drm->vbios.fp_no_ddc) && nouveau_bios_fp_mode(dev, NULL)) {
770 struct drm_display_mode mode;
771
772 nouveau_bios_fp_mode(dev, &mode);
773 nv_connector->native_mode = drm_mode_duplicate(dev, &mode);
774 }
775
776 /* Determine display colour depth for everything except LVDS now,
777 * DP requires this before mode_valid() is called.
778 */
779 if (connector->connector_type != DRM_MODE_CONNECTOR_LVDS)
780 nouveau_connector_detect_depth(connector);
781
782 /* Find the native mode if this is a digital panel, if we didn't
783 * find any modes through DDC previously add the native mode to
784 * the list of modes.
785 */
786 if (!nv_connector->native_mode)
787 nv_connector->native_mode =
788 nouveau_connector_native_mode(connector);
789 if (ret == 0 && nv_connector->native_mode) {
790 struct drm_display_mode *mode;
791
792 mode = drm_mode_duplicate(dev, nv_connector->native_mode);
793 drm_mode_probed_add(connector, mode);
794 ret = 1;
795 }
796
797 /* Determine LVDS colour depth, must happen after determining
798 * "native" mode as some VBIOS tables require us to use the
799 * pixel clock as part of the lookup...
800 */
801 if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)
802 nouveau_connector_detect_depth(connector);
803
804 if (nv_encoder->dcb->type == DCB_OUTPUT_TV)
805 ret = get_slave_funcs(encoder)->get_modes(encoder, connector);
806
807 if (nv_connector->type == DCB_CONNECTOR_LVDS ||
808 nv_connector->type == DCB_CONNECTOR_LVDS_SPWG ||
809 nv_connector->type == DCB_CONNECTOR_eDP)
810 ret += nouveau_connector_scaler_modes_add(connector);
811
812 return ret;
813 }
814
815 static unsigned
816 get_tmds_link_bandwidth(struct drm_connector *connector, bool hdmi)
817 {
818 struct nouveau_connector *nv_connector = nouveau_connector(connector);
819 struct nouveau_drm *drm = nouveau_drm(connector->dev);
820 struct dcb_output *dcb = nv_connector->detected_encoder->dcb;
821
822 if (hdmi) {
823 if (nouveau_hdmimhz > 0)
824 return nouveau_hdmimhz * 1000;
825 /* Note: these limits are conservative, some Fermi's
826 * can do 297 MHz. Unclear how this can be determined.
827 */
828 if (drm->device.info.family >= NV_DEVICE_INFO_V0_KEPLER)
829 return 297000;
830 if (drm->device.info.family >= NV_DEVICE_INFO_V0_FERMI)
831 return 225000;
832 }
833 if (dcb->location != DCB_LOC_ON_CHIP ||
834 drm->device.info.chipset >= 0x46)
835 return 165000;
836 else if (drm->device.info.chipset >= 0x40)
837 return 155000;
838 else if (drm->device.info.chipset >= 0x18)
839 return 135000;
840 else
841 return 112000;
842 }
843
844 static int
845 nouveau_connector_mode_valid(struct drm_connector *connector,
846 struct drm_display_mode *mode)
847 {
848 struct nouveau_connector *nv_connector = nouveau_connector(connector);
849 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
850 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
851 unsigned min_clock = 25000, max_clock = min_clock;
852 unsigned clock = mode->clock;
853 bool hdmi;
854
855 switch (nv_encoder->dcb->type) {
856 case DCB_OUTPUT_LVDS:
857 if (nv_connector->native_mode &&
858 (mode->hdisplay > nv_connector->native_mode->hdisplay ||
859 mode->vdisplay > nv_connector->native_mode->vdisplay))
860 return MODE_PANEL;
861
862 min_clock = 0;
863 max_clock = 400000;
864 break;
865 case DCB_OUTPUT_TMDS:
866 hdmi = drm_detect_hdmi_monitor(nv_connector->edid);
867 max_clock = get_tmds_link_bandwidth(connector, hdmi);
868 if (!hdmi && nouveau_duallink &&
869 nv_encoder->dcb->duallink_possible)
870 max_clock *= 2;
871 break;
872 case DCB_OUTPUT_ANALOG:
873 max_clock = nv_encoder->dcb->crtconf.maxfreq;
874 if (!max_clock)
875 max_clock = 350000;
876 break;
877 case DCB_OUTPUT_TV:
878 return get_slave_funcs(encoder)->mode_valid(encoder, mode);
879 case DCB_OUTPUT_DP:
880 max_clock = nv_encoder->dp.link_nr;
881 max_clock *= nv_encoder->dp.link_bw;
882 clock = clock * (connector->display_info.bpc * 3) / 10;
883 break;
884 default:
885 BUG_ON(1);
886 return MODE_BAD;
887 }
888
889 if (clock < min_clock)
890 return MODE_CLOCK_LOW;
891
892 if (clock > max_clock)
893 return MODE_CLOCK_HIGH;
894
895 return MODE_OK;
896 }
897
898 static struct drm_encoder *
899 nouveau_connector_best_encoder(struct drm_connector *connector)
900 {
901 struct nouveau_connector *nv_connector = nouveau_connector(connector);
902
903 if (nv_connector->detected_encoder)
904 return to_drm_encoder(nv_connector->detected_encoder);
905
906 return NULL;
907 }
908
909 static const struct drm_connector_helper_funcs
910 nouveau_connector_helper_funcs = {
911 .get_modes = nouveau_connector_get_modes,
912 .mode_valid = nouveau_connector_mode_valid,
913 .best_encoder = nouveau_connector_best_encoder,
914 };
915
916 static const struct drm_connector_funcs
917 nouveau_connector_funcs = {
918 .dpms = drm_helper_connector_dpms,
919 .detect = nouveau_connector_detect,
920 .destroy = nouveau_connector_destroy,
921 .fill_modes = drm_helper_probe_single_connector_modes,
922 .set_property = nouveau_connector_set_property,
923 .force = nouveau_connector_force
924 };
925
926 static const struct drm_connector_funcs
927 nouveau_connector_funcs_lvds = {
928 .dpms = drm_helper_connector_dpms,
929 .detect = nouveau_connector_detect_lvds,
930 .destroy = nouveau_connector_destroy,
931 .fill_modes = drm_helper_probe_single_connector_modes,
932 .set_property = nouveau_connector_set_property,
933 .force = nouveau_connector_force
934 };
935
936 static int
937 nouveau_connector_dp_dpms(struct drm_connector *connector, int mode)
938 {
939 struct nouveau_encoder *nv_encoder = NULL;
940
941 if (connector->encoder)
942 nv_encoder = nouveau_encoder(connector->encoder);
943 if (nv_encoder && nv_encoder->dcb &&
944 nv_encoder->dcb->type == DCB_OUTPUT_DP) {
945 if (mode == DRM_MODE_DPMS_ON) {
946 u8 data = DP_SET_POWER_D0;
947 nvkm_wraux(nv_encoder->aux, DP_SET_POWER, &data, 1);
948 usleep_range(1000, 2000);
949 } else {
950 u8 data = DP_SET_POWER_D3;
951 nvkm_wraux(nv_encoder->aux, DP_SET_POWER, &data, 1);
952 }
953 }
954
955 return drm_helper_connector_dpms(connector, mode);
956 }
957
958 static const struct drm_connector_funcs
959 nouveau_connector_funcs_dp = {
960 .dpms = nouveau_connector_dp_dpms,
961 .detect = nouveau_connector_detect,
962 .destroy = nouveau_connector_destroy,
963 .fill_modes = drm_helper_probe_single_connector_modes,
964 .set_property = nouveau_connector_set_property,
965 .force = nouveau_connector_force
966 };
967
968 static int
969 nouveau_connector_hotplug(struct nvif_notify *notify)
970 {
971 struct nouveau_connector *nv_connector =
972 container_of(notify, typeof(*nv_connector), hpd);
973 struct drm_connector *connector = &nv_connector->base;
974 struct nouveau_drm *drm = nouveau_drm(connector->dev);
975 const struct nvif_notify_conn_rep_v0 *rep = notify->data;
976 const char *name = connector->name;
977
978 if (rep->mask & NVIF_NOTIFY_CONN_V0_IRQ) {
979 } else {
980 bool plugged = (rep->mask != NVIF_NOTIFY_CONN_V0_UNPLUG);
981
982 NV_DEBUG(drm, "%splugged %s\n", plugged ? "" : "un", name);
983
984 if (plugged)
985 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
986 else
987 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
988 drm_helper_hpd_irq_event(connector->dev);
989 }
990
991 return NVIF_NOTIFY_KEEP;
992 }
993
994 static ssize_t
995 nouveau_connector_aux_xfer(struct drm_dp_aux *obj, struct drm_dp_aux_msg *msg)
996 {
997 struct nouveau_connector *nv_connector =
998 container_of(obj, typeof(*nv_connector), aux);
999 struct nouveau_encoder *nv_encoder;
1000 struct nvkm_i2c_aux *aux;
1001 int ret;
1002
1003 nv_encoder = find_encoder(&nv_connector->base, DCB_OUTPUT_DP);
1004 if (!nv_encoder || !(aux = nv_encoder->aux))
1005 return -ENODEV;
1006 if (WARN_ON(msg->size > 16))
1007 return -E2BIG;
1008 if (msg->size == 0)
1009 return msg->size;
1010
1011 ret = nvkm_i2c_aux_acquire(aux);
1012 if (ret)
1013 return ret;
1014
1015 ret = nvkm_i2c_aux_xfer(aux, false, msg->request, msg->address,
1016 msg->buffer, msg->size);
1017 nvkm_i2c_aux_release(aux);
1018 if (ret >= 0) {
1019 msg->reply = ret;
1020 return msg->size;
1021 }
1022
1023 return ret;
1024 }
1025
1026 static int
1027 drm_conntype_from_dcb(enum dcb_connector_type dcb)
1028 {
1029 switch (dcb) {
1030 case DCB_CONNECTOR_VGA : return DRM_MODE_CONNECTOR_VGA;
1031 case DCB_CONNECTOR_TV_0 :
1032 case DCB_CONNECTOR_TV_1 :
1033 case DCB_CONNECTOR_TV_3 : return DRM_MODE_CONNECTOR_TV;
1034 case DCB_CONNECTOR_DMS59_0 :
1035 case DCB_CONNECTOR_DMS59_1 :
1036 case DCB_CONNECTOR_DVI_I : return DRM_MODE_CONNECTOR_DVII;
1037 case DCB_CONNECTOR_DVI_D : return DRM_MODE_CONNECTOR_DVID;
1038 case DCB_CONNECTOR_LVDS :
1039 case DCB_CONNECTOR_LVDS_SPWG: return DRM_MODE_CONNECTOR_LVDS;
1040 case DCB_CONNECTOR_DMS59_DP0:
1041 case DCB_CONNECTOR_DMS59_DP1:
1042 case DCB_CONNECTOR_DP : return DRM_MODE_CONNECTOR_DisplayPort;
1043 case DCB_CONNECTOR_eDP : return DRM_MODE_CONNECTOR_eDP;
1044 case DCB_CONNECTOR_HDMI_0 :
1045 case DCB_CONNECTOR_HDMI_1 :
1046 case DCB_CONNECTOR_HDMI_C : return DRM_MODE_CONNECTOR_HDMIA;
1047 default:
1048 break;
1049 }
1050
1051 return DRM_MODE_CONNECTOR_Unknown;
1052 }
1053
1054 struct drm_connector *
1055 nouveau_connector_create(struct drm_device *dev, int index)
1056 {
1057 const struct drm_connector_funcs *funcs = &nouveau_connector_funcs;
1058 struct nouveau_drm *drm = nouveau_drm(dev);
1059 struct nouveau_display *disp = nouveau_display(dev);
1060 struct nouveau_connector *nv_connector = NULL;
1061 struct drm_connector *connector;
1062 int type, ret = 0;
1063 bool dummy;
1064
1065 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1066 nv_connector = nouveau_connector(connector);
1067 if (nv_connector->index == index)
1068 return connector;
1069 }
1070
1071 nv_connector = kzalloc(sizeof(*nv_connector), GFP_KERNEL);
1072 if (!nv_connector)
1073 return ERR_PTR(-ENOMEM);
1074
1075 connector = &nv_connector->base;
1076 nv_connector->index = index;
1077
1078 /* attempt to parse vbios connector type and hotplug gpio */
1079 nv_connector->dcb = olddcb_conn(dev, index);
1080 if (nv_connector->dcb) {
1081 u32 entry = ROM16(nv_connector->dcb[0]);
1082 if (olddcb_conntab(dev)[3] >= 4)
1083 entry |= (u32)ROM16(nv_connector->dcb[2]) << 16;
1084
1085 nv_connector->type = nv_connector->dcb[0];
1086 if (drm_conntype_from_dcb(nv_connector->type) ==
1087 DRM_MODE_CONNECTOR_Unknown) {
1088 NV_WARN(drm, "unknown connector type %02x\n",
1089 nv_connector->type);
1090 nv_connector->type = DCB_CONNECTOR_NONE;
1091 }
1092
1093 /* Gigabyte NX85T */
1094 if (nv_match_device(dev, 0x0421, 0x1458, 0x344c)) {
1095 if (nv_connector->type == DCB_CONNECTOR_HDMI_1)
1096 nv_connector->type = DCB_CONNECTOR_DVI_I;
1097 }
1098
1099 /* Gigabyte GV-NX86T512H */
1100 if (nv_match_device(dev, 0x0402, 0x1458, 0x3455)) {
1101 if (nv_connector->type == DCB_CONNECTOR_HDMI_1)
1102 nv_connector->type = DCB_CONNECTOR_DVI_I;
1103 }
1104 } else {
1105 nv_connector->type = DCB_CONNECTOR_NONE;
1106 }
1107
1108 /* no vbios data, or an unknown dcb connector type - attempt to
1109 * figure out something suitable ourselves
1110 */
1111 if (nv_connector->type == DCB_CONNECTOR_NONE) {
1112 struct nouveau_drm *drm = nouveau_drm(dev);
1113 struct dcb_table *dcbt = &drm->vbios.dcb;
1114 u32 encoders = 0;
1115 int i;
1116
1117 for (i = 0; i < dcbt->entries; i++) {
1118 if (dcbt->entry[i].connector == nv_connector->index)
1119 encoders |= (1 << dcbt->entry[i].type);
1120 }
1121
1122 if (encoders & (1 << DCB_OUTPUT_DP)) {
1123 if (encoders & (1 << DCB_OUTPUT_TMDS))
1124 nv_connector->type = DCB_CONNECTOR_DP;
1125 else
1126 nv_connector->type = DCB_CONNECTOR_eDP;
1127 } else
1128 if (encoders & (1 << DCB_OUTPUT_TMDS)) {
1129 if (encoders & (1 << DCB_OUTPUT_ANALOG))
1130 nv_connector->type = DCB_CONNECTOR_DVI_I;
1131 else
1132 nv_connector->type = DCB_CONNECTOR_DVI_D;
1133 } else
1134 if (encoders & (1 << DCB_OUTPUT_ANALOG)) {
1135 nv_connector->type = DCB_CONNECTOR_VGA;
1136 } else
1137 if (encoders & (1 << DCB_OUTPUT_LVDS)) {
1138 nv_connector->type = DCB_CONNECTOR_LVDS;
1139 } else
1140 if (encoders & (1 << DCB_OUTPUT_TV)) {
1141 nv_connector->type = DCB_CONNECTOR_TV_0;
1142 }
1143 }
1144
1145 switch ((type = drm_conntype_from_dcb(nv_connector->type))) {
1146 case DRM_MODE_CONNECTOR_LVDS:
1147 ret = nouveau_bios_parse_lvds_table(dev, 0, &dummy, &dummy);
1148 if (ret) {
1149 NV_ERROR(drm, "Error parsing LVDS table, disabling\n");
1150 kfree(nv_connector);
1151 return ERR_PTR(ret);
1152 }
1153
1154 funcs = &nouveau_connector_funcs_lvds;
1155 break;
1156 case DRM_MODE_CONNECTOR_DisplayPort:
1157 case DRM_MODE_CONNECTOR_eDP:
1158 nv_connector->aux.dev = dev->dev;
1159 nv_connector->aux.transfer = nouveau_connector_aux_xfer;
1160 ret = drm_dp_aux_register(&nv_connector->aux);
1161 if (ret) {
1162 NV_ERROR(drm, "failed to register aux channel\n");
1163 kfree(nv_connector);
1164 return ERR_PTR(ret);
1165 }
1166
1167 funcs = &nouveau_connector_funcs_dp;
1168 break;
1169 default:
1170 funcs = &nouveau_connector_funcs;
1171 break;
1172 }
1173
1174 /* defaults, will get overridden in detect() */
1175 connector->interlace_allowed = false;
1176 connector->doublescan_allowed = false;
1177
1178 drm_connector_init(dev, connector, funcs, type);
1179 drm_connector_helper_add(connector, &nouveau_connector_helper_funcs);
1180
1181 /* Init DVI-I specific properties */
1182 if (nv_connector->type == DCB_CONNECTOR_DVI_I)
1183 drm_object_attach_property(&connector->base, dev->mode_config.dvi_i_subconnector_property, 0);
1184
1185 /* Add overscan compensation options to digital outputs */
1186 if (disp->underscan_property &&
1187 (type == DRM_MODE_CONNECTOR_DVID ||
1188 type == DRM_MODE_CONNECTOR_DVII ||
1189 type == DRM_MODE_CONNECTOR_HDMIA ||
1190 type == DRM_MODE_CONNECTOR_DisplayPort)) {
1191 drm_object_attach_property(&connector->base,
1192 disp->underscan_property,
1193 UNDERSCAN_OFF);
1194 drm_object_attach_property(&connector->base,
1195 disp->underscan_hborder_property,
1196 0);
1197 drm_object_attach_property(&connector->base,
1198 disp->underscan_vborder_property,
1199 0);
1200 }
1201
1202 /* Add hue and saturation options */
1203 if (disp->vibrant_hue_property)
1204 drm_object_attach_property(&connector->base,
1205 disp->vibrant_hue_property,
1206 90);
1207 if (disp->color_vibrance_property)
1208 drm_object_attach_property(&connector->base,
1209 disp->color_vibrance_property,
1210 150);
1211
1212 /* default scaling mode */
1213 switch (nv_connector->type) {
1214 case DCB_CONNECTOR_LVDS:
1215 case DCB_CONNECTOR_LVDS_SPWG:
1216 case DCB_CONNECTOR_eDP:
1217 /* see note in nouveau_connector_set_property() */
1218 if (disp->disp.oclass < NV50_DISP) {
1219 nv_connector->scaling_mode = DRM_MODE_SCALE_FULLSCREEN;
1220 break;
1221 }
1222 nv_connector->scaling_mode = DRM_MODE_SCALE_NONE;
1223 break;
1224 default:
1225 nv_connector->scaling_mode = DRM_MODE_SCALE_NONE;
1226 break;
1227 }
1228
1229 /* scaling mode property */
1230 switch (nv_connector->type) {
1231 case DCB_CONNECTOR_TV_0:
1232 case DCB_CONNECTOR_TV_1:
1233 case DCB_CONNECTOR_TV_3:
1234 break;
1235 case DCB_CONNECTOR_VGA:
1236 if (disp->disp.oclass < NV50_DISP)
1237 break; /* can only scale on DFPs */
1238 /* fall-through */
1239 default:
1240 drm_object_attach_property(&connector->base, dev->mode_config.
1241 scaling_mode_property,
1242 nv_connector->scaling_mode);
1243 break;
1244 }
1245
1246 /* dithering properties */
1247 switch (nv_connector->type) {
1248 case DCB_CONNECTOR_TV_0:
1249 case DCB_CONNECTOR_TV_1:
1250 case DCB_CONNECTOR_TV_3:
1251 case DCB_CONNECTOR_VGA:
1252 break;
1253 default:
1254 if (disp->dithering_mode) {
1255 drm_object_attach_property(&connector->base,
1256 disp->dithering_mode,
1257 nv_connector->
1258 dithering_mode);
1259 nv_connector->dithering_mode = DITHERING_MODE_AUTO;
1260 }
1261 if (disp->dithering_depth) {
1262 drm_object_attach_property(&connector->base,
1263 disp->dithering_depth,
1264 nv_connector->
1265 dithering_depth);
1266 nv_connector->dithering_depth = DITHERING_DEPTH_AUTO;
1267 }
1268 break;
1269 }
1270
1271 ret = nvif_notify_init(&disp->disp, nouveau_connector_hotplug, true,
1272 NV04_DISP_NTFY_CONN,
1273 &(struct nvif_notify_conn_req_v0) {
1274 .mask = NVIF_NOTIFY_CONN_V0_ANY,
1275 .conn = index,
1276 },
1277 sizeof(struct nvif_notify_conn_req_v0),
1278 sizeof(struct nvif_notify_conn_rep_v0),
1279 &nv_connector->hpd);
1280 if (ret)
1281 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
1282 else
1283 connector->polled = DRM_CONNECTOR_POLL_HPD;
1284
1285 drm_connector_register(connector);
1286 return connector;
1287 }
This page took 0.059463 seconds and 6 git commands to generate.