2 * Copyright 2007-8 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
23 * Authors: Dave Airlie
28 #include "drm_crtc_helper.h"
29 #include "drm_fb_helper.h"
30 #include "radeon_drm.h"
35 radeon_combios_connected_scratch_regs(struct drm_connector
*connector
,
36 struct drm_encoder
*encoder
,
39 radeon_atombios_connected_scratch_regs(struct drm_connector
*connector
,
40 struct drm_encoder
*encoder
,
44 radeon_legacy_backlight_init(struct radeon_encoder
*radeon_encoder
,
45 struct drm_connector
*drm_connector
);
47 void radeon_connector_hotplug(struct drm_connector
*connector
)
49 struct drm_device
*dev
= connector
->dev
;
50 struct radeon_device
*rdev
= dev
->dev_private
;
51 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
53 if (radeon_connector
->hpd
.hpd
!= RADEON_HPD_NONE
)
54 radeon_hpd_set_polarity(rdev
, radeon_connector
->hpd
.hpd
);
56 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
) ||
57 (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
)) {
58 if ((radeon_dp_getsinktype(radeon_connector
) == CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
59 (radeon_dp_getsinktype(radeon_connector
) == CONNECTOR_OBJECT_ID_eDP
)) {
60 if (radeon_dp_needs_link_train(radeon_connector
)) {
61 if (connector
->encoder
)
62 dp_link_train(connector
->encoder
, connector
);
69 static void radeon_property_change_mode(struct drm_encoder
*encoder
)
71 struct drm_crtc
*crtc
= encoder
->crtc
;
73 if (crtc
&& crtc
->enabled
) {
74 drm_crtc_helper_set_mode(crtc
, &crtc
->mode
,
75 crtc
->x
, crtc
->y
, crtc
->fb
);
79 radeon_connector_update_scratch_regs(struct drm_connector
*connector
, enum drm_connector_status status
)
81 struct drm_device
*dev
= connector
->dev
;
82 struct radeon_device
*rdev
= dev
->dev_private
;
83 struct drm_encoder
*best_encoder
= NULL
;
84 struct drm_encoder
*encoder
= NULL
;
85 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
86 struct drm_mode_object
*obj
;
90 best_encoder
= connector_funcs
->best_encoder(connector
);
92 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
93 if (connector
->encoder_ids
[i
] == 0)
96 obj
= drm_mode_object_find(connector
->dev
,
97 connector
->encoder_ids
[i
],
98 DRM_MODE_OBJECT_ENCODER
);
102 encoder
= obj_to_encoder(obj
);
104 if ((encoder
== best_encoder
) && (status
== connector_status_connected
))
109 if (rdev
->is_atom_bios
)
110 radeon_atombios_connected_scratch_regs(connector
, encoder
, connected
);
112 radeon_combios_connected_scratch_regs(connector
, encoder
, connected
);
117 struct drm_encoder
*radeon_find_encoder(struct drm_connector
*connector
, int encoder_type
)
119 struct drm_mode_object
*obj
;
120 struct drm_encoder
*encoder
;
123 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
124 if (connector
->encoder_ids
[i
] == 0)
127 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
131 encoder
= obj_to_encoder(obj
);
132 if (encoder
->encoder_type
== encoder_type
)
138 struct drm_encoder
*radeon_best_single_encoder(struct drm_connector
*connector
)
140 int enc_id
= connector
->encoder_ids
[0];
141 struct drm_mode_object
*obj
;
142 struct drm_encoder
*encoder
;
144 /* pick the encoder ids */
146 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
149 encoder
= obj_to_encoder(obj
);
156 * radeon_connector_analog_encoder_conflict_solve
157 * - search for other connectors sharing this encoder
158 * if priority is true, then set them disconnected if this is connected
159 * if priority is false, set us disconnected if they are connected
161 static enum drm_connector_status
162 radeon_connector_analog_encoder_conflict_solve(struct drm_connector
*connector
,
163 struct drm_encoder
*encoder
,
164 enum drm_connector_status current_status
,
167 struct drm_device
*dev
= connector
->dev
;
168 struct drm_connector
*conflict
;
169 struct radeon_connector
*radeon_conflict
;
172 list_for_each_entry(conflict
, &dev
->mode_config
.connector_list
, head
) {
173 if (conflict
== connector
)
176 radeon_conflict
= to_radeon_connector(conflict
);
177 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
178 if (conflict
->encoder_ids
[i
] == 0)
181 /* if the IDs match */
182 if (conflict
->encoder_ids
[i
] == encoder
->base
.id
) {
183 if (conflict
->status
!= connector_status_connected
)
186 if (radeon_conflict
->use_digital
)
189 if (priority
== true) {
190 DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict
));
191 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(connector
));
192 conflict
->status
= connector_status_disconnected
;
193 radeon_connector_update_scratch_regs(conflict
, connector_status_disconnected
);
195 DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector
));
196 DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(conflict
));
197 current_status
= connector_status_disconnected
;
203 return current_status
;
207 static struct drm_display_mode
*radeon_fp_native_mode(struct drm_encoder
*encoder
)
209 struct drm_device
*dev
= encoder
->dev
;
210 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
211 struct drm_display_mode
*mode
= NULL
;
212 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
214 if (native_mode
->hdisplay
!= 0 &&
215 native_mode
->vdisplay
!= 0 &&
216 native_mode
->clock
!= 0) {
217 mode
= drm_mode_duplicate(dev
, native_mode
);
218 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
219 drm_mode_set_name(mode
);
221 DRM_DEBUG_KMS("Adding native panel mode %s\n", mode
->name
);
222 } else if (native_mode
->hdisplay
!= 0 &&
223 native_mode
->vdisplay
!= 0) {
224 /* mac laptops without an edid */
225 /* Note that this is not necessarily the exact panel mode,
226 * but an approximation based on the cvt formula. For these
227 * systems we should ideally read the mode info out of the
228 * registers or add a mode table, but this works and is much
231 mode
= drm_cvt_mode(dev
, native_mode
->hdisplay
, native_mode
->vdisplay
, 60, true, false, false);
232 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
233 DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode
->name
);
238 static void radeon_add_common_modes(struct drm_encoder
*encoder
, struct drm_connector
*connector
)
240 struct drm_device
*dev
= encoder
->dev
;
241 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
242 struct drm_display_mode
*mode
= NULL
;
243 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
248 } common_modes
[17] = {
268 for (i
= 0; i
< 17; i
++) {
269 if (radeon_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
)) {
270 if (common_modes
[i
].w
> 1024 ||
271 common_modes
[i
].h
> 768)
274 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
275 if (common_modes
[i
].w
> native_mode
->hdisplay
||
276 common_modes
[i
].h
> native_mode
->vdisplay
||
277 (common_modes
[i
].w
== native_mode
->hdisplay
&&
278 common_modes
[i
].h
== native_mode
->vdisplay
))
281 if (common_modes
[i
].w
< 320 || common_modes
[i
].h
< 200)
284 mode
= drm_cvt_mode(dev
, common_modes
[i
].w
, common_modes
[i
].h
, 60, false, false, false);
285 drm_mode_probed_add(connector
, mode
);
289 int radeon_connector_set_property(struct drm_connector
*connector
, struct drm_property
*property
,
292 struct drm_device
*dev
= connector
->dev
;
293 struct radeon_device
*rdev
= dev
->dev_private
;
294 struct drm_encoder
*encoder
;
295 struct radeon_encoder
*radeon_encoder
;
297 if (property
== rdev
->mode_info
.coherent_mode_property
) {
298 struct radeon_encoder_atom_dig
*dig
;
299 bool new_coherent_mode
;
301 /* need to find digital encoder on connector */
302 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
306 radeon_encoder
= to_radeon_encoder(encoder
);
308 if (!radeon_encoder
->enc_priv
)
311 dig
= radeon_encoder
->enc_priv
;
312 new_coherent_mode
= val
? true : false;
313 if (dig
->coherent_mode
!= new_coherent_mode
) {
314 dig
->coherent_mode
= new_coherent_mode
;
315 radeon_property_change_mode(&radeon_encoder
->base
);
319 if (property
== rdev
->mode_info
.underscan_property
) {
320 /* need to find digital encoder on connector */
321 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
325 radeon_encoder
= to_radeon_encoder(encoder
);
327 if (radeon_encoder
->underscan_type
!= val
) {
328 radeon_encoder
->underscan_type
= val
;
329 radeon_property_change_mode(&radeon_encoder
->base
);
333 if (property
== rdev
->mode_info
.underscan_hborder_property
) {
334 /* need to find digital encoder on connector */
335 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
339 radeon_encoder
= to_radeon_encoder(encoder
);
341 if (radeon_encoder
->underscan_hborder
!= val
) {
342 radeon_encoder
->underscan_hborder
= val
;
343 radeon_property_change_mode(&radeon_encoder
->base
);
347 if (property
== rdev
->mode_info
.underscan_vborder_property
) {
348 /* need to find digital encoder on connector */
349 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
353 radeon_encoder
= to_radeon_encoder(encoder
);
355 if (radeon_encoder
->underscan_vborder
!= val
) {
356 radeon_encoder
->underscan_vborder
= val
;
357 radeon_property_change_mode(&radeon_encoder
->base
);
361 if (property
== rdev
->mode_info
.tv_std_property
) {
362 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TVDAC
);
364 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_DAC
);
370 radeon_encoder
= to_radeon_encoder(encoder
);
371 if (!radeon_encoder
->enc_priv
)
373 if (ASIC_IS_AVIVO(rdev
) || radeon_r4xx_atom
) {
374 struct radeon_encoder_atom_dac
*dac_int
;
375 dac_int
= radeon_encoder
->enc_priv
;
376 dac_int
->tv_std
= val
;
378 struct radeon_encoder_tv_dac
*dac_int
;
379 dac_int
= radeon_encoder
->enc_priv
;
380 dac_int
->tv_std
= val
;
382 radeon_property_change_mode(&radeon_encoder
->base
);
385 if (property
== rdev
->mode_info
.load_detect_property
) {
386 struct radeon_connector
*radeon_connector
=
387 to_radeon_connector(connector
);
390 radeon_connector
->dac_load_detect
= false;
392 radeon_connector
->dac_load_detect
= true;
395 if (property
== rdev
->mode_info
.tmds_pll_property
) {
396 struct radeon_encoder_int_tmds
*tmds
= NULL
;
398 /* need to find digital encoder on connector */
399 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
403 radeon_encoder
= to_radeon_encoder(encoder
);
405 tmds
= radeon_encoder
->enc_priv
;
410 if (rdev
->is_atom_bios
)
411 ret
= radeon_atombios_get_tmds_info(radeon_encoder
, tmds
);
413 ret
= radeon_legacy_get_tmds_info_from_combios(radeon_encoder
, tmds
);
415 if (val
== 1 || ret
== false) {
416 radeon_legacy_get_tmds_info_from_table(radeon_encoder
, tmds
);
418 radeon_property_change_mode(&radeon_encoder
->base
);
424 static void radeon_fixup_lvds_native_mode(struct drm_encoder
*encoder
,
425 struct drm_connector
*connector
)
427 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
428 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
430 /* Try to get native mode details from EDID if necessary */
431 if (!native_mode
->clock
) {
432 struct drm_display_mode
*t
, *mode
;
434 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
435 if (mode
->hdisplay
== native_mode
->hdisplay
&&
436 mode
->vdisplay
== native_mode
->vdisplay
) {
437 *native_mode
= *mode
;
438 drm_mode_set_crtcinfo(native_mode
, CRTC_INTERLACE_HALVE_V
);
439 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
444 if (!native_mode
->clock
) {
445 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n");
446 radeon_encoder
->rmx_type
= RMX_OFF
;
450 static int radeon_lvds_get_modes(struct drm_connector
*connector
)
452 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
453 struct drm_encoder
*encoder
;
455 struct drm_display_mode
*mode
;
457 if (radeon_connector
->ddc_bus
) {
458 ret
= radeon_ddc_get_modes(radeon_connector
);
460 encoder
= radeon_best_single_encoder(connector
);
462 radeon_fixup_lvds_native_mode(encoder
, connector
);
463 /* add scaled modes */
464 radeon_add_common_modes(encoder
, connector
);
470 encoder
= radeon_best_single_encoder(connector
);
474 /* we have no EDID modes */
475 mode
= radeon_fp_native_mode(encoder
);
478 drm_mode_probed_add(connector
, mode
);
479 /* add the width/height from vbios tables if available */
480 connector
->display_info
.width_mm
= mode
->width_mm
;
481 connector
->display_info
.height_mm
= mode
->height_mm
;
482 /* add scaled modes */
483 radeon_add_common_modes(encoder
, connector
);
489 static int radeon_lvds_mode_valid(struct drm_connector
*connector
,
490 struct drm_display_mode
*mode
)
492 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
494 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
498 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
499 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
501 /* AVIVO hardware supports downscaling modes larger than the panel
502 * to the panel size, but I'm not sure this is desirable.
504 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
505 (mode
->vdisplay
> native_mode
->vdisplay
))
508 /* if scaling is disabled, block non-native modes */
509 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
510 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
511 (mode
->vdisplay
!= native_mode
->vdisplay
))
519 static enum drm_connector_status
520 radeon_lvds_detect(struct drm_connector
*connector
, bool force
)
522 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
523 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
524 enum drm_connector_status ret
= connector_status_disconnected
;
527 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
528 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
530 /* check if panel is valid */
531 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
532 ret
= connector_status_connected
;
536 /* check for edid as well */
537 if (radeon_connector
->edid
)
538 ret
= connector_status_connected
;
540 if (radeon_connector
->ddc_bus
) {
541 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
,
542 &radeon_connector
->ddc_bus
->adapter
);
543 if (radeon_connector
->edid
)
544 ret
= connector_status_connected
;
547 /* check acpi lid status ??? */
549 radeon_connector_update_scratch_regs(connector
, ret
);
553 static void radeon_connector_destroy(struct drm_connector
*connector
)
555 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
557 if (radeon_connector
->edid
)
558 kfree(radeon_connector
->edid
);
559 kfree(radeon_connector
->con_priv
);
560 drm_sysfs_connector_remove(connector
);
561 drm_connector_cleanup(connector
);
565 static int radeon_lvds_set_property(struct drm_connector
*connector
,
566 struct drm_property
*property
,
569 struct drm_device
*dev
= connector
->dev
;
570 struct radeon_encoder
*radeon_encoder
;
571 enum radeon_rmx_type rmx_type
;
574 if (property
!= dev
->mode_config
.scaling_mode_property
)
577 if (connector
->encoder
)
578 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
580 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
581 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
585 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
586 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
587 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
589 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
591 if (radeon_encoder
->rmx_type
== rmx_type
)
594 radeon_encoder
->rmx_type
= rmx_type
;
596 radeon_property_change_mode(&radeon_encoder
->base
);
601 struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs
= {
602 .get_modes
= radeon_lvds_get_modes
,
603 .mode_valid
= radeon_lvds_mode_valid
,
604 .best_encoder
= radeon_best_single_encoder
,
607 struct drm_connector_funcs radeon_lvds_connector_funcs
= {
608 .dpms
= drm_helper_connector_dpms
,
609 .detect
= radeon_lvds_detect
,
610 .fill_modes
= drm_helper_probe_single_connector_modes
,
611 .destroy
= radeon_connector_destroy
,
612 .set_property
= radeon_lvds_set_property
,
615 static int radeon_vga_get_modes(struct drm_connector
*connector
)
617 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
620 ret
= radeon_ddc_get_modes(radeon_connector
);
625 static int radeon_vga_mode_valid(struct drm_connector
*connector
,
626 struct drm_display_mode
*mode
)
628 /* XXX check mode bandwidth */
629 /* XXX verify against max DAC output frequency */
633 static enum drm_connector_status
634 radeon_vga_detect(struct drm_connector
*connector
, bool force
)
636 struct drm_device
*dev
= connector
->dev
;
637 struct radeon_device
*rdev
= dev
->dev_private
;
638 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
639 struct drm_encoder
*encoder
;
640 struct drm_encoder_helper_funcs
*encoder_funcs
;
642 enum drm_connector_status ret
= connector_status_disconnected
;
644 encoder
= radeon_best_single_encoder(connector
);
646 ret
= connector_status_disconnected
;
648 if (radeon_connector
->ddc_bus
)
649 dret
= radeon_ddc_probe(radeon_connector
);
651 if (radeon_connector
->edid
) {
652 kfree(radeon_connector
->edid
);
653 radeon_connector
->edid
= NULL
;
655 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
657 if (!radeon_connector
->edid
) {
658 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
659 drm_get_connector_name(connector
));
660 ret
= connector_status_connected
;
662 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
664 /* some oems have boards with separate digital and analog connectors
665 * with a shared ddc line (often vga + hdmi)
667 if (radeon_connector
->use_digital
&& radeon_connector
->shared_ddc
) {
668 kfree(radeon_connector
->edid
);
669 radeon_connector
->edid
= NULL
;
670 ret
= connector_status_disconnected
;
672 ret
= connector_status_connected
;
676 /* if we aren't forcing don't do destructive polling */
678 return connector
->status
;
680 if (radeon_connector
->dac_load_detect
&& encoder
) {
681 encoder_funcs
= encoder
->helper_private
;
682 ret
= encoder_funcs
->detect(encoder
, connector
);
686 if (ret
== connector_status_connected
)
687 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
689 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
690 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
691 * by other means, assume the CRT is connected and use that EDID.
693 if ((!rdev
->is_atom_bios
) &&
694 (ret
== connector_status_disconnected
) &&
695 rdev
->mode_info
.bios_hardcoded_edid_size
) {
696 ret
= connector_status_connected
;
699 radeon_connector_update_scratch_regs(connector
, ret
);
703 struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs
= {
704 .get_modes
= radeon_vga_get_modes
,
705 .mode_valid
= radeon_vga_mode_valid
,
706 .best_encoder
= radeon_best_single_encoder
,
709 struct drm_connector_funcs radeon_vga_connector_funcs
= {
710 .dpms
= drm_helper_connector_dpms
,
711 .detect
= radeon_vga_detect
,
712 .fill_modes
= drm_helper_probe_single_connector_modes
,
713 .destroy
= radeon_connector_destroy
,
714 .set_property
= radeon_connector_set_property
,
717 static int radeon_tv_get_modes(struct drm_connector
*connector
)
719 struct drm_device
*dev
= connector
->dev
;
720 struct radeon_device
*rdev
= dev
->dev_private
;
721 struct drm_display_mode
*tv_mode
;
722 struct drm_encoder
*encoder
;
724 encoder
= radeon_best_single_encoder(connector
);
728 /* avivo chips can scale any mode */
729 if (rdev
->family
>= CHIP_RS600
)
730 /* add scaled modes */
731 radeon_add_common_modes(encoder
, connector
);
733 /* only 800x600 is supported right now on pre-avivo chips */
734 tv_mode
= drm_cvt_mode(dev
, 800, 600, 60, false, false, false);
735 tv_mode
->type
= DRM_MODE_TYPE_DRIVER
| DRM_MODE_TYPE_PREFERRED
;
736 drm_mode_probed_add(connector
, tv_mode
);
741 static int radeon_tv_mode_valid(struct drm_connector
*connector
,
742 struct drm_display_mode
*mode
)
744 if ((mode
->hdisplay
> 1024) || (mode
->vdisplay
> 768))
745 return MODE_CLOCK_RANGE
;
749 static enum drm_connector_status
750 radeon_tv_detect(struct drm_connector
*connector
, bool force
)
752 struct drm_encoder
*encoder
;
753 struct drm_encoder_helper_funcs
*encoder_funcs
;
754 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
755 enum drm_connector_status ret
= connector_status_disconnected
;
757 if (!radeon_connector
->dac_load_detect
)
760 encoder
= radeon_best_single_encoder(connector
);
762 ret
= connector_status_disconnected
;
764 encoder_funcs
= encoder
->helper_private
;
765 ret
= encoder_funcs
->detect(encoder
, connector
);
767 if (ret
== connector_status_connected
)
768 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, false);
769 radeon_connector_update_scratch_regs(connector
, ret
);
773 struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs
= {
774 .get_modes
= radeon_tv_get_modes
,
775 .mode_valid
= radeon_tv_mode_valid
,
776 .best_encoder
= radeon_best_single_encoder
,
779 struct drm_connector_funcs radeon_tv_connector_funcs
= {
780 .dpms
= drm_helper_connector_dpms
,
781 .detect
= radeon_tv_detect
,
782 .fill_modes
= drm_helper_probe_single_connector_modes
,
783 .destroy
= radeon_connector_destroy
,
784 .set_property
= radeon_connector_set_property
,
787 static int radeon_dvi_get_modes(struct drm_connector
*connector
)
789 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
792 ret
= radeon_ddc_get_modes(radeon_connector
);
798 * Do a DDC probe, if DDC probe passes, get the full EDID so
799 * we can do analog/digital monitor detection at this point.
800 * If the monitor is an analog monitor or we got no DDC,
801 * we need to find the DAC encoder object for this connector.
802 * If we got no DDC, we do load detection on the DAC encoder object.
803 * If we got analog DDC or load detection passes on the DAC encoder
804 * we have to check if this analog encoder is shared with anyone else (TV)
805 * if its shared we have to set the other connector to disconnected.
807 static enum drm_connector_status
808 radeon_dvi_detect(struct drm_connector
*connector
, bool force
)
810 struct drm_device
*dev
= connector
->dev
;
811 struct radeon_device
*rdev
= dev
->dev_private
;
812 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
813 struct drm_encoder
*encoder
= NULL
;
814 struct drm_encoder_helper_funcs
*encoder_funcs
;
815 struct drm_mode_object
*obj
;
817 enum drm_connector_status ret
= connector_status_disconnected
;
820 if (radeon_connector
->ddc_bus
)
821 dret
= radeon_ddc_probe(radeon_connector
);
823 if (radeon_connector
->edid
) {
824 kfree(radeon_connector
->edid
);
825 radeon_connector
->edid
= NULL
;
827 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
829 if (!radeon_connector
->edid
) {
830 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
831 drm_get_connector_name(connector
));
833 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
835 /* some oems have boards with separate digital and analog connectors
836 * with a shared ddc line (often vga + hdmi)
838 if ((!radeon_connector
->use_digital
) && radeon_connector
->shared_ddc
) {
839 kfree(radeon_connector
->edid
);
840 radeon_connector
->edid
= NULL
;
841 ret
= connector_status_disconnected
;
843 ret
= connector_status_connected
;
845 /* This gets complicated. We have boards with VGA + HDMI with a
846 * shared DDC line and we have boards with DVI-D + HDMI with a shared
847 * DDC line. The latter is more complex because with DVI<->HDMI adapters
848 * you don't really know what's connected to which port as both are digital.
850 if (radeon_connector
->shared_ddc
&& (ret
== connector_status_connected
)) {
851 struct drm_connector
*list_connector
;
852 struct radeon_connector
*list_radeon_connector
;
853 list_for_each_entry(list_connector
, &dev
->mode_config
.connector_list
, head
) {
854 if (connector
== list_connector
)
856 list_radeon_connector
= to_radeon_connector(list_connector
);
857 if (list_radeon_connector
->shared_ddc
&&
858 (list_radeon_connector
->ddc_bus
->rec
.i2c_id
==
859 radeon_connector
->ddc_bus
->rec
.i2c_id
)) {
860 /* cases where both connectors are digital */
861 if (list_connector
->connector_type
!= DRM_MODE_CONNECTOR_VGA
) {
862 /* hpd is our only option in this case */
863 if (!radeon_hpd_sense(rdev
, radeon_connector
->hpd
.hpd
)) {
864 kfree(radeon_connector
->edid
);
865 radeon_connector
->edid
= NULL
;
866 ret
= connector_status_disconnected
;
875 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== true))
879 ret
= connector
->status
;
883 /* find analog encoder */
884 if (radeon_connector
->dac_load_detect
) {
885 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
886 if (connector
->encoder_ids
[i
] == 0)
889 obj
= drm_mode_object_find(connector
->dev
,
890 connector
->encoder_ids
[i
],
891 DRM_MODE_OBJECT_ENCODER
);
895 encoder
= obj_to_encoder(obj
);
897 encoder_funcs
= encoder
->helper_private
;
898 if (encoder_funcs
->detect
) {
899 if (ret
!= connector_status_connected
) {
900 ret
= encoder_funcs
->detect(encoder
, connector
);
901 if (ret
== connector_status_connected
) {
902 radeon_connector
->use_digital
= false;
910 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== false) &&
912 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
915 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
916 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
917 * by other means, assume the DFP is connected and use that EDID. In most
918 * cases the DVI port is actually a virtual KVM port connected to the service
921 if ((!rdev
->is_atom_bios
) &&
922 (ret
== connector_status_disconnected
) &&
923 rdev
->mode_info
.bios_hardcoded_edid_size
) {
924 radeon_connector
->use_digital
= true;
925 ret
= connector_status_connected
;
929 /* updated in get modes as well since we need to know if it's analog or digital */
930 radeon_connector_update_scratch_regs(connector
, ret
);
934 /* okay need to be smart in here about which encoder to pick */
935 struct drm_encoder
*radeon_dvi_encoder(struct drm_connector
*connector
)
937 int enc_id
= connector
->encoder_ids
[0];
938 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
939 struct drm_mode_object
*obj
;
940 struct drm_encoder
*encoder
;
942 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
943 if (connector
->encoder_ids
[i
] == 0)
946 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
950 encoder
= obj_to_encoder(obj
);
952 if (radeon_connector
->use_digital
== true) {
953 if (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)
956 if (encoder
->encoder_type
== DRM_MODE_ENCODER_DAC
||
957 encoder
->encoder_type
== DRM_MODE_ENCODER_TVDAC
)
962 /* see if we have a default encoder TODO */
964 /* then check use digitial */
965 /* pick the first one */
967 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
970 encoder
= obj_to_encoder(obj
);
976 static void radeon_dvi_force(struct drm_connector
*connector
)
978 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
979 if (connector
->force
== DRM_FORCE_ON
)
980 radeon_connector
->use_digital
= false;
981 if (connector
->force
== DRM_FORCE_ON_DIGITAL
)
982 radeon_connector
->use_digital
= true;
985 static int radeon_dvi_mode_valid(struct drm_connector
*connector
,
986 struct drm_display_mode
*mode
)
988 struct drm_device
*dev
= connector
->dev
;
989 struct radeon_device
*rdev
= dev
->dev_private
;
990 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
992 /* XXX check mode bandwidth */
994 /* clocks over 135 MHz have heat issues with DVI on RV100 */
995 if (radeon_connector
->use_digital
&&
996 (rdev
->family
== CHIP_RV100
) &&
997 (mode
->clock
> 135000))
998 return MODE_CLOCK_HIGH
;
1000 if (radeon_connector
->use_digital
&& (mode
->clock
> 165000)) {
1001 if ((radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
) ||
1002 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
) ||
1003 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_B
))
1005 else if (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_A
) {
1006 if (ASIC_IS_DCE3(rdev
)) {
1007 /* HDMI 1.3+ supports max clock of 340 Mhz */
1008 if (mode
->clock
> 340000)
1009 return MODE_CLOCK_HIGH
;
1013 return MODE_CLOCK_HIGH
;
1015 return MODE_CLOCK_HIGH
;
1020 struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs
= {
1021 .get_modes
= radeon_dvi_get_modes
,
1022 .mode_valid
= radeon_dvi_mode_valid
,
1023 .best_encoder
= radeon_dvi_encoder
,
1026 struct drm_connector_funcs radeon_dvi_connector_funcs
= {
1027 .dpms
= drm_helper_connector_dpms
,
1028 .detect
= radeon_dvi_detect
,
1029 .fill_modes
= drm_helper_probe_single_connector_modes
,
1030 .set_property
= radeon_connector_set_property
,
1031 .destroy
= radeon_connector_destroy
,
1032 .force
= radeon_dvi_force
,
1035 static void radeon_dp_connector_destroy(struct drm_connector
*connector
)
1037 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1038 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1040 if (radeon_connector
->edid
)
1041 kfree(radeon_connector
->edid
);
1042 if (radeon_dig_connector
->dp_i2c_bus
)
1043 radeon_i2c_destroy(radeon_dig_connector
->dp_i2c_bus
);
1044 kfree(radeon_connector
->con_priv
);
1045 drm_sysfs_connector_remove(connector
);
1046 drm_connector_cleanup(connector
);
1050 static int radeon_dp_get_modes(struct drm_connector
*connector
)
1052 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1053 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1056 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) {
1057 if (!radeon_dig_connector
->edp_on
)
1058 atombios_set_edp_panel_power(connector
,
1059 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1061 ret
= radeon_ddc_get_modes(radeon_connector
);
1062 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) {
1063 if (!radeon_dig_connector
->edp_on
)
1064 atombios_set_edp_panel_power(connector
,
1065 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1071 static enum drm_connector_status
1072 radeon_dp_detect(struct drm_connector
*connector
, bool force
)
1074 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1075 enum drm_connector_status ret
= connector_status_disconnected
;
1076 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1078 if (radeon_connector
->edid
) {
1079 kfree(radeon_connector
->edid
);
1080 radeon_connector
->edid
= NULL
;
1083 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) {
1084 /* eDP is always DP */
1085 radeon_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1086 if (!radeon_dig_connector
->edp_on
)
1087 atombios_set_edp_panel_power(connector
,
1088 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1089 if (radeon_dp_getdpcd(radeon_connector
))
1090 ret
= connector_status_connected
;
1091 if (!radeon_dig_connector
->edp_on
)
1092 atombios_set_edp_panel_power(connector
,
1093 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1095 radeon_dig_connector
->dp_sink_type
= radeon_dp_getsinktype(radeon_connector
);
1096 if (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
1097 if (radeon_dp_getdpcd(radeon_connector
))
1098 ret
= connector_status_connected
;
1100 if (radeon_ddc_probe(radeon_connector
))
1101 ret
= connector_status_connected
;
1105 radeon_connector_update_scratch_regs(connector
, ret
);
1109 static int radeon_dp_mode_valid(struct drm_connector
*connector
,
1110 struct drm_display_mode
*mode
)
1112 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1113 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1115 /* XXX check mode bandwidth */
1117 if ((radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
1118 (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
))
1119 return radeon_dp_mode_valid_helper(radeon_connector
, mode
);
1124 struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs
= {
1125 .get_modes
= radeon_dp_get_modes
,
1126 .mode_valid
= radeon_dp_mode_valid
,
1127 .best_encoder
= radeon_dvi_encoder
,
1130 struct drm_connector_funcs radeon_dp_connector_funcs
= {
1131 .dpms
= drm_helper_connector_dpms
,
1132 .detect
= radeon_dp_detect
,
1133 .fill_modes
= drm_helper_probe_single_connector_modes
,
1134 .set_property
= radeon_connector_set_property
,
1135 .destroy
= radeon_dp_connector_destroy
,
1136 .force
= radeon_dvi_force
,
1140 radeon_add_atom_connector(struct drm_device
*dev
,
1141 uint32_t connector_id
,
1142 uint32_t supported_device
,
1144 struct radeon_i2c_bus_rec
*i2c_bus
,
1145 uint32_t igp_lane_info
,
1146 uint16_t connector_object_id
,
1147 struct radeon_hpd
*hpd
,
1148 struct radeon_router
*router
)
1150 struct radeon_device
*rdev
= dev
->dev_private
;
1151 struct drm_connector
*connector
;
1152 struct radeon_connector
*radeon_connector
;
1153 struct radeon_connector_atom_dig
*radeon_dig_connector
;
1154 uint32_t subpixel_order
= SubPixelNone
;
1155 bool shared_ddc
= false;
1157 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1160 /* if the user selected tv=0 don't try and add the connector */
1161 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1162 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1163 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1167 /* see if we already added it */
1168 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1169 radeon_connector
= to_radeon_connector(connector
);
1170 if (radeon_connector
->connector_id
== connector_id
) {
1171 radeon_connector
->devices
|= supported_device
;
1174 if (radeon_connector
->ddc_bus
&& i2c_bus
->valid
) {
1175 if (radeon_connector
->ddc_bus
->rec
.i2c_id
== i2c_bus
->i2c_id
) {
1176 radeon_connector
->shared_ddc
= true;
1179 if (radeon_connector
->router_bus
&& router
->ddc_valid
&&
1180 (radeon_connector
->router
.router_id
== router
->router_id
)) {
1181 radeon_connector
->shared_ddc
= false;
1187 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1188 if (!radeon_connector
)
1191 connector
= &radeon_connector
->base
;
1193 radeon_connector
->connector_id
= connector_id
;
1194 radeon_connector
->devices
= supported_device
;
1195 radeon_connector
->shared_ddc
= shared_ddc
;
1196 radeon_connector
->connector_object_id
= connector_object_id
;
1197 radeon_connector
->hpd
= *hpd
;
1198 radeon_connector
->router
= *router
;
1199 if (router
->ddc_valid
|| router
->cd_valid
) {
1200 radeon_connector
->router_bus
= radeon_i2c_lookup(rdev
, &router
->i2c_info
);
1201 if (!radeon_connector
->router_bus
)
1204 switch (connector_type
) {
1205 case DRM_MODE_CONNECTOR_VGA
:
1206 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1207 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1208 if (i2c_bus
->valid
) {
1209 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1210 if (!radeon_connector
->ddc_bus
)
1213 radeon_connector
->dac_load_detect
= true;
1214 drm_connector_attach_property(&radeon_connector
->base
,
1215 rdev
->mode_info
.load_detect_property
,
1217 /* no HPD on analog connectors */
1218 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1219 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1220 connector
->interlace_allowed
= true;
1221 connector
->doublescan_allowed
= true;
1223 case DRM_MODE_CONNECTOR_DVIA
:
1224 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1225 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1226 if (i2c_bus
->valid
) {
1227 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1228 if (!radeon_connector
->ddc_bus
)
1231 radeon_connector
->dac_load_detect
= true;
1232 drm_connector_attach_property(&radeon_connector
->base
,
1233 rdev
->mode_info
.load_detect_property
,
1235 /* no HPD on analog connectors */
1236 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1237 connector
->interlace_allowed
= true;
1238 connector
->doublescan_allowed
= true;
1240 case DRM_MODE_CONNECTOR_DVII
:
1241 case DRM_MODE_CONNECTOR_DVID
:
1242 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1243 if (!radeon_dig_connector
)
1245 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1246 radeon_connector
->con_priv
= radeon_dig_connector
;
1247 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1248 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1249 if (i2c_bus
->valid
) {
1250 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1251 if (!radeon_connector
->ddc_bus
)
1254 subpixel_order
= SubPixelHorizontalRGB
;
1255 drm_connector_attach_property(&radeon_connector
->base
,
1256 rdev
->mode_info
.coherent_mode_property
,
1258 if (ASIC_IS_AVIVO(rdev
)) {
1259 drm_connector_attach_property(&radeon_connector
->base
,
1260 rdev
->mode_info
.underscan_property
,
1262 drm_connector_attach_property(&radeon_connector
->base
,
1263 rdev
->mode_info
.underscan_hborder_property
,
1265 drm_connector_attach_property(&radeon_connector
->base
,
1266 rdev
->mode_info
.underscan_vborder_property
,
1269 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1270 radeon_connector
->dac_load_detect
= true;
1271 drm_connector_attach_property(&radeon_connector
->base
,
1272 rdev
->mode_info
.load_detect_property
,
1275 connector
->interlace_allowed
= true;
1276 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
1277 connector
->doublescan_allowed
= true;
1279 connector
->doublescan_allowed
= false;
1281 case DRM_MODE_CONNECTOR_HDMIA
:
1282 case DRM_MODE_CONNECTOR_HDMIB
:
1283 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1284 if (!radeon_dig_connector
)
1286 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1287 radeon_connector
->con_priv
= radeon_dig_connector
;
1288 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1289 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1290 if (i2c_bus
->valid
) {
1291 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1292 if (!radeon_connector
->ddc_bus
)
1295 drm_connector_attach_property(&radeon_connector
->base
,
1296 rdev
->mode_info
.coherent_mode_property
,
1298 if (ASIC_IS_AVIVO(rdev
)) {
1299 drm_connector_attach_property(&radeon_connector
->base
,
1300 rdev
->mode_info
.underscan_property
,
1302 drm_connector_attach_property(&radeon_connector
->base
,
1303 rdev
->mode_info
.underscan_hborder_property
,
1305 drm_connector_attach_property(&radeon_connector
->base
,
1306 rdev
->mode_info
.underscan_vborder_property
,
1309 subpixel_order
= SubPixelHorizontalRGB
;
1310 connector
->interlace_allowed
= true;
1311 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1312 connector
->doublescan_allowed
= true;
1314 connector
->doublescan_allowed
= false;
1316 case DRM_MODE_CONNECTOR_DisplayPort
:
1317 case DRM_MODE_CONNECTOR_eDP
:
1318 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1319 if (!radeon_dig_connector
)
1321 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1322 radeon_connector
->con_priv
= radeon_dig_connector
;
1323 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1324 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1325 if (i2c_bus
->valid
) {
1326 /* add DP i2c bus */
1327 if (connector_type
== DRM_MODE_CONNECTOR_eDP
)
1328 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1330 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1331 if (!radeon_dig_connector
->dp_i2c_bus
)
1333 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1334 if (!radeon_connector
->ddc_bus
)
1337 subpixel_order
= SubPixelHorizontalRGB
;
1338 drm_connector_attach_property(&radeon_connector
->base
,
1339 rdev
->mode_info
.coherent_mode_property
,
1341 if (ASIC_IS_AVIVO(rdev
)) {
1342 drm_connector_attach_property(&radeon_connector
->base
,
1343 rdev
->mode_info
.underscan_property
,
1345 drm_connector_attach_property(&radeon_connector
->base
,
1346 rdev
->mode_info
.underscan_hborder_property
,
1348 drm_connector_attach_property(&radeon_connector
->base
,
1349 rdev
->mode_info
.underscan_vborder_property
,
1352 connector
->interlace_allowed
= true;
1353 /* in theory with a DP to VGA converter... */
1354 connector
->doublescan_allowed
= false;
1356 case DRM_MODE_CONNECTOR_SVIDEO
:
1357 case DRM_MODE_CONNECTOR_Composite
:
1358 case DRM_MODE_CONNECTOR_9PinDIN
:
1359 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1360 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1361 radeon_connector
->dac_load_detect
= true;
1362 drm_connector_attach_property(&radeon_connector
->base
,
1363 rdev
->mode_info
.load_detect_property
,
1365 drm_connector_attach_property(&radeon_connector
->base
,
1366 rdev
->mode_info
.tv_std_property
,
1367 radeon_atombios_get_tv_info(rdev
));
1368 /* no HPD on analog connectors */
1369 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1370 connector
->interlace_allowed
= false;
1371 connector
->doublescan_allowed
= false;
1373 case DRM_MODE_CONNECTOR_LVDS
:
1374 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1375 if (!radeon_dig_connector
)
1377 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1378 radeon_connector
->con_priv
= radeon_dig_connector
;
1379 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1380 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1381 if (i2c_bus
->valid
) {
1382 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1383 if (!radeon_connector
->ddc_bus
)
1386 drm_connector_attach_property(&radeon_connector
->base
,
1387 dev
->mode_config
.scaling_mode_property
,
1388 DRM_MODE_SCALE_FULLSCREEN
);
1389 subpixel_order
= SubPixelHorizontalRGB
;
1390 connector
->interlace_allowed
= false;
1391 connector
->doublescan_allowed
= false;
1395 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
1397 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1399 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
1401 connector
->display_info
.subpixel_order
= subpixel_order
;
1402 drm_sysfs_connector_add(connector
);
1406 drm_connector_cleanup(connector
);
1411 radeon_add_legacy_connector(struct drm_device
*dev
,
1412 uint32_t connector_id
,
1413 uint32_t supported_device
,
1415 struct radeon_i2c_bus_rec
*i2c_bus
,
1416 uint16_t connector_object_id
,
1417 struct radeon_hpd
*hpd
)
1419 struct radeon_device
*rdev
= dev
->dev_private
;
1420 struct drm_connector
*connector
;
1421 struct radeon_connector
*radeon_connector
;
1422 uint32_t subpixel_order
= SubPixelNone
;
1424 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1427 /* if the user selected tv=0 don't try and add the connector */
1428 if (((connector_type
== DRM_MODE_CONNECTOR_SVIDEO
) ||
1429 (connector_type
== DRM_MODE_CONNECTOR_Composite
) ||
1430 (connector_type
== DRM_MODE_CONNECTOR_9PinDIN
)) &&
1434 /* see if we already added it */
1435 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1436 radeon_connector
= to_radeon_connector(connector
);
1437 if (radeon_connector
->connector_id
== connector_id
) {
1438 radeon_connector
->devices
|= supported_device
;
1443 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1444 if (!radeon_connector
)
1447 connector
= &radeon_connector
->base
;
1449 radeon_connector
->connector_id
= connector_id
;
1450 radeon_connector
->devices
= supported_device
;
1451 radeon_connector
->connector_object_id
= connector_object_id
;
1452 radeon_connector
->hpd
= *hpd
;
1453 switch (connector_type
) {
1454 case DRM_MODE_CONNECTOR_VGA
:
1455 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1456 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1457 if (i2c_bus
->valid
) {
1458 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1459 if (!radeon_connector
->ddc_bus
)
1462 radeon_connector
->dac_load_detect
= true;
1463 drm_connector_attach_property(&radeon_connector
->base
,
1464 rdev
->mode_info
.load_detect_property
,
1466 /* no HPD on analog connectors */
1467 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1468 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1469 connector
->interlace_allowed
= true;
1470 connector
->doublescan_allowed
= true;
1472 case DRM_MODE_CONNECTOR_DVIA
:
1473 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1474 drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1475 if (i2c_bus
->valid
) {
1476 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1477 if (!radeon_connector
->ddc_bus
)
1480 radeon_connector
->dac_load_detect
= true;
1481 drm_connector_attach_property(&radeon_connector
->base
,
1482 rdev
->mode_info
.load_detect_property
,
1484 /* no HPD on analog connectors */
1485 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1486 connector
->interlace_allowed
= true;
1487 connector
->doublescan_allowed
= true;
1489 case DRM_MODE_CONNECTOR_DVII
:
1490 case DRM_MODE_CONNECTOR_DVID
:
1491 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1492 drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1493 if (i2c_bus
->valid
) {
1494 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1495 if (!radeon_connector
->ddc_bus
)
1498 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1499 radeon_connector
->dac_load_detect
= true;
1500 drm_connector_attach_property(&radeon_connector
->base
,
1501 rdev
->mode_info
.load_detect_property
,
1504 subpixel_order
= SubPixelHorizontalRGB
;
1505 connector
->interlace_allowed
= true;
1506 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
1507 connector
->doublescan_allowed
= true;
1509 connector
->doublescan_allowed
= false;
1511 case DRM_MODE_CONNECTOR_SVIDEO
:
1512 case DRM_MODE_CONNECTOR_Composite
:
1513 case DRM_MODE_CONNECTOR_9PinDIN
:
1514 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1515 drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1516 radeon_connector
->dac_load_detect
= true;
1517 /* RS400,RC410,RS480 chipset seems to report a lot
1518 * of false positive on load detect, we haven't yet
1519 * found a way to make load detect reliable on those
1520 * chipset, thus just disable it for TV.
1522 if (rdev
->family
== CHIP_RS400
|| rdev
->family
== CHIP_RS480
)
1523 radeon_connector
->dac_load_detect
= false;
1524 drm_connector_attach_property(&radeon_connector
->base
,
1525 rdev
->mode_info
.load_detect_property
,
1526 radeon_connector
->dac_load_detect
);
1527 drm_connector_attach_property(&radeon_connector
->base
,
1528 rdev
->mode_info
.tv_std_property
,
1529 radeon_combios_get_tv_info(rdev
));
1530 /* no HPD on analog connectors */
1531 radeon_connector
->hpd
.hpd
= RADEON_HPD_NONE
;
1532 connector
->interlace_allowed
= false;
1533 connector
->doublescan_allowed
= false;
1535 case DRM_MODE_CONNECTOR_LVDS
:
1536 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1537 drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1538 if (i2c_bus
->valid
) {
1539 radeon_connector
->ddc_bus
= radeon_i2c_lookup(rdev
, i2c_bus
);
1540 if (!radeon_connector
->ddc_bus
)
1543 drm_connector_attach_property(&radeon_connector
->base
,
1544 dev
->mode_config
.scaling_mode_property
,
1545 DRM_MODE_SCALE_FULLSCREEN
);
1546 subpixel_order
= SubPixelHorizontalRGB
;
1547 connector
->interlace_allowed
= false;
1548 connector
->doublescan_allowed
= false;
1552 if (radeon_connector
->hpd
.hpd
== RADEON_HPD_NONE
) {
1554 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
;
1556 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
1557 connector
->display_info
.subpixel_order
= subpixel_order
;
1558 drm_sysfs_connector_add(connector
);
1559 if (connector_type
== DRM_MODE_CONNECTOR_LVDS
) {
1560 struct drm_encoder
*drm_encoder
;
1562 list_for_each_entry(drm_encoder
, &dev
->mode_config
.encoder_list
, head
) {
1563 struct radeon_encoder
*radeon_encoder
;
1565 radeon_encoder
= to_radeon_encoder(drm_encoder
);
1566 if (radeon_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_LVDS
)
1567 radeon_legacy_backlight_init(radeon_encoder
, connector
);
1573 drm_connector_cleanup(connector
);