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
,
43 void radeon_connector_hotplug(struct drm_connector
*connector
)
45 struct drm_device
*dev
= connector
->dev
;
46 struct radeon_device
*rdev
= dev
->dev_private
;
47 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
49 if (radeon_connector
->hpd
.hpd
!= RADEON_HPD_NONE
)
50 radeon_hpd_set_polarity(rdev
, radeon_connector
->hpd
.hpd
);
52 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
) ||
53 (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
)) {
54 if ((radeon_dp_getsinktype(radeon_connector
) == CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
55 (radeon_dp_getsinktype(radeon_connector
) == CONNECTOR_OBJECT_ID_eDP
)) {
56 if (radeon_dp_needs_link_train(radeon_connector
)) {
57 if (connector
->encoder
)
58 dp_link_train(connector
->encoder
, connector
);
65 static void radeon_property_change_mode(struct drm_encoder
*encoder
)
67 struct drm_crtc
*crtc
= encoder
->crtc
;
69 if (crtc
&& crtc
->enabled
) {
70 drm_crtc_helper_set_mode(crtc
, &crtc
->mode
,
71 crtc
->x
, crtc
->y
, crtc
->fb
);
75 radeon_connector_update_scratch_regs(struct drm_connector
*connector
, enum drm_connector_status status
)
77 struct drm_device
*dev
= connector
->dev
;
78 struct radeon_device
*rdev
= dev
->dev_private
;
79 struct drm_encoder
*best_encoder
= NULL
;
80 struct drm_encoder
*encoder
= NULL
;
81 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
82 struct drm_mode_object
*obj
;
86 best_encoder
= connector_funcs
->best_encoder(connector
);
88 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
89 if (connector
->encoder_ids
[i
] == 0)
92 obj
= drm_mode_object_find(connector
->dev
,
93 connector
->encoder_ids
[i
],
94 DRM_MODE_OBJECT_ENCODER
);
98 encoder
= obj_to_encoder(obj
);
100 if ((encoder
== best_encoder
) && (status
== connector_status_connected
))
105 if (rdev
->is_atom_bios
)
106 radeon_atombios_connected_scratch_regs(connector
, encoder
, connected
);
108 radeon_combios_connected_scratch_regs(connector
, encoder
, connected
);
113 struct drm_encoder
*radeon_find_encoder(struct drm_connector
*connector
, int encoder_type
)
115 struct drm_mode_object
*obj
;
116 struct drm_encoder
*encoder
;
119 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
120 if (connector
->encoder_ids
[i
] == 0)
123 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
127 encoder
= obj_to_encoder(obj
);
128 if (encoder
->encoder_type
== encoder_type
)
134 struct drm_encoder
*radeon_best_single_encoder(struct drm_connector
*connector
)
136 int enc_id
= connector
->encoder_ids
[0];
137 struct drm_mode_object
*obj
;
138 struct drm_encoder
*encoder
;
140 /* pick the encoder ids */
142 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
145 encoder
= obj_to_encoder(obj
);
152 * radeon_connector_analog_encoder_conflict_solve
153 * - search for other connectors sharing this encoder
154 * if priority is true, then set them disconnected if this is connected
155 * if priority is false, set us disconnected if they are connected
157 static enum drm_connector_status
158 radeon_connector_analog_encoder_conflict_solve(struct drm_connector
*connector
,
159 struct drm_encoder
*encoder
,
160 enum drm_connector_status current_status
,
163 struct drm_device
*dev
= connector
->dev
;
164 struct drm_connector
*conflict
;
167 list_for_each_entry(conflict
, &dev
->mode_config
.connector_list
, head
) {
168 if (conflict
== connector
)
171 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
172 if (conflict
->encoder_ids
[i
] == 0)
175 /* if the IDs match */
176 if (conflict
->encoder_ids
[i
] == encoder
->base
.id
) {
177 if (conflict
->status
!= connector_status_connected
)
180 if (priority
== true) {
181 DRM_INFO("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict
));
182 DRM_INFO("in favor of %s\n", drm_get_connector_name(connector
));
183 conflict
->status
= connector_status_disconnected
;
184 radeon_connector_update_scratch_regs(conflict
, connector_status_disconnected
);
186 DRM_INFO("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector
));
187 DRM_INFO("in favor of %s\n", drm_get_connector_name(conflict
));
188 current_status
= connector_status_disconnected
;
194 return current_status
;
198 static struct drm_display_mode
*radeon_fp_native_mode(struct drm_encoder
*encoder
)
200 struct drm_device
*dev
= encoder
->dev
;
201 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
202 struct drm_display_mode
*mode
= NULL
;
203 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
205 if (native_mode
->hdisplay
!= 0 &&
206 native_mode
->vdisplay
!= 0 &&
207 native_mode
->clock
!= 0) {
208 mode
= drm_mode_duplicate(dev
, native_mode
);
209 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
210 drm_mode_set_name(mode
);
212 DRM_DEBUG("Adding native panel mode %s\n", mode
->name
);
213 } else if (native_mode
->hdisplay
!= 0 &&
214 native_mode
->vdisplay
!= 0) {
215 /* mac laptops without an edid */
216 /* Note that this is not necessarily the exact panel mode,
217 * but an approximation based on the cvt formula. For these
218 * systems we should ideally read the mode info out of the
219 * registers or add a mode table, but this works and is much
222 mode
= drm_cvt_mode(dev
, native_mode
->hdisplay
, native_mode
->vdisplay
, 60, true, false, false);
223 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
224 DRM_DEBUG("Adding cvt approximation of native panel mode %s\n", mode
->name
);
229 static void radeon_add_common_modes(struct drm_encoder
*encoder
, struct drm_connector
*connector
)
231 struct drm_device
*dev
= encoder
->dev
;
232 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
233 struct drm_display_mode
*mode
= NULL
;
234 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
239 } common_modes
[17] = {
259 for (i
= 0; i
< 17; i
++) {
260 if (radeon_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
)) {
261 if (common_modes
[i
].w
> 1024 ||
262 common_modes
[i
].h
> 768)
265 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
266 if (common_modes
[i
].w
> native_mode
->hdisplay
||
267 common_modes
[i
].h
> native_mode
->vdisplay
||
268 (common_modes
[i
].w
== native_mode
->hdisplay
&&
269 common_modes
[i
].h
== native_mode
->vdisplay
))
272 if (common_modes
[i
].w
< 320 || common_modes
[i
].h
< 200)
275 mode
= drm_cvt_mode(dev
, common_modes
[i
].w
, common_modes
[i
].h
, 60, false, false, false);
276 drm_mode_probed_add(connector
, mode
);
280 int radeon_connector_set_property(struct drm_connector
*connector
, struct drm_property
*property
,
283 struct drm_device
*dev
= connector
->dev
;
284 struct radeon_device
*rdev
= dev
->dev_private
;
285 struct drm_encoder
*encoder
;
286 struct radeon_encoder
*radeon_encoder
;
288 if (property
== rdev
->mode_info
.coherent_mode_property
) {
289 struct radeon_encoder_atom_dig
*dig
;
291 /* need to find digital encoder on connector */
292 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
296 radeon_encoder
= to_radeon_encoder(encoder
);
298 if (!radeon_encoder
->enc_priv
)
301 dig
= radeon_encoder
->enc_priv
;
302 dig
->coherent_mode
= val
? true : false;
303 radeon_property_change_mode(&radeon_encoder
->base
);
306 if (property
== rdev
->mode_info
.tv_std_property
) {
307 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TVDAC
);
309 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_DAC
);
315 radeon_encoder
= to_radeon_encoder(encoder
);
316 if (!radeon_encoder
->enc_priv
)
318 if (rdev
->is_atom_bios
) {
319 struct radeon_encoder_atom_dac
*dac_int
;
320 dac_int
= radeon_encoder
->enc_priv
;
321 dac_int
->tv_std
= val
;
323 struct radeon_encoder_tv_dac
*dac_int
;
324 dac_int
= radeon_encoder
->enc_priv
;
325 dac_int
->tv_std
= val
;
327 radeon_property_change_mode(&radeon_encoder
->base
);
330 if (property
== rdev
->mode_info
.load_detect_property
) {
331 struct radeon_connector
*radeon_connector
=
332 to_radeon_connector(connector
);
335 radeon_connector
->dac_load_detect
= false;
337 radeon_connector
->dac_load_detect
= true;
340 if (property
== rdev
->mode_info
.tmds_pll_property
) {
341 struct radeon_encoder_int_tmds
*tmds
= NULL
;
343 /* need to find digital encoder on connector */
344 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
348 radeon_encoder
= to_radeon_encoder(encoder
);
350 tmds
= radeon_encoder
->enc_priv
;
355 if (rdev
->is_atom_bios
)
356 ret
= radeon_atombios_get_tmds_info(radeon_encoder
, tmds
);
358 ret
= radeon_legacy_get_tmds_info_from_combios(radeon_encoder
, tmds
);
360 if (val
== 1 || ret
== false) {
361 radeon_legacy_get_tmds_info_from_table(radeon_encoder
, tmds
);
363 radeon_property_change_mode(&radeon_encoder
->base
);
369 static void radeon_fixup_lvds_native_mode(struct drm_encoder
*encoder
,
370 struct drm_connector
*connector
)
372 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
373 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
375 /* Try to get native mode details from EDID if necessary */
376 if (!native_mode
->clock
) {
377 struct drm_display_mode
*t
, *mode
;
379 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
380 if (mode
->hdisplay
== native_mode
->hdisplay
&&
381 mode
->vdisplay
== native_mode
->vdisplay
) {
382 *native_mode
= *mode
;
383 drm_mode_set_crtcinfo(native_mode
, CRTC_INTERLACE_HALVE_V
);
384 DRM_INFO("Determined LVDS native mode details from EDID\n");
389 if (!native_mode
->clock
) {
390 DRM_INFO("No LVDS native mode details, disabling RMX\n");
391 radeon_encoder
->rmx_type
= RMX_OFF
;
395 static int radeon_lvds_get_modes(struct drm_connector
*connector
)
397 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
398 struct drm_encoder
*encoder
;
400 struct drm_display_mode
*mode
;
402 if (radeon_connector
->ddc_bus
) {
403 ret
= radeon_ddc_get_modes(radeon_connector
);
405 encoder
= radeon_best_single_encoder(connector
);
407 radeon_fixup_lvds_native_mode(encoder
, connector
);
408 /* add scaled modes */
409 radeon_add_common_modes(encoder
, connector
);
415 encoder
= radeon_best_single_encoder(connector
);
419 /* we have no EDID modes */
420 mode
= radeon_fp_native_mode(encoder
);
423 drm_mode_probed_add(connector
, mode
);
424 /* add scaled modes */
425 radeon_add_common_modes(encoder
, connector
);
431 static int radeon_lvds_mode_valid(struct drm_connector
*connector
,
432 struct drm_display_mode
*mode
)
434 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
436 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
440 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
441 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
443 /* AVIVO hardware supports downscaling modes larger than the panel
444 * to the panel size, but I'm not sure this is desirable.
446 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
447 (mode
->vdisplay
> native_mode
->vdisplay
))
450 /* if scaling is disabled, block non-native modes */
451 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
452 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
453 (mode
->vdisplay
!= native_mode
->vdisplay
))
461 static enum drm_connector_status
radeon_lvds_detect(struct drm_connector
*connector
)
463 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
464 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
465 enum drm_connector_status ret
= connector_status_disconnected
;
468 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
469 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
471 /* check if panel is valid */
472 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
473 ret
= connector_status_connected
;
477 /* check for edid as well */
478 if (radeon_connector
->edid
)
479 ret
= connector_status_connected
;
481 if (radeon_connector
->ddc_bus
) {
482 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 1);
483 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
,
484 &radeon_connector
->ddc_bus
->adapter
);
485 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 0);
486 if (radeon_connector
->edid
)
487 ret
= connector_status_connected
;
490 /* check acpi lid status ??? */
492 radeon_connector_update_scratch_regs(connector
, ret
);
496 static void radeon_connector_destroy(struct drm_connector
*connector
)
498 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
500 if (radeon_connector
->ddc_bus
)
501 radeon_i2c_destroy(radeon_connector
->ddc_bus
);
502 if (radeon_connector
->edid
)
503 kfree(radeon_connector
->edid
);
504 kfree(radeon_connector
->con_priv
);
505 drm_sysfs_connector_remove(connector
);
506 drm_connector_cleanup(connector
);
510 static int radeon_lvds_set_property(struct drm_connector
*connector
,
511 struct drm_property
*property
,
514 struct drm_device
*dev
= connector
->dev
;
515 struct radeon_encoder
*radeon_encoder
;
516 enum radeon_rmx_type rmx_type
;
519 if (property
!= dev
->mode_config
.scaling_mode_property
)
522 if (connector
->encoder
)
523 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
525 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
526 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
530 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
531 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
532 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
534 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
536 if (radeon_encoder
->rmx_type
== rmx_type
)
539 radeon_encoder
->rmx_type
= rmx_type
;
541 radeon_property_change_mode(&radeon_encoder
->base
);
546 struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs
= {
547 .get_modes
= radeon_lvds_get_modes
,
548 .mode_valid
= radeon_lvds_mode_valid
,
549 .best_encoder
= radeon_best_single_encoder
,
552 struct drm_connector_funcs radeon_lvds_connector_funcs
= {
553 .dpms
= drm_helper_connector_dpms
,
554 .detect
= radeon_lvds_detect
,
555 .fill_modes
= drm_helper_probe_single_connector_modes
,
556 .destroy
= radeon_connector_destroy
,
557 .set_property
= radeon_lvds_set_property
,
560 static int radeon_vga_get_modes(struct drm_connector
*connector
)
562 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
565 ret
= radeon_ddc_get_modes(radeon_connector
);
570 static int radeon_vga_mode_valid(struct drm_connector
*connector
,
571 struct drm_display_mode
*mode
)
573 /* XXX check mode bandwidth */
574 /* XXX verify against max DAC output frequency */
578 static enum drm_connector_status
radeon_vga_detect(struct drm_connector
*connector
)
580 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
581 struct drm_encoder
*encoder
;
582 struct drm_encoder_helper_funcs
*encoder_funcs
;
584 enum drm_connector_status ret
= connector_status_disconnected
;
586 encoder
= radeon_best_single_encoder(connector
);
588 ret
= connector_status_disconnected
;
590 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 1);
591 dret
= radeon_ddc_probe(radeon_connector
);
592 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 0);
594 if (radeon_connector
->edid
) {
595 kfree(radeon_connector
->edid
);
596 radeon_connector
->edid
= NULL
;
598 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 1);
599 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
600 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 0);
602 if (!radeon_connector
->edid
) {
603 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
604 drm_get_connector_name(connector
));
605 ret
= connector_status_connected
;
607 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
609 /* some oems have boards with separate digital and analog connectors
610 * with a shared ddc line (often vga + hdmi)
612 if (radeon_connector
->use_digital
&& radeon_connector
->shared_ddc
) {
613 kfree(radeon_connector
->edid
);
614 radeon_connector
->edid
= NULL
;
615 ret
= connector_status_disconnected
;
617 ret
= connector_status_connected
;
620 if (radeon_connector
->dac_load_detect
&& encoder
) {
621 encoder_funcs
= encoder
->helper_private
;
622 ret
= encoder_funcs
->detect(encoder
, connector
);
626 if (ret
== connector_status_connected
)
627 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
628 radeon_connector_update_scratch_regs(connector
, ret
);
632 struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs
= {
633 .get_modes
= radeon_vga_get_modes
,
634 .mode_valid
= radeon_vga_mode_valid
,
635 .best_encoder
= radeon_best_single_encoder
,
638 struct drm_connector_funcs radeon_vga_connector_funcs
= {
639 .dpms
= drm_helper_connector_dpms
,
640 .detect
= radeon_vga_detect
,
641 .fill_modes
= drm_helper_probe_single_connector_modes
,
642 .destroy
= radeon_connector_destroy
,
643 .set_property
= radeon_connector_set_property
,
646 static int radeon_tv_get_modes(struct drm_connector
*connector
)
648 struct drm_device
*dev
= connector
->dev
;
649 struct radeon_device
*rdev
= dev
->dev_private
;
650 struct drm_display_mode
*tv_mode
;
651 struct drm_encoder
*encoder
;
653 encoder
= radeon_best_single_encoder(connector
);
657 /* avivo chips can scale any mode */
658 if (rdev
->family
>= CHIP_RS600
)
659 /* add scaled modes */
660 radeon_add_common_modes(encoder
, connector
);
662 /* only 800x600 is supported right now on pre-avivo chips */
663 tv_mode
= drm_cvt_mode(dev
, 800, 600, 60, false, false, false);
664 tv_mode
->type
= DRM_MODE_TYPE_DRIVER
| DRM_MODE_TYPE_PREFERRED
;
665 drm_mode_probed_add(connector
, tv_mode
);
670 static int radeon_tv_mode_valid(struct drm_connector
*connector
,
671 struct drm_display_mode
*mode
)
673 if ((mode
->hdisplay
> 1024) || (mode
->vdisplay
> 768))
674 return MODE_CLOCK_RANGE
;
678 static enum drm_connector_status
radeon_tv_detect(struct drm_connector
*connector
)
680 struct drm_encoder
*encoder
;
681 struct drm_encoder_helper_funcs
*encoder_funcs
;
682 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
683 enum drm_connector_status ret
= connector_status_disconnected
;
685 if (!radeon_connector
->dac_load_detect
)
688 encoder
= radeon_best_single_encoder(connector
);
690 ret
= connector_status_disconnected
;
692 encoder_funcs
= encoder
->helper_private
;
693 ret
= encoder_funcs
->detect(encoder
, connector
);
695 if (ret
== connector_status_connected
)
696 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, false);
697 radeon_connector_update_scratch_regs(connector
, ret
);
701 struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs
= {
702 .get_modes
= radeon_tv_get_modes
,
703 .mode_valid
= radeon_tv_mode_valid
,
704 .best_encoder
= radeon_best_single_encoder
,
707 struct drm_connector_funcs radeon_tv_connector_funcs
= {
708 .dpms
= drm_helper_connector_dpms
,
709 .detect
= radeon_tv_detect
,
710 .fill_modes
= drm_helper_probe_single_connector_modes
,
711 .destroy
= radeon_connector_destroy
,
712 .set_property
= radeon_connector_set_property
,
715 static int radeon_dvi_get_modes(struct drm_connector
*connector
)
717 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
720 ret
= radeon_ddc_get_modes(radeon_connector
);
726 * Do a DDC probe, if DDC probe passes, get the full EDID so
727 * we can do analog/digital monitor detection at this point.
728 * If the monitor is an analog monitor or we got no DDC,
729 * we need to find the DAC encoder object for this connector.
730 * If we got no DDC, we do load detection on the DAC encoder object.
731 * If we got analog DDC or load detection passes on the DAC encoder
732 * we have to check if this analog encoder is shared with anyone else (TV)
733 * if its shared we have to set the other connector to disconnected.
735 static enum drm_connector_status
radeon_dvi_detect(struct drm_connector
*connector
)
737 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
738 struct drm_encoder
*encoder
= NULL
;
739 struct drm_encoder_helper_funcs
*encoder_funcs
;
740 struct drm_mode_object
*obj
;
742 enum drm_connector_status ret
= connector_status_disconnected
;
745 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 1);
746 dret
= radeon_ddc_probe(radeon_connector
);
747 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 0);
749 if (radeon_connector
->edid
) {
750 kfree(radeon_connector
->edid
);
751 radeon_connector
->edid
= NULL
;
753 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 1);
754 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
755 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 0);
757 if (!radeon_connector
->edid
) {
758 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
759 drm_get_connector_name(connector
));
761 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
763 /* some oems have boards with separate digital and analog connectors
764 * with a shared ddc line (often vga + hdmi)
766 if ((!radeon_connector
->use_digital
) && radeon_connector
->shared_ddc
) {
767 kfree(radeon_connector
->edid
);
768 radeon_connector
->edid
= NULL
;
769 ret
= connector_status_disconnected
;
771 ret
= connector_status_connected
;
773 /* multiple connectors on the same encoder with the same ddc line
774 * This tends to be HDMI and DVI on the same encoder with the
775 * same ddc line. If the edid says HDMI, consider the HDMI port
776 * connected and the DVI port disconnected. If the edid doesn't
777 * say HDMI, vice versa.
779 if (radeon_connector
->shared_ddc
&& connector_status_connected
) {
780 struct drm_device
*dev
= connector
->dev
;
781 struct drm_connector
*list_connector
;
782 struct radeon_connector
*list_radeon_connector
;
783 list_for_each_entry(list_connector
, &dev
->mode_config
.connector_list
, head
) {
784 if (connector
== list_connector
)
786 list_radeon_connector
= to_radeon_connector(list_connector
);
787 if (radeon_connector
->devices
== list_radeon_connector
->devices
) {
788 if (drm_detect_hdmi_monitor(radeon_connector
->edid
)) {
789 if (connector
->connector_type
== DRM_MODE_CONNECTOR_DVID
) {
790 kfree(radeon_connector
->edid
);
791 radeon_connector
->edid
= NULL
;
792 ret
= connector_status_disconnected
;
795 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_HDMIA
) ||
796 (connector
->connector_type
== DRM_MODE_CONNECTOR_HDMIB
)) {
797 kfree(radeon_connector
->edid
);
798 radeon_connector
->edid
= NULL
;
799 ret
= connector_status_disconnected
;
808 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== true))
811 /* find analog encoder */
812 if (radeon_connector
->dac_load_detect
) {
813 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
814 if (connector
->encoder_ids
[i
] == 0)
817 obj
= drm_mode_object_find(connector
->dev
,
818 connector
->encoder_ids
[i
],
819 DRM_MODE_OBJECT_ENCODER
);
823 encoder
= obj_to_encoder(obj
);
825 encoder_funcs
= encoder
->helper_private
;
826 if (encoder_funcs
->detect
) {
827 if (ret
!= connector_status_connected
) {
828 ret
= encoder_funcs
->detect(encoder
, connector
);
829 if (ret
== connector_status_connected
) {
830 radeon_connector
->use_digital
= false;
838 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== false) &&
840 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
844 /* updated in get modes as well since we need to know if it's analog or digital */
845 radeon_connector_update_scratch_regs(connector
, ret
);
849 /* okay need to be smart in here about which encoder to pick */
850 struct drm_encoder
*radeon_dvi_encoder(struct drm_connector
*connector
)
852 int enc_id
= connector
->encoder_ids
[0];
853 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
854 struct drm_mode_object
*obj
;
855 struct drm_encoder
*encoder
;
857 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
858 if (connector
->encoder_ids
[i
] == 0)
861 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
865 encoder
= obj_to_encoder(obj
);
867 if (radeon_connector
->use_digital
== true) {
868 if (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)
871 if (encoder
->encoder_type
== DRM_MODE_ENCODER_DAC
||
872 encoder
->encoder_type
== DRM_MODE_ENCODER_TVDAC
)
877 /* see if we have a default encoder TODO */
879 /* then check use digitial */
880 /* pick the first one */
882 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
885 encoder
= obj_to_encoder(obj
);
891 static void radeon_dvi_force(struct drm_connector
*connector
)
893 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
894 if (connector
->force
== DRM_FORCE_ON
)
895 radeon_connector
->use_digital
= false;
896 if (connector
->force
== DRM_FORCE_ON_DIGITAL
)
897 radeon_connector
->use_digital
= true;
900 static int radeon_dvi_mode_valid(struct drm_connector
*connector
,
901 struct drm_display_mode
*mode
)
903 struct drm_device
*dev
= connector
->dev
;
904 struct radeon_device
*rdev
= dev
->dev_private
;
905 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
907 /* XXX check mode bandwidth */
909 /* clocks over 135 MHz have heat issues with DVI on RV100 */
910 if (radeon_connector
->use_digital
&&
911 (rdev
->family
== CHIP_RV100
) &&
912 (mode
->clock
> 135000))
913 return MODE_CLOCK_HIGH
;
915 if (radeon_connector
->use_digital
&& (mode
->clock
> 165000)) {
916 if ((radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
) ||
917 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
) ||
918 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_B
))
921 return MODE_CLOCK_HIGH
;
926 struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs
= {
927 .get_modes
= radeon_dvi_get_modes
,
928 .mode_valid
= radeon_dvi_mode_valid
,
929 .best_encoder
= radeon_dvi_encoder
,
932 struct drm_connector_funcs radeon_dvi_connector_funcs
= {
933 .dpms
= drm_helper_connector_dpms
,
934 .detect
= radeon_dvi_detect
,
935 .fill_modes
= drm_helper_probe_single_connector_modes
,
936 .set_property
= radeon_connector_set_property
,
937 .destroy
= radeon_connector_destroy
,
938 .force
= radeon_dvi_force
,
941 static void radeon_dp_connector_destroy(struct drm_connector
*connector
)
943 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
944 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
946 if (radeon_connector
->ddc_bus
)
947 radeon_i2c_destroy(radeon_connector
->ddc_bus
);
948 if (radeon_connector
->edid
)
949 kfree(radeon_connector
->edid
);
950 if (radeon_dig_connector
->dp_i2c_bus
)
951 radeon_i2c_destroy(radeon_dig_connector
->dp_i2c_bus
);
952 kfree(radeon_connector
->con_priv
);
953 drm_sysfs_connector_remove(connector
);
954 drm_connector_cleanup(connector
);
958 static int radeon_dp_get_modes(struct drm_connector
*connector
)
960 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
963 ret
= radeon_ddc_get_modes(radeon_connector
);
967 static enum drm_connector_status
radeon_dp_detect(struct drm_connector
*connector
)
969 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
970 enum drm_connector_status ret
= connector_status_disconnected
;
971 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
974 if (radeon_connector
->edid
) {
975 kfree(radeon_connector
->edid
);
976 radeon_connector
->edid
= NULL
;
979 sink_type
= radeon_dp_getsinktype(radeon_connector
);
980 if ((sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
981 (sink_type
== CONNECTOR_OBJECT_ID_eDP
)) {
982 if (radeon_dp_getdpcd(radeon_connector
)) {
983 radeon_dig_connector
->dp_sink_type
= sink_type
;
984 ret
= connector_status_connected
;
987 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 1);
988 if (radeon_ddc_probe(radeon_connector
)) {
989 radeon_dig_connector
->dp_sink_type
= sink_type
;
990 ret
= connector_status_connected
;
992 radeon_i2c_do_lock(radeon_connector
->ddc_bus
, 0);
998 static int radeon_dp_mode_valid(struct drm_connector
*connector
,
999 struct drm_display_mode
*mode
)
1001 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1002 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
1004 /* XXX check mode bandwidth */
1006 if ((radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
1007 (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
))
1008 return radeon_dp_mode_valid_helper(radeon_connector
, mode
);
1013 struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs
= {
1014 .get_modes
= radeon_dp_get_modes
,
1015 .mode_valid
= radeon_dp_mode_valid
,
1016 .best_encoder
= radeon_dvi_encoder
,
1019 struct drm_connector_funcs radeon_dp_connector_funcs
= {
1020 .dpms
= drm_helper_connector_dpms
,
1021 .detect
= radeon_dp_detect
,
1022 .fill_modes
= drm_helper_probe_single_connector_modes
,
1023 .set_property
= radeon_connector_set_property
,
1024 .destroy
= radeon_dp_connector_destroy
,
1025 .force
= radeon_dvi_force
,
1029 radeon_add_atom_connector(struct drm_device
*dev
,
1030 uint32_t connector_id
,
1031 uint32_t supported_device
,
1033 struct radeon_i2c_bus_rec
*i2c_bus
,
1035 uint32_t igp_lane_info
,
1036 uint16_t connector_object_id
,
1037 struct radeon_hpd
*hpd
)
1039 struct radeon_device
*rdev
= dev
->dev_private
;
1040 struct drm_connector
*connector
;
1041 struct radeon_connector
*radeon_connector
;
1042 struct radeon_connector_atom_dig
*radeon_dig_connector
;
1043 uint32_t subpixel_order
= SubPixelNone
;
1044 bool shared_ddc
= false;
1047 /* fixme - tv/cv/din */
1048 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1051 /* see if we already added it */
1052 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1053 radeon_connector
= to_radeon_connector(connector
);
1054 if (radeon_connector
->connector_id
== connector_id
) {
1055 radeon_connector
->devices
|= supported_device
;
1058 if (radeon_connector
->ddc_bus
&& i2c_bus
->valid
) {
1059 if (memcmp(&radeon_connector
->ddc_bus
->rec
, i2c_bus
,
1060 sizeof(struct radeon_i2c_bus_rec
)) == 0) {
1061 radeon_connector
->shared_ddc
= true;
1067 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1068 if (!radeon_connector
)
1071 connector
= &radeon_connector
->base
;
1073 radeon_connector
->connector_id
= connector_id
;
1074 radeon_connector
->devices
= supported_device
;
1075 radeon_connector
->shared_ddc
= shared_ddc
;
1076 radeon_connector
->connector_object_id
= connector_object_id
;
1077 radeon_connector
->hpd
= *hpd
;
1078 switch (connector_type
) {
1079 case DRM_MODE_CONNECTOR_VGA
:
1080 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1081 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1084 if (i2c_bus
->valid
) {
1085 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "VGA");
1086 if (!radeon_connector
->ddc_bus
)
1089 radeon_connector
->dac_load_detect
= true;
1090 drm_connector_attach_property(&radeon_connector
->base
,
1091 rdev
->mode_info
.load_detect_property
,
1094 case DRM_MODE_CONNECTOR_DVIA
:
1095 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1096 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1099 if (i2c_bus
->valid
) {
1100 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "DVI");
1101 if (!radeon_connector
->ddc_bus
)
1104 radeon_connector
->dac_load_detect
= true;
1105 drm_connector_attach_property(&radeon_connector
->base
,
1106 rdev
->mode_info
.load_detect_property
,
1109 case DRM_MODE_CONNECTOR_DVII
:
1110 case DRM_MODE_CONNECTOR_DVID
:
1111 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1112 if (!radeon_dig_connector
)
1114 radeon_dig_connector
->linkb
= linkb
;
1115 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1116 radeon_connector
->con_priv
= radeon_dig_connector
;
1117 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1118 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1121 if (i2c_bus
->valid
) {
1122 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "DVI");
1123 if (!radeon_connector
->ddc_bus
)
1126 subpixel_order
= SubPixelHorizontalRGB
;
1127 drm_connector_attach_property(&radeon_connector
->base
,
1128 rdev
->mode_info
.coherent_mode_property
,
1130 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1131 radeon_connector
->dac_load_detect
= true;
1132 drm_connector_attach_property(&radeon_connector
->base
,
1133 rdev
->mode_info
.load_detect_property
,
1137 case DRM_MODE_CONNECTOR_HDMIA
:
1138 case DRM_MODE_CONNECTOR_HDMIB
:
1139 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1140 if (!radeon_dig_connector
)
1142 radeon_dig_connector
->linkb
= linkb
;
1143 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1144 radeon_connector
->con_priv
= radeon_dig_connector
;
1145 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1146 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1149 if (i2c_bus
->valid
) {
1150 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "HDMI");
1151 if (!radeon_connector
->ddc_bus
)
1154 drm_connector_attach_property(&radeon_connector
->base
,
1155 rdev
->mode_info
.coherent_mode_property
,
1157 subpixel_order
= SubPixelHorizontalRGB
;
1159 case DRM_MODE_CONNECTOR_DisplayPort
:
1160 case DRM_MODE_CONNECTOR_eDP
:
1161 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1162 if (!radeon_dig_connector
)
1164 radeon_dig_connector
->linkb
= linkb
;
1165 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1166 radeon_connector
->con_priv
= radeon_dig_connector
;
1167 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1168 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1171 if (i2c_bus
->valid
) {
1172 /* add DP i2c bus */
1173 if (connector_type
== DRM_MODE_CONNECTOR_eDP
)
1174 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1176 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1177 if (!radeon_dig_connector
->dp_i2c_bus
)
1179 if (connector_type
== DRM_MODE_CONNECTOR_eDP
)
1180 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "eDP");
1182 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "DP");
1183 if (!radeon_connector
->ddc_bus
)
1186 subpixel_order
= SubPixelHorizontalRGB
;
1187 drm_connector_attach_property(&radeon_connector
->base
,
1188 rdev
->mode_info
.coherent_mode_property
,
1191 case DRM_MODE_CONNECTOR_SVIDEO
:
1192 case DRM_MODE_CONNECTOR_Composite
:
1193 case DRM_MODE_CONNECTOR_9PinDIN
:
1194 if (radeon_tv
== 1) {
1195 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1196 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1199 radeon_connector
->dac_load_detect
= true;
1200 drm_connector_attach_property(&radeon_connector
->base
,
1201 rdev
->mode_info
.load_detect_property
,
1203 drm_connector_attach_property(&radeon_connector
->base
,
1204 rdev
->mode_info
.tv_std_property
,
1205 radeon_atombios_get_tv_info(rdev
));
1208 case DRM_MODE_CONNECTOR_LVDS
:
1209 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1210 if (!radeon_dig_connector
)
1212 radeon_dig_connector
->linkb
= linkb
;
1213 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1214 radeon_connector
->con_priv
= radeon_dig_connector
;
1215 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1216 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1219 if (i2c_bus
->valid
) {
1220 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "LVDS");
1221 if (!radeon_connector
->ddc_bus
)
1224 drm_connector_attach_property(&radeon_connector
->base
,
1225 dev
->mode_config
.scaling_mode_property
,
1226 DRM_MODE_SCALE_FULLSCREEN
);
1227 subpixel_order
= SubPixelHorizontalRGB
;
1231 connector
->display_info
.subpixel_order
= subpixel_order
;
1232 drm_sysfs_connector_add(connector
);
1236 if (radeon_connector
->ddc_bus
)
1237 radeon_i2c_destroy(radeon_connector
->ddc_bus
);
1238 drm_connector_cleanup(connector
);
1243 radeon_add_legacy_connector(struct drm_device
*dev
,
1244 uint32_t connector_id
,
1245 uint32_t supported_device
,
1247 struct radeon_i2c_bus_rec
*i2c_bus
,
1248 uint16_t connector_object_id
,
1249 struct radeon_hpd
*hpd
)
1251 struct radeon_device
*rdev
= dev
->dev_private
;
1252 struct drm_connector
*connector
;
1253 struct radeon_connector
*radeon_connector
;
1254 uint32_t subpixel_order
= SubPixelNone
;
1257 /* fixme - tv/cv/din */
1258 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1261 /* see if we already added it */
1262 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1263 radeon_connector
= to_radeon_connector(connector
);
1264 if (radeon_connector
->connector_id
== connector_id
) {
1265 radeon_connector
->devices
|= supported_device
;
1270 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1271 if (!radeon_connector
)
1274 connector
= &radeon_connector
->base
;
1276 radeon_connector
->connector_id
= connector_id
;
1277 radeon_connector
->devices
= supported_device
;
1278 radeon_connector
->connector_object_id
= connector_object_id
;
1279 radeon_connector
->hpd
= *hpd
;
1280 switch (connector_type
) {
1281 case DRM_MODE_CONNECTOR_VGA
:
1282 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1283 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1286 if (i2c_bus
->valid
) {
1287 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "VGA");
1288 if (!radeon_connector
->ddc_bus
)
1291 radeon_connector
->dac_load_detect
= true;
1292 drm_connector_attach_property(&radeon_connector
->base
,
1293 rdev
->mode_info
.load_detect_property
,
1296 case DRM_MODE_CONNECTOR_DVIA
:
1297 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1298 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1301 if (i2c_bus
->valid
) {
1302 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "DVI");
1303 if (!radeon_connector
->ddc_bus
)
1306 radeon_connector
->dac_load_detect
= true;
1307 drm_connector_attach_property(&radeon_connector
->base
,
1308 rdev
->mode_info
.load_detect_property
,
1311 case DRM_MODE_CONNECTOR_DVII
:
1312 case DRM_MODE_CONNECTOR_DVID
:
1313 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1314 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1317 if (i2c_bus
->valid
) {
1318 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "DVI");
1319 if (!radeon_connector
->ddc_bus
)
1321 radeon_connector
->dac_load_detect
= true;
1322 drm_connector_attach_property(&radeon_connector
->base
,
1323 rdev
->mode_info
.load_detect_property
,
1326 subpixel_order
= SubPixelHorizontalRGB
;
1328 case DRM_MODE_CONNECTOR_SVIDEO
:
1329 case DRM_MODE_CONNECTOR_Composite
:
1330 case DRM_MODE_CONNECTOR_9PinDIN
:
1331 if (radeon_tv
== 1) {
1332 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1333 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1336 radeon_connector
->dac_load_detect
= true;
1337 /* RS400,RC410,RS480 chipset seems to report a lot
1338 * of false positive on load detect, we haven't yet
1339 * found a way to make load detect reliable on those
1340 * chipset, thus just disable it for TV.
1342 if (rdev
->family
== CHIP_RS400
|| rdev
->family
== CHIP_RS480
)
1343 radeon_connector
->dac_load_detect
= false;
1344 drm_connector_attach_property(&radeon_connector
->base
,
1345 rdev
->mode_info
.load_detect_property
,
1347 drm_connector_attach_property(&radeon_connector
->base
,
1348 rdev
->mode_info
.tv_std_property
,
1349 radeon_combios_get_tv_info(rdev
));
1352 case DRM_MODE_CONNECTOR_LVDS
:
1353 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1354 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1357 if (i2c_bus
->valid
) {
1358 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "LVDS");
1359 if (!radeon_connector
->ddc_bus
)
1362 drm_connector_attach_property(&radeon_connector
->base
,
1363 dev
->mode_config
.scaling_mode_property
,
1364 DRM_MODE_SCALE_FULLSCREEN
);
1365 subpixel_order
= SubPixelHorizontalRGB
;
1369 connector
->display_info
.subpixel_order
= subpixel_order
;
1370 drm_sysfs_connector_add(connector
);
1374 if (radeon_connector
->ddc_bus
)
1375 radeon_i2c_destroy(radeon_connector
->ddc_bus
);
1376 drm_connector_cleanup(connector
);