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
;
290 bool new_coherent_mode
;
292 /* need to find digital encoder on connector */
293 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
297 radeon_encoder
= to_radeon_encoder(encoder
);
299 if (!radeon_encoder
->enc_priv
)
302 dig
= radeon_encoder
->enc_priv
;
303 new_coherent_mode
= val
? true : false;
304 if (dig
->coherent_mode
!= new_coherent_mode
) {
305 dig
->coherent_mode
= new_coherent_mode
;
306 radeon_property_change_mode(&radeon_encoder
->base
);
310 if (property
== rdev
->mode_info
.tv_std_property
) {
311 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TVDAC
);
313 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_DAC
);
319 radeon_encoder
= to_radeon_encoder(encoder
);
320 if (!radeon_encoder
->enc_priv
)
322 if (ASIC_IS_AVIVO(rdev
) || radeon_r4xx_atom
) {
323 struct radeon_encoder_atom_dac
*dac_int
;
324 dac_int
= radeon_encoder
->enc_priv
;
325 dac_int
->tv_std
= val
;
327 struct radeon_encoder_tv_dac
*dac_int
;
328 dac_int
= radeon_encoder
->enc_priv
;
329 dac_int
->tv_std
= val
;
331 radeon_property_change_mode(&radeon_encoder
->base
);
334 if (property
== rdev
->mode_info
.load_detect_property
) {
335 struct radeon_connector
*radeon_connector
=
336 to_radeon_connector(connector
);
339 radeon_connector
->dac_load_detect
= false;
341 radeon_connector
->dac_load_detect
= true;
344 if (property
== rdev
->mode_info
.tmds_pll_property
) {
345 struct radeon_encoder_int_tmds
*tmds
= NULL
;
347 /* need to find digital encoder on connector */
348 encoder
= radeon_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
352 radeon_encoder
= to_radeon_encoder(encoder
);
354 tmds
= radeon_encoder
->enc_priv
;
359 if (rdev
->is_atom_bios
)
360 ret
= radeon_atombios_get_tmds_info(radeon_encoder
, tmds
);
362 ret
= radeon_legacy_get_tmds_info_from_combios(radeon_encoder
, tmds
);
364 if (val
== 1 || ret
== false) {
365 radeon_legacy_get_tmds_info_from_table(radeon_encoder
, tmds
);
367 radeon_property_change_mode(&radeon_encoder
->base
);
373 static void radeon_fixup_lvds_native_mode(struct drm_encoder
*encoder
,
374 struct drm_connector
*connector
)
376 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
377 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
379 /* Try to get native mode details from EDID if necessary */
380 if (!native_mode
->clock
) {
381 struct drm_display_mode
*t
, *mode
;
383 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
384 if (mode
->hdisplay
== native_mode
->hdisplay
&&
385 mode
->vdisplay
== native_mode
->vdisplay
) {
386 *native_mode
= *mode
;
387 drm_mode_set_crtcinfo(native_mode
, CRTC_INTERLACE_HALVE_V
);
388 DRM_INFO("Determined LVDS native mode details from EDID\n");
393 if (!native_mode
->clock
) {
394 DRM_INFO("No LVDS native mode details, disabling RMX\n");
395 radeon_encoder
->rmx_type
= RMX_OFF
;
399 static int radeon_lvds_get_modes(struct drm_connector
*connector
)
401 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
402 struct drm_encoder
*encoder
;
404 struct drm_display_mode
*mode
;
406 if (radeon_connector
->ddc_bus
) {
407 ret
= radeon_ddc_get_modes(radeon_connector
);
409 encoder
= radeon_best_single_encoder(connector
);
411 radeon_fixup_lvds_native_mode(encoder
, connector
);
412 /* add scaled modes */
413 radeon_add_common_modes(encoder
, connector
);
419 encoder
= radeon_best_single_encoder(connector
);
423 /* we have no EDID modes */
424 mode
= radeon_fp_native_mode(encoder
);
427 drm_mode_probed_add(connector
, mode
);
428 /* add scaled modes */
429 radeon_add_common_modes(encoder
, connector
);
435 static int radeon_lvds_mode_valid(struct drm_connector
*connector
,
436 struct drm_display_mode
*mode
)
438 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
440 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
444 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
445 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
447 /* AVIVO hardware supports downscaling modes larger than the panel
448 * to the panel size, but I'm not sure this is desirable.
450 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
451 (mode
->vdisplay
> native_mode
->vdisplay
))
454 /* if scaling is disabled, block non-native modes */
455 if (radeon_encoder
->rmx_type
== RMX_OFF
) {
456 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
457 (mode
->vdisplay
!= native_mode
->vdisplay
))
465 static enum drm_connector_status
radeon_lvds_detect(struct drm_connector
*connector
)
467 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
468 struct drm_encoder
*encoder
= radeon_best_single_encoder(connector
);
469 enum drm_connector_status ret
= connector_status_disconnected
;
472 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
473 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
475 /* check if panel is valid */
476 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
477 ret
= connector_status_connected
;
481 /* check for edid as well */
482 if (radeon_connector
->edid
)
483 ret
= connector_status_connected
;
485 if (radeon_connector
->ddc_bus
) {
486 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
,
487 &radeon_connector
->ddc_bus
->adapter
);
488 if (radeon_connector
->edid
)
489 ret
= connector_status_connected
;
492 /* check acpi lid status ??? */
494 radeon_connector_update_scratch_regs(connector
, ret
);
498 static void radeon_connector_destroy(struct drm_connector
*connector
)
500 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
502 if (radeon_connector
->ddc_bus
)
503 radeon_i2c_destroy(radeon_connector
->ddc_bus
);
504 if (radeon_connector
->edid
)
505 kfree(radeon_connector
->edid
);
506 kfree(radeon_connector
->con_priv
);
507 drm_sysfs_connector_remove(connector
);
508 drm_connector_cleanup(connector
);
512 static int radeon_lvds_set_property(struct drm_connector
*connector
,
513 struct drm_property
*property
,
516 struct drm_device
*dev
= connector
->dev
;
517 struct radeon_encoder
*radeon_encoder
;
518 enum radeon_rmx_type rmx_type
;
521 if (property
!= dev
->mode_config
.scaling_mode_property
)
524 if (connector
->encoder
)
525 radeon_encoder
= to_radeon_encoder(connector
->encoder
);
527 struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
528 radeon_encoder
= to_radeon_encoder(connector_funcs
->best_encoder(connector
));
532 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
533 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
534 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
536 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
538 if (radeon_encoder
->rmx_type
== rmx_type
)
541 radeon_encoder
->rmx_type
= rmx_type
;
543 radeon_property_change_mode(&radeon_encoder
->base
);
548 struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs
= {
549 .get_modes
= radeon_lvds_get_modes
,
550 .mode_valid
= radeon_lvds_mode_valid
,
551 .best_encoder
= radeon_best_single_encoder
,
554 struct drm_connector_funcs radeon_lvds_connector_funcs
= {
555 .dpms
= drm_helper_connector_dpms
,
556 .detect
= radeon_lvds_detect
,
557 .fill_modes
= drm_helper_probe_single_connector_modes
,
558 .destroy
= radeon_connector_destroy
,
559 .set_property
= radeon_lvds_set_property
,
562 static int radeon_vga_get_modes(struct drm_connector
*connector
)
564 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
567 ret
= radeon_ddc_get_modes(radeon_connector
);
572 static int radeon_vga_mode_valid(struct drm_connector
*connector
,
573 struct drm_display_mode
*mode
)
575 /* XXX check mode bandwidth */
576 /* XXX verify against max DAC output frequency */
580 static enum drm_connector_status
radeon_vga_detect(struct drm_connector
*connector
)
582 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
583 struct drm_encoder
*encoder
;
584 struct drm_encoder_helper_funcs
*encoder_funcs
;
586 enum drm_connector_status ret
= connector_status_disconnected
;
588 encoder
= radeon_best_single_encoder(connector
);
590 ret
= connector_status_disconnected
;
592 if (radeon_connector
->ddc_bus
)
593 dret
= radeon_ddc_probe(radeon_connector
);
595 if (radeon_connector
->edid
) {
596 kfree(radeon_connector
->edid
);
597 radeon_connector
->edid
= NULL
;
599 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
601 if (!radeon_connector
->edid
) {
602 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
603 drm_get_connector_name(connector
));
604 ret
= connector_status_connected
;
606 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
608 /* some oems have boards with separate digital and analog connectors
609 * with a shared ddc line (often vga + hdmi)
611 if (radeon_connector
->use_digital
&& radeon_connector
->shared_ddc
) {
612 kfree(radeon_connector
->edid
);
613 radeon_connector
->edid
= NULL
;
614 ret
= connector_status_disconnected
;
616 ret
= connector_status_connected
;
619 if (radeon_connector
->dac_load_detect
&& encoder
) {
620 encoder_funcs
= encoder
->helper_private
;
621 ret
= encoder_funcs
->detect(encoder
, connector
);
625 if (ret
== connector_status_connected
)
626 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
627 radeon_connector_update_scratch_regs(connector
, ret
);
631 struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs
= {
632 .get_modes
= radeon_vga_get_modes
,
633 .mode_valid
= radeon_vga_mode_valid
,
634 .best_encoder
= radeon_best_single_encoder
,
637 struct drm_connector_funcs radeon_vga_connector_funcs
= {
638 .dpms
= drm_helper_connector_dpms
,
639 .detect
= radeon_vga_detect
,
640 .fill_modes
= drm_helper_probe_single_connector_modes
,
641 .destroy
= radeon_connector_destroy
,
642 .set_property
= radeon_connector_set_property
,
645 static int radeon_tv_get_modes(struct drm_connector
*connector
)
647 struct drm_device
*dev
= connector
->dev
;
648 struct radeon_device
*rdev
= dev
->dev_private
;
649 struct drm_display_mode
*tv_mode
;
650 struct drm_encoder
*encoder
;
652 encoder
= radeon_best_single_encoder(connector
);
656 /* avivo chips can scale any mode */
657 if (rdev
->family
>= CHIP_RS600
)
658 /* add scaled modes */
659 radeon_add_common_modes(encoder
, connector
);
661 /* only 800x600 is supported right now on pre-avivo chips */
662 tv_mode
= drm_cvt_mode(dev
, 800, 600, 60, false, false, false);
663 tv_mode
->type
= DRM_MODE_TYPE_DRIVER
| DRM_MODE_TYPE_PREFERRED
;
664 drm_mode_probed_add(connector
, tv_mode
);
669 static int radeon_tv_mode_valid(struct drm_connector
*connector
,
670 struct drm_display_mode
*mode
)
672 if ((mode
->hdisplay
> 1024) || (mode
->vdisplay
> 768))
673 return MODE_CLOCK_RANGE
;
677 static enum drm_connector_status
radeon_tv_detect(struct drm_connector
*connector
)
679 struct drm_encoder
*encoder
;
680 struct drm_encoder_helper_funcs
*encoder_funcs
;
681 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
682 enum drm_connector_status ret
= connector_status_disconnected
;
684 if (!radeon_connector
->dac_load_detect
)
687 encoder
= radeon_best_single_encoder(connector
);
689 ret
= connector_status_disconnected
;
691 encoder_funcs
= encoder
->helper_private
;
692 ret
= encoder_funcs
->detect(encoder
, connector
);
694 if (ret
== connector_status_connected
)
695 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, false);
696 radeon_connector_update_scratch_regs(connector
, ret
);
700 struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs
= {
701 .get_modes
= radeon_tv_get_modes
,
702 .mode_valid
= radeon_tv_mode_valid
,
703 .best_encoder
= radeon_best_single_encoder
,
706 struct drm_connector_funcs radeon_tv_connector_funcs
= {
707 .dpms
= drm_helper_connector_dpms
,
708 .detect
= radeon_tv_detect
,
709 .fill_modes
= drm_helper_probe_single_connector_modes
,
710 .destroy
= radeon_connector_destroy
,
711 .set_property
= radeon_connector_set_property
,
714 static int radeon_dvi_get_modes(struct drm_connector
*connector
)
716 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
719 ret
= radeon_ddc_get_modes(radeon_connector
);
725 * Do a DDC probe, if DDC probe passes, get the full EDID so
726 * we can do analog/digital monitor detection at this point.
727 * If the monitor is an analog monitor or we got no DDC,
728 * we need to find the DAC encoder object for this connector.
729 * If we got no DDC, we do load detection on the DAC encoder object.
730 * If we got analog DDC or load detection passes on the DAC encoder
731 * we have to check if this analog encoder is shared with anyone else (TV)
732 * if its shared we have to set the other connector to disconnected.
734 static enum drm_connector_status
radeon_dvi_detect(struct drm_connector
*connector
)
736 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
737 struct drm_encoder
*encoder
= NULL
;
738 struct drm_encoder_helper_funcs
*encoder_funcs
;
739 struct drm_mode_object
*obj
;
741 enum drm_connector_status ret
= connector_status_disconnected
;
744 if (radeon_connector
->ddc_bus
)
745 dret
= radeon_ddc_probe(radeon_connector
);
747 if (radeon_connector
->edid
) {
748 kfree(radeon_connector
->edid
);
749 radeon_connector
->edid
= NULL
;
751 radeon_connector
->edid
= drm_get_edid(&radeon_connector
->base
, &radeon_connector
->ddc_bus
->adapter
);
753 if (!radeon_connector
->edid
) {
754 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
755 drm_get_connector_name(connector
));
757 radeon_connector
->use_digital
= !!(radeon_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
759 /* some oems have boards with separate digital and analog connectors
760 * with a shared ddc line (often vga + hdmi)
762 if ((!radeon_connector
->use_digital
) && radeon_connector
->shared_ddc
) {
763 kfree(radeon_connector
->edid
);
764 radeon_connector
->edid
= NULL
;
765 ret
= connector_status_disconnected
;
767 ret
= connector_status_connected
;
769 /* multiple connectors on the same encoder with the same ddc line
770 * This tends to be HDMI and DVI on the same encoder with the
771 * same ddc line. If the edid says HDMI, consider the HDMI port
772 * connected and the DVI port disconnected. If the edid doesn't
773 * say HDMI, vice versa.
775 if (radeon_connector
->shared_ddc
&& (ret
== connector_status_connected
)) {
776 struct drm_device
*dev
= connector
->dev
;
777 struct drm_connector
*list_connector
;
778 struct radeon_connector
*list_radeon_connector
;
779 list_for_each_entry(list_connector
, &dev
->mode_config
.connector_list
, head
) {
780 if (connector
== list_connector
)
782 list_radeon_connector
= to_radeon_connector(list_connector
);
783 if (radeon_connector
->devices
== list_radeon_connector
->devices
) {
784 if (drm_detect_hdmi_monitor(radeon_connector
->edid
)) {
785 if (connector
->connector_type
== DRM_MODE_CONNECTOR_DVID
) {
786 kfree(radeon_connector
->edid
);
787 radeon_connector
->edid
= NULL
;
788 ret
= connector_status_disconnected
;
791 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_HDMIA
) ||
792 (connector
->connector_type
== DRM_MODE_CONNECTOR_HDMIB
)) {
793 kfree(radeon_connector
->edid
);
794 radeon_connector
->edid
= NULL
;
795 ret
= connector_status_disconnected
;
804 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== true))
807 /* find analog encoder */
808 if (radeon_connector
->dac_load_detect
) {
809 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
810 if (connector
->encoder_ids
[i
] == 0)
813 obj
= drm_mode_object_find(connector
->dev
,
814 connector
->encoder_ids
[i
],
815 DRM_MODE_OBJECT_ENCODER
);
819 encoder
= obj_to_encoder(obj
);
821 encoder_funcs
= encoder
->helper_private
;
822 if (encoder_funcs
->detect
) {
823 if (ret
!= connector_status_connected
) {
824 ret
= encoder_funcs
->detect(encoder
, connector
);
825 if (ret
== connector_status_connected
) {
826 radeon_connector
->use_digital
= false;
834 if ((ret
== connector_status_connected
) && (radeon_connector
->use_digital
== false) &&
836 ret
= radeon_connector_analog_encoder_conflict_solve(connector
, encoder
, ret
, true);
840 /* updated in get modes as well since we need to know if it's analog or digital */
841 radeon_connector_update_scratch_regs(connector
, ret
);
845 /* okay need to be smart in here about which encoder to pick */
846 struct drm_encoder
*radeon_dvi_encoder(struct drm_connector
*connector
)
848 int enc_id
= connector
->encoder_ids
[0];
849 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
850 struct drm_mode_object
*obj
;
851 struct drm_encoder
*encoder
;
853 for (i
= 0; i
< DRM_CONNECTOR_MAX_ENCODER
; i
++) {
854 if (connector
->encoder_ids
[i
] == 0)
857 obj
= drm_mode_object_find(connector
->dev
, connector
->encoder_ids
[i
], DRM_MODE_OBJECT_ENCODER
);
861 encoder
= obj_to_encoder(obj
);
863 if (radeon_connector
->use_digital
== true) {
864 if (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)
867 if (encoder
->encoder_type
== DRM_MODE_ENCODER_DAC
||
868 encoder
->encoder_type
== DRM_MODE_ENCODER_TVDAC
)
873 /* see if we have a default encoder TODO */
875 /* then check use digitial */
876 /* pick the first one */
878 obj
= drm_mode_object_find(connector
->dev
, enc_id
, DRM_MODE_OBJECT_ENCODER
);
881 encoder
= obj_to_encoder(obj
);
887 static void radeon_dvi_force(struct drm_connector
*connector
)
889 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
890 if (connector
->force
== DRM_FORCE_ON
)
891 radeon_connector
->use_digital
= false;
892 if (connector
->force
== DRM_FORCE_ON_DIGITAL
)
893 radeon_connector
->use_digital
= true;
896 static int radeon_dvi_mode_valid(struct drm_connector
*connector
,
897 struct drm_display_mode
*mode
)
899 struct drm_device
*dev
= connector
->dev
;
900 struct radeon_device
*rdev
= dev
->dev_private
;
901 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
903 /* XXX check mode bandwidth */
905 /* clocks over 135 MHz have heat issues with DVI on RV100 */
906 if (radeon_connector
->use_digital
&&
907 (rdev
->family
== CHIP_RV100
) &&
908 (mode
->clock
> 135000))
909 return MODE_CLOCK_HIGH
;
911 if (radeon_connector
->use_digital
&& (mode
->clock
> 165000)) {
912 if ((radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
) ||
913 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
) ||
914 (radeon_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_B
))
917 return MODE_CLOCK_HIGH
;
922 struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs
= {
923 .get_modes
= radeon_dvi_get_modes
,
924 .mode_valid
= radeon_dvi_mode_valid
,
925 .best_encoder
= radeon_dvi_encoder
,
928 struct drm_connector_funcs radeon_dvi_connector_funcs
= {
929 .dpms
= drm_helper_connector_dpms
,
930 .detect
= radeon_dvi_detect
,
931 .fill_modes
= drm_helper_probe_single_connector_modes
,
932 .set_property
= radeon_connector_set_property
,
933 .destroy
= radeon_connector_destroy
,
934 .force
= radeon_dvi_force
,
937 static void radeon_dp_connector_destroy(struct drm_connector
*connector
)
939 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
940 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
942 if (radeon_connector
->ddc_bus
)
943 radeon_i2c_destroy(radeon_connector
->ddc_bus
);
944 if (radeon_connector
->edid
)
945 kfree(radeon_connector
->edid
);
946 if (radeon_dig_connector
->dp_i2c_bus
)
947 radeon_i2c_destroy(radeon_dig_connector
->dp_i2c_bus
);
948 kfree(radeon_connector
->con_priv
);
949 drm_sysfs_connector_remove(connector
);
950 drm_connector_cleanup(connector
);
954 static int radeon_dp_get_modes(struct drm_connector
*connector
)
956 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
959 ret
= radeon_ddc_get_modes(radeon_connector
);
963 static enum drm_connector_status
radeon_dp_detect(struct drm_connector
*connector
)
965 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
966 enum drm_connector_status ret
= connector_status_disconnected
;
967 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
970 if (radeon_connector
->edid
) {
971 kfree(radeon_connector
->edid
);
972 radeon_connector
->edid
= NULL
;
975 sink_type
= radeon_dp_getsinktype(radeon_connector
);
976 if ((sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
977 (sink_type
== CONNECTOR_OBJECT_ID_eDP
)) {
978 if (radeon_dp_getdpcd(radeon_connector
)) {
979 radeon_dig_connector
->dp_sink_type
= sink_type
;
980 ret
= connector_status_connected
;
983 if (radeon_ddc_probe(radeon_connector
)) {
984 radeon_dig_connector
->dp_sink_type
= sink_type
;
985 ret
= connector_status_connected
;
992 static int radeon_dp_mode_valid(struct drm_connector
*connector
,
993 struct drm_display_mode
*mode
)
995 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
996 struct radeon_connector_atom_dig
*radeon_dig_connector
= radeon_connector
->con_priv
;
998 /* XXX check mode bandwidth */
1000 if ((radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
1001 (radeon_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
))
1002 return radeon_dp_mode_valid_helper(radeon_connector
, mode
);
1007 struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs
= {
1008 .get_modes
= radeon_dp_get_modes
,
1009 .mode_valid
= radeon_dp_mode_valid
,
1010 .best_encoder
= radeon_dvi_encoder
,
1013 struct drm_connector_funcs radeon_dp_connector_funcs
= {
1014 .dpms
= drm_helper_connector_dpms
,
1015 .detect
= radeon_dp_detect
,
1016 .fill_modes
= drm_helper_probe_single_connector_modes
,
1017 .set_property
= radeon_connector_set_property
,
1018 .destroy
= radeon_dp_connector_destroy
,
1019 .force
= radeon_dvi_force
,
1023 radeon_add_atom_connector(struct drm_device
*dev
,
1024 uint32_t connector_id
,
1025 uint32_t supported_device
,
1027 struct radeon_i2c_bus_rec
*i2c_bus
,
1029 uint32_t igp_lane_info
,
1030 uint16_t connector_object_id
,
1031 struct radeon_hpd
*hpd
)
1033 struct radeon_device
*rdev
= dev
->dev_private
;
1034 struct drm_connector
*connector
;
1035 struct radeon_connector
*radeon_connector
;
1036 struct radeon_connector_atom_dig
*radeon_dig_connector
;
1037 uint32_t subpixel_order
= SubPixelNone
;
1038 bool shared_ddc
= false;
1041 /* fixme - tv/cv/din */
1042 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1045 /* see if we already added it */
1046 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1047 radeon_connector
= to_radeon_connector(connector
);
1048 if (radeon_connector
->connector_id
== connector_id
) {
1049 radeon_connector
->devices
|= supported_device
;
1052 if (radeon_connector
->ddc_bus
&& i2c_bus
->valid
) {
1053 if (radeon_connector
->ddc_bus
->rec
.i2c_id
== i2c_bus
->i2c_id
) {
1054 radeon_connector
->shared_ddc
= true;
1060 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1061 if (!radeon_connector
)
1064 connector
= &radeon_connector
->base
;
1066 radeon_connector
->connector_id
= connector_id
;
1067 radeon_connector
->devices
= supported_device
;
1068 radeon_connector
->shared_ddc
= shared_ddc
;
1069 radeon_connector
->connector_object_id
= connector_object_id
;
1070 radeon_connector
->hpd
= *hpd
;
1071 switch (connector_type
) {
1072 case DRM_MODE_CONNECTOR_VGA
:
1073 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1074 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1077 if (i2c_bus
->valid
) {
1078 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "VGA");
1079 if (!radeon_connector
->ddc_bus
)
1082 radeon_connector
->dac_load_detect
= true;
1083 drm_connector_attach_property(&radeon_connector
->base
,
1084 rdev
->mode_info
.load_detect_property
,
1087 case DRM_MODE_CONNECTOR_DVIA
:
1088 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1089 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1092 if (i2c_bus
->valid
) {
1093 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "DVI");
1094 if (!radeon_connector
->ddc_bus
)
1097 radeon_connector
->dac_load_detect
= true;
1098 drm_connector_attach_property(&radeon_connector
->base
,
1099 rdev
->mode_info
.load_detect_property
,
1102 case DRM_MODE_CONNECTOR_DVII
:
1103 case DRM_MODE_CONNECTOR_DVID
:
1104 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1105 if (!radeon_dig_connector
)
1107 radeon_dig_connector
->linkb
= linkb
;
1108 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1109 radeon_connector
->con_priv
= radeon_dig_connector
;
1110 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1111 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1114 if (i2c_bus
->valid
) {
1115 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "DVI");
1116 if (!radeon_connector
->ddc_bus
)
1119 subpixel_order
= SubPixelHorizontalRGB
;
1120 drm_connector_attach_property(&radeon_connector
->base
,
1121 rdev
->mode_info
.coherent_mode_property
,
1123 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1124 radeon_connector
->dac_load_detect
= true;
1125 drm_connector_attach_property(&radeon_connector
->base
,
1126 rdev
->mode_info
.load_detect_property
,
1130 case DRM_MODE_CONNECTOR_HDMIA
:
1131 case DRM_MODE_CONNECTOR_HDMIB
:
1132 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1133 if (!radeon_dig_connector
)
1135 radeon_dig_connector
->linkb
= linkb
;
1136 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1137 radeon_connector
->con_priv
= radeon_dig_connector
;
1138 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1139 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1142 if (i2c_bus
->valid
) {
1143 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "HDMI");
1144 if (!radeon_connector
->ddc_bus
)
1147 drm_connector_attach_property(&radeon_connector
->base
,
1148 rdev
->mode_info
.coherent_mode_property
,
1150 subpixel_order
= SubPixelHorizontalRGB
;
1152 case DRM_MODE_CONNECTOR_DisplayPort
:
1153 case DRM_MODE_CONNECTOR_eDP
:
1154 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1155 if (!radeon_dig_connector
)
1157 radeon_dig_connector
->linkb
= linkb
;
1158 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1159 radeon_connector
->con_priv
= radeon_dig_connector
;
1160 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dp_connector_funcs
, connector_type
);
1161 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_dp_connector_helper_funcs
);
1164 if (i2c_bus
->valid
) {
1165 /* add DP i2c bus */
1166 if (connector_type
== DRM_MODE_CONNECTOR_eDP
)
1167 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "eDP-auxch");
1169 radeon_dig_connector
->dp_i2c_bus
= radeon_i2c_create_dp(dev
, i2c_bus
, "DP-auxch");
1170 if (!radeon_dig_connector
->dp_i2c_bus
)
1172 if (connector_type
== DRM_MODE_CONNECTOR_eDP
)
1173 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "eDP");
1175 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "DP");
1176 if (!radeon_connector
->ddc_bus
)
1179 subpixel_order
= SubPixelHorizontalRGB
;
1180 drm_connector_attach_property(&radeon_connector
->base
,
1181 rdev
->mode_info
.coherent_mode_property
,
1184 case DRM_MODE_CONNECTOR_SVIDEO
:
1185 case DRM_MODE_CONNECTOR_Composite
:
1186 case DRM_MODE_CONNECTOR_9PinDIN
:
1187 if (radeon_tv
== 1) {
1188 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1189 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1192 radeon_connector
->dac_load_detect
= true;
1193 drm_connector_attach_property(&radeon_connector
->base
,
1194 rdev
->mode_info
.load_detect_property
,
1196 drm_connector_attach_property(&radeon_connector
->base
,
1197 rdev
->mode_info
.tv_std_property
,
1198 radeon_atombios_get_tv_info(rdev
));
1201 case DRM_MODE_CONNECTOR_LVDS
:
1202 radeon_dig_connector
= kzalloc(sizeof(struct radeon_connector_atom_dig
), GFP_KERNEL
);
1203 if (!radeon_dig_connector
)
1205 radeon_dig_connector
->linkb
= linkb
;
1206 radeon_dig_connector
->igp_lane_info
= igp_lane_info
;
1207 radeon_connector
->con_priv
= radeon_dig_connector
;
1208 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1209 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1212 if (i2c_bus
->valid
) {
1213 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "LVDS");
1214 if (!radeon_connector
->ddc_bus
)
1217 drm_connector_attach_property(&radeon_connector
->base
,
1218 dev
->mode_config
.scaling_mode_property
,
1219 DRM_MODE_SCALE_FULLSCREEN
);
1220 subpixel_order
= SubPixelHorizontalRGB
;
1224 connector
->display_info
.subpixel_order
= subpixel_order
;
1225 drm_sysfs_connector_add(connector
);
1229 if (radeon_connector
->ddc_bus
)
1230 radeon_i2c_destroy(radeon_connector
->ddc_bus
);
1231 drm_connector_cleanup(connector
);
1236 radeon_add_legacy_connector(struct drm_device
*dev
,
1237 uint32_t connector_id
,
1238 uint32_t supported_device
,
1240 struct radeon_i2c_bus_rec
*i2c_bus
,
1241 uint16_t connector_object_id
,
1242 struct radeon_hpd
*hpd
)
1244 struct radeon_device
*rdev
= dev
->dev_private
;
1245 struct drm_connector
*connector
;
1246 struct radeon_connector
*radeon_connector
;
1247 uint32_t subpixel_order
= SubPixelNone
;
1250 /* fixme - tv/cv/din */
1251 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1254 /* see if we already added it */
1255 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1256 radeon_connector
= to_radeon_connector(connector
);
1257 if (radeon_connector
->connector_id
== connector_id
) {
1258 radeon_connector
->devices
|= supported_device
;
1263 radeon_connector
= kzalloc(sizeof(struct radeon_connector
), GFP_KERNEL
);
1264 if (!radeon_connector
)
1267 connector
= &radeon_connector
->base
;
1269 radeon_connector
->connector_id
= connector_id
;
1270 radeon_connector
->devices
= supported_device
;
1271 radeon_connector
->connector_object_id
= connector_object_id
;
1272 radeon_connector
->hpd
= *hpd
;
1273 switch (connector_type
) {
1274 case DRM_MODE_CONNECTOR_VGA
:
1275 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1276 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1279 if (i2c_bus
->valid
) {
1280 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "VGA");
1281 if (!radeon_connector
->ddc_bus
)
1284 radeon_connector
->dac_load_detect
= true;
1285 drm_connector_attach_property(&radeon_connector
->base
,
1286 rdev
->mode_info
.load_detect_property
,
1289 case DRM_MODE_CONNECTOR_DVIA
:
1290 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_vga_connector_funcs
, connector_type
);
1291 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_vga_connector_helper_funcs
);
1294 if (i2c_bus
->valid
) {
1295 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "DVI");
1296 if (!radeon_connector
->ddc_bus
)
1299 radeon_connector
->dac_load_detect
= true;
1300 drm_connector_attach_property(&radeon_connector
->base
,
1301 rdev
->mode_info
.load_detect_property
,
1304 case DRM_MODE_CONNECTOR_DVII
:
1305 case DRM_MODE_CONNECTOR_DVID
:
1306 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_dvi_connector_funcs
, connector_type
);
1307 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_dvi_connector_helper_funcs
);
1310 if (i2c_bus
->valid
) {
1311 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "DVI");
1312 if (!radeon_connector
->ddc_bus
)
1314 radeon_connector
->dac_load_detect
= true;
1315 drm_connector_attach_property(&radeon_connector
->base
,
1316 rdev
->mode_info
.load_detect_property
,
1319 subpixel_order
= SubPixelHorizontalRGB
;
1321 case DRM_MODE_CONNECTOR_SVIDEO
:
1322 case DRM_MODE_CONNECTOR_Composite
:
1323 case DRM_MODE_CONNECTOR_9PinDIN
:
1324 if (radeon_tv
== 1) {
1325 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_tv_connector_funcs
, connector_type
);
1326 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_tv_connector_helper_funcs
);
1329 radeon_connector
->dac_load_detect
= true;
1330 /* RS400,RC410,RS480 chipset seems to report a lot
1331 * of false positive on load detect, we haven't yet
1332 * found a way to make load detect reliable on those
1333 * chipset, thus just disable it for TV.
1335 if (rdev
->family
== CHIP_RS400
|| rdev
->family
== CHIP_RS480
)
1336 radeon_connector
->dac_load_detect
= false;
1337 drm_connector_attach_property(&radeon_connector
->base
,
1338 rdev
->mode_info
.load_detect_property
,
1339 radeon_connector
->dac_load_detect
);
1340 drm_connector_attach_property(&radeon_connector
->base
,
1341 rdev
->mode_info
.tv_std_property
,
1342 radeon_combios_get_tv_info(rdev
));
1345 case DRM_MODE_CONNECTOR_LVDS
:
1346 drm_connector_init(dev
, &radeon_connector
->base
, &radeon_lvds_connector_funcs
, connector_type
);
1347 ret
= drm_connector_helper_add(&radeon_connector
->base
, &radeon_lvds_connector_helper_funcs
);
1350 if (i2c_bus
->valid
) {
1351 radeon_connector
->ddc_bus
= radeon_i2c_create(dev
, i2c_bus
, "LVDS");
1352 if (!radeon_connector
->ddc_bus
)
1355 drm_connector_attach_property(&radeon_connector
->base
,
1356 dev
->mode_config
.scaling_mode_property
,
1357 DRM_MODE_SCALE_FULLSCREEN
);
1358 subpixel_order
= SubPixelHorizontalRGB
;
1362 connector
->display_info
.subpixel_order
= subpixel_order
;
1363 drm_sysfs_connector_add(connector
);
1367 if (radeon_connector
->ddc_bus
)
1368 radeon_i2c_destroy(radeon_connector
->ddc_bus
);
1369 drm_connector_cleanup(connector
);