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 void radeon_connector_hotplug(struct drm_connector
*connector
)
49 struct drm_device
*dev
= connector
->dev
;
50 struct radeon_device
*rdev
= dev
->dev_private
;
51 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
53 /* bail if the connector does not have hpd pin, e.g.,
56 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
)
59 radeon_hpd_set_polarity(rdev
, radeon_connector
->hpd
.hpd
);
61 /* if the connector is already off, don't turn it back on */
62 if (connector
->dpms
!= DRM_MODE_DPMS_ON
)
65 /* just deal with DP (not eDP) here. */
66 if (connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
) {
67 int saved_dpms
= connector
->dpms
;
69 /* Only turn off the display it it's physically disconnected */
70 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
))
71 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_OFF
);
72 else if (radeon_dp_needs_link_train(radeon_connector
))
73 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_ON
);
74 connector
->dpms
= saved_dpms
;
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
);
433 static void radeon_fixup_lvds_native_mode(struct drm_encoder
*encoder
,
434 struct drm_connector
*connector
)
436 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
437 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
438 struct drm_display_mode
*t
, *mode
;
440 /* If the EDID preferred mode doesn't match the native mode, use it */
441 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
442 if (mode
->type
& DRM_MODE_TYPE_PREFERRED
) {
443 if (mode
->hdisplay
!= native_mode
->hdisplay
||
444 mode
->vdisplay
!= native_mode
->vdisplay
)
445 memcpy(native_mode
, mode
, sizeof(*mode
));
449 /* Try to get native mode details from EDID if necessary */
450 if (!native_mode
->clock
) {
451 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
452 if (mode
->hdisplay
== native_mode
->hdisplay
&&
453 mode
->vdisplay
== native_mode
->vdisplay
) {
454 *native_mode
= *mode
;
455 drm_mode_set_crtcinfo(native_mode
, CRTC_INTERLACE_HALVE_V
);
456 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
462 if (!native_mode
->clock
) {
463 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n");
464 radeon_encoder
->rmx_type
= RMX_OFF
;
468 static int radeon_lvds_get_modes(struct drm_connector
*connector
)
470 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
471 struct drm_encoder
*encoder
;
473 struct drm_display_mode
*mode
;
475 if (radeon_connector
->ddc_bus
) {
476 ret
= radeon_ddc_get_modes(radeon_connector
);
478 encoder
= radeon_best_single_encoder(connector
);
480 radeon_fixup_lvds_native_mode(encoder
, connector
);
481 /* add scaled modes */
482 radeon_add_common_modes(encoder
, connector
);
488 encoder
= radeon_best_single_encoder(connector
);
492 /* we have no EDID modes */
493 mode
= radeon_fp_native_mode(encoder
);
496 drm_mode_probed_add(connector
, mode
);
497 /* add the width/height from vbios tables if available */
498 connector
->display_info
.width_mm
= mode
->width_mm
;
499 connector
->display_info
.height_mm
= mode
->height_mm
;
500 /* add scaled modes */
501 radeon_add_common_modes(encoder
, connector
);
507 static int radeon_lvds_mode_valid(struct drm_connector
*connector
,
508 struct drm_display_mode
*mode
)
510 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
512 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
516 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
517 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
519 /* AVIVO hardware supports downscaling modes larger than the panel
520 * to the panel size, but I'm not sure this is desirable.
522 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
523 (mode
->vdisplay
> native_mode
->vdisplay
))
526 /* if scaling is disabled, block non-native modes */
527 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
528 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
529 (mode
->vdisplay
!= native_mode
->vdisplay
))
537 static enum drm_connector_status
538 radeon_lvds_detect(struct drm_connector
*connector
, bool force
)
540 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
541 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
542 enum drm_connector_status ret
= connector_status_disconnected
;
545 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
546 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
548 /* check if panel is valid */
549 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
550 ret
= connector_status_connected
;
554 /* check for edid as well */
555 if (radeon_connector
->edid
)
556 ret
= connector_status_connected
;
558 if (radeon_connector
->ddc_bus
) {
559 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
,
560 &radeon_connector
->ddc_bus
->adapter
);
561 if (radeon_connector
->edid
)
562 ret
= connector_status_connected
;
565 /* check acpi lid status ??? */
567 radeon_connector_update_scratch_regs(connector
, ret
);
571 static void radeon_connector_destroy(struct drm_connector
*connector
)
573 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
575 if (radeon_connector
->edid
)
576 kfree(radeon_connector
->edid
);
577 kfree(radeon_connector
->con_priv
);
578 drm_sysfs_connector_remove(connector
);
579 drm_connector_cleanup(connector
);
583 static int radeon_lvds_set_property(struct drm_connector
*connector
,
584 struct drm_property
*property
,
587 struct drm_device
*dev
= connector
->dev
;
588 struct radeon_encoder
*radeon_encoder
;
589 enum radeon_rmx_type rmx_type
;
592 if (property
!= dev
->mode_config
.scaling_mode_property
)
595 if (connector
->encoder
)
596 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
598 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
599 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
603 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
604 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
605 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
607 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
609 if (radeon_encoder
->rmx_type
== rmx_type
)
612 radeon_encoder
->rmx_type
= rmx_type
;
614 radeon_property_change_mode(&radeon_encoder
->base
);
619 struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs
= {
620 .get_modes
= radeon_lvds_get_modes
,
621 .mode_valid
= radeon_lvds_mode_valid
,
622 .best_encoder
= radeon_best_single_encoder
,
625 struct drm_connector_funcs radeon_lvds_connector_funcs
= {
626 .dpms
= drm_helper_connector_dpms
,
627 .detect
= radeon_lvds_detect
,
628 .fill_modes
= drm_helper_probe_single_connector_modes
,
629 .destroy
= radeon_connector_destroy
,
630 .set_property
= radeon_lvds_set_property
,
633 static int radeon_vga_get_modes(struct drm_connector
*connector
)
635 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
638 ret
= radeon_ddc_get_modes(radeon_connector
);
643 static int radeon_vga_mode_valid(struct drm_connector
*connector
,
644 struct drm_display_mode
*mode
)
646 struct drm_device
*dev
= connector
->dev
;
647 struct radeon_device
*rdev
= dev
->dev_private
;
649 /* XXX check mode bandwidth */
651 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
652 return MODE_CLOCK_HIGH
;
657 static enum drm_connector_status
658 radeon_vga_detect(struct drm_connector
*connector
, bool force
)
660 struct drm_device
*dev
= connector
->dev
;
661 struct radeon_device
*rdev
= dev
->dev_private
;
662 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
663 struct drm_encoder
*encoder
;
664 struct drm_encoder_helper_funcs
*encoder_funcs
;
666 enum drm_connector_status ret
= connector_status_disconnected
;
668 encoder
= radeon_best_single_encoder(connector
);
670 ret
= connector_status_disconnected
;
672 if (radeon_connector
->ddc_bus
)
673 dret
= radeon_ddc_probe(radeon_connector
);
675 radeon_connector
->detected_by_load
= false;
676 if (radeon_connector
->edid
) {
677 kfree(radeon_connector
->edid
);
678 radeon_connector
->edid
= NULL
;
680 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
682 if (!radeon_connector
->edid
) {
683 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
684 drm_get_connector_name(connector
));
685 ret
= connector_status_connected
;
687 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
689 /* some oems have boards with separate digital and analog connectors
690 * with a shared ddc line (often vga + hdmi)
692 if (radeon_connector
->use_digital
&& radeon_connector
->shared_ddc
) {
693 kfree(radeon_connector
->edid
);
694 radeon_connector
->edid
= NULL
;
695 ret
= connector_status_disconnected
;
697 ret
= connector_status_connected
;
701 /* if we aren't forcing don't do destructive polling */
703 /* only return the previous status if we last
704 * detected a monitor via load.
706 if (radeon_connector
->detected_by_load
)
707 return connector
->status
;
712 if (radeon_connector
->dac_load_detect
&& encoder
) {
713 encoder_funcs
= encoder
->helper_private
;
714 ret
= encoder_funcs
->detect(encoder
, connector
);
715 if (ret
!= connector_status_disconnected
)
716 radeon_connector
->detected_by_load
= true;
720 if (ret
== connector_status_connected
)
721 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
723 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
724 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
725 * by other means, assume the CRT is connected and use that EDID.
727 if ((!rdev
->is_atom_bios
) &&
728 (ret
== connector_status_disconnected
) &&
729 rdev
->mode_info
.bios_hardcoded_edid_size
) {
730 ret
= connector_status_connected
;
733 radeon_connector_update_scratch_regs(connector
, ret
);
737 struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs
= {
738 .get_modes
= radeon_vga_get_modes
,
739 .mode_valid
= radeon_vga_mode_valid
,
740 .best_encoder
= radeon_best_single_encoder
,
743 struct drm_connector_funcs radeon_vga_connector_funcs
= {
744 .dpms
= drm_helper_connector_dpms
,
745 .detect
= radeon_vga_detect
,
746 .fill_modes
= drm_helper_probe_single_connector_modes
,
747 .destroy
= radeon_connector_destroy
,
748 .set_property
= radeon_connector_set_property
,
751 static int radeon_tv_get_modes(struct drm_connector
*connector
)
753 struct drm_device
*dev
= connector
->dev
;
754 struct radeon_device
*rdev
= dev
->dev_private
;
755 struct drm_display_mode
*tv_mode
;
756 struct drm_encoder
*encoder
;
758 encoder
= radeon_best_single_encoder(connector
);
762 /* avivo chips can scale any mode */
763 if (rdev
->family
>= CHIP_RS600
)
764 /* add scaled modes */
765 radeon_add_common_modes(encoder
, connector
);
767 /* only 800x600 is supported right now on pre-avivo chips */
768 tv_mode
= drm_cvt_mode(dev
, 800, 600, 60, false, false, false);
769 tv_mode
->type
= DRM_MODE_TYPE_DRIVER
| DRM_MODE_TYPE_PREFERRED
;
770 drm_mode_probed_add(connector
, tv_mode
);
775 static int radeon_tv_mode_valid(struct drm_connector
*connector
,
776 struct drm_display_mode
*mode
)
778 if ((mode
->hdisplay
> 1024) || (mode
->vdisplay
> 768))
779 return MODE_CLOCK_RANGE
;
783 static enum drm_connector_status
784 radeon_tv_detect(struct drm_connector
*connector
, bool force
)
786 struct drm_encoder
*encoder
;
787 struct drm_encoder_helper_funcs
*encoder_funcs
;
788 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
789 enum drm_connector_status ret
= connector_status_disconnected
;
791 if (!radeon_connector
->dac_load_detect
)
794 encoder
= radeon_best_single_encoder(connector
);
796 ret
= connector_status_disconnected
;
798 encoder_funcs
= encoder
->helper_private
;
799 ret
= encoder_funcs
->detect(encoder
, connector
);
801 if (ret
== connector_status_connected
)
802 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, false);
803 radeon_connector_update_scratch_regs(connector
, ret
);
807 struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs
= {
808 .get_modes
= radeon_tv_get_modes
,
809 .mode_valid
= radeon_tv_mode_valid
,
810 .best_encoder
= radeon_best_single_encoder
,
813 struct drm_connector_funcs radeon_tv_connector_funcs
= {
814 .dpms
= drm_helper_connector_dpms
,
815 .detect
= radeon_tv_detect
,
816 .fill_modes
= drm_helper_probe_single_connector_modes
,
817 .destroy
= radeon_connector_destroy
,
818 .set_property
= radeon_connector_set_property
,
821 static int radeon_dvi_get_modes(struct drm_connector
*connector
)
823 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
826 ret
= radeon_ddc_get_modes(radeon_connector
);
832 * Do a DDC probe, if DDC probe passes, get the full EDID so
833 * we can do analog/digital monitor detection at this point.
834 * If the monitor is an analog monitor or we got no DDC,
835 * we need to find the DAC encoder object for this connector.
836 * If we got no DDC, we do load detection on the DAC encoder object.
837 * If we got analog DDC or load detection passes on the DAC encoder
838 * we have to check if this analog encoder is shared with anyone else (TV)
839 * if its shared we have to set the other connector to disconnected.
841 static enum drm_connector_status
842 radeon_dvi_detect(struct drm_connector
*connector
, bool force
)
844 struct drm_device
*dev
= connector
->dev
;
845 struct radeon_device
*rdev
= dev
->dev_private
;
846 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
847 struct drm_encoder
*encoder
= NULL
;
848 struct drm_encoder_helper_funcs
*encoder_funcs
;
849 struct drm_mode_object
*obj
;
851 enum drm_connector_status ret
= connector_status_disconnected
;
854 if (radeon_connector
->ddc_bus
)
855 dret
= radeon_ddc_probe(radeon_connector
);
857 radeon_connector
->detected_by_load
= false;
858 if (radeon_connector
->edid
) {
859 kfree(radeon_connector
->edid
);
860 radeon_connector
->edid
= NULL
;
862 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
864 if (!radeon_connector
->edid
) {
865 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
866 drm_get_connector_name(connector
));
867 /* rs690 seems to have a problem with connectors not existing and always
868 * return a block of 0's. If we see this just stop polling on this output */
869 if ((rdev
->family
== CHIP_RS690
|| rdev
->family
== CHIP_RS740
) && radeon_connector
->base
.null_edid_counter
) {
870 ret
= connector_status_disconnected
;
871 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", drm_get_connector_name(connector
));
872 radeon_connector
->ddc_bus
= NULL
;
875 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
877 /* some oems have boards with separate digital and analog connectors
878 * with a shared ddc line (often vga + hdmi)
880 if ((!radeon_connector
->use_digital
) && radeon_connector
->shared_ddc
) {
881 kfree(radeon_connector
->edid
);
882 radeon_connector
->edid
= NULL
;
883 ret
= connector_status_disconnected
;
885 ret
= connector_status_connected
;
887 /* This gets complicated. We have boards with VGA + HDMI with a
888 * shared DDC line and we have boards with DVI-D + HDMI with a shared
889 * DDC line. The latter is more complex because with DVI<->HDMI adapters
890 * you don't really know what's connected to which port as both are digital.
892 if (radeon_connector
->shared_ddc
&& (ret
== connector_status_connected
)) {
893 struct drm_connector
*list_connector
;
894 struct radeon_connector
*list_radeon_connector
;
895 list_for_each_entry(list_connector
, &dev
->mode_config
.connector_list
, head
) {
896 if (connector
== list_connector
)
898 list_radeon_connector
= to_radeon_connector(list_connector
);
899 if (list_radeon_connector
->shared_ddc
&&
900 (list_radeon_connector
->ddc_bus
->rec
.i2c_id
==
901 radeon_connector
->ddc_bus
->rec
.i2c_id
)) {
902 /* cases where both connectors are digital */
903 if (list_connector
->connector_type
!= DRM_MODE_CONNECTOR_VGA
) {
904 /* hpd is our only option in this case */
905 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
906 kfree(radeon_connector
->edid
);
907 radeon_connector
->edid
= NULL
;
908 ret
= connector_status_disconnected
;
917 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== true))
920 /* DVI-D and HDMI-A are digital only */
921 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_DVID
) ||
922 (connector
->connector_type
== DRM_MODE_CONNECTOR_HDMIA
))
925 /* if we aren't forcing don't do destructive polling */
927 /* only return the previous status if we last
928 * detected a monitor via load.
930 if (radeon_connector
->detected_by_load
)
931 ret
= connector
->status
;
935 /* find analog encoder */
936 if (radeon_connector
->dac_load_detect
) {
937 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
938 if (connector
->encoder_ids
[i
] == 0)
941 obj
= drm_mode_object_find(connector
->dev
,
942 connector
->encoder_ids
[i
],
943 DRM_MODE_OBJECT_ENCODER
);
947 encoder
= obj_to_encoder(obj
);
949 if (encoder
->encoder_type
!= DRM_MODE_ENCODER_DAC
&&
950 encoder
->encoder_type
!= DRM_MODE_ENCODER_TVDAC
)
953 encoder_funcs
= encoder
->helper_private
;
954 if (encoder_funcs
->detect
) {
955 if (ret
!= connector_status_connected
) {
956 ret
= encoder_funcs
->detect(encoder
, connector
);
957 if (ret
== connector_status_connected
) {
958 radeon_connector
->use_digital
= false;
960 if (ret
!= connector_status_disconnected
)
961 radeon_connector
->detected_by_load
= true;
968 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== false) &&
970 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
973 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
974 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
975 * by other means, assume the DFP is connected and use that EDID. In most
976 * cases the DVI port is actually a virtual KVM port connected to the service
980 if ((!rdev
->is_atom_bios
) &&
981 (ret
== connector_status_disconnected
) &&
982 rdev
->mode_info
.bios_hardcoded_edid_size
) {
983 radeon_connector
->use_digital
= true;
984 ret
= connector_status_connected
;
987 /* updated in get modes as well since we need to know if it's analog or digital */
988 radeon_connector_update_scratch_regs(connector
, ret
);
992 /* okay need to be smart in here about which encoder to pick */
993 struct drm_encoder
*radeon_dvi_encoder(struct drm_connector
*connector
)
995 int enc_id
= connector
->encoder_ids
[0];
996 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
997 struct drm_mode_object
*obj
;
998 struct drm_encoder
*encoder
;
1000 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1001 if (connector
->encoder_ids
[i
] == 0)
1004 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1008 encoder
= obj_to_encoder(obj
);
1010 if (radeon_connector
->use_digital
== true) {
1011 if (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)
1014 if (encoder
->encoder_type
== DRM_MODE_ENCODER_DAC
||
1015 encoder
->encoder_type
== DRM_MODE_ENCODER_TVDAC
)
1020 /* see if we have a default encoder TODO */
1022 /* then check use digitial */
1023 /* pick the first one */
1025 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
1028 encoder
= obj_to_encoder(obj
);
1034 static void radeon_dvi_force(struct drm_connector
*connector
)
1036 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1037 if (connector
->force
== DRM_FORCE_ON
)
1038 radeon_connector
->use_digital
= false;
1039 if (connector
->force
== DRM_FORCE_ON_DIGITAL
)
1040 radeon_connector
->use_digital
= true;
1043 static int radeon_dvi_mode_valid(struct drm_connector
*connector
,
1044 struct drm_display_mode
*mode
)
1046 struct drm_device
*dev
= connector
->dev
;
1047 struct radeon_device
*rdev
= dev
->dev_private
;
1048 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1050 /* XXX check mode bandwidth */
1052 /* clocks over 135 MHz have heat issues with DVI on RV100 */
1053 if (radeon_connector
->use_digital
&&
1054 (rdev
->family
== CHIP_RV100
) &&
1055 (mode
->clock
> 135000))
1056 return MODE_CLOCK_HIGH
;
1058 if (radeon_connector
->use_digital
&& (mode
->clock
> 165000)) {
1059 if ((radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
) ||
1060 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
) ||
1061 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_B
))
1063 else if (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_A
) {
1065 /* HDMI 1.3+ supports max clock of 340 Mhz */
1066 if (mode
->clock
> 340000)
1067 return MODE_CLOCK_HIGH
;
1071 return MODE_CLOCK_HIGH
;
1073 return MODE_CLOCK_HIGH
;
1076 /* check against the max pixel clock */
1077 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
1078 return MODE_CLOCK_HIGH
;
1083 struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs
= {
1084 .get_modes
= radeon_dvi_get_modes
,
1085 .mode_valid
= radeon_dvi_mode_valid
,
1086 .best_encoder
= radeon_dvi_encoder
,
1089 struct drm_connector_funcs radeon_dvi_connector_funcs
= {
1090 .dpms
= drm_helper_connector_dpms
,
1091 .detect
= radeon_dvi_detect
,
1092 .fill_modes
= drm_helper_probe_single_connector_modes
,
1093 .set_property
= radeon_connector_set_property
,
1094 .destroy
= radeon_connector_destroy
,
1095 .force
= radeon_dvi_force
,
1098 static void radeon_dp_connector_destroy(struct drm_connector
*connector
)
1100 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1101 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1103 if (radeon_connector
->edid
)
1104 kfree(radeon_connector
->edid
);
1105 if (radeon_dig_connector
->dp_i2c_bus
)
1106 radeon_i2c_destroy(radeon_dig_connector
->dp_i2c_bus
);
1107 kfree(radeon_connector
->con_priv
);
1108 drm_sysfs_connector_remove(connector
);
1109 drm_connector_cleanup(connector
);
1113 static int radeon_dp_get_modes(struct drm_connector
*connector
)
1115 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1116 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1117 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1120 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1121 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1122 struct drm_display_mode
*mode
;
1124 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) {
1125 if (!radeon_dig_connector
->edp_on
)
1126 atombios_set_edp_panel_power(connector
,
1127 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1128 ret
= radeon_ddc_get_modes(radeon_connector
);
1129 if (!radeon_dig_connector
->edp_on
)
1130 atombios_set_edp_panel_power(connector
,
1131 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1133 /* need to setup ddc on the bridge */
1134 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1135 ENCODER_OBJECT_ID_NONE
) {
1137 radeon_atom_ext_encoder_setup_ddc(encoder
);
1139 ret
= radeon_ddc_get_modes(radeon_connector
);
1144 radeon_fixup_lvds_native_mode(encoder
, connector
);
1145 /* add scaled modes */
1146 radeon_add_common_modes(encoder
, connector
);
1154 /* we have no EDID modes */
1155 mode
= radeon_fp_native_mode(encoder
);
1158 drm_mode_probed_add(connector
, mode
);
1159 /* add the width/height from vbios tables if available */
1160 connector
->display_info
.width_mm
= mode
->width_mm
;
1161 connector
->display_info
.height_mm
= mode
->height_mm
;
1162 /* add scaled modes */
1163 radeon_add_common_modes(encoder
, connector
);
1166 /* need to setup ddc on the bridge */
1167 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1168 ENCODER_OBJECT_ID_NONE
) {
1170 radeon_atom_ext_encoder_setup_ddc(encoder
);
1172 ret
= radeon_ddc_get_modes(radeon_connector
);
1178 u16
radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector
*connector
)
1180 struct drm_mode_object
*obj
;
1181 struct drm_encoder
*encoder
;
1182 struct radeon_encoder
*radeon_encoder
;
1185 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1186 if (connector
->encoder_ids
[i
] == 0)
1189 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1193 encoder
= obj_to_encoder(obj
);
1194 radeon_encoder
= to_radeon_encoder(encoder
);
1196 switch (radeon_encoder
->encoder_id
) {
1197 case ENCODER_OBJECT_ID_TRAVIS
:
1198 case ENCODER_OBJECT_ID_NUTMEG
:
1199 return radeon_encoder
->encoder_id
;
1205 return ENCODER_OBJECT_ID_NONE
;
1208 bool radeon_connector_encoder_is_hbr2(struct drm_connector
*connector
)
1210 struct drm_mode_object
*obj
;
1211 struct drm_encoder
*encoder
;
1212 struct radeon_encoder
*radeon_encoder
;
1216 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1217 if (connector
->encoder_ids
[i
] == 0)
1220 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1224 encoder
= obj_to_encoder(obj
);
1225 radeon_encoder
= to_radeon_encoder(encoder
);
1226 if (radeon_encoder
->caps
& ATOM_ENCODER_CAP_RECORD_HBR2
)
1233 bool radeon_connector_is_dp12_capable(struct drm_connector
*connector
)
1235 struct drm_device
*dev
= connector
->dev
;
1236 struct radeon_device
*rdev
= dev
->dev_private
;
1238 if (ASIC_IS_DCE5(rdev
) &&
1239 (rdev
->clock
.dp_extclk
>= 53900) &&
1240 radeon_connector_encoder_is_hbr2(connector
)) {
1247 static enum drm_connector_status
1248 radeon_dp_detect(struct drm_connector
*connector
, bool force
)
1250 struct drm_device
*dev
= connector
->dev
;
1251 struct radeon_device
*rdev
= dev
->dev_private
;
1252 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1253 enum drm_connector_status ret
= connector_status_disconnected
;
1254 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1255 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1257 if (radeon_connector
->edid
) {
1258 kfree(radeon_connector
->edid
);
1259 radeon_connector
->edid
= NULL
;
1262 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1263 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1265 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1266 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1268 /* check if panel is valid */
1269 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
1270 ret
= connector_status_connected
;
1272 /* eDP is always DP */
1273 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1274 if (!radeon_dig_connector
->edp_on
)
1275 atombios_set_edp_panel_power(connector
,
1276 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1277 if (radeon_dp_getdpcd(radeon_connector
))
1278 ret
= connector_status_connected
;
1279 if (!radeon_dig_connector
->edp_on
)
1280 atombios_set_edp_panel_power(connector
,
1281 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1282 } else if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1283 ENCODER_OBJECT_ID_NONE
) {
1284 /* DP bridges are always DP */
1285 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1286 /* get the DPCD from the bridge */
1287 radeon_dp_getdpcd(radeon_connector
);
1290 /* setup ddc on the bridge */
1291 radeon_atom_ext_encoder_setup_ddc(encoder
);
1292 if (radeon_ddc_probe(radeon_connector
)) /* try DDC */
1293 ret
= connector_status_connected
;
1294 else if (radeon_connector
->dac_load_detect
) { /* try load detection */
1295 struct drm_encoder_helper_funcs
*encoder_funcs
= encoder
->helper_private
;
1296 ret
= encoder_funcs
->detect(encoder
, connector
);
1300 radeon_dig_connector
->dp_sink_type
= radeon_dp_getsinktype(radeon_connector
);
1301 if (radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
1302 ret
= connector_status_connected
;
1303 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
)
1304 radeon_dp_getdpcd(radeon_connector
);
1306 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
1307 if (radeon_dp_getdpcd(radeon_connector
))
1308 ret
= connector_status_connected
;
1310 if (radeon_ddc_probe(radeon_connector
))
1311 ret
= connector_status_connected
;
1316 radeon_connector_update_scratch_regs(connector
, ret
);
1320 static int radeon_dp_mode_valid(struct drm_connector
*connector
,
1321 struct drm_display_mode
*mode
)
1323 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1324 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1326 /* XXX check mode bandwidth */
1328 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1329 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1330 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1332 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
1336 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1337 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1339 /* AVIVO hardware supports downscaling modes larger than the panel
1340 * to the panel size, but I'm not sure this is desirable.
1342 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
1343 (mode
->vdisplay
> native_mode
->vdisplay
))
1346 /* if scaling is disabled, block non-native modes */
1347 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
1348 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
1349 (mode
->vdisplay
!= native_mode
->vdisplay
))
1355 if ((radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
1356 (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
))
1357 return radeon_dp_mode_valid_helper(connector
, mode
);
1363 struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs
= {
1364 .get_modes
= radeon_dp_get_modes
,
1365 .mode_valid
= radeon_dp_mode_valid
,
1366 .best_encoder
= radeon_dvi_encoder
,
1369 struct drm_connector_funcs radeon_dp_connector_funcs
= {
1370 .dpms
= drm_helper_connector_dpms
,
1371 .detect
= radeon_dp_detect
,
1372 .fill_modes
= drm_helper_probe_single_connector_modes
,
1373 .set_property
= radeon_connector_set_property
,
1374 .destroy
= radeon_dp_connector_destroy
,
1375 .force
= radeon_dvi_force
,
1379 radeon_add_atom_connector(struct drm_device
*dev
,
1380 uint32_t connector_id
,
1381 uint32_t supported_device
,
1383 struct radeon_i2c_bus_rec
*i2c_bus
,
1384 uint32_t igp_lane_info
,
1385 uint16_t connector_object_id
,
1386 struct radeon_hpd
*hpd
,
1387 struct radeon_router
*router
)
1389 struct radeon_device
*rdev
= dev
->dev_private
;
1390 struct drm_connector
*connector
;
1391 struct radeon_connector
*radeon_connector
;
1392 struct radeon_connector_atom_dig
*radeon_dig_connector
;
1393 struct drm_encoder
*encoder
;
1394 struct radeon_encoder
*radeon_encoder
;
1395 uint32_t subpixel_order
= SubPixelNone
;
1396 bool shared_ddc
= false;
1397 bool is_dp_bridge
= false;
1399 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1402 /* if the user selected tv=0 don't try and add the connector */
1403 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1404 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1405 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1409 /* see if we already added it */
1410 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1411 radeon_connector
= to_radeon_connector(connector
);
1412 if (radeon_connector
->connector_id
== connector_id
) {
1413 radeon_connector
->devices
|= supported_device
;
1416 if (radeon_connector
->ddc_bus
&& i2c_bus
->valid
) {
1417 if (radeon_connector
->ddc_bus
->rec
.i2c_id
== i2c_bus
->i2c_id
) {
1418 radeon_connector
->shared_ddc
= true;
1421 if (radeon_connector
->router_bus
&& router
->ddc_valid
&&
1422 (radeon_connector
->router
.router_id
== router
->router_id
)) {
1423 radeon_connector
->shared_ddc
= false;
1429 /* check if it's a dp bridge */
1430 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
1431 radeon_encoder
= to_radeon_encoder(encoder
);
1432 if (radeon_encoder
->devices
& supported_device
) {
1433 switch (radeon_encoder
->encoder_id
) {
1434 case ENCODER_OBJECT_ID_TRAVIS
:
1435 case ENCODER_OBJECT_ID_NUTMEG
:
1436 is_dp_bridge
= true;
1444 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1445 if (!radeon_connector
)
1448 connector
= &radeon_connector
->base
;
1450 radeon_connector
->connector_id
= connector_id
;
1451 radeon_connector
->devices
= supported_device
;
1452 radeon_connector
->shared_ddc
= shared_ddc
;
1453 radeon_connector
->connector_object_id
= connector_object_id
;
1454 radeon_connector
->hpd
= *hpd
;
1456 radeon_connector
->router
= *router
;
1457 if (router
->ddc_valid
|| router
->cd_valid
) {
1458 radeon_connector
->router_bus
= radeon_i2c_lookup(rdev
, &router
->i2c_info
);
1459 if (!radeon_connector
->router_bus
)
1460 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n");
1464 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1465 if (!radeon_dig_connector
)
1467 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1468 radeon_connector
->con_priv
= radeon_dig_connector
;
1469 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1470 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1471 if (i2c_bus
->valid
) {
1472 /* add DP i2c bus */
1473 if (connector_type
== DRM_MODE_CONNECTOR_eDP
)
1474 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1476 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1477 if (!radeon_dig_connector
->dp_i2c_bus
)
1478 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1479 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1480 if (!radeon_connector
->ddc_bus
)
1481 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1483 switch (connector_type
) {
1484 case DRM_MODE_CONNECTOR_VGA
:
1485 case DRM_MODE_CONNECTOR_DVIA
:
1487 connector
->interlace_allowed
= true;
1488 connector
->doublescan_allowed
= true;
1489 radeon_connector
->dac_load_detect
= true;
1490 drm_connector_attach_property(&radeon_connector
->base
,
1491 rdev
->mode_info
.load_detect_property
,
1494 case DRM_MODE_CONNECTOR_DVII
:
1495 case DRM_MODE_CONNECTOR_DVID
:
1496 case DRM_MODE_CONNECTOR_HDMIA
:
1497 case DRM_MODE_CONNECTOR_HDMIB
:
1498 case DRM_MODE_CONNECTOR_DisplayPort
:
1499 drm_connector_attach_property(&radeon_connector
->base
,
1500 rdev
->mode_info
.underscan_property
,
1502 drm_connector_attach_property(&radeon_connector
->base
,
1503 rdev
->mode_info
.underscan_hborder_property
,
1505 drm_connector_attach_property(&radeon_connector
->base
,
1506 rdev
->mode_info
.underscan_vborder_property
,
1508 subpixel_order
= SubPixelHorizontalRGB
;
1509 connector
->interlace_allowed
= true;
1510 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1511 connector
->doublescan_allowed
= true;
1513 connector
->doublescan_allowed
= false;
1514 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1515 radeon_connector
->dac_load_detect
= true;
1516 drm_connector_attach_property(&radeon_connector
->base
,
1517 rdev
->mode_info
.load_detect_property
,
1521 case DRM_MODE_CONNECTOR_LVDS
:
1522 case DRM_MODE_CONNECTOR_eDP
:
1523 drm_connector_attach_property(&radeon_connector
->base
,
1524 dev
->mode_config
.scaling_mode_property
,
1525 DRM_MODE_SCALE_FULLSCREEN
);
1526 subpixel_order
= SubPixelHorizontalRGB
;
1527 connector
->interlace_allowed
= false;
1528 connector
->doublescan_allowed
= false;
1532 switch (connector_type
) {
1533 case DRM_MODE_CONNECTOR_VGA
:
1534 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1535 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1536 if (i2c_bus
->valid
) {
1537 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1538 if (!radeon_connector
->ddc_bus
)
1539 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1541 radeon_connector
->dac_load_detect
= true;
1542 drm_connector_attach_property(&radeon_connector
->base
,
1543 rdev
->mode_info
.load_detect_property
,
1545 /* no HPD on analog connectors */
1546 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1547 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1548 connector
->interlace_allowed
= true;
1549 connector
->doublescan_allowed
= true;
1551 case DRM_MODE_CONNECTOR_DVIA
:
1552 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1553 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1554 if (i2c_bus
->valid
) {
1555 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1556 if (!radeon_connector
->ddc_bus
)
1557 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1559 radeon_connector
->dac_load_detect
= true;
1560 drm_connector_attach_property(&radeon_connector
->base
,
1561 rdev
->mode_info
.load_detect_property
,
1563 /* no HPD on analog connectors */
1564 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1565 connector
->interlace_allowed
= true;
1566 connector
->doublescan_allowed
= true;
1568 case DRM_MODE_CONNECTOR_DVII
:
1569 case DRM_MODE_CONNECTOR_DVID
:
1570 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1571 if (!radeon_dig_connector
)
1573 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1574 radeon_connector
->con_priv
= radeon_dig_connector
;
1575 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1576 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1577 if (i2c_bus
->valid
) {
1578 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1579 if (!radeon_connector
->ddc_bus
)
1580 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1582 subpixel_order
= SubPixelHorizontalRGB
;
1583 drm_connector_attach_property(&radeon_connector
->base
,
1584 rdev
->mode_info
.coherent_mode_property
,
1586 if (ASIC_IS_AVIVO(rdev
)) {
1587 drm_connector_attach_property(&radeon_connector
->base
,
1588 rdev
->mode_info
.underscan_property
,
1590 drm_connector_attach_property(&radeon_connector
->base
,
1591 rdev
->mode_info
.underscan_hborder_property
,
1593 drm_connector_attach_property(&radeon_connector
->base
,
1594 rdev
->mode_info
.underscan_vborder_property
,
1597 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1598 radeon_connector
->dac_load_detect
= true;
1599 drm_connector_attach_property(&radeon_connector
->base
,
1600 rdev
->mode_info
.load_detect_property
,
1603 connector
->interlace_allowed
= true;
1604 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
1605 connector
->doublescan_allowed
= true;
1607 connector
->doublescan_allowed
= false;
1609 case DRM_MODE_CONNECTOR_HDMIA
:
1610 case DRM_MODE_CONNECTOR_HDMIB
:
1611 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1612 if (!radeon_dig_connector
)
1614 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1615 radeon_connector
->con_priv
= radeon_dig_connector
;
1616 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1617 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1618 if (i2c_bus
->valid
) {
1619 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1620 if (!radeon_connector
->ddc_bus
)
1621 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1623 drm_connector_attach_property(&radeon_connector
->base
,
1624 rdev
->mode_info
.coherent_mode_property
,
1626 if (ASIC_IS_AVIVO(rdev
)) {
1627 drm_connector_attach_property(&radeon_connector
->base
,
1628 rdev
->mode_info
.underscan_property
,
1630 drm_connector_attach_property(&radeon_connector
->base
,
1631 rdev
->mode_info
.underscan_hborder_property
,
1633 drm_connector_attach_property(&radeon_connector
->base
,
1634 rdev
->mode_info
.underscan_vborder_property
,
1637 subpixel_order
= SubPixelHorizontalRGB
;
1638 connector
->interlace_allowed
= true;
1639 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1640 connector
->doublescan_allowed
= true;
1642 connector
->doublescan_allowed
= false;
1644 case DRM_MODE_CONNECTOR_DisplayPort
:
1645 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1646 if (!radeon_dig_connector
)
1648 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1649 radeon_connector
->con_priv
= radeon_dig_connector
;
1650 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1651 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1652 if (i2c_bus
->valid
) {
1653 /* add DP i2c bus */
1654 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1655 if (!radeon_dig_connector
->dp_i2c_bus
)
1656 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1657 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1658 if (!radeon_connector
->ddc_bus
)
1659 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1661 subpixel_order
= SubPixelHorizontalRGB
;
1662 drm_connector_attach_property(&radeon_connector
->base
,
1663 rdev
->mode_info
.coherent_mode_property
,
1665 if (ASIC_IS_AVIVO(rdev
)) {
1666 drm_connector_attach_property(&radeon_connector
->base
,
1667 rdev
->mode_info
.underscan_property
,
1669 drm_connector_attach_property(&radeon_connector
->base
,
1670 rdev
->mode_info
.underscan_hborder_property
,
1672 drm_connector_attach_property(&radeon_connector
->base
,
1673 rdev
->mode_info
.underscan_vborder_property
,
1676 connector
->interlace_allowed
= true;
1677 /* in theory with a DP to VGA converter... */
1678 connector
->doublescan_allowed
= false;
1680 case DRM_MODE_CONNECTOR_eDP
:
1681 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1682 if (!radeon_dig_connector
)
1684 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1685 radeon_connector
->con_priv
= radeon_dig_connector
;
1686 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1687 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1688 if (i2c_bus
->valid
) {
1689 /* add DP i2c bus */
1690 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1691 if (!radeon_dig_connector
->dp_i2c_bus
)
1692 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1693 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1694 if (!radeon_connector
->ddc_bus
)
1695 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1697 drm_connector_attach_property(&radeon_connector
->base
,
1698 dev
->mode_config
.scaling_mode_property
,
1699 DRM_MODE_SCALE_FULLSCREEN
);
1700 subpixel_order
= SubPixelHorizontalRGB
;
1701 connector
->interlace_allowed
= false;
1702 connector
->doublescan_allowed
= false;
1704 case DRM_MODE_CONNECTOR_SVIDEO
:
1705 case DRM_MODE_CONNECTOR_Composite
:
1706 case DRM_MODE_CONNECTOR_9PinDIN
:
1707 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1708 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1709 radeon_connector
->dac_load_detect
= true;
1710 drm_connector_attach_property(&radeon_connector
->base
,
1711 rdev
->mode_info
.load_detect_property
,
1713 drm_connector_attach_property(&radeon_connector
->base
,
1714 rdev
->mode_info
.tv_std_property
,
1715 radeon_atombios_get_tv_info(rdev
));
1716 /* no HPD on analog connectors */
1717 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1718 connector
->interlace_allowed
= false;
1719 connector
->doublescan_allowed
= false;
1721 case DRM_MODE_CONNECTOR_LVDS
:
1722 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1723 if (!radeon_dig_connector
)
1725 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1726 radeon_connector
->con_priv
= radeon_dig_connector
;
1727 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1728 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1729 if (i2c_bus
->valid
) {
1730 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1731 if (!radeon_connector
->ddc_bus
)
1732 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1734 drm_connector_attach_property(&radeon_connector
->base
,
1735 dev
->mode_config
.scaling_mode_property
,
1736 DRM_MODE_SCALE_FULLSCREEN
);
1737 subpixel_order
= SubPixelHorizontalRGB
;
1738 connector
->interlace_allowed
= false;
1739 connector
->doublescan_allowed
= false;
1744 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
1746 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1748 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
1750 connector
->display_info
.subpixel_order
= subpixel_order
;
1751 drm_sysfs_connector_add(connector
);
1755 drm_connector_cleanup(connector
);
1760 radeon_add_legacy_connector(struct drm_device
*dev
,
1761 uint32_t connector_id
,
1762 uint32_t supported_device
,
1764 struct radeon_i2c_bus_rec
*i2c_bus
,
1765 uint16_t connector_object_id
,
1766 struct radeon_hpd
*hpd
)
1768 struct radeon_device
*rdev
= dev
->dev_private
;
1769 struct drm_connector
*connector
;
1770 struct radeon_connector
*radeon_connector
;
1771 uint32_t subpixel_order
= SubPixelNone
;
1773 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1776 /* if the user selected tv=0 don't try and add the connector */
1777 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1778 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1779 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1783 /* see if we already added it */
1784 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1785 radeon_connector
= to_radeon_connector(connector
);
1786 if (radeon_connector
->connector_id
== connector_id
) {
1787 radeon_connector
->devices
|= supported_device
;
1792 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1793 if (!radeon_connector
)
1796 connector
= &radeon_connector
->base
;
1798 radeon_connector
->connector_id
= connector_id
;
1799 radeon_connector
->devices
= supported_device
;
1800 radeon_connector
->connector_object_id
= connector_object_id
;
1801 radeon_connector
->hpd
= *hpd
;
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
);