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/drm_dp_mst_helper.h>
31 #include <drm/radeon_drm.h>
33 #include "radeon_audio.h"
36 #include <linux/pm_runtime.h>
37 #include <linux/vga_switcheroo.h>
39 static int radeon_dp_handle_hpd(struct drm_connector
*connector
)
41 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
44 ret
= radeon_dp_mst_check_status(radeon_connector
);
49 void radeon_connector_hotplug(struct drm_connector
*connector
)
51 struct drm_device
*dev
= connector
->dev
;
52 struct radeon_device
*rdev
= dev
->dev_private
;
53 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
55 if (connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
) {
56 struct radeon_connector_atom_dig
*dig_connector
=
57 radeon_connector
->con_priv
;
59 if (radeon_connector
->is_mst_connector
)
61 if (dig_connector
->is_mst
) {
62 radeon_dp_handle_hpd(connector
);
66 /* bail if the connector does not have hpd pin, e.g.,
69 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
)
72 radeon_hpd_set_polarity(rdev
, radeon_connector
->hpd
.hpd
);
74 /* if the connector is already off, don't turn it back on */
75 /* FIXME: This access isn't protected by any locks. */
76 if (connector
->dpms
!= DRM_MODE_DPMS_ON
)
79 /* just deal with DP (not eDP) here. */
80 if (connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
) {
81 struct radeon_connector_atom_dig
*dig_connector
=
82 radeon_connector
->con_priv
;
84 /* if existing sink type was not DP no need to retrain */
85 if (dig_connector
->dp_sink_type
!= CONNECTOR_OBJECT_ID_DISPLAYPORT
)
88 /* first get sink type as it may be reset after (un)plug */
89 dig_connector
->dp_sink_type
= radeon_dp_getsinktype(radeon_connector
);
90 /* don't do anything if sink is not display port, i.e.,
91 * passive dp->(dvi|hdmi) adaptor
93 if (dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
94 int saved_dpms
= connector
->dpms
;
95 /* Only turn off the display if it's physically disconnected */
96 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
97 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_OFF
);
98 } else if (radeon_dp_needs_link_train(radeon_connector
)) {
99 /* Don't try to start link training before we
101 if (!radeon_dp_getdpcd(radeon_connector
))
104 /* set it to OFF so that drm_helper_connector_dpms()
105 * won't return immediately since the current state
106 * is ON at this point.
108 connector
->dpms
= DRM_MODE_DPMS_OFF
;
109 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_ON
);
111 connector
->dpms
= saved_dpms
;
116 static void radeon_property_change_mode(struct drm_encoder
*encoder
)
118 struct drm_crtc
*crtc
= encoder
->crtc
;
120 if (crtc
&& crtc
->enabled
) {
121 drm_crtc_helper_set_mode(crtc
, &crtc
->mode
,
122 crtc
->x
, crtc
->y
, crtc
->primary
->fb
);
126 int radeon_get_monitor_bpc(struct drm_connector
*connector
)
128 struct drm_device
*dev
= connector
->dev
;
129 struct radeon_device
*rdev
= dev
->dev_private
;
130 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
131 struct radeon_connector_atom_dig
*dig_connector
;
133 int mode_clock
, max_tmds_clock
;
135 switch (connector
->connector_type
) {
136 case DRM_MODE_CONNECTOR_DVII
:
137 case DRM_MODE_CONNECTOR_HDMIB
:
138 if (radeon_connector
->use_digital
) {
139 if (drm_detect_hdmi_monitor(radeon_connector_edid(connector
))) {
140 if (connector
->display_info
.bpc
)
141 bpc
= connector
->display_info
.bpc
;
145 case DRM_MODE_CONNECTOR_DVID
:
146 case DRM_MODE_CONNECTOR_HDMIA
:
147 if (drm_detect_hdmi_monitor(radeon_connector_edid(connector
))) {
148 if (connector
->display_info
.bpc
)
149 bpc
= connector
->display_info
.bpc
;
152 case DRM_MODE_CONNECTOR_DisplayPort
:
153 dig_connector
= radeon_connector
->con_priv
;
154 if ((dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
155 (dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
) ||
156 drm_detect_hdmi_monitor(radeon_connector_edid(connector
))) {
157 if (connector
->display_info
.bpc
)
158 bpc
= connector
->display_info
.bpc
;
161 case DRM_MODE_CONNECTOR_eDP
:
162 case DRM_MODE_CONNECTOR_LVDS
:
163 if (connector
->display_info
.bpc
)
164 bpc
= connector
->display_info
.bpc
;
165 else if (ASIC_IS_DCE41(rdev
) || ASIC_IS_DCE5(rdev
)) {
166 const struct drm_connector_helper_funcs
*connector_funcs
=
167 connector
->helper_private
;
168 struct drm_encoder
*encoder
= connector_funcs
->best_encoder(connector
);
169 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
170 struct radeon_encoder_atom_dig
*dig
= radeon_encoder
->enc_priv
;
172 if (dig
->lcd_misc
& ATOM_PANEL_MISC_V13_6BIT_PER_COLOR
)
174 else if (dig
->lcd_misc
& ATOM_PANEL_MISC_V13_8BIT_PER_COLOR
)
180 if (drm_detect_hdmi_monitor(radeon_connector_edid(connector
))) {
181 /* hdmi deep color only implemented on DCE4+ */
182 if ((bpc
> 8) && !ASIC_IS_DCE4(rdev
)) {
183 DRM_DEBUG("%s: HDMI deep color %d bpc unsupported. Using 8 bpc.\n",
184 connector
->name
, bpc
);
189 * Pre DCE-8 hw can't handle > 12 bpc, and more than 12 bpc doesn't make
190 * much sense without support for > 12 bpc framebuffers. RGB 4:4:4 at
191 * 12 bpc is always supported on hdmi deep color sinks, as this is
192 * required by the HDMI-1.3 spec. Clamp to a safe 12 bpc maximum.
195 DRM_DEBUG("%s: HDMI deep color %d bpc unsupported. Using 12 bpc.\n",
196 connector
->name
, bpc
);
200 /* Any defined maximum tmds clock limit we must not exceed? */
201 if (connector
->display_info
.max_tmds_clock
> 0) {
202 /* mode_clock is clock in kHz for mode to be modeset on this connector */
203 mode_clock
= radeon_connector
->pixelclock_for_modeset
;
205 /* Maximum allowable input clock in kHz */
206 max_tmds_clock
= connector
->display_info
.max_tmds_clock
;
208 DRM_DEBUG("%s: hdmi mode dotclock %d kHz, max tmds input clock %d kHz.\n",
209 connector
->name
, mode_clock
, max_tmds_clock
);
211 /* Check if bpc is within clock limit. Try to degrade gracefully otherwise */
212 if ((bpc
== 12) && (mode_clock
* 3/2 > max_tmds_clock
)) {
213 if ((connector
->display_info
.edid_hdmi_dc_modes
& DRM_EDID_HDMI_DC_30
) &&
214 (mode_clock
* 5/4 <= max_tmds_clock
))
219 DRM_DEBUG("%s: HDMI deep color 12 bpc exceeds max tmds clock. Using %d bpc.\n",
220 connector
->name
, bpc
);
223 if ((bpc
== 10) && (mode_clock
* 5/4 > max_tmds_clock
)) {
225 DRM_DEBUG("%s: HDMI deep color 10 bpc exceeds max tmds clock. Using %d bpc.\n",
226 connector
->name
, bpc
);
230 /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */
231 DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n",
237 if ((radeon_deep_color
== 0) && (bpc
> 8)) {
238 DRM_DEBUG("%s: Deep color disabled. Set radeon module param deep_color=1 to enable.\n",
243 DRM_DEBUG("%s: Display bpc=%d, returned bpc=%d\n",
244 connector
->name
, connector
->display_info
.bpc
, bpc
);
250 radeon_connector_update_scratch_regs(struct drm_connector
*connector
, enum drm_connector_status status
)
252 struct drm_device
*dev
= connector
->dev
;
253 struct radeon_device
*rdev
= dev
->dev_private
;
254 struct drm_encoder
*best_encoder
= NULL
;
255 struct drm_encoder
*encoder
= NULL
;
256 const struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
260 best_encoder
= connector_funcs
->best_encoder(connector
);
262 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
263 if (connector
->encoder_ids
[i
] == 0)
266 encoder
= drm_encoder_find(connector
->dev
,
267 connector
->encoder_ids
[i
]);
271 if ((encoder
== best_encoder
) && (status
== connector_status_connected
))
276 if (rdev
->is_atom_bios
)
277 radeon_atombios_connected_scratch_regs(connector
, encoder
, connected
);
279 radeon_combios_connected_scratch_regs(connector
, encoder
, connected
);
284 static struct drm_encoder
*radeon_find_encoder(struct drm_connector
*connector
, int encoder_type
)
286 struct drm_encoder
*encoder
;
289 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
290 if (connector
->encoder_ids
[i
] == 0)
293 encoder
= drm_encoder_find(connector
->dev
, connector
->encoder_ids
[i
]);
297 if (encoder
->encoder_type
== encoder_type
)
303 struct edid
*radeon_connector_edid(struct drm_connector
*connector
)
305 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
306 struct drm_property_blob
*edid_blob
= connector
->edid_blob_ptr
;
308 if (radeon_connector
->edid
) {
309 return radeon_connector
->edid
;
310 } else if (edid_blob
) {
311 struct edid
*edid
= kmemdup(edid_blob
->data
, edid_blob
->length
, GFP_KERNEL
);
313 radeon_connector
->edid
= edid
;
315 return radeon_connector
->edid
;
318 static void radeon_connector_get_edid(struct drm_connector
*connector
)
320 struct drm_device
*dev
= connector
->dev
;
321 struct radeon_device
*rdev
= dev
->dev_private
;
322 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
324 if (radeon_connector
->edid
)
327 /* on hw with routers, select right port */
328 if (radeon_connector
->router
.ddc_valid
)
329 radeon_router_select_ddc_port(radeon_connector
);
331 if ((radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
332 ENCODER_OBJECT_ID_NONE
) &&
333 radeon_connector
->ddc_bus
->has_aux
) {
334 radeon_connector
->edid
= drm_get_edid(connector
,
335 &radeon_connector
->ddc_bus
->aux
.ddc
);
336 } else if ((connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
) ||
337 (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
)) {
338 struct radeon_connector_atom_dig
*dig
= radeon_connector
->con_priv
;
340 if ((dig
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
||
341 dig
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
) &&
342 radeon_connector
->ddc_bus
->has_aux
)
343 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
,
344 &radeon_connector
->ddc_bus
->aux
.ddc
);
345 else if (radeon_connector
->ddc_bus
)
346 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
,
347 &radeon_connector
->ddc_bus
->adapter
);
348 } else if (vga_switcheroo_handler_flags() & VGA_SWITCHEROO_CAN_SWITCH_DDC
&&
349 connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
&&
350 radeon_connector
->ddc_bus
) {
351 radeon_connector
->edid
= drm_get_edid_switcheroo(&radeon_connector
->base
,
352 &radeon_connector
->ddc_bus
->adapter
);
353 } else if (radeon_connector
->ddc_bus
) {
354 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
,
355 &radeon_connector
->ddc_bus
->adapter
);
358 if (!radeon_connector
->edid
) {
359 /* don't fetch the edid from the vbios if ddc fails and runpm is
360 * enabled so we report disconnected.
362 if ((rdev
->flags
& RADEON_IS_PX
) && (radeon_runtime_pm
!= 0))
365 if (rdev
->is_atom_bios
) {
366 /* some laptops provide a hardcoded edid in rom for LCDs */
367 if (((connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
) ||
368 (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
)))
369 radeon_connector
->edid
= radeon_bios_get_hardcoded_edid(rdev
);
371 /* some servers provide a hardcoded edid in rom for KVMs */
372 radeon_connector
->edid
= radeon_bios_get_hardcoded_edid(rdev
);
377 static void radeon_connector_free_edid(struct drm_connector
*connector
)
379 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
381 if (radeon_connector
->edid
) {
382 kfree(radeon_connector
->edid
);
383 radeon_connector
->edid
= NULL
;
387 static int radeon_ddc_get_modes(struct drm_connector
*connector
)
389 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
392 if (radeon_connector
->edid
) {
393 drm_mode_connector_update_edid_property(connector
, radeon_connector
->edid
);
394 ret
= drm_add_edid_modes(connector
, radeon_connector
->edid
);
395 drm_edid_to_eld(connector
, radeon_connector
->edid
);
398 drm_mode_connector_update_edid_property(connector
, NULL
);
402 static struct drm_encoder
*radeon_best_single_encoder(struct drm_connector
*connector
)
404 int enc_id
= connector
->encoder_ids
[0];
405 /* pick the encoder ids */
407 return drm_encoder_find(connector
->dev
, enc_id
);
411 static void radeon_get_native_mode(struct drm_connector
*connector
)
413 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
414 struct radeon_encoder
*radeon_encoder
;
419 radeon_encoder
= to_radeon_encoder(encoder
);
421 if (!list_empty(&connector
->probed_modes
)) {
422 struct drm_display_mode
*preferred_mode
=
423 list_first_entry(&connector
->probed_modes
,
424 struct drm_display_mode
, head
);
426 radeon_encoder
->native_mode
= *preferred_mode
;
428 radeon_encoder
->native_mode
.clock
= 0;
433 * radeon_connector_analog_encoder_conflict_solve
434 * - search for other connectors sharing this encoder
435 * if priority is true, then set them disconnected if this is connected
436 * if priority is false, set us disconnected if they are connected
438 static enum drm_connector_status
439 radeon_connector_analog_encoder_conflict_solve(struct drm_connector
*connector
,
440 struct drm_encoder
*encoder
,
441 enum drm_connector_status current_status
,
444 struct drm_device
*dev
= connector
->dev
;
445 struct drm_connector
*conflict
;
446 struct radeon_connector
*radeon_conflict
;
449 list_for_each_entry(conflict
, &dev
->mode_config
.connector_list
, head
) {
450 if (conflict
== connector
)
453 radeon_conflict
= to_radeon_connector(conflict
);
454 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
455 if (conflict
->encoder_ids
[i
] == 0)
458 /* if the IDs match */
459 if (conflict
->encoder_ids
[i
] == encoder
->base
.id
) {
460 if (conflict
->status
!= connector_status_connected
)
463 if (radeon_conflict
->use_digital
)
466 if (priority
== true) {
467 DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n",
469 DRM_DEBUG_KMS("in favor of %s\n",
471 conflict
->status
= connector_status_disconnected
;
472 radeon_connector_update_scratch_regs(conflict
, connector_status_disconnected
);
474 DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n",
476 DRM_DEBUG_KMS("in favor of %s\n",
478 current_status
= connector_status_disconnected
;
484 return current_status
;
488 static struct drm_display_mode
*radeon_fp_native_mode(struct drm_encoder
*encoder
)
490 struct drm_device
*dev
= encoder
->dev
;
491 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
492 struct drm_display_mode
*mode
= NULL
;
493 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
495 if (native_mode
->hdisplay
!= 0 &&
496 native_mode
->vdisplay
!= 0 &&
497 native_mode
->clock
!= 0) {
498 mode
= drm_mode_duplicate(dev
, native_mode
);
499 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
500 drm_mode_set_name(mode
);
502 DRM_DEBUG_KMS("Adding native panel mode %s\n", mode
->name
);
503 } else if (native_mode
->hdisplay
!= 0 &&
504 native_mode
->vdisplay
!= 0) {
505 /* mac laptops without an edid */
506 /* Note that this is not necessarily the exact panel mode,
507 * but an approximation based on the cvt formula. For these
508 * systems we should ideally read the mode info out of the
509 * registers or add a mode table, but this works and is much
512 mode
= drm_cvt_mode(dev
, native_mode
->hdisplay
, native_mode
->vdisplay
, 60, true, false, false);
513 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
514 DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode
->name
);
519 static void radeon_add_common_modes(struct drm_encoder
*encoder
, struct drm_connector
*connector
)
521 struct drm_device
*dev
= encoder
->dev
;
522 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
523 struct drm_display_mode
*mode
= NULL
;
524 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
529 } common_modes
[17] = {
549 for (i
= 0; i
< 17; i
++) {
550 if (radeon_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
)) {
551 if (common_modes
[i
].w
> 1024 ||
552 common_modes
[i
].h
> 768)
555 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
556 if (common_modes
[i
].w
> native_mode
->hdisplay
||
557 common_modes
[i
].h
> native_mode
->vdisplay
||
558 (common_modes
[i
].w
== native_mode
->hdisplay
&&
559 common_modes
[i
].h
== native_mode
->vdisplay
))
562 if (common_modes
[i
].w
< 320 || common_modes
[i
].h
< 200)
565 mode
= drm_cvt_mode(dev
, common_modes
[i
].w
, common_modes
[i
].h
, 60, false, false, false);
566 drm_mode_probed_add(connector
, mode
);
570 static int radeon_connector_set_property(struct drm_connector
*connector
, struct drm_property
*property
,
573 struct drm_device
*dev
= connector
->dev
;
574 struct radeon_device
*rdev
= dev
->dev_private
;
575 struct drm_encoder
*encoder
;
576 struct radeon_encoder
*radeon_encoder
;
578 if (property
== rdev
->mode_info
.coherent_mode_property
) {
579 struct radeon_encoder_atom_dig
*dig
;
580 bool new_coherent_mode
;
582 /* need to find digital encoder on connector */
583 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
587 radeon_encoder
= to_radeon_encoder(encoder
);
589 if (!radeon_encoder
->enc_priv
)
592 dig
= radeon_encoder
->enc_priv
;
593 new_coherent_mode
= val
? true : false;
594 if (dig
->coherent_mode
!= new_coherent_mode
) {
595 dig
->coherent_mode
= new_coherent_mode
;
596 radeon_property_change_mode(&radeon_encoder
->base
);
600 if (property
== rdev
->mode_info
.audio_property
) {
601 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
602 /* need to find digital encoder on connector */
603 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
607 radeon_encoder
= to_radeon_encoder(encoder
);
609 if (radeon_connector
->audio
!= val
) {
610 radeon_connector
->audio
= val
;
611 radeon_property_change_mode(&radeon_encoder
->base
);
615 if (property
== rdev
->mode_info
.dither_property
) {
616 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
617 /* need to find digital encoder on connector */
618 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
622 radeon_encoder
= to_radeon_encoder(encoder
);
624 if (radeon_connector
->dither
!= val
) {
625 radeon_connector
->dither
= val
;
626 radeon_property_change_mode(&radeon_encoder
->base
);
630 if (property
== rdev
->mode_info
.underscan_property
) {
631 /* need to find digital encoder on connector */
632 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
636 radeon_encoder
= to_radeon_encoder(encoder
);
638 if (radeon_encoder
->underscan_type
!= val
) {
639 radeon_encoder
->underscan_type
= val
;
640 radeon_property_change_mode(&radeon_encoder
->base
);
644 if (property
== rdev
->mode_info
.underscan_hborder_property
) {
645 /* need to find digital encoder on connector */
646 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
650 radeon_encoder
= to_radeon_encoder(encoder
);
652 if (radeon_encoder
->underscan_hborder
!= val
) {
653 radeon_encoder
->underscan_hborder
= val
;
654 radeon_property_change_mode(&radeon_encoder
->base
);
658 if (property
== rdev
->mode_info
.underscan_vborder_property
) {
659 /* need to find digital encoder on connector */
660 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
664 radeon_encoder
= to_radeon_encoder(encoder
);
666 if (radeon_encoder
->underscan_vborder
!= val
) {
667 radeon_encoder
->underscan_vborder
= val
;
668 radeon_property_change_mode(&radeon_encoder
->base
);
672 if (property
== rdev
->mode_info
.tv_std_property
) {
673 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TVDAC
);
675 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_DAC
);
681 radeon_encoder
= to_radeon_encoder(encoder
);
682 if (!radeon_encoder
->enc_priv
)
684 if (ASIC_IS_AVIVO(rdev
) || radeon_r4xx_atom
) {
685 struct radeon_encoder_atom_dac
*dac_int
;
686 dac_int
= radeon_encoder
->enc_priv
;
687 dac_int
->tv_std
= val
;
689 struct radeon_encoder_tv_dac
*dac_int
;
690 dac_int
= radeon_encoder
->enc_priv
;
691 dac_int
->tv_std
= val
;
693 radeon_property_change_mode(&radeon_encoder
->base
);
696 if (property
== rdev
->mode_info
.load_detect_property
) {
697 struct radeon_connector
*radeon_connector
=
698 to_radeon_connector(connector
);
701 radeon_connector
->dac_load_detect
= false;
703 radeon_connector
->dac_load_detect
= true;
706 if (property
== rdev
->mode_info
.tmds_pll_property
) {
707 struct radeon_encoder_int_tmds
*tmds
= NULL
;
709 /* need to find digital encoder on connector */
710 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
714 radeon_encoder
= to_radeon_encoder(encoder
);
716 tmds
= radeon_encoder
->enc_priv
;
721 if (rdev
->is_atom_bios
)
722 ret
= radeon_atombios_get_tmds_info(radeon_encoder
, tmds
);
724 ret
= radeon_legacy_get_tmds_info_from_combios(radeon_encoder
, tmds
);
726 if (val
== 1 || ret
== false) {
727 radeon_legacy_get_tmds_info_from_table(radeon_encoder
, tmds
);
729 radeon_property_change_mode(&radeon_encoder
->base
);
732 if (property
== dev
->mode_config
.scaling_mode_property
) {
733 enum radeon_rmx_type rmx_type
;
735 if (connector
->encoder
)
736 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
738 const struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
739 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
744 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
745 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
746 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
747 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
749 if (radeon_encoder
->rmx_type
== rmx_type
)
752 if ((rmx_type
!= DRM_MODE_SCALE_NONE
) &&
753 (radeon_encoder
->native_mode
.clock
== 0))
756 radeon_encoder
->rmx_type
= rmx_type
;
758 radeon_property_change_mode(&radeon_encoder
->base
);
761 if (property
== rdev
->mode_info
.output_csc_property
) {
762 if (connector
->encoder
)
763 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
765 const struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
766 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
769 if (radeon_encoder
->output_csc
== val
)
772 radeon_encoder
->output_csc
= val
;
774 if (connector
->encoder
->crtc
) {
775 struct drm_crtc
*crtc
= connector
->encoder
->crtc
;
776 const struct drm_crtc_helper_funcs
*crtc_funcs
= crtc
->helper_private
;
777 struct radeon_crtc
*radeon_crtc
= to_radeon_crtc(crtc
);
779 radeon_crtc
->output_csc
= radeon_encoder
->output_csc
;
781 (*crtc_funcs
->load_lut
)(crtc
);
788 static void radeon_fixup_lvds_native_mode(struct drm_encoder
*encoder
,
789 struct drm_connector
*connector
)
791 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
792 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
793 struct drm_display_mode
*t
, *mode
;
795 /* If the EDID preferred mode doesn't match the native mode, use it */
796 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
797 if (mode
->type
& DRM_MODE_TYPE_PREFERRED
) {
798 if (mode
->hdisplay
!= native_mode
->hdisplay
||
799 mode
->vdisplay
!= native_mode
->vdisplay
)
800 memcpy(native_mode
, mode
, sizeof(*mode
));
804 /* Try to get native mode details from EDID if necessary */
805 if (!native_mode
->clock
) {
806 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
807 if (mode
->hdisplay
== native_mode
->hdisplay
&&
808 mode
->vdisplay
== native_mode
->vdisplay
) {
809 *native_mode
= *mode
;
810 drm_mode_set_crtcinfo(native_mode
, CRTC_INTERLACE_HALVE_V
);
811 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
817 if (!native_mode
->clock
) {
818 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n");
819 radeon_encoder
->rmx_type
= RMX_OFF
;
823 static int radeon_lvds_get_modes(struct drm_connector
*connector
)
825 struct drm_encoder
*encoder
;
827 struct drm_display_mode
*mode
;
829 radeon_connector_get_edid(connector
);
830 ret
= radeon_ddc_get_modes(connector
);
832 encoder
= radeon_best_single_encoder(connector
);
834 radeon_fixup_lvds_native_mode(encoder
, connector
);
835 /* add scaled modes */
836 radeon_add_common_modes(encoder
, connector
);
841 encoder
= radeon_best_single_encoder(connector
);
845 /* we have no EDID modes */
846 mode
= radeon_fp_native_mode(encoder
);
849 drm_mode_probed_add(connector
, mode
);
850 /* add the width/height from vbios tables if available */
851 connector
->display_info
.width_mm
= mode
->width_mm
;
852 connector
->display_info
.height_mm
= mode
->height_mm
;
853 /* add scaled modes */
854 radeon_add_common_modes(encoder
, connector
);
860 static int radeon_lvds_mode_valid(struct drm_connector
*connector
,
861 struct drm_display_mode
*mode
)
863 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
865 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
869 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
870 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
872 /* AVIVO hardware supports downscaling modes larger than the panel
873 * to the panel size, but I'm not sure this is desirable.
875 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
876 (mode
->vdisplay
> native_mode
->vdisplay
))
879 /* if scaling is disabled, block non-native modes */
880 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
881 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
882 (mode
->vdisplay
!= native_mode
->vdisplay
))
890 static enum drm_connector_status
891 radeon_lvds_detect(struct drm_connector
*connector
, bool force
)
893 struct drm_device
*dev
= connector
->dev
;
894 struct radeon_device
*rdev
= dev
->dev_private
;
895 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
896 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
897 enum drm_connector_status ret
= connector_status_disconnected
;
900 r
= pm_runtime_get_sync(connector
->dev
->dev
);
902 return connector_status_disconnected
;
905 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
906 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
908 /* check if panel is valid */
909 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
910 ret
= connector_status_connected
;
911 /* don't fetch the edid from the vbios if ddc fails and runpm is
912 * enabled so we report disconnected.
914 if ((rdev
->flags
& RADEON_IS_PX
) && (radeon_runtime_pm
!= 0))
915 ret
= connector_status_disconnected
;
918 /* check for edid as well */
919 radeon_connector_get_edid(connector
);
920 if (radeon_connector
->edid
)
921 ret
= connector_status_connected
;
922 /* check acpi lid status ??? */
924 radeon_connector_update_scratch_regs(connector
, ret
);
925 pm_runtime_mark_last_busy(connector
->dev
->dev
);
926 pm_runtime_put_autosuspend(connector
->dev
->dev
);
930 static void radeon_connector_unregister(struct drm_connector
*connector
)
932 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
934 if (radeon_connector
->ddc_bus
&& radeon_connector
->ddc_bus
->has_aux
) {
935 drm_dp_aux_unregister(&radeon_connector
->ddc_bus
->aux
);
936 radeon_connector
->ddc_bus
->has_aux
= false;
940 static void radeon_connector_destroy(struct drm_connector
*connector
)
942 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
944 radeon_connector_free_edid(connector
);
945 kfree(radeon_connector
->con_priv
);
946 drm_connector_unregister(connector
);
947 drm_connector_cleanup(connector
);
951 static int radeon_lvds_set_property(struct drm_connector
*connector
,
952 struct drm_property
*property
,
955 struct drm_device
*dev
= connector
->dev
;
956 struct radeon_encoder
*radeon_encoder
;
957 enum radeon_rmx_type rmx_type
;
960 if (property
!= dev
->mode_config
.scaling_mode_property
)
963 if (connector
->encoder
)
964 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
966 const struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
967 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
971 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
972 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
973 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
975 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
977 if (radeon_encoder
->rmx_type
== rmx_type
)
980 radeon_encoder
->rmx_type
= rmx_type
;
982 radeon_property_change_mode(&radeon_encoder
->base
);
987 static const struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs
= {
988 .get_modes
= radeon_lvds_get_modes
,
989 .mode_valid
= radeon_lvds_mode_valid
,
990 .best_encoder
= radeon_best_single_encoder
,
993 static const struct drm_connector_funcs radeon_lvds_connector_funcs
= {
994 .dpms
= drm_helper_connector_dpms
,
995 .detect
= radeon_lvds_detect
,
996 .fill_modes
= drm_helper_probe_single_connector_modes
,
997 .early_unregister
= radeon_connector_unregister
,
998 .destroy
= radeon_connector_destroy
,
999 .set_property
= radeon_lvds_set_property
,
1002 static int radeon_vga_get_modes(struct drm_connector
*connector
)
1006 radeon_connector_get_edid(connector
);
1007 ret
= radeon_ddc_get_modes(connector
);
1009 radeon_get_native_mode(connector
);
1014 static int radeon_vga_mode_valid(struct drm_connector
*connector
,
1015 struct drm_display_mode
*mode
)
1017 struct drm_device
*dev
= connector
->dev
;
1018 struct radeon_device
*rdev
= dev
->dev_private
;
1020 /* XXX check mode bandwidth */
1022 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
1023 return MODE_CLOCK_HIGH
;
1028 static enum drm_connector_status
1029 radeon_vga_detect(struct drm_connector
*connector
, bool force
)
1031 struct drm_device
*dev
= connector
->dev
;
1032 struct radeon_device
*rdev
= dev
->dev_private
;
1033 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1034 struct drm_encoder
*encoder
;
1035 const struct drm_encoder_helper_funcs
*encoder_funcs
;
1037 enum drm_connector_status ret
= connector_status_disconnected
;
1040 r
= pm_runtime_get_sync(connector
->dev
->dev
);
1042 return connector_status_disconnected
;
1044 encoder
= radeon_best_single_encoder(connector
);
1046 ret
= connector_status_disconnected
;
1048 if (radeon_connector
->ddc_bus
)
1049 dret
= radeon_ddc_probe(radeon_connector
, false);
1051 radeon_connector
->detected_by_load
= false;
1052 radeon_connector_free_edid(connector
);
1053 radeon_connector_get_edid(connector
);
1055 if (!radeon_connector
->edid
) {
1056 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
1058 ret
= connector_status_connected
;
1060 radeon_connector
->use_digital
=
1061 !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
1063 /* some oems have boards with separate digital and analog connectors
1064 * with a shared ddc line (often vga + hdmi)
1066 if (radeon_connector
->use_digital
&& radeon_connector
->shared_ddc
) {
1067 radeon_connector_free_edid(connector
);
1068 ret
= connector_status_disconnected
;
1070 ret
= connector_status_connected
;
1075 /* if we aren't forcing don't do destructive polling */
1077 /* only return the previous status if we last
1078 * detected a monitor via load.
1080 if (radeon_connector
->detected_by_load
)
1081 ret
= connector
->status
;
1085 if (radeon_connector
->dac_load_detect
&& encoder
) {
1086 encoder_funcs
= encoder
->helper_private
;
1087 ret
= encoder_funcs
->detect(encoder
, connector
);
1088 if (ret
!= connector_status_disconnected
)
1089 radeon_connector
->detected_by_load
= true;
1093 if (ret
== connector_status_connected
)
1094 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
1096 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
1097 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
1098 * by other means, assume the CRT is connected and use that EDID.
1100 if ((!rdev
->is_atom_bios
) &&
1101 (ret
== connector_status_disconnected
) &&
1102 rdev
->mode_info
.bios_hardcoded_edid_size
) {
1103 ret
= connector_status_connected
;
1106 radeon_connector_update_scratch_regs(connector
, ret
);
1109 pm_runtime_mark_last_busy(connector
->dev
->dev
);
1110 pm_runtime_put_autosuspend(connector
->dev
->dev
);
1115 static const struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs
= {
1116 .get_modes
= radeon_vga_get_modes
,
1117 .mode_valid
= radeon_vga_mode_valid
,
1118 .best_encoder
= radeon_best_single_encoder
,
1121 static const struct drm_connector_funcs radeon_vga_connector_funcs
= {
1122 .dpms
= drm_helper_connector_dpms
,
1123 .detect
= radeon_vga_detect
,
1124 .fill_modes
= drm_helper_probe_single_connector_modes
,
1125 .early_unregister
= radeon_connector_unregister
,
1126 .destroy
= radeon_connector_destroy
,
1127 .set_property
= radeon_connector_set_property
,
1130 static int radeon_tv_get_modes(struct drm_connector
*connector
)
1132 struct drm_device
*dev
= connector
->dev
;
1133 struct radeon_device
*rdev
= dev
->dev_private
;
1134 struct drm_display_mode
*tv_mode
;
1135 struct drm_encoder
*encoder
;
1137 encoder
= radeon_best_single_encoder(connector
);
1141 /* avivo chips can scale any mode */
1142 if (rdev
->family
>= CHIP_RS600
)
1143 /* add scaled modes */
1144 radeon_add_common_modes(encoder
, connector
);
1146 /* only 800x600 is supported right now on pre-avivo chips */
1147 tv_mode
= drm_cvt_mode(dev
, 800, 600, 60, false, false, false);
1148 tv_mode
->type
= DRM_MODE_TYPE_DRIVER
| DRM_MODE_TYPE_PREFERRED
;
1149 drm_mode_probed_add(connector
, tv_mode
);
1154 static int radeon_tv_mode_valid(struct drm_connector
*connector
,
1155 struct drm_display_mode
*mode
)
1157 if ((mode
->hdisplay
> 1024) || (mode
->vdisplay
> 768))
1158 return MODE_CLOCK_RANGE
;
1162 static enum drm_connector_status
1163 radeon_tv_detect(struct drm_connector
*connector
, bool force
)
1165 struct drm_encoder
*encoder
;
1166 const struct drm_encoder_helper_funcs
*encoder_funcs
;
1167 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1168 enum drm_connector_status ret
= connector_status_disconnected
;
1171 if (!radeon_connector
->dac_load_detect
)
1174 r
= pm_runtime_get_sync(connector
->dev
->dev
);
1176 return connector_status_disconnected
;
1178 encoder
= radeon_best_single_encoder(connector
);
1180 ret
= connector_status_disconnected
;
1182 encoder_funcs
= encoder
->helper_private
;
1183 ret
= encoder_funcs
->detect(encoder
, connector
);
1185 if (ret
== connector_status_connected
)
1186 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, false);
1187 radeon_connector_update_scratch_regs(connector
, ret
);
1188 pm_runtime_mark_last_busy(connector
->dev
->dev
);
1189 pm_runtime_put_autosuspend(connector
->dev
->dev
);
1193 static const struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs
= {
1194 .get_modes
= radeon_tv_get_modes
,
1195 .mode_valid
= radeon_tv_mode_valid
,
1196 .best_encoder
= radeon_best_single_encoder
,
1199 static const struct drm_connector_funcs radeon_tv_connector_funcs
= {
1200 .dpms
= drm_helper_connector_dpms
,
1201 .detect
= radeon_tv_detect
,
1202 .fill_modes
= drm_helper_probe_single_connector_modes
,
1203 .early_unregister
= radeon_connector_unregister
,
1204 .destroy
= radeon_connector_destroy
,
1205 .set_property
= radeon_connector_set_property
,
1208 static bool radeon_check_hpd_status_unchanged(struct drm_connector
*connector
)
1210 struct drm_device
*dev
= connector
->dev
;
1211 struct radeon_device
*rdev
= dev
->dev_private
;
1212 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1213 enum drm_connector_status status
;
1215 /* We only trust HPD on R600 and newer ASICS. */
1216 if (rdev
->family
>= CHIP_R600
1217 && radeon_connector
->hpd
.hpd
!= RADEON_HPD_NONE
) {
1218 if (radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
))
1219 status
= connector_status_connected
;
1221 status
= connector_status_disconnected
;
1222 if (connector
->status
== status
)
1230 * DVI is complicated
1231 * Do a DDC probe, if DDC probe passes, get the full EDID so
1232 * we can do analog/digital monitor detection at this point.
1233 * If the monitor is an analog monitor or we got no DDC,
1234 * we need to find the DAC encoder object for this connector.
1235 * If we got no DDC, we do load detection on the DAC encoder object.
1236 * If we got analog DDC or load detection passes on the DAC encoder
1237 * we have to check if this analog encoder is shared with anyone else (TV)
1238 * if its shared we have to set the other connector to disconnected.
1240 static enum drm_connector_status
1241 radeon_dvi_detect(struct drm_connector
*connector
, bool force
)
1243 struct drm_device
*dev
= connector
->dev
;
1244 struct radeon_device
*rdev
= dev
->dev_private
;
1245 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1246 struct drm_encoder
*encoder
= NULL
;
1247 const struct drm_encoder_helper_funcs
*encoder_funcs
;
1249 enum drm_connector_status ret
= connector_status_disconnected
;
1250 bool dret
= false, broken_edid
= false;
1252 r
= pm_runtime_get_sync(connector
->dev
->dev
);
1254 return connector_status_disconnected
;
1256 if (radeon_connector
->detected_hpd_without_ddc
) {
1258 radeon_connector
->detected_hpd_without_ddc
= false;
1261 if (!force
&& radeon_check_hpd_status_unchanged(connector
)) {
1262 ret
= connector
->status
;
1266 if (radeon_connector
->ddc_bus
) {
1267 dret
= radeon_ddc_probe(radeon_connector
, false);
1269 /* Sometimes the pins required for the DDC probe on DVI
1270 * connectors don't make contact at the same time that the ones
1271 * for HPD do. If the DDC probe fails even though we had an HPD
1272 * signal, try again later */
1273 if (!dret
&& !force
&&
1274 connector
->status
!= connector_status_connected
) {
1275 DRM_DEBUG_KMS("hpd detected without ddc, retrying in 1 second\n");
1276 radeon_connector
->detected_hpd_without_ddc
= true;
1277 schedule_delayed_work(&rdev
->hotplug_work
,
1278 msecs_to_jiffies(1000));
1283 radeon_connector
->detected_by_load
= false;
1284 radeon_connector_free_edid(connector
);
1285 radeon_connector_get_edid(connector
);
1287 if (!radeon_connector
->edid
) {
1288 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
1290 /* rs690 seems to have a problem with connectors not existing and always
1291 * return a block of 0's. If we see this just stop polling on this output */
1292 if ((rdev
->family
== CHIP_RS690
|| rdev
->family
== CHIP_RS740
) &&
1293 radeon_connector
->base
.null_edid_counter
) {
1294 ret
= connector_status_disconnected
;
1295 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n",
1297 radeon_connector
->ddc_bus
= NULL
;
1299 ret
= connector_status_connected
;
1300 broken_edid
= true; /* defer use_digital to later */
1303 radeon_connector
->use_digital
=
1304 !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
1306 /* some oems have boards with separate digital and analog connectors
1307 * with a shared ddc line (often vga + hdmi)
1309 if ((!radeon_connector
->use_digital
) && radeon_connector
->shared_ddc
) {
1310 radeon_connector_free_edid(connector
);
1311 ret
= connector_status_disconnected
;
1313 ret
= connector_status_connected
;
1315 /* This gets complicated. We have boards with VGA + HDMI with a
1316 * shared DDC line and we have boards with DVI-D + HDMI with a shared
1317 * DDC line. The latter is more complex because with DVI<->HDMI adapters
1318 * you don't really know what's connected to which port as both are digital.
1320 if (radeon_connector
->shared_ddc
&& (ret
== connector_status_connected
)) {
1321 struct drm_connector
*list_connector
;
1322 struct radeon_connector
*list_radeon_connector
;
1323 list_for_each_entry(list_connector
, &dev
->mode_config
.connector_list
, head
) {
1324 if (connector
== list_connector
)
1326 list_radeon_connector
= to_radeon_connector(list_connector
);
1327 if (list_radeon_connector
->shared_ddc
&&
1328 (list_radeon_connector
->ddc_bus
->rec
.i2c_id
==
1329 radeon_connector
->ddc_bus
->rec
.i2c_id
)) {
1330 /* cases where both connectors are digital */
1331 if (list_connector
->connector_type
!= DRM_MODE_CONNECTOR_VGA
) {
1332 /* hpd is our only option in this case */
1333 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
1334 radeon_connector_free_edid(connector
);
1335 ret
= connector_status_disconnected
;
1344 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== true))
1347 /* DVI-D and HDMI-A are digital only */
1348 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_DVID
) ||
1349 (connector
->connector_type
== DRM_MODE_CONNECTOR_HDMIA
))
1352 /* if we aren't forcing don't do destructive polling */
1354 /* only return the previous status if we last
1355 * detected a monitor via load.
1357 if (radeon_connector
->detected_by_load
)
1358 ret
= connector
->status
;
1362 /* find analog encoder */
1363 if (radeon_connector
->dac_load_detect
) {
1364 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1365 if (connector
->encoder_ids
[i
] == 0)
1368 encoder
= drm_encoder_find(connector
->dev
,
1369 connector
->encoder_ids
[i
]);
1373 if (encoder
->encoder_type
!= DRM_MODE_ENCODER_DAC
&&
1374 encoder
->encoder_type
!= DRM_MODE_ENCODER_TVDAC
)
1377 encoder_funcs
= encoder
->helper_private
;
1378 if (encoder_funcs
->detect
) {
1380 if (ret
!= connector_status_connected
) {
1381 /* deal with analog monitors without DDC */
1382 ret
= encoder_funcs
->detect(encoder
, connector
);
1383 if (ret
== connector_status_connected
) {
1384 radeon_connector
->use_digital
= false;
1386 if (ret
!= connector_status_disconnected
)
1387 radeon_connector
->detected_by_load
= true;
1390 enum drm_connector_status lret
;
1391 /* assume digital unless load detected otherwise */
1392 radeon_connector
->use_digital
= true;
1393 lret
= encoder_funcs
->detect(encoder
, connector
);
1394 DRM_DEBUG_KMS("load_detect %x returned: %x\n",encoder
->encoder_type
,lret
);
1395 if (lret
== connector_status_connected
)
1396 radeon_connector
->use_digital
= false;
1403 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== false) &&
1405 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
1408 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
1409 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
1410 * by other means, assume the DFP is connected and use that EDID. In most
1411 * cases the DVI port is actually a virtual KVM port connected to the service
1415 if ((!rdev
->is_atom_bios
) &&
1416 (ret
== connector_status_disconnected
) &&
1417 rdev
->mode_info
.bios_hardcoded_edid_size
) {
1418 radeon_connector
->use_digital
= true;
1419 ret
= connector_status_connected
;
1422 /* updated in get modes as well since we need to know if it's analog or digital */
1423 radeon_connector_update_scratch_regs(connector
, ret
);
1425 if ((radeon_audio
!= 0) && radeon_connector
->use_digital
) {
1426 const struct drm_connector_helper_funcs
*connector_funcs
=
1427 connector
->helper_private
;
1429 encoder
= connector_funcs
->best_encoder(connector
);
1430 if (encoder
&& (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)) {
1431 radeon_connector_get_edid(connector
);
1432 radeon_audio_detect(connector
, encoder
, ret
);
1437 pm_runtime_mark_last_busy(connector
->dev
->dev
);
1438 pm_runtime_put_autosuspend(connector
->dev
->dev
);
1443 /* okay need to be smart in here about which encoder to pick */
1444 static struct drm_encoder
*radeon_dvi_encoder(struct drm_connector
*connector
)
1446 int enc_id
= connector
->encoder_ids
[0];
1447 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1448 struct drm_encoder
*encoder
;
1450 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1451 if (connector
->encoder_ids
[i
] == 0)
1454 encoder
= drm_encoder_find(connector
->dev
, connector
->encoder_ids
[i
]);
1458 if (radeon_connector
->use_digital
== true) {
1459 if (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)
1462 if (encoder
->encoder_type
== DRM_MODE_ENCODER_DAC
||
1463 encoder
->encoder_type
== DRM_MODE_ENCODER_TVDAC
)
1468 /* see if we have a default encoder TODO */
1470 /* then check use digitial */
1471 /* pick the first one */
1473 return drm_encoder_find(connector
->dev
, enc_id
);
1477 static void radeon_dvi_force(struct drm_connector
*connector
)
1479 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1480 if (connector
->force
== DRM_FORCE_ON
)
1481 radeon_connector
->use_digital
= false;
1482 if (connector
->force
== DRM_FORCE_ON_DIGITAL
)
1483 radeon_connector
->use_digital
= true;
1486 static int radeon_dvi_mode_valid(struct drm_connector
*connector
,
1487 struct drm_display_mode
*mode
)
1489 struct drm_device
*dev
= connector
->dev
;
1490 struct radeon_device
*rdev
= dev
->dev_private
;
1491 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1493 /* XXX check mode bandwidth */
1495 /* clocks over 135 MHz have heat issues with DVI on RV100 */
1496 if (radeon_connector
->use_digital
&&
1497 (rdev
->family
== CHIP_RV100
) &&
1498 (mode
->clock
> 135000))
1499 return MODE_CLOCK_HIGH
;
1501 if (radeon_connector
->use_digital
&& (mode
->clock
> 165000)) {
1502 if ((radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
) ||
1503 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
) ||
1504 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_B
))
1506 else if (ASIC_IS_DCE6(rdev
) && drm_detect_hdmi_monitor(radeon_connector_edid(connector
))) {
1507 /* HDMI 1.3+ supports max clock of 340 Mhz */
1508 if (mode
->clock
> 340000)
1509 return MODE_CLOCK_HIGH
;
1513 return MODE_CLOCK_HIGH
;
1517 /* check against the max pixel clock */
1518 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
1519 return MODE_CLOCK_HIGH
;
1524 static const struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs
= {
1525 .get_modes
= radeon_vga_get_modes
,
1526 .mode_valid
= radeon_dvi_mode_valid
,
1527 .best_encoder
= radeon_dvi_encoder
,
1530 static const struct drm_connector_funcs radeon_dvi_connector_funcs
= {
1531 .dpms
= drm_helper_connector_dpms
,
1532 .detect
= radeon_dvi_detect
,
1533 .fill_modes
= drm_helper_probe_single_connector_modes
,
1534 .set_property
= radeon_connector_set_property
,
1535 .early_unregister
= radeon_connector_unregister
,
1536 .destroy
= radeon_connector_destroy
,
1537 .force
= radeon_dvi_force
,
1540 static int radeon_dp_get_modes(struct drm_connector
*connector
)
1542 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1543 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1544 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1547 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1548 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1549 struct drm_display_mode
*mode
;
1551 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) {
1552 if (!radeon_dig_connector
->edp_on
)
1553 atombios_set_edp_panel_power(connector
,
1554 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1555 radeon_connector_get_edid(connector
);
1556 ret
= radeon_ddc_get_modes(connector
);
1557 if (!radeon_dig_connector
->edp_on
)
1558 atombios_set_edp_panel_power(connector
,
1559 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1561 /* need to setup ddc on the bridge */
1562 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1563 ENCODER_OBJECT_ID_NONE
) {
1565 radeon_atom_ext_encoder_setup_ddc(encoder
);
1567 radeon_connector_get_edid(connector
);
1568 ret
= radeon_ddc_get_modes(connector
);
1573 radeon_fixup_lvds_native_mode(encoder
, connector
);
1574 /* add scaled modes */
1575 radeon_add_common_modes(encoder
, connector
);
1583 /* we have no EDID modes */
1584 mode
= radeon_fp_native_mode(encoder
);
1587 drm_mode_probed_add(connector
, mode
);
1588 /* add the width/height from vbios tables if available */
1589 connector
->display_info
.width_mm
= mode
->width_mm
;
1590 connector
->display_info
.height_mm
= mode
->height_mm
;
1591 /* add scaled modes */
1592 radeon_add_common_modes(encoder
, connector
);
1595 /* need to setup ddc on the bridge */
1596 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1597 ENCODER_OBJECT_ID_NONE
) {
1599 radeon_atom_ext_encoder_setup_ddc(encoder
);
1601 radeon_connector_get_edid(connector
);
1602 ret
= radeon_ddc_get_modes(connector
);
1604 radeon_get_native_mode(connector
);
1610 u16
radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector
*connector
)
1612 struct drm_encoder
*encoder
;
1613 struct radeon_encoder
*radeon_encoder
;
1616 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1617 if (connector
->encoder_ids
[i
] == 0)
1620 encoder
= drm_encoder_find(connector
->dev
, connector
->encoder_ids
[i
]);
1624 radeon_encoder
= to_radeon_encoder(encoder
);
1626 switch (radeon_encoder
->encoder_id
) {
1627 case ENCODER_OBJECT_ID_TRAVIS
:
1628 case ENCODER_OBJECT_ID_NUTMEG
:
1629 return radeon_encoder
->encoder_id
;
1635 return ENCODER_OBJECT_ID_NONE
;
1638 static bool radeon_connector_encoder_is_hbr2(struct drm_connector
*connector
)
1640 struct drm_encoder
*encoder
;
1641 struct radeon_encoder
*radeon_encoder
;
1645 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1646 if (connector
->encoder_ids
[i
] == 0)
1649 encoder
= drm_encoder_find(connector
->dev
, connector
->encoder_ids
[i
]);
1653 radeon_encoder
= to_radeon_encoder(encoder
);
1654 if (radeon_encoder
->caps
& ATOM_ENCODER_CAP_RECORD_HBR2
)
1661 bool radeon_connector_is_dp12_capable(struct drm_connector
*connector
)
1663 struct drm_device
*dev
= connector
->dev
;
1664 struct radeon_device
*rdev
= dev
->dev_private
;
1666 if (ASIC_IS_DCE5(rdev
) &&
1667 (rdev
->clock
.default_dispclk
>= 53900) &&
1668 radeon_connector_encoder_is_hbr2(connector
)) {
1675 static enum drm_connector_status
1676 radeon_dp_detect(struct drm_connector
*connector
, bool force
)
1678 struct drm_device
*dev
= connector
->dev
;
1679 struct radeon_device
*rdev
= dev
->dev_private
;
1680 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1681 enum drm_connector_status ret
= connector_status_disconnected
;
1682 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1683 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1686 if (radeon_dig_connector
->is_mst
)
1687 return connector_status_disconnected
;
1689 r
= pm_runtime_get_sync(connector
->dev
->dev
);
1691 return connector_status_disconnected
;
1693 if (!force
&& radeon_check_hpd_status_unchanged(connector
)) {
1694 ret
= connector
->status
;
1698 radeon_connector_free_edid(connector
);
1700 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1701 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1703 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1704 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1706 /* check if panel is valid */
1707 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
1708 ret
= connector_status_connected
;
1709 /* don't fetch the edid from the vbios if ddc fails and runpm is
1710 * enabled so we report disconnected.
1712 if ((rdev
->flags
& RADEON_IS_PX
) && (radeon_runtime_pm
!= 0))
1713 ret
= connector_status_disconnected
;
1715 /* eDP is always DP */
1716 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1717 if (!radeon_dig_connector
->edp_on
)
1718 atombios_set_edp_panel_power(connector
,
1719 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1720 if (radeon_dp_getdpcd(radeon_connector
))
1721 ret
= connector_status_connected
;
1722 if (!radeon_dig_connector
->edp_on
)
1723 atombios_set_edp_panel_power(connector
,
1724 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1725 } else if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1726 ENCODER_OBJECT_ID_NONE
) {
1727 /* DP bridges are always DP */
1728 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1729 /* get the DPCD from the bridge */
1730 radeon_dp_getdpcd(radeon_connector
);
1733 /* setup ddc on the bridge */
1734 radeon_atom_ext_encoder_setup_ddc(encoder
);
1735 /* bridge chips are always aux */
1736 if (radeon_ddc_probe(radeon_connector
, true)) /* try DDC */
1737 ret
= connector_status_connected
;
1738 else if (radeon_connector
->dac_load_detect
) { /* try load detection */
1739 const struct drm_encoder_helper_funcs
*encoder_funcs
= encoder
->helper_private
;
1740 ret
= encoder_funcs
->detect(encoder
, connector
);
1744 radeon_dig_connector
->dp_sink_type
= radeon_dp_getsinktype(radeon_connector
);
1745 if (radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
1746 ret
= connector_status_connected
;
1747 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
1748 radeon_dp_getdpcd(radeon_connector
);
1749 r
= radeon_dp_mst_probe(radeon_connector
);
1751 ret
= connector_status_disconnected
;
1754 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
1755 if (radeon_dp_getdpcd(radeon_connector
)) {
1756 r
= radeon_dp_mst_probe(radeon_connector
);
1758 ret
= connector_status_disconnected
;
1760 ret
= connector_status_connected
;
1763 /* try non-aux ddc (DP to DVI/HDMI/etc. adapter) */
1764 if (radeon_ddc_probe(radeon_connector
, false))
1765 ret
= connector_status_connected
;
1770 radeon_connector_update_scratch_regs(connector
, ret
);
1772 if ((radeon_audio
!= 0) && encoder
) {
1773 radeon_connector_get_edid(connector
);
1774 radeon_audio_detect(connector
, encoder
, ret
);
1778 pm_runtime_mark_last_busy(connector
->dev
->dev
);
1779 pm_runtime_put_autosuspend(connector
->dev
->dev
);
1784 static int radeon_dp_mode_valid(struct drm_connector
*connector
,
1785 struct drm_display_mode
*mode
)
1787 struct drm_device
*dev
= connector
->dev
;
1788 struct radeon_device
*rdev
= dev
->dev_private
;
1789 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1790 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1792 /* XXX check mode bandwidth */
1794 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1795 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1796 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1798 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
1802 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1803 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1805 /* AVIVO hardware supports downscaling modes larger than the panel
1806 * to the panel size, but I'm not sure this is desirable.
1808 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
1809 (mode
->vdisplay
> native_mode
->vdisplay
))
1812 /* if scaling is disabled, block non-native modes */
1813 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
1814 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
1815 (mode
->vdisplay
!= native_mode
->vdisplay
))
1820 if ((radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
1821 (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
)) {
1822 return radeon_dp_mode_valid_helper(connector
, mode
);
1824 if (ASIC_IS_DCE6(rdev
) && drm_detect_hdmi_monitor(radeon_connector_edid(connector
))) {
1825 /* HDMI 1.3+ supports max clock of 340 Mhz */
1826 if (mode
->clock
> 340000)
1827 return MODE_CLOCK_HIGH
;
1829 if (mode
->clock
> 165000)
1830 return MODE_CLOCK_HIGH
;
1838 static const struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs
= {
1839 .get_modes
= radeon_dp_get_modes
,
1840 .mode_valid
= radeon_dp_mode_valid
,
1841 .best_encoder
= radeon_dvi_encoder
,
1844 static const struct drm_connector_funcs radeon_dp_connector_funcs
= {
1845 .dpms
= drm_helper_connector_dpms
,
1846 .detect
= radeon_dp_detect
,
1847 .fill_modes
= drm_helper_probe_single_connector_modes
,
1848 .set_property
= radeon_connector_set_property
,
1849 .early_unregister
= radeon_connector_unregister
,
1850 .destroy
= radeon_connector_destroy
,
1851 .force
= radeon_dvi_force
,
1854 static const struct drm_connector_funcs radeon_edp_connector_funcs
= {
1855 .dpms
= drm_helper_connector_dpms
,
1856 .detect
= radeon_dp_detect
,
1857 .fill_modes
= drm_helper_probe_single_connector_modes
,
1858 .set_property
= radeon_lvds_set_property
,
1859 .early_unregister
= radeon_connector_unregister
,
1860 .destroy
= radeon_connector_destroy
,
1861 .force
= radeon_dvi_force
,
1864 static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs
= {
1865 .dpms
= drm_helper_connector_dpms
,
1866 .detect
= radeon_dp_detect
,
1867 .fill_modes
= drm_helper_probe_single_connector_modes
,
1868 .set_property
= radeon_lvds_set_property
,
1869 .early_unregister
= radeon_connector_unregister
,
1870 .destroy
= radeon_connector_destroy
,
1871 .force
= radeon_dvi_force
,
1875 radeon_add_atom_connector(struct drm_device
*dev
,
1876 uint32_t connector_id
,
1877 uint32_t supported_device
,
1879 struct radeon_i2c_bus_rec
*i2c_bus
,
1880 uint32_t igp_lane_info
,
1881 uint16_t connector_object_id
,
1882 struct radeon_hpd
*hpd
,
1883 struct radeon_router
*router
)
1885 struct radeon_device
*rdev
= dev
->dev_private
;
1886 struct drm_connector
*connector
;
1887 struct radeon_connector
*radeon_connector
;
1888 struct radeon_connector_atom_dig
*radeon_dig_connector
;
1889 struct drm_encoder
*encoder
;
1890 struct radeon_encoder
*radeon_encoder
;
1891 uint32_t subpixel_order
= SubPixelNone
;
1892 bool shared_ddc
= false;
1893 bool is_dp_bridge
= false;
1894 bool has_aux
= false;
1896 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1899 /* if the user selected tv=0 don't try and add the connector */
1900 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1901 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1902 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1906 /* see if we already added it */
1907 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1908 radeon_connector
= to_radeon_connector(connector
);
1909 if (radeon_connector
->connector_id
== connector_id
) {
1910 radeon_connector
->devices
|= supported_device
;
1913 if (radeon_connector
->ddc_bus
&& i2c_bus
->valid
) {
1914 if (radeon_connector
->ddc_bus
->rec
.i2c_id
== i2c_bus
->i2c_id
) {
1915 radeon_connector
->shared_ddc
= true;
1918 if (radeon_connector
->router_bus
&& router
->ddc_valid
&&
1919 (radeon_connector
->router
.router_id
== router
->router_id
)) {
1920 radeon_connector
->shared_ddc
= false;
1926 /* check if it's a dp bridge */
1927 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
1928 radeon_encoder
= to_radeon_encoder(encoder
);
1929 if (radeon_encoder
->devices
& supported_device
) {
1930 switch (radeon_encoder
->encoder_id
) {
1931 case ENCODER_OBJECT_ID_TRAVIS
:
1932 case ENCODER_OBJECT_ID_NUTMEG
:
1933 is_dp_bridge
= true;
1941 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1942 if (!radeon_connector
)
1945 connector
= &radeon_connector
->base
;
1947 radeon_connector
->connector_id
= connector_id
;
1948 radeon_connector
->devices
= supported_device
;
1949 radeon_connector
->shared_ddc
= shared_ddc
;
1950 radeon_connector
->connector_object_id
= connector_object_id
;
1951 radeon_connector
->hpd
= *hpd
;
1953 radeon_connector
->router
= *router
;
1954 if (router
->ddc_valid
|| router
->cd_valid
) {
1955 radeon_connector
->router_bus
= radeon_i2c_lookup(rdev
, &router
->i2c_info
);
1956 if (!radeon_connector
->router_bus
)
1957 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n");
1961 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1962 if (!radeon_dig_connector
)
1964 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1965 radeon_connector
->con_priv
= radeon_dig_connector
;
1966 if (i2c_bus
->valid
) {
1967 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1968 if (radeon_connector
->ddc_bus
)
1971 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1973 switch (connector_type
) {
1974 case DRM_MODE_CONNECTOR_VGA
:
1975 case DRM_MODE_CONNECTOR_DVIA
:
1977 drm_connector_init(dev
, &radeon_connector
->base
,
1978 &radeon_dp_connector_funcs
, connector_type
);
1979 drm_connector_helper_add(&radeon_connector
->base
,
1980 &radeon_dp_connector_helper_funcs
);
1981 connector
->interlace_allowed
= true;
1982 connector
->doublescan_allowed
= true;
1983 radeon_connector
->dac_load_detect
= true;
1984 drm_object_attach_property(&radeon_connector
->base
.base
,
1985 rdev
->mode_info
.load_detect_property
,
1987 drm_object_attach_property(&radeon_connector
->base
.base
,
1988 dev
->mode_config
.scaling_mode_property
,
1989 DRM_MODE_SCALE_NONE
);
1990 if (ASIC_IS_DCE5(rdev
))
1991 drm_object_attach_property(&radeon_connector
->base
.base
,
1992 rdev
->mode_info
.output_csc_property
,
1993 RADEON_OUTPUT_CSC_BYPASS
);
1995 case DRM_MODE_CONNECTOR_DVII
:
1996 case DRM_MODE_CONNECTOR_DVID
:
1997 case DRM_MODE_CONNECTOR_HDMIA
:
1998 case DRM_MODE_CONNECTOR_HDMIB
:
1999 case DRM_MODE_CONNECTOR_DisplayPort
:
2000 drm_connector_init(dev
, &radeon_connector
->base
,
2001 &radeon_dp_connector_funcs
, connector_type
);
2002 drm_connector_helper_add(&radeon_connector
->base
,
2003 &radeon_dp_connector_helper_funcs
);
2004 drm_object_attach_property(&radeon_connector
->base
.base
,
2005 rdev
->mode_info
.underscan_property
,
2007 drm_object_attach_property(&radeon_connector
->base
.base
,
2008 rdev
->mode_info
.underscan_hborder_property
,
2010 drm_object_attach_property(&radeon_connector
->base
.base
,
2011 rdev
->mode_info
.underscan_vborder_property
,
2014 drm_object_attach_property(&radeon_connector
->base
.base
,
2015 dev
->mode_config
.scaling_mode_property
,
2016 DRM_MODE_SCALE_NONE
);
2018 drm_object_attach_property(&radeon_connector
->base
.base
,
2019 rdev
->mode_info
.dither_property
,
2020 RADEON_FMT_DITHER_DISABLE
);
2022 if (radeon_audio
!= 0) {
2023 drm_object_attach_property(&radeon_connector
->base
.base
,
2024 rdev
->mode_info
.audio_property
,
2026 radeon_connector
->audio
= RADEON_AUDIO_AUTO
;
2028 if (ASIC_IS_DCE5(rdev
))
2029 drm_object_attach_property(&radeon_connector
->base
.base
,
2030 rdev
->mode_info
.output_csc_property
,
2031 RADEON_OUTPUT_CSC_BYPASS
);
2033 subpixel_order
= SubPixelHorizontalRGB
;
2034 connector
->interlace_allowed
= true;
2035 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
2036 connector
->doublescan_allowed
= true;
2038 connector
->doublescan_allowed
= false;
2039 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
2040 radeon_connector
->dac_load_detect
= true;
2041 drm_object_attach_property(&radeon_connector
->base
.base
,
2042 rdev
->mode_info
.load_detect_property
,
2046 case DRM_MODE_CONNECTOR_LVDS
:
2047 case DRM_MODE_CONNECTOR_eDP
:
2048 drm_connector_init(dev
, &radeon_connector
->base
,
2049 &radeon_lvds_bridge_connector_funcs
, connector_type
);
2050 drm_connector_helper_add(&radeon_connector
->base
,
2051 &radeon_dp_connector_helper_funcs
);
2052 drm_object_attach_property(&radeon_connector
->base
.base
,
2053 dev
->mode_config
.scaling_mode_property
,
2054 DRM_MODE_SCALE_FULLSCREEN
);
2055 subpixel_order
= SubPixelHorizontalRGB
;
2056 connector
->interlace_allowed
= false;
2057 connector
->doublescan_allowed
= false;
2061 switch (connector_type
) {
2062 case DRM_MODE_CONNECTOR_VGA
:
2063 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
2064 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
2065 if (i2c_bus
->valid
) {
2066 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2067 if (!radeon_connector
->ddc_bus
)
2068 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2070 radeon_connector
->dac_load_detect
= true;
2071 drm_object_attach_property(&radeon_connector
->base
.base
,
2072 rdev
->mode_info
.load_detect_property
,
2074 if (ASIC_IS_AVIVO(rdev
))
2075 drm_object_attach_property(&radeon_connector
->base
.base
,
2076 dev
->mode_config
.scaling_mode_property
,
2077 DRM_MODE_SCALE_NONE
);
2078 if (ASIC_IS_DCE5(rdev
))
2079 drm_object_attach_property(&radeon_connector
->base
.base
,
2080 rdev
->mode_info
.output_csc_property
,
2081 RADEON_OUTPUT_CSC_BYPASS
);
2082 /* no HPD on analog connectors */
2083 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2084 connector
->interlace_allowed
= true;
2085 connector
->doublescan_allowed
= true;
2087 case DRM_MODE_CONNECTOR_DVIA
:
2088 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
2089 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
2090 if (i2c_bus
->valid
) {
2091 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2092 if (!radeon_connector
->ddc_bus
)
2093 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2095 radeon_connector
->dac_load_detect
= true;
2096 drm_object_attach_property(&radeon_connector
->base
.base
,
2097 rdev
->mode_info
.load_detect_property
,
2099 if (ASIC_IS_AVIVO(rdev
))
2100 drm_object_attach_property(&radeon_connector
->base
.base
,
2101 dev
->mode_config
.scaling_mode_property
,
2102 DRM_MODE_SCALE_NONE
);
2103 if (ASIC_IS_DCE5(rdev
))
2104 drm_object_attach_property(&radeon_connector
->base
.base
,
2105 rdev
->mode_info
.output_csc_property
,
2106 RADEON_OUTPUT_CSC_BYPASS
);
2107 /* no HPD on analog connectors */
2108 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2109 connector
->interlace_allowed
= true;
2110 connector
->doublescan_allowed
= true;
2112 case DRM_MODE_CONNECTOR_DVII
:
2113 case DRM_MODE_CONNECTOR_DVID
:
2114 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
2115 if (!radeon_dig_connector
)
2117 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
2118 radeon_connector
->con_priv
= radeon_dig_connector
;
2119 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
2120 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
2121 if (i2c_bus
->valid
) {
2122 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2123 if (!radeon_connector
->ddc_bus
)
2124 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2126 subpixel_order
= SubPixelHorizontalRGB
;
2127 drm_object_attach_property(&radeon_connector
->base
.base
,
2128 rdev
->mode_info
.coherent_mode_property
,
2130 if (ASIC_IS_AVIVO(rdev
)) {
2131 drm_object_attach_property(&radeon_connector
->base
.base
,
2132 rdev
->mode_info
.underscan_property
,
2134 drm_object_attach_property(&radeon_connector
->base
.base
,
2135 rdev
->mode_info
.underscan_hborder_property
,
2137 drm_object_attach_property(&radeon_connector
->base
.base
,
2138 rdev
->mode_info
.underscan_vborder_property
,
2140 drm_object_attach_property(&radeon_connector
->base
.base
,
2141 rdev
->mode_info
.dither_property
,
2142 RADEON_FMT_DITHER_DISABLE
);
2143 drm_object_attach_property(&radeon_connector
->base
.base
,
2144 dev
->mode_config
.scaling_mode_property
,
2145 DRM_MODE_SCALE_NONE
);
2147 if (ASIC_IS_DCE2(rdev
) && (radeon_audio
!= 0)) {
2148 drm_object_attach_property(&radeon_connector
->base
.base
,
2149 rdev
->mode_info
.audio_property
,
2151 radeon_connector
->audio
= RADEON_AUDIO_AUTO
;
2153 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
2154 radeon_connector
->dac_load_detect
= true;
2155 drm_object_attach_property(&radeon_connector
->base
.base
,
2156 rdev
->mode_info
.load_detect_property
,
2159 if (ASIC_IS_DCE5(rdev
))
2160 drm_object_attach_property(&radeon_connector
->base
.base
,
2161 rdev
->mode_info
.output_csc_property
,
2162 RADEON_OUTPUT_CSC_BYPASS
);
2163 connector
->interlace_allowed
= true;
2164 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
2165 connector
->doublescan_allowed
= true;
2167 connector
->doublescan_allowed
= false;
2169 case DRM_MODE_CONNECTOR_HDMIA
:
2170 case DRM_MODE_CONNECTOR_HDMIB
:
2171 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
2172 if (!radeon_dig_connector
)
2174 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
2175 radeon_connector
->con_priv
= radeon_dig_connector
;
2176 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
2177 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
2178 if (i2c_bus
->valid
) {
2179 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2180 if (!radeon_connector
->ddc_bus
)
2181 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2183 drm_object_attach_property(&radeon_connector
->base
.base
,
2184 rdev
->mode_info
.coherent_mode_property
,
2186 if (ASIC_IS_AVIVO(rdev
)) {
2187 drm_object_attach_property(&radeon_connector
->base
.base
,
2188 rdev
->mode_info
.underscan_property
,
2190 drm_object_attach_property(&radeon_connector
->base
.base
,
2191 rdev
->mode_info
.underscan_hborder_property
,
2193 drm_object_attach_property(&radeon_connector
->base
.base
,
2194 rdev
->mode_info
.underscan_vborder_property
,
2196 drm_object_attach_property(&radeon_connector
->base
.base
,
2197 rdev
->mode_info
.dither_property
,
2198 RADEON_FMT_DITHER_DISABLE
);
2199 drm_object_attach_property(&radeon_connector
->base
.base
,
2200 dev
->mode_config
.scaling_mode_property
,
2201 DRM_MODE_SCALE_NONE
);
2203 if (ASIC_IS_DCE2(rdev
) && (radeon_audio
!= 0)) {
2204 drm_object_attach_property(&radeon_connector
->base
.base
,
2205 rdev
->mode_info
.audio_property
,
2207 radeon_connector
->audio
= RADEON_AUDIO_AUTO
;
2209 if (ASIC_IS_DCE5(rdev
))
2210 drm_object_attach_property(&radeon_connector
->base
.base
,
2211 rdev
->mode_info
.output_csc_property
,
2212 RADEON_OUTPUT_CSC_BYPASS
);
2213 subpixel_order
= SubPixelHorizontalRGB
;
2214 connector
->interlace_allowed
= true;
2215 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
2216 connector
->doublescan_allowed
= true;
2218 connector
->doublescan_allowed
= false;
2220 case DRM_MODE_CONNECTOR_DisplayPort
:
2221 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
2222 if (!radeon_dig_connector
)
2224 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
2225 radeon_connector
->con_priv
= radeon_dig_connector
;
2226 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
2227 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
2228 if (i2c_bus
->valid
) {
2229 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2230 if (radeon_connector
->ddc_bus
)
2233 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2235 subpixel_order
= SubPixelHorizontalRGB
;
2236 drm_object_attach_property(&radeon_connector
->base
.base
,
2237 rdev
->mode_info
.coherent_mode_property
,
2239 if (ASIC_IS_AVIVO(rdev
)) {
2240 drm_object_attach_property(&radeon_connector
->base
.base
,
2241 rdev
->mode_info
.underscan_property
,
2243 drm_object_attach_property(&radeon_connector
->base
.base
,
2244 rdev
->mode_info
.underscan_hborder_property
,
2246 drm_object_attach_property(&radeon_connector
->base
.base
,
2247 rdev
->mode_info
.underscan_vborder_property
,
2249 drm_object_attach_property(&radeon_connector
->base
.base
,
2250 rdev
->mode_info
.dither_property
,
2251 RADEON_FMT_DITHER_DISABLE
);
2252 drm_object_attach_property(&radeon_connector
->base
.base
,
2253 dev
->mode_config
.scaling_mode_property
,
2254 DRM_MODE_SCALE_NONE
);
2256 if (ASIC_IS_DCE2(rdev
) && (radeon_audio
!= 0)) {
2257 drm_object_attach_property(&radeon_connector
->base
.base
,
2258 rdev
->mode_info
.audio_property
,
2260 radeon_connector
->audio
= RADEON_AUDIO_AUTO
;
2262 if (ASIC_IS_DCE5(rdev
))
2263 drm_object_attach_property(&radeon_connector
->base
.base
,
2264 rdev
->mode_info
.output_csc_property
,
2265 RADEON_OUTPUT_CSC_BYPASS
);
2266 connector
->interlace_allowed
= true;
2267 /* in theory with a DP to VGA converter... */
2268 connector
->doublescan_allowed
= false;
2270 case DRM_MODE_CONNECTOR_eDP
:
2271 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
2272 if (!radeon_dig_connector
)
2274 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
2275 radeon_connector
->con_priv
= radeon_dig_connector
;
2276 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_edp_connector_funcs
, connector_type
);
2277 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
2278 if (i2c_bus
->valid
) {
2279 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2280 if (radeon_connector
->ddc_bus
)
2283 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2285 drm_object_attach_property(&radeon_connector
->base
.base
,
2286 dev
->mode_config
.scaling_mode_property
,
2287 DRM_MODE_SCALE_FULLSCREEN
);
2288 subpixel_order
= SubPixelHorizontalRGB
;
2289 connector
->interlace_allowed
= false;
2290 connector
->doublescan_allowed
= false;
2292 case DRM_MODE_CONNECTOR_SVIDEO
:
2293 case DRM_MODE_CONNECTOR_Composite
:
2294 case DRM_MODE_CONNECTOR_9PinDIN
:
2295 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
2296 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
2297 radeon_connector
->dac_load_detect
= true;
2298 drm_object_attach_property(&radeon_connector
->base
.base
,
2299 rdev
->mode_info
.load_detect_property
,
2301 drm_object_attach_property(&radeon_connector
->base
.base
,
2302 rdev
->mode_info
.tv_std_property
,
2303 radeon_atombios_get_tv_info(rdev
));
2304 /* no HPD on analog connectors */
2305 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2306 connector
->interlace_allowed
= false;
2307 connector
->doublescan_allowed
= false;
2309 case DRM_MODE_CONNECTOR_LVDS
:
2310 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
2311 if (!radeon_dig_connector
)
2313 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
2314 radeon_connector
->con_priv
= radeon_dig_connector
;
2315 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
2316 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
2317 if (i2c_bus
->valid
) {
2318 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2319 if (!radeon_connector
->ddc_bus
)
2320 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2322 drm_object_attach_property(&radeon_connector
->base
.base
,
2323 dev
->mode_config
.scaling_mode_property
,
2324 DRM_MODE_SCALE_FULLSCREEN
);
2325 subpixel_order
= SubPixelHorizontalRGB
;
2326 connector
->interlace_allowed
= false;
2327 connector
->doublescan_allowed
= false;
2332 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
2333 if (i2c_bus
->valid
) {
2334 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
|
2335 DRM_CONNECTOR_POLL_DISCONNECT
;
2338 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
2340 connector
->display_info
.subpixel_order
= subpixel_order
;
2341 drm_connector_register(connector
);
2344 radeon_dp_aux_init(radeon_connector
);
2349 drm_connector_cleanup(connector
);
2354 radeon_add_legacy_connector(struct drm_device
*dev
,
2355 uint32_t connector_id
,
2356 uint32_t supported_device
,
2358 struct radeon_i2c_bus_rec
*i2c_bus
,
2359 uint16_t connector_object_id
,
2360 struct radeon_hpd
*hpd
)
2362 struct radeon_device
*rdev
= dev
->dev_private
;
2363 struct drm_connector
*connector
;
2364 struct radeon_connector
*radeon_connector
;
2365 uint32_t subpixel_order
= SubPixelNone
;
2367 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
2370 /* if the user selected tv=0 don't try and add the connector */
2371 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
2372 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
2373 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
2377 /* see if we already added it */
2378 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
2379 radeon_connector
= to_radeon_connector(connector
);
2380 if (radeon_connector
->connector_id
== connector_id
) {
2381 radeon_connector
->devices
|= supported_device
;
2386 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
2387 if (!radeon_connector
)
2390 connector
= &radeon_connector
->base
;
2392 radeon_connector
->connector_id
= connector_id
;
2393 radeon_connector
->devices
= supported_device
;
2394 radeon_connector
->connector_object_id
= connector_object_id
;
2395 radeon_connector
->hpd
= *hpd
;
2397 switch (connector_type
) {
2398 case DRM_MODE_CONNECTOR_VGA
:
2399 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
2400 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
2401 if (i2c_bus
->valid
) {
2402 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2403 if (!radeon_connector
->ddc_bus
)
2404 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2406 radeon_connector
->dac_load_detect
= true;
2407 drm_object_attach_property(&radeon_connector
->base
.base
,
2408 rdev
->mode_info
.load_detect_property
,
2410 /* no HPD on analog connectors */
2411 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2412 connector
->interlace_allowed
= true;
2413 connector
->doublescan_allowed
= true;
2415 case DRM_MODE_CONNECTOR_DVIA
:
2416 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
2417 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
2418 if (i2c_bus
->valid
) {
2419 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2420 if (!radeon_connector
->ddc_bus
)
2421 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2423 radeon_connector
->dac_load_detect
= true;
2424 drm_object_attach_property(&radeon_connector
->base
.base
,
2425 rdev
->mode_info
.load_detect_property
,
2427 /* no HPD on analog connectors */
2428 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2429 connector
->interlace_allowed
= true;
2430 connector
->doublescan_allowed
= true;
2432 case DRM_MODE_CONNECTOR_DVII
:
2433 case DRM_MODE_CONNECTOR_DVID
:
2434 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
2435 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
2436 if (i2c_bus
->valid
) {
2437 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2438 if (!radeon_connector
->ddc_bus
)
2439 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2441 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
2442 radeon_connector
->dac_load_detect
= true;
2443 drm_object_attach_property(&radeon_connector
->base
.base
,
2444 rdev
->mode_info
.load_detect_property
,
2447 subpixel_order
= SubPixelHorizontalRGB
;
2448 connector
->interlace_allowed
= true;
2449 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
2450 connector
->doublescan_allowed
= true;
2452 connector
->doublescan_allowed
= false;
2454 case DRM_MODE_CONNECTOR_SVIDEO
:
2455 case DRM_MODE_CONNECTOR_Composite
:
2456 case DRM_MODE_CONNECTOR_9PinDIN
:
2457 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
2458 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
2459 radeon_connector
->dac_load_detect
= true;
2460 /* RS400,RC410,RS480 chipset seems to report a lot
2461 * of false positive on load detect, we haven't yet
2462 * found a way to make load detect reliable on those
2463 * chipset, thus just disable it for TV.
2465 if (rdev
->family
== CHIP_RS400
|| rdev
->family
== CHIP_RS480
)
2466 radeon_connector
->dac_load_detect
= false;
2467 drm_object_attach_property(&radeon_connector
->base
.base
,
2468 rdev
->mode_info
.load_detect_property
,
2469 radeon_connector
->dac_load_detect
);
2470 drm_object_attach_property(&radeon_connector
->base
.base
,
2471 rdev
->mode_info
.tv_std_property
,
2472 radeon_combios_get_tv_info(rdev
));
2473 /* no HPD on analog connectors */
2474 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2475 connector
->interlace_allowed
= false;
2476 connector
->doublescan_allowed
= false;
2478 case DRM_MODE_CONNECTOR_LVDS
:
2479 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
2480 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
2481 if (i2c_bus
->valid
) {
2482 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2483 if (!radeon_connector
->ddc_bus
)
2484 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2486 drm_object_attach_property(&radeon_connector
->base
.base
,
2487 dev
->mode_config
.scaling_mode_property
,
2488 DRM_MODE_SCALE_FULLSCREEN
);
2489 subpixel_order
= SubPixelHorizontalRGB
;
2490 connector
->interlace_allowed
= false;
2491 connector
->doublescan_allowed
= false;
2495 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
2496 if (i2c_bus
->valid
) {
2497 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
|
2498 DRM_CONNECTOR_POLL_DISCONNECT
;
2501 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
2503 connector
->display_info
.subpixel_order
= subpixel_order
;
2504 drm_connector_register(connector
);
2507 void radeon_setup_mst_connector(struct drm_device
*dev
)
2509 struct radeon_device
*rdev
= dev
->dev_private
;
2510 struct drm_connector
*connector
;
2511 struct radeon_connector
*radeon_connector
;
2513 if (!ASIC_IS_DCE5(rdev
))
2516 if (radeon_mst
== 0)
2519 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
2522 radeon_connector
= to_radeon_connector(connector
);
2524 if (connector
->connector_type
!= DRM_MODE_CONNECTOR_DisplayPort
)
2527 ret
= radeon_dp_mst_init(radeon_connector
);