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
28 #include "drm_crtc_helper.h"
29 #include "drm_fb_helper.h"
30 #include "radeon_drm.h"
35 radeon_combios_connected_scratch_regs(struct drm_connector
*connector
,
36 struct drm_encoder
*encoder
,
39 radeon_atombios_connected_scratch_regs(struct drm_connector
*connector
,
40 struct drm_encoder
*encoder
,
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 /* bail if the connector does not have hpd pin, e.g.,
58 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
)
61 radeon_hpd_set_polarity(rdev
, radeon_connector
->hpd
.hpd
);
63 /* powering up/down the eDP panel generates hpd events which
64 * can interfere with modesetting.
66 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
)
69 /* pre-r600 did not always have the hpd pins mapped accurately to connectors */
70 if (rdev
->family
>= CHIP_R600
) {
71 if (radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
))
72 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_ON
);
74 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_OFF
);
78 static void radeon_property_change_mode(struct drm_encoder
*encoder
)
80 struct drm_crtc
*crtc
= encoder
->crtc
;
82 if (crtc
&& crtc
->enabled
) {
83 drm_crtc_helper_set_mode(crtc
, &crtc
->mode
,
84 crtc
->x
, crtc
->y
, crtc
->fb
);
88 radeon_connector_update_scratch_regs(struct drm_connector
*connector
, enum drm_connector_status status
)
90 struct drm_device
*dev
= connector
->dev
;
91 struct radeon_device
*rdev
= dev
->dev_private
;
92 struct drm_encoder
*best_encoder
= NULL
;
93 struct drm_encoder
*encoder
= NULL
;
94 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
95 struct drm_mode_object
*obj
;
99 best_encoder
= connector_funcs
->best_encoder(connector
);
101 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
102 if (connector
->encoder_ids
[i
] == 0)
105 obj
= drm_mode_object_find(connector
->dev
,
106 connector
->encoder_ids
[i
],
107 DRM_MODE_OBJECT_ENCODER
);
111 encoder
= obj_to_encoder(obj
);
113 if ((encoder
== best_encoder
) && (status
== connector_status_connected
))
118 if (rdev
->is_atom_bios
)
119 radeon_atombios_connected_scratch_regs(connector
, encoder
, connected
);
121 radeon_combios_connected_scratch_regs(connector
, encoder
, connected
);
126 struct drm_encoder
*radeon_find_encoder(struct drm_connector
*connector
, int encoder_type
)
128 struct drm_mode_object
*obj
;
129 struct drm_encoder
*encoder
;
132 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
133 if (connector
->encoder_ids
[i
] == 0)
136 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
140 encoder
= obj_to_encoder(obj
);
141 if (encoder
->encoder_type
== encoder_type
)
147 struct drm_encoder
*radeon_best_single_encoder(struct drm_connector
*connector
)
149 int enc_id
= connector
->encoder_ids
[0];
150 struct drm_mode_object
*obj
;
151 struct drm_encoder
*encoder
;
153 /* pick the encoder ids */
155 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
158 encoder
= obj_to_encoder(obj
);
165 * radeon_connector_analog_encoder_conflict_solve
166 * - search for other connectors sharing this encoder
167 * if priority is true, then set them disconnected if this is connected
168 * if priority is false, set us disconnected if they are connected
170 static enum drm_connector_status
171 radeon_connector_analog_encoder_conflict_solve(struct drm_connector
*connector
,
172 struct drm_encoder
*encoder
,
173 enum drm_connector_status current_status
,
176 struct drm_device
*dev
= connector
->dev
;
177 struct drm_connector
*conflict
;
178 struct radeon_connector
*radeon_conflict
;
181 list_for_each_entry(conflict
, &dev
->mode_config
.connector_list
, head
) {
182 if (conflict
== connector
)
185 radeon_conflict
= to_radeon_connector(conflict
);
186 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
187 if (conflict
->encoder_ids
[i
] == 0)
190 /* if the IDs match */
191 if (conflict
->encoder_ids
[i
] == encoder
->base
.id
) {
192 if (conflict
->status
!= connector_status_connected
)
195 if (radeon_conflict
->use_digital
)
198 if (priority
== true) {
199 DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict
));
200 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(connector
));
201 conflict
->status
= connector_status_disconnected
;
202 radeon_connector_update_scratch_regs(conflict
, connector_status_disconnected
);
204 DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector
));
205 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(conflict
));
206 current_status
= connector_status_disconnected
;
212 return current_status
;
216 static struct drm_display_mode
*radeon_fp_native_mode(struct drm_encoder
*encoder
)
218 struct drm_device
*dev
= encoder
->dev
;
219 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
220 struct drm_display_mode
*mode
= NULL
;
221 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
223 if (native_mode
->hdisplay
!= 0 &&
224 native_mode
->vdisplay
!= 0 &&
225 native_mode
->clock
!= 0) {
226 mode
= drm_mode_duplicate(dev
, native_mode
);
227 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
228 drm_mode_set_name(mode
);
230 DRM_DEBUG_KMS("Adding native panel mode %s\n", mode
->name
);
231 } else if (native_mode
->hdisplay
!= 0 &&
232 native_mode
->vdisplay
!= 0) {
233 /* mac laptops without an edid */
234 /* Note that this is not necessarily the exact panel mode,
235 * but an approximation based on the cvt formula. For these
236 * systems we should ideally read the mode info out of the
237 * registers or add a mode table, but this works and is much
240 mode
= drm_cvt_mode(dev
, native_mode
->hdisplay
, native_mode
->vdisplay
, 60, true, false, false);
241 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
242 DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode
->name
);
247 static void radeon_add_common_modes(struct drm_encoder
*encoder
, struct drm_connector
*connector
)
249 struct drm_device
*dev
= encoder
->dev
;
250 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
251 struct drm_display_mode
*mode
= NULL
;
252 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
257 } common_modes
[17] = {
277 for (i
= 0; i
< 17; i
++) {
278 if (radeon_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
)) {
279 if (common_modes
[i
].w
> 1024 ||
280 common_modes
[i
].h
> 768)
283 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
284 if (common_modes
[i
].w
> native_mode
->hdisplay
||
285 common_modes
[i
].h
> native_mode
->vdisplay
||
286 (common_modes
[i
].w
== native_mode
->hdisplay
&&
287 common_modes
[i
].h
== native_mode
->vdisplay
))
290 if (common_modes
[i
].w
< 320 || common_modes
[i
].h
< 200)
293 mode
= drm_cvt_mode(dev
, common_modes
[i
].w
, common_modes
[i
].h
, 60, false, false, false);
294 drm_mode_probed_add(connector
, mode
);
298 int radeon_connector_set_property(struct drm_connector
*connector
, struct drm_property
*property
,
301 struct drm_device
*dev
= connector
->dev
;
302 struct radeon_device
*rdev
= dev
->dev_private
;
303 struct drm_encoder
*encoder
;
304 struct radeon_encoder
*radeon_encoder
;
306 if (property
== rdev
->mode_info
.coherent_mode_property
) {
307 struct radeon_encoder_atom_dig
*dig
;
308 bool new_coherent_mode
;
310 /* need to find digital encoder on connector */
311 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
315 radeon_encoder
= to_radeon_encoder(encoder
);
317 if (!radeon_encoder
->enc_priv
)
320 dig
= radeon_encoder
->enc_priv
;
321 new_coherent_mode
= val
? true : false;
322 if (dig
->coherent_mode
!= new_coherent_mode
) {
323 dig
->coherent_mode
= new_coherent_mode
;
324 radeon_property_change_mode(&radeon_encoder
->base
);
328 if (property
== rdev
->mode_info
.underscan_property
) {
329 /* need to find digital encoder on connector */
330 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
334 radeon_encoder
= to_radeon_encoder(encoder
);
336 if (radeon_encoder
->underscan_type
!= val
) {
337 radeon_encoder
->underscan_type
= val
;
338 radeon_property_change_mode(&radeon_encoder
->base
);
342 if (property
== rdev
->mode_info
.underscan_hborder_property
) {
343 /* need to find digital encoder on connector */
344 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
348 radeon_encoder
= to_radeon_encoder(encoder
);
350 if (radeon_encoder
->underscan_hborder
!= val
) {
351 radeon_encoder
->underscan_hborder
= val
;
352 radeon_property_change_mode(&radeon_encoder
->base
);
356 if (property
== rdev
->mode_info
.underscan_vborder_property
) {
357 /* need to find digital encoder on connector */
358 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
362 radeon_encoder
= to_radeon_encoder(encoder
);
364 if (radeon_encoder
->underscan_vborder
!= val
) {
365 radeon_encoder
->underscan_vborder
= val
;
366 radeon_property_change_mode(&radeon_encoder
->base
);
370 if (property
== rdev
->mode_info
.tv_std_property
) {
371 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TVDAC
);
373 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_DAC
);
379 radeon_encoder
= to_radeon_encoder(encoder
);
380 if (!radeon_encoder
->enc_priv
)
382 if (ASIC_IS_AVIVO(rdev
) || radeon_r4xx_atom
) {
383 struct radeon_encoder_atom_dac
*dac_int
;
384 dac_int
= radeon_encoder
->enc_priv
;
385 dac_int
->tv_std
= val
;
387 struct radeon_encoder_tv_dac
*dac_int
;
388 dac_int
= radeon_encoder
->enc_priv
;
389 dac_int
->tv_std
= val
;
391 radeon_property_change_mode(&radeon_encoder
->base
);
394 if (property
== rdev
->mode_info
.load_detect_property
) {
395 struct radeon_connector
*radeon_connector
=
396 to_radeon_connector(connector
);
399 radeon_connector
->dac_load_detect
= false;
401 radeon_connector
->dac_load_detect
= true;
404 if (property
== rdev
->mode_info
.tmds_pll_property
) {
405 struct radeon_encoder_int_tmds
*tmds
= NULL
;
407 /* need to find digital encoder on connector */
408 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
412 radeon_encoder
= to_radeon_encoder(encoder
);
414 tmds
= radeon_encoder
->enc_priv
;
419 if (rdev
->is_atom_bios
)
420 ret
= radeon_atombios_get_tmds_info(radeon_encoder
, tmds
);
422 ret
= radeon_legacy_get_tmds_info_from_combios(radeon_encoder
, tmds
);
424 if (val
== 1 || ret
== false) {
425 radeon_legacy_get_tmds_info_from_table(radeon_encoder
, tmds
);
427 radeon_property_change_mode(&radeon_encoder
->base
);
434 * Some integrated ATI Radeon chipset implementations (e. g.
435 * Asus M2A-VM HDMI) may indicate the availability of a DDC,
436 * even when there's no monitor connected. For these connectors
437 * following DDC probe extension will be applied: check also for the
438 * availability of EDID with at least a correct EDID header. Only then,
439 * DDC is assumed to be available. This prevents drm_get_edid() and
440 * drm_edid_block_valid() from periodically dumping data and kernel
441 * errors into the logs and onto the terminal.
443 static bool radeon_connector_needs_extended_probe(struct radeon_device
*dev
,
444 uint32_t supported_device
,
447 /* Asus M2A-VM HDMI board sends data to i2c bus even,
448 * if HDMI add-on card is not plugged in or HDMI is disabled in
449 * BIOS. Valid DDC can only be assumed, if also a valid EDID header
450 * can be retrieved via i2c bus during DDC probe */
451 if ((dev
->pdev
->device
== 0x791e) &&
452 (dev
->pdev
->subsystem_vendor
== 0x1043) &&
453 (dev
->pdev
->subsystem_device
== 0x826d)) {
454 if ((connector_type
== DRM_MODE_CONNECTOR_HDMIA
) &&
455 (supported_device
== ATOM_DEVICE_DFP2_SUPPORT
))
458 /* ECS A740GM-M with ATI RADEON 2100 sends data to i2c bus
459 * for a DVI connector that is not implemented */
460 if ((dev
->pdev
->device
== 0x796e) &&
461 (dev
->pdev
->subsystem_vendor
== 0x1019) &&
462 (dev
->pdev
->subsystem_device
== 0x2615)) {
463 if ((connector_type
== DRM_MODE_CONNECTOR_DVID
) &&
464 (supported_device
== ATOM_DEVICE_DFP2_SUPPORT
))
468 /* Default: no EDID header probe required for DDC probing */
472 static void radeon_fixup_lvds_native_mode(struct drm_encoder
*encoder
,
473 struct drm_connector
*connector
)
475 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
476 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
478 /* Try to get native mode details from EDID if necessary */
479 if (!native_mode
->clock
) {
480 struct drm_display_mode
*t
, *mode
;
482 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
483 if (mode
->hdisplay
== native_mode
->hdisplay
&&
484 mode
->vdisplay
== native_mode
->vdisplay
) {
485 *native_mode
= *mode
;
486 drm_mode_set_crtcinfo(native_mode
, CRTC_INTERLACE_HALVE_V
);
487 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
492 if (!native_mode
->clock
) {
493 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n");
494 radeon_encoder
->rmx_type
= RMX_OFF
;
498 static int radeon_lvds_get_modes(struct drm_connector
*connector
)
500 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
501 struct drm_encoder
*encoder
;
503 struct drm_display_mode
*mode
;
505 if (radeon_connector
->ddc_bus
) {
506 ret
= radeon_ddc_get_modes(radeon_connector
);
508 encoder
= radeon_best_single_encoder(connector
);
510 radeon_fixup_lvds_native_mode(encoder
, connector
);
511 /* add scaled modes */
512 radeon_add_common_modes(encoder
, connector
);
518 encoder
= radeon_best_single_encoder(connector
);
522 /* we have no EDID modes */
523 mode
= radeon_fp_native_mode(encoder
);
526 drm_mode_probed_add(connector
, mode
);
527 /* add the width/height from vbios tables if available */
528 connector
->display_info
.width_mm
= mode
->width_mm
;
529 connector
->display_info
.height_mm
= mode
->height_mm
;
530 /* add scaled modes */
531 radeon_add_common_modes(encoder
, connector
);
537 static int radeon_lvds_mode_valid(struct drm_connector
*connector
,
538 struct drm_display_mode
*mode
)
540 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
542 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
546 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
547 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
549 /* AVIVO hardware supports downscaling modes larger than the panel
550 * to the panel size, but I'm not sure this is desirable.
552 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
553 (mode
->vdisplay
> native_mode
->vdisplay
))
556 /* if scaling is disabled, block non-native modes */
557 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
558 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
559 (mode
->vdisplay
!= native_mode
->vdisplay
))
567 static enum drm_connector_status
568 radeon_lvds_detect(struct drm_connector
*connector
, bool force
)
570 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
571 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
572 enum drm_connector_status ret
= connector_status_disconnected
;
575 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
576 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
578 /* check if panel is valid */
579 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
580 ret
= connector_status_connected
;
584 /* check for edid as well */
585 if (radeon_connector
->edid
)
586 ret
= connector_status_connected
;
588 if (radeon_connector
->ddc_bus
) {
589 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
,
590 &radeon_connector
->ddc_bus
->adapter
);
591 if (radeon_connector
->edid
)
592 ret
= connector_status_connected
;
595 /* check acpi lid status ??? */
597 radeon_connector_update_scratch_regs(connector
, ret
);
601 static void radeon_connector_destroy(struct drm_connector
*connector
)
603 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
605 if (radeon_connector
->edid
)
606 kfree(radeon_connector
->edid
);
607 kfree(radeon_connector
->con_priv
);
608 drm_sysfs_connector_remove(connector
);
609 drm_connector_cleanup(connector
);
613 static int radeon_lvds_set_property(struct drm_connector
*connector
,
614 struct drm_property
*property
,
617 struct drm_device
*dev
= connector
->dev
;
618 struct radeon_encoder
*radeon_encoder
;
619 enum radeon_rmx_type rmx_type
;
622 if (property
!= dev
->mode_config
.scaling_mode_property
)
625 if (connector
->encoder
)
626 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
628 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
629 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
633 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
634 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
635 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
637 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
639 if (radeon_encoder
->rmx_type
== rmx_type
)
642 radeon_encoder
->rmx_type
= rmx_type
;
644 radeon_property_change_mode(&radeon_encoder
->base
);
649 struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs
= {
650 .get_modes
= radeon_lvds_get_modes
,
651 .mode_valid
= radeon_lvds_mode_valid
,
652 .best_encoder
= radeon_best_single_encoder
,
655 struct drm_connector_funcs radeon_lvds_connector_funcs
= {
656 .dpms
= drm_helper_connector_dpms
,
657 .detect
= radeon_lvds_detect
,
658 .fill_modes
= drm_helper_probe_single_connector_modes
,
659 .destroy
= radeon_connector_destroy
,
660 .set_property
= radeon_lvds_set_property
,
663 static int radeon_vga_get_modes(struct drm_connector
*connector
)
665 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
668 ret
= radeon_ddc_get_modes(radeon_connector
);
673 static int radeon_vga_mode_valid(struct drm_connector
*connector
,
674 struct drm_display_mode
*mode
)
676 struct drm_device
*dev
= connector
->dev
;
677 struct radeon_device
*rdev
= dev
->dev_private
;
679 /* XXX check mode bandwidth */
681 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
682 return MODE_CLOCK_HIGH
;
687 static enum drm_connector_status
688 radeon_vga_detect(struct drm_connector
*connector
, bool force
)
690 struct drm_device
*dev
= connector
->dev
;
691 struct radeon_device
*rdev
= dev
->dev_private
;
692 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
693 struct drm_encoder
*encoder
;
694 struct drm_encoder_helper_funcs
*encoder_funcs
;
696 enum drm_connector_status ret
= connector_status_disconnected
;
698 encoder
= radeon_best_single_encoder(connector
);
700 ret
= connector_status_disconnected
;
702 if (radeon_connector
->ddc_bus
)
703 dret
= radeon_ddc_probe(radeon_connector
,
704 radeon_connector
->requires_extended_probe
);
706 if (radeon_connector
->edid
) {
707 kfree(radeon_connector
->edid
);
708 radeon_connector
->edid
= NULL
;
710 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
712 if (!radeon_connector
->edid
) {
713 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
714 drm_get_connector_name(connector
));
715 ret
= connector_status_connected
;
717 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
719 /* some oems have boards with separate digital and analog connectors
720 * with a shared ddc line (often vga + hdmi)
722 if (radeon_connector
->use_digital
&& radeon_connector
->shared_ddc
) {
723 kfree(radeon_connector
->edid
);
724 radeon_connector
->edid
= NULL
;
725 ret
= connector_status_disconnected
;
727 ret
= connector_status_connected
;
731 /* if we aren't forcing don't do destructive polling */
733 return connector
->status
;
735 if (radeon_connector
->dac_load_detect
&& encoder
) {
736 encoder_funcs
= encoder
->helper_private
;
737 ret
= encoder_funcs
->detect(encoder
, connector
);
741 if (ret
== connector_status_connected
)
742 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
744 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
745 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
746 * by other means, assume the CRT is connected and use that EDID.
748 if ((!rdev
->is_atom_bios
) &&
749 (ret
== connector_status_disconnected
) &&
750 rdev
->mode_info
.bios_hardcoded_edid_size
) {
751 ret
= connector_status_connected
;
754 radeon_connector_update_scratch_regs(connector
, ret
);
758 struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs
= {
759 .get_modes
= radeon_vga_get_modes
,
760 .mode_valid
= radeon_vga_mode_valid
,
761 .best_encoder
= radeon_best_single_encoder
,
764 struct drm_connector_funcs radeon_vga_connector_funcs
= {
765 .dpms
= drm_helper_connector_dpms
,
766 .detect
= radeon_vga_detect
,
767 .fill_modes
= drm_helper_probe_single_connector_modes
,
768 .destroy
= radeon_connector_destroy
,
769 .set_property
= radeon_connector_set_property
,
772 static int radeon_tv_get_modes(struct drm_connector
*connector
)
774 struct drm_device
*dev
= connector
->dev
;
775 struct radeon_device
*rdev
= dev
->dev_private
;
776 struct drm_display_mode
*tv_mode
;
777 struct drm_encoder
*encoder
;
779 encoder
= radeon_best_single_encoder(connector
);
783 /* avivo chips can scale any mode */
784 if (rdev
->family
>= CHIP_RS600
)
785 /* add scaled modes */
786 radeon_add_common_modes(encoder
, connector
);
788 /* only 800x600 is supported right now on pre-avivo chips */
789 tv_mode
= drm_cvt_mode(dev
, 800, 600, 60, false, false, false);
790 tv_mode
->type
= DRM_MODE_TYPE_DRIVER
| DRM_MODE_TYPE_PREFERRED
;
791 drm_mode_probed_add(connector
, tv_mode
);
796 static int radeon_tv_mode_valid(struct drm_connector
*connector
,
797 struct drm_display_mode
*mode
)
799 if ((mode
->hdisplay
> 1024) || (mode
->vdisplay
> 768))
800 return MODE_CLOCK_RANGE
;
804 static enum drm_connector_status
805 radeon_tv_detect(struct drm_connector
*connector
, bool force
)
807 struct drm_encoder
*encoder
;
808 struct drm_encoder_helper_funcs
*encoder_funcs
;
809 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
810 enum drm_connector_status ret
= connector_status_disconnected
;
812 if (!radeon_connector
->dac_load_detect
)
815 encoder
= radeon_best_single_encoder(connector
);
817 ret
= connector_status_disconnected
;
819 encoder_funcs
= encoder
->helper_private
;
820 ret
= encoder_funcs
->detect(encoder
, connector
);
822 if (ret
== connector_status_connected
)
823 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, false);
824 radeon_connector_update_scratch_regs(connector
, ret
);
828 struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs
= {
829 .get_modes
= radeon_tv_get_modes
,
830 .mode_valid
= radeon_tv_mode_valid
,
831 .best_encoder
= radeon_best_single_encoder
,
834 struct drm_connector_funcs radeon_tv_connector_funcs
= {
835 .dpms
= drm_helper_connector_dpms
,
836 .detect
= radeon_tv_detect
,
837 .fill_modes
= drm_helper_probe_single_connector_modes
,
838 .destroy
= radeon_connector_destroy
,
839 .set_property
= radeon_connector_set_property
,
842 static int radeon_dvi_get_modes(struct drm_connector
*connector
)
844 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
847 ret
= radeon_ddc_get_modes(radeon_connector
);
853 * Do a DDC probe, if DDC probe passes, get the full EDID so
854 * we can do analog/digital monitor detection at this point.
855 * If the monitor is an analog monitor or we got no DDC,
856 * we need to find the DAC encoder object for this connector.
857 * If we got no DDC, we do load detection on the DAC encoder object.
858 * If we got analog DDC or load detection passes on the DAC encoder
859 * we have to check if this analog encoder is shared with anyone else (TV)
860 * if its shared we have to set the other connector to disconnected.
862 static enum drm_connector_status
863 radeon_dvi_detect(struct drm_connector
*connector
, bool force
)
865 struct drm_device
*dev
= connector
->dev
;
866 struct radeon_device
*rdev
= dev
->dev_private
;
867 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
868 struct drm_encoder
*encoder
= NULL
;
869 struct drm_encoder_helper_funcs
*encoder_funcs
;
870 struct drm_mode_object
*obj
;
872 enum drm_connector_status ret
= connector_status_disconnected
;
875 if (radeon_connector
->ddc_bus
)
876 dret
= radeon_ddc_probe(radeon_connector
,
877 radeon_connector
->requires_extended_probe
);
879 if (radeon_connector
->edid
) {
880 kfree(radeon_connector
->edid
);
881 radeon_connector
->edid
= NULL
;
883 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
885 if (!radeon_connector
->edid
) {
886 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
887 drm_get_connector_name(connector
));
888 /* rs690 seems to have a problem with connectors not existing and always
889 * return a block of 0's. If we see this just stop polling on this output */
890 if ((rdev
->family
== CHIP_RS690
|| rdev
->family
== CHIP_RS740
) && radeon_connector
->base
.null_edid_counter
) {
891 ret
= connector_status_disconnected
;
892 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", drm_get_connector_name(connector
));
893 radeon_connector
->ddc_bus
= NULL
;
896 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
898 /* some oems have boards with separate digital and analog connectors
899 * with a shared ddc line (often vga + hdmi)
901 if ((!radeon_connector
->use_digital
) && radeon_connector
->shared_ddc
) {
902 kfree(radeon_connector
->edid
);
903 radeon_connector
->edid
= NULL
;
904 ret
= connector_status_disconnected
;
906 ret
= connector_status_connected
;
908 /* This gets complicated. We have boards with VGA + HDMI with a
909 * shared DDC line and we have boards with DVI-D + HDMI with a shared
910 * DDC line. The latter is more complex because with DVI<->HDMI adapters
911 * you don't really know what's connected to which port as both are digital.
913 if (radeon_connector
->shared_ddc
&& (ret
== connector_status_connected
)) {
914 struct drm_connector
*list_connector
;
915 struct radeon_connector
*list_radeon_connector
;
916 list_for_each_entry(list_connector
, &dev
->mode_config
.connector_list
, head
) {
917 if (connector
== list_connector
)
919 list_radeon_connector
= to_radeon_connector(list_connector
);
920 if (list_radeon_connector
->shared_ddc
&&
921 (list_radeon_connector
->ddc_bus
->rec
.i2c_id
==
922 radeon_connector
->ddc_bus
->rec
.i2c_id
)) {
923 /* cases where both connectors are digital */
924 if (list_connector
->connector_type
!= DRM_MODE_CONNECTOR_VGA
) {
925 /* hpd is our only option in this case */
926 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
927 kfree(radeon_connector
->edid
);
928 radeon_connector
->edid
= NULL
;
929 ret
= connector_status_disconnected
;
938 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== true))
942 ret
= connector
->status
;
946 /* find analog encoder */
947 if (radeon_connector
->dac_load_detect
) {
948 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
949 if (connector
->encoder_ids
[i
] == 0)
952 obj
= drm_mode_object_find(connector
->dev
,
953 connector
->encoder_ids
[i
],
954 DRM_MODE_OBJECT_ENCODER
);
958 encoder
= obj_to_encoder(obj
);
960 encoder_funcs
= encoder
->helper_private
;
961 if (encoder_funcs
->detect
) {
962 if (ret
!= connector_status_connected
) {
963 ret
= encoder_funcs
->detect(encoder
, connector
);
964 if (ret
== connector_status_connected
) {
965 radeon_connector
->use_digital
= false;
973 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== false) &&
975 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
978 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
979 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
980 * by other means, assume the DFP is connected and use that EDID. In most
981 * cases the DVI port is actually a virtual KVM port connected to the service
984 if ((!rdev
->is_atom_bios
) &&
985 (ret
== connector_status_disconnected
) &&
986 rdev
->mode_info
.bios_hardcoded_edid_size
) {
987 radeon_connector
->use_digital
= true;
988 ret
= connector_status_connected
;
992 /* updated in get modes as well since we need to know if it's analog or digital */
993 radeon_connector_update_scratch_regs(connector
, ret
);
997 /* okay need to be smart in here about which encoder to pick */
998 struct drm_encoder
*radeon_dvi_encoder(struct drm_connector
*connector
)
1000 int enc_id
= connector
->encoder_ids
[0];
1001 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1002 struct drm_mode_object
*obj
;
1003 struct drm_encoder
*encoder
;
1005 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1006 if (connector
->encoder_ids
[i
] == 0)
1009 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1013 encoder
= obj_to_encoder(obj
);
1015 if (radeon_connector
->use_digital
== true) {
1016 if (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)
1019 if (encoder
->encoder_type
== DRM_MODE_ENCODER_DAC
||
1020 encoder
->encoder_type
== DRM_MODE_ENCODER_TVDAC
)
1025 /* see if we have a default encoder TODO */
1027 /* then check use digitial */
1028 /* pick the first one */
1030 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
1033 encoder
= obj_to_encoder(obj
);
1039 static void radeon_dvi_force(struct drm_connector
*connector
)
1041 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1042 if (connector
->force
== DRM_FORCE_ON
)
1043 radeon_connector
->use_digital
= false;
1044 if (connector
->force
== DRM_FORCE_ON_DIGITAL
)
1045 radeon_connector
->use_digital
= true;
1048 static int radeon_dvi_mode_valid(struct drm_connector
*connector
,
1049 struct drm_display_mode
*mode
)
1051 struct drm_device
*dev
= connector
->dev
;
1052 struct radeon_device
*rdev
= dev
->dev_private
;
1053 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1055 /* XXX check mode bandwidth */
1057 /* clocks over 135 MHz have heat issues with DVI on RV100 */
1058 if (radeon_connector
->use_digital
&&
1059 (rdev
->family
== CHIP_RV100
) &&
1060 (mode
->clock
> 135000))
1061 return MODE_CLOCK_HIGH
;
1063 if (radeon_connector
->use_digital
&& (mode
->clock
> 165000)) {
1064 if ((radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
) ||
1065 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
) ||
1066 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_B
))
1068 else if (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_A
) {
1069 if (ASIC_IS_DCE3(rdev
)) {
1070 /* HDMI 1.3+ supports max clock of 340 Mhz */
1071 if (mode
->clock
> 340000)
1072 return MODE_CLOCK_HIGH
;
1076 return MODE_CLOCK_HIGH
;
1078 return MODE_CLOCK_HIGH
;
1081 /* check against the max pixel clock */
1082 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
1083 return MODE_CLOCK_HIGH
;
1088 struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs
= {
1089 .get_modes
= radeon_dvi_get_modes
,
1090 .mode_valid
= radeon_dvi_mode_valid
,
1091 .best_encoder
= radeon_dvi_encoder
,
1094 struct drm_connector_funcs radeon_dvi_connector_funcs
= {
1095 .dpms
= drm_helper_connector_dpms
,
1096 .detect
= radeon_dvi_detect
,
1097 .fill_modes
= drm_helper_probe_single_connector_modes
,
1098 .set_property
= radeon_connector_set_property
,
1099 .destroy
= radeon_connector_destroy
,
1100 .force
= radeon_dvi_force
,
1103 static void radeon_dp_connector_destroy(struct drm_connector
*connector
)
1105 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1106 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1108 if (radeon_connector
->edid
)
1109 kfree(radeon_connector
->edid
);
1110 if (radeon_dig_connector
->dp_i2c_bus
)
1111 radeon_i2c_destroy(radeon_dig_connector
->dp_i2c_bus
);
1112 kfree(radeon_connector
->con_priv
);
1113 drm_sysfs_connector_remove(connector
);
1114 drm_connector_cleanup(connector
);
1118 static int radeon_dp_get_modes(struct drm_connector
*connector
)
1120 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1121 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1122 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1125 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1126 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1127 struct drm_display_mode
*mode
;
1129 if (!radeon_dig_connector
->edp_on
)
1130 atombios_set_edp_panel_power(connector
,
1131 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1132 ret
= radeon_ddc_get_modes(radeon_connector
);
1133 if (!radeon_dig_connector
->edp_on
)
1134 atombios_set_edp_panel_power(connector
,
1135 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1139 radeon_fixup_lvds_native_mode(encoder
, connector
);
1140 /* add scaled modes */
1141 radeon_add_common_modes(encoder
, connector
);
1146 encoder
= radeon_best_single_encoder(connector
);
1150 /* we have no EDID modes */
1151 mode
= radeon_fp_native_mode(encoder
);
1154 drm_mode_probed_add(connector
, mode
);
1155 /* add the width/height from vbios tables if available */
1156 connector
->display_info
.width_mm
= mode
->width_mm
;
1157 connector
->display_info
.height_mm
= mode
->height_mm
;
1158 /* add scaled modes */
1159 radeon_add_common_modes(encoder
, connector
);
1162 /* need to setup ddc on the bridge */
1163 if (radeon_connector_encoder_is_dp_bridge(connector
)) {
1165 radeon_atom_ext_encoder_setup_ddc(encoder
);
1167 ret
= radeon_ddc_get_modes(radeon_connector
);
1173 bool radeon_connector_encoder_is_dp_bridge(struct drm_connector
*connector
)
1175 struct drm_mode_object
*obj
;
1176 struct drm_encoder
*encoder
;
1177 struct radeon_encoder
*radeon_encoder
;
1181 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1182 if (connector
->encoder_ids
[i
] == 0)
1185 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1189 encoder
= obj_to_encoder(obj
);
1190 radeon_encoder
= to_radeon_encoder(encoder
);
1192 switch (radeon_encoder
->encoder_id
) {
1193 case ENCODER_OBJECT_ID_TRAVIS
:
1194 case ENCODER_OBJECT_ID_NUTMEG
:
1205 bool radeon_connector_encoder_is_hbr2(struct drm_connector
*connector
)
1207 struct drm_mode_object
*obj
;
1208 struct drm_encoder
*encoder
;
1209 struct radeon_encoder
*radeon_encoder
;
1213 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1214 if (connector
->encoder_ids
[i
] == 0)
1217 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1221 encoder
= obj_to_encoder(obj
);
1222 radeon_encoder
= to_radeon_encoder(encoder
);
1223 if (radeon_encoder
->caps
& ATOM_ENCODER_CAP_RECORD_HBR2
)
1230 bool radeon_connector_is_dp12_capable(struct drm_connector
*connector
)
1232 struct drm_device
*dev
= connector
->dev
;
1233 struct radeon_device
*rdev
= dev
->dev_private
;
1235 if (ASIC_IS_DCE5(rdev
) &&
1236 (rdev
->clock
.dp_extclk
>= 53900) &&
1237 radeon_connector_encoder_is_hbr2(connector
)) {
1244 static enum drm_connector_status
1245 radeon_dp_detect(struct drm_connector
*connector
, bool force
)
1247 struct drm_device
*dev
= connector
->dev
;
1248 struct radeon_device
*rdev
= dev
->dev_private
;
1249 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1250 enum drm_connector_status ret
= connector_status_disconnected
;
1251 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1252 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1254 if (radeon_connector
->edid
) {
1255 kfree(radeon_connector
->edid
);
1256 radeon_connector
->edid
= NULL
;
1259 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1260 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1262 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1263 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1265 /* check if panel is valid */
1266 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
1267 ret
= connector_status_connected
;
1269 /* eDP is always DP */
1270 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1271 if (!radeon_dig_connector
->edp_on
)
1272 atombios_set_edp_panel_power(connector
,
1273 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1274 if (radeon_dp_getdpcd(radeon_connector
))
1275 ret
= connector_status_connected
;
1276 if (!radeon_dig_connector
->edp_on
)
1277 atombios_set_edp_panel_power(connector
,
1278 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1280 /* need to setup ddc on the bridge */
1281 if (radeon_connector_encoder_is_dp_bridge(connector
)) {
1283 radeon_atom_ext_encoder_setup_ddc(encoder
);
1285 radeon_dig_connector
->dp_sink_type
= radeon_dp_getsinktype(radeon_connector
);
1286 if (radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
1287 ret
= connector_status_connected
;
1288 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
)
1289 radeon_dp_getdpcd(radeon_connector
);
1291 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
1292 if (radeon_dp_getdpcd(radeon_connector
))
1293 ret
= connector_status_connected
;
1295 if (radeon_ddc_probe(radeon_connector
,
1296 radeon_connector
->requires_extended_probe
))
1297 ret
= connector_status_connected
;
1301 if ((ret
== connector_status_disconnected
) &&
1302 radeon_connector
->dac_load_detect
) {
1303 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1304 struct drm_encoder_helper_funcs
*encoder_funcs
;
1306 encoder_funcs
= encoder
->helper_private
;
1307 ret
= encoder_funcs
->detect(encoder
, connector
);
1312 radeon_connector_update_scratch_regs(connector
, ret
);
1316 static int radeon_dp_mode_valid(struct drm_connector
*connector
,
1317 struct drm_display_mode
*mode
)
1319 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1320 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1322 /* XXX check mode bandwidth */
1324 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1325 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1326 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1328 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
1332 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1333 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1335 /* AVIVO hardware supports downscaling modes larger than the panel
1336 * to the panel size, but I'm not sure this is desirable.
1338 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
1339 (mode
->vdisplay
> native_mode
->vdisplay
))
1342 /* if scaling is disabled, block non-native modes */
1343 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
1344 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
1345 (mode
->vdisplay
!= native_mode
->vdisplay
))
1351 if ((radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
1352 (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
))
1353 return radeon_dp_mode_valid_helper(connector
, mode
);
1359 struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs
= {
1360 .get_modes
= radeon_dp_get_modes
,
1361 .mode_valid
= radeon_dp_mode_valid
,
1362 .best_encoder
= radeon_dvi_encoder
,
1365 struct drm_connector_funcs radeon_dp_connector_funcs
= {
1366 .dpms
= drm_helper_connector_dpms
,
1367 .detect
= radeon_dp_detect
,
1368 .fill_modes
= drm_helper_probe_single_connector_modes
,
1369 .set_property
= radeon_connector_set_property
,
1370 .destroy
= radeon_dp_connector_destroy
,
1371 .force
= radeon_dvi_force
,
1375 radeon_add_atom_connector(struct drm_device
*dev
,
1376 uint32_t connector_id
,
1377 uint32_t supported_device
,
1379 struct radeon_i2c_bus_rec
*i2c_bus
,
1380 uint32_t igp_lane_info
,
1381 uint16_t connector_object_id
,
1382 struct radeon_hpd
*hpd
,
1383 struct radeon_router
*router
)
1385 struct radeon_device
*rdev
= dev
->dev_private
;
1386 struct drm_connector
*connector
;
1387 struct radeon_connector
*radeon_connector
;
1388 struct radeon_connector_atom_dig
*radeon_dig_connector
;
1389 struct drm_encoder
*encoder
;
1390 struct radeon_encoder
*radeon_encoder
;
1391 uint32_t subpixel_order
= SubPixelNone
;
1392 bool shared_ddc
= false;
1393 bool is_dp_bridge
= false;
1395 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1398 /* if the user selected tv=0 don't try and add the connector */
1399 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1400 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1401 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1405 /* see if we already added it */
1406 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1407 radeon_connector
= to_radeon_connector(connector
);
1408 if (radeon_connector
->connector_id
== connector_id
) {
1409 radeon_connector
->devices
|= supported_device
;
1412 if (radeon_connector
->ddc_bus
&& i2c_bus
->valid
) {
1413 if (radeon_connector
->ddc_bus
->rec
.i2c_id
== i2c_bus
->i2c_id
) {
1414 radeon_connector
->shared_ddc
= true;
1417 if (radeon_connector
->router_bus
&& router
->ddc_valid
&&
1418 (radeon_connector
->router
.router_id
== router
->router_id
)) {
1419 radeon_connector
->shared_ddc
= false;
1425 /* check if it's a dp bridge */
1426 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
1427 radeon_encoder
= to_radeon_encoder(encoder
);
1428 if (radeon_encoder
->devices
& supported_device
) {
1429 switch (radeon_encoder
->encoder_id
) {
1430 case ENCODER_OBJECT_ID_TRAVIS
:
1431 case ENCODER_OBJECT_ID_NUTMEG
:
1432 is_dp_bridge
= true;
1440 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1441 if (!radeon_connector
)
1444 connector
= &radeon_connector
->base
;
1446 radeon_connector
->connector_id
= connector_id
;
1447 radeon_connector
->devices
= supported_device
;
1448 radeon_connector
->shared_ddc
= shared_ddc
;
1449 radeon_connector
->connector_object_id
= connector_object_id
;
1450 radeon_connector
->hpd
= *hpd
;
1451 radeon_connector
->requires_extended_probe
=
1452 radeon_connector_needs_extended_probe(rdev
, supported_device
,
1454 radeon_connector
->router
= *router
;
1455 if (router
->ddc_valid
|| router
->cd_valid
) {
1456 radeon_connector
->router_bus
= radeon_i2c_lookup(rdev
, &router
->i2c_info
);
1457 if (!radeon_connector
->router_bus
)
1458 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n");
1462 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1463 if (!radeon_dig_connector
)
1465 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1466 radeon_connector
->con_priv
= radeon_dig_connector
;
1467 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1468 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1469 if (i2c_bus
->valid
) {
1470 /* add DP i2c bus */
1471 if (connector_type
== DRM_MODE_CONNECTOR_eDP
)
1472 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1474 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1475 if (!radeon_dig_connector
->dp_i2c_bus
)
1476 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1477 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1478 if (!radeon_connector
->ddc_bus
)
1479 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1481 switch (connector_type
) {
1482 case DRM_MODE_CONNECTOR_VGA
:
1483 case DRM_MODE_CONNECTOR_DVIA
:
1485 connector
->interlace_allowed
= true;
1486 connector
->doublescan_allowed
= true;
1487 radeon_connector
->dac_load_detect
= true;
1488 drm_connector_attach_property(&radeon_connector
->base
,
1489 rdev
->mode_info
.load_detect_property
,
1492 case DRM_MODE_CONNECTOR_DVII
:
1493 case DRM_MODE_CONNECTOR_DVID
:
1494 case DRM_MODE_CONNECTOR_HDMIA
:
1495 case DRM_MODE_CONNECTOR_HDMIB
:
1496 case DRM_MODE_CONNECTOR_DisplayPort
:
1497 drm_connector_attach_property(&radeon_connector
->base
,
1498 rdev
->mode_info
.underscan_property
,
1500 drm_connector_attach_property(&radeon_connector
->base
,
1501 rdev
->mode_info
.underscan_hborder_property
,
1503 drm_connector_attach_property(&radeon_connector
->base
,
1504 rdev
->mode_info
.underscan_vborder_property
,
1506 subpixel_order
= SubPixelHorizontalRGB
;
1507 connector
->interlace_allowed
= true;
1508 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1509 connector
->doublescan_allowed
= true;
1511 connector
->doublescan_allowed
= false;
1512 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1513 radeon_connector
->dac_load_detect
= true;
1514 drm_connector_attach_property(&radeon_connector
->base
,
1515 rdev
->mode_info
.load_detect_property
,
1519 case DRM_MODE_CONNECTOR_LVDS
:
1520 case DRM_MODE_CONNECTOR_eDP
:
1521 drm_connector_attach_property(&radeon_connector
->base
,
1522 dev
->mode_config
.scaling_mode_property
,
1523 DRM_MODE_SCALE_FULLSCREEN
);
1524 subpixel_order
= SubPixelHorizontalRGB
;
1525 connector
->interlace_allowed
= false;
1526 connector
->doublescan_allowed
= false;
1530 switch (connector_type
) {
1531 case DRM_MODE_CONNECTOR_VGA
:
1532 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1533 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1534 if (i2c_bus
->valid
) {
1535 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1536 if (!radeon_connector
->ddc_bus
)
1537 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1539 radeon_connector
->dac_load_detect
= true;
1540 drm_connector_attach_property(&radeon_connector
->base
,
1541 rdev
->mode_info
.load_detect_property
,
1543 /* no HPD on analog connectors */
1544 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1545 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1546 connector
->interlace_allowed
= true;
1547 connector
->doublescan_allowed
= true;
1549 case DRM_MODE_CONNECTOR_DVIA
:
1550 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1551 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1552 if (i2c_bus
->valid
) {
1553 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1554 if (!radeon_connector
->ddc_bus
)
1555 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1557 radeon_connector
->dac_load_detect
= true;
1558 drm_connector_attach_property(&radeon_connector
->base
,
1559 rdev
->mode_info
.load_detect_property
,
1561 /* no HPD on analog connectors */
1562 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1563 connector
->interlace_allowed
= true;
1564 connector
->doublescan_allowed
= true;
1566 case DRM_MODE_CONNECTOR_DVII
:
1567 case DRM_MODE_CONNECTOR_DVID
:
1568 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1569 if (!radeon_dig_connector
)
1571 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1572 radeon_connector
->con_priv
= radeon_dig_connector
;
1573 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1574 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1575 if (i2c_bus
->valid
) {
1576 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1577 if (!radeon_connector
->ddc_bus
)
1578 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1580 subpixel_order
= SubPixelHorizontalRGB
;
1581 drm_connector_attach_property(&radeon_connector
->base
,
1582 rdev
->mode_info
.coherent_mode_property
,
1584 if (ASIC_IS_AVIVO(rdev
)) {
1585 drm_connector_attach_property(&radeon_connector
->base
,
1586 rdev
->mode_info
.underscan_property
,
1588 drm_connector_attach_property(&radeon_connector
->base
,
1589 rdev
->mode_info
.underscan_hborder_property
,
1591 drm_connector_attach_property(&radeon_connector
->base
,
1592 rdev
->mode_info
.underscan_vborder_property
,
1595 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1596 radeon_connector
->dac_load_detect
= true;
1597 drm_connector_attach_property(&radeon_connector
->base
,
1598 rdev
->mode_info
.load_detect_property
,
1601 connector
->interlace_allowed
= true;
1602 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
1603 connector
->doublescan_allowed
= true;
1605 connector
->doublescan_allowed
= false;
1607 case DRM_MODE_CONNECTOR_HDMIA
:
1608 case DRM_MODE_CONNECTOR_HDMIB
:
1609 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1610 if (!radeon_dig_connector
)
1612 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1613 radeon_connector
->con_priv
= radeon_dig_connector
;
1614 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1615 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1616 if (i2c_bus
->valid
) {
1617 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1618 if (!radeon_connector
->ddc_bus
)
1619 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1621 drm_connector_attach_property(&radeon_connector
->base
,
1622 rdev
->mode_info
.coherent_mode_property
,
1624 if (ASIC_IS_AVIVO(rdev
)) {
1625 drm_connector_attach_property(&radeon_connector
->base
,
1626 rdev
->mode_info
.underscan_property
,
1628 drm_connector_attach_property(&radeon_connector
->base
,
1629 rdev
->mode_info
.underscan_hborder_property
,
1631 drm_connector_attach_property(&radeon_connector
->base
,
1632 rdev
->mode_info
.underscan_vborder_property
,
1635 subpixel_order
= SubPixelHorizontalRGB
;
1636 connector
->interlace_allowed
= true;
1637 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1638 connector
->doublescan_allowed
= true;
1640 connector
->doublescan_allowed
= false;
1642 case DRM_MODE_CONNECTOR_DisplayPort
:
1643 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1644 if (!radeon_dig_connector
)
1646 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1647 radeon_connector
->con_priv
= radeon_dig_connector
;
1648 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1649 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1650 if (i2c_bus
->valid
) {
1651 /* add DP i2c bus */
1652 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1653 if (!radeon_dig_connector
->dp_i2c_bus
)
1654 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1655 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1656 if (!radeon_connector
->ddc_bus
)
1657 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1659 subpixel_order
= SubPixelHorizontalRGB
;
1660 drm_connector_attach_property(&radeon_connector
->base
,
1661 rdev
->mode_info
.coherent_mode_property
,
1663 if (ASIC_IS_AVIVO(rdev
)) {
1664 drm_connector_attach_property(&radeon_connector
->base
,
1665 rdev
->mode_info
.underscan_property
,
1667 drm_connector_attach_property(&radeon_connector
->base
,
1668 rdev
->mode_info
.underscan_hborder_property
,
1670 drm_connector_attach_property(&radeon_connector
->base
,
1671 rdev
->mode_info
.underscan_vborder_property
,
1674 connector
->interlace_allowed
= true;
1675 /* in theory with a DP to VGA converter... */
1676 connector
->doublescan_allowed
= false;
1678 case DRM_MODE_CONNECTOR_eDP
:
1679 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1680 if (!radeon_dig_connector
)
1682 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1683 radeon_connector
->con_priv
= radeon_dig_connector
;
1684 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1685 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1686 if (i2c_bus
->valid
) {
1687 /* add DP i2c bus */
1688 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1689 if (!radeon_dig_connector
->dp_i2c_bus
)
1690 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1691 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1692 if (!radeon_connector
->ddc_bus
)
1693 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1695 drm_connector_attach_property(&radeon_connector
->base
,
1696 dev
->mode_config
.scaling_mode_property
,
1697 DRM_MODE_SCALE_FULLSCREEN
);
1698 subpixel_order
= SubPixelHorizontalRGB
;
1699 connector
->interlace_allowed
= false;
1700 connector
->doublescan_allowed
= false;
1702 case DRM_MODE_CONNECTOR_SVIDEO
:
1703 case DRM_MODE_CONNECTOR_Composite
:
1704 case DRM_MODE_CONNECTOR_9PinDIN
:
1705 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1706 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1707 radeon_connector
->dac_load_detect
= true;
1708 drm_connector_attach_property(&radeon_connector
->base
,
1709 rdev
->mode_info
.load_detect_property
,
1711 drm_connector_attach_property(&radeon_connector
->base
,
1712 rdev
->mode_info
.tv_std_property
,
1713 radeon_atombios_get_tv_info(rdev
));
1714 /* no HPD on analog connectors */
1715 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1716 connector
->interlace_allowed
= false;
1717 connector
->doublescan_allowed
= false;
1719 case DRM_MODE_CONNECTOR_LVDS
:
1720 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1721 if (!radeon_dig_connector
)
1723 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1724 radeon_connector
->con_priv
= radeon_dig_connector
;
1725 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1726 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1727 if (i2c_bus
->valid
) {
1728 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1729 if (!radeon_connector
->ddc_bus
)
1730 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1732 drm_connector_attach_property(&radeon_connector
->base
,
1733 dev
->mode_config
.scaling_mode_property
,
1734 DRM_MODE_SCALE_FULLSCREEN
);
1735 subpixel_order
= SubPixelHorizontalRGB
;
1736 connector
->interlace_allowed
= false;
1737 connector
->doublescan_allowed
= false;
1742 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
1744 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1746 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
1748 connector
->display_info
.subpixel_order
= subpixel_order
;
1749 drm_sysfs_connector_add(connector
);
1753 drm_connector_cleanup(connector
);
1758 radeon_add_legacy_connector(struct drm_device
*dev
,
1759 uint32_t connector_id
,
1760 uint32_t supported_device
,
1762 struct radeon_i2c_bus_rec
*i2c_bus
,
1763 uint16_t connector_object_id
,
1764 struct radeon_hpd
*hpd
)
1766 struct radeon_device
*rdev
= dev
->dev_private
;
1767 struct drm_connector
*connector
;
1768 struct radeon_connector
*radeon_connector
;
1769 uint32_t subpixel_order
= SubPixelNone
;
1771 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1774 /* if the user selected tv=0 don't try and add the connector */
1775 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1776 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1777 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1781 /* see if we already added it */
1782 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1783 radeon_connector
= to_radeon_connector(connector
);
1784 if (radeon_connector
->connector_id
== connector_id
) {
1785 radeon_connector
->devices
|= supported_device
;
1790 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1791 if (!radeon_connector
)
1794 connector
= &radeon_connector
->base
;
1796 radeon_connector
->connector_id
= connector_id
;
1797 radeon_connector
->devices
= supported_device
;
1798 radeon_connector
->connector_object_id
= connector_object_id
;
1799 radeon_connector
->hpd
= *hpd
;
1800 radeon_connector
->requires_extended_probe
=
1801 radeon_connector_needs_extended_probe(rdev
, supported_device
,
1803 switch (connector_type
) {
1804 case DRM_MODE_CONNECTOR_VGA
:
1805 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1806 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1807 if (i2c_bus
->valid
) {
1808 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1809 if (!radeon_connector
->ddc_bus
)
1810 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1812 radeon_connector
->dac_load_detect
= true;
1813 drm_connector_attach_property(&radeon_connector
->base
,
1814 rdev
->mode_info
.load_detect_property
,
1816 /* no HPD on analog connectors */
1817 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1818 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1819 connector
->interlace_allowed
= true;
1820 connector
->doublescan_allowed
= true;
1822 case DRM_MODE_CONNECTOR_DVIA
:
1823 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1824 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1825 if (i2c_bus
->valid
) {
1826 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1827 if (!radeon_connector
->ddc_bus
)
1828 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1830 radeon_connector
->dac_load_detect
= true;
1831 drm_connector_attach_property(&radeon_connector
->base
,
1832 rdev
->mode_info
.load_detect_property
,
1834 /* no HPD on analog connectors */
1835 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1836 connector
->interlace_allowed
= true;
1837 connector
->doublescan_allowed
= true;
1839 case DRM_MODE_CONNECTOR_DVII
:
1840 case DRM_MODE_CONNECTOR_DVID
:
1841 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1842 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1843 if (i2c_bus
->valid
) {
1844 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1845 if (!radeon_connector
->ddc_bus
)
1846 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1848 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1849 radeon_connector
->dac_load_detect
= true;
1850 drm_connector_attach_property(&radeon_connector
->base
,
1851 rdev
->mode_info
.load_detect_property
,
1854 subpixel_order
= SubPixelHorizontalRGB
;
1855 connector
->interlace_allowed
= true;
1856 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
1857 connector
->doublescan_allowed
= true;
1859 connector
->doublescan_allowed
= false;
1861 case DRM_MODE_CONNECTOR_SVIDEO
:
1862 case DRM_MODE_CONNECTOR_Composite
:
1863 case DRM_MODE_CONNECTOR_9PinDIN
:
1864 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1865 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1866 radeon_connector
->dac_load_detect
= true;
1867 /* RS400,RC410,RS480 chipset seems to report a lot
1868 * of false positive on load detect, we haven't yet
1869 * found a way to make load detect reliable on those
1870 * chipset, thus just disable it for TV.
1872 if (rdev
->family
== CHIP_RS400
|| rdev
->family
== CHIP_RS480
)
1873 radeon_connector
->dac_load_detect
= false;
1874 drm_connector_attach_property(&radeon_connector
->base
,
1875 rdev
->mode_info
.load_detect_property
,
1876 radeon_connector
->dac_load_detect
);
1877 drm_connector_attach_property(&radeon_connector
->base
,
1878 rdev
->mode_info
.tv_std_property
,
1879 radeon_combios_get_tv_info(rdev
));
1880 /* no HPD on analog connectors */
1881 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1882 connector
->interlace_allowed
= false;
1883 connector
->doublescan_allowed
= false;
1885 case DRM_MODE_CONNECTOR_LVDS
:
1886 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1887 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1888 if (i2c_bus
->valid
) {
1889 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1890 if (!radeon_connector
->ddc_bus
)
1891 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1893 drm_connector_attach_property(&radeon_connector
->base
,
1894 dev
->mode_config
.scaling_mode_property
,
1895 DRM_MODE_SCALE_FULLSCREEN
);
1896 subpixel_order
= SubPixelHorizontalRGB
;
1897 connector
->interlace_allowed
= false;
1898 connector
->doublescan_allowed
= false;
1902 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
1904 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1906 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
1907 connector
->display_info
.subpixel_order
= subpixel_order
;
1908 drm_sysfs_connector_add(connector
);
1909 if (connector_type
== DRM_MODE_CONNECTOR_LVDS
) {
1910 struct drm_encoder
*drm_encoder
;
1912 list_for_each_entry(drm_encoder
, &dev
->mode_config
.encoder_list
, head
) {
1913 struct radeon_encoder
*radeon_encoder
;
1915 radeon_encoder
= to_radeon_encoder(drm_encoder
);
1916 if (radeon_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_LVDS
)
1917 radeon_legacy_backlight_init(radeon_encoder
, connector
);