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
27 #include <drm/drm_edid.h>
28 #include <drm/drm_crtc_helper.h>
29 #include <drm/drm_fb_helper.h>
30 #include <drm/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
,
43 void radeon_connector_hotplug(struct drm_connector
*connector
)
45 struct drm_device
*dev
= connector
->dev
;
46 struct radeon_device
*rdev
= dev
->dev_private
;
47 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
49 /* bail if the connector does not have hpd pin, e.g.,
52 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
)
55 radeon_hpd_set_polarity(rdev
, radeon_connector
->hpd
.hpd
);
57 /* if the connector is already off, don't turn it back on */
58 if (connector
->dpms
!= DRM_MODE_DPMS_ON
)
61 /* just deal with DP (not eDP) here. */
62 if (connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
) {
63 struct radeon_connector_atom_dig
*dig_connector
=
64 radeon_connector
->con_priv
;
66 /* if existing sink type was not DP no need to retrain */
67 if (dig_connector
->dp_sink_type
!= CONNECTOR_OBJECT_ID_DISPLAYPORT
)
70 /* first get sink type as it may be reset after (un)plug */
71 dig_connector
->dp_sink_type
= radeon_dp_getsinktype(radeon_connector
);
72 /* don't do anything if sink is not display port, i.e.,
73 * passive dp->(dvi|hdmi) adaptor
75 if (dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
76 int saved_dpms
= connector
->dpms
;
77 /* Only turn off the display if it's physically disconnected */
78 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
79 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_OFF
);
80 } else if (radeon_dp_needs_link_train(radeon_connector
)) {
81 /* set it to OFF so that drm_helper_connector_dpms()
82 * won't return immediately since the current state
83 * is ON at this point.
85 connector
->dpms
= DRM_MODE_DPMS_OFF
;
86 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_ON
);
88 connector
->dpms
= saved_dpms
;
93 static void radeon_property_change_mode(struct drm_encoder
*encoder
)
95 struct drm_crtc
*crtc
= encoder
->crtc
;
97 if (crtc
&& crtc
->enabled
) {
98 drm_crtc_helper_set_mode(crtc
, &crtc
->mode
,
99 crtc
->x
, crtc
->y
, crtc
->fb
);
103 int radeon_get_monitor_bpc(struct drm_connector
*connector
)
105 struct drm_device
*dev
= connector
->dev
;
106 struct radeon_device
*rdev
= dev
->dev_private
;
107 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
108 struct radeon_connector_atom_dig
*dig_connector
;
111 switch (connector
->connector_type
) {
112 case DRM_MODE_CONNECTOR_DVII
:
113 case DRM_MODE_CONNECTOR_HDMIB
:
114 if (radeon_connector
->use_digital
) {
115 if (drm_detect_hdmi_monitor(radeon_connector
->edid
)) {
116 if (connector
->display_info
.bpc
)
117 bpc
= connector
->display_info
.bpc
;
121 case DRM_MODE_CONNECTOR_DVID
:
122 case DRM_MODE_CONNECTOR_HDMIA
:
123 if (drm_detect_hdmi_monitor(radeon_connector
->edid
)) {
124 if (connector
->display_info
.bpc
)
125 bpc
= connector
->display_info
.bpc
;
128 case DRM_MODE_CONNECTOR_DisplayPort
:
129 dig_connector
= radeon_connector
->con_priv
;
130 if ((dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
131 (dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
) ||
132 drm_detect_hdmi_monitor(radeon_connector
->edid
)) {
133 if (connector
->display_info
.bpc
)
134 bpc
= connector
->display_info
.bpc
;
137 case DRM_MODE_CONNECTOR_eDP
:
138 case DRM_MODE_CONNECTOR_LVDS
:
139 if (connector
->display_info
.bpc
)
140 bpc
= connector
->display_info
.bpc
;
141 else if (ASIC_IS_DCE41(rdev
) || ASIC_IS_DCE5(rdev
)) {
142 struct drm_connector_helper_funcs
*connector_funcs
=
143 connector
->helper_private
;
144 struct drm_encoder
*encoder
= connector_funcs
->best_encoder(connector
);
145 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
146 struct radeon_encoder_atom_dig
*dig
= radeon_encoder
->enc_priv
;
148 if (dig
->lcd_misc
& ATOM_PANEL_MISC_V13_6BIT_PER_COLOR
)
150 else if (dig
->lcd_misc
& ATOM_PANEL_MISC_V13_8BIT_PER_COLOR
)
159 radeon_connector_update_scratch_regs(struct drm_connector
*connector
, enum drm_connector_status status
)
161 struct drm_device
*dev
= connector
->dev
;
162 struct radeon_device
*rdev
= dev
->dev_private
;
163 struct drm_encoder
*best_encoder
= NULL
;
164 struct drm_encoder
*encoder
= NULL
;
165 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
166 struct drm_mode_object
*obj
;
170 best_encoder
= connector_funcs
->best_encoder(connector
);
172 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
173 if (connector
->encoder_ids
[i
] == 0)
176 obj
= drm_mode_object_find(connector
->dev
,
177 connector
->encoder_ids
[i
],
178 DRM_MODE_OBJECT_ENCODER
);
182 encoder
= obj_to_encoder(obj
);
184 if ((encoder
== best_encoder
) && (status
== connector_status_connected
))
189 if (rdev
->is_atom_bios
)
190 radeon_atombios_connected_scratch_regs(connector
, encoder
, connected
);
192 radeon_combios_connected_scratch_regs(connector
, encoder
, connected
);
197 static struct drm_encoder
*radeon_find_encoder(struct drm_connector
*connector
, int encoder_type
)
199 struct drm_mode_object
*obj
;
200 struct drm_encoder
*encoder
;
203 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
204 if (connector
->encoder_ids
[i
] == 0)
207 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
211 encoder
= obj_to_encoder(obj
);
212 if (encoder
->encoder_type
== encoder_type
)
218 static struct drm_encoder
*radeon_best_single_encoder(struct drm_connector
*connector
)
220 int enc_id
= connector
->encoder_ids
[0];
221 struct drm_mode_object
*obj
;
222 struct drm_encoder
*encoder
;
224 /* pick the encoder ids */
226 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
229 encoder
= obj_to_encoder(obj
);
236 * radeon_connector_analog_encoder_conflict_solve
237 * - search for other connectors sharing this encoder
238 * if priority is true, then set them disconnected if this is connected
239 * if priority is false, set us disconnected if they are connected
241 static enum drm_connector_status
242 radeon_connector_analog_encoder_conflict_solve(struct drm_connector
*connector
,
243 struct drm_encoder
*encoder
,
244 enum drm_connector_status current_status
,
247 struct drm_device
*dev
= connector
->dev
;
248 struct drm_connector
*conflict
;
249 struct radeon_connector
*radeon_conflict
;
252 list_for_each_entry(conflict
, &dev
->mode_config
.connector_list
, head
) {
253 if (conflict
== connector
)
256 radeon_conflict
= to_radeon_connector(conflict
);
257 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
258 if (conflict
->encoder_ids
[i
] == 0)
261 /* if the IDs match */
262 if (conflict
->encoder_ids
[i
] == encoder
->base
.id
) {
263 if (conflict
->status
!= connector_status_connected
)
266 if (radeon_conflict
->use_digital
)
269 if (priority
== true) {
270 DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict
));
271 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(connector
));
272 conflict
->status
= connector_status_disconnected
;
273 radeon_connector_update_scratch_regs(conflict
, connector_status_disconnected
);
275 DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector
));
276 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(conflict
));
277 current_status
= connector_status_disconnected
;
283 return current_status
;
287 static struct drm_display_mode
*radeon_fp_native_mode(struct drm_encoder
*encoder
)
289 struct drm_device
*dev
= encoder
->dev
;
290 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
291 struct drm_display_mode
*mode
= NULL
;
292 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
294 if (native_mode
->hdisplay
!= 0 &&
295 native_mode
->vdisplay
!= 0 &&
296 native_mode
->clock
!= 0) {
297 mode
= drm_mode_duplicate(dev
, native_mode
);
298 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
299 drm_mode_set_name(mode
);
301 DRM_DEBUG_KMS("Adding native panel mode %s\n", mode
->name
);
302 } else if (native_mode
->hdisplay
!= 0 &&
303 native_mode
->vdisplay
!= 0) {
304 /* mac laptops without an edid */
305 /* Note that this is not necessarily the exact panel mode,
306 * but an approximation based on the cvt formula. For these
307 * systems we should ideally read the mode info out of the
308 * registers or add a mode table, but this works and is much
311 mode
= drm_cvt_mode(dev
, native_mode
->hdisplay
, native_mode
->vdisplay
, 60, true, false, false);
312 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
313 DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode
->name
);
318 static void radeon_add_common_modes(struct drm_encoder
*encoder
, struct drm_connector
*connector
)
320 struct drm_device
*dev
= encoder
->dev
;
321 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
322 struct drm_display_mode
*mode
= NULL
;
323 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
328 } common_modes
[17] = {
348 for (i
= 0; i
< 17; i
++) {
349 if (radeon_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
)) {
350 if (common_modes
[i
].w
> 1024 ||
351 common_modes
[i
].h
> 768)
354 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
355 if (common_modes
[i
].w
> native_mode
->hdisplay
||
356 common_modes
[i
].h
> native_mode
->vdisplay
||
357 (common_modes
[i
].w
== native_mode
->hdisplay
&&
358 common_modes
[i
].h
== native_mode
->vdisplay
))
361 if (common_modes
[i
].w
< 320 || common_modes
[i
].h
< 200)
364 mode
= drm_cvt_mode(dev
, common_modes
[i
].w
, common_modes
[i
].h
, 60, false, false, false);
365 drm_mode_probed_add(connector
, mode
);
369 static int radeon_connector_set_property(struct drm_connector
*connector
, struct drm_property
*property
,
372 struct drm_device
*dev
= connector
->dev
;
373 struct radeon_device
*rdev
= dev
->dev_private
;
374 struct drm_encoder
*encoder
;
375 struct radeon_encoder
*radeon_encoder
;
377 if (property
== rdev
->mode_info
.coherent_mode_property
) {
378 struct radeon_encoder_atom_dig
*dig
;
379 bool new_coherent_mode
;
381 /* need to find digital encoder on connector */
382 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
386 radeon_encoder
= to_radeon_encoder(encoder
);
388 if (!radeon_encoder
->enc_priv
)
391 dig
= radeon_encoder
->enc_priv
;
392 new_coherent_mode
= val
? true : false;
393 if (dig
->coherent_mode
!= new_coherent_mode
) {
394 dig
->coherent_mode
= new_coherent_mode
;
395 radeon_property_change_mode(&radeon_encoder
->base
);
399 if (property
== rdev
->mode_info
.audio_property
) {
400 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
401 /* need to find digital encoder on connector */
402 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
406 radeon_encoder
= to_radeon_encoder(encoder
);
408 if (radeon_connector
->audio
!= val
) {
409 radeon_connector
->audio
= val
;
410 radeon_property_change_mode(&radeon_encoder
->base
);
414 if (property
== rdev
->mode_info
.underscan_property
) {
415 /* need to find digital encoder on connector */
416 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
420 radeon_encoder
= to_radeon_encoder(encoder
);
422 if (radeon_encoder
->underscan_type
!= val
) {
423 radeon_encoder
->underscan_type
= val
;
424 radeon_property_change_mode(&radeon_encoder
->base
);
428 if (property
== rdev
->mode_info
.underscan_hborder_property
) {
429 /* need to find digital encoder on connector */
430 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
434 radeon_encoder
= to_radeon_encoder(encoder
);
436 if (radeon_encoder
->underscan_hborder
!= val
) {
437 radeon_encoder
->underscan_hborder
= val
;
438 radeon_property_change_mode(&radeon_encoder
->base
);
442 if (property
== rdev
->mode_info
.underscan_vborder_property
) {
443 /* need to find digital encoder on connector */
444 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
448 radeon_encoder
= to_radeon_encoder(encoder
);
450 if (radeon_encoder
->underscan_vborder
!= val
) {
451 radeon_encoder
->underscan_vborder
= val
;
452 radeon_property_change_mode(&radeon_encoder
->base
);
456 if (property
== rdev
->mode_info
.tv_std_property
) {
457 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TVDAC
);
459 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_DAC
);
465 radeon_encoder
= to_radeon_encoder(encoder
);
466 if (!radeon_encoder
->enc_priv
)
468 if (ASIC_IS_AVIVO(rdev
) || radeon_r4xx_atom
) {
469 struct radeon_encoder_atom_dac
*dac_int
;
470 dac_int
= radeon_encoder
->enc_priv
;
471 dac_int
->tv_std
= val
;
473 struct radeon_encoder_tv_dac
*dac_int
;
474 dac_int
= radeon_encoder
->enc_priv
;
475 dac_int
->tv_std
= val
;
477 radeon_property_change_mode(&radeon_encoder
->base
);
480 if (property
== rdev
->mode_info
.load_detect_property
) {
481 struct radeon_connector
*radeon_connector
=
482 to_radeon_connector(connector
);
485 radeon_connector
->dac_load_detect
= false;
487 radeon_connector
->dac_load_detect
= true;
490 if (property
== rdev
->mode_info
.tmds_pll_property
) {
491 struct radeon_encoder_int_tmds
*tmds
= NULL
;
493 /* need to find digital encoder on connector */
494 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
498 radeon_encoder
= to_radeon_encoder(encoder
);
500 tmds
= radeon_encoder
->enc_priv
;
505 if (rdev
->is_atom_bios
)
506 ret
= radeon_atombios_get_tmds_info(radeon_encoder
, tmds
);
508 ret
= radeon_legacy_get_tmds_info_from_combios(radeon_encoder
, tmds
);
510 if (val
== 1 || ret
== false) {
511 radeon_legacy_get_tmds_info_from_table(radeon_encoder
, tmds
);
513 radeon_property_change_mode(&radeon_encoder
->base
);
519 static void radeon_fixup_lvds_native_mode(struct drm_encoder
*encoder
,
520 struct drm_connector
*connector
)
522 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
523 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
524 struct drm_display_mode
*t
, *mode
;
526 /* If the EDID preferred mode doesn't match the native mode, use it */
527 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
528 if (mode
->type
& DRM_MODE_TYPE_PREFERRED
) {
529 if (mode
->hdisplay
!= native_mode
->hdisplay
||
530 mode
->vdisplay
!= native_mode
->vdisplay
)
531 memcpy(native_mode
, mode
, sizeof(*mode
));
535 /* Try to get native mode details from EDID if necessary */
536 if (!native_mode
->clock
) {
537 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
538 if (mode
->hdisplay
== native_mode
->hdisplay
&&
539 mode
->vdisplay
== native_mode
->vdisplay
) {
540 *native_mode
= *mode
;
541 drm_mode_set_crtcinfo(native_mode
, CRTC_INTERLACE_HALVE_V
);
542 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
548 if (!native_mode
->clock
) {
549 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n");
550 radeon_encoder
->rmx_type
= RMX_OFF
;
554 static int radeon_lvds_get_modes(struct drm_connector
*connector
)
556 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
557 struct drm_encoder
*encoder
;
559 struct drm_display_mode
*mode
;
561 if (radeon_connector
->ddc_bus
) {
562 ret
= radeon_ddc_get_modes(radeon_connector
);
564 encoder
= radeon_best_single_encoder(connector
);
566 radeon_fixup_lvds_native_mode(encoder
, connector
);
567 /* add scaled modes */
568 radeon_add_common_modes(encoder
, connector
);
574 encoder
= radeon_best_single_encoder(connector
);
578 /* we have no EDID modes */
579 mode
= radeon_fp_native_mode(encoder
);
582 drm_mode_probed_add(connector
, mode
);
583 /* add the width/height from vbios tables if available */
584 connector
->display_info
.width_mm
= mode
->width_mm
;
585 connector
->display_info
.height_mm
= mode
->height_mm
;
586 /* add scaled modes */
587 radeon_add_common_modes(encoder
, connector
);
593 static int radeon_lvds_mode_valid(struct drm_connector
*connector
,
594 struct drm_display_mode
*mode
)
596 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
598 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
602 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
603 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
605 /* AVIVO hardware supports downscaling modes larger than the panel
606 * to the panel size, but I'm not sure this is desirable.
608 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
609 (mode
->vdisplay
> native_mode
->vdisplay
))
612 /* if scaling is disabled, block non-native modes */
613 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
614 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
615 (mode
->vdisplay
!= native_mode
->vdisplay
))
623 static enum drm_connector_status
624 radeon_lvds_detect(struct drm_connector
*connector
, bool force
)
626 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
627 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
628 enum drm_connector_status ret
= connector_status_disconnected
;
631 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
632 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
634 /* check if panel is valid */
635 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
636 ret
= connector_status_connected
;
640 /* check for edid as well */
641 if (radeon_connector
->edid
)
642 ret
= connector_status_connected
;
644 if (radeon_connector
->ddc_bus
) {
645 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
,
646 &radeon_connector
->ddc_bus
->adapter
);
647 if (radeon_connector
->edid
)
648 ret
= connector_status_connected
;
651 /* check acpi lid status ??? */
653 radeon_connector_update_scratch_regs(connector
, ret
);
657 static void radeon_connector_destroy(struct drm_connector
*connector
)
659 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
661 if (radeon_connector
->edid
)
662 kfree(radeon_connector
->edid
);
663 kfree(radeon_connector
->con_priv
);
664 drm_sysfs_connector_remove(connector
);
665 drm_connector_cleanup(connector
);
669 static int radeon_lvds_set_property(struct drm_connector
*connector
,
670 struct drm_property
*property
,
673 struct drm_device
*dev
= connector
->dev
;
674 struct radeon_encoder
*radeon_encoder
;
675 enum radeon_rmx_type rmx_type
;
678 if (property
!= dev
->mode_config
.scaling_mode_property
)
681 if (connector
->encoder
)
682 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
684 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
685 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
689 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
690 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
691 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
693 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
695 if (radeon_encoder
->rmx_type
== rmx_type
)
698 radeon_encoder
->rmx_type
= rmx_type
;
700 radeon_property_change_mode(&radeon_encoder
->base
);
705 static const struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs
= {
706 .get_modes
= radeon_lvds_get_modes
,
707 .mode_valid
= radeon_lvds_mode_valid
,
708 .best_encoder
= radeon_best_single_encoder
,
711 static const struct drm_connector_funcs radeon_lvds_connector_funcs
= {
712 .dpms
= drm_helper_connector_dpms
,
713 .detect
= radeon_lvds_detect
,
714 .fill_modes
= drm_helper_probe_single_connector_modes
,
715 .destroy
= radeon_connector_destroy
,
716 .set_property
= radeon_lvds_set_property
,
719 static int radeon_vga_get_modes(struct drm_connector
*connector
)
721 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
724 ret
= radeon_ddc_get_modes(radeon_connector
);
729 static int radeon_vga_mode_valid(struct drm_connector
*connector
,
730 struct drm_display_mode
*mode
)
732 struct drm_device
*dev
= connector
->dev
;
733 struct radeon_device
*rdev
= dev
->dev_private
;
735 /* XXX check mode bandwidth */
737 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
738 return MODE_CLOCK_HIGH
;
743 static enum drm_connector_status
744 radeon_vga_detect(struct drm_connector
*connector
, bool force
)
746 struct drm_device
*dev
= connector
->dev
;
747 struct radeon_device
*rdev
= dev
->dev_private
;
748 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
749 struct drm_encoder
*encoder
;
750 struct drm_encoder_helper_funcs
*encoder_funcs
;
752 enum drm_connector_status ret
= connector_status_disconnected
;
754 encoder
= radeon_best_single_encoder(connector
);
756 ret
= connector_status_disconnected
;
758 if (radeon_connector
->ddc_bus
)
759 dret
= radeon_ddc_probe(radeon_connector
, false);
761 radeon_connector
->detected_by_load
= false;
762 if (radeon_connector
->edid
) {
763 kfree(radeon_connector
->edid
);
764 radeon_connector
->edid
= NULL
;
766 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
768 if (!radeon_connector
->edid
) {
769 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
770 drm_get_connector_name(connector
));
771 ret
= connector_status_connected
;
773 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
775 /* some oems have boards with separate digital and analog connectors
776 * with a shared ddc line (often vga + hdmi)
778 if (radeon_connector
->use_digital
&& radeon_connector
->shared_ddc
) {
779 kfree(radeon_connector
->edid
);
780 radeon_connector
->edid
= NULL
;
781 ret
= connector_status_disconnected
;
783 ret
= connector_status_connected
;
787 /* if we aren't forcing don't do destructive polling */
789 /* only return the previous status if we last
790 * detected a monitor via load.
792 if (radeon_connector
->detected_by_load
)
793 return connector
->status
;
798 if (radeon_connector
->dac_load_detect
&& encoder
) {
799 encoder_funcs
= encoder
->helper_private
;
800 ret
= encoder_funcs
->detect(encoder
, connector
);
801 if (ret
!= connector_status_disconnected
)
802 radeon_connector
->detected_by_load
= true;
806 if (ret
== connector_status_connected
)
807 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
809 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
810 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
811 * by other means, assume the CRT is connected and use that EDID.
813 if ((!rdev
->is_atom_bios
) &&
814 (ret
== connector_status_disconnected
) &&
815 rdev
->mode_info
.bios_hardcoded_edid_size
) {
816 ret
= connector_status_connected
;
819 radeon_connector_update_scratch_regs(connector
, ret
);
823 static const struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs
= {
824 .get_modes
= radeon_vga_get_modes
,
825 .mode_valid
= radeon_vga_mode_valid
,
826 .best_encoder
= radeon_best_single_encoder
,
829 static const struct drm_connector_funcs radeon_vga_connector_funcs
= {
830 .dpms
= drm_helper_connector_dpms
,
831 .detect
= radeon_vga_detect
,
832 .fill_modes
= drm_helper_probe_single_connector_modes
,
833 .destroy
= radeon_connector_destroy
,
834 .set_property
= radeon_connector_set_property
,
837 static int radeon_tv_get_modes(struct drm_connector
*connector
)
839 struct drm_device
*dev
= connector
->dev
;
840 struct radeon_device
*rdev
= dev
->dev_private
;
841 struct drm_display_mode
*tv_mode
;
842 struct drm_encoder
*encoder
;
844 encoder
= radeon_best_single_encoder(connector
);
848 /* avivo chips can scale any mode */
849 if (rdev
->family
>= CHIP_RS600
)
850 /* add scaled modes */
851 radeon_add_common_modes(encoder
, connector
);
853 /* only 800x600 is supported right now on pre-avivo chips */
854 tv_mode
= drm_cvt_mode(dev
, 800, 600, 60, false, false, false);
855 tv_mode
->type
= DRM_MODE_TYPE_DRIVER
| DRM_MODE_TYPE_PREFERRED
;
856 drm_mode_probed_add(connector
, tv_mode
);
861 static int radeon_tv_mode_valid(struct drm_connector
*connector
,
862 struct drm_display_mode
*mode
)
864 if ((mode
->hdisplay
> 1024) || (mode
->vdisplay
> 768))
865 return MODE_CLOCK_RANGE
;
869 static enum drm_connector_status
870 radeon_tv_detect(struct drm_connector
*connector
, bool force
)
872 struct drm_encoder
*encoder
;
873 struct drm_encoder_helper_funcs
*encoder_funcs
;
874 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
875 enum drm_connector_status ret
= connector_status_disconnected
;
877 if (!radeon_connector
->dac_load_detect
)
880 encoder
= radeon_best_single_encoder(connector
);
882 ret
= connector_status_disconnected
;
884 encoder_funcs
= encoder
->helper_private
;
885 ret
= encoder_funcs
->detect(encoder
, connector
);
887 if (ret
== connector_status_connected
)
888 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, false);
889 radeon_connector_update_scratch_regs(connector
, ret
);
893 static const struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs
= {
894 .get_modes
= radeon_tv_get_modes
,
895 .mode_valid
= radeon_tv_mode_valid
,
896 .best_encoder
= radeon_best_single_encoder
,
899 static const struct drm_connector_funcs radeon_tv_connector_funcs
= {
900 .dpms
= drm_helper_connector_dpms
,
901 .detect
= radeon_tv_detect
,
902 .fill_modes
= drm_helper_probe_single_connector_modes
,
903 .destroy
= radeon_connector_destroy
,
904 .set_property
= radeon_connector_set_property
,
907 static int radeon_dvi_get_modes(struct drm_connector
*connector
)
909 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
912 ret
= radeon_ddc_get_modes(radeon_connector
);
916 static bool radeon_check_hpd_status_unchanged(struct drm_connector
*connector
)
918 struct drm_device
*dev
= connector
->dev
;
919 struct radeon_device
*rdev
= dev
->dev_private
;
920 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
921 enum drm_connector_status status
;
923 /* We only trust HPD on R600 and newer ASICS. */
924 if (rdev
->family
>= CHIP_R600
925 && radeon_connector
->hpd
.hpd
!= RADEON_HPD_NONE
) {
926 if (radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
))
927 status
= connector_status_connected
;
929 status
= connector_status_disconnected
;
930 if (connector
->status
== status
)
939 * Do a DDC probe, if DDC probe passes, get the full EDID so
940 * we can do analog/digital monitor detection at this point.
941 * If the monitor is an analog monitor or we got no DDC,
942 * we need to find the DAC encoder object for this connector.
943 * If we got no DDC, we do load detection on the DAC encoder object.
944 * If we got analog DDC or load detection passes on the DAC encoder
945 * we have to check if this analog encoder is shared with anyone else (TV)
946 * if its shared we have to set the other connector to disconnected.
948 static enum drm_connector_status
949 radeon_dvi_detect(struct drm_connector
*connector
, bool force
)
951 struct drm_device
*dev
= connector
->dev
;
952 struct radeon_device
*rdev
= dev
->dev_private
;
953 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
954 struct drm_encoder
*encoder
= NULL
;
955 struct drm_encoder_helper_funcs
*encoder_funcs
;
956 struct drm_mode_object
*obj
;
958 enum drm_connector_status ret
= connector_status_disconnected
;
959 bool dret
= false, broken_edid
= false;
961 if (!force
&& radeon_check_hpd_status_unchanged(connector
))
962 return connector
->status
;
964 if (radeon_connector
->ddc_bus
)
965 dret
= radeon_ddc_probe(radeon_connector
, false);
967 radeon_connector
->detected_by_load
= false;
968 if (radeon_connector
->edid
) {
969 kfree(radeon_connector
->edid
);
970 radeon_connector
->edid
= NULL
;
972 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
974 if (!radeon_connector
->edid
) {
975 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
976 drm_get_connector_name(connector
));
977 /* rs690 seems to have a problem with connectors not existing and always
978 * return a block of 0's. If we see this just stop polling on this output */
979 if ((rdev
->family
== CHIP_RS690
|| rdev
->family
== CHIP_RS740
) && radeon_connector
->base
.null_edid_counter
) {
980 ret
= connector_status_disconnected
;
981 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", drm_get_connector_name(connector
));
982 radeon_connector
->ddc_bus
= NULL
;
984 ret
= connector_status_connected
;
985 broken_edid
= true; /* defer use_digital to later */
988 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
990 /* some oems have boards with separate digital and analog connectors
991 * with a shared ddc line (often vga + hdmi)
993 if ((!radeon_connector
->use_digital
) && radeon_connector
->shared_ddc
) {
994 kfree(radeon_connector
->edid
);
995 radeon_connector
->edid
= NULL
;
996 ret
= connector_status_disconnected
;
998 ret
= connector_status_connected
;
1000 /* This gets complicated. We have boards with VGA + HDMI with a
1001 * shared DDC line and we have boards with DVI-D + HDMI with a shared
1002 * DDC line. The latter is more complex because with DVI<->HDMI adapters
1003 * you don't really know what's connected to which port as both are digital.
1005 if (radeon_connector
->shared_ddc
&& (ret
== connector_status_connected
)) {
1006 struct drm_connector
*list_connector
;
1007 struct radeon_connector
*list_radeon_connector
;
1008 list_for_each_entry(list_connector
, &dev
->mode_config
.connector_list
, head
) {
1009 if (connector
== list_connector
)
1011 list_radeon_connector
= to_radeon_connector(list_connector
);
1012 if (list_radeon_connector
->shared_ddc
&&
1013 (list_radeon_connector
->ddc_bus
->rec
.i2c_id
==
1014 radeon_connector
->ddc_bus
->rec
.i2c_id
)) {
1015 /* cases where both connectors are digital */
1016 if (list_connector
->connector_type
!= DRM_MODE_CONNECTOR_VGA
) {
1017 /* hpd is our only option in this case */
1018 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
1019 kfree(radeon_connector
->edid
);
1020 radeon_connector
->edid
= NULL
;
1021 ret
= connector_status_disconnected
;
1030 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== true))
1033 /* DVI-D and HDMI-A are digital only */
1034 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_DVID
) ||
1035 (connector
->connector_type
== DRM_MODE_CONNECTOR_HDMIA
))
1038 /* if we aren't forcing don't do destructive polling */
1040 /* only return the previous status if we last
1041 * detected a monitor via load.
1043 if (radeon_connector
->detected_by_load
)
1044 ret
= connector
->status
;
1048 /* find analog encoder */
1049 if (radeon_connector
->dac_load_detect
) {
1050 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1051 if (connector
->encoder_ids
[i
] == 0)
1054 obj
= drm_mode_object_find(connector
->dev
,
1055 connector
->encoder_ids
[i
],
1056 DRM_MODE_OBJECT_ENCODER
);
1060 encoder
= obj_to_encoder(obj
);
1062 if (encoder
->encoder_type
!= DRM_MODE_ENCODER_DAC
&&
1063 encoder
->encoder_type
!= DRM_MODE_ENCODER_TVDAC
)
1066 encoder_funcs
= encoder
->helper_private
;
1067 if (encoder_funcs
->detect
) {
1069 if (ret
!= connector_status_connected
) {
1070 /* deal with analog monitors without DDC */
1071 ret
= encoder_funcs
->detect(encoder
, connector
);
1072 if (ret
== connector_status_connected
) {
1073 radeon_connector
->use_digital
= false;
1075 if (ret
!= connector_status_disconnected
)
1076 radeon_connector
->detected_by_load
= true;
1079 enum drm_connector_status lret
;
1080 /* assume digital unless load detected otherwise */
1081 radeon_connector
->use_digital
= true;
1082 lret
= encoder_funcs
->detect(encoder
, connector
);
1083 DRM_DEBUG_KMS("load_detect %x returned: %x\n",encoder
->encoder_type
,lret
);
1084 if (lret
== connector_status_connected
)
1085 radeon_connector
->use_digital
= false;
1092 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== false) &&
1094 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
1097 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
1098 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
1099 * by other means, assume the DFP is connected and use that EDID. In most
1100 * cases the DVI port is actually a virtual KVM port connected to the service
1104 if ((!rdev
->is_atom_bios
) &&
1105 (ret
== connector_status_disconnected
) &&
1106 rdev
->mode_info
.bios_hardcoded_edid_size
) {
1107 radeon_connector
->use_digital
= true;
1108 ret
= connector_status_connected
;
1111 /* updated in get modes as well since we need to know if it's analog or digital */
1112 radeon_connector_update_scratch_regs(connector
, ret
);
1116 /* okay need to be smart in here about which encoder to pick */
1117 static struct drm_encoder
*radeon_dvi_encoder(struct drm_connector
*connector
)
1119 int enc_id
= connector
->encoder_ids
[0];
1120 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1121 struct drm_mode_object
*obj
;
1122 struct drm_encoder
*encoder
;
1124 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1125 if (connector
->encoder_ids
[i
] == 0)
1128 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1132 encoder
= obj_to_encoder(obj
);
1134 if (radeon_connector
->use_digital
== true) {
1135 if (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)
1138 if (encoder
->encoder_type
== DRM_MODE_ENCODER_DAC
||
1139 encoder
->encoder_type
== DRM_MODE_ENCODER_TVDAC
)
1144 /* see if we have a default encoder TODO */
1146 /* then check use digitial */
1147 /* pick the first one */
1149 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
1152 encoder
= obj_to_encoder(obj
);
1158 static void radeon_dvi_force(struct drm_connector
*connector
)
1160 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1161 if (connector
->force
== DRM_FORCE_ON
)
1162 radeon_connector
->use_digital
= false;
1163 if (connector
->force
== DRM_FORCE_ON_DIGITAL
)
1164 radeon_connector
->use_digital
= true;
1167 static int radeon_dvi_mode_valid(struct drm_connector
*connector
,
1168 struct drm_display_mode
*mode
)
1170 struct drm_device
*dev
= connector
->dev
;
1171 struct radeon_device
*rdev
= dev
->dev_private
;
1172 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1174 /* XXX check mode bandwidth */
1176 /* clocks over 135 MHz have heat issues with DVI on RV100 */
1177 if (radeon_connector
->use_digital
&&
1178 (rdev
->family
== CHIP_RV100
) &&
1179 (mode
->clock
> 135000))
1180 return MODE_CLOCK_HIGH
;
1182 if (radeon_connector
->use_digital
&& (mode
->clock
> 165000)) {
1183 if ((radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
) ||
1184 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
) ||
1185 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_B
))
1187 else if (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_A
) {
1188 if (ASIC_IS_DCE6(rdev
)) {
1189 /* HDMI 1.3+ supports max clock of 340 Mhz */
1190 if (mode
->clock
> 340000)
1191 return MODE_CLOCK_HIGH
;
1195 return MODE_CLOCK_HIGH
;
1197 return MODE_CLOCK_HIGH
;
1200 /* check against the max pixel clock */
1201 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
1202 return MODE_CLOCK_HIGH
;
1207 static const struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs
= {
1208 .get_modes
= radeon_dvi_get_modes
,
1209 .mode_valid
= radeon_dvi_mode_valid
,
1210 .best_encoder
= radeon_dvi_encoder
,
1213 static const struct drm_connector_funcs radeon_dvi_connector_funcs
= {
1214 .dpms
= drm_helper_connector_dpms
,
1215 .detect
= radeon_dvi_detect
,
1216 .fill_modes
= drm_helper_probe_single_connector_modes
,
1217 .set_property
= radeon_connector_set_property
,
1218 .destroy
= radeon_connector_destroy
,
1219 .force
= radeon_dvi_force
,
1222 static void radeon_dp_connector_destroy(struct drm_connector
*connector
)
1224 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1225 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1227 if (radeon_connector
->edid
)
1228 kfree(radeon_connector
->edid
);
1229 if (radeon_dig_connector
->dp_i2c_bus
)
1230 radeon_i2c_destroy(radeon_dig_connector
->dp_i2c_bus
);
1231 kfree(radeon_connector
->con_priv
);
1232 drm_sysfs_connector_remove(connector
);
1233 drm_connector_cleanup(connector
);
1237 static int radeon_dp_get_modes(struct drm_connector
*connector
)
1239 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1240 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1241 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1244 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1245 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1246 struct drm_display_mode
*mode
;
1248 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) {
1249 if (!radeon_dig_connector
->edp_on
)
1250 atombios_set_edp_panel_power(connector
,
1251 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1252 ret
= radeon_ddc_get_modes(radeon_connector
);
1253 if (!radeon_dig_connector
->edp_on
)
1254 atombios_set_edp_panel_power(connector
,
1255 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1257 /* need to setup ddc on the bridge */
1258 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1259 ENCODER_OBJECT_ID_NONE
) {
1261 radeon_atom_ext_encoder_setup_ddc(encoder
);
1263 ret
= radeon_ddc_get_modes(radeon_connector
);
1268 radeon_fixup_lvds_native_mode(encoder
, connector
);
1269 /* add scaled modes */
1270 radeon_add_common_modes(encoder
, connector
);
1278 /* we have no EDID modes */
1279 mode
= radeon_fp_native_mode(encoder
);
1282 drm_mode_probed_add(connector
, mode
);
1283 /* add the width/height from vbios tables if available */
1284 connector
->display_info
.width_mm
= mode
->width_mm
;
1285 connector
->display_info
.height_mm
= mode
->height_mm
;
1286 /* add scaled modes */
1287 radeon_add_common_modes(encoder
, connector
);
1290 /* need to setup ddc on the bridge */
1291 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1292 ENCODER_OBJECT_ID_NONE
) {
1294 radeon_atom_ext_encoder_setup_ddc(encoder
);
1296 ret
= radeon_ddc_get_modes(radeon_connector
);
1302 u16
radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector
*connector
)
1304 struct drm_mode_object
*obj
;
1305 struct drm_encoder
*encoder
;
1306 struct radeon_encoder
*radeon_encoder
;
1309 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1310 if (connector
->encoder_ids
[i
] == 0)
1313 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1317 encoder
= obj_to_encoder(obj
);
1318 radeon_encoder
= to_radeon_encoder(encoder
);
1320 switch (radeon_encoder
->encoder_id
) {
1321 case ENCODER_OBJECT_ID_TRAVIS
:
1322 case ENCODER_OBJECT_ID_NUTMEG
:
1323 return radeon_encoder
->encoder_id
;
1329 return ENCODER_OBJECT_ID_NONE
;
1332 bool radeon_connector_encoder_is_hbr2(struct drm_connector
*connector
)
1334 struct drm_mode_object
*obj
;
1335 struct drm_encoder
*encoder
;
1336 struct radeon_encoder
*radeon_encoder
;
1340 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1341 if (connector
->encoder_ids
[i
] == 0)
1344 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
1348 encoder
= obj_to_encoder(obj
);
1349 radeon_encoder
= to_radeon_encoder(encoder
);
1350 if (radeon_encoder
->caps
& ATOM_ENCODER_CAP_RECORD_HBR2
)
1357 bool radeon_connector_is_dp12_capable(struct drm_connector
*connector
)
1359 struct drm_device
*dev
= connector
->dev
;
1360 struct radeon_device
*rdev
= dev
->dev_private
;
1362 if (ASIC_IS_DCE5(rdev
) &&
1363 (rdev
->clock
.default_dispclk
>= 53900) &&
1364 radeon_connector_encoder_is_hbr2(connector
)) {
1371 static enum drm_connector_status
1372 radeon_dp_detect(struct drm_connector
*connector
, bool force
)
1374 struct drm_device
*dev
= connector
->dev
;
1375 struct radeon_device
*rdev
= dev
->dev_private
;
1376 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1377 enum drm_connector_status ret
= connector_status_disconnected
;
1378 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1379 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1381 if (!force
&& radeon_check_hpd_status_unchanged(connector
))
1382 return connector
->status
;
1384 if (radeon_connector
->edid
) {
1385 kfree(radeon_connector
->edid
);
1386 radeon_connector
->edid
= NULL
;
1389 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1390 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1392 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1393 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1395 /* check if panel is valid */
1396 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
1397 ret
= connector_status_connected
;
1399 /* eDP is always DP */
1400 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1401 if (!radeon_dig_connector
->edp_on
)
1402 atombios_set_edp_panel_power(connector
,
1403 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1404 if (radeon_dp_getdpcd(radeon_connector
))
1405 ret
= connector_status_connected
;
1406 if (!radeon_dig_connector
->edp_on
)
1407 atombios_set_edp_panel_power(connector
,
1408 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1409 } else if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1410 ENCODER_OBJECT_ID_NONE
) {
1411 /* DP bridges are always DP */
1412 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1413 /* get the DPCD from the bridge */
1414 radeon_dp_getdpcd(radeon_connector
);
1417 /* setup ddc on the bridge */
1418 radeon_atom_ext_encoder_setup_ddc(encoder
);
1419 /* bridge chips are always aux */
1420 if (radeon_ddc_probe(radeon_connector
, true)) /* try DDC */
1421 ret
= connector_status_connected
;
1422 else if (radeon_connector
->dac_load_detect
) { /* try load detection */
1423 struct drm_encoder_helper_funcs
*encoder_funcs
= encoder
->helper_private
;
1424 ret
= encoder_funcs
->detect(encoder
, connector
);
1428 radeon_dig_connector
->dp_sink_type
= radeon_dp_getsinktype(radeon_connector
);
1429 if (radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
1430 ret
= connector_status_connected
;
1431 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
)
1432 radeon_dp_getdpcd(radeon_connector
);
1434 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
1435 if (radeon_dp_getdpcd(radeon_connector
))
1436 ret
= connector_status_connected
;
1438 /* try non-aux ddc (DP to DVI/HDMI/etc. adapter) */
1439 if (radeon_ddc_probe(radeon_connector
, false))
1440 ret
= connector_status_connected
;
1445 radeon_connector_update_scratch_regs(connector
, ret
);
1449 static int radeon_dp_mode_valid(struct drm_connector
*connector
,
1450 struct drm_display_mode
*mode
)
1452 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1453 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1455 /* XXX check mode bandwidth */
1457 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1458 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1459 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1461 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
1465 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1466 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1468 /* AVIVO hardware supports downscaling modes larger than the panel
1469 * to the panel size, but I'm not sure this is desirable.
1471 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
1472 (mode
->vdisplay
> native_mode
->vdisplay
))
1475 /* if scaling is disabled, block non-native modes */
1476 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
1477 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
1478 (mode
->vdisplay
!= native_mode
->vdisplay
))
1484 if ((radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
1485 (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
))
1486 return radeon_dp_mode_valid_helper(connector
, mode
);
1492 static const struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs
= {
1493 .get_modes
= radeon_dp_get_modes
,
1494 .mode_valid
= radeon_dp_mode_valid
,
1495 .best_encoder
= radeon_dvi_encoder
,
1498 static const struct drm_connector_funcs radeon_dp_connector_funcs
= {
1499 .dpms
= drm_helper_connector_dpms
,
1500 .detect
= radeon_dp_detect
,
1501 .fill_modes
= drm_helper_probe_single_connector_modes
,
1502 .set_property
= radeon_connector_set_property
,
1503 .destroy
= radeon_dp_connector_destroy
,
1504 .force
= radeon_dvi_force
,
1507 static const struct drm_connector_funcs radeon_edp_connector_funcs
= {
1508 .dpms
= drm_helper_connector_dpms
,
1509 .detect
= radeon_dp_detect
,
1510 .fill_modes
= drm_helper_probe_single_connector_modes
,
1511 .set_property
= radeon_lvds_set_property
,
1512 .destroy
= radeon_dp_connector_destroy
,
1513 .force
= radeon_dvi_force
,
1516 static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs
= {
1517 .dpms
= drm_helper_connector_dpms
,
1518 .detect
= radeon_dp_detect
,
1519 .fill_modes
= drm_helper_probe_single_connector_modes
,
1520 .set_property
= radeon_lvds_set_property
,
1521 .destroy
= radeon_dp_connector_destroy
,
1522 .force
= radeon_dvi_force
,
1526 radeon_add_atom_connector(struct drm_device
*dev
,
1527 uint32_t connector_id
,
1528 uint32_t supported_device
,
1530 struct radeon_i2c_bus_rec
*i2c_bus
,
1531 uint32_t igp_lane_info
,
1532 uint16_t connector_object_id
,
1533 struct radeon_hpd
*hpd
,
1534 struct radeon_router
*router
)
1536 struct radeon_device
*rdev
= dev
->dev_private
;
1537 struct drm_connector
*connector
;
1538 struct radeon_connector
*radeon_connector
;
1539 struct radeon_connector_atom_dig
*radeon_dig_connector
;
1540 struct drm_encoder
*encoder
;
1541 struct radeon_encoder
*radeon_encoder
;
1542 uint32_t subpixel_order
= SubPixelNone
;
1543 bool shared_ddc
= false;
1544 bool is_dp_bridge
= false;
1546 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1549 /* if the user selected tv=0 don't try and add the connector */
1550 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1551 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1552 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1556 /* see if we already added it */
1557 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1558 radeon_connector
= to_radeon_connector(connector
);
1559 if (radeon_connector
->connector_id
== connector_id
) {
1560 radeon_connector
->devices
|= supported_device
;
1563 if (radeon_connector
->ddc_bus
&& i2c_bus
->valid
) {
1564 if (radeon_connector
->ddc_bus
->rec
.i2c_id
== i2c_bus
->i2c_id
) {
1565 radeon_connector
->shared_ddc
= true;
1568 if (radeon_connector
->router_bus
&& router
->ddc_valid
&&
1569 (radeon_connector
->router
.router_id
== router
->router_id
)) {
1570 radeon_connector
->shared_ddc
= false;
1576 /* check if it's a dp bridge */
1577 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
1578 radeon_encoder
= to_radeon_encoder(encoder
);
1579 if (radeon_encoder
->devices
& supported_device
) {
1580 switch (radeon_encoder
->encoder_id
) {
1581 case ENCODER_OBJECT_ID_TRAVIS
:
1582 case ENCODER_OBJECT_ID_NUTMEG
:
1583 is_dp_bridge
= true;
1591 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1592 if (!radeon_connector
)
1595 connector
= &radeon_connector
->base
;
1597 radeon_connector
->connector_id
= connector_id
;
1598 radeon_connector
->devices
= supported_device
;
1599 radeon_connector
->shared_ddc
= shared_ddc
;
1600 radeon_connector
->connector_object_id
= connector_object_id
;
1601 radeon_connector
->hpd
= *hpd
;
1603 radeon_connector
->router
= *router
;
1604 if (router
->ddc_valid
|| router
->cd_valid
) {
1605 radeon_connector
->router_bus
= radeon_i2c_lookup(rdev
, &router
->i2c_info
);
1606 if (!radeon_connector
->router_bus
)
1607 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n");
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 if (i2c_bus
->valid
) {
1617 /* add DP i2c bus */
1618 if (connector_type
== DRM_MODE_CONNECTOR_eDP
)
1619 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1621 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1622 if (!radeon_dig_connector
->dp_i2c_bus
)
1623 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1624 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1625 if (!radeon_connector
->ddc_bus
)
1626 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1628 switch (connector_type
) {
1629 case DRM_MODE_CONNECTOR_VGA
:
1630 case DRM_MODE_CONNECTOR_DVIA
:
1632 drm_connector_init(dev
, &radeon_connector
->base
,
1633 &radeon_dp_connector_funcs
, connector_type
);
1634 drm_connector_helper_add(&radeon_connector
->base
,
1635 &radeon_dp_connector_helper_funcs
);
1636 connector
->interlace_allowed
= true;
1637 connector
->doublescan_allowed
= true;
1638 radeon_connector
->dac_load_detect
= true;
1639 drm_object_attach_property(&radeon_connector
->base
.base
,
1640 rdev
->mode_info
.load_detect_property
,
1643 case DRM_MODE_CONNECTOR_DVII
:
1644 case DRM_MODE_CONNECTOR_DVID
:
1645 case DRM_MODE_CONNECTOR_HDMIA
:
1646 case DRM_MODE_CONNECTOR_HDMIB
:
1647 case DRM_MODE_CONNECTOR_DisplayPort
:
1648 drm_connector_init(dev
, &radeon_connector
->base
,
1649 &radeon_dp_connector_funcs
, connector_type
);
1650 drm_connector_helper_add(&radeon_connector
->base
,
1651 &radeon_dp_connector_helper_funcs
);
1652 drm_object_attach_property(&radeon_connector
->base
.base
,
1653 rdev
->mode_info
.underscan_property
,
1655 drm_object_attach_property(&radeon_connector
->base
.base
,
1656 rdev
->mode_info
.underscan_hborder_property
,
1658 drm_object_attach_property(&radeon_connector
->base
.base
,
1659 rdev
->mode_info
.underscan_vborder_property
,
1661 if (radeon_audio
!= 0)
1662 drm_object_attach_property(&radeon_connector
->base
.base
,
1663 rdev
->mode_info
.audio_property
,
1664 (radeon_audio
== 1) ?
1666 RADEON_AUDIO_DISABLE
);
1667 subpixel_order
= SubPixelHorizontalRGB
;
1668 connector
->interlace_allowed
= true;
1669 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1670 connector
->doublescan_allowed
= true;
1672 connector
->doublescan_allowed
= false;
1673 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1674 radeon_connector
->dac_load_detect
= true;
1675 drm_object_attach_property(&radeon_connector
->base
.base
,
1676 rdev
->mode_info
.load_detect_property
,
1680 case DRM_MODE_CONNECTOR_LVDS
:
1681 case DRM_MODE_CONNECTOR_eDP
:
1682 drm_connector_init(dev
, &radeon_connector
->base
,
1683 &radeon_lvds_bridge_connector_funcs
, connector_type
);
1684 drm_connector_helper_add(&radeon_connector
->base
,
1685 &radeon_dp_connector_helper_funcs
);
1686 drm_object_attach_property(&radeon_connector
->base
.base
,
1687 dev
->mode_config
.scaling_mode_property
,
1688 DRM_MODE_SCALE_FULLSCREEN
);
1689 subpixel_order
= SubPixelHorizontalRGB
;
1690 connector
->interlace_allowed
= false;
1691 connector
->doublescan_allowed
= false;
1695 switch (connector_type
) {
1696 case DRM_MODE_CONNECTOR_VGA
:
1697 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1698 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1699 if (i2c_bus
->valid
) {
1700 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1701 if (!radeon_connector
->ddc_bus
)
1702 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1704 radeon_connector
->dac_load_detect
= true;
1705 drm_object_attach_property(&radeon_connector
->base
.base
,
1706 rdev
->mode_info
.load_detect_property
,
1708 /* no HPD on analog connectors */
1709 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1710 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1711 connector
->interlace_allowed
= true;
1712 connector
->doublescan_allowed
= true;
1714 case DRM_MODE_CONNECTOR_DVIA
:
1715 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1716 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1717 if (i2c_bus
->valid
) {
1718 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1719 if (!radeon_connector
->ddc_bus
)
1720 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1722 radeon_connector
->dac_load_detect
= true;
1723 drm_object_attach_property(&radeon_connector
->base
.base
,
1724 rdev
->mode_info
.load_detect_property
,
1726 /* no HPD on analog connectors */
1727 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1728 connector
->interlace_allowed
= true;
1729 connector
->doublescan_allowed
= true;
1731 case DRM_MODE_CONNECTOR_DVII
:
1732 case DRM_MODE_CONNECTOR_DVID
:
1733 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1734 if (!radeon_dig_connector
)
1736 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1737 radeon_connector
->con_priv
= radeon_dig_connector
;
1738 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1739 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1740 if (i2c_bus
->valid
) {
1741 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1742 if (!radeon_connector
->ddc_bus
)
1743 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1745 subpixel_order
= SubPixelHorizontalRGB
;
1746 drm_object_attach_property(&radeon_connector
->base
.base
,
1747 rdev
->mode_info
.coherent_mode_property
,
1749 if (ASIC_IS_AVIVO(rdev
)) {
1750 drm_object_attach_property(&radeon_connector
->base
.base
,
1751 rdev
->mode_info
.underscan_property
,
1753 drm_object_attach_property(&radeon_connector
->base
.base
,
1754 rdev
->mode_info
.underscan_hborder_property
,
1756 drm_object_attach_property(&radeon_connector
->base
.base
,
1757 rdev
->mode_info
.underscan_vborder_property
,
1760 if (ASIC_IS_DCE2(rdev
) && (radeon_audio
!= 0)) {
1761 drm_object_attach_property(&radeon_connector
->base
.base
,
1762 rdev
->mode_info
.audio_property
,
1763 (radeon_audio
== 1) ?
1765 RADEON_AUDIO_DISABLE
);
1767 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1768 radeon_connector
->dac_load_detect
= true;
1769 drm_object_attach_property(&radeon_connector
->base
.base
,
1770 rdev
->mode_info
.load_detect_property
,
1773 connector
->interlace_allowed
= true;
1774 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
1775 connector
->doublescan_allowed
= true;
1777 connector
->doublescan_allowed
= false;
1779 case DRM_MODE_CONNECTOR_HDMIA
:
1780 case DRM_MODE_CONNECTOR_HDMIB
:
1781 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1782 if (!radeon_dig_connector
)
1784 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1785 radeon_connector
->con_priv
= radeon_dig_connector
;
1786 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1787 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1788 if (i2c_bus
->valid
) {
1789 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1790 if (!radeon_connector
->ddc_bus
)
1791 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1793 drm_object_attach_property(&radeon_connector
->base
.base
,
1794 rdev
->mode_info
.coherent_mode_property
,
1796 if (ASIC_IS_AVIVO(rdev
)) {
1797 drm_object_attach_property(&radeon_connector
->base
.base
,
1798 rdev
->mode_info
.underscan_property
,
1800 drm_object_attach_property(&radeon_connector
->base
.base
,
1801 rdev
->mode_info
.underscan_hborder_property
,
1803 drm_object_attach_property(&radeon_connector
->base
.base
,
1804 rdev
->mode_info
.underscan_vborder_property
,
1807 if (ASIC_IS_DCE2(rdev
) && (radeon_audio
!= 0)) {
1808 drm_object_attach_property(&radeon_connector
->base
.base
,
1809 rdev
->mode_info
.audio_property
,
1810 (radeon_audio
== 1) ?
1812 RADEON_AUDIO_DISABLE
);
1814 subpixel_order
= SubPixelHorizontalRGB
;
1815 connector
->interlace_allowed
= true;
1816 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1817 connector
->doublescan_allowed
= true;
1819 connector
->doublescan_allowed
= false;
1821 case DRM_MODE_CONNECTOR_DisplayPort
:
1822 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1823 if (!radeon_dig_connector
)
1825 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1826 radeon_connector
->con_priv
= radeon_dig_connector
;
1827 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1828 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1829 if (i2c_bus
->valid
) {
1830 /* add DP i2c bus */
1831 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1832 if (!radeon_dig_connector
->dp_i2c_bus
)
1833 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1834 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1835 if (!radeon_connector
->ddc_bus
)
1836 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1838 subpixel_order
= SubPixelHorizontalRGB
;
1839 drm_object_attach_property(&radeon_connector
->base
.base
,
1840 rdev
->mode_info
.coherent_mode_property
,
1842 if (ASIC_IS_AVIVO(rdev
)) {
1843 drm_object_attach_property(&radeon_connector
->base
.base
,
1844 rdev
->mode_info
.underscan_property
,
1846 drm_object_attach_property(&radeon_connector
->base
.base
,
1847 rdev
->mode_info
.underscan_hborder_property
,
1849 drm_object_attach_property(&radeon_connector
->base
.base
,
1850 rdev
->mode_info
.underscan_vborder_property
,
1853 if (ASIC_IS_DCE2(rdev
) && (radeon_audio
!= 0)) {
1854 drm_object_attach_property(&radeon_connector
->base
.base
,
1855 rdev
->mode_info
.audio_property
,
1856 (radeon_audio
== 1) ?
1858 RADEON_AUDIO_DISABLE
);
1860 connector
->interlace_allowed
= true;
1861 /* in theory with a DP to VGA converter... */
1862 connector
->doublescan_allowed
= false;
1864 case DRM_MODE_CONNECTOR_eDP
:
1865 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1866 if (!radeon_dig_connector
)
1868 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1869 radeon_connector
->con_priv
= radeon_dig_connector
;
1870 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_edp_connector_funcs
, connector_type
);
1871 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1872 if (i2c_bus
->valid
) {
1873 /* add DP i2c bus */
1874 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1875 if (!radeon_dig_connector
->dp_i2c_bus
)
1876 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1877 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1878 if (!radeon_connector
->ddc_bus
)
1879 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1881 drm_object_attach_property(&radeon_connector
->base
.base
,
1882 dev
->mode_config
.scaling_mode_property
,
1883 DRM_MODE_SCALE_FULLSCREEN
);
1884 subpixel_order
= SubPixelHorizontalRGB
;
1885 connector
->interlace_allowed
= false;
1886 connector
->doublescan_allowed
= false;
1888 case DRM_MODE_CONNECTOR_SVIDEO
:
1889 case DRM_MODE_CONNECTOR_Composite
:
1890 case DRM_MODE_CONNECTOR_9PinDIN
:
1891 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1892 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1893 radeon_connector
->dac_load_detect
= true;
1894 drm_object_attach_property(&radeon_connector
->base
.base
,
1895 rdev
->mode_info
.load_detect_property
,
1897 drm_object_attach_property(&radeon_connector
->base
.base
,
1898 rdev
->mode_info
.tv_std_property
,
1899 radeon_atombios_get_tv_info(rdev
));
1900 /* no HPD on analog connectors */
1901 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1902 connector
->interlace_allowed
= false;
1903 connector
->doublescan_allowed
= false;
1905 case DRM_MODE_CONNECTOR_LVDS
:
1906 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1907 if (!radeon_dig_connector
)
1909 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1910 radeon_connector
->con_priv
= radeon_dig_connector
;
1911 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1912 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1913 if (i2c_bus
->valid
) {
1914 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1915 if (!radeon_connector
->ddc_bus
)
1916 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1918 drm_object_attach_property(&radeon_connector
->base
.base
,
1919 dev
->mode_config
.scaling_mode_property
,
1920 DRM_MODE_SCALE_FULLSCREEN
);
1921 subpixel_order
= SubPixelHorizontalRGB
;
1922 connector
->interlace_allowed
= false;
1923 connector
->doublescan_allowed
= false;
1928 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
1930 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1932 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
1934 connector
->display_info
.subpixel_order
= subpixel_order
;
1935 drm_sysfs_connector_add(connector
);
1939 drm_connector_cleanup(connector
);
1944 radeon_add_legacy_connector(struct drm_device
*dev
,
1945 uint32_t connector_id
,
1946 uint32_t supported_device
,
1948 struct radeon_i2c_bus_rec
*i2c_bus
,
1949 uint16_t connector_object_id
,
1950 struct radeon_hpd
*hpd
)
1952 struct radeon_device
*rdev
= dev
->dev_private
;
1953 struct drm_connector
*connector
;
1954 struct radeon_connector
*radeon_connector
;
1955 uint32_t subpixel_order
= SubPixelNone
;
1957 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1960 /* if the user selected tv=0 don't try and add the connector */
1961 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1962 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1963 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1967 /* see if we already added it */
1968 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1969 radeon_connector
= to_radeon_connector(connector
);
1970 if (radeon_connector
->connector_id
== connector_id
) {
1971 radeon_connector
->devices
|= supported_device
;
1976 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1977 if (!radeon_connector
)
1980 connector
= &radeon_connector
->base
;
1982 radeon_connector
->connector_id
= connector_id
;
1983 radeon_connector
->devices
= supported_device
;
1984 radeon_connector
->connector_object_id
= connector_object_id
;
1985 radeon_connector
->hpd
= *hpd
;
1987 switch (connector_type
) {
1988 case DRM_MODE_CONNECTOR_VGA
:
1989 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1990 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1991 if (i2c_bus
->valid
) {
1992 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1993 if (!radeon_connector
->ddc_bus
)
1994 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1996 radeon_connector
->dac_load_detect
= true;
1997 drm_object_attach_property(&radeon_connector
->base
.base
,
1998 rdev
->mode_info
.load_detect_property
,
2000 /* no HPD on analog connectors */
2001 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2002 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
2003 connector
->interlace_allowed
= true;
2004 connector
->doublescan_allowed
= true;
2006 case DRM_MODE_CONNECTOR_DVIA
:
2007 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
2008 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
2009 if (i2c_bus
->valid
) {
2010 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2011 if (!radeon_connector
->ddc_bus
)
2012 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2014 radeon_connector
->dac_load_detect
= true;
2015 drm_object_attach_property(&radeon_connector
->base
.base
,
2016 rdev
->mode_info
.load_detect_property
,
2018 /* no HPD on analog connectors */
2019 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2020 connector
->interlace_allowed
= true;
2021 connector
->doublescan_allowed
= true;
2023 case DRM_MODE_CONNECTOR_DVII
:
2024 case DRM_MODE_CONNECTOR_DVID
:
2025 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
2026 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
2027 if (i2c_bus
->valid
) {
2028 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2029 if (!radeon_connector
->ddc_bus
)
2030 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2032 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
2033 radeon_connector
->dac_load_detect
= true;
2034 drm_object_attach_property(&radeon_connector
->base
.base
,
2035 rdev
->mode_info
.load_detect_property
,
2038 subpixel_order
= SubPixelHorizontalRGB
;
2039 connector
->interlace_allowed
= true;
2040 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
2041 connector
->doublescan_allowed
= true;
2043 connector
->doublescan_allowed
= false;
2045 case DRM_MODE_CONNECTOR_SVIDEO
:
2046 case DRM_MODE_CONNECTOR_Composite
:
2047 case DRM_MODE_CONNECTOR_9PinDIN
:
2048 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
2049 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
2050 radeon_connector
->dac_load_detect
= true;
2051 /* RS400,RC410,RS480 chipset seems to report a lot
2052 * of false positive on load detect, we haven't yet
2053 * found a way to make load detect reliable on those
2054 * chipset, thus just disable it for TV.
2056 if (rdev
->family
== CHIP_RS400
|| rdev
->family
== CHIP_RS480
)
2057 radeon_connector
->dac_load_detect
= false;
2058 drm_object_attach_property(&radeon_connector
->base
.base
,
2059 rdev
->mode_info
.load_detect_property
,
2060 radeon_connector
->dac_load_detect
);
2061 drm_object_attach_property(&radeon_connector
->base
.base
,
2062 rdev
->mode_info
.tv_std_property
,
2063 radeon_combios_get_tv_info(rdev
));
2064 /* no HPD on analog connectors */
2065 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2066 connector
->interlace_allowed
= false;
2067 connector
->doublescan_allowed
= false;
2069 case DRM_MODE_CONNECTOR_LVDS
:
2070 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
2071 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
2072 if (i2c_bus
->valid
) {
2073 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2074 if (!radeon_connector
->ddc_bus
)
2075 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2077 drm_object_attach_property(&radeon_connector
->base
.base
,
2078 dev
->mode_config
.scaling_mode_property
,
2079 DRM_MODE_SCALE_FULLSCREEN
);
2080 subpixel_order
= SubPixelHorizontalRGB
;
2081 connector
->interlace_allowed
= false;
2082 connector
->doublescan_allowed
= false;
2086 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
2088 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
2090 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
2091 connector
->display_info
.subpixel_order
= subpixel_order
;
2092 drm_sysfs_connector_add(connector
);