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 /* if the connector is already off, don't turn it back on */
64 if (connector
->dpms
!= DRM_MODE_DPMS_ON
)
67 /* just deal with DP (not eDP) here. */
68 if (connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
) {
69 int saved_dpms
= connector
->dpms
;
71 /* Only turn off the display it it's physically disconnected */
72 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
))
73 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_OFF
);
74 else if (radeon_dp_needs_link_train(radeon_connector
))
75 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_ON
);
76 connector
->dpms
= saved_dpms
;
80 static void radeon_property_change_mode(struct drm_encoder
*encoder
)
82 struct drm_crtc
*crtc
= encoder
->crtc
;
84 if (crtc
&& crtc
->enabled
) {
85 drm_crtc_helper_set_mode(crtc
, &crtc
->mode
,
86 crtc
->x
, crtc
->y
, crtc
->fb
);
90 radeon_connector_update_scratch_regs(struct drm_connector
*connector
, enum drm_connector_status status
)
92 struct drm_device
*dev
= connector
->dev
;
93 struct radeon_device
*rdev
= dev
->dev_private
;
94 struct drm_encoder
*best_encoder
= NULL
;
95 struct drm_encoder
*encoder
= NULL
;
96 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
97 struct drm_mode_object
*obj
;
101 best_encoder
= connector_funcs
->best_encoder(connector
);
103 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
104 if (connector
->encoder_ids
[i
] == 0)
107 obj
= drm_mode_object_find(connector
->dev
,
108 connector
->encoder_ids
[i
],
109 DRM_MODE_OBJECT_ENCODER
);
113 encoder
= obj_to_encoder(obj
);
115 if ((encoder
== best_encoder
) && (status
== connector_status_connected
))
120 if (rdev
->is_atom_bios
)
121 radeon_atombios_connected_scratch_regs(connector
, encoder
, connected
);
123 radeon_combios_connected_scratch_regs(connector
, encoder
, connected
);
128 struct drm_encoder
*radeon_find_encoder(struct drm_connector
*connector
, int encoder_type
)
130 struct drm_mode_object
*obj
;
131 struct drm_encoder
*encoder
;
134 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
135 if (connector
->encoder_ids
[i
] == 0)
138 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
142 encoder
= obj_to_encoder(obj
);
143 if (encoder
->encoder_type
== encoder_type
)
149 struct drm_encoder
*radeon_best_single_encoder(struct drm_connector
*connector
)
151 int enc_id
= connector
->encoder_ids
[0];
152 struct drm_mode_object
*obj
;
153 struct drm_encoder
*encoder
;
155 /* pick the encoder ids */
157 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
160 encoder
= obj_to_encoder(obj
);
167 * radeon_connector_analog_encoder_conflict_solve
168 * - search for other connectors sharing this encoder
169 * if priority is true, then set them disconnected if this is connected
170 * if priority is false, set us disconnected if they are connected
172 static enum drm_connector_status
173 radeon_connector_analog_encoder_conflict_solve(struct drm_connector
*connector
,
174 struct drm_encoder
*encoder
,
175 enum drm_connector_status current_status
,
178 struct drm_device
*dev
= connector
->dev
;
179 struct drm_connector
*conflict
;
180 struct radeon_connector
*radeon_conflict
;
183 list_for_each_entry(conflict
, &dev
->mode_config
.connector_list
, head
) {
184 if (conflict
== connector
)
187 radeon_conflict
= to_radeon_connector(conflict
);
188 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
189 if (conflict
->encoder_ids
[i
] == 0)
192 /* if the IDs match */
193 if (conflict
->encoder_ids
[i
] == encoder
->base
.id
) {
194 if (conflict
->status
!= connector_status_connected
)
197 if (radeon_conflict
->use_digital
)
200 if (priority
== true) {
201 DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict
));
202 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(connector
));
203 conflict
->status
= connector_status_disconnected
;
204 radeon_connector_update_scratch_regs(conflict
, connector_status_disconnected
);
206 DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector
));
207 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(conflict
));
208 current_status
= connector_status_disconnected
;
214 return current_status
;
218 static struct drm_display_mode
*radeon_fp_native_mode(struct drm_encoder
*encoder
)
220 struct drm_device
*dev
= encoder
->dev
;
221 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
222 struct drm_display_mode
*mode
= NULL
;
223 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
225 if (native_mode
->hdisplay
!= 0 &&
226 native_mode
->vdisplay
!= 0 &&
227 native_mode
->clock
!= 0) {
228 mode
= drm_mode_duplicate(dev
, native_mode
);
229 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
230 drm_mode_set_name(mode
);
232 DRM_DEBUG_KMS("Adding native panel mode %s\n", mode
->name
);
233 } else if (native_mode
->hdisplay
!= 0 &&
234 native_mode
->vdisplay
!= 0) {
235 /* mac laptops without an edid */
236 /* Note that this is not necessarily the exact panel mode,
237 * but an approximation based on the cvt formula. For these
238 * systems we should ideally read the mode info out of the
239 * registers or add a mode table, but this works and is much
242 mode
= drm_cvt_mode(dev
, native_mode
->hdisplay
, native_mode
->vdisplay
, 60, true, false, false);
243 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
244 DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode
->name
);
249 static void radeon_add_common_modes(struct drm_encoder
*encoder
, struct drm_connector
*connector
)
251 struct drm_device
*dev
= encoder
->dev
;
252 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
253 struct drm_display_mode
*mode
= NULL
;
254 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
259 } common_modes
[17] = {
279 for (i
= 0; i
< 17; i
++) {
280 if (radeon_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
)) {
281 if (common_modes
[i
].w
> 1024 ||
282 common_modes
[i
].h
> 768)
285 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
286 if (common_modes
[i
].w
> native_mode
->hdisplay
||
287 common_modes
[i
].h
> native_mode
->vdisplay
||
288 (common_modes
[i
].w
== native_mode
->hdisplay
&&
289 common_modes
[i
].h
== native_mode
->vdisplay
))
292 if (common_modes
[i
].w
< 320 || common_modes
[i
].h
< 200)
295 mode
= drm_cvt_mode(dev
, common_modes
[i
].w
, common_modes
[i
].h
, 60, false, false, false);
296 drm_mode_probed_add(connector
, mode
);
300 int radeon_connector_set_property(struct drm_connector
*connector
, struct drm_property
*property
,
303 struct drm_device
*dev
= connector
->dev
;
304 struct radeon_device
*rdev
= dev
->dev_private
;
305 struct drm_encoder
*encoder
;
306 struct radeon_encoder
*radeon_encoder
;
308 if (property
== rdev
->mode_info
.coherent_mode_property
) {
309 struct radeon_encoder_atom_dig
*dig
;
310 bool new_coherent_mode
;
312 /* need to find digital encoder on connector */
313 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
317 radeon_encoder
= to_radeon_encoder(encoder
);
319 if (!radeon_encoder
->enc_priv
)
322 dig
= radeon_encoder
->enc_priv
;
323 new_coherent_mode
= val
? true : false;
324 if (dig
->coherent_mode
!= new_coherent_mode
) {
325 dig
->coherent_mode
= new_coherent_mode
;
326 radeon_property_change_mode(&radeon_encoder
->base
);
330 if (property
== rdev
->mode_info
.underscan_property
) {
331 /* need to find digital encoder on connector */
332 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
336 radeon_encoder
= to_radeon_encoder(encoder
);
338 if (radeon_encoder
->underscan_type
!= val
) {
339 radeon_encoder
->underscan_type
= val
;
340 radeon_property_change_mode(&radeon_encoder
->base
);
344 if (property
== rdev
->mode_info
.underscan_hborder_property
) {
345 /* need to find digital encoder on connector */
346 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
350 radeon_encoder
= to_radeon_encoder(encoder
);
352 if (radeon_encoder
->underscan_hborder
!= val
) {
353 radeon_encoder
->underscan_hborder
= val
;
354 radeon_property_change_mode(&radeon_encoder
->base
);
358 if (property
== rdev
->mode_info
.underscan_vborder_property
) {
359 /* need to find digital encoder on connector */
360 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
364 radeon_encoder
= to_radeon_encoder(encoder
);
366 if (radeon_encoder
->underscan_vborder
!= val
) {
367 radeon_encoder
->underscan_vborder
= val
;
368 radeon_property_change_mode(&radeon_encoder
->base
);
372 if (property
== rdev
->mode_info
.tv_std_property
) {
373 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TVDAC
);
375 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_DAC
);
381 radeon_encoder
= to_radeon_encoder(encoder
);
382 if (!radeon_encoder
->enc_priv
)
384 if (ASIC_IS_AVIVO(rdev
) || radeon_r4xx_atom
) {
385 struct radeon_encoder_atom_dac
*dac_int
;
386 dac_int
= radeon_encoder
->enc_priv
;
387 dac_int
->tv_std
= val
;
389 struct radeon_encoder_tv_dac
*dac_int
;
390 dac_int
= radeon_encoder
->enc_priv
;
391 dac_int
->tv_std
= val
;
393 radeon_property_change_mode(&radeon_encoder
->base
);
396 if (property
== rdev
->mode_info
.load_detect_property
) {
397 struct radeon_connector
*radeon_connector
=
398 to_radeon_connector(connector
);
401 radeon_connector
->dac_load_detect
= false;
403 radeon_connector
->dac_load_detect
= true;
406 if (property
== rdev
->mode_info
.tmds_pll_property
) {
407 struct radeon_encoder_int_tmds
*tmds
= NULL
;
409 /* need to find digital encoder on connector */
410 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
414 radeon_encoder
= to_radeon_encoder(encoder
);
416 tmds
= radeon_encoder
->enc_priv
;
421 if (rdev
->is_atom_bios
)
422 ret
= radeon_atombios_get_tmds_info(radeon_encoder
, tmds
);
424 ret
= radeon_legacy_get_tmds_info_from_combios(radeon_encoder
, tmds
);
426 if (val
== 1 || ret
== false) {
427 radeon_legacy_get_tmds_info_from_table(radeon_encoder
, tmds
);
429 radeon_property_change_mode(&radeon_encoder
->base
);
436 * Some integrated ATI Radeon chipset implementations (e. g.
437 * Asus M2A-VM HDMI) may indicate the availability of a DDC,
438 * even when there's no monitor connected. For these connectors
439 * following DDC probe extension will be applied: check also for the
440 * availability of EDID with at least a correct EDID header. Only then,
441 * DDC is assumed to be available. This prevents drm_get_edid() and
442 * drm_edid_block_valid() from periodically dumping data and kernel
443 * errors into the logs and onto the terminal.
445 static bool radeon_connector_needs_extended_probe(struct radeon_device
*dev
,
446 uint32_t supported_device
,
449 /* Asus M2A-VM HDMI board sends data to i2c bus even,
450 * if HDMI add-on card is not plugged in or HDMI is disabled in
451 * BIOS. Valid DDC can only be assumed, if also a valid EDID header
452 * can be retrieved via i2c bus during DDC probe */
453 if ((dev
->pdev
->device
== 0x791e) &&
454 (dev
->pdev
->subsystem_vendor
== 0x1043) &&
455 (dev
->pdev
->subsystem_device
== 0x826d)) {
456 if ((connector_type
== DRM_MODE_CONNECTOR_HDMIA
) &&
457 (supported_device
== ATOM_DEVICE_DFP2_SUPPORT
))
460 /* ECS A740GM-M with ATI RADEON 2100 sends data to i2c bus
461 * for a DVI connector that is not implemented */
462 if ((dev
->pdev
->device
== 0x796e) &&
463 (dev
->pdev
->subsystem_vendor
== 0x1019) &&
464 (dev
->pdev
->subsystem_device
== 0x2615)) {
465 if ((connector_type
== DRM_MODE_CONNECTOR_DVID
) &&
466 (supported_device
== ATOM_DEVICE_DFP2_SUPPORT
))
469 /* TOSHIBA Satellite L300D with ATI Mobility Radeon x1100
470 * (RS690M) sends data to i2c bus for a HDMI connector that
471 * is not implemented */
472 if ((dev
->pdev
->device
== 0x791f) &&
473 (dev
->pdev
->subsystem_vendor
== 0x1179) &&
474 (dev
->pdev
->subsystem_device
== 0xff68)) {
475 if ((connector_type
== DRM_MODE_CONNECTOR_HDMIA
) &&
476 (supported_device
== ATOM_DEVICE_DFP2_SUPPORT
))
480 /* Default: no EDID header probe required for DDC probing */
484 static void radeon_fixup_lvds_native_mode(struct drm_encoder
*encoder
,
485 struct drm_connector
*connector
)
487 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
488 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
489 struct drm_display_mode
*t
, *mode
;
491 /* If the EDID preferred mode doesn't match the native mode, use it */
492 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
493 if (mode
->type
& DRM_MODE_TYPE_PREFERRED
) {
494 if (mode
->hdisplay
!= native_mode
->hdisplay
||
495 mode
->vdisplay
!= native_mode
->vdisplay
)
496 memcpy(native_mode
, mode
, sizeof(*mode
));
500 /* Try to get native mode details from EDID if necessary */
501 if (!native_mode
->clock
) {
502 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
503 if (mode
->hdisplay
== native_mode
->hdisplay
&&
504 mode
->vdisplay
== native_mode
->vdisplay
) {
505 *native_mode
= *mode
;
506 drm_mode_set_crtcinfo(native_mode
, CRTC_INTERLACE_HALVE_V
);
507 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
513 if (!native_mode
->clock
) {
514 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n");
515 radeon_encoder
->rmx_type
= RMX_OFF
;
519 static int radeon_lvds_get_modes(struct drm_connector
*connector
)
521 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
522 struct drm_encoder
*encoder
;
524 struct drm_display_mode
*mode
;
526 if (radeon_connector
->ddc_bus
) {
527 ret
= radeon_ddc_get_modes(radeon_connector
);
529 encoder
= radeon_best_single_encoder(connector
);
531 radeon_fixup_lvds_native_mode(encoder
, connector
);
532 /* add scaled modes */
533 radeon_add_common_modes(encoder
, connector
);
539 encoder
= radeon_best_single_encoder(connector
);
543 /* we have no EDID modes */
544 mode
= radeon_fp_native_mode(encoder
);
547 drm_mode_probed_add(connector
, mode
);
548 /* add the width/height from vbios tables if available */
549 connector
->display_info
.width_mm
= mode
->width_mm
;
550 connector
->display_info
.height_mm
= mode
->height_mm
;
551 /* add scaled modes */
552 radeon_add_common_modes(encoder
, connector
);
558 static int radeon_lvds_mode_valid(struct drm_connector
*connector
,
559 struct drm_display_mode
*mode
)
561 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
563 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
567 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
568 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
570 /* AVIVO hardware supports downscaling modes larger than the panel
571 * to the panel size, but I'm not sure this is desirable.
573 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
574 (mode
->vdisplay
> native_mode
->vdisplay
))
577 /* if scaling is disabled, block non-native modes */
578 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
579 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
580 (mode
->vdisplay
!= native_mode
->vdisplay
))
588 static enum drm_connector_status
589 radeon_lvds_detect(struct drm_connector
*connector
, bool force
)
591 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
592 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
593 enum drm_connector_status ret
= connector_status_disconnected
;
596 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
597 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
599 /* check if panel is valid */
600 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
601 ret
= connector_status_connected
;
605 /* check for edid as well */
606 if (radeon_connector
->edid
)
607 ret
= connector_status_connected
;
609 if (radeon_connector
->ddc_bus
) {
610 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
,
611 &radeon_connector
->ddc_bus
->adapter
);
612 if (radeon_connector
->edid
)
613 ret
= connector_status_connected
;
616 /* check acpi lid status ??? */
618 radeon_connector_update_scratch_regs(connector
, ret
);
622 static void radeon_connector_destroy(struct drm_connector
*connector
)
624 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
626 if (radeon_connector
->edid
)
627 kfree(radeon_connector
->edid
);
628 kfree(radeon_connector
->con_priv
);
629 drm_sysfs_connector_remove(connector
);
630 drm_connector_cleanup(connector
);
634 static int radeon_lvds_set_property(struct drm_connector
*connector
,
635 struct drm_property
*property
,
638 struct drm_device
*dev
= connector
->dev
;
639 struct radeon_encoder
*radeon_encoder
;
640 enum radeon_rmx_type rmx_type
;
643 if (property
!= dev
->mode_config
.scaling_mode_property
)
646 if (connector
->encoder
)
647 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
649 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
650 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
654 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
655 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
656 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
658 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
660 if (radeon_encoder
->rmx_type
== rmx_type
)
663 radeon_encoder
->rmx_type
= rmx_type
;
665 radeon_property_change_mode(&radeon_encoder
->base
);
670 struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs
= {
671 .get_modes
= radeon_lvds_get_modes
,
672 .mode_valid
= radeon_lvds_mode_valid
,
673 .best_encoder
= radeon_best_single_encoder
,
676 struct drm_connector_funcs radeon_lvds_connector_funcs
= {
677 .dpms
= drm_helper_connector_dpms
,
678 .detect
= radeon_lvds_detect
,
679 .fill_modes
= drm_helper_probe_single_connector_modes
,
680 .destroy
= radeon_connector_destroy
,
681 .set_property
= radeon_lvds_set_property
,
684 static int radeon_vga_get_modes(struct drm_connector
*connector
)
686 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
689 ret
= radeon_ddc_get_modes(radeon_connector
);
694 static int radeon_vga_mode_valid(struct drm_connector
*connector
,
695 struct drm_display_mode
*mode
)
697 struct drm_device
*dev
= connector
->dev
;
698 struct radeon_device
*rdev
= dev
->dev_private
;
700 /* XXX check mode bandwidth */
702 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
703 return MODE_CLOCK_HIGH
;
708 static enum drm_connector_status
709 radeon_vga_detect(struct drm_connector
*connector
, bool force
)
711 struct drm_device
*dev
= connector
->dev
;
712 struct radeon_device
*rdev
= dev
->dev_private
;
713 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
714 struct drm_encoder
*encoder
;
715 struct drm_encoder_helper_funcs
*encoder_funcs
;
717 enum drm_connector_status ret
= connector_status_disconnected
;
719 encoder
= radeon_best_single_encoder(connector
);
721 ret
= connector_status_disconnected
;
723 if (radeon_connector
->ddc_bus
)
724 dret
= radeon_ddc_probe(radeon_connector
,
725 radeon_connector
->requires_extended_probe
);
727 if (radeon_connector
->edid
) {
728 kfree(radeon_connector
->edid
);
729 radeon_connector
->edid
= NULL
;
731 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
733 if (!radeon_connector
->edid
) {
734 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
735 drm_get_connector_name(connector
));
736 ret
= connector_status_connected
;
738 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
740 /* some oems have boards with separate digital and analog connectors
741 * with a shared ddc line (often vga + hdmi)
743 if (radeon_connector
->use_digital
&& radeon_connector
->shared_ddc
) {
744 kfree(radeon_connector
->edid
);
745 radeon_connector
->edid
= NULL
;
746 ret
= connector_status_disconnected
;
748 ret
= connector_status_connected
;
752 /* if we aren't forcing don't do destructive polling */
754 return connector
->status
;
756 if (radeon_connector
->dac_load_detect
&& encoder
) {
757 encoder_funcs
= encoder
->helper_private
;
758 ret
= encoder_funcs
->detect(encoder
, connector
);
762 if (ret
== connector_status_connected
)
763 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
765 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
766 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
767 * by other means, assume the CRT is connected and use that EDID.
769 if ((!rdev
->is_atom_bios
) &&
770 (ret
== connector_status_disconnected
) &&
771 rdev
->mode_info
.bios_hardcoded_edid_size
) {
772 ret
= connector_status_connected
;
775 radeon_connector_update_scratch_regs(connector
, ret
);
779 struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs
= {
780 .get_modes
= radeon_vga_get_modes
,
781 .mode_valid
= radeon_vga_mode_valid
,
782 .best_encoder
= radeon_best_single_encoder
,
785 struct drm_connector_funcs radeon_vga_connector_funcs
= {
786 .dpms
= drm_helper_connector_dpms
,
787 .detect
= radeon_vga_detect
,
788 .fill_modes
= drm_helper_probe_single_connector_modes
,
789 .destroy
= radeon_connector_destroy
,
790 .set_property
= radeon_connector_set_property
,
793 static int radeon_tv_get_modes(struct drm_connector
*connector
)
795 struct drm_device
*dev
= connector
->dev
;
796 struct radeon_device
*rdev
= dev
->dev_private
;
797 struct drm_display_mode
*tv_mode
;
798 struct drm_encoder
*encoder
;
800 encoder
= radeon_best_single_encoder(connector
);
804 /* avivo chips can scale any mode */
805 if (rdev
->family
>= CHIP_RS600
)
806 /* add scaled modes */
807 radeon_add_common_modes(encoder
, connector
);
809 /* only 800x600 is supported right now on pre-avivo chips */
810 tv_mode
= drm_cvt_mode(dev
, 800, 600, 60, false, false, false);
811 tv_mode
->type
= DRM_MODE_TYPE_DRIVER
| DRM_MODE_TYPE_PREFERRED
;
812 drm_mode_probed_add(connector
, tv_mode
);
817 static int radeon_tv_mode_valid(struct drm_connector
*connector
,
818 struct drm_display_mode
*mode
)
820 if ((mode
->hdisplay
> 1024) || (mode
->vdisplay
> 768))
821 return MODE_CLOCK_RANGE
;
825 static enum drm_connector_status
826 radeon_tv_detect(struct drm_connector
*connector
, bool force
)
828 struct drm_encoder
*encoder
;
829 struct drm_encoder_helper_funcs
*encoder_funcs
;
830 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
831 enum drm_connector_status ret
= connector_status_disconnected
;
833 if (!radeon_connector
->dac_load_detect
)
836 encoder
= radeon_best_single_encoder(connector
);
838 ret
= connector_status_disconnected
;
840 encoder_funcs
= encoder
->helper_private
;
841 ret
= encoder_funcs
->detect(encoder
, connector
);
843 if (ret
== connector_status_connected
)
844 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, false);
845 radeon_connector_update_scratch_regs(connector
, ret
);
849 struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs
= {
850 .get_modes
= radeon_tv_get_modes
,
851 .mode_valid
= radeon_tv_mode_valid
,
852 .best_encoder
= radeon_best_single_encoder
,
855 struct drm_connector_funcs radeon_tv_connector_funcs
= {
856 .dpms
= drm_helper_connector_dpms
,
857 .detect
= radeon_tv_detect
,
858 .fill_modes
= drm_helper_probe_single_connector_modes
,
859 .destroy
= radeon_connector_destroy
,
860 .set_property
= radeon_connector_set_property
,
863 static int radeon_dvi_get_modes(struct drm_connector
*connector
)
865 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
868 ret
= radeon_ddc_get_modes(radeon_connector
);
874 * Do a DDC probe, if DDC probe passes, get the full EDID so
875 * we can do analog/digital monitor detection at this point.
876 * If the monitor is an analog monitor or we got no DDC,
877 * we need to find the DAC encoder object for this connector.
878 * If we got no DDC, we do load detection on the DAC encoder object.
879 * If we got analog DDC or load detection passes on the DAC encoder
880 * we have to check if this analog encoder is shared with anyone else (TV)
881 * if its shared we have to set the other connector to disconnected.
883 static enum drm_connector_status
884 radeon_dvi_detect(struct drm_connector
*connector
, bool force
)
886 struct drm_device
*dev
= connector
->dev
;
887 struct radeon_device
*rdev
= dev
->dev_private
;
888 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
889 struct drm_encoder
*encoder
= NULL
;
890 struct drm_encoder_helper_funcs
*encoder_funcs
;
891 struct drm_mode_object
*obj
;
893 enum drm_connector_status ret
= connector_status_disconnected
;
896 if (radeon_connector
->ddc_bus
)
897 dret
= radeon_ddc_probe(radeon_connector
,
898 radeon_connector
->requires_extended_probe
);
900 if (radeon_connector
->edid
) {
901 kfree(radeon_connector
->edid
);
902 radeon_connector
->edid
= NULL
;
904 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
906 if (!radeon_connector
->edid
) {
907 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
908 drm_get_connector_name(connector
));
909 /* rs690 seems to have a problem with connectors not existing and always
910 * return a block of 0's. If we see this just stop polling on this output */
911 if ((rdev
->family
== CHIP_RS690
|| rdev
->family
== CHIP_RS740
) && radeon_connector
->base
.null_edid_counter
) {
912 ret
= connector_status_disconnected
;
913 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", drm_get_connector_name(connector
));
914 radeon_connector
->ddc_bus
= NULL
;
917 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
919 /* some oems have boards with separate digital and analog connectors
920 * with a shared ddc line (often vga + hdmi)
922 if ((!radeon_connector
->use_digital
) && radeon_connector
->shared_ddc
) {
923 kfree(radeon_connector
->edid
);
924 radeon_connector
->edid
= NULL
;
925 ret
= connector_status_disconnected
;
927 ret
= connector_status_connected
;
929 /* This gets complicated. We have boards with VGA + HDMI with a
930 * shared DDC line and we have boards with DVI-D + HDMI with a shared
931 * DDC line. The latter is more complex because with DVI<->HDMI adapters
932 * you don't really know what's connected to which port as both are digital.
934 if (radeon_connector
->shared_ddc
&& (ret
== connector_status_connected
)) {
935 struct drm_connector
*list_connector
;
936 struct radeon_connector
*list_radeon_connector
;
937 list_for_each_entry(list_connector
, &dev
->mode_config
.connector_list
, head
) {
938 if (connector
== list_connector
)
940 list_radeon_connector
= to_radeon_connector(list_connector
);
941 if (list_radeon_connector
->shared_ddc
&&
942 (list_radeon_connector
->ddc_bus
->rec
.i2c_id
==
943 radeon_connector
->ddc_bus
->rec
.i2c_id
)) {
944 /* cases where both connectors are digital */
945 if (list_connector
->connector_type
!= DRM_MODE_CONNECTOR_VGA
) {
946 /* hpd is our only option in this case */
947 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
948 kfree(radeon_connector
->edid
);
949 radeon_connector
->edid
= NULL
;
950 ret
= connector_status_disconnected
;
959 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== true))
963 ret
= connector
->status
;
967 /* find analog encoder */
968 if (radeon_connector
->dac_load_detect
) {
969 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
970 if (connector
->encoder_ids
[i
] == 0)
973 obj
= drm_mode_object_find(connector
->dev
,
974 connector
->encoder_ids
[i
],
975 DRM_MODE_OBJECT_ENCODER
);
979 encoder
= obj_to_encoder(obj
);
981 encoder_funcs
= encoder
->helper_private
;
982 if (encoder_funcs
->detect
) {
983 if (ret
!= connector_status_connected
) {
984 ret
= encoder_funcs
->detect(encoder
, connector
);
985 if (ret
== connector_status_connected
) {
986 radeon_connector
->use_digital
= false;
994 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== false) &&
996 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
999 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
1000 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
1001 * by other means, assume the DFP is connected and use that EDID. In most
1002 * cases the DVI port is actually a virtual KVM port connected to the service
1005 if ((!rdev
->is_atom_bios
) &&
1006 (ret
== connector_status_disconnected
) &&
1007 rdev
->mode_info
.bios_hardcoded_edid_size
) {
1008 radeon_connector
->use_digital
= true;
1009 ret
= connector_status_connected
;
1013 /* updated in get modes as well since we need to know if it's analog or digital */
1014 radeon_connector_update_scratch_regs(connector
, ret
);
1018 /* okay need to be smart in here about which encoder to pick */
1019 struct drm_encoder
*radeon_dvi_encoder(struct drm_connector
*connector
)
1021 int enc_id
= connector
->encoder_ids
[0];
1022 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1023 struct drm_mode_object
*obj
;
1024 struct drm_encoder
*encoder
;
1026 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1027 if (connector
->encoder_ids
[i
] == 0)
1030 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1034 encoder
= obj_to_encoder(obj
);
1036 if (radeon_connector
->use_digital
== true) {
1037 if (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)
1040 if (encoder
->encoder_type
== DRM_MODE_ENCODER_DAC
||
1041 encoder
->encoder_type
== DRM_MODE_ENCODER_TVDAC
)
1046 /* see if we have a default encoder TODO */
1048 /* then check use digitial */
1049 /* pick the first one */
1051 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
1054 encoder
= obj_to_encoder(obj
);
1060 static void radeon_dvi_force(struct drm_connector
*connector
)
1062 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1063 if (connector
->force
== DRM_FORCE_ON
)
1064 radeon_connector
->use_digital
= false;
1065 if (connector
->force
== DRM_FORCE_ON_DIGITAL
)
1066 radeon_connector
->use_digital
= true;
1069 static int radeon_dvi_mode_valid(struct drm_connector
*connector
,
1070 struct drm_display_mode
*mode
)
1072 struct drm_device
*dev
= connector
->dev
;
1073 struct radeon_device
*rdev
= dev
->dev_private
;
1074 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1076 /* XXX check mode bandwidth */
1078 /* clocks over 135 MHz have heat issues with DVI on RV100 */
1079 if (radeon_connector
->use_digital
&&
1080 (rdev
->family
== CHIP_RV100
) &&
1081 (mode
->clock
> 135000))
1082 return MODE_CLOCK_HIGH
;
1084 if (radeon_connector
->use_digital
&& (mode
->clock
> 165000)) {
1085 if ((radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
) ||
1086 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
) ||
1087 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_B
))
1089 else if (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_A
) {
1090 if (ASIC_IS_DCE3(rdev
)) {
1091 /* HDMI 1.3+ supports max clock of 340 Mhz */
1092 if (mode
->clock
> 340000)
1093 return MODE_CLOCK_HIGH
;
1097 return MODE_CLOCK_HIGH
;
1099 return MODE_CLOCK_HIGH
;
1102 /* check against the max pixel clock */
1103 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
1104 return MODE_CLOCK_HIGH
;
1109 struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs
= {
1110 .get_modes
= radeon_dvi_get_modes
,
1111 .mode_valid
= radeon_dvi_mode_valid
,
1112 .best_encoder
= radeon_dvi_encoder
,
1115 struct drm_connector_funcs radeon_dvi_connector_funcs
= {
1116 .dpms
= drm_helper_connector_dpms
,
1117 .detect
= radeon_dvi_detect
,
1118 .fill_modes
= drm_helper_probe_single_connector_modes
,
1119 .set_property
= radeon_connector_set_property
,
1120 .destroy
= radeon_connector_destroy
,
1121 .force
= radeon_dvi_force
,
1124 static void radeon_dp_connector_destroy(struct drm_connector
*connector
)
1126 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1127 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1129 if (radeon_connector
->edid
)
1130 kfree(radeon_connector
->edid
);
1131 if (radeon_dig_connector
->dp_i2c_bus
)
1132 radeon_i2c_destroy(radeon_dig_connector
->dp_i2c_bus
);
1133 kfree(radeon_connector
->con_priv
);
1134 drm_sysfs_connector_remove(connector
);
1135 drm_connector_cleanup(connector
);
1139 static int radeon_dp_get_modes(struct drm_connector
*connector
)
1141 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1142 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1143 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1146 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1147 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1148 struct drm_display_mode
*mode
;
1150 if (!radeon_dig_connector
->edp_on
)
1151 atombios_set_edp_panel_power(connector
,
1152 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1153 ret
= radeon_ddc_get_modes(radeon_connector
);
1154 if (!radeon_dig_connector
->edp_on
)
1155 atombios_set_edp_panel_power(connector
,
1156 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1160 radeon_fixup_lvds_native_mode(encoder
, connector
);
1161 /* add scaled modes */
1162 radeon_add_common_modes(encoder
, connector
);
1167 encoder
= radeon_best_single_encoder(connector
);
1171 /* we have no EDID modes */
1172 mode
= radeon_fp_native_mode(encoder
);
1175 drm_mode_probed_add(connector
, mode
);
1176 /* add the width/height from vbios tables if available */
1177 connector
->display_info
.width_mm
= mode
->width_mm
;
1178 connector
->display_info
.height_mm
= mode
->height_mm
;
1179 /* add scaled modes */
1180 radeon_add_common_modes(encoder
, connector
);
1183 /* need to setup ddc on the bridge */
1184 if (radeon_connector_encoder_is_dp_bridge(connector
)) {
1186 radeon_atom_ext_encoder_setup_ddc(encoder
);
1188 ret
= radeon_ddc_get_modes(radeon_connector
);
1194 bool radeon_connector_encoder_is_dp_bridge(struct drm_connector
*connector
)
1196 struct drm_mode_object
*obj
;
1197 struct drm_encoder
*encoder
;
1198 struct radeon_encoder
*radeon_encoder
;
1202 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1203 if (connector
->encoder_ids
[i
] == 0)
1206 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1210 encoder
= obj_to_encoder(obj
);
1211 radeon_encoder
= to_radeon_encoder(encoder
);
1213 switch (radeon_encoder
->encoder_id
) {
1214 case ENCODER_OBJECT_ID_TRAVIS
:
1215 case ENCODER_OBJECT_ID_NUTMEG
:
1226 bool radeon_connector_encoder_is_hbr2(struct drm_connector
*connector
)
1228 struct drm_mode_object
*obj
;
1229 struct drm_encoder
*encoder
;
1230 struct radeon_encoder
*radeon_encoder
;
1234 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1235 if (connector
->encoder_ids
[i
] == 0)
1238 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1242 encoder
= obj_to_encoder(obj
);
1243 radeon_encoder
= to_radeon_encoder(encoder
);
1244 if (radeon_encoder
->caps
& ATOM_ENCODER_CAP_RECORD_HBR2
)
1251 bool radeon_connector_is_dp12_capable(struct drm_connector
*connector
)
1253 struct drm_device
*dev
= connector
->dev
;
1254 struct radeon_device
*rdev
= dev
->dev_private
;
1256 if (ASIC_IS_DCE5(rdev
) &&
1257 (rdev
->clock
.dp_extclk
>= 53900) &&
1258 radeon_connector_encoder_is_hbr2(connector
)) {
1265 static enum drm_connector_status
1266 radeon_dp_detect(struct drm_connector
*connector
, bool force
)
1268 struct drm_device
*dev
= connector
->dev
;
1269 struct radeon_device
*rdev
= dev
->dev_private
;
1270 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1271 enum drm_connector_status ret
= connector_status_disconnected
;
1272 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1273 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1275 if (radeon_connector
->edid
) {
1276 kfree(radeon_connector
->edid
);
1277 radeon_connector
->edid
= NULL
;
1280 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1281 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1283 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1284 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1286 /* check if panel is valid */
1287 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
1288 ret
= connector_status_connected
;
1290 /* eDP is always DP */
1291 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1292 if (!radeon_dig_connector
->edp_on
)
1293 atombios_set_edp_panel_power(connector
,
1294 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1295 if (radeon_dp_getdpcd(radeon_connector
))
1296 ret
= connector_status_connected
;
1297 if (!radeon_dig_connector
->edp_on
)
1298 atombios_set_edp_panel_power(connector
,
1299 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1300 } else if (radeon_connector_encoder_is_dp_bridge(connector
)) {
1301 /* DP bridges are always DP */
1302 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1303 /* get the DPCD from the bridge */
1304 radeon_dp_getdpcd(radeon_connector
);
1307 /* setup ddc on the bridge */
1308 radeon_atom_ext_encoder_setup_ddc(encoder
);
1309 if (radeon_ddc_probe(radeon_connector
,
1310 radeon_connector
->requires_extended_probe
)) /* try DDC */
1311 ret
= connector_status_connected
;
1312 else if (radeon_connector
->dac_load_detect
) { /* try load detection */
1313 struct drm_encoder_helper_funcs
*encoder_funcs
= encoder
->helper_private
;
1314 ret
= encoder_funcs
->detect(encoder
, connector
);
1318 radeon_dig_connector
->dp_sink_type
= radeon_dp_getsinktype(radeon_connector
);
1319 if (radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
1320 ret
= connector_status_connected
;
1321 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
)
1322 radeon_dp_getdpcd(radeon_connector
);
1324 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
1325 if (radeon_dp_getdpcd(radeon_connector
))
1326 ret
= connector_status_connected
;
1328 if (radeon_ddc_probe(radeon_connector
,
1329 radeon_connector
->requires_extended_probe
))
1330 ret
= connector_status_connected
;
1335 radeon_connector_update_scratch_regs(connector
, ret
);
1339 static int radeon_dp_mode_valid(struct drm_connector
*connector
,
1340 struct drm_display_mode
*mode
)
1342 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1343 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1345 /* XXX check mode bandwidth */
1347 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1348 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1349 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1351 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
1355 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1356 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1358 /* AVIVO hardware supports downscaling modes larger than the panel
1359 * to the panel size, but I'm not sure this is desirable.
1361 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
1362 (mode
->vdisplay
> native_mode
->vdisplay
))
1365 /* if scaling is disabled, block non-native modes */
1366 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
1367 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
1368 (mode
->vdisplay
!= native_mode
->vdisplay
))
1374 if ((radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
1375 (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
))
1376 return radeon_dp_mode_valid_helper(connector
, mode
);
1382 struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs
= {
1383 .get_modes
= radeon_dp_get_modes
,
1384 .mode_valid
= radeon_dp_mode_valid
,
1385 .best_encoder
= radeon_dvi_encoder
,
1388 struct drm_connector_funcs radeon_dp_connector_funcs
= {
1389 .dpms
= drm_helper_connector_dpms
,
1390 .detect
= radeon_dp_detect
,
1391 .fill_modes
= drm_helper_probe_single_connector_modes
,
1392 .set_property
= radeon_connector_set_property
,
1393 .destroy
= radeon_dp_connector_destroy
,
1394 .force
= radeon_dvi_force
,
1398 radeon_add_atom_connector(struct drm_device
*dev
,
1399 uint32_t connector_id
,
1400 uint32_t supported_device
,
1402 struct radeon_i2c_bus_rec
*i2c_bus
,
1403 uint32_t igp_lane_info
,
1404 uint16_t connector_object_id
,
1405 struct radeon_hpd
*hpd
,
1406 struct radeon_router
*router
)
1408 struct radeon_device
*rdev
= dev
->dev_private
;
1409 struct drm_connector
*connector
;
1410 struct radeon_connector
*radeon_connector
;
1411 struct radeon_connector_atom_dig
*radeon_dig_connector
;
1412 struct drm_encoder
*encoder
;
1413 struct radeon_encoder
*radeon_encoder
;
1414 uint32_t subpixel_order
= SubPixelNone
;
1415 bool shared_ddc
= false;
1416 bool is_dp_bridge
= false;
1418 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1421 /* if the user selected tv=0 don't try and add the connector */
1422 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1423 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1424 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1428 /* see if we already added it */
1429 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1430 radeon_connector
= to_radeon_connector(connector
);
1431 if (radeon_connector
->connector_id
== connector_id
) {
1432 radeon_connector
->devices
|= supported_device
;
1435 if (radeon_connector
->ddc_bus
&& i2c_bus
->valid
) {
1436 if (radeon_connector
->ddc_bus
->rec
.i2c_id
== i2c_bus
->i2c_id
) {
1437 radeon_connector
->shared_ddc
= true;
1440 if (radeon_connector
->router_bus
&& router
->ddc_valid
&&
1441 (radeon_connector
->router
.router_id
== router
->router_id
)) {
1442 radeon_connector
->shared_ddc
= false;
1448 /* check if it's a dp bridge */
1449 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
1450 radeon_encoder
= to_radeon_encoder(encoder
);
1451 if (radeon_encoder
->devices
& supported_device
) {
1452 switch (radeon_encoder
->encoder_id
) {
1453 case ENCODER_OBJECT_ID_TRAVIS
:
1454 case ENCODER_OBJECT_ID_NUTMEG
:
1455 is_dp_bridge
= true;
1463 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1464 if (!radeon_connector
)
1467 connector
= &radeon_connector
->base
;
1469 radeon_connector
->connector_id
= connector_id
;
1470 radeon_connector
->devices
= supported_device
;
1471 radeon_connector
->shared_ddc
= shared_ddc
;
1472 radeon_connector
->connector_object_id
= connector_object_id
;
1473 radeon_connector
->hpd
= *hpd
;
1474 radeon_connector
->requires_extended_probe
=
1475 radeon_connector_needs_extended_probe(rdev
, supported_device
,
1477 radeon_connector
->router
= *router
;
1478 if (router
->ddc_valid
|| router
->cd_valid
) {
1479 radeon_connector
->router_bus
= radeon_i2c_lookup(rdev
, &router
->i2c_info
);
1480 if (!radeon_connector
->router_bus
)
1481 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n");
1485 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1486 if (!radeon_dig_connector
)
1488 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1489 radeon_connector
->con_priv
= radeon_dig_connector
;
1490 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1491 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1492 if (i2c_bus
->valid
) {
1493 /* add DP i2c bus */
1494 if (connector_type
== DRM_MODE_CONNECTOR_eDP
)
1495 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1497 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1498 if (!radeon_dig_connector
->dp_i2c_bus
)
1499 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1500 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1501 if (!radeon_connector
->ddc_bus
)
1502 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1504 switch (connector_type
) {
1505 case DRM_MODE_CONNECTOR_VGA
:
1506 case DRM_MODE_CONNECTOR_DVIA
:
1508 connector
->interlace_allowed
= true;
1509 connector
->doublescan_allowed
= true;
1510 radeon_connector
->dac_load_detect
= true;
1511 drm_connector_attach_property(&radeon_connector
->base
,
1512 rdev
->mode_info
.load_detect_property
,
1515 case DRM_MODE_CONNECTOR_DVII
:
1516 case DRM_MODE_CONNECTOR_DVID
:
1517 case DRM_MODE_CONNECTOR_HDMIA
:
1518 case DRM_MODE_CONNECTOR_HDMIB
:
1519 case DRM_MODE_CONNECTOR_DisplayPort
:
1520 drm_connector_attach_property(&radeon_connector
->base
,
1521 rdev
->mode_info
.underscan_property
,
1523 drm_connector_attach_property(&radeon_connector
->base
,
1524 rdev
->mode_info
.underscan_hborder_property
,
1526 drm_connector_attach_property(&radeon_connector
->base
,
1527 rdev
->mode_info
.underscan_vborder_property
,
1529 subpixel_order
= SubPixelHorizontalRGB
;
1530 connector
->interlace_allowed
= true;
1531 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1532 connector
->doublescan_allowed
= true;
1534 connector
->doublescan_allowed
= false;
1535 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1536 radeon_connector
->dac_load_detect
= true;
1537 drm_connector_attach_property(&radeon_connector
->base
,
1538 rdev
->mode_info
.load_detect_property
,
1542 case DRM_MODE_CONNECTOR_LVDS
:
1543 case DRM_MODE_CONNECTOR_eDP
:
1544 drm_connector_attach_property(&radeon_connector
->base
,
1545 dev
->mode_config
.scaling_mode_property
,
1546 DRM_MODE_SCALE_FULLSCREEN
);
1547 subpixel_order
= SubPixelHorizontalRGB
;
1548 connector
->interlace_allowed
= false;
1549 connector
->doublescan_allowed
= false;
1553 switch (connector_type
) {
1554 case DRM_MODE_CONNECTOR_VGA
:
1555 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1556 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1557 if (i2c_bus
->valid
) {
1558 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1559 if (!radeon_connector
->ddc_bus
)
1560 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1562 radeon_connector
->dac_load_detect
= true;
1563 drm_connector_attach_property(&radeon_connector
->base
,
1564 rdev
->mode_info
.load_detect_property
,
1566 /* no HPD on analog connectors */
1567 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1568 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1569 connector
->interlace_allowed
= true;
1570 connector
->doublescan_allowed
= true;
1572 case DRM_MODE_CONNECTOR_DVIA
:
1573 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1574 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_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("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1580 radeon_connector
->dac_load_detect
= true;
1581 drm_connector_attach_property(&radeon_connector
->base
,
1582 rdev
->mode_info
.load_detect_property
,
1584 /* no HPD on analog connectors */
1585 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1586 connector
->interlace_allowed
= true;
1587 connector
->doublescan_allowed
= true;
1589 case DRM_MODE_CONNECTOR_DVII
:
1590 case DRM_MODE_CONNECTOR_DVID
:
1591 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1592 if (!radeon_dig_connector
)
1594 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1595 radeon_connector
->con_priv
= radeon_dig_connector
;
1596 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1597 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1598 if (i2c_bus
->valid
) {
1599 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1600 if (!radeon_connector
->ddc_bus
)
1601 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1603 subpixel_order
= SubPixelHorizontalRGB
;
1604 drm_connector_attach_property(&radeon_connector
->base
,
1605 rdev
->mode_info
.coherent_mode_property
,
1607 if (ASIC_IS_AVIVO(rdev
)) {
1608 drm_connector_attach_property(&radeon_connector
->base
,
1609 rdev
->mode_info
.underscan_property
,
1611 drm_connector_attach_property(&radeon_connector
->base
,
1612 rdev
->mode_info
.underscan_hborder_property
,
1614 drm_connector_attach_property(&radeon_connector
->base
,
1615 rdev
->mode_info
.underscan_vborder_property
,
1618 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1619 radeon_connector
->dac_load_detect
= true;
1620 drm_connector_attach_property(&radeon_connector
->base
,
1621 rdev
->mode_info
.load_detect_property
,
1624 connector
->interlace_allowed
= true;
1625 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
1626 connector
->doublescan_allowed
= true;
1628 connector
->doublescan_allowed
= false;
1630 case DRM_MODE_CONNECTOR_HDMIA
:
1631 case DRM_MODE_CONNECTOR_HDMIB
:
1632 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1633 if (!radeon_dig_connector
)
1635 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1636 radeon_connector
->con_priv
= radeon_dig_connector
;
1637 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1638 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1639 if (i2c_bus
->valid
) {
1640 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1641 if (!radeon_connector
->ddc_bus
)
1642 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1644 drm_connector_attach_property(&radeon_connector
->base
,
1645 rdev
->mode_info
.coherent_mode_property
,
1647 if (ASIC_IS_AVIVO(rdev
)) {
1648 drm_connector_attach_property(&radeon_connector
->base
,
1649 rdev
->mode_info
.underscan_property
,
1651 drm_connector_attach_property(&radeon_connector
->base
,
1652 rdev
->mode_info
.underscan_hborder_property
,
1654 drm_connector_attach_property(&radeon_connector
->base
,
1655 rdev
->mode_info
.underscan_vborder_property
,
1658 subpixel_order
= SubPixelHorizontalRGB
;
1659 connector
->interlace_allowed
= true;
1660 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1661 connector
->doublescan_allowed
= true;
1663 connector
->doublescan_allowed
= false;
1665 case DRM_MODE_CONNECTOR_DisplayPort
:
1666 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1667 if (!radeon_dig_connector
)
1669 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1670 radeon_connector
->con_priv
= radeon_dig_connector
;
1671 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1672 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1673 if (i2c_bus
->valid
) {
1674 /* add DP i2c bus */
1675 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1676 if (!radeon_dig_connector
->dp_i2c_bus
)
1677 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1678 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1679 if (!radeon_connector
->ddc_bus
)
1680 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1682 subpixel_order
= SubPixelHorizontalRGB
;
1683 drm_connector_attach_property(&radeon_connector
->base
,
1684 rdev
->mode_info
.coherent_mode_property
,
1686 if (ASIC_IS_AVIVO(rdev
)) {
1687 drm_connector_attach_property(&radeon_connector
->base
,
1688 rdev
->mode_info
.underscan_property
,
1690 drm_connector_attach_property(&radeon_connector
->base
,
1691 rdev
->mode_info
.underscan_hborder_property
,
1693 drm_connector_attach_property(&radeon_connector
->base
,
1694 rdev
->mode_info
.underscan_vborder_property
,
1697 connector
->interlace_allowed
= true;
1698 /* in theory with a DP to VGA converter... */
1699 connector
->doublescan_allowed
= false;
1701 case DRM_MODE_CONNECTOR_eDP
:
1702 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1703 if (!radeon_dig_connector
)
1705 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1706 radeon_connector
->con_priv
= radeon_dig_connector
;
1707 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1708 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1709 if (i2c_bus
->valid
) {
1710 /* add DP i2c bus */
1711 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1712 if (!radeon_dig_connector
->dp_i2c_bus
)
1713 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1714 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1715 if (!radeon_connector
->ddc_bus
)
1716 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1718 drm_connector_attach_property(&radeon_connector
->base
,
1719 dev
->mode_config
.scaling_mode_property
,
1720 DRM_MODE_SCALE_FULLSCREEN
);
1721 subpixel_order
= SubPixelHorizontalRGB
;
1722 connector
->interlace_allowed
= false;
1723 connector
->doublescan_allowed
= false;
1725 case DRM_MODE_CONNECTOR_SVIDEO
:
1726 case DRM_MODE_CONNECTOR_Composite
:
1727 case DRM_MODE_CONNECTOR_9PinDIN
:
1728 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1729 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1730 radeon_connector
->dac_load_detect
= true;
1731 drm_connector_attach_property(&radeon_connector
->base
,
1732 rdev
->mode_info
.load_detect_property
,
1734 drm_connector_attach_property(&radeon_connector
->base
,
1735 rdev
->mode_info
.tv_std_property
,
1736 radeon_atombios_get_tv_info(rdev
));
1737 /* no HPD on analog connectors */
1738 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1739 connector
->interlace_allowed
= false;
1740 connector
->doublescan_allowed
= false;
1742 case DRM_MODE_CONNECTOR_LVDS
:
1743 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1744 if (!radeon_dig_connector
)
1746 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1747 radeon_connector
->con_priv
= radeon_dig_connector
;
1748 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1749 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1750 if (i2c_bus
->valid
) {
1751 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1752 if (!radeon_connector
->ddc_bus
)
1753 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1755 drm_connector_attach_property(&radeon_connector
->base
,
1756 dev
->mode_config
.scaling_mode_property
,
1757 DRM_MODE_SCALE_FULLSCREEN
);
1758 subpixel_order
= SubPixelHorizontalRGB
;
1759 connector
->interlace_allowed
= false;
1760 connector
->doublescan_allowed
= false;
1765 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
1767 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1769 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
1771 connector
->display_info
.subpixel_order
= subpixel_order
;
1772 drm_sysfs_connector_add(connector
);
1776 drm_connector_cleanup(connector
);
1781 radeon_add_legacy_connector(struct drm_device
*dev
,
1782 uint32_t connector_id
,
1783 uint32_t supported_device
,
1785 struct radeon_i2c_bus_rec
*i2c_bus
,
1786 uint16_t connector_object_id
,
1787 struct radeon_hpd
*hpd
)
1789 struct radeon_device
*rdev
= dev
->dev_private
;
1790 struct drm_connector
*connector
;
1791 struct radeon_connector
*radeon_connector
;
1792 uint32_t subpixel_order
= SubPixelNone
;
1794 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1797 /* if the user selected tv=0 don't try and add the connector */
1798 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1799 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1800 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1804 /* see if we already added it */
1805 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1806 radeon_connector
= to_radeon_connector(connector
);
1807 if (radeon_connector
->connector_id
== connector_id
) {
1808 radeon_connector
->devices
|= supported_device
;
1813 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1814 if (!radeon_connector
)
1817 connector
= &radeon_connector
->base
;
1819 radeon_connector
->connector_id
= connector_id
;
1820 radeon_connector
->devices
= supported_device
;
1821 radeon_connector
->connector_object_id
= connector_object_id
;
1822 radeon_connector
->hpd
= *hpd
;
1823 radeon_connector
->requires_extended_probe
=
1824 radeon_connector_needs_extended_probe(rdev
, supported_device
,
1826 switch (connector_type
) {
1827 case DRM_MODE_CONNECTOR_VGA
:
1828 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1829 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1830 if (i2c_bus
->valid
) {
1831 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1832 if (!radeon_connector
->ddc_bus
)
1833 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1835 radeon_connector
->dac_load_detect
= true;
1836 drm_connector_attach_property(&radeon_connector
->base
,
1837 rdev
->mode_info
.load_detect_property
,
1839 /* no HPD on analog connectors */
1840 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1841 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1842 connector
->interlace_allowed
= true;
1843 connector
->doublescan_allowed
= true;
1845 case DRM_MODE_CONNECTOR_DVIA
:
1846 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1847 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1848 if (i2c_bus
->valid
) {
1849 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1850 if (!radeon_connector
->ddc_bus
)
1851 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1853 radeon_connector
->dac_load_detect
= true;
1854 drm_connector_attach_property(&radeon_connector
->base
,
1855 rdev
->mode_info
.load_detect_property
,
1857 /* no HPD on analog connectors */
1858 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1859 connector
->interlace_allowed
= true;
1860 connector
->doublescan_allowed
= true;
1862 case DRM_MODE_CONNECTOR_DVII
:
1863 case DRM_MODE_CONNECTOR_DVID
:
1864 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1865 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1866 if (i2c_bus
->valid
) {
1867 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1868 if (!radeon_connector
->ddc_bus
)
1869 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1871 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1872 radeon_connector
->dac_load_detect
= true;
1873 drm_connector_attach_property(&radeon_connector
->base
,
1874 rdev
->mode_info
.load_detect_property
,
1877 subpixel_order
= SubPixelHorizontalRGB
;
1878 connector
->interlace_allowed
= true;
1879 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
1880 connector
->doublescan_allowed
= true;
1882 connector
->doublescan_allowed
= false;
1884 case DRM_MODE_CONNECTOR_SVIDEO
:
1885 case DRM_MODE_CONNECTOR_Composite
:
1886 case DRM_MODE_CONNECTOR_9PinDIN
:
1887 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1888 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1889 radeon_connector
->dac_load_detect
= true;
1890 /* RS400,RC410,RS480 chipset seems to report a lot
1891 * of false positive on load detect, we haven't yet
1892 * found a way to make load detect reliable on those
1893 * chipset, thus just disable it for TV.
1895 if (rdev
->family
== CHIP_RS400
|| rdev
->family
== CHIP_RS480
)
1896 radeon_connector
->dac_load_detect
= false;
1897 drm_connector_attach_property(&radeon_connector
->base
,
1898 rdev
->mode_info
.load_detect_property
,
1899 radeon_connector
->dac_load_detect
);
1900 drm_connector_attach_property(&radeon_connector
->base
,
1901 rdev
->mode_info
.tv_std_property
,
1902 radeon_combios_get_tv_info(rdev
));
1903 /* no HPD on analog connectors */
1904 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1905 connector
->interlace_allowed
= false;
1906 connector
->doublescan_allowed
= false;
1908 case DRM_MODE_CONNECTOR_LVDS
:
1909 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1910 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1911 if (i2c_bus
->valid
) {
1912 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1913 if (!radeon_connector
->ddc_bus
)
1914 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1916 drm_connector_attach_property(&radeon_connector
->base
,
1917 dev
->mode_config
.scaling_mode_property
,
1918 DRM_MODE_SCALE_FULLSCREEN
);
1919 subpixel_order
= SubPixelHorizontalRGB
;
1920 connector
->interlace_allowed
= false;
1921 connector
->doublescan_allowed
= false;
1925 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
1927 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1929 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
1930 connector
->display_info
.subpixel_order
= subpixel_order
;
1931 drm_sysfs_connector_add(connector
);
1932 if (connector_type
== DRM_MODE_CONNECTOR_LVDS
) {
1933 struct drm_encoder
*drm_encoder
;
1935 list_for_each_entry(drm_encoder
, &dev
->mode_config
.encoder_list
, head
) {
1936 struct radeon_encoder
*radeon_encoder
;
1938 radeon_encoder
= to_radeon_encoder(drm_encoder
);
1939 if (radeon_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_LVDS
)
1940 radeon_legacy_backlight_init(radeon_encoder
, connector
);