2 * Copyright 2007-8 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
23 * Authors: Dave Airlie
27 #include "drm_crtc_helper.h"
28 #include "radeon_drm.h"
32 extern int atom_debug
;
34 /* evil but including atombios.h is much worse */
35 bool radeon_atom_get_tv_timings(struct radeon_device
*rdev
, int index
,
36 struct drm_display_mode
*mode
);
38 static uint32_t radeon_encoder_clones(struct drm_encoder
*encoder
)
40 struct drm_device
*dev
= encoder
->dev
;
41 struct radeon_device
*rdev
= dev
->dev_private
;
42 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
43 struct drm_encoder
*clone_encoder
;
44 uint32_t index_mask
= 0;
47 /* DIG routing gets problematic */
48 if (rdev
->family
>= CHIP_R600
)
50 /* LVDS/TV are too wacky */
51 if (radeon_encoder
->devices
& ATOM_DEVICE_LCD_SUPPORT
)
53 /* DVO requires 2x ppll clocks depending on tmds chip */
54 if (radeon_encoder
->devices
& ATOM_DEVICE_DFP2_SUPPORT
)
58 list_for_each_entry(clone_encoder
, &dev
->mode_config
.encoder_list
, head
) {
59 struct radeon_encoder
*radeon_clone
= to_radeon_encoder(clone_encoder
);
62 if (clone_encoder
== encoder
)
64 if (radeon_clone
->devices
& (ATOM_DEVICE_LCD_SUPPORT
))
66 if (radeon_clone
->devices
& ATOM_DEVICE_DFP2_SUPPORT
)
69 index_mask
|= (1 << count
);
74 void radeon_setup_encoder_clones(struct drm_device
*dev
)
76 struct drm_encoder
*encoder
;
78 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
79 encoder
->possible_clones
= radeon_encoder_clones(encoder
);
84 radeon_get_encoder_id(struct drm_device
*dev
, uint32_t supported_device
, uint8_t dac
)
86 struct radeon_device
*rdev
= dev
->dev_private
;
89 switch (supported_device
) {
90 case ATOM_DEVICE_CRT1_SUPPORT
:
91 case ATOM_DEVICE_TV1_SUPPORT
:
92 case ATOM_DEVICE_TV2_SUPPORT
:
93 case ATOM_DEVICE_CRT2_SUPPORT
:
94 case ATOM_DEVICE_CV_SUPPORT
:
97 if ((rdev
->family
== CHIP_RS300
) ||
98 (rdev
->family
== CHIP_RS400
) ||
99 (rdev
->family
== CHIP_RS480
))
100 ret
= ENCODER_OBJECT_ID_INTERNAL_DAC2
;
101 else if (ASIC_IS_AVIVO(rdev
))
102 ret
= ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
;
104 ret
= ENCODER_OBJECT_ID_INTERNAL_DAC1
;
107 if (ASIC_IS_AVIVO(rdev
))
108 ret
= ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
;
110 /*if (rdev->family == CHIP_R200)
111 ret = ENCODER_OBJECT_ID_INTERNAL_DVO1;
113 ret
= ENCODER_OBJECT_ID_INTERNAL_DAC2
;
116 case 3: /* external dac */
117 if (ASIC_IS_AVIVO(rdev
))
118 ret
= ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1
;
120 ret
= ENCODER_OBJECT_ID_INTERNAL_DVO1
;
124 case ATOM_DEVICE_LCD1_SUPPORT
:
125 if (ASIC_IS_AVIVO(rdev
))
126 ret
= ENCODER_OBJECT_ID_INTERNAL_LVTM1
;
128 ret
= ENCODER_OBJECT_ID_INTERNAL_LVDS
;
130 case ATOM_DEVICE_DFP1_SUPPORT
:
131 if ((rdev
->family
== CHIP_RS300
) ||
132 (rdev
->family
== CHIP_RS400
) ||
133 (rdev
->family
== CHIP_RS480
))
134 ret
= ENCODER_OBJECT_ID_INTERNAL_DVO1
;
135 else if (ASIC_IS_AVIVO(rdev
))
136 ret
= ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1
;
138 ret
= ENCODER_OBJECT_ID_INTERNAL_TMDS1
;
140 case ATOM_DEVICE_LCD2_SUPPORT
:
141 case ATOM_DEVICE_DFP2_SUPPORT
:
142 if ((rdev
->family
== CHIP_RS600
) ||
143 (rdev
->family
== CHIP_RS690
) ||
144 (rdev
->family
== CHIP_RS740
))
145 ret
= ENCODER_OBJECT_ID_INTERNAL_DDI
;
146 else if (ASIC_IS_AVIVO(rdev
))
147 ret
= ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1
;
149 ret
= ENCODER_OBJECT_ID_INTERNAL_DVO1
;
151 case ATOM_DEVICE_DFP3_SUPPORT
:
152 ret
= ENCODER_OBJECT_ID_INTERNAL_LVTM1
;
159 static inline bool radeon_encoder_is_digital(struct drm_encoder
*encoder
)
161 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
162 switch (radeon_encoder
->encoder_id
) {
163 case ENCODER_OBJECT_ID_INTERNAL_LVDS
:
164 case ENCODER_OBJECT_ID_INTERNAL_TMDS1
:
165 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1
:
166 case ENCODER_OBJECT_ID_INTERNAL_LVTM1
:
167 case ENCODER_OBJECT_ID_INTERNAL_DVO1
:
168 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1
:
169 case ENCODER_OBJECT_ID_INTERNAL_DDI
:
170 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
171 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
:
172 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
173 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
180 radeon_link_encoder_connector(struct drm_device
*dev
)
182 struct drm_connector
*connector
;
183 struct radeon_connector
*radeon_connector
;
184 struct drm_encoder
*encoder
;
185 struct radeon_encoder
*radeon_encoder
;
187 /* walk the list and link encoders to connectors */
188 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
189 radeon_connector
= to_radeon_connector(connector
);
190 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
191 radeon_encoder
= to_radeon_encoder(encoder
);
192 if (radeon_encoder
->devices
& radeon_connector
->devices
)
193 drm_mode_connector_attach_encoder(connector
, encoder
);
198 void radeon_encoder_set_active_device(struct drm_encoder
*encoder
)
200 struct drm_device
*dev
= encoder
->dev
;
201 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
202 struct drm_connector
*connector
;
204 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
205 if (connector
->encoder
== encoder
) {
206 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
207 radeon_encoder
->active_device
= radeon_encoder
->devices
& radeon_connector
->devices
;
208 DRM_DEBUG("setting active device to %08x from %08x %08x for encoder %d\n",
209 radeon_encoder
->active_device
, radeon_encoder
->devices
,
210 radeon_connector
->devices
, encoder
->encoder_type
);
215 static struct drm_connector
*
216 radeon_get_connector_for_encoder(struct drm_encoder
*encoder
)
218 struct drm_device
*dev
= encoder
->dev
;
219 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
220 struct drm_connector
*connector
;
221 struct radeon_connector
*radeon_connector
;
223 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
224 radeon_connector
= to_radeon_connector(connector
);
225 if (radeon_encoder
->active_device
& radeon_connector
->devices
)
231 static struct radeon_connector_atom_dig
*
232 radeon_get_atom_connector_priv_from_encoder(struct drm_encoder
*encoder
)
234 struct drm_device
*dev
= encoder
->dev
;
235 struct radeon_device
*rdev
= dev
->dev_private
;
236 struct drm_connector
*connector
;
237 struct radeon_connector
*radeon_connector
;
238 struct radeon_connector_atom_dig
*dig_connector
;
240 if (!rdev
->is_atom_bios
)
243 connector
= radeon_get_connector_for_encoder(encoder
);
247 radeon_connector
= to_radeon_connector(connector
);
249 if (!radeon_connector
->con_priv
)
252 dig_connector
= radeon_connector
->con_priv
;
254 return dig_connector
;
257 static bool radeon_atom_mode_fixup(struct drm_encoder
*encoder
,
258 struct drm_display_mode
*mode
,
259 struct drm_display_mode
*adjusted_mode
)
261 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
262 struct drm_device
*dev
= encoder
->dev
;
263 struct radeon_device
*rdev
= dev
->dev_private
;
265 /* adjust pm to upcoming mode change */
266 radeon_pm_compute_clocks(rdev
);
268 /* set the active encoder to connector routing */
269 radeon_encoder_set_active_device(encoder
);
270 drm_mode_set_crtcinfo(adjusted_mode
, 0);
273 if ((mode
->flags
& DRM_MODE_FLAG_INTERLACE
)
274 && (mode
->crtc_vsync_start
< (mode
->crtc_vdisplay
+ 2)))
275 adjusted_mode
->crtc_vsync_start
= adjusted_mode
->crtc_vdisplay
+ 2;
277 /* get the native mode for LVDS */
278 if (radeon_encoder
->active_device
& (ATOM_DEVICE_LCD_SUPPORT
)) {
279 struct drm_display_mode
*native_mode
= &radeon_encoder
->native_mode
;
280 int mode_id
= adjusted_mode
->base
.id
;
281 *adjusted_mode
= *native_mode
;
282 if (!ASIC_IS_AVIVO(rdev
)) {
283 adjusted_mode
->hdisplay
= mode
->hdisplay
;
284 adjusted_mode
->vdisplay
= mode
->vdisplay
;
285 adjusted_mode
->crtc_hdisplay
= mode
->hdisplay
;
286 adjusted_mode
->crtc_vdisplay
= mode
->vdisplay
;
288 adjusted_mode
->base
.id
= mode_id
;
291 /* get the native mode for TV */
292 if (radeon_encoder
->active_device
& (ATOM_DEVICE_TV_SUPPORT
)) {
293 struct radeon_encoder_atom_dac
*tv_dac
= radeon_encoder
->enc_priv
;
295 if (tv_dac
->tv_std
== TV_STD_NTSC
||
296 tv_dac
->tv_std
== TV_STD_NTSC_J
||
297 tv_dac
->tv_std
== TV_STD_PAL_M
)
298 radeon_atom_get_tv_timings(rdev
, 0, adjusted_mode
);
300 radeon_atom_get_tv_timings(rdev
, 1, adjusted_mode
);
304 if (ASIC_IS_DCE3(rdev
) &&
305 (radeon_encoder
->active_device
& (ATOM_DEVICE_DFP_SUPPORT
| ATOM_DEVICE_LCD_SUPPORT
))) {
306 struct drm_connector
*connector
= radeon_get_connector_for_encoder(encoder
);
307 radeon_dp_set_link_config(connector
, mode
);
314 atombios_dac_setup(struct drm_encoder
*encoder
, int action
)
316 struct drm_device
*dev
= encoder
->dev
;
317 struct radeon_device
*rdev
= dev
->dev_private
;
318 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
319 DAC_ENCODER_CONTROL_PS_ALLOCATION args
;
321 struct radeon_encoder_atom_dac
*dac_info
= radeon_encoder
->enc_priv
;
323 memset(&args
, 0, sizeof(args
));
325 switch (radeon_encoder
->encoder_id
) {
326 case ENCODER_OBJECT_ID_INTERNAL_DAC1
:
327 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
:
328 index
= GetIndexIntoMasterTable(COMMAND
, DAC1EncoderControl
);
330 case ENCODER_OBJECT_ID_INTERNAL_DAC2
:
331 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
:
332 index
= GetIndexIntoMasterTable(COMMAND
, DAC2EncoderControl
);
336 args
.ucAction
= action
;
338 if (radeon_encoder
->active_device
& (ATOM_DEVICE_CRT_SUPPORT
))
339 args
.ucDacStandard
= ATOM_DAC1_PS2
;
340 else if (radeon_encoder
->active_device
& (ATOM_DEVICE_CV_SUPPORT
))
341 args
.ucDacStandard
= ATOM_DAC1_CV
;
343 switch (dac_info
->tv_std
) {
346 case TV_STD_SCART_PAL
:
349 args
.ucDacStandard
= ATOM_DAC1_PAL
;
355 args
.ucDacStandard
= ATOM_DAC1_NTSC
;
359 args
.usPixelClock
= cpu_to_le16(radeon_encoder
->pixel_clock
/ 10);
361 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
366 atombios_tv_setup(struct drm_encoder
*encoder
, int action
)
368 struct drm_device
*dev
= encoder
->dev
;
369 struct radeon_device
*rdev
= dev
->dev_private
;
370 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
371 TV_ENCODER_CONTROL_PS_ALLOCATION args
;
373 struct radeon_encoder_atom_dac
*dac_info
= radeon_encoder
->enc_priv
;
375 memset(&args
, 0, sizeof(args
));
377 index
= GetIndexIntoMasterTable(COMMAND
, TVEncoderControl
);
379 args
.sTVEncoder
.ucAction
= action
;
381 if (radeon_encoder
->active_device
& (ATOM_DEVICE_CV_SUPPORT
))
382 args
.sTVEncoder
.ucTvStandard
= ATOM_TV_CV
;
384 switch (dac_info
->tv_std
) {
386 args
.sTVEncoder
.ucTvStandard
= ATOM_TV_NTSC
;
389 args
.sTVEncoder
.ucTvStandard
= ATOM_TV_PAL
;
392 args
.sTVEncoder
.ucTvStandard
= ATOM_TV_PALM
;
395 args
.sTVEncoder
.ucTvStandard
= ATOM_TV_PAL60
;
398 args
.sTVEncoder
.ucTvStandard
= ATOM_TV_NTSCJ
;
400 case TV_STD_SCART_PAL
:
401 args
.sTVEncoder
.ucTvStandard
= ATOM_TV_PAL
; /* ??? */
404 args
.sTVEncoder
.ucTvStandard
= ATOM_TV_SECAM
;
407 args
.sTVEncoder
.ucTvStandard
= ATOM_TV_PALCN
;
410 args
.sTVEncoder
.ucTvStandard
= ATOM_TV_NTSC
;
415 args
.sTVEncoder
.usPixelClock
= cpu_to_le16(radeon_encoder
->pixel_clock
/ 10);
417 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
422 atombios_external_tmds_setup(struct drm_encoder
*encoder
, int action
)
424 struct drm_device
*dev
= encoder
->dev
;
425 struct radeon_device
*rdev
= dev
->dev_private
;
426 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
427 ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION args
;
430 memset(&args
, 0, sizeof(args
));
432 index
= GetIndexIntoMasterTable(COMMAND
, DVOEncoderControl
);
434 args
.sXTmdsEncoder
.ucEnable
= action
;
436 if (radeon_encoder
->pixel_clock
> 165000)
437 args
.sXTmdsEncoder
.ucMisc
= PANEL_ENCODER_MISC_DUAL
;
439 /*if (pScrn->rgbBits == 8)*/
440 args
.sXTmdsEncoder
.ucMisc
|= (1 << 1);
442 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
447 atombios_ddia_setup(struct drm_encoder
*encoder
, int action
)
449 struct drm_device
*dev
= encoder
->dev
;
450 struct radeon_device
*rdev
= dev
->dev_private
;
451 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
452 DVO_ENCODER_CONTROL_PS_ALLOCATION args
;
455 memset(&args
, 0, sizeof(args
));
457 index
= GetIndexIntoMasterTable(COMMAND
, DVOEncoderControl
);
459 args
.sDVOEncoder
.ucAction
= action
;
460 args
.sDVOEncoder
.usPixelClock
= cpu_to_le16(radeon_encoder
->pixel_clock
/ 10);
462 if (radeon_encoder
->pixel_clock
> 165000)
463 args
.sDVOEncoder
.usDevAttr
.sDigAttrib
.ucAttribute
= PANEL_ENCODER_MISC_DUAL
;
465 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
469 union lvds_encoder_control
{
470 LVDS_ENCODER_CONTROL_PS_ALLOCATION v1
;
471 LVDS_ENCODER_CONTROL_PS_ALLOCATION_V2 v2
;
475 atombios_digital_setup(struct drm_encoder
*encoder
, int action
)
477 struct drm_device
*dev
= encoder
->dev
;
478 struct radeon_device
*rdev
= dev
->dev_private
;
479 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
480 struct radeon_encoder_atom_dig
*dig
= radeon_encoder
->enc_priv
;
481 struct radeon_connector_atom_dig
*dig_connector
=
482 radeon_get_atom_connector_priv_from_encoder(encoder
);
483 union lvds_encoder_control args
;
485 int hdmi_detected
= 0;
488 if (!dig
|| !dig_connector
)
491 if (atombios_get_encoder_mode(encoder
) == ATOM_ENCODER_MODE_HDMI
)
494 memset(&args
, 0, sizeof(args
));
496 switch (radeon_encoder
->encoder_id
) {
497 case ENCODER_OBJECT_ID_INTERNAL_LVDS
:
498 index
= GetIndexIntoMasterTable(COMMAND
, LVDSEncoderControl
);
500 case ENCODER_OBJECT_ID_INTERNAL_TMDS1
:
501 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1
:
502 index
= GetIndexIntoMasterTable(COMMAND
, TMDS1EncoderControl
);
504 case ENCODER_OBJECT_ID_INTERNAL_LVTM1
:
505 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
))
506 index
= GetIndexIntoMasterTable(COMMAND
, LVDSEncoderControl
);
508 index
= GetIndexIntoMasterTable(COMMAND
, TMDS2EncoderControl
);
512 if (!atom_parse_cmd_header(rdev
->mode_info
.atom_context
, index
, &frev
, &crev
))
521 args
.v1
.ucAction
= action
;
523 args
.v1
.ucMisc
|= PANEL_ENCODER_MISC_HDMI_TYPE
;
524 args
.v1
.usPixelClock
= cpu_to_le16(radeon_encoder
->pixel_clock
/ 10);
525 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
526 if (dig
->lvds_misc
& ATOM_PANEL_MISC_DUAL
)
527 args
.v1
.ucMisc
|= PANEL_ENCODER_MISC_DUAL
;
528 if (dig
->lvds_misc
& ATOM_PANEL_MISC_888RGB
)
529 args
.v1
.ucMisc
|= (1 << 1);
531 if (dig_connector
->linkb
)
532 args
.v1
.ucMisc
|= PANEL_ENCODER_MISC_TMDS_LINKB
;
533 if (radeon_encoder
->pixel_clock
> 165000)
534 args
.v1
.ucMisc
|= PANEL_ENCODER_MISC_DUAL
;
535 /*if (pScrn->rgbBits == 8) */
536 args
.v1
.ucMisc
|= (1 << 1);
542 args
.v2
.ucAction
= action
;
544 if (dig
->coherent_mode
)
545 args
.v2
.ucMisc
|= PANEL_ENCODER_MISC_COHERENT
;
548 args
.v2
.ucMisc
|= PANEL_ENCODER_MISC_HDMI_TYPE
;
549 args
.v2
.usPixelClock
= cpu_to_le16(radeon_encoder
->pixel_clock
/ 10);
550 args
.v2
.ucTruncate
= 0;
551 args
.v2
.ucSpatial
= 0;
552 args
.v2
.ucTemporal
= 0;
554 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
555 if (dig
->lvds_misc
& ATOM_PANEL_MISC_DUAL
)
556 args
.v2
.ucMisc
|= PANEL_ENCODER_MISC_DUAL
;
557 if (dig
->lvds_misc
& ATOM_PANEL_MISC_SPATIAL
) {
558 args
.v2
.ucSpatial
= PANEL_ENCODER_SPATIAL_DITHER_EN
;
559 if (dig
->lvds_misc
& ATOM_PANEL_MISC_888RGB
)
560 args
.v2
.ucSpatial
|= PANEL_ENCODER_SPATIAL_DITHER_DEPTH
;
562 if (dig
->lvds_misc
& ATOM_PANEL_MISC_TEMPORAL
) {
563 args
.v2
.ucTemporal
= PANEL_ENCODER_TEMPORAL_DITHER_EN
;
564 if (dig
->lvds_misc
& ATOM_PANEL_MISC_888RGB
)
565 args
.v2
.ucTemporal
|= PANEL_ENCODER_TEMPORAL_DITHER_DEPTH
;
566 if (((dig
->lvds_misc
>> ATOM_PANEL_MISC_GREY_LEVEL_SHIFT
) & 0x3) == 2)
567 args
.v2
.ucTemporal
|= PANEL_ENCODER_TEMPORAL_LEVEL_4
;
570 if (dig_connector
->linkb
)
571 args
.v2
.ucMisc
|= PANEL_ENCODER_MISC_TMDS_LINKB
;
572 if (radeon_encoder
->pixel_clock
> 165000)
573 args
.v2
.ucMisc
|= PANEL_ENCODER_MISC_DUAL
;
577 DRM_ERROR("Unknown table version %d, %d\n", frev
, crev
);
582 DRM_ERROR("Unknown table version %d, %d\n", frev
, crev
);
586 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
590 atombios_get_encoder_mode(struct drm_encoder
*encoder
)
592 struct drm_connector
*connector
;
593 struct radeon_connector
*radeon_connector
;
594 struct radeon_connector_atom_dig
*dig_connector
;
596 connector
= radeon_get_connector_for_encoder(encoder
);
600 radeon_connector
= to_radeon_connector(connector
);
602 switch (connector
->connector_type
) {
603 case DRM_MODE_CONNECTOR_DVII
:
604 case DRM_MODE_CONNECTOR_HDMIB
: /* HDMI-B is basically DL-DVI; analog works fine */
605 if (drm_detect_hdmi_monitor(radeon_connector
->edid
))
606 return ATOM_ENCODER_MODE_HDMI
;
607 else if (radeon_connector
->use_digital
)
608 return ATOM_ENCODER_MODE_DVI
;
610 return ATOM_ENCODER_MODE_CRT
;
612 case DRM_MODE_CONNECTOR_DVID
:
613 case DRM_MODE_CONNECTOR_HDMIA
:
615 if (drm_detect_hdmi_monitor(radeon_connector
->edid
))
616 return ATOM_ENCODER_MODE_HDMI
;
618 return ATOM_ENCODER_MODE_DVI
;
620 case DRM_MODE_CONNECTOR_LVDS
:
621 return ATOM_ENCODER_MODE_LVDS
;
623 case DRM_MODE_CONNECTOR_DisplayPort
:
624 case DRM_MODE_CONNECTOR_eDP
:
625 dig_connector
= radeon_connector
->con_priv
;
626 if ((dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
627 (dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
))
628 return ATOM_ENCODER_MODE_DP
;
629 else if (drm_detect_hdmi_monitor(radeon_connector
->edid
))
630 return ATOM_ENCODER_MODE_HDMI
;
632 return ATOM_ENCODER_MODE_DVI
;
634 case DRM_MODE_CONNECTOR_DVIA
:
635 case DRM_MODE_CONNECTOR_VGA
:
636 return ATOM_ENCODER_MODE_CRT
;
638 case DRM_MODE_CONNECTOR_Composite
:
639 case DRM_MODE_CONNECTOR_SVIDEO
:
640 case DRM_MODE_CONNECTOR_9PinDIN
:
642 return ATOM_ENCODER_MODE_TV
;
643 /*return ATOM_ENCODER_MODE_CV;*/
649 * DIG Encoder/Transmitter Setup
652 * - 2 DIG transmitter blocks. UNIPHY (links A and B) and LVTMA.
653 * Supports up to 3 digital outputs
654 * - 2 DIG encoder blocks.
655 * DIG1 can drive UNIPHY link A or link B
656 * DIG2 can drive UNIPHY link B or LVTMA
659 * - 3 DIG transmitter blocks. UNIPHY0/1/2 (links A and B).
660 * Supports up to 5 digital outputs
661 * - 2 DIG encoder blocks.
662 * DIG1/2 can drive UNIPHY0/1/2 link A or link B
665 * - 3 DIG transmitter blocks UNPHY0/1/2 (links A and B).
666 * Supports up to 6 digital outputs
667 * - 6 DIG encoder blocks.
668 * - DIG to PHY mapping is hardcoded
669 * DIG1 drives UNIPHY0 link A, A+B
670 * DIG2 drives UNIPHY0 link B
671 * DIG3 drives UNIPHY1 link A, A+B
672 * DIG4 drives UNIPHY1 link B
673 * DIG5 drives UNIPHY2 link A, A+B
674 * DIG6 drives UNIPHY2 link B
677 * crtc -> dig encoder -> UNIPHY/LVTMA (1 or 2 links)
679 * crtc0 -> dig2 -> LVTMA links A+B -> TMDS/HDMI
680 * crtc1 -> dig1 -> UNIPHY0 link B -> DP
681 * crtc0 -> dig1 -> UNIPHY2 link A -> LVDS
682 * crtc1 -> dig2 -> UNIPHY1 link B+A -> TMDS/HDMI
685 union dig_encoder_control
{
686 DIG_ENCODER_CONTROL_PS_ALLOCATION v1
;
687 DIG_ENCODER_CONTROL_PARAMETERS_V2 v2
;
688 DIG_ENCODER_CONTROL_PARAMETERS_V3 v3
;
692 atombios_dig_encoder_setup(struct drm_encoder
*encoder
, int action
)
694 struct drm_device
*dev
= encoder
->dev
;
695 struct radeon_device
*rdev
= dev
->dev_private
;
696 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
697 struct radeon_encoder_atom_dig
*dig
= radeon_encoder
->enc_priv
;
698 struct radeon_connector_atom_dig
*dig_connector
=
699 radeon_get_atom_connector_priv_from_encoder(encoder
);
700 union dig_encoder_control args
;
704 if (!dig
|| !dig_connector
)
707 memset(&args
, 0, sizeof(args
));
709 if (ASIC_IS_DCE4(rdev
))
710 index
= GetIndexIntoMasterTable(COMMAND
, DIGxEncoderControl
);
712 if (dig
->dig_encoder
)
713 index
= GetIndexIntoMasterTable(COMMAND
, DIG2EncoderControl
);
715 index
= GetIndexIntoMasterTable(COMMAND
, DIG1EncoderControl
);
718 if (!atom_parse_cmd_header(rdev
->mode_info
.atom_context
, index
, &frev
, &crev
))
721 args
.v1
.ucAction
= action
;
722 args
.v1
.usPixelClock
= cpu_to_le16(radeon_encoder
->pixel_clock
/ 10);
723 args
.v1
.ucEncoderMode
= atombios_get_encoder_mode(encoder
);
725 if (args
.v1
.ucEncoderMode
== ATOM_ENCODER_MODE_DP
) {
726 if (dig_connector
->dp_clock
== 270000)
727 args
.v1
.ucConfig
|= ATOM_ENCODER_CONFIG_DPLINKRATE_2_70GHZ
;
728 args
.v1
.ucLaneNum
= dig_connector
->dp_lane_count
;
729 } else if (radeon_encoder
->pixel_clock
> 165000)
730 args
.v1
.ucLaneNum
= 8;
732 args
.v1
.ucLaneNum
= 4;
734 if (ASIC_IS_DCE4(rdev
)) {
735 args
.v3
.acConfig
.ucDigSel
= dig
->dig_encoder
;
736 args
.v3
.ucBitPerColor
= PANEL_8BIT_PER_COLOR
;
738 switch (radeon_encoder
->encoder_id
) {
739 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
740 args
.v1
.ucConfig
= ATOM_ENCODER_CONFIG_V2_TRANSMITTER1
;
742 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
743 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
:
744 args
.v1
.ucConfig
= ATOM_ENCODER_CONFIG_V2_TRANSMITTER2
;
746 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
747 args
.v1
.ucConfig
= ATOM_ENCODER_CONFIG_V2_TRANSMITTER3
;
750 if (dig_connector
->linkb
)
751 args
.v1
.ucConfig
|= ATOM_ENCODER_CONFIG_LINKB
;
753 args
.v1
.ucConfig
|= ATOM_ENCODER_CONFIG_LINKA
;
756 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
760 union dig_transmitter_control
{
761 DIG_TRANSMITTER_CONTROL_PS_ALLOCATION v1
;
762 DIG_TRANSMITTER_CONTROL_PARAMETERS_V2 v2
;
763 DIG_TRANSMITTER_CONTROL_PARAMETERS_V3 v3
;
767 atombios_dig_transmitter_setup(struct drm_encoder
*encoder
, int action
, uint8_t lane_num
, uint8_t lane_set
)
769 struct drm_device
*dev
= encoder
->dev
;
770 struct radeon_device
*rdev
= dev
->dev_private
;
771 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
772 struct radeon_encoder_atom_dig
*dig
= radeon_encoder
->enc_priv
;
773 struct radeon_connector_atom_dig
*dig_connector
=
774 radeon_get_atom_connector_priv_from_encoder(encoder
);
775 struct drm_connector
*connector
;
776 struct radeon_connector
*radeon_connector
;
777 union dig_transmitter_control args
;
783 if (!dig
|| !dig_connector
)
786 connector
= radeon_get_connector_for_encoder(encoder
);
787 radeon_connector
= to_radeon_connector(connector
);
789 if (atombios_get_encoder_mode(encoder
) == ATOM_ENCODER_MODE_DP
)
792 memset(&args
, 0, sizeof(args
));
794 if (ASIC_IS_DCE32(rdev
) || ASIC_IS_DCE4(rdev
))
795 index
= GetIndexIntoMasterTable(COMMAND
, UNIPHYTransmitterControl
);
797 switch (radeon_encoder
->encoder_id
) {
798 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
799 index
= GetIndexIntoMasterTable(COMMAND
, DIG1TransmitterControl
);
801 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
:
802 index
= GetIndexIntoMasterTable(COMMAND
, DIG2TransmitterControl
);
807 if (!atom_parse_cmd_header(rdev
->mode_info
.atom_context
, index
, &frev
, &crev
))
810 args
.v1
.ucAction
= action
;
811 if (action
== ATOM_TRANSMITTER_ACTION_INIT
) {
812 args
.v1
.usInitInfo
= radeon_connector
->connector_object_id
;
813 } else if (action
== ATOM_TRANSMITTER_ACTION_SETUP_VSEMPH
) {
814 args
.v1
.asMode
.ucLaneSel
= lane_num
;
815 args
.v1
.asMode
.ucLaneSet
= lane_set
;
818 args
.v1
.usPixelClock
=
819 cpu_to_le16(dig_connector
->dp_clock
/ 10);
820 else if (radeon_encoder
->pixel_clock
> 165000)
821 args
.v1
.usPixelClock
= cpu_to_le16((radeon_encoder
->pixel_clock
/ 2) / 10);
823 args
.v1
.usPixelClock
= cpu_to_le16(radeon_encoder
->pixel_clock
/ 10);
825 if (ASIC_IS_DCE4(rdev
)) {
827 args
.v3
.ucLaneNum
= dig_connector
->dp_lane_count
;
828 else if (radeon_encoder
->pixel_clock
> 165000)
829 args
.v3
.ucLaneNum
= 8;
831 args
.v3
.ucLaneNum
= 4;
833 if (dig_connector
->linkb
) {
834 args
.v3
.acConfig
.ucLinkSel
= 1;
835 args
.v3
.acConfig
.ucEncoderSel
= 1;
838 /* Select the PLL for the PHY
839 * DP PHY should be clocked from external src if there is
843 struct radeon_crtc
*radeon_crtc
= to_radeon_crtc(encoder
->crtc
);
844 pll_id
= radeon_crtc
->pll_id
;
846 if (is_dp
&& rdev
->clock
.dp_extclk
)
847 args
.v3
.acConfig
.ucRefClkSource
= 2; /* external src */
849 args
.v3
.acConfig
.ucRefClkSource
= pll_id
;
851 switch (radeon_encoder
->encoder_id
) {
852 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
853 args
.v3
.acConfig
.ucTransmitterSel
= 0;
855 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
856 args
.v3
.acConfig
.ucTransmitterSel
= 1;
858 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
859 args
.v3
.acConfig
.ucTransmitterSel
= 2;
864 args
.v3
.acConfig
.fCoherentMode
= 1; /* DP requires coherent */
865 else if (radeon_encoder
->devices
& (ATOM_DEVICE_DFP_SUPPORT
)) {
866 if (dig
->coherent_mode
)
867 args
.v3
.acConfig
.fCoherentMode
= 1;
868 if (radeon_encoder
->pixel_clock
> 165000)
869 args
.v3
.acConfig
.fDualLinkConnector
= 1;
871 } else if (ASIC_IS_DCE32(rdev
)) {
872 args
.v2
.acConfig
.ucEncoderSel
= dig
->dig_encoder
;
873 if (dig_connector
->linkb
)
874 args
.v2
.acConfig
.ucLinkSel
= 1;
876 switch (radeon_encoder
->encoder_id
) {
877 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
878 args
.v2
.acConfig
.ucTransmitterSel
= 0;
880 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
881 args
.v2
.acConfig
.ucTransmitterSel
= 1;
883 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
884 args
.v2
.acConfig
.ucTransmitterSel
= 2;
889 args
.v2
.acConfig
.fCoherentMode
= 1;
890 else if (radeon_encoder
->devices
& (ATOM_DEVICE_DFP_SUPPORT
)) {
891 if (dig
->coherent_mode
)
892 args
.v2
.acConfig
.fCoherentMode
= 1;
893 if (radeon_encoder
->pixel_clock
> 165000)
894 args
.v2
.acConfig
.fDualLinkConnector
= 1;
897 args
.v1
.ucConfig
= ATOM_TRANSMITTER_CONFIG_CLKSRC_PPLL
;
899 if (dig
->dig_encoder
)
900 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_DIG2_ENCODER
;
902 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_DIG1_ENCODER
;
904 if ((rdev
->flags
& RADEON_IS_IGP
) &&
905 (radeon_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_UNIPHY
)) {
906 if (is_dp
|| (radeon_encoder
->pixel_clock
<= 165000)) {
907 if (dig_connector
->igp_lane_info
& 0x1)
908 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_LANE_0_3
;
909 else if (dig_connector
->igp_lane_info
& 0x2)
910 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_LANE_4_7
;
911 else if (dig_connector
->igp_lane_info
& 0x4)
912 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_LANE_8_11
;
913 else if (dig_connector
->igp_lane_info
& 0x8)
914 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_LANE_12_15
;
916 if (dig_connector
->igp_lane_info
& 0x3)
917 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_LANE_0_7
;
918 else if (dig_connector
->igp_lane_info
& 0xc)
919 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_LANE_8_15
;
923 if (dig_connector
->linkb
)
924 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_LINKB
;
926 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_LINKA
;
929 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_COHERENT
;
930 else if (radeon_encoder
->devices
& (ATOM_DEVICE_DFP_SUPPORT
)) {
931 if (dig
->coherent_mode
)
932 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_COHERENT
;
933 if (radeon_encoder
->pixel_clock
> 165000)
934 args
.v1
.ucConfig
|= ATOM_TRANSMITTER_CONFIG_8LANE_LINK
;
938 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
942 atombios_yuv_setup(struct drm_encoder
*encoder
, bool enable
)
944 struct drm_device
*dev
= encoder
->dev
;
945 struct radeon_device
*rdev
= dev
->dev_private
;
946 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
947 struct radeon_crtc
*radeon_crtc
= to_radeon_crtc(encoder
->crtc
);
948 ENABLE_YUV_PS_ALLOCATION args
;
949 int index
= GetIndexIntoMasterTable(COMMAND
, EnableYUV
);
952 memset(&args
, 0, sizeof(args
));
954 if (rdev
->family
>= CHIP_R600
)
955 reg
= R600_BIOS_3_SCRATCH
;
957 reg
= RADEON_BIOS_3_SCRATCH
;
959 /* XXX: fix up scratch reg handling */
961 if (radeon_encoder
->active_device
& (ATOM_DEVICE_TV_SUPPORT
))
962 WREG32(reg
, (ATOM_S3_TV1_ACTIVE
|
963 (radeon_crtc
->crtc_id
<< 18)));
964 else if (radeon_encoder
->active_device
& (ATOM_DEVICE_CV_SUPPORT
))
965 WREG32(reg
, (ATOM_S3_CV_ACTIVE
| (radeon_crtc
->crtc_id
<< 24)));
970 args
.ucEnable
= ATOM_ENABLE
;
971 args
.ucCRTC
= radeon_crtc
->crtc_id
;
973 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
979 radeon_atom_encoder_dpms(struct drm_encoder
*encoder
, int mode
)
981 struct drm_device
*dev
= encoder
->dev
;
982 struct radeon_device
*rdev
= dev
->dev_private
;
983 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
984 DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION args
;
988 memset(&args
, 0, sizeof(args
));
990 DRM_DEBUG("encoder dpms %d to mode %d, devices %08x, active_devices %08x\n",
991 radeon_encoder
->encoder_id
, mode
, radeon_encoder
->devices
,
992 radeon_encoder
->active_device
);
993 switch (radeon_encoder
->encoder_id
) {
994 case ENCODER_OBJECT_ID_INTERNAL_TMDS1
:
995 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1
:
996 index
= GetIndexIntoMasterTable(COMMAND
, TMDSAOutputControl
);
998 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
999 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
1000 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
1001 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
:
1004 case ENCODER_OBJECT_ID_INTERNAL_DVO1
:
1005 case ENCODER_OBJECT_ID_INTERNAL_DDI
:
1006 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1
:
1007 index
= GetIndexIntoMasterTable(COMMAND
, DVOOutputControl
);
1009 case ENCODER_OBJECT_ID_INTERNAL_LVDS
:
1010 index
= GetIndexIntoMasterTable(COMMAND
, LCD1OutputControl
);
1012 case ENCODER_OBJECT_ID_INTERNAL_LVTM1
:
1013 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
))
1014 index
= GetIndexIntoMasterTable(COMMAND
, LCD1OutputControl
);
1016 index
= GetIndexIntoMasterTable(COMMAND
, LVTMAOutputControl
);
1018 case ENCODER_OBJECT_ID_INTERNAL_DAC1
:
1019 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
:
1020 if (radeon_encoder
->active_device
& (ATOM_DEVICE_TV_SUPPORT
))
1021 index
= GetIndexIntoMasterTable(COMMAND
, TV1OutputControl
);
1022 else if (radeon_encoder
->active_device
& (ATOM_DEVICE_CV_SUPPORT
))
1023 index
= GetIndexIntoMasterTable(COMMAND
, CV1OutputControl
);
1025 index
= GetIndexIntoMasterTable(COMMAND
, DAC1OutputControl
);
1027 case ENCODER_OBJECT_ID_INTERNAL_DAC2
:
1028 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
:
1029 if (radeon_encoder
->active_device
& (ATOM_DEVICE_TV_SUPPORT
))
1030 index
= GetIndexIntoMasterTable(COMMAND
, TV1OutputControl
);
1031 else if (radeon_encoder
->active_device
& (ATOM_DEVICE_CV_SUPPORT
))
1032 index
= GetIndexIntoMasterTable(COMMAND
, CV1OutputControl
);
1034 index
= GetIndexIntoMasterTable(COMMAND
, DAC2OutputControl
);
1040 case DRM_MODE_DPMS_ON
:
1041 if (atombios_get_encoder_mode(encoder
) == ATOM_ENCODER_MODE_DP
) {
1042 struct drm_connector
*connector
= radeon_get_connector_for_encoder(encoder
);
1044 dp_link_train(encoder
, connector
);
1045 if (ASIC_IS_DCE4(rdev
))
1046 atombios_dig_encoder_setup(encoder
, ATOM_ENCODER_CMD_DP_VIDEO_ON
);
1048 if (!ASIC_IS_DCE4(rdev
))
1049 atombios_dig_transmitter_setup(encoder
, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT
, 0, 0);
1051 case DRM_MODE_DPMS_STANDBY
:
1052 case DRM_MODE_DPMS_SUSPEND
:
1053 case DRM_MODE_DPMS_OFF
:
1054 if (!ASIC_IS_DCE4(rdev
))
1055 atombios_dig_transmitter_setup(encoder
, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT
, 0, 0);
1056 if (atombios_get_encoder_mode(encoder
) == ATOM_ENCODER_MODE_DP
) {
1057 if (ASIC_IS_DCE4(rdev
))
1058 atombios_dig_encoder_setup(encoder
, ATOM_ENCODER_CMD_DP_VIDEO_OFF
);
1064 case DRM_MODE_DPMS_ON
:
1065 args
.ucAction
= ATOM_ENABLE
;
1067 case DRM_MODE_DPMS_STANDBY
:
1068 case DRM_MODE_DPMS_SUSPEND
:
1069 case DRM_MODE_DPMS_OFF
:
1070 args
.ucAction
= ATOM_DISABLE
;
1073 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
1075 radeon_atombios_encoder_dpms_scratch_regs(encoder
, (mode
== DRM_MODE_DPMS_ON
) ? true : false);
1077 /* adjust pm to dpms change */
1078 radeon_pm_compute_clocks(rdev
);
1081 union crtc_source_param
{
1082 SELECT_CRTC_SOURCE_PS_ALLOCATION v1
;
1083 SELECT_CRTC_SOURCE_PARAMETERS_V2 v2
;
1087 atombios_set_encoder_crtc_source(struct drm_encoder
*encoder
)
1089 struct drm_device
*dev
= encoder
->dev
;
1090 struct radeon_device
*rdev
= dev
->dev_private
;
1091 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1092 struct radeon_crtc
*radeon_crtc
= to_radeon_crtc(encoder
->crtc
);
1093 union crtc_source_param args
;
1094 int index
= GetIndexIntoMasterTable(COMMAND
, SelectCRTC_Source
);
1096 struct radeon_encoder_atom_dig
*dig
;
1098 memset(&args
, 0, sizeof(args
));
1100 if (!atom_parse_cmd_header(rdev
->mode_info
.atom_context
, index
, &frev
, &crev
))
1108 if (ASIC_IS_AVIVO(rdev
))
1109 args
.v1
.ucCRTC
= radeon_crtc
->crtc_id
;
1111 if (radeon_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_DAC1
) {
1112 args
.v1
.ucCRTC
= radeon_crtc
->crtc_id
;
1114 args
.v1
.ucCRTC
= radeon_crtc
->crtc_id
<< 2;
1117 switch (radeon_encoder
->encoder_id
) {
1118 case ENCODER_OBJECT_ID_INTERNAL_TMDS1
:
1119 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1
:
1120 args
.v1
.ucDevice
= ATOM_DEVICE_DFP1_INDEX
;
1122 case ENCODER_OBJECT_ID_INTERNAL_LVDS
:
1123 case ENCODER_OBJECT_ID_INTERNAL_LVTM1
:
1124 if (radeon_encoder
->devices
& ATOM_DEVICE_LCD1_SUPPORT
)
1125 args
.v1
.ucDevice
= ATOM_DEVICE_LCD1_INDEX
;
1127 args
.v1
.ucDevice
= ATOM_DEVICE_DFP3_INDEX
;
1129 case ENCODER_OBJECT_ID_INTERNAL_DVO1
:
1130 case ENCODER_OBJECT_ID_INTERNAL_DDI
:
1131 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1
:
1132 args
.v1
.ucDevice
= ATOM_DEVICE_DFP2_INDEX
;
1134 case ENCODER_OBJECT_ID_INTERNAL_DAC1
:
1135 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
:
1136 if (radeon_encoder
->active_device
& (ATOM_DEVICE_TV_SUPPORT
))
1137 args
.v1
.ucDevice
= ATOM_DEVICE_TV1_INDEX
;
1138 else if (radeon_encoder
->active_device
& (ATOM_DEVICE_CV_SUPPORT
))
1139 args
.v1
.ucDevice
= ATOM_DEVICE_CV_INDEX
;
1141 args
.v1
.ucDevice
= ATOM_DEVICE_CRT1_INDEX
;
1143 case ENCODER_OBJECT_ID_INTERNAL_DAC2
:
1144 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
:
1145 if (radeon_encoder
->active_device
& (ATOM_DEVICE_TV_SUPPORT
))
1146 args
.v1
.ucDevice
= ATOM_DEVICE_TV1_INDEX
;
1147 else if (radeon_encoder
->active_device
& (ATOM_DEVICE_CV_SUPPORT
))
1148 args
.v1
.ucDevice
= ATOM_DEVICE_CV_INDEX
;
1150 args
.v1
.ucDevice
= ATOM_DEVICE_CRT2_INDEX
;
1155 args
.v2
.ucCRTC
= radeon_crtc
->crtc_id
;
1156 args
.v2
.ucEncodeMode
= atombios_get_encoder_mode(encoder
);
1157 switch (radeon_encoder
->encoder_id
) {
1158 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
1159 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
1160 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
1161 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
:
1162 dig
= radeon_encoder
->enc_priv
;
1163 switch (dig
->dig_encoder
) {
1165 args
.v2
.ucEncoderID
= ASIC_INT_DIG1_ENCODER_ID
;
1168 args
.v2
.ucEncoderID
= ASIC_INT_DIG2_ENCODER_ID
;
1171 args
.v2
.ucEncoderID
= ASIC_INT_DIG3_ENCODER_ID
;
1174 args
.v2
.ucEncoderID
= ASIC_INT_DIG4_ENCODER_ID
;
1177 args
.v2
.ucEncoderID
= ASIC_INT_DIG5_ENCODER_ID
;
1180 args
.v2
.ucEncoderID
= ASIC_INT_DIG6_ENCODER_ID
;
1184 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1
:
1185 args
.v2
.ucEncoderID
= ASIC_INT_DVO_ENCODER_ID
;
1187 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
:
1188 if (radeon_encoder
->active_device
& (ATOM_DEVICE_TV_SUPPORT
))
1189 args
.v2
.ucEncoderID
= ASIC_INT_TV_ENCODER_ID
;
1190 else if (radeon_encoder
->active_device
& (ATOM_DEVICE_CV_SUPPORT
))
1191 args
.v2
.ucEncoderID
= ASIC_INT_TV_ENCODER_ID
;
1193 args
.v2
.ucEncoderID
= ASIC_INT_DAC1_ENCODER_ID
;
1195 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
:
1196 if (radeon_encoder
->active_device
& (ATOM_DEVICE_TV_SUPPORT
))
1197 args
.v2
.ucEncoderID
= ASIC_INT_TV_ENCODER_ID
;
1198 else if (radeon_encoder
->active_device
& (ATOM_DEVICE_CV_SUPPORT
))
1199 args
.v2
.ucEncoderID
= ASIC_INT_TV_ENCODER_ID
;
1201 args
.v2
.ucEncoderID
= ASIC_INT_DAC2_ENCODER_ID
;
1208 DRM_ERROR("Unknown table version: %d, %d\n", frev
, crev
);
1212 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
1214 /* update scratch regs with new routing */
1215 radeon_atombios_encoder_crtc_scratch_regs(encoder
, radeon_crtc
->crtc_id
);
1219 atombios_apply_encoder_quirks(struct drm_encoder
*encoder
,
1220 struct drm_display_mode
*mode
)
1222 struct drm_device
*dev
= encoder
->dev
;
1223 struct radeon_device
*rdev
= dev
->dev_private
;
1224 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1225 struct radeon_crtc
*radeon_crtc
= to_radeon_crtc(encoder
->crtc
);
1227 /* Funky macbooks */
1228 if ((dev
->pdev
->device
== 0x71C5) &&
1229 (dev
->pdev
->subsystem_vendor
== 0x106b) &&
1230 (dev
->pdev
->subsystem_device
== 0x0080)) {
1231 if (radeon_encoder
->devices
& ATOM_DEVICE_LCD1_SUPPORT
) {
1232 uint32_t lvtma_bit_depth_control
= RREG32(AVIVO_LVTMA_BIT_DEPTH_CONTROL
);
1234 lvtma_bit_depth_control
&= ~AVIVO_LVTMA_BIT_DEPTH_CONTROL_TRUNCATE_EN
;
1235 lvtma_bit_depth_control
&= ~AVIVO_LVTMA_BIT_DEPTH_CONTROL_SPATIAL_DITHER_EN
;
1237 WREG32(AVIVO_LVTMA_BIT_DEPTH_CONTROL
, lvtma_bit_depth_control
);
1241 /* set scaler clears this on some chips */
1242 /* XXX check DCE4 */
1243 if (!(radeon_encoder
->active_device
& (ATOM_DEVICE_TV_SUPPORT
))) {
1244 if (ASIC_IS_AVIVO(rdev
) && (mode
->flags
& DRM_MODE_FLAG_INTERLACE
))
1245 WREG32(AVIVO_D1MODE_DATA_FORMAT
+ radeon_crtc
->crtc_offset
,
1246 AVIVO_D1MODE_INTERLEAVE_EN
);
1250 static int radeon_atom_pick_dig_encoder(struct drm_encoder
*encoder
)
1252 struct drm_device
*dev
= encoder
->dev
;
1253 struct radeon_device
*rdev
= dev
->dev_private
;
1254 struct radeon_crtc
*radeon_crtc
= to_radeon_crtc(encoder
->crtc
);
1255 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1256 struct drm_encoder
*test_encoder
;
1257 struct radeon_encoder_atom_dig
*dig
;
1258 uint32_t dig_enc_in_use
= 0;
1260 if (ASIC_IS_DCE4(rdev
)) {
1261 struct radeon_connector_atom_dig
*dig_connector
=
1262 radeon_get_atom_connector_priv_from_encoder(encoder
);
1264 switch (radeon_encoder
->encoder_id
) {
1265 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
1266 if (dig_connector
->linkb
)
1271 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
1272 if (dig_connector
->linkb
)
1277 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
1278 if (dig_connector
->linkb
)
1286 /* on DCE32 and encoder can driver any block so just crtc id */
1287 if (ASIC_IS_DCE32(rdev
)) {
1288 return radeon_crtc
->crtc_id
;
1291 /* on DCE3 - LVTMA can only be driven by DIGB */
1292 list_for_each_entry(test_encoder
, &dev
->mode_config
.encoder_list
, head
) {
1293 struct radeon_encoder
*radeon_test_encoder
;
1295 if (encoder
== test_encoder
)
1298 if (!radeon_encoder_is_digital(test_encoder
))
1301 radeon_test_encoder
= to_radeon_encoder(test_encoder
);
1302 dig
= radeon_test_encoder
->enc_priv
;
1304 if (dig
->dig_encoder
>= 0)
1305 dig_enc_in_use
|= (1 << dig
->dig_encoder
);
1308 if (radeon_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
) {
1309 if (dig_enc_in_use
& 0x2)
1310 DRM_ERROR("LVDS required digital encoder 2 but it was in use - stealing\n");
1313 if (!(dig_enc_in_use
& 1))
1319 radeon_atom_encoder_mode_set(struct drm_encoder
*encoder
,
1320 struct drm_display_mode
*mode
,
1321 struct drm_display_mode
*adjusted_mode
)
1323 struct drm_device
*dev
= encoder
->dev
;
1324 struct radeon_device
*rdev
= dev
->dev_private
;
1325 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1327 radeon_encoder
->pixel_clock
= adjusted_mode
->clock
;
1329 if (ASIC_IS_AVIVO(rdev
) && !ASIC_IS_DCE4(rdev
)) {
1330 if (radeon_encoder
->active_device
& (ATOM_DEVICE_CV_SUPPORT
| ATOM_DEVICE_TV_SUPPORT
))
1331 atombios_yuv_setup(encoder
, true);
1333 atombios_yuv_setup(encoder
, false);
1336 switch (radeon_encoder
->encoder_id
) {
1337 case ENCODER_OBJECT_ID_INTERNAL_TMDS1
:
1338 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1
:
1339 case ENCODER_OBJECT_ID_INTERNAL_LVDS
:
1340 case ENCODER_OBJECT_ID_INTERNAL_LVTM1
:
1341 atombios_digital_setup(encoder
, PANEL_ENCODER_ACTION_ENABLE
);
1343 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
1344 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
1345 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
1346 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
:
1347 if (ASIC_IS_DCE4(rdev
)) {
1348 /* disable the transmitter */
1349 atombios_dig_transmitter_setup(encoder
, ATOM_TRANSMITTER_ACTION_DISABLE
, 0, 0);
1350 /* setup and enable the encoder */
1351 atombios_dig_encoder_setup(encoder
, ATOM_ENCODER_CMD_SETUP
);
1353 /* init and enable the transmitter */
1354 atombios_dig_transmitter_setup(encoder
, ATOM_TRANSMITTER_ACTION_INIT
, 0, 0);
1355 atombios_dig_transmitter_setup(encoder
, ATOM_TRANSMITTER_ACTION_ENABLE
, 0, 0);
1357 /* disable the encoder and transmitter */
1358 atombios_dig_transmitter_setup(encoder
, ATOM_TRANSMITTER_ACTION_DISABLE
, 0, 0);
1359 atombios_dig_encoder_setup(encoder
, ATOM_DISABLE
);
1361 /* setup and enable the encoder and transmitter */
1362 atombios_dig_encoder_setup(encoder
, ATOM_ENABLE
);
1363 atombios_dig_transmitter_setup(encoder
, ATOM_TRANSMITTER_ACTION_INIT
, 0, 0);
1364 atombios_dig_transmitter_setup(encoder
, ATOM_TRANSMITTER_ACTION_SETUP
, 0, 0);
1365 atombios_dig_transmitter_setup(encoder
, ATOM_TRANSMITTER_ACTION_ENABLE
, 0, 0);
1368 case ENCODER_OBJECT_ID_INTERNAL_DDI
:
1369 atombios_ddia_setup(encoder
, ATOM_ENABLE
);
1371 case ENCODER_OBJECT_ID_INTERNAL_DVO1
:
1372 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1
:
1373 atombios_external_tmds_setup(encoder
, ATOM_ENABLE
);
1375 case ENCODER_OBJECT_ID_INTERNAL_DAC1
:
1376 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
:
1377 case ENCODER_OBJECT_ID_INTERNAL_DAC2
:
1378 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
:
1379 atombios_dac_setup(encoder
, ATOM_ENABLE
);
1380 if (radeon_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
| ATOM_DEVICE_CV_SUPPORT
)) {
1381 if (radeon_encoder
->active_device
& (ATOM_DEVICE_TV_SUPPORT
| ATOM_DEVICE_CV_SUPPORT
))
1382 atombios_tv_setup(encoder
, ATOM_ENABLE
);
1384 atombios_tv_setup(encoder
, ATOM_DISABLE
);
1388 atombios_apply_encoder_quirks(encoder
, adjusted_mode
);
1390 if (atombios_get_encoder_mode(encoder
) == ATOM_ENCODER_MODE_HDMI
) {
1391 r600_hdmi_enable(encoder
);
1392 r600_hdmi_setmode(encoder
, adjusted_mode
);
1397 atombios_dac_load_detect(struct drm_encoder
*encoder
, struct drm_connector
*connector
)
1399 struct drm_device
*dev
= encoder
->dev
;
1400 struct radeon_device
*rdev
= dev
->dev_private
;
1401 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1402 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1404 if (radeon_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
|
1405 ATOM_DEVICE_CV_SUPPORT
|
1406 ATOM_DEVICE_CRT_SUPPORT
)) {
1407 DAC_LOAD_DETECTION_PS_ALLOCATION args
;
1408 int index
= GetIndexIntoMasterTable(COMMAND
, DAC_LoadDetection
);
1411 memset(&args
, 0, sizeof(args
));
1413 if (!atom_parse_cmd_header(rdev
->mode_info
.atom_context
, index
, &frev
, &crev
))
1416 args
.sDacload
.ucMisc
= 0;
1418 if ((radeon_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_DAC1
) ||
1419 (radeon_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
))
1420 args
.sDacload
.ucDacType
= ATOM_DAC_A
;
1422 args
.sDacload
.ucDacType
= ATOM_DAC_B
;
1424 if (radeon_connector
->devices
& ATOM_DEVICE_CRT1_SUPPORT
)
1425 args
.sDacload
.usDeviceID
= cpu_to_le16(ATOM_DEVICE_CRT1_SUPPORT
);
1426 else if (radeon_connector
->devices
& ATOM_DEVICE_CRT2_SUPPORT
)
1427 args
.sDacload
.usDeviceID
= cpu_to_le16(ATOM_DEVICE_CRT2_SUPPORT
);
1428 else if (radeon_connector
->devices
& ATOM_DEVICE_CV_SUPPORT
) {
1429 args
.sDacload
.usDeviceID
= cpu_to_le16(ATOM_DEVICE_CV_SUPPORT
);
1431 args
.sDacload
.ucMisc
= DAC_LOAD_MISC_YPrPb
;
1432 } else if (radeon_connector
->devices
& ATOM_DEVICE_TV1_SUPPORT
) {
1433 args
.sDacload
.usDeviceID
= cpu_to_le16(ATOM_DEVICE_TV1_SUPPORT
);
1435 args
.sDacload
.ucMisc
= DAC_LOAD_MISC_YPrPb
;
1438 atom_execute_table(rdev
->mode_info
.atom_context
, index
, (uint32_t *)&args
);
1445 static enum drm_connector_status
1446 radeon_atom_dac_detect(struct drm_encoder
*encoder
, struct drm_connector
*connector
)
1448 struct drm_device
*dev
= encoder
->dev
;
1449 struct radeon_device
*rdev
= dev
->dev_private
;
1450 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1451 struct radeon_connector
*radeon_connector
= to_radeon_connector(connector
);
1452 uint32_t bios_0_scratch
;
1454 if (!atombios_dac_load_detect(encoder
, connector
)) {
1455 DRM_DEBUG("detect returned false \n");
1456 return connector_status_unknown
;
1459 if (rdev
->family
>= CHIP_R600
)
1460 bios_0_scratch
= RREG32(R600_BIOS_0_SCRATCH
);
1462 bios_0_scratch
= RREG32(RADEON_BIOS_0_SCRATCH
);
1464 DRM_DEBUG("Bios 0 scratch %x %08x\n", bios_0_scratch
, radeon_encoder
->devices
);
1465 if (radeon_connector
->devices
& ATOM_DEVICE_CRT1_SUPPORT
) {
1466 if (bios_0_scratch
& ATOM_S0_CRT1_MASK
)
1467 return connector_status_connected
;
1469 if (radeon_connector
->devices
& ATOM_DEVICE_CRT2_SUPPORT
) {
1470 if (bios_0_scratch
& ATOM_S0_CRT2_MASK
)
1471 return connector_status_connected
;
1473 if (radeon_connector
->devices
& ATOM_DEVICE_CV_SUPPORT
) {
1474 if (bios_0_scratch
& (ATOM_S0_CV_MASK
|ATOM_S0_CV_MASK_A
))
1475 return connector_status_connected
;
1477 if (radeon_connector
->devices
& ATOM_DEVICE_TV1_SUPPORT
) {
1478 if (bios_0_scratch
& (ATOM_S0_TV1_COMPOSITE
| ATOM_S0_TV1_COMPOSITE_A
))
1479 return connector_status_connected
; /* CTV */
1480 else if (bios_0_scratch
& (ATOM_S0_TV1_SVIDEO
| ATOM_S0_TV1_SVIDEO_A
))
1481 return connector_status_connected
; /* STV */
1483 return connector_status_disconnected
;
1486 static void radeon_atom_encoder_prepare(struct drm_encoder
*encoder
)
1488 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1490 if (radeon_encoder
->active_device
&
1491 (ATOM_DEVICE_DFP_SUPPORT
| ATOM_DEVICE_LCD_SUPPORT
)) {
1492 struct radeon_encoder_atom_dig
*dig
= radeon_encoder
->enc_priv
;
1494 dig
->dig_encoder
= radeon_atom_pick_dig_encoder(encoder
);
1497 radeon_atom_output_lock(encoder
, true);
1498 radeon_atom_encoder_dpms(encoder
, DRM_MODE_DPMS_OFF
);
1500 /* this is needed for the pll/ss setup to work correctly in some cases */
1501 atombios_set_encoder_crtc_source(encoder
);
1504 static void radeon_atom_encoder_commit(struct drm_encoder
*encoder
)
1506 radeon_atom_encoder_dpms(encoder
, DRM_MODE_DPMS_ON
);
1507 radeon_atom_output_lock(encoder
, false);
1510 static void radeon_atom_encoder_disable(struct drm_encoder
*encoder
)
1512 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1513 struct radeon_encoder_atom_dig
*dig
;
1514 radeon_atom_encoder_dpms(encoder
, DRM_MODE_DPMS_OFF
);
1516 if (radeon_encoder_is_digital(encoder
)) {
1517 if (atombios_get_encoder_mode(encoder
) == ATOM_ENCODER_MODE_HDMI
)
1518 r600_hdmi_disable(encoder
);
1519 dig
= radeon_encoder
->enc_priv
;
1520 dig
->dig_encoder
= -1;
1522 radeon_encoder
->active_device
= 0;
1525 static const struct drm_encoder_helper_funcs radeon_atom_dig_helper_funcs
= {
1526 .dpms
= radeon_atom_encoder_dpms
,
1527 .mode_fixup
= radeon_atom_mode_fixup
,
1528 .prepare
= radeon_atom_encoder_prepare
,
1529 .mode_set
= radeon_atom_encoder_mode_set
,
1530 .commit
= radeon_atom_encoder_commit
,
1531 .disable
= radeon_atom_encoder_disable
,
1532 /* no detect for TMDS/LVDS yet */
1535 static const struct drm_encoder_helper_funcs radeon_atom_dac_helper_funcs
= {
1536 .dpms
= radeon_atom_encoder_dpms
,
1537 .mode_fixup
= radeon_atom_mode_fixup
,
1538 .prepare
= radeon_atom_encoder_prepare
,
1539 .mode_set
= radeon_atom_encoder_mode_set
,
1540 .commit
= radeon_atom_encoder_commit
,
1541 .detect
= radeon_atom_dac_detect
,
1544 void radeon_enc_destroy(struct drm_encoder
*encoder
)
1546 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
1547 kfree(radeon_encoder
->enc_priv
);
1548 drm_encoder_cleanup(encoder
);
1549 kfree(radeon_encoder
);
1552 static const struct drm_encoder_funcs radeon_atom_enc_funcs
= {
1553 .destroy
= radeon_enc_destroy
,
1556 struct radeon_encoder_atom_dac
*
1557 radeon_atombios_set_dac_info(struct radeon_encoder
*radeon_encoder
)
1559 struct drm_device
*dev
= radeon_encoder
->base
.dev
;
1560 struct radeon_device
*rdev
= dev
->dev_private
;
1561 struct radeon_encoder_atom_dac
*dac
= kzalloc(sizeof(struct radeon_encoder_atom_dac
), GFP_KERNEL
);
1566 dac
->tv_std
= radeon_atombios_get_tv_info(rdev
);
1570 struct radeon_encoder_atom_dig
*
1571 radeon_atombios_set_dig_info(struct radeon_encoder
*radeon_encoder
)
1573 struct radeon_encoder_atom_dig
*dig
= kzalloc(sizeof(struct radeon_encoder_atom_dig
), GFP_KERNEL
);
1578 /* coherent mode by default */
1579 dig
->coherent_mode
= true;
1580 dig
->dig_encoder
= -1;
1586 radeon_add_atom_encoder(struct drm_device
*dev
, uint32_t encoder_id
, uint32_t supported_device
)
1588 struct radeon_device
*rdev
= dev
->dev_private
;
1589 struct drm_encoder
*encoder
;
1590 struct radeon_encoder
*radeon_encoder
;
1592 /* see if we already added it */
1593 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
1594 radeon_encoder
= to_radeon_encoder(encoder
);
1595 if (radeon_encoder
->encoder_id
== encoder_id
) {
1596 radeon_encoder
->devices
|= supported_device
;
1603 radeon_encoder
= kzalloc(sizeof(struct radeon_encoder
), GFP_KERNEL
);
1604 if (!radeon_encoder
)
1607 encoder
= &radeon_encoder
->base
;
1608 switch (rdev
->num_crtc
) {
1610 encoder
->possible_crtcs
= 0x1;
1614 encoder
->possible_crtcs
= 0x3;
1617 encoder
->possible_crtcs
= 0x3f;
1621 radeon_encoder
->enc_priv
= NULL
;
1623 radeon_encoder
->encoder_id
= encoder_id
;
1624 radeon_encoder
->devices
= supported_device
;
1625 radeon_encoder
->rmx_type
= RMX_OFF
;
1627 switch (radeon_encoder
->encoder_id
) {
1628 case ENCODER_OBJECT_ID_INTERNAL_LVDS
:
1629 case ENCODER_OBJECT_ID_INTERNAL_TMDS1
:
1630 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1
:
1631 case ENCODER_OBJECT_ID_INTERNAL_LVTM1
:
1632 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
1633 radeon_encoder
->rmx_type
= RMX_FULL
;
1634 drm_encoder_init(dev
, encoder
, &radeon_atom_enc_funcs
, DRM_MODE_ENCODER_LVDS
);
1635 radeon_encoder
->enc_priv
= radeon_atombios_get_lvds_info(radeon_encoder
);
1637 drm_encoder_init(dev
, encoder
, &radeon_atom_enc_funcs
, DRM_MODE_ENCODER_TMDS
);
1638 radeon_encoder
->enc_priv
= radeon_atombios_set_dig_info(radeon_encoder
);
1640 drm_encoder_helper_add(encoder
, &radeon_atom_dig_helper_funcs
);
1642 case ENCODER_OBJECT_ID_INTERNAL_DAC1
:
1643 drm_encoder_init(dev
, encoder
, &radeon_atom_enc_funcs
, DRM_MODE_ENCODER_DAC
);
1644 radeon_encoder
->enc_priv
= radeon_atombios_set_dac_info(radeon_encoder
);
1645 drm_encoder_helper_add(encoder
, &radeon_atom_dac_helper_funcs
);
1647 case ENCODER_OBJECT_ID_INTERNAL_DAC2
:
1648 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
:
1649 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
:
1650 drm_encoder_init(dev
, encoder
, &radeon_atom_enc_funcs
, DRM_MODE_ENCODER_TVDAC
);
1651 radeon_encoder
->enc_priv
= radeon_atombios_set_dac_info(radeon_encoder
);
1652 drm_encoder_helper_add(encoder
, &radeon_atom_dac_helper_funcs
);
1654 case ENCODER_OBJECT_ID_INTERNAL_DVO1
:
1655 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1
:
1656 case ENCODER_OBJECT_ID_INTERNAL_DDI
:
1657 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
1658 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
:
1659 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
1660 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
1661 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
1662 radeon_encoder
->rmx_type
= RMX_FULL
;
1663 drm_encoder_init(dev
, encoder
, &radeon_atom_enc_funcs
, DRM_MODE_ENCODER_LVDS
);
1664 radeon_encoder
->enc_priv
= radeon_atombios_get_lvds_info(radeon_encoder
);
1666 drm_encoder_init(dev
, encoder
, &radeon_atom_enc_funcs
, DRM_MODE_ENCODER_TMDS
);
1667 radeon_encoder
->enc_priv
= radeon_atombios_set_dig_info(radeon_encoder
);
1669 drm_encoder_helper_add(encoder
, &radeon_atom_dig_helper_funcs
);