drm/radeon/kms/atom: AdjustPixelClock fixes for DP bridges
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / gpu / drm / radeon / radeon_connectors.c
blobcbfca3a24fdf9caac828d4cca8ce8445963af4c4
1 /*
2 * Copyright 2007-8 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
23 * Authors: Dave Airlie
24 * Alex Deucher
26 #include "drmP.h"
27 #include "drm_edid.h"
28 #include "drm_crtc_helper.h"
29 #include "drm_fb_helper.h"
30 #include "radeon_drm.h"
31 #include "radeon.h"
32 #include "atom.h"
34 extern void
35 radeon_combios_connected_scratch_regs(struct drm_connector *connector,
36 struct drm_encoder *encoder,
37 bool connected);
38 extern void
39 radeon_atombios_connected_scratch_regs(struct drm_connector *connector,
40 struct drm_encoder *encoder,
41 bool connected);
43 extern void
44 radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
45 struct drm_connector *drm_connector);
47 bool radeon_connector_encoder_is_dp_bridge(struct drm_connector *connector);
49 void radeon_connector_hotplug(struct drm_connector *connector)
51 struct drm_device *dev = connector->dev;
52 struct radeon_device *rdev = dev->dev_private;
53 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
55 radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd);
57 /* powering up/down the eDP panel generates hpd events which
58 * can interfere with modesetting.
60 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP)
61 return;
63 /* pre-r600 did not always have the hpd pins mapped accurately to connectors */
64 if (rdev->family >= CHIP_R600) {
65 if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
66 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
67 else
68 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
72 static void radeon_property_change_mode(struct drm_encoder *encoder)
74 struct drm_crtc *crtc = encoder->crtc;
76 if (crtc && crtc->enabled) {
77 drm_crtc_helper_set_mode(crtc, &crtc->mode,
78 crtc->x, crtc->y, crtc->fb);
81 static void
82 radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_connector_status status)
84 struct drm_device *dev = connector->dev;
85 struct radeon_device *rdev = dev->dev_private;
86 struct drm_encoder *best_encoder = NULL;
87 struct drm_encoder *encoder = NULL;
88 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
89 struct drm_mode_object *obj;
90 bool connected;
91 int i;
93 best_encoder = connector_funcs->best_encoder(connector);
95 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
96 if (connector->encoder_ids[i] == 0)
97 break;
99 obj = drm_mode_object_find(connector->dev,
100 connector->encoder_ids[i],
101 DRM_MODE_OBJECT_ENCODER);
102 if (!obj)
103 continue;
105 encoder = obj_to_encoder(obj);
107 if ((encoder == best_encoder) && (status == connector_status_connected))
108 connected = true;
109 else
110 connected = false;
112 if (rdev->is_atom_bios)
113 radeon_atombios_connected_scratch_regs(connector, encoder, connected);
114 else
115 radeon_combios_connected_scratch_regs(connector, encoder, connected);
120 struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type)
122 struct drm_mode_object *obj;
123 struct drm_encoder *encoder;
124 int i;
126 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
127 if (connector->encoder_ids[i] == 0)
128 break;
130 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER);
131 if (!obj)
132 continue;
134 encoder = obj_to_encoder(obj);
135 if (encoder->encoder_type == encoder_type)
136 return encoder;
138 return NULL;
141 struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector)
143 int enc_id = connector->encoder_ids[0];
144 struct drm_mode_object *obj;
145 struct drm_encoder *encoder;
147 /* pick the encoder ids */
148 if (enc_id) {
149 obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER);
150 if (!obj)
151 return NULL;
152 encoder = obj_to_encoder(obj);
153 return encoder;
155 return NULL;
159 * radeon_connector_analog_encoder_conflict_solve
160 * - search for other connectors sharing this encoder
161 * if priority is true, then set them disconnected if this is connected
162 * if priority is false, set us disconnected if they are connected
164 static enum drm_connector_status
165 radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector,
166 struct drm_encoder *encoder,
167 enum drm_connector_status current_status,
168 bool priority)
170 struct drm_device *dev = connector->dev;
171 struct drm_connector *conflict;
172 struct radeon_connector *radeon_conflict;
173 int i;
175 list_for_each_entry(conflict, &dev->mode_config.connector_list, head) {
176 if (conflict == connector)
177 continue;
179 radeon_conflict = to_radeon_connector(conflict);
180 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
181 if (conflict->encoder_ids[i] == 0)
182 break;
184 /* if the IDs match */
185 if (conflict->encoder_ids[i] == encoder->base.id) {
186 if (conflict->status != connector_status_connected)
187 continue;
189 if (radeon_conflict->use_digital)
190 continue;
192 if (priority == true) {
193 DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict));
194 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(connector));
195 conflict->status = connector_status_disconnected;
196 radeon_connector_update_scratch_regs(conflict, connector_status_disconnected);
197 } else {
198 DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector));
199 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(conflict));
200 current_status = connector_status_disconnected;
202 break;
206 return current_status;
210 static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encoder)
212 struct drm_device *dev = encoder->dev;
213 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
214 struct drm_display_mode *mode = NULL;
215 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
217 if (native_mode->hdisplay != 0 &&
218 native_mode->vdisplay != 0 &&
219 native_mode->clock != 0) {
220 mode = drm_mode_duplicate(dev, native_mode);
221 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
222 drm_mode_set_name(mode);
224 DRM_DEBUG_KMS("Adding native panel mode %s\n", mode->name);
225 } else if (native_mode->hdisplay != 0 &&
226 native_mode->vdisplay != 0) {
227 /* mac laptops without an edid */
228 /* Note that this is not necessarily the exact panel mode,
229 * but an approximation based on the cvt formula. For these
230 * systems we should ideally read the mode info out of the
231 * registers or add a mode table, but this works and is much
232 * simpler.
234 mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false);
235 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
236 DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode->name);
238 return mode;
241 static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_connector *connector)
243 struct drm_device *dev = encoder->dev;
244 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
245 struct drm_display_mode *mode = NULL;
246 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
247 int i;
248 struct mode_size {
249 int w;
250 int h;
251 } common_modes[17] = {
252 { 640, 480},
253 { 720, 480},
254 { 800, 600},
255 { 848, 480},
256 {1024, 768},
257 {1152, 768},
258 {1280, 720},
259 {1280, 800},
260 {1280, 854},
261 {1280, 960},
262 {1280, 1024},
263 {1440, 900},
264 {1400, 1050},
265 {1680, 1050},
266 {1600, 1200},
267 {1920, 1080},
268 {1920, 1200}
271 for (i = 0; i < 17; i++) {
272 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) {
273 if (common_modes[i].w > 1024 ||
274 common_modes[i].h > 768)
275 continue;
277 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
278 if (common_modes[i].w > native_mode->hdisplay ||
279 common_modes[i].h > native_mode->vdisplay ||
280 (common_modes[i].w == native_mode->hdisplay &&
281 common_modes[i].h == native_mode->vdisplay))
282 continue;
284 if (common_modes[i].w < 320 || common_modes[i].h < 200)
285 continue;
287 mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false);
288 drm_mode_probed_add(connector, mode);
292 int radeon_connector_set_property(struct drm_connector *connector, struct drm_property *property,
293 uint64_t val)
295 struct drm_device *dev = connector->dev;
296 struct radeon_device *rdev = dev->dev_private;
297 struct drm_encoder *encoder;
298 struct radeon_encoder *radeon_encoder;
300 if (property == rdev->mode_info.coherent_mode_property) {
301 struct radeon_encoder_atom_dig *dig;
302 bool new_coherent_mode;
304 /* need to find digital encoder on connector */
305 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
306 if (!encoder)
307 return 0;
309 radeon_encoder = to_radeon_encoder(encoder);
311 if (!radeon_encoder->enc_priv)
312 return 0;
314 dig = radeon_encoder->enc_priv;
315 new_coherent_mode = val ? true : false;
316 if (dig->coherent_mode != new_coherent_mode) {
317 dig->coherent_mode = new_coherent_mode;
318 radeon_property_change_mode(&radeon_encoder->base);
322 if (property == rdev->mode_info.underscan_property) {
323 /* need to find digital encoder on connector */
324 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
325 if (!encoder)
326 return 0;
328 radeon_encoder = to_radeon_encoder(encoder);
330 if (radeon_encoder->underscan_type != val) {
331 radeon_encoder->underscan_type = val;
332 radeon_property_change_mode(&radeon_encoder->base);
336 if (property == rdev->mode_info.underscan_hborder_property) {
337 /* need to find digital encoder on connector */
338 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
339 if (!encoder)
340 return 0;
342 radeon_encoder = to_radeon_encoder(encoder);
344 if (radeon_encoder->underscan_hborder != val) {
345 radeon_encoder->underscan_hborder = val;
346 radeon_property_change_mode(&radeon_encoder->base);
350 if (property == rdev->mode_info.underscan_vborder_property) {
351 /* need to find digital encoder on connector */
352 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
353 if (!encoder)
354 return 0;
356 radeon_encoder = to_radeon_encoder(encoder);
358 if (radeon_encoder->underscan_vborder != val) {
359 radeon_encoder->underscan_vborder = val;
360 radeon_property_change_mode(&radeon_encoder->base);
364 if (property == rdev->mode_info.tv_std_property) {
365 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC);
366 if (!encoder) {
367 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_DAC);
370 if (!encoder)
371 return 0;
373 radeon_encoder = to_radeon_encoder(encoder);
374 if (!radeon_encoder->enc_priv)
375 return 0;
376 if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom) {
377 struct radeon_encoder_atom_dac *dac_int;
378 dac_int = radeon_encoder->enc_priv;
379 dac_int->tv_std = val;
380 } else {
381 struct radeon_encoder_tv_dac *dac_int;
382 dac_int = radeon_encoder->enc_priv;
383 dac_int->tv_std = val;
385 radeon_property_change_mode(&radeon_encoder->base);
388 if (property == rdev->mode_info.load_detect_property) {
389 struct radeon_connector *radeon_connector =
390 to_radeon_connector(connector);
392 if (val == 0)
393 radeon_connector->dac_load_detect = false;
394 else
395 radeon_connector->dac_load_detect = true;
398 if (property == rdev->mode_info.tmds_pll_property) {
399 struct radeon_encoder_int_tmds *tmds = NULL;
400 bool ret = false;
401 /* need to find digital encoder on connector */
402 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
403 if (!encoder)
404 return 0;
406 radeon_encoder = to_radeon_encoder(encoder);
408 tmds = radeon_encoder->enc_priv;
409 if (!tmds)
410 return 0;
412 if (val == 0) {
413 if (rdev->is_atom_bios)
414 ret = radeon_atombios_get_tmds_info(radeon_encoder, tmds);
415 else
416 ret = radeon_legacy_get_tmds_info_from_combios(radeon_encoder, tmds);
418 if (val == 1 || ret == false) {
419 radeon_legacy_get_tmds_info_from_table(radeon_encoder, tmds);
421 radeon_property_change_mode(&radeon_encoder->base);
424 return 0;
427 static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
428 struct drm_connector *connector)
430 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
431 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
433 /* Try to get native mode details from EDID if necessary */
434 if (!native_mode->clock) {
435 struct drm_display_mode *t, *mode;
437 list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
438 if (mode->hdisplay == native_mode->hdisplay &&
439 mode->vdisplay == native_mode->vdisplay) {
440 *native_mode = *mode;
441 drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
442 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
443 break;
447 if (!native_mode->clock) {
448 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n");
449 radeon_encoder->rmx_type = RMX_OFF;
453 static int radeon_lvds_get_modes(struct drm_connector *connector)
455 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
456 struct drm_encoder *encoder;
457 int ret = 0;
458 struct drm_display_mode *mode;
460 if (radeon_connector->ddc_bus) {
461 ret = radeon_ddc_get_modes(radeon_connector);
462 if (ret > 0) {
463 encoder = radeon_best_single_encoder(connector);
464 if (encoder) {
465 radeon_fixup_lvds_native_mode(encoder, connector);
466 /* add scaled modes */
467 radeon_add_common_modes(encoder, connector);
469 return ret;
473 encoder = radeon_best_single_encoder(connector);
474 if (!encoder)
475 return 0;
477 /* we have no EDID modes */
478 mode = radeon_fp_native_mode(encoder);
479 if (mode) {
480 ret = 1;
481 drm_mode_probed_add(connector, mode);
482 /* add the width/height from vbios tables if available */
483 connector->display_info.width_mm = mode->width_mm;
484 connector->display_info.height_mm = mode->height_mm;
485 /* add scaled modes */
486 radeon_add_common_modes(encoder, connector);
489 return ret;
492 static int radeon_lvds_mode_valid(struct drm_connector *connector,
493 struct drm_display_mode *mode)
495 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
497 if ((mode->hdisplay < 320) || (mode->vdisplay < 240))
498 return MODE_PANEL;
500 if (encoder) {
501 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
502 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
504 /* AVIVO hardware supports downscaling modes larger than the panel
505 * to the panel size, but I'm not sure this is desirable.
507 if ((mode->hdisplay > native_mode->hdisplay) ||
508 (mode->vdisplay > native_mode->vdisplay))
509 return MODE_PANEL;
511 /* if scaling is disabled, block non-native modes */
512 if (radeon_encoder->rmx_type == RMX_OFF) {
513 if ((mode->hdisplay != native_mode->hdisplay) ||
514 (mode->vdisplay != native_mode->vdisplay))
515 return MODE_PANEL;
519 return MODE_OK;
522 static enum drm_connector_status
523 radeon_lvds_detect(struct drm_connector *connector, bool force)
525 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
526 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
527 enum drm_connector_status ret = connector_status_disconnected;
529 if (encoder) {
530 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
531 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
533 /* check if panel is valid */
534 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240)
535 ret = connector_status_connected;
539 /* check for edid as well */
540 if (radeon_connector->edid)
541 ret = connector_status_connected;
542 else {
543 if (radeon_connector->ddc_bus) {
544 radeon_connector->edid = drm_get_edid(&radeon_connector->base,
545 &radeon_connector->ddc_bus->adapter);
546 if (radeon_connector->edid)
547 ret = connector_status_connected;
550 /* check acpi lid status ??? */
552 radeon_connector_update_scratch_regs(connector, ret);
553 return ret;
556 static void radeon_connector_destroy(struct drm_connector *connector)
558 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
560 if (radeon_connector->edid)
561 kfree(radeon_connector->edid);
562 kfree(radeon_connector->con_priv);
563 drm_sysfs_connector_remove(connector);
564 drm_connector_cleanup(connector);
565 kfree(connector);
568 static int radeon_lvds_set_property(struct drm_connector *connector,
569 struct drm_property *property,
570 uint64_t value)
572 struct drm_device *dev = connector->dev;
573 struct radeon_encoder *radeon_encoder;
574 enum radeon_rmx_type rmx_type;
576 DRM_DEBUG_KMS("\n");
577 if (property != dev->mode_config.scaling_mode_property)
578 return 0;
580 if (connector->encoder)
581 radeon_encoder = to_radeon_encoder(connector->encoder);
582 else {
583 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
584 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector));
587 switch (value) {
588 case DRM_MODE_SCALE_NONE: rmx_type = RMX_OFF; break;
589 case DRM_MODE_SCALE_CENTER: rmx_type = RMX_CENTER; break;
590 case DRM_MODE_SCALE_ASPECT: rmx_type = RMX_ASPECT; break;
591 default:
592 case DRM_MODE_SCALE_FULLSCREEN: rmx_type = RMX_FULL; break;
594 if (radeon_encoder->rmx_type == rmx_type)
595 return 0;
597 radeon_encoder->rmx_type = rmx_type;
599 radeon_property_change_mode(&radeon_encoder->base);
600 return 0;
604 struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs = {
605 .get_modes = radeon_lvds_get_modes,
606 .mode_valid = radeon_lvds_mode_valid,
607 .best_encoder = radeon_best_single_encoder,
610 struct drm_connector_funcs radeon_lvds_connector_funcs = {
611 .dpms = drm_helper_connector_dpms,
612 .detect = radeon_lvds_detect,
613 .fill_modes = drm_helper_probe_single_connector_modes,
614 .destroy = radeon_connector_destroy,
615 .set_property = radeon_lvds_set_property,
618 static int radeon_vga_get_modes(struct drm_connector *connector)
620 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
621 int ret;
623 ret = radeon_ddc_get_modes(radeon_connector);
625 return ret;
628 static int radeon_vga_mode_valid(struct drm_connector *connector,
629 struct drm_display_mode *mode)
631 struct drm_device *dev = connector->dev;
632 struct radeon_device *rdev = dev->dev_private;
634 /* XXX check mode bandwidth */
636 if ((mode->clock / 10) > rdev->clock.max_pixel_clock)
637 return MODE_CLOCK_HIGH;
639 return MODE_OK;
642 static enum drm_connector_status
643 radeon_vga_detect(struct drm_connector *connector, bool force)
645 struct drm_device *dev = connector->dev;
646 struct radeon_device *rdev = dev->dev_private;
647 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
648 struct drm_encoder *encoder;
649 struct drm_encoder_helper_funcs *encoder_funcs;
650 bool dret = false;
651 enum drm_connector_status ret = connector_status_disconnected;
653 encoder = radeon_best_single_encoder(connector);
654 if (!encoder)
655 ret = connector_status_disconnected;
657 if (radeon_connector->ddc_bus)
658 dret = radeon_ddc_probe(radeon_connector);
659 if (dret) {
660 if (radeon_connector->edid) {
661 kfree(radeon_connector->edid);
662 radeon_connector->edid = NULL;
664 radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter);
666 if (!radeon_connector->edid) {
667 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
668 drm_get_connector_name(connector));
669 ret = connector_status_connected;
670 } else {
671 radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL);
673 /* some oems have boards with separate digital and analog connectors
674 * with a shared ddc line (often vga + hdmi)
676 if (radeon_connector->use_digital && radeon_connector->shared_ddc) {
677 kfree(radeon_connector->edid);
678 radeon_connector->edid = NULL;
679 ret = connector_status_disconnected;
680 } else
681 ret = connector_status_connected;
683 } else {
685 /* if we aren't forcing don't do destructive polling */
686 if (!force)
687 return connector->status;
689 if (radeon_connector->dac_load_detect && encoder) {
690 encoder_funcs = encoder->helper_private;
691 ret = encoder_funcs->detect(encoder, connector);
695 if (ret == connector_status_connected)
696 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true);
698 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
699 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
700 * by other means, assume the CRT is connected and use that EDID.
702 if ((!rdev->is_atom_bios) &&
703 (ret == connector_status_disconnected) &&
704 rdev->mode_info.bios_hardcoded_edid_size) {
705 ret = connector_status_connected;
708 radeon_connector_update_scratch_regs(connector, ret);
709 return ret;
712 struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs = {
713 .get_modes = radeon_vga_get_modes,
714 .mode_valid = radeon_vga_mode_valid,
715 .best_encoder = radeon_best_single_encoder,
718 struct drm_connector_funcs radeon_vga_connector_funcs = {
719 .dpms = drm_helper_connector_dpms,
720 .detect = radeon_vga_detect,
721 .fill_modes = drm_helper_probe_single_connector_modes,
722 .destroy = radeon_connector_destroy,
723 .set_property = radeon_connector_set_property,
726 static int radeon_tv_get_modes(struct drm_connector *connector)
728 struct drm_device *dev = connector->dev;
729 struct radeon_device *rdev = dev->dev_private;
730 struct drm_display_mode *tv_mode;
731 struct drm_encoder *encoder;
733 encoder = radeon_best_single_encoder(connector);
734 if (!encoder)
735 return 0;
737 /* avivo chips can scale any mode */
738 if (rdev->family >= CHIP_RS600)
739 /* add scaled modes */
740 radeon_add_common_modes(encoder, connector);
741 else {
742 /* only 800x600 is supported right now on pre-avivo chips */
743 tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false);
744 tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
745 drm_mode_probed_add(connector, tv_mode);
747 return 1;
750 static int radeon_tv_mode_valid(struct drm_connector *connector,
751 struct drm_display_mode *mode)
753 if ((mode->hdisplay > 1024) || (mode->vdisplay > 768))
754 return MODE_CLOCK_RANGE;
755 return MODE_OK;
758 static enum drm_connector_status
759 radeon_tv_detect(struct drm_connector *connector, bool force)
761 struct drm_encoder *encoder;
762 struct drm_encoder_helper_funcs *encoder_funcs;
763 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
764 enum drm_connector_status ret = connector_status_disconnected;
766 if (!radeon_connector->dac_load_detect)
767 return ret;
769 encoder = radeon_best_single_encoder(connector);
770 if (!encoder)
771 ret = connector_status_disconnected;
772 else {
773 encoder_funcs = encoder->helper_private;
774 ret = encoder_funcs->detect(encoder, connector);
776 if (ret == connector_status_connected)
777 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false);
778 radeon_connector_update_scratch_regs(connector, ret);
779 return ret;
782 struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs = {
783 .get_modes = radeon_tv_get_modes,
784 .mode_valid = radeon_tv_mode_valid,
785 .best_encoder = radeon_best_single_encoder,
788 struct drm_connector_funcs radeon_tv_connector_funcs = {
789 .dpms = drm_helper_connector_dpms,
790 .detect = radeon_tv_detect,
791 .fill_modes = drm_helper_probe_single_connector_modes,
792 .destroy = radeon_connector_destroy,
793 .set_property = radeon_connector_set_property,
796 static int radeon_dvi_get_modes(struct drm_connector *connector)
798 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
799 int ret;
801 ret = radeon_ddc_get_modes(radeon_connector);
802 return ret;
806 * DVI is complicated
807 * Do a DDC probe, if DDC probe passes, get the full EDID so
808 * we can do analog/digital monitor detection at this point.
809 * If the monitor is an analog monitor or we got no DDC,
810 * we need to find the DAC encoder object for this connector.
811 * If we got no DDC, we do load detection on the DAC encoder object.
812 * If we got analog DDC or load detection passes on the DAC encoder
813 * we have to check if this analog encoder is shared with anyone else (TV)
814 * if its shared we have to set the other connector to disconnected.
816 static enum drm_connector_status
817 radeon_dvi_detect(struct drm_connector *connector, bool force)
819 struct drm_device *dev = connector->dev;
820 struct radeon_device *rdev = dev->dev_private;
821 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
822 struct drm_encoder *encoder = NULL;
823 struct drm_encoder_helper_funcs *encoder_funcs;
824 struct drm_mode_object *obj;
825 int i;
826 enum drm_connector_status ret = connector_status_disconnected;
827 bool dret = false;
829 if (radeon_connector->ddc_bus)
830 dret = radeon_ddc_probe(radeon_connector);
831 if (dret) {
832 if (radeon_connector->edid) {
833 kfree(radeon_connector->edid);
834 radeon_connector->edid = NULL;
836 radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter);
838 if (!radeon_connector->edid) {
839 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
840 drm_get_connector_name(connector));
841 /* rs690 seems to have a problem with connectors not existing and always
842 * return a block of 0's. If we see this just stop polling on this output */
843 if ((rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) && radeon_connector->base.null_edid_counter) {
844 ret = connector_status_disconnected;
845 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", drm_get_connector_name(connector));
846 radeon_connector->ddc_bus = NULL;
848 } else {
849 radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL);
851 /* some oems have boards with separate digital and analog connectors
852 * with a shared ddc line (often vga + hdmi)
854 if ((!radeon_connector->use_digital) && radeon_connector->shared_ddc) {
855 kfree(radeon_connector->edid);
856 radeon_connector->edid = NULL;
857 ret = connector_status_disconnected;
858 } else
859 ret = connector_status_connected;
861 /* This gets complicated. We have boards with VGA + HDMI with a
862 * shared DDC line and we have boards with DVI-D + HDMI with a shared
863 * DDC line. The latter is more complex because with DVI<->HDMI adapters
864 * you don't really know what's connected to which port as both are digital.
866 if (radeon_connector->shared_ddc && (ret == connector_status_connected)) {
867 struct drm_connector *list_connector;
868 struct radeon_connector *list_radeon_connector;
869 list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) {
870 if (connector == list_connector)
871 continue;
872 list_radeon_connector = to_radeon_connector(list_connector);
873 if (list_radeon_connector->shared_ddc &&
874 (list_radeon_connector->ddc_bus->rec.i2c_id ==
875 radeon_connector->ddc_bus->rec.i2c_id)) {
876 /* cases where both connectors are digital */
877 if (list_connector->connector_type != DRM_MODE_CONNECTOR_VGA) {
878 /* hpd is our only option in this case */
879 if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
880 kfree(radeon_connector->edid);
881 radeon_connector->edid = NULL;
882 ret = connector_status_disconnected;
891 if ((ret == connector_status_connected) && (radeon_connector->use_digital == true))
892 goto out;
894 if (!force) {
895 ret = connector->status;
896 goto out;
899 /* find analog encoder */
900 if (radeon_connector->dac_load_detect) {
901 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
902 if (connector->encoder_ids[i] == 0)
903 break;
905 obj = drm_mode_object_find(connector->dev,
906 connector->encoder_ids[i],
907 DRM_MODE_OBJECT_ENCODER);
908 if (!obj)
909 continue;
911 encoder = obj_to_encoder(obj);
913 encoder_funcs = encoder->helper_private;
914 if (encoder_funcs->detect) {
915 if (ret != connector_status_connected) {
916 ret = encoder_funcs->detect(encoder, connector);
917 if (ret == connector_status_connected) {
918 radeon_connector->use_digital = false;
921 break;
926 if ((ret == connector_status_connected) && (radeon_connector->use_digital == false) &&
927 encoder) {
928 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true);
931 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
932 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
933 * by other means, assume the DFP is connected and use that EDID. In most
934 * cases the DVI port is actually a virtual KVM port connected to the service
935 * processor.
937 if ((!rdev->is_atom_bios) &&
938 (ret == connector_status_disconnected) &&
939 rdev->mode_info.bios_hardcoded_edid_size) {
940 radeon_connector->use_digital = true;
941 ret = connector_status_connected;
944 out:
945 /* updated in get modes as well since we need to know if it's analog or digital */
946 radeon_connector_update_scratch_regs(connector, ret);
947 return ret;
950 /* okay need to be smart in here about which encoder to pick */
951 struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector)
953 int enc_id = connector->encoder_ids[0];
954 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
955 struct drm_mode_object *obj;
956 struct drm_encoder *encoder;
957 int i;
958 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
959 if (connector->encoder_ids[i] == 0)
960 break;
962 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER);
963 if (!obj)
964 continue;
966 encoder = obj_to_encoder(obj);
968 if (radeon_connector->use_digital == true) {
969 if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS)
970 return encoder;
971 } else {
972 if (encoder->encoder_type == DRM_MODE_ENCODER_DAC ||
973 encoder->encoder_type == DRM_MODE_ENCODER_TVDAC)
974 return encoder;
978 /* see if we have a default encoder TODO */
980 /* then check use digitial */
981 /* pick the first one */
982 if (enc_id) {
983 obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER);
984 if (!obj)
985 return NULL;
986 encoder = obj_to_encoder(obj);
987 return encoder;
989 return NULL;
992 static void radeon_dvi_force(struct drm_connector *connector)
994 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
995 if (connector->force == DRM_FORCE_ON)
996 radeon_connector->use_digital = false;
997 if (connector->force == DRM_FORCE_ON_DIGITAL)
998 radeon_connector->use_digital = true;
1001 static int radeon_dvi_mode_valid(struct drm_connector *connector,
1002 struct drm_display_mode *mode)
1004 struct drm_device *dev = connector->dev;
1005 struct radeon_device *rdev = dev->dev_private;
1006 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1008 /* XXX check mode bandwidth */
1010 /* clocks over 135 MHz have heat issues with DVI on RV100 */
1011 if (radeon_connector->use_digital &&
1012 (rdev->family == CHIP_RV100) &&
1013 (mode->clock > 135000))
1014 return MODE_CLOCK_HIGH;
1016 if (radeon_connector->use_digital && (mode->clock > 165000)) {
1017 if ((radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I) ||
1018 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) ||
1019 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B))
1020 return MODE_OK;
1021 else if (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_A) {
1022 if (ASIC_IS_DCE3(rdev)) {
1023 /* HDMI 1.3+ supports max clock of 340 Mhz */
1024 if (mode->clock > 340000)
1025 return MODE_CLOCK_HIGH;
1026 else
1027 return MODE_OK;
1028 } else
1029 return MODE_CLOCK_HIGH;
1030 } else
1031 return MODE_CLOCK_HIGH;
1034 /* check against the max pixel clock */
1035 if ((mode->clock / 10) > rdev->clock.max_pixel_clock)
1036 return MODE_CLOCK_HIGH;
1038 return MODE_OK;
1041 struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = {
1042 .get_modes = radeon_dvi_get_modes,
1043 .mode_valid = radeon_dvi_mode_valid,
1044 .best_encoder = radeon_dvi_encoder,
1047 struct drm_connector_funcs radeon_dvi_connector_funcs = {
1048 .dpms = drm_helper_connector_dpms,
1049 .detect = radeon_dvi_detect,
1050 .fill_modes = drm_helper_probe_single_connector_modes,
1051 .set_property = radeon_connector_set_property,
1052 .destroy = radeon_connector_destroy,
1053 .force = radeon_dvi_force,
1056 static void radeon_dp_connector_destroy(struct drm_connector *connector)
1058 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1059 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
1061 if (radeon_connector->edid)
1062 kfree(radeon_connector->edid);
1063 if (radeon_dig_connector->dp_i2c_bus)
1064 radeon_i2c_destroy(radeon_dig_connector->dp_i2c_bus);
1065 kfree(radeon_connector->con_priv);
1066 drm_sysfs_connector_remove(connector);
1067 drm_connector_cleanup(connector);
1068 kfree(connector);
1071 static int radeon_dp_get_modes(struct drm_connector *connector)
1073 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1074 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
1075 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1076 int ret;
1078 if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) ||
1079 (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) {
1080 struct drm_display_mode *mode;
1082 if (!radeon_dig_connector->edp_on)
1083 atombios_set_edp_panel_power(connector,
1084 ATOM_TRANSMITTER_ACTION_POWER_ON);
1085 ret = radeon_ddc_get_modes(radeon_connector);
1086 if (!radeon_dig_connector->edp_on)
1087 atombios_set_edp_panel_power(connector,
1088 ATOM_TRANSMITTER_ACTION_POWER_OFF);
1090 if (ret > 0) {
1091 if (encoder) {
1092 radeon_fixup_lvds_native_mode(encoder, connector);
1093 /* add scaled modes */
1094 radeon_add_common_modes(encoder, connector);
1096 return ret;
1099 encoder = radeon_best_single_encoder(connector);
1100 if (!encoder)
1101 return 0;
1103 /* we have no EDID modes */
1104 mode = radeon_fp_native_mode(encoder);
1105 if (mode) {
1106 ret = 1;
1107 drm_mode_probed_add(connector, mode);
1108 /* add the width/height from vbios tables if available */
1109 connector->display_info.width_mm = mode->width_mm;
1110 connector->display_info.height_mm = mode->height_mm;
1111 /* add scaled modes */
1112 radeon_add_common_modes(encoder, connector);
1114 } else {
1115 /* need to setup ddc on the bridge */
1116 if (radeon_connector_encoder_is_dp_bridge(connector)) {
1117 if (encoder)
1118 radeon_atom_ext_encoder_setup_ddc(encoder);
1120 ret = radeon_ddc_get_modes(radeon_connector);
1123 return ret;
1126 bool radeon_connector_encoder_is_dp_bridge(struct drm_connector *connector)
1128 struct drm_mode_object *obj;
1129 struct drm_encoder *encoder;
1130 struct radeon_encoder *radeon_encoder;
1131 int i;
1132 bool found = false;
1134 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
1135 if (connector->encoder_ids[i] == 0)
1136 break;
1138 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER);
1139 if (!obj)
1140 continue;
1142 encoder = obj_to_encoder(obj);
1143 radeon_encoder = to_radeon_encoder(encoder);
1145 switch (radeon_encoder->encoder_id) {
1146 case ENCODER_OBJECT_ID_TRAVIS:
1147 case ENCODER_OBJECT_ID_NUTMEG:
1148 found = true;
1149 break;
1150 default:
1151 break;
1155 return found;
1158 bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector)
1160 struct drm_mode_object *obj;
1161 struct drm_encoder *encoder;
1162 struct radeon_encoder *radeon_encoder;
1163 int i;
1164 bool found = false;
1166 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
1167 if (connector->encoder_ids[i] == 0)
1168 break;
1170 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER);
1171 if (!obj)
1172 continue;
1174 encoder = obj_to_encoder(obj);
1175 radeon_encoder = to_radeon_encoder(encoder);
1176 if (radeon_encoder->caps & ATOM_ENCODER_CAP_RECORD_HBR2)
1177 found = true;
1180 return found;
1183 bool radeon_connector_is_dp12_capable(struct drm_connector *connector)
1185 struct drm_device *dev = connector->dev;
1186 struct radeon_device *rdev = dev->dev_private;
1188 if (ASIC_IS_DCE5(rdev) &&
1189 (rdev->clock.dp_extclk >= 53900) &&
1190 radeon_connector_encoder_is_hbr2(connector)) {
1191 return true;
1194 return false;
1197 static enum drm_connector_status
1198 radeon_dp_detect(struct drm_connector *connector, bool force)
1200 struct drm_device *dev = connector->dev;
1201 struct radeon_device *rdev = dev->dev_private;
1202 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1203 enum drm_connector_status ret = connector_status_disconnected;
1204 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
1205 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1207 if (radeon_connector->edid) {
1208 kfree(radeon_connector->edid);
1209 radeon_connector->edid = NULL;
1212 if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) ||
1213 (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) {
1214 if (encoder) {
1215 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1216 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
1218 /* check if panel is valid */
1219 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240)
1220 ret = connector_status_connected;
1222 /* eDP is always DP */
1223 radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT;
1224 if (!radeon_dig_connector->edp_on)
1225 atombios_set_edp_panel_power(connector,
1226 ATOM_TRANSMITTER_ACTION_POWER_ON);
1227 if (radeon_dp_getdpcd(radeon_connector))
1228 ret = connector_status_connected;
1229 if (!radeon_dig_connector->edp_on)
1230 atombios_set_edp_panel_power(connector,
1231 ATOM_TRANSMITTER_ACTION_POWER_OFF);
1232 } else {
1233 /* need to setup ddc on the bridge */
1234 if (radeon_connector_encoder_is_dp_bridge(connector)) {
1235 if (encoder)
1236 radeon_atom_ext_encoder_setup_ddc(encoder);
1238 radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector);
1239 if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
1240 ret = connector_status_connected;
1241 if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT)
1242 radeon_dp_getdpcd(radeon_connector);
1243 } else {
1244 if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) {
1245 if (radeon_dp_getdpcd(radeon_connector))
1246 ret = connector_status_connected;
1247 } else {
1248 if (radeon_ddc_probe(radeon_connector))
1249 ret = connector_status_connected;
1253 if ((ret == connector_status_disconnected) &&
1254 radeon_connector->dac_load_detect) {
1255 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1256 struct drm_encoder_helper_funcs *encoder_funcs;
1257 if (encoder) {
1258 encoder_funcs = encoder->helper_private;
1259 ret = encoder_funcs->detect(encoder, connector);
1264 radeon_connector_update_scratch_regs(connector, ret);
1265 return ret;
1268 static int radeon_dp_mode_valid(struct drm_connector *connector,
1269 struct drm_display_mode *mode)
1271 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1272 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
1274 /* XXX check mode bandwidth */
1276 if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) ||
1277 (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) {
1278 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1280 if ((mode->hdisplay < 320) || (mode->vdisplay < 240))
1281 return MODE_PANEL;
1283 if (encoder) {
1284 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1285 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
1287 /* AVIVO hardware supports downscaling modes larger than the panel
1288 * to the panel size, but I'm not sure this is desirable.
1290 if ((mode->hdisplay > native_mode->hdisplay) ||
1291 (mode->vdisplay > native_mode->vdisplay))
1292 return MODE_PANEL;
1294 /* if scaling is disabled, block non-native modes */
1295 if (radeon_encoder->rmx_type == RMX_OFF) {
1296 if ((mode->hdisplay != native_mode->hdisplay) ||
1297 (mode->vdisplay != native_mode->vdisplay))
1298 return MODE_PANEL;
1301 return MODE_OK;
1302 } else {
1303 if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
1304 (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP))
1305 return radeon_dp_mode_valid_helper(connector, mode);
1306 else
1307 return MODE_OK;
1311 struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = {
1312 .get_modes = radeon_dp_get_modes,
1313 .mode_valid = radeon_dp_mode_valid,
1314 .best_encoder = radeon_dvi_encoder,
1317 struct drm_connector_funcs radeon_dp_connector_funcs = {
1318 .dpms = drm_helper_connector_dpms,
1319 .detect = radeon_dp_detect,
1320 .fill_modes = drm_helper_probe_single_connector_modes,
1321 .set_property = radeon_connector_set_property,
1322 .destroy = radeon_dp_connector_destroy,
1323 .force = radeon_dvi_force,
1326 void
1327 radeon_add_atom_connector(struct drm_device *dev,
1328 uint32_t connector_id,
1329 uint32_t supported_device,
1330 int connector_type,
1331 struct radeon_i2c_bus_rec *i2c_bus,
1332 uint32_t igp_lane_info,
1333 uint16_t connector_object_id,
1334 struct radeon_hpd *hpd,
1335 struct radeon_router *router)
1337 struct radeon_device *rdev = dev->dev_private;
1338 struct drm_connector *connector;
1339 struct radeon_connector *radeon_connector;
1340 struct radeon_connector_atom_dig *radeon_dig_connector;
1341 struct drm_encoder *encoder;
1342 struct radeon_encoder *radeon_encoder;
1343 uint32_t subpixel_order = SubPixelNone;
1344 bool shared_ddc = false;
1345 bool is_dp_bridge = false;
1347 if (connector_type == DRM_MODE_CONNECTOR_Unknown)
1348 return;
1350 /* if the user selected tv=0 don't try and add the connector */
1351 if (((connector_type == DRM_MODE_CONNECTOR_SVIDEO) ||
1352 (connector_type == DRM_MODE_CONNECTOR_Composite) ||
1353 (connector_type == DRM_MODE_CONNECTOR_9PinDIN)) &&
1354 (radeon_tv == 0))
1355 return;
1357 /* see if we already added it */
1358 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1359 radeon_connector = to_radeon_connector(connector);
1360 if (radeon_connector->connector_id == connector_id) {
1361 radeon_connector->devices |= supported_device;
1362 return;
1364 if (radeon_connector->ddc_bus && i2c_bus->valid) {
1365 if (radeon_connector->ddc_bus->rec.i2c_id == i2c_bus->i2c_id) {
1366 radeon_connector->shared_ddc = true;
1367 shared_ddc = true;
1369 if (radeon_connector->router_bus && router->ddc_valid &&
1370 (radeon_connector->router.router_id == router->router_id)) {
1371 radeon_connector->shared_ddc = false;
1372 shared_ddc = false;
1377 /* check if it's a dp bridge */
1378 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
1379 radeon_encoder = to_radeon_encoder(encoder);
1380 if (radeon_encoder->devices & supported_device) {
1381 switch (radeon_encoder->encoder_id) {
1382 case ENCODER_OBJECT_ID_TRAVIS:
1383 case ENCODER_OBJECT_ID_NUTMEG:
1384 is_dp_bridge = true;
1385 break;
1386 default:
1387 break;
1392 radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL);
1393 if (!radeon_connector)
1394 return;
1396 connector = &radeon_connector->base;
1398 radeon_connector->connector_id = connector_id;
1399 radeon_connector->devices = supported_device;
1400 radeon_connector->shared_ddc = shared_ddc;
1401 radeon_connector->connector_object_id = connector_object_id;
1402 radeon_connector->hpd = *hpd;
1403 radeon_connector->router = *router;
1404 if (router->ddc_valid || router->cd_valid) {
1405 radeon_connector->router_bus = radeon_i2c_lookup(rdev, &router->i2c_info);
1406 if (!radeon_connector->router_bus)
1407 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n");
1410 if (is_dp_bridge) {
1411 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
1412 if (!radeon_dig_connector)
1413 goto failed;
1414 radeon_dig_connector->igp_lane_info = igp_lane_info;
1415 radeon_connector->con_priv = radeon_dig_connector;
1416 drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type);
1417 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
1418 if (i2c_bus->valid) {
1419 /* add DP i2c bus */
1420 if (connector_type == DRM_MODE_CONNECTOR_eDP)
1421 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch");
1422 else
1423 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch");
1424 if (!radeon_dig_connector->dp_i2c_bus)
1425 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1426 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1427 if (!radeon_connector->ddc_bus)
1428 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1430 switch (connector_type) {
1431 case DRM_MODE_CONNECTOR_VGA:
1432 case DRM_MODE_CONNECTOR_DVIA:
1433 default:
1434 connector->interlace_allowed = true;
1435 connector->doublescan_allowed = true;
1436 radeon_connector->dac_load_detect = true;
1437 drm_connector_attach_property(&radeon_connector->base,
1438 rdev->mode_info.load_detect_property,
1440 break;
1441 case DRM_MODE_CONNECTOR_DVII:
1442 case DRM_MODE_CONNECTOR_DVID:
1443 case DRM_MODE_CONNECTOR_HDMIA:
1444 case DRM_MODE_CONNECTOR_HDMIB:
1445 case DRM_MODE_CONNECTOR_DisplayPort:
1446 drm_connector_attach_property(&radeon_connector->base,
1447 rdev->mode_info.underscan_property,
1448 UNDERSCAN_OFF);
1449 drm_connector_attach_property(&radeon_connector->base,
1450 rdev->mode_info.underscan_hborder_property,
1452 drm_connector_attach_property(&radeon_connector->base,
1453 rdev->mode_info.underscan_vborder_property,
1455 subpixel_order = SubPixelHorizontalRGB;
1456 connector->interlace_allowed = true;
1457 if (connector_type == DRM_MODE_CONNECTOR_HDMIB)
1458 connector->doublescan_allowed = true;
1459 else
1460 connector->doublescan_allowed = false;
1461 if (connector_type == DRM_MODE_CONNECTOR_DVII) {
1462 radeon_connector->dac_load_detect = true;
1463 drm_connector_attach_property(&radeon_connector->base,
1464 rdev->mode_info.load_detect_property,
1467 break;
1468 case DRM_MODE_CONNECTOR_LVDS:
1469 case DRM_MODE_CONNECTOR_eDP:
1470 drm_connector_attach_property(&radeon_connector->base,
1471 dev->mode_config.scaling_mode_property,
1472 DRM_MODE_SCALE_FULLSCREEN);
1473 subpixel_order = SubPixelHorizontalRGB;
1474 connector->interlace_allowed = false;
1475 connector->doublescan_allowed = false;
1476 break;
1478 } else {
1479 switch (connector_type) {
1480 case DRM_MODE_CONNECTOR_VGA:
1481 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
1482 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
1483 if (i2c_bus->valid) {
1484 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1485 if (!radeon_connector->ddc_bus)
1486 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1488 radeon_connector->dac_load_detect = true;
1489 drm_connector_attach_property(&radeon_connector->base,
1490 rdev->mode_info.load_detect_property,
1492 /* no HPD on analog connectors */
1493 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1494 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
1495 connector->interlace_allowed = true;
1496 connector->doublescan_allowed = true;
1497 break;
1498 case DRM_MODE_CONNECTOR_DVIA:
1499 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
1500 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
1501 if (i2c_bus->valid) {
1502 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1503 if (!radeon_connector->ddc_bus)
1504 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1506 radeon_connector->dac_load_detect = true;
1507 drm_connector_attach_property(&radeon_connector->base,
1508 rdev->mode_info.load_detect_property,
1510 /* no HPD on analog connectors */
1511 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1512 connector->interlace_allowed = true;
1513 connector->doublescan_allowed = true;
1514 break;
1515 case DRM_MODE_CONNECTOR_DVII:
1516 case DRM_MODE_CONNECTOR_DVID:
1517 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
1518 if (!radeon_dig_connector)
1519 goto failed;
1520 radeon_dig_connector->igp_lane_info = igp_lane_info;
1521 radeon_connector->con_priv = radeon_dig_connector;
1522 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type);
1523 drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
1524 if (i2c_bus->valid) {
1525 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1526 if (!radeon_connector->ddc_bus)
1527 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1529 subpixel_order = SubPixelHorizontalRGB;
1530 drm_connector_attach_property(&radeon_connector->base,
1531 rdev->mode_info.coherent_mode_property,
1533 if (ASIC_IS_AVIVO(rdev)) {
1534 drm_connector_attach_property(&radeon_connector->base,
1535 rdev->mode_info.underscan_property,
1536 UNDERSCAN_OFF);
1537 drm_connector_attach_property(&radeon_connector->base,
1538 rdev->mode_info.underscan_hborder_property,
1540 drm_connector_attach_property(&radeon_connector->base,
1541 rdev->mode_info.underscan_vborder_property,
1544 if (connector_type == DRM_MODE_CONNECTOR_DVII) {
1545 radeon_connector->dac_load_detect = true;
1546 drm_connector_attach_property(&radeon_connector->base,
1547 rdev->mode_info.load_detect_property,
1550 connector->interlace_allowed = true;
1551 if (connector_type == DRM_MODE_CONNECTOR_DVII)
1552 connector->doublescan_allowed = true;
1553 else
1554 connector->doublescan_allowed = false;
1555 break;
1556 case DRM_MODE_CONNECTOR_HDMIA:
1557 case DRM_MODE_CONNECTOR_HDMIB:
1558 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
1559 if (!radeon_dig_connector)
1560 goto failed;
1561 radeon_dig_connector->igp_lane_info = igp_lane_info;
1562 radeon_connector->con_priv = radeon_dig_connector;
1563 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type);
1564 drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
1565 if (i2c_bus->valid) {
1566 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1567 if (!radeon_connector->ddc_bus)
1568 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1570 drm_connector_attach_property(&radeon_connector->base,
1571 rdev->mode_info.coherent_mode_property,
1573 if (ASIC_IS_AVIVO(rdev)) {
1574 drm_connector_attach_property(&radeon_connector->base,
1575 rdev->mode_info.underscan_property,
1576 UNDERSCAN_OFF);
1577 drm_connector_attach_property(&radeon_connector->base,
1578 rdev->mode_info.underscan_hborder_property,
1580 drm_connector_attach_property(&radeon_connector->base,
1581 rdev->mode_info.underscan_vborder_property,
1584 subpixel_order = SubPixelHorizontalRGB;
1585 connector->interlace_allowed = true;
1586 if (connector_type == DRM_MODE_CONNECTOR_HDMIB)
1587 connector->doublescan_allowed = true;
1588 else
1589 connector->doublescan_allowed = false;
1590 break;
1591 case DRM_MODE_CONNECTOR_DisplayPort:
1592 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
1593 if (!radeon_dig_connector)
1594 goto failed;
1595 radeon_dig_connector->igp_lane_info = igp_lane_info;
1596 radeon_connector->con_priv = radeon_dig_connector;
1597 drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type);
1598 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
1599 if (i2c_bus->valid) {
1600 /* add DP i2c bus */
1601 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch");
1602 if (!radeon_dig_connector->dp_i2c_bus)
1603 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1604 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1605 if (!radeon_connector->ddc_bus)
1606 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1608 subpixel_order = SubPixelHorizontalRGB;
1609 drm_connector_attach_property(&radeon_connector->base,
1610 rdev->mode_info.coherent_mode_property,
1612 if (ASIC_IS_AVIVO(rdev)) {
1613 drm_connector_attach_property(&radeon_connector->base,
1614 rdev->mode_info.underscan_property,
1615 UNDERSCAN_OFF);
1616 drm_connector_attach_property(&radeon_connector->base,
1617 rdev->mode_info.underscan_hborder_property,
1619 drm_connector_attach_property(&radeon_connector->base,
1620 rdev->mode_info.underscan_vborder_property,
1623 connector->interlace_allowed = true;
1624 /* in theory with a DP to VGA converter... */
1625 connector->doublescan_allowed = false;
1626 break;
1627 case DRM_MODE_CONNECTOR_eDP:
1628 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
1629 if (!radeon_dig_connector)
1630 goto failed;
1631 radeon_dig_connector->igp_lane_info = igp_lane_info;
1632 radeon_connector->con_priv = radeon_dig_connector;
1633 drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type);
1634 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
1635 if (i2c_bus->valid) {
1636 /* add DP i2c bus */
1637 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch");
1638 if (!radeon_dig_connector->dp_i2c_bus)
1639 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1640 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1641 if (!radeon_connector->ddc_bus)
1642 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1644 drm_connector_attach_property(&radeon_connector->base,
1645 dev->mode_config.scaling_mode_property,
1646 DRM_MODE_SCALE_FULLSCREEN);
1647 subpixel_order = SubPixelHorizontalRGB;
1648 connector->interlace_allowed = false;
1649 connector->doublescan_allowed = false;
1650 break;
1651 case DRM_MODE_CONNECTOR_SVIDEO:
1652 case DRM_MODE_CONNECTOR_Composite:
1653 case DRM_MODE_CONNECTOR_9PinDIN:
1654 drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type);
1655 drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs);
1656 radeon_connector->dac_load_detect = true;
1657 drm_connector_attach_property(&radeon_connector->base,
1658 rdev->mode_info.load_detect_property,
1660 drm_connector_attach_property(&radeon_connector->base,
1661 rdev->mode_info.tv_std_property,
1662 radeon_atombios_get_tv_info(rdev));
1663 /* no HPD on analog connectors */
1664 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1665 connector->interlace_allowed = false;
1666 connector->doublescan_allowed = false;
1667 break;
1668 case DRM_MODE_CONNECTOR_LVDS:
1669 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
1670 if (!radeon_dig_connector)
1671 goto failed;
1672 radeon_dig_connector->igp_lane_info = igp_lane_info;
1673 radeon_connector->con_priv = radeon_dig_connector;
1674 drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type);
1675 drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs);
1676 if (i2c_bus->valid) {
1677 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1678 if (!radeon_connector->ddc_bus)
1679 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1681 drm_connector_attach_property(&radeon_connector->base,
1682 dev->mode_config.scaling_mode_property,
1683 DRM_MODE_SCALE_FULLSCREEN);
1684 subpixel_order = SubPixelHorizontalRGB;
1685 connector->interlace_allowed = false;
1686 connector->doublescan_allowed = false;
1687 break;
1691 if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) {
1692 if (i2c_bus->valid)
1693 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
1694 } else
1695 connector->polled = DRM_CONNECTOR_POLL_HPD;
1697 connector->display_info.subpixel_order = subpixel_order;
1698 drm_sysfs_connector_add(connector);
1699 return;
1701 failed:
1702 drm_connector_cleanup(connector);
1703 kfree(connector);
1706 void
1707 radeon_add_legacy_connector(struct drm_device *dev,
1708 uint32_t connector_id,
1709 uint32_t supported_device,
1710 int connector_type,
1711 struct radeon_i2c_bus_rec *i2c_bus,
1712 uint16_t connector_object_id,
1713 struct radeon_hpd *hpd)
1715 struct radeon_device *rdev = dev->dev_private;
1716 struct drm_connector *connector;
1717 struct radeon_connector *radeon_connector;
1718 uint32_t subpixel_order = SubPixelNone;
1720 if (connector_type == DRM_MODE_CONNECTOR_Unknown)
1721 return;
1723 /* if the user selected tv=0 don't try and add the connector */
1724 if (((connector_type == DRM_MODE_CONNECTOR_SVIDEO) ||
1725 (connector_type == DRM_MODE_CONNECTOR_Composite) ||
1726 (connector_type == DRM_MODE_CONNECTOR_9PinDIN)) &&
1727 (radeon_tv == 0))
1728 return;
1730 /* see if we already added it */
1731 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1732 radeon_connector = to_radeon_connector(connector);
1733 if (radeon_connector->connector_id == connector_id) {
1734 radeon_connector->devices |= supported_device;
1735 return;
1739 radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL);
1740 if (!radeon_connector)
1741 return;
1743 connector = &radeon_connector->base;
1745 radeon_connector->connector_id = connector_id;
1746 radeon_connector->devices = supported_device;
1747 radeon_connector->connector_object_id = connector_object_id;
1748 radeon_connector->hpd = *hpd;
1749 switch (connector_type) {
1750 case DRM_MODE_CONNECTOR_VGA:
1751 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
1752 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
1753 if (i2c_bus->valid) {
1754 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1755 if (!radeon_connector->ddc_bus)
1756 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1758 radeon_connector->dac_load_detect = true;
1759 drm_connector_attach_property(&radeon_connector->base,
1760 rdev->mode_info.load_detect_property,
1762 /* no HPD on analog connectors */
1763 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1764 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
1765 connector->interlace_allowed = true;
1766 connector->doublescan_allowed = true;
1767 break;
1768 case DRM_MODE_CONNECTOR_DVIA:
1769 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
1770 drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
1771 if (i2c_bus->valid) {
1772 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1773 if (!radeon_connector->ddc_bus)
1774 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1776 radeon_connector->dac_load_detect = true;
1777 drm_connector_attach_property(&radeon_connector->base,
1778 rdev->mode_info.load_detect_property,
1780 /* no HPD on analog connectors */
1781 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1782 connector->interlace_allowed = true;
1783 connector->doublescan_allowed = true;
1784 break;
1785 case DRM_MODE_CONNECTOR_DVII:
1786 case DRM_MODE_CONNECTOR_DVID:
1787 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type);
1788 drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
1789 if (i2c_bus->valid) {
1790 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1791 if (!radeon_connector->ddc_bus)
1792 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1794 if (connector_type == DRM_MODE_CONNECTOR_DVII) {
1795 radeon_connector->dac_load_detect = true;
1796 drm_connector_attach_property(&radeon_connector->base,
1797 rdev->mode_info.load_detect_property,
1800 subpixel_order = SubPixelHorizontalRGB;
1801 connector->interlace_allowed = true;
1802 if (connector_type == DRM_MODE_CONNECTOR_DVII)
1803 connector->doublescan_allowed = true;
1804 else
1805 connector->doublescan_allowed = false;
1806 break;
1807 case DRM_MODE_CONNECTOR_SVIDEO:
1808 case DRM_MODE_CONNECTOR_Composite:
1809 case DRM_MODE_CONNECTOR_9PinDIN:
1810 drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type);
1811 drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs);
1812 radeon_connector->dac_load_detect = true;
1813 /* RS400,RC410,RS480 chipset seems to report a lot
1814 * of false positive on load detect, we haven't yet
1815 * found a way to make load detect reliable on those
1816 * chipset, thus just disable it for TV.
1818 if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480)
1819 radeon_connector->dac_load_detect = false;
1820 drm_connector_attach_property(&radeon_connector->base,
1821 rdev->mode_info.load_detect_property,
1822 radeon_connector->dac_load_detect);
1823 drm_connector_attach_property(&radeon_connector->base,
1824 rdev->mode_info.tv_std_property,
1825 radeon_combios_get_tv_info(rdev));
1826 /* no HPD on analog connectors */
1827 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1828 connector->interlace_allowed = false;
1829 connector->doublescan_allowed = false;
1830 break;
1831 case DRM_MODE_CONNECTOR_LVDS:
1832 drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type);
1833 drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs);
1834 if (i2c_bus->valid) {
1835 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1836 if (!radeon_connector->ddc_bus)
1837 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1839 drm_connector_attach_property(&radeon_connector->base,
1840 dev->mode_config.scaling_mode_property,
1841 DRM_MODE_SCALE_FULLSCREEN);
1842 subpixel_order = SubPixelHorizontalRGB;
1843 connector->interlace_allowed = false;
1844 connector->doublescan_allowed = false;
1845 break;
1848 if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) {
1849 if (i2c_bus->valid)
1850 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
1851 } else
1852 connector->polled = DRM_CONNECTOR_POLL_HPD;
1853 connector->display_info.subpixel_order = subpixel_order;
1854 drm_sysfs_connector_add(connector);
1855 if (connector_type == DRM_MODE_CONNECTOR_LVDS) {
1856 struct drm_encoder *drm_encoder;
1858 list_for_each_entry(drm_encoder, &dev->mode_config.encoder_list, head) {
1859 struct radeon_encoder *radeon_encoder;
1861 radeon_encoder = to_radeon_encoder(drm_encoder);
1862 if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_LVDS)
1863 radeon_legacy_backlight_init(radeon_encoder, connector);