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
, NULL
,
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
, NULL
, 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
);
397 drm_mode_connector_update_edid_property(connector
, NULL
);
401 static struct drm_encoder
*radeon_best_single_encoder(struct drm_connector
*connector
)
403 int enc_id
= connector
->encoder_ids
[0];
404 /* pick the encoder ids */
406 return drm_encoder_find(connector
->dev
, NULL
, enc_id
);
410 static void radeon_get_native_mode(struct drm_connector
*connector
)
412 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
413 struct radeon_encoder
*radeon_encoder
;
418 radeon_encoder
= to_radeon_encoder(encoder
);
420 if (!list_empty(&connector
->probed_modes
)) {
421 struct drm_display_mode
*preferred_mode
=
422 list_first_entry(&connector
->probed_modes
,
423 struct drm_display_mode
, head
);
425 radeon_encoder
->native_mode
= *preferred_mode
;
427 radeon_encoder
->native_mode
.clock
= 0;
432 * radeon_connector_analog_encoder_conflict_solve
433 * - search for other connectors sharing this encoder
434 * if priority is true, then set them disconnected if this is connected
435 * if priority is false, set us disconnected if they are connected
437 static enum drm_connector_status
438 radeon_connector_analog_encoder_conflict_solve(struct drm_connector
*connector
,
439 struct drm_encoder
*encoder
,
440 enum drm_connector_status current_status
,
443 struct drm_device
*dev
= connector
->dev
;
444 struct drm_connector
*conflict
;
445 struct radeon_connector
*radeon_conflict
;
448 list_for_each_entry(conflict
, &dev
->mode_config
.connector_list
, head
) {
449 if (conflict
== connector
)
452 radeon_conflict
= to_radeon_connector(conflict
);
453 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
454 if (conflict
->encoder_ids
[i
] == 0)
457 /* if the IDs match */
458 if (conflict
->encoder_ids
[i
] == encoder
->base
.id
) {
459 if (conflict
->status
!= connector_status_connected
)
462 if (radeon_conflict
->use_digital
)
465 if (priority
== true) {
466 DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n",
468 DRM_DEBUG_KMS("in favor of %s\n",
470 conflict
->status
= connector_status_disconnected
;
471 radeon_connector_update_scratch_regs(conflict
, connector_status_disconnected
);
473 DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n",
475 DRM_DEBUG_KMS("in favor of %s\n",
477 current_status
= connector_status_disconnected
;
483 return current_status
;
487 static struct drm_display_mode
*radeon_fp_native_mode(struct drm_encoder
*encoder
)
489 struct drm_device
*dev
= encoder
->dev
;
490 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
491 struct drm_display_mode
*mode
= NULL
;
492 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
494 if (native_mode
->hdisplay
!= 0 &&
495 native_mode
->vdisplay
!= 0 &&
496 native_mode
->clock
!= 0) {
497 mode
= drm_mode_duplicate(dev
, native_mode
);
498 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
499 drm_mode_set_name(mode
);
501 DRM_DEBUG_KMS("Adding native panel mode %s\n", mode
->name
);
502 } else if (native_mode
->hdisplay
!= 0 &&
503 native_mode
->vdisplay
!= 0) {
504 /* mac laptops without an edid */
505 /* Note that this is not necessarily the exact panel mode,
506 * but an approximation based on the cvt formula. For these
507 * systems we should ideally read the mode info out of the
508 * registers or add a mode table, but this works and is much
511 mode
= drm_cvt_mode(dev
, native_mode
->hdisplay
, native_mode
->vdisplay
, 60, true, false, false);
512 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
513 DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode
->name
);
518 static void radeon_add_common_modes(struct drm_encoder
*encoder
, struct drm_connector
*connector
)
520 struct drm_device
*dev
= encoder
->dev
;
521 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
522 struct drm_display_mode
*mode
= NULL
;
523 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
528 } common_modes
[17] = {
548 for (i
= 0; i
< 17; i
++) {
549 if (radeon_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
)) {
550 if (common_modes
[i
].w
> 1024 ||
551 common_modes
[i
].h
> 768)
554 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
555 if (common_modes
[i
].w
> native_mode
->hdisplay
||
556 common_modes
[i
].h
> native_mode
->vdisplay
||
557 (common_modes
[i
].w
== native_mode
->hdisplay
&&
558 common_modes
[i
].h
== native_mode
->vdisplay
))
561 if (common_modes
[i
].w
< 320 || common_modes
[i
].h
< 200)
564 mode
= drm_cvt_mode(dev
, common_modes
[i
].w
, common_modes
[i
].h
, 60, false, false, false);
565 drm_mode_probed_add(connector
, mode
);
569 static int radeon_connector_set_property(struct drm_connector
*connector
, struct drm_property
*property
,
572 struct drm_device
*dev
= connector
->dev
;
573 struct radeon_device
*rdev
= dev
->dev_private
;
574 struct drm_encoder
*encoder
;
575 struct radeon_encoder
*radeon_encoder
;
577 if (property
== rdev
->mode_info
.coherent_mode_property
) {
578 struct radeon_encoder_atom_dig
*dig
;
579 bool new_coherent_mode
;
581 /* need to find digital encoder on connector */
582 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
586 radeon_encoder
= to_radeon_encoder(encoder
);
588 if (!radeon_encoder
->enc_priv
)
591 dig
= radeon_encoder
->enc_priv
;
592 new_coherent_mode
= val
? true : false;
593 if (dig
->coherent_mode
!= new_coherent_mode
) {
594 dig
->coherent_mode
= new_coherent_mode
;
595 radeon_property_change_mode(&radeon_encoder
->base
);
599 if (property
== rdev
->mode_info
.audio_property
) {
600 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
601 /* need to find digital encoder on connector */
602 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
606 radeon_encoder
= to_radeon_encoder(encoder
);
608 if (radeon_connector
->audio
!= val
) {
609 radeon_connector
->audio
= val
;
610 radeon_property_change_mode(&radeon_encoder
->base
);
614 if (property
== rdev
->mode_info
.dither_property
) {
615 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
616 /* need to find digital encoder on connector */
617 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
621 radeon_encoder
= to_radeon_encoder(encoder
);
623 if (radeon_connector
->dither
!= val
) {
624 radeon_connector
->dither
= val
;
625 radeon_property_change_mode(&radeon_encoder
->base
);
629 if (property
== rdev
->mode_info
.underscan_property
) {
630 /* need to find digital encoder on connector */
631 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
635 radeon_encoder
= to_radeon_encoder(encoder
);
637 if (radeon_encoder
->underscan_type
!= val
) {
638 radeon_encoder
->underscan_type
= val
;
639 radeon_property_change_mode(&radeon_encoder
->base
);
643 if (property
== rdev
->mode_info
.underscan_hborder_property
) {
644 /* need to find digital encoder on connector */
645 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
649 radeon_encoder
= to_radeon_encoder(encoder
);
651 if (radeon_encoder
->underscan_hborder
!= val
) {
652 radeon_encoder
->underscan_hborder
= val
;
653 radeon_property_change_mode(&radeon_encoder
->base
);
657 if (property
== rdev
->mode_info
.underscan_vborder_property
) {
658 /* need to find digital encoder on connector */
659 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
663 radeon_encoder
= to_radeon_encoder(encoder
);
665 if (radeon_encoder
->underscan_vborder
!= val
) {
666 radeon_encoder
->underscan_vborder
= val
;
667 radeon_property_change_mode(&radeon_encoder
->base
);
671 if (property
== rdev
->mode_info
.tv_std_property
) {
672 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TVDAC
);
674 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_DAC
);
680 radeon_encoder
= to_radeon_encoder(encoder
);
681 if (!radeon_encoder
->enc_priv
)
683 if (ASIC_IS_AVIVO(rdev
) || radeon_r4xx_atom
) {
684 struct radeon_encoder_atom_dac
*dac_int
;
685 dac_int
= radeon_encoder
->enc_priv
;
686 dac_int
->tv_std
= val
;
688 struct radeon_encoder_tv_dac
*dac_int
;
689 dac_int
= radeon_encoder
->enc_priv
;
690 dac_int
->tv_std
= val
;
692 radeon_property_change_mode(&radeon_encoder
->base
);
695 if (property
== rdev
->mode_info
.load_detect_property
) {
696 struct radeon_connector
*radeon_connector
=
697 to_radeon_connector(connector
);
700 radeon_connector
->dac_load_detect
= false;
702 radeon_connector
->dac_load_detect
= true;
705 if (property
== rdev
->mode_info
.tmds_pll_property
) {
706 struct radeon_encoder_int_tmds
*tmds
= NULL
;
708 /* need to find digital encoder on connector */
709 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
713 radeon_encoder
= to_radeon_encoder(encoder
);
715 tmds
= radeon_encoder
->enc_priv
;
720 if (rdev
->is_atom_bios
)
721 ret
= radeon_atombios_get_tmds_info(radeon_encoder
, tmds
);
723 ret
= radeon_legacy_get_tmds_info_from_combios(radeon_encoder
, tmds
);
725 if (val
== 1 || ret
== false) {
726 radeon_legacy_get_tmds_info_from_table(radeon_encoder
, tmds
);
728 radeon_property_change_mode(&radeon_encoder
->base
);
731 if (property
== dev
->mode_config
.scaling_mode_property
) {
732 enum radeon_rmx_type rmx_type
;
734 if (connector
->encoder
)
735 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
737 const struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
738 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
743 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
744 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
745 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
746 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
748 if (radeon_encoder
->rmx_type
== rmx_type
)
751 if ((rmx_type
!= DRM_MODE_SCALE_NONE
) &&
752 (radeon_encoder
->native_mode
.clock
== 0))
755 radeon_encoder
->rmx_type
= rmx_type
;
757 radeon_property_change_mode(&radeon_encoder
->base
);
760 if (property
== rdev
->mode_info
.output_csc_property
) {
761 if (connector
->encoder
)
762 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
764 const struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
765 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
768 if (radeon_encoder
->output_csc
== val
)
771 radeon_encoder
->output_csc
= val
;
773 if (connector
->encoder
->crtc
) {
774 struct drm_crtc
*crtc
= connector
->encoder
->crtc
;
775 struct radeon_crtc
*radeon_crtc
= to_radeon_crtc(crtc
);
777 radeon_crtc
->output_csc
= radeon_encoder
->output_csc
;
780 * Our .gamma_set assumes the .gamma_store has been
781 * prefilled and don't care about its arguments.
783 crtc
->funcs
->gamma_set(crtc
, NULL
, NULL
, NULL
, 0, NULL
);
790 static void radeon_fixup_lvds_native_mode(struct drm_encoder
*encoder
,
791 struct drm_connector
*connector
)
793 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
794 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
795 struct drm_display_mode
*t
, *mode
;
797 /* If the EDID preferred mode doesn't match the native mode, use it */
798 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
799 if (mode
->type
& DRM_MODE_TYPE_PREFERRED
) {
800 if (mode
->hdisplay
!= native_mode
->hdisplay
||
801 mode
->vdisplay
!= native_mode
->vdisplay
)
802 memcpy(native_mode
, mode
, sizeof(*mode
));
806 /* Try to get native mode details from EDID if necessary */
807 if (!native_mode
->clock
) {
808 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
809 if (mode
->hdisplay
== native_mode
->hdisplay
&&
810 mode
->vdisplay
== native_mode
->vdisplay
) {
811 *native_mode
= *mode
;
812 drm_mode_set_crtcinfo(native_mode
, CRTC_INTERLACE_HALVE_V
);
813 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
819 if (!native_mode
->clock
) {
820 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n");
821 radeon_encoder
->rmx_type
= RMX_OFF
;
825 static int radeon_lvds_get_modes(struct drm_connector
*connector
)
827 struct drm_encoder
*encoder
;
829 struct drm_display_mode
*mode
;
831 radeon_connector_get_edid(connector
);
832 ret
= radeon_ddc_get_modes(connector
);
834 encoder
= radeon_best_single_encoder(connector
);
836 radeon_fixup_lvds_native_mode(encoder
, connector
);
837 /* add scaled modes */
838 radeon_add_common_modes(encoder
, connector
);
843 encoder
= radeon_best_single_encoder(connector
);
847 /* we have no EDID modes */
848 mode
= radeon_fp_native_mode(encoder
);
851 drm_mode_probed_add(connector
, mode
);
852 /* add the width/height from vbios tables if available */
853 connector
->display_info
.width_mm
= mode
->width_mm
;
854 connector
->display_info
.height_mm
= mode
->height_mm
;
855 /* add scaled modes */
856 radeon_add_common_modes(encoder
, connector
);
862 static int radeon_lvds_mode_valid(struct drm_connector
*connector
,
863 struct drm_display_mode
*mode
)
865 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
867 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
871 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
872 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
874 /* AVIVO hardware supports downscaling modes larger than the panel
875 * to the panel size, but I'm not sure this is desirable.
877 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
878 (mode
->vdisplay
> native_mode
->vdisplay
))
881 /* if scaling is disabled, block non-native modes */
882 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
883 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
884 (mode
->vdisplay
!= native_mode
->vdisplay
))
892 static enum drm_connector_status
893 radeon_lvds_detect(struct drm_connector
*connector
, bool force
)
895 struct drm_device
*dev
= connector
->dev
;
896 struct radeon_device
*rdev
= dev
->dev_private
;
897 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
898 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
899 enum drm_connector_status ret
= connector_status_disconnected
;
902 if (!drm_kms_helper_is_poll_worker()) {
903 r
= pm_runtime_get_sync(connector
->dev
->dev
);
905 return connector_status_disconnected
;
909 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
910 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
912 /* check if panel is valid */
913 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
914 ret
= connector_status_connected
;
915 /* don't fetch the edid from the vbios if ddc fails and runpm is
916 * enabled so we report disconnected.
918 if ((rdev
->flags
& RADEON_IS_PX
) && (radeon_runtime_pm
!= 0))
919 ret
= connector_status_disconnected
;
922 /* check for edid as well */
923 radeon_connector_get_edid(connector
);
924 if (radeon_connector
->edid
)
925 ret
= connector_status_connected
;
926 /* check acpi lid status ??? */
928 radeon_connector_update_scratch_regs(connector
, ret
);
930 if (!drm_kms_helper_is_poll_worker()) {
931 pm_runtime_mark_last_busy(connector
->dev
->dev
);
932 pm_runtime_put_autosuspend(connector
->dev
->dev
);
938 static void radeon_connector_unregister(struct drm_connector
*connector
)
940 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
942 if (radeon_connector
->ddc_bus
&& radeon_connector
->ddc_bus
->has_aux
) {
943 drm_dp_aux_unregister(&radeon_connector
->ddc_bus
->aux
);
944 radeon_connector
->ddc_bus
->has_aux
= false;
948 static void radeon_connector_destroy(struct drm_connector
*connector
)
950 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
952 radeon_connector_free_edid(connector
);
953 kfree(radeon_connector
->con_priv
);
954 drm_connector_unregister(connector
);
955 drm_connector_cleanup(connector
);
959 static int radeon_lvds_set_property(struct drm_connector
*connector
,
960 struct drm_property
*property
,
963 struct drm_device
*dev
= connector
->dev
;
964 struct radeon_encoder
*radeon_encoder
;
965 enum radeon_rmx_type rmx_type
;
968 if (property
!= dev
->mode_config
.scaling_mode_property
)
971 if (connector
->encoder
)
972 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
974 const struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
975 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
979 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
980 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
981 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
983 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
985 if (radeon_encoder
->rmx_type
== rmx_type
)
988 radeon_encoder
->rmx_type
= rmx_type
;
990 radeon_property_change_mode(&radeon_encoder
->base
);
995 static const struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs
= {
996 .get_modes
= radeon_lvds_get_modes
,
997 .mode_valid
= radeon_lvds_mode_valid
,
998 .best_encoder
= radeon_best_single_encoder
,
1001 static const struct drm_connector_funcs radeon_lvds_connector_funcs
= {
1002 .dpms
= drm_helper_connector_dpms
,
1003 .detect
= radeon_lvds_detect
,
1004 .fill_modes
= drm_helper_probe_single_connector_modes
,
1005 .early_unregister
= radeon_connector_unregister
,
1006 .destroy
= radeon_connector_destroy
,
1007 .set_property
= radeon_lvds_set_property
,
1010 static int radeon_vga_get_modes(struct drm_connector
*connector
)
1014 radeon_connector_get_edid(connector
);
1015 ret
= radeon_ddc_get_modes(connector
);
1017 radeon_get_native_mode(connector
);
1022 static int radeon_vga_mode_valid(struct drm_connector
*connector
,
1023 struct drm_display_mode
*mode
)
1025 struct drm_device
*dev
= connector
->dev
;
1026 struct radeon_device
*rdev
= dev
->dev_private
;
1028 /* XXX check mode bandwidth */
1030 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
1031 return MODE_CLOCK_HIGH
;
1036 static enum drm_connector_status
1037 radeon_vga_detect(struct drm_connector
*connector
, bool force
)
1039 struct drm_device
*dev
= connector
->dev
;
1040 struct radeon_device
*rdev
= dev
->dev_private
;
1041 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1042 struct drm_encoder
*encoder
;
1043 const struct drm_encoder_helper_funcs
*encoder_funcs
;
1045 enum drm_connector_status ret
= connector_status_disconnected
;
1048 if (!drm_kms_helper_is_poll_worker()) {
1049 r
= pm_runtime_get_sync(connector
->dev
->dev
);
1051 return connector_status_disconnected
;
1054 encoder
= radeon_best_single_encoder(connector
);
1056 ret
= connector_status_disconnected
;
1058 if (radeon_connector
->ddc_bus
)
1059 dret
= radeon_ddc_probe(radeon_connector
, false);
1061 radeon_connector
->detected_by_load
= false;
1062 radeon_connector_free_edid(connector
);
1063 radeon_connector_get_edid(connector
);
1065 if (!radeon_connector
->edid
) {
1066 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
1068 ret
= connector_status_connected
;
1070 radeon_connector
->use_digital
=
1071 !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
1073 /* some oems have boards with separate digital and analog connectors
1074 * with a shared ddc line (often vga + hdmi)
1076 if (radeon_connector
->use_digital
&& radeon_connector
->shared_ddc
) {
1077 radeon_connector_free_edid(connector
);
1078 ret
= connector_status_disconnected
;
1080 ret
= connector_status_connected
;
1085 /* if we aren't forcing don't do destructive polling */
1087 /* only return the previous status if we last
1088 * detected a monitor via load.
1090 if (radeon_connector
->detected_by_load
)
1091 ret
= connector
->status
;
1095 if (radeon_connector
->dac_load_detect
&& encoder
) {
1096 encoder_funcs
= encoder
->helper_private
;
1097 ret
= encoder_funcs
->detect(encoder
, connector
);
1098 if (ret
!= connector_status_disconnected
)
1099 radeon_connector
->detected_by_load
= true;
1103 if (ret
== connector_status_connected
)
1104 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
1106 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
1107 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
1108 * by other means, assume the CRT is connected and use that EDID.
1110 if ((!rdev
->is_atom_bios
) &&
1111 (ret
== connector_status_disconnected
) &&
1112 rdev
->mode_info
.bios_hardcoded_edid_size
) {
1113 ret
= connector_status_connected
;
1116 radeon_connector_update_scratch_regs(connector
, ret
);
1119 if (!drm_kms_helper_is_poll_worker()) {
1120 pm_runtime_mark_last_busy(connector
->dev
->dev
);
1121 pm_runtime_put_autosuspend(connector
->dev
->dev
);
1127 static const struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs
= {
1128 .get_modes
= radeon_vga_get_modes
,
1129 .mode_valid
= radeon_vga_mode_valid
,
1130 .best_encoder
= radeon_best_single_encoder
,
1133 static const struct drm_connector_funcs radeon_vga_connector_funcs
= {
1134 .dpms
= drm_helper_connector_dpms
,
1135 .detect
= radeon_vga_detect
,
1136 .fill_modes
= drm_helper_probe_single_connector_modes
,
1137 .early_unregister
= radeon_connector_unregister
,
1138 .destroy
= radeon_connector_destroy
,
1139 .set_property
= radeon_connector_set_property
,
1142 static int radeon_tv_get_modes(struct drm_connector
*connector
)
1144 struct drm_device
*dev
= connector
->dev
;
1145 struct radeon_device
*rdev
= dev
->dev_private
;
1146 struct drm_display_mode
*tv_mode
;
1147 struct drm_encoder
*encoder
;
1149 encoder
= radeon_best_single_encoder(connector
);
1153 /* avivo chips can scale any mode */
1154 if (rdev
->family
>= CHIP_RS600
)
1155 /* add scaled modes */
1156 radeon_add_common_modes(encoder
, connector
);
1158 /* only 800x600 is supported right now on pre-avivo chips */
1159 tv_mode
= drm_cvt_mode(dev
, 800, 600, 60, false, false, false);
1160 tv_mode
->type
= DRM_MODE_TYPE_DRIVER
| DRM_MODE_TYPE_PREFERRED
;
1161 drm_mode_probed_add(connector
, tv_mode
);
1166 static int radeon_tv_mode_valid(struct drm_connector
*connector
,
1167 struct drm_display_mode
*mode
)
1169 if ((mode
->hdisplay
> 1024) || (mode
->vdisplay
> 768))
1170 return MODE_CLOCK_RANGE
;
1174 static enum drm_connector_status
1175 radeon_tv_detect(struct drm_connector
*connector
, bool force
)
1177 struct drm_encoder
*encoder
;
1178 const struct drm_encoder_helper_funcs
*encoder_funcs
;
1179 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1180 enum drm_connector_status ret
= connector_status_disconnected
;
1183 if (!radeon_connector
->dac_load_detect
)
1186 if (!drm_kms_helper_is_poll_worker()) {
1187 r
= pm_runtime_get_sync(connector
->dev
->dev
);
1189 return connector_status_disconnected
;
1192 encoder
= radeon_best_single_encoder(connector
);
1194 ret
= connector_status_disconnected
;
1196 encoder_funcs
= encoder
->helper_private
;
1197 ret
= encoder_funcs
->detect(encoder
, connector
);
1199 if (ret
== connector_status_connected
)
1200 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, false);
1201 radeon_connector_update_scratch_regs(connector
, ret
);
1203 if (!drm_kms_helper_is_poll_worker()) {
1204 pm_runtime_mark_last_busy(connector
->dev
->dev
);
1205 pm_runtime_put_autosuspend(connector
->dev
->dev
);
1211 static const struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs
= {
1212 .get_modes
= radeon_tv_get_modes
,
1213 .mode_valid
= radeon_tv_mode_valid
,
1214 .best_encoder
= radeon_best_single_encoder
,
1217 static const struct drm_connector_funcs radeon_tv_connector_funcs
= {
1218 .dpms
= drm_helper_connector_dpms
,
1219 .detect
= radeon_tv_detect
,
1220 .fill_modes
= drm_helper_probe_single_connector_modes
,
1221 .early_unregister
= radeon_connector_unregister
,
1222 .destroy
= radeon_connector_destroy
,
1223 .set_property
= radeon_connector_set_property
,
1226 static bool radeon_check_hpd_status_unchanged(struct drm_connector
*connector
)
1228 struct drm_device
*dev
= connector
->dev
;
1229 struct radeon_device
*rdev
= dev
->dev_private
;
1230 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1231 enum drm_connector_status status
;
1233 /* We only trust HPD on R600 and newer ASICS. */
1234 if (rdev
->family
>= CHIP_R600
1235 && radeon_connector
->hpd
.hpd
!= RADEON_HPD_NONE
) {
1236 if (radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
))
1237 status
= connector_status_connected
;
1239 status
= connector_status_disconnected
;
1240 if (connector
->status
== status
)
1248 * DVI is complicated
1249 * Do a DDC probe, if DDC probe passes, get the full EDID so
1250 * we can do analog/digital monitor detection at this point.
1251 * If the monitor is an analog monitor or we got no DDC,
1252 * we need to find the DAC encoder object for this connector.
1253 * If we got no DDC, we do load detection on the DAC encoder object.
1254 * If we got analog DDC or load detection passes on the DAC encoder
1255 * we have to check if this analog encoder is shared with anyone else (TV)
1256 * if its shared we have to set the other connector to disconnected.
1258 static enum drm_connector_status
1259 radeon_dvi_detect(struct drm_connector
*connector
, bool force
)
1261 struct drm_device
*dev
= connector
->dev
;
1262 struct radeon_device
*rdev
= dev
->dev_private
;
1263 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1264 struct drm_encoder
*encoder
= NULL
;
1265 const struct drm_encoder_helper_funcs
*encoder_funcs
;
1267 enum drm_connector_status ret
= connector_status_disconnected
;
1268 bool dret
= false, broken_edid
= false;
1270 if (!drm_kms_helper_is_poll_worker()) {
1271 r
= pm_runtime_get_sync(connector
->dev
->dev
);
1273 return connector_status_disconnected
;
1276 if (radeon_connector
->detected_hpd_without_ddc
) {
1278 radeon_connector
->detected_hpd_without_ddc
= false;
1281 if (!force
&& radeon_check_hpd_status_unchanged(connector
)) {
1282 ret
= connector
->status
;
1286 if (radeon_connector
->ddc_bus
) {
1287 dret
= radeon_ddc_probe(radeon_connector
, false);
1289 /* Sometimes the pins required for the DDC probe on DVI
1290 * connectors don't make contact at the same time that the ones
1291 * for HPD do. If the DDC probe fails even though we had an HPD
1292 * signal, try again later */
1293 if (!dret
&& !force
&&
1294 connector
->status
!= connector_status_connected
) {
1295 DRM_DEBUG_KMS("hpd detected without ddc, retrying in 1 second\n");
1296 radeon_connector
->detected_hpd_without_ddc
= true;
1297 schedule_delayed_work(&rdev
->hotplug_work
,
1298 msecs_to_jiffies(1000));
1303 radeon_connector
->detected_by_load
= false;
1304 radeon_connector_free_edid(connector
);
1305 radeon_connector_get_edid(connector
);
1307 if (!radeon_connector
->edid
) {
1308 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
1310 /* rs690 seems to have a problem with connectors not existing and always
1311 * return a block of 0's. If we see this just stop polling on this output */
1312 if ((rdev
->family
== CHIP_RS690
|| rdev
->family
== CHIP_RS740
) &&
1313 radeon_connector
->base
.null_edid_counter
) {
1314 ret
= connector_status_disconnected
;
1315 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n",
1317 radeon_connector
->ddc_bus
= NULL
;
1319 ret
= connector_status_connected
;
1320 broken_edid
= true; /* defer use_digital to later */
1323 radeon_connector
->use_digital
=
1324 !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
1326 /* some oems have boards with separate digital and analog connectors
1327 * with a shared ddc line (often vga + hdmi)
1329 if ((!radeon_connector
->use_digital
) && radeon_connector
->shared_ddc
) {
1330 radeon_connector_free_edid(connector
);
1331 ret
= connector_status_disconnected
;
1333 ret
= connector_status_connected
;
1335 /* This gets complicated. We have boards with VGA + HDMI with a
1336 * shared DDC line and we have boards with DVI-D + HDMI with a shared
1337 * DDC line. The latter is more complex because with DVI<->HDMI adapters
1338 * you don't really know what's connected to which port as both are digital.
1340 if (radeon_connector
->shared_ddc
&& (ret
== connector_status_connected
)) {
1341 struct drm_connector
*list_connector
;
1342 struct radeon_connector
*list_radeon_connector
;
1343 list_for_each_entry(list_connector
, &dev
->mode_config
.connector_list
, head
) {
1344 if (connector
== list_connector
)
1346 list_radeon_connector
= to_radeon_connector(list_connector
);
1347 if (list_radeon_connector
->shared_ddc
&&
1348 (list_radeon_connector
->ddc_bus
->rec
.i2c_id
==
1349 radeon_connector
->ddc_bus
->rec
.i2c_id
)) {
1350 /* cases where both connectors are digital */
1351 if (list_connector
->connector_type
!= DRM_MODE_CONNECTOR_VGA
) {
1352 /* hpd is our only option in this case */
1353 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
1354 radeon_connector_free_edid(connector
);
1355 ret
= connector_status_disconnected
;
1364 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== true))
1367 /* DVI-D and HDMI-A are digital only */
1368 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_DVID
) ||
1369 (connector
->connector_type
== DRM_MODE_CONNECTOR_HDMIA
))
1372 /* if we aren't forcing don't do destructive polling */
1374 /* only return the previous status if we last
1375 * detected a monitor via load.
1377 if (radeon_connector
->detected_by_load
)
1378 ret
= connector
->status
;
1382 /* find analog encoder */
1383 if (radeon_connector
->dac_load_detect
) {
1384 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1385 if (connector
->encoder_ids
[i
] == 0)
1388 encoder
= drm_encoder_find(connector
->dev
, NULL
,
1389 connector
->encoder_ids
[i
]);
1393 if (encoder
->encoder_type
!= DRM_MODE_ENCODER_DAC
&&
1394 encoder
->encoder_type
!= DRM_MODE_ENCODER_TVDAC
)
1397 encoder_funcs
= encoder
->helper_private
;
1398 if (encoder_funcs
->detect
) {
1400 if (ret
!= connector_status_connected
) {
1401 /* deal with analog monitors without DDC */
1402 ret
= encoder_funcs
->detect(encoder
, connector
);
1403 if (ret
== connector_status_connected
) {
1404 radeon_connector
->use_digital
= false;
1406 if (ret
!= connector_status_disconnected
)
1407 radeon_connector
->detected_by_load
= true;
1410 enum drm_connector_status lret
;
1411 /* assume digital unless load detected otherwise */
1412 radeon_connector
->use_digital
= true;
1413 lret
= encoder_funcs
->detect(encoder
, connector
);
1414 DRM_DEBUG_KMS("load_detect %x returned: %x\n",encoder
->encoder_type
,lret
);
1415 if (lret
== connector_status_connected
)
1416 radeon_connector
->use_digital
= false;
1423 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== false) &&
1425 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
1428 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
1429 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
1430 * by other means, assume the DFP is connected and use that EDID. In most
1431 * cases the DVI port is actually a virtual KVM port connected to the service
1435 if ((!rdev
->is_atom_bios
) &&
1436 (ret
== connector_status_disconnected
) &&
1437 rdev
->mode_info
.bios_hardcoded_edid_size
) {
1438 radeon_connector
->use_digital
= true;
1439 ret
= connector_status_connected
;
1442 /* updated in get modes as well since we need to know if it's analog or digital */
1443 radeon_connector_update_scratch_regs(connector
, ret
);
1445 if ((radeon_audio
!= 0) && radeon_connector
->use_digital
) {
1446 const struct drm_connector_helper_funcs
*connector_funcs
=
1447 connector
->helper_private
;
1449 encoder
= connector_funcs
->best_encoder(connector
);
1450 if (encoder
&& (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)) {
1451 radeon_connector_get_edid(connector
);
1452 radeon_audio_detect(connector
, encoder
, ret
);
1457 if (!drm_kms_helper_is_poll_worker()) {
1458 pm_runtime_mark_last_busy(connector
->dev
->dev
);
1459 pm_runtime_put_autosuspend(connector
->dev
->dev
);
1465 /* okay need to be smart in here about which encoder to pick */
1466 static struct drm_encoder
*radeon_dvi_encoder(struct drm_connector
*connector
)
1468 int enc_id
= connector
->encoder_ids
[0];
1469 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1470 struct drm_encoder
*encoder
;
1472 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1473 if (connector
->encoder_ids
[i
] == 0)
1476 encoder
= drm_encoder_find(connector
->dev
, NULL
, connector
->encoder_ids
[i
]);
1480 if (radeon_connector
->use_digital
== true) {
1481 if (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)
1484 if (encoder
->encoder_type
== DRM_MODE_ENCODER_DAC
||
1485 encoder
->encoder_type
== DRM_MODE_ENCODER_TVDAC
)
1490 /* see if we have a default encoder TODO */
1492 /* then check use digitial */
1493 /* pick the first one */
1495 return drm_encoder_find(connector
->dev
, NULL
, enc_id
);
1499 static void radeon_dvi_force(struct drm_connector
*connector
)
1501 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1502 if (connector
->force
== DRM_FORCE_ON
)
1503 radeon_connector
->use_digital
= false;
1504 if (connector
->force
== DRM_FORCE_ON_DIGITAL
)
1505 radeon_connector
->use_digital
= true;
1508 static int radeon_dvi_mode_valid(struct drm_connector
*connector
,
1509 struct drm_display_mode
*mode
)
1511 struct drm_device
*dev
= connector
->dev
;
1512 struct radeon_device
*rdev
= dev
->dev_private
;
1513 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1515 /* XXX check mode bandwidth */
1517 /* clocks over 135 MHz have heat issues with DVI on RV100 */
1518 if (radeon_connector
->use_digital
&&
1519 (rdev
->family
== CHIP_RV100
) &&
1520 (mode
->clock
> 135000))
1521 return MODE_CLOCK_HIGH
;
1523 if (radeon_connector
->use_digital
&& (mode
->clock
> 165000)) {
1524 if ((radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
) ||
1525 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
) ||
1526 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_B
))
1528 else if (ASIC_IS_DCE6(rdev
) && drm_detect_hdmi_monitor(radeon_connector_edid(connector
))) {
1529 /* HDMI 1.3+ supports max clock of 340 Mhz */
1530 if (mode
->clock
> 340000)
1531 return MODE_CLOCK_HIGH
;
1535 return MODE_CLOCK_HIGH
;
1539 /* check against the max pixel clock */
1540 if ((mode
->clock
/ 10) > rdev
->clock
.max_pixel_clock
)
1541 return MODE_CLOCK_HIGH
;
1546 static const struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs
= {
1547 .get_modes
= radeon_vga_get_modes
,
1548 .mode_valid
= radeon_dvi_mode_valid
,
1549 .best_encoder
= radeon_dvi_encoder
,
1552 static const struct drm_connector_funcs radeon_dvi_connector_funcs
= {
1553 .dpms
= drm_helper_connector_dpms
,
1554 .detect
= radeon_dvi_detect
,
1555 .fill_modes
= drm_helper_probe_single_connector_modes
,
1556 .set_property
= radeon_connector_set_property
,
1557 .early_unregister
= radeon_connector_unregister
,
1558 .destroy
= radeon_connector_destroy
,
1559 .force
= radeon_dvi_force
,
1562 static int radeon_dp_get_modes(struct drm_connector
*connector
)
1564 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1565 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1566 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1569 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1570 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1571 struct drm_display_mode
*mode
;
1573 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) {
1574 if (!radeon_dig_connector
->edp_on
)
1575 atombios_set_edp_panel_power(connector
,
1576 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1577 radeon_connector_get_edid(connector
);
1578 ret
= radeon_ddc_get_modes(connector
);
1579 if (!radeon_dig_connector
->edp_on
)
1580 atombios_set_edp_panel_power(connector
,
1581 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1583 /* need to setup ddc on the bridge */
1584 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1585 ENCODER_OBJECT_ID_NONE
) {
1587 radeon_atom_ext_encoder_setup_ddc(encoder
);
1589 radeon_connector_get_edid(connector
);
1590 ret
= radeon_ddc_get_modes(connector
);
1595 radeon_fixup_lvds_native_mode(encoder
, connector
);
1596 /* add scaled modes */
1597 radeon_add_common_modes(encoder
, connector
);
1605 /* we have no EDID modes */
1606 mode
= radeon_fp_native_mode(encoder
);
1609 drm_mode_probed_add(connector
, mode
);
1610 /* add the width/height from vbios tables if available */
1611 connector
->display_info
.width_mm
= mode
->width_mm
;
1612 connector
->display_info
.height_mm
= mode
->height_mm
;
1613 /* add scaled modes */
1614 radeon_add_common_modes(encoder
, connector
);
1617 /* need to setup ddc on the bridge */
1618 if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1619 ENCODER_OBJECT_ID_NONE
) {
1621 radeon_atom_ext_encoder_setup_ddc(encoder
);
1623 radeon_connector_get_edid(connector
);
1624 ret
= radeon_ddc_get_modes(connector
);
1626 radeon_get_native_mode(connector
);
1632 u16
radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector
*connector
)
1634 struct drm_encoder
*encoder
;
1635 struct radeon_encoder
*radeon_encoder
;
1638 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1639 if (connector
->encoder_ids
[i
] == 0)
1642 encoder
= drm_encoder_find(connector
->dev
, NULL
, connector
->encoder_ids
[i
]);
1646 radeon_encoder
= to_radeon_encoder(encoder
);
1648 switch (radeon_encoder
->encoder_id
) {
1649 case ENCODER_OBJECT_ID_TRAVIS
:
1650 case ENCODER_OBJECT_ID_NUTMEG
:
1651 return radeon_encoder
->encoder_id
;
1657 return ENCODER_OBJECT_ID_NONE
;
1660 static bool radeon_connector_encoder_is_hbr2(struct drm_connector
*connector
)
1662 struct drm_encoder
*encoder
;
1663 struct radeon_encoder
*radeon_encoder
;
1667 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
1668 if (connector
->encoder_ids
[i
] == 0)
1671 encoder
= drm_encoder_find(connector
->dev
, NULL
, connector
->encoder_ids
[i
]);
1675 radeon_encoder
= to_radeon_encoder(encoder
);
1676 if (radeon_encoder
->caps
& ATOM_ENCODER_CAP_RECORD_HBR2
)
1683 bool radeon_connector_is_dp12_capable(struct drm_connector
*connector
)
1685 struct drm_device
*dev
= connector
->dev
;
1686 struct radeon_device
*rdev
= dev
->dev_private
;
1688 if (ASIC_IS_DCE5(rdev
) &&
1689 (rdev
->clock
.default_dispclk
>= 53900) &&
1690 radeon_connector_encoder_is_hbr2(connector
)) {
1697 static enum drm_connector_status
1698 radeon_dp_detect(struct drm_connector
*connector
, bool force
)
1700 struct drm_device
*dev
= connector
->dev
;
1701 struct radeon_device
*rdev
= dev
->dev_private
;
1702 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1703 enum drm_connector_status ret
= connector_status_disconnected
;
1704 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1705 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1708 if (radeon_dig_connector
->is_mst
)
1709 return connector_status_disconnected
;
1711 if (!drm_kms_helper_is_poll_worker()) {
1712 r
= pm_runtime_get_sync(connector
->dev
->dev
);
1714 return connector_status_disconnected
;
1717 if (!force
&& radeon_check_hpd_status_unchanged(connector
)) {
1718 ret
= connector
->status
;
1722 radeon_connector_free_edid(connector
);
1724 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1725 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1727 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1728 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1730 /* check if panel is valid */
1731 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
1732 ret
= connector_status_connected
;
1733 /* don't fetch the edid from the vbios if ddc fails and runpm is
1734 * enabled so we report disconnected.
1736 if ((rdev
->flags
& RADEON_IS_PX
) && (radeon_runtime_pm
!= 0))
1737 ret
= connector_status_disconnected
;
1739 /* eDP is always DP */
1740 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1741 if (!radeon_dig_connector
->edp_on
)
1742 atombios_set_edp_panel_power(connector
,
1743 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1744 if (radeon_dp_getdpcd(radeon_connector
))
1745 ret
= connector_status_connected
;
1746 if (!radeon_dig_connector
->edp_on
)
1747 atombios_set_edp_panel_power(connector
,
1748 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1749 } else if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1750 ENCODER_OBJECT_ID_NONE
) {
1751 /* DP bridges are always DP */
1752 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1753 /* get the DPCD from the bridge */
1754 radeon_dp_getdpcd(radeon_connector
);
1757 /* setup ddc on the bridge */
1758 radeon_atom_ext_encoder_setup_ddc(encoder
);
1759 /* bridge chips are always aux */
1760 if (radeon_ddc_probe(radeon_connector
, true)) /* try DDC */
1761 ret
= connector_status_connected
;
1762 else if (radeon_connector
->dac_load_detect
) { /* try load detection */
1763 const struct drm_encoder_helper_funcs
*encoder_funcs
= encoder
->helper_private
;
1764 ret
= encoder_funcs
->detect(encoder
, connector
);
1768 radeon_dig_connector
->dp_sink_type
= radeon_dp_getsinktype(radeon_connector
);
1769 if (radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
1770 ret
= connector_status_connected
;
1771 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
1772 radeon_dp_getdpcd(radeon_connector
);
1773 r
= radeon_dp_mst_probe(radeon_connector
);
1775 ret
= connector_status_disconnected
;
1778 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
1779 if (radeon_dp_getdpcd(radeon_connector
)) {
1780 r
= radeon_dp_mst_probe(radeon_connector
);
1782 ret
= connector_status_disconnected
;
1784 ret
= connector_status_connected
;
1787 /* try non-aux ddc (DP to DVI/HDMI/etc. adapter) */
1788 if (radeon_ddc_probe(radeon_connector
, false))
1789 ret
= connector_status_connected
;
1794 radeon_connector_update_scratch_regs(connector
, ret
);
1796 if ((radeon_audio
!= 0) && encoder
) {
1797 radeon_connector_get_edid(connector
);
1798 radeon_audio_detect(connector
, encoder
, ret
);
1802 if (!drm_kms_helper_is_poll_worker()) {
1803 pm_runtime_mark_last_busy(connector
->dev
->dev
);
1804 pm_runtime_put_autosuspend(connector
->dev
->dev
);
1810 static int radeon_dp_mode_valid(struct drm_connector
*connector
,
1811 struct drm_display_mode
*mode
)
1813 struct drm_device
*dev
= connector
->dev
;
1814 struct radeon_device
*rdev
= dev
->dev_private
;
1815 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1816 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1818 /* XXX check mode bandwidth */
1820 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1821 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1822 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
1824 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
1828 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1829 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
1831 /* AVIVO hardware supports downscaling modes larger than the panel
1832 * to the panel size, but I'm not sure this is desirable.
1834 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
1835 (mode
->vdisplay
> native_mode
->vdisplay
))
1838 /* if scaling is disabled, block non-native modes */
1839 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
1840 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
1841 (mode
->vdisplay
!= native_mode
->vdisplay
))
1846 if ((radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
1847 (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
)) {
1848 return radeon_dp_mode_valid_helper(connector
, mode
);
1850 if (ASIC_IS_DCE6(rdev
) && drm_detect_hdmi_monitor(radeon_connector_edid(connector
))) {
1851 /* HDMI 1.3+ supports max clock of 340 Mhz */
1852 if (mode
->clock
> 340000)
1853 return MODE_CLOCK_HIGH
;
1855 if (mode
->clock
> 165000)
1856 return MODE_CLOCK_HIGH
;
1864 static const struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs
= {
1865 .get_modes
= radeon_dp_get_modes
,
1866 .mode_valid
= radeon_dp_mode_valid
,
1867 .best_encoder
= radeon_dvi_encoder
,
1870 static const struct drm_connector_funcs radeon_dp_connector_funcs
= {
1871 .dpms
= drm_helper_connector_dpms
,
1872 .detect
= radeon_dp_detect
,
1873 .fill_modes
= drm_helper_probe_single_connector_modes
,
1874 .set_property
= radeon_connector_set_property
,
1875 .early_unregister
= radeon_connector_unregister
,
1876 .destroy
= radeon_connector_destroy
,
1877 .force
= radeon_dvi_force
,
1880 static const struct drm_connector_funcs radeon_edp_connector_funcs
= {
1881 .dpms
= drm_helper_connector_dpms
,
1882 .detect
= radeon_dp_detect
,
1883 .fill_modes
= drm_helper_probe_single_connector_modes
,
1884 .set_property
= radeon_lvds_set_property
,
1885 .early_unregister
= radeon_connector_unregister
,
1886 .destroy
= radeon_connector_destroy
,
1887 .force
= radeon_dvi_force
,
1890 static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs
= {
1891 .dpms
= drm_helper_connector_dpms
,
1892 .detect
= radeon_dp_detect
,
1893 .fill_modes
= drm_helper_probe_single_connector_modes
,
1894 .set_property
= radeon_lvds_set_property
,
1895 .early_unregister
= radeon_connector_unregister
,
1896 .destroy
= radeon_connector_destroy
,
1897 .force
= radeon_dvi_force
,
1901 radeon_add_atom_connector(struct drm_device
*dev
,
1902 uint32_t connector_id
,
1903 uint32_t supported_device
,
1905 struct radeon_i2c_bus_rec
*i2c_bus
,
1906 uint32_t igp_lane_info
,
1907 uint16_t connector_object_id
,
1908 struct radeon_hpd
*hpd
,
1909 struct radeon_router
*router
)
1911 struct radeon_device
*rdev
= dev
->dev_private
;
1912 struct drm_connector
*connector
;
1913 struct radeon_connector
*radeon_connector
;
1914 struct radeon_connector_atom_dig
*radeon_dig_connector
;
1915 struct drm_encoder
*encoder
;
1916 struct radeon_encoder
*radeon_encoder
;
1917 uint32_t subpixel_order
= SubPixelNone
;
1918 bool shared_ddc
= false;
1919 bool is_dp_bridge
= false;
1920 bool has_aux
= false;
1922 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1925 /* if the user selected tv=0 don't try and add the connector */
1926 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1927 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1928 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1932 /* see if we already added it */
1933 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1934 radeon_connector
= to_radeon_connector(connector
);
1935 if (radeon_connector
->connector_id
== connector_id
) {
1936 radeon_connector
->devices
|= supported_device
;
1939 if (radeon_connector
->ddc_bus
&& i2c_bus
->valid
) {
1940 if (radeon_connector
->ddc_bus
->rec
.i2c_id
== i2c_bus
->i2c_id
) {
1941 radeon_connector
->shared_ddc
= true;
1944 if (radeon_connector
->router_bus
&& router
->ddc_valid
&&
1945 (radeon_connector
->router
.router_id
== router
->router_id
)) {
1946 radeon_connector
->shared_ddc
= false;
1952 /* check if it's a dp bridge */
1953 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
1954 radeon_encoder
= to_radeon_encoder(encoder
);
1955 if (radeon_encoder
->devices
& supported_device
) {
1956 switch (radeon_encoder
->encoder_id
) {
1957 case ENCODER_OBJECT_ID_TRAVIS
:
1958 case ENCODER_OBJECT_ID_NUTMEG
:
1959 is_dp_bridge
= true;
1967 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1968 if (!radeon_connector
)
1971 connector
= &radeon_connector
->base
;
1973 radeon_connector
->connector_id
= connector_id
;
1974 radeon_connector
->devices
= supported_device
;
1975 radeon_connector
->shared_ddc
= shared_ddc
;
1976 radeon_connector
->connector_object_id
= connector_object_id
;
1977 radeon_connector
->hpd
= *hpd
;
1979 radeon_connector
->router
= *router
;
1980 if (router
->ddc_valid
|| router
->cd_valid
) {
1981 radeon_connector
->router_bus
= radeon_i2c_lookup(rdev
, &router
->i2c_info
);
1982 if (!radeon_connector
->router_bus
)
1983 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n");
1987 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1988 if (!radeon_dig_connector
)
1990 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1991 radeon_connector
->con_priv
= radeon_dig_connector
;
1992 if (i2c_bus
->valid
) {
1993 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1994 if (radeon_connector
->ddc_bus
)
1997 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1999 switch (connector_type
) {
2000 case DRM_MODE_CONNECTOR_VGA
:
2001 case DRM_MODE_CONNECTOR_DVIA
:
2003 drm_connector_init(dev
, &radeon_connector
->base
,
2004 &radeon_dp_connector_funcs
, connector_type
);
2005 drm_connector_helper_add(&radeon_connector
->base
,
2006 &radeon_dp_connector_helper_funcs
);
2007 connector
->interlace_allowed
= true;
2008 connector
->doublescan_allowed
= true;
2009 radeon_connector
->dac_load_detect
= true;
2010 drm_object_attach_property(&radeon_connector
->base
.base
,
2011 rdev
->mode_info
.load_detect_property
,
2013 drm_object_attach_property(&radeon_connector
->base
.base
,
2014 dev
->mode_config
.scaling_mode_property
,
2015 DRM_MODE_SCALE_NONE
);
2016 if (ASIC_IS_DCE5(rdev
))
2017 drm_object_attach_property(&radeon_connector
->base
.base
,
2018 rdev
->mode_info
.output_csc_property
,
2019 RADEON_OUTPUT_CSC_BYPASS
);
2021 case DRM_MODE_CONNECTOR_DVII
:
2022 case DRM_MODE_CONNECTOR_DVID
:
2023 case DRM_MODE_CONNECTOR_HDMIA
:
2024 case DRM_MODE_CONNECTOR_HDMIB
:
2025 case DRM_MODE_CONNECTOR_DisplayPort
:
2026 drm_connector_init(dev
, &radeon_connector
->base
,
2027 &radeon_dp_connector_funcs
, connector_type
);
2028 drm_connector_helper_add(&radeon_connector
->base
,
2029 &radeon_dp_connector_helper_funcs
);
2030 drm_object_attach_property(&radeon_connector
->base
.base
,
2031 rdev
->mode_info
.underscan_property
,
2033 drm_object_attach_property(&radeon_connector
->base
.base
,
2034 rdev
->mode_info
.underscan_hborder_property
,
2036 drm_object_attach_property(&radeon_connector
->base
.base
,
2037 rdev
->mode_info
.underscan_vborder_property
,
2040 drm_object_attach_property(&radeon_connector
->base
.base
,
2041 dev
->mode_config
.scaling_mode_property
,
2042 DRM_MODE_SCALE_NONE
);
2044 drm_object_attach_property(&radeon_connector
->base
.base
,
2045 rdev
->mode_info
.dither_property
,
2046 RADEON_FMT_DITHER_DISABLE
);
2048 if (radeon_audio
!= 0) {
2049 drm_object_attach_property(&radeon_connector
->base
.base
,
2050 rdev
->mode_info
.audio_property
,
2052 radeon_connector
->audio
= RADEON_AUDIO_AUTO
;
2054 if (ASIC_IS_DCE5(rdev
))
2055 drm_object_attach_property(&radeon_connector
->base
.base
,
2056 rdev
->mode_info
.output_csc_property
,
2057 RADEON_OUTPUT_CSC_BYPASS
);
2059 subpixel_order
= SubPixelHorizontalRGB
;
2060 connector
->interlace_allowed
= true;
2061 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
2062 connector
->doublescan_allowed
= true;
2064 connector
->doublescan_allowed
= false;
2065 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
2066 radeon_connector
->dac_load_detect
= true;
2067 drm_object_attach_property(&radeon_connector
->base
.base
,
2068 rdev
->mode_info
.load_detect_property
,
2072 case DRM_MODE_CONNECTOR_LVDS
:
2073 case DRM_MODE_CONNECTOR_eDP
:
2074 drm_connector_init(dev
, &radeon_connector
->base
,
2075 &radeon_lvds_bridge_connector_funcs
, connector_type
);
2076 drm_connector_helper_add(&radeon_connector
->base
,
2077 &radeon_dp_connector_helper_funcs
);
2078 drm_object_attach_property(&radeon_connector
->base
.base
,
2079 dev
->mode_config
.scaling_mode_property
,
2080 DRM_MODE_SCALE_FULLSCREEN
);
2081 subpixel_order
= SubPixelHorizontalRGB
;
2082 connector
->interlace_allowed
= false;
2083 connector
->doublescan_allowed
= false;
2087 switch (connector_type
) {
2088 case DRM_MODE_CONNECTOR_VGA
:
2089 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
2090 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
2091 if (i2c_bus
->valid
) {
2092 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2093 if (!radeon_connector
->ddc_bus
)
2094 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2096 radeon_connector
->dac_load_detect
= true;
2097 drm_object_attach_property(&radeon_connector
->base
.base
,
2098 rdev
->mode_info
.load_detect_property
,
2100 if (ASIC_IS_AVIVO(rdev
))
2101 drm_object_attach_property(&radeon_connector
->base
.base
,
2102 dev
->mode_config
.scaling_mode_property
,
2103 DRM_MODE_SCALE_NONE
);
2104 if (ASIC_IS_DCE5(rdev
))
2105 drm_object_attach_property(&radeon_connector
->base
.base
,
2106 rdev
->mode_info
.output_csc_property
,
2107 RADEON_OUTPUT_CSC_BYPASS
);
2108 /* no HPD on analog connectors */
2109 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2110 connector
->interlace_allowed
= true;
2111 connector
->doublescan_allowed
= true;
2113 case DRM_MODE_CONNECTOR_DVIA
:
2114 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
2115 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
2116 if (i2c_bus
->valid
) {
2117 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2118 if (!radeon_connector
->ddc_bus
)
2119 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2121 radeon_connector
->dac_load_detect
= true;
2122 drm_object_attach_property(&radeon_connector
->base
.base
,
2123 rdev
->mode_info
.load_detect_property
,
2125 if (ASIC_IS_AVIVO(rdev
))
2126 drm_object_attach_property(&radeon_connector
->base
.base
,
2127 dev
->mode_config
.scaling_mode_property
,
2128 DRM_MODE_SCALE_NONE
);
2129 if (ASIC_IS_DCE5(rdev
))
2130 drm_object_attach_property(&radeon_connector
->base
.base
,
2131 rdev
->mode_info
.output_csc_property
,
2132 RADEON_OUTPUT_CSC_BYPASS
);
2133 /* no HPD on analog connectors */
2134 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2135 connector
->interlace_allowed
= true;
2136 connector
->doublescan_allowed
= true;
2138 case DRM_MODE_CONNECTOR_DVII
:
2139 case DRM_MODE_CONNECTOR_DVID
:
2140 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
2141 if (!radeon_dig_connector
)
2143 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
2144 radeon_connector
->con_priv
= radeon_dig_connector
;
2145 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
2146 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
2147 if (i2c_bus
->valid
) {
2148 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2149 if (!radeon_connector
->ddc_bus
)
2150 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2152 subpixel_order
= SubPixelHorizontalRGB
;
2153 drm_object_attach_property(&radeon_connector
->base
.base
,
2154 rdev
->mode_info
.coherent_mode_property
,
2156 if (ASIC_IS_AVIVO(rdev
)) {
2157 drm_object_attach_property(&radeon_connector
->base
.base
,
2158 rdev
->mode_info
.underscan_property
,
2160 drm_object_attach_property(&radeon_connector
->base
.base
,
2161 rdev
->mode_info
.underscan_hborder_property
,
2163 drm_object_attach_property(&radeon_connector
->base
.base
,
2164 rdev
->mode_info
.underscan_vborder_property
,
2166 drm_object_attach_property(&radeon_connector
->base
.base
,
2167 rdev
->mode_info
.dither_property
,
2168 RADEON_FMT_DITHER_DISABLE
);
2169 drm_object_attach_property(&radeon_connector
->base
.base
,
2170 dev
->mode_config
.scaling_mode_property
,
2171 DRM_MODE_SCALE_NONE
);
2173 if (ASIC_IS_DCE2(rdev
) && (radeon_audio
!= 0)) {
2174 drm_object_attach_property(&radeon_connector
->base
.base
,
2175 rdev
->mode_info
.audio_property
,
2177 radeon_connector
->audio
= RADEON_AUDIO_AUTO
;
2179 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
2180 radeon_connector
->dac_load_detect
= true;
2181 drm_object_attach_property(&radeon_connector
->base
.base
,
2182 rdev
->mode_info
.load_detect_property
,
2185 if (ASIC_IS_DCE5(rdev
))
2186 drm_object_attach_property(&radeon_connector
->base
.base
,
2187 rdev
->mode_info
.output_csc_property
,
2188 RADEON_OUTPUT_CSC_BYPASS
);
2189 connector
->interlace_allowed
= true;
2190 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
2191 connector
->doublescan_allowed
= true;
2193 connector
->doublescan_allowed
= false;
2195 case DRM_MODE_CONNECTOR_HDMIA
:
2196 case DRM_MODE_CONNECTOR_HDMIB
:
2197 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
2198 if (!radeon_dig_connector
)
2200 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
2201 radeon_connector
->con_priv
= radeon_dig_connector
;
2202 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
2203 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
2204 if (i2c_bus
->valid
) {
2205 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2206 if (!radeon_connector
->ddc_bus
)
2207 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2209 drm_object_attach_property(&radeon_connector
->base
.base
,
2210 rdev
->mode_info
.coherent_mode_property
,
2212 if (ASIC_IS_AVIVO(rdev
)) {
2213 drm_object_attach_property(&radeon_connector
->base
.base
,
2214 rdev
->mode_info
.underscan_property
,
2216 drm_object_attach_property(&radeon_connector
->base
.base
,
2217 rdev
->mode_info
.underscan_hborder_property
,
2219 drm_object_attach_property(&radeon_connector
->base
.base
,
2220 rdev
->mode_info
.underscan_vborder_property
,
2222 drm_object_attach_property(&radeon_connector
->base
.base
,
2223 rdev
->mode_info
.dither_property
,
2224 RADEON_FMT_DITHER_DISABLE
);
2225 drm_object_attach_property(&radeon_connector
->base
.base
,
2226 dev
->mode_config
.scaling_mode_property
,
2227 DRM_MODE_SCALE_NONE
);
2229 if (ASIC_IS_DCE2(rdev
) && (radeon_audio
!= 0)) {
2230 drm_object_attach_property(&radeon_connector
->base
.base
,
2231 rdev
->mode_info
.audio_property
,
2233 radeon_connector
->audio
= RADEON_AUDIO_AUTO
;
2235 if (ASIC_IS_DCE5(rdev
))
2236 drm_object_attach_property(&radeon_connector
->base
.base
,
2237 rdev
->mode_info
.output_csc_property
,
2238 RADEON_OUTPUT_CSC_BYPASS
);
2239 subpixel_order
= SubPixelHorizontalRGB
;
2240 connector
->interlace_allowed
= true;
2241 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
2242 connector
->doublescan_allowed
= true;
2244 connector
->doublescan_allowed
= false;
2246 case DRM_MODE_CONNECTOR_DisplayPort
:
2247 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
2248 if (!radeon_dig_connector
)
2250 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
2251 radeon_connector
->con_priv
= radeon_dig_connector
;
2252 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
2253 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
2254 if (i2c_bus
->valid
) {
2255 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2256 if (radeon_connector
->ddc_bus
)
2259 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2261 subpixel_order
= SubPixelHorizontalRGB
;
2262 drm_object_attach_property(&radeon_connector
->base
.base
,
2263 rdev
->mode_info
.coherent_mode_property
,
2265 if (ASIC_IS_AVIVO(rdev
)) {
2266 drm_object_attach_property(&radeon_connector
->base
.base
,
2267 rdev
->mode_info
.underscan_property
,
2269 drm_object_attach_property(&radeon_connector
->base
.base
,
2270 rdev
->mode_info
.underscan_hborder_property
,
2272 drm_object_attach_property(&radeon_connector
->base
.base
,
2273 rdev
->mode_info
.underscan_vborder_property
,
2275 drm_object_attach_property(&radeon_connector
->base
.base
,
2276 rdev
->mode_info
.dither_property
,
2277 RADEON_FMT_DITHER_DISABLE
);
2278 drm_object_attach_property(&radeon_connector
->base
.base
,
2279 dev
->mode_config
.scaling_mode_property
,
2280 DRM_MODE_SCALE_NONE
);
2282 if (ASIC_IS_DCE2(rdev
) && (radeon_audio
!= 0)) {
2283 drm_object_attach_property(&radeon_connector
->base
.base
,
2284 rdev
->mode_info
.audio_property
,
2286 radeon_connector
->audio
= RADEON_AUDIO_AUTO
;
2288 if (ASIC_IS_DCE5(rdev
))
2289 drm_object_attach_property(&radeon_connector
->base
.base
,
2290 rdev
->mode_info
.output_csc_property
,
2291 RADEON_OUTPUT_CSC_BYPASS
);
2292 connector
->interlace_allowed
= true;
2293 /* in theory with a DP to VGA converter... */
2294 connector
->doublescan_allowed
= false;
2296 case DRM_MODE_CONNECTOR_eDP
:
2297 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
2298 if (!radeon_dig_connector
)
2300 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
2301 radeon_connector
->con_priv
= radeon_dig_connector
;
2302 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_edp_connector_funcs
, connector_type
);
2303 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
2304 if (i2c_bus
->valid
) {
2305 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2306 if (radeon_connector
->ddc_bus
)
2309 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2311 drm_object_attach_property(&radeon_connector
->base
.base
,
2312 dev
->mode_config
.scaling_mode_property
,
2313 DRM_MODE_SCALE_FULLSCREEN
);
2314 subpixel_order
= SubPixelHorizontalRGB
;
2315 connector
->interlace_allowed
= false;
2316 connector
->doublescan_allowed
= false;
2318 case DRM_MODE_CONNECTOR_SVIDEO
:
2319 case DRM_MODE_CONNECTOR_Composite
:
2320 case DRM_MODE_CONNECTOR_9PinDIN
:
2321 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
2322 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
2323 radeon_connector
->dac_load_detect
= true;
2324 drm_object_attach_property(&radeon_connector
->base
.base
,
2325 rdev
->mode_info
.load_detect_property
,
2327 drm_object_attach_property(&radeon_connector
->base
.base
,
2328 rdev
->mode_info
.tv_std_property
,
2329 radeon_atombios_get_tv_info(rdev
));
2330 /* no HPD on analog connectors */
2331 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2332 connector
->interlace_allowed
= false;
2333 connector
->doublescan_allowed
= false;
2335 case DRM_MODE_CONNECTOR_LVDS
:
2336 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
2337 if (!radeon_dig_connector
)
2339 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
2340 radeon_connector
->con_priv
= radeon_dig_connector
;
2341 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
2342 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
2343 if (i2c_bus
->valid
) {
2344 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2345 if (!radeon_connector
->ddc_bus
)
2346 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2348 drm_object_attach_property(&radeon_connector
->base
.base
,
2349 dev
->mode_config
.scaling_mode_property
,
2350 DRM_MODE_SCALE_FULLSCREEN
);
2351 subpixel_order
= SubPixelHorizontalRGB
;
2352 connector
->interlace_allowed
= false;
2353 connector
->doublescan_allowed
= false;
2358 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
2359 if (i2c_bus
->valid
) {
2360 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
|
2361 DRM_CONNECTOR_POLL_DISCONNECT
;
2364 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
2366 connector
->display_info
.subpixel_order
= subpixel_order
;
2367 drm_connector_register(connector
);
2370 radeon_dp_aux_init(radeon_connector
);
2375 drm_connector_cleanup(connector
);
2380 radeon_add_legacy_connector(struct drm_device
*dev
,
2381 uint32_t connector_id
,
2382 uint32_t supported_device
,
2384 struct radeon_i2c_bus_rec
*i2c_bus
,
2385 uint16_t connector_object_id
,
2386 struct radeon_hpd
*hpd
)
2388 struct radeon_device
*rdev
= dev
->dev_private
;
2389 struct drm_connector
*connector
;
2390 struct radeon_connector
*radeon_connector
;
2391 uint32_t subpixel_order
= SubPixelNone
;
2393 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
2396 /* if the user selected tv=0 don't try and add the connector */
2397 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
2398 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
2399 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
2403 /* see if we already added it */
2404 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
2405 radeon_connector
= to_radeon_connector(connector
);
2406 if (radeon_connector
->connector_id
== connector_id
) {
2407 radeon_connector
->devices
|= supported_device
;
2412 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
2413 if (!radeon_connector
)
2416 connector
= &radeon_connector
->base
;
2418 radeon_connector
->connector_id
= connector_id
;
2419 radeon_connector
->devices
= supported_device
;
2420 radeon_connector
->connector_object_id
= connector_object_id
;
2421 radeon_connector
->hpd
= *hpd
;
2423 switch (connector_type
) {
2424 case DRM_MODE_CONNECTOR_VGA
:
2425 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
2426 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
2427 if (i2c_bus
->valid
) {
2428 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2429 if (!radeon_connector
->ddc_bus
)
2430 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2432 radeon_connector
->dac_load_detect
= true;
2433 drm_object_attach_property(&radeon_connector
->base
.base
,
2434 rdev
->mode_info
.load_detect_property
,
2436 /* no HPD on analog connectors */
2437 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2438 connector
->interlace_allowed
= true;
2439 connector
->doublescan_allowed
= true;
2441 case DRM_MODE_CONNECTOR_DVIA
:
2442 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
2443 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
2444 if (i2c_bus
->valid
) {
2445 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2446 if (!radeon_connector
->ddc_bus
)
2447 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2449 radeon_connector
->dac_load_detect
= true;
2450 drm_object_attach_property(&radeon_connector
->base
.base
,
2451 rdev
->mode_info
.load_detect_property
,
2453 /* no HPD on analog connectors */
2454 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2455 connector
->interlace_allowed
= true;
2456 connector
->doublescan_allowed
= true;
2458 case DRM_MODE_CONNECTOR_DVII
:
2459 case DRM_MODE_CONNECTOR_DVID
:
2460 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
2461 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
2462 if (i2c_bus
->valid
) {
2463 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2464 if (!radeon_connector
->ddc_bus
)
2465 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2467 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
2468 radeon_connector
->dac_load_detect
= true;
2469 drm_object_attach_property(&radeon_connector
->base
.base
,
2470 rdev
->mode_info
.load_detect_property
,
2473 subpixel_order
= SubPixelHorizontalRGB
;
2474 connector
->interlace_allowed
= true;
2475 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
2476 connector
->doublescan_allowed
= true;
2478 connector
->doublescan_allowed
= false;
2480 case DRM_MODE_CONNECTOR_SVIDEO
:
2481 case DRM_MODE_CONNECTOR_Composite
:
2482 case DRM_MODE_CONNECTOR_9PinDIN
:
2483 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
2484 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
2485 radeon_connector
->dac_load_detect
= true;
2486 /* RS400,RC410,RS480 chipset seems to report a lot
2487 * of false positive on load detect, we haven't yet
2488 * found a way to make load detect reliable on those
2489 * chipset, thus just disable it for TV.
2491 if (rdev
->family
== CHIP_RS400
|| rdev
->family
== CHIP_RS480
)
2492 radeon_connector
->dac_load_detect
= false;
2493 drm_object_attach_property(&radeon_connector
->base
.base
,
2494 rdev
->mode_info
.load_detect_property
,
2495 radeon_connector
->dac_load_detect
);
2496 drm_object_attach_property(&radeon_connector
->base
.base
,
2497 rdev
->mode_info
.tv_std_property
,
2498 radeon_combios_get_tv_info(rdev
));
2499 /* no HPD on analog connectors */
2500 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
2501 connector
->interlace_allowed
= false;
2502 connector
->doublescan_allowed
= false;
2504 case DRM_MODE_CONNECTOR_LVDS
:
2505 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
2506 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
2507 if (i2c_bus
->valid
) {
2508 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
2509 if (!radeon_connector
->ddc_bus
)
2510 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2512 drm_object_attach_property(&radeon_connector
->base
.base
,
2513 dev
->mode_config
.scaling_mode_property
,
2514 DRM_MODE_SCALE_FULLSCREEN
);
2515 subpixel_order
= SubPixelHorizontalRGB
;
2516 connector
->interlace_allowed
= false;
2517 connector
->doublescan_allowed
= false;
2521 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
2522 if (i2c_bus
->valid
) {
2523 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
|
2524 DRM_CONNECTOR_POLL_DISCONNECT
;
2527 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
2529 connector
->display_info
.subpixel_order
= subpixel_order
;
2530 drm_connector_register(connector
);
2533 void radeon_setup_mst_connector(struct drm_device
*dev
)
2535 struct radeon_device
*rdev
= dev
->dev_private
;
2536 struct drm_connector
*connector
;
2537 struct radeon_connector
*radeon_connector
;
2539 if (!ASIC_IS_DCE5(rdev
))
2542 if (radeon_mst
== 0)
2545 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
2548 radeon_connector
= to_radeon_connector(connector
);
2550 if (connector
->connector_type
!= DRM_MODE_CONNECTOR_DisplayPort
)
2553 ret
= radeon_dp_mst_init(radeon_connector
);