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_KMS("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 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 void radeon_panel_mode_fixup(struct drm_encoder *encoder,
258 struct drm_display_mode *adjusted_mode)
260 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
261 struct drm_device *dev = encoder->dev;
262 struct radeon_device *rdev = dev->dev_private;
263 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
264 unsigned hblank = native_mode->htotal - native_mode->hdisplay;
265 unsigned vblank = native_mode->vtotal - native_mode->vdisplay;
266 unsigned hover = native_mode->hsync_start - native_mode->hdisplay;
267 unsigned vover = native_mode->vsync_start - native_mode->vdisplay;
268 unsigned hsync_width = native_mode->hsync_end - native_mode->hsync_start;
269 unsigned vsync_width = native_mode->vsync_end - native_mode->vsync_start;
271 adjusted_mode->clock = native_mode->clock;
272 adjusted_mode->flags = native_mode->flags;
274 if (ASIC_IS_AVIVO(rdev)) {
275 adjusted_mode->hdisplay = native_mode->hdisplay;
276 adjusted_mode->vdisplay = native_mode->vdisplay;
279 adjusted_mode->htotal = native_mode->hdisplay + hblank;
280 adjusted_mode->hsync_start = native_mode->hdisplay + hover;
281 adjusted_mode->hsync_end = adjusted_mode->hsync_start + hsync_width;
283 adjusted_mode->vtotal = native_mode->vdisplay + vblank;
284 adjusted_mode->vsync_start = native_mode->vdisplay + vover;
285 adjusted_mode->vsync_end = adjusted_mode->vsync_start + vsync_width;
287 drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V);
289 if (ASIC_IS_AVIVO(rdev)) {
290 adjusted_mode->crtc_hdisplay = native_mode->hdisplay;
291 adjusted_mode->crtc_vdisplay = native_mode->vdisplay;
294 adjusted_mode->crtc_htotal = adjusted_mode->crtc_hdisplay + hblank;
295 adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hdisplay + hover;
296 adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + hsync_width;
298 adjusted_mode->crtc_vtotal = adjusted_mode->crtc_vdisplay + vblank;
299 adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + vover;
300 adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + vsync_width;
304 static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
305 struct drm_display_mode *mode,
306 struct drm_display_mode *adjusted_mode)
308 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
309 struct drm_device *dev = encoder->dev;
310 struct radeon_device *rdev = dev->dev_private;
312 /* set the active encoder to connector routing */
313 radeon_encoder_set_active_device(encoder);
314 drm_mode_set_crtcinfo(adjusted_mode, 0);
317 if ((mode->flags & DRM_MODE_FLAG_INTERLACE)
318 && (mode->crtc_vsync_start < (mode->crtc_vdisplay + 2)))
319 adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + 2;
321 /* get the native mode for LVDS */
322 if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT))
323 radeon_panel_mode_fixup(encoder, adjusted_mode);
325 /* get the native mode for TV */
326 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) {
327 struct radeon_encoder_atom_dac *tv_dac = radeon_encoder->enc_priv;
329 if (tv_dac->tv_std == TV_STD_NTSC ||
330 tv_dac->tv_std == TV_STD_NTSC_J ||
331 tv_dac->tv_std == TV_STD_PAL_M)
332 radeon_atom_get_tv_timings(rdev, 0, adjusted_mode);
334 radeon_atom_get_tv_timings(rdev, 1, adjusted_mode);
338 if (ASIC_IS_DCE3(rdev) &&
339 (radeon_encoder->active_device & (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT))) {
340 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
341 radeon_dp_set_link_config(connector, mode);
348 atombios_dac_setup(struct drm_encoder *encoder, int action)
350 struct drm_device *dev = encoder->dev;
351 struct radeon_device *rdev = dev->dev_private;
352 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
353 DAC_ENCODER_CONTROL_PS_ALLOCATION args;
355 struct radeon_encoder_atom_dac *dac_info = radeon_encoder->enc_priv;
357 memset(&args, 0, sizeof(args));
359 switch (radeon_encoder->encoder_id) {
360 case ENCODER_OBJECT_ID_INTERNAL_DAC1:
361 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
362 index = GetIndexIntoMasterTable(COMMAND, DAC1EncoderControl);
364 case ENCODER_OBJECT_ID_INTERNAL_DAC2:
365 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
366 index = GetIndexIntoMasterTable(COMMAND, DAC2EncoderControl);
370 args.ucAction = action;
372 if (radeon_encoder->active_device & (ATOM_DEVICE_CRT_SUPPORT))
373 args.ucDacStandard = ATOM_DAC1_PS2;
374 else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
375 args.ucDacStandard = ATOM_DAC1_CV;
377 switch (dac_info->tv_std) {
380 case TV_STD_SCART_PAL:
383 args.ucDacStandard = ATOM_DAC1_PAL;
389 args.ucDacStandard = ATOM_DAC1_NTSC;
393 args.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
395 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
400 atombios_tv_setup(struct drm_encoder *encoder, int action)
402 struct drm_device *dev = encoder->dev;
403 struct radeon_device *rdev = dev->dev_private;
404 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
405 TV_ENCODER_CONTROL_PS_ALLOCATION args;
407 struct radeon_encoder_atom_dac *dac_info = radeon_encoder->enc_priv;
409 memset(&args, 0, sizeof(args));
411 index = GetIndexIntoMasterTable(COMMAND, TVEncoderControl);
413 args.sTVEncoder.ucAction = action;
415 if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
416 args.sTVEncoder.ucTvStandard = ATOM_TV_CV;
418 switch (dac_info->tv_std) {
420 args.sTVEncoder.ucTvStandard = ATOM_TV_NTSC;
423 args.sTVEncoder.ucTvStandard = ATOM_TV_PAL;
426 args.sTVEncoder.ucTvStandard = ATOM_TV_PALM;
429 args.sTVEncoder.ucTvStandard = ATOM_TV_PAL60;
432 args.sTVEncoder.ucTvStandard = ATOM_TV_NTSCJ;
434 case TV_STD_SCART_PAL:
435 args.sTVEncoder.ucTvStandard = ATOM_TV_PAL; /* ??? */
438 args.sTVEncoder.ucTvStandard = ATOM_TV_SECAM;
441 args.sTVEncoder.ucTvStandard = ATOM_TV_PALCN;
444 args.sTVEncoder.ucTvStandard = ATOM_TV_NTSC;
449 args.sTVEncoder.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
451 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
456 atombios_external_tmds_setup(struct drm_encoder *encoder, int action)
458 struct drm_device *dev = encoder->dev;
459 struct radeon_device *rdev = dev->dev_private;
460 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
461 ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION args;
464 memset(&args, 0, sizeof(args));
466 index = GetIndexIntoMasterTable(COMMAND, DVOEncoderControl);
468 args.sXTmdsEncoder.ucEnable = action;
470 if (radeon_encoder->pixel_clock > 165000)
471 args.sXTmdsEncoder.ucMisc = PANEL_ENCODER_MISC_DUAL;
473 /*if (pScrn->rgbBits == 8)*/
474 args.sXTmdsEncoder.ucMisc |= (1 << 1);
476 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
481 atombios_ddia_setup(struct drm_encoder *encoder, int action)
483 struct drm_device *dev = encoder->dev;
484 struct radeon_device *rdev = dev->dev_private;
485 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
486 DVO_ENCODER_CONTROL_PS_ALLOCATION args;
489 memset(&args, 0, sizeof(args));
491 index = GetIndexIntoMasterTable(COMMAND, DVOEncoderControl);
493 args.sDVOEncoder.ucAction = action;
494 args.sDVOEncoder.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
496 if (radeon_encoder->pixel_clock > 165000)
497 args.sDVOEncoder.usDevAttr.sDigAttrib.ucAttribute = PANEL_ENCODER_MISC_DUAL;
499 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
503 union lvds_encoder_control {
504 LVDS_ENCODER_CONTROL_PS_ALLOCATION v1;
505 LVDS_ENCODER_CONTROL_PS_ALLOCATION_V2 v2;
509 atombios_digital_setup(struct drm_encoder *encoder, int action)
511 struct drm_device *dev = encoder->dev;
512 struct radeon_device *rdev = dev->dev_private;
513 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
514 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
515 struct radeon_connector_atom_dig *dig_connector =
516 radeon_get_atom_connector_priv_from_encoder(encoder);
517 union lvds_encoder_control args;
519 int hdmi_detected = 0;
522 if (!dig || !dig_connector)
525 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI)
528 memset(&args, 0, sizeof(args));
530 switch (radeon_encoder->encoder_id) {
531 case ENCODER_OBJECT_ID_INTERNAL_LVDS:
532 index = GetIndexIntoMasterTable(COMMAND, LVDSEncoderControl);
534 case ENCODER_OBJECT_ID_INTERNAL_TMDS1:
535 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
536 index = GetIndexIntoMasterTable(COMMAND, TMDS1EncoderControl);
538 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
539 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
540 index = GetIndexIntoMasterTable(COMMAND, LVDSEncoderControl);
542 index = GetIndexIntoMasterTable(COMMAND, TMDS2EncoderControl);
546 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
555 args.v1.ucAction = action;
557 args.v1.ucMisc |= PANEL_ENCODER_MISC_HDMI_TYPE;
558 args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
559 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
560 if (dig->lvds_misc & ATOM_PANEL_MISC_DUAL)
561 args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL;
562 if (dig->lvds_misc & ATOM_PANEL_MISC_888RGB)
563 args.v1.ucMisc |= (1 << 1);
565 if (dig_connector->linkb)
566 args.v1.ucMisc |= PANEL_ENCODER_MISC_TMDS_LINKB;
567 if (radeon_encoder->pixel_clock > 165000)
568 args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL;
569 /*if (pScrn->rgbBits == 8) */
570 args.v1.ucMisc |= (1 << 1);
576 args.v2.ucAction = action;
578 if (dig->coherent_mode)
579 args.v2.ucMisc |= PANEL_ENCODER_MISC_COHERENT;
582 args.v2.ucMisc |= PANEL_ENCODER_MISC_HDMI_TYPE;
583 args.v2.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
584 args.v2.ucTruncate = 0;
585 args.v2.ucSpatial = 0;
586 args.v2.ucTemporal = 0;
588 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
589 if (dig->lvds_misc & ATOM_PANEL_MISC_DUAL)
590 args.v2.ucMisc |= PANEL_ENCODER_MISC_DUAL;
591 if (dig->lvds_misc & ATOM_PANEL_MISC_SPATIAL) {
592 args.v2.ucSpatial = PANEL_ENCODER_SPATIAL_DITHER_EN;
593 if (dig->lvds_misc & ATOM_PANEL_MISC_888RGB)
594 args.v2.ucSpatial |= PANEL_ENCODER_SPATIAL_DITHER_DEPTH;
596 if (dig->lvds_misc & ATOM_PANEL_MISC_TEMPORAL) {
597 args.v2.ucTemporal = PANEL_ENCODER_TEMPORAL_DITHER_EN;
598 if (dig->lvds_misc & ATOM_PANEL_MISC_888RGB)
599 args.v2.ucTemporal |= PANEL_ENCODER_TEMPORAL_DITHER_DEPTH;
600 if (((dig->lvds_misc >> ATOM_PANEL_MISC_GREY_LEVEL_SHIFT) & 0x3) == 2)
601 args.v2.ucTemporal |= PANEL_ENCODER_TEMPORAL_LEVEL_4;
604 if (dig_connector->linkb)
605 args.v2.ucMisc |= PANEL_ENCODER_MISC_TMDS_LINKB;
606 if (radeon_encoder->pixel_clock > 165000)
607 args.v2.ucMisc |= PANEL_ENCODER_MISC_DUAL;
611 DRM_ERROR("Unknown table version %d, %d\n", frev, crev);
616 DRM_ERROR("Unknown table version %d, %d\n", frev, crev);
620 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
624 atombios_get_encoder_mode(struct drm_encoder *encoder)
626 struct drm_connector *connector;
627 struct radeon_connector *radeon_connector;
628 struct radeon_connector_atom_dig *dig_connector;
630 connector = radeon_get_connector_for_encoder(encoder);
634 radeon_connector = to_radeon_connector(connector);
636 switch (connector->connector_type) {
637 case DRM_MODE_CONNECTOR_DVII:
638 case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */
639 if (drm_detect_hdmi_monitor(radeon_connector->edid))
640 return ATOM_ENCODER_MODE_HDMI;
641 else if (radeon_connector->use_digital)
642 return ATOM_ENCODER_MODE_DVI;
644 return ATOM_ENCODER_MODE_CRT;
646 case DRM_MODE_CONNECTOR_DVID:
647 case DRM_MODE_CONNECTOR_HDMIA:
649 if (drm_detect_hdmi_monitor(radeon_connector->edid))
650 return ATOM_ENCODER_MODE_HDMI;
652 return ATOM_ENCODER_MODE_DVI;
654 case DRM_MODE_CONNECTOR_LVDS:
655 return ATOM_ENCODER_MODE_LVDS;
657 case DRM_MODE_CONNECTOR_DisplayPort:
658 case DRM_MODE_CONNECTOR_eDP:
659 dig_connector = radeon_connector->con_priv;
660 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
661 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP))
662 return ATOM_ENCODER_MODE_DP;
663 else if (drm_detect_hdmi_monitor(radeon_connector->edid))
664 return ATOM_ENCODER_MODE_HDMI;
666 return ATOM_ENCODER_MODE_DVI;
668 case DRM_MODE_CONNECTOR_DVIA:
669 case DRM_MODE_CONNECTOR_VGA:
670 return ATOM_ENCODER_MODE_CRT;
672 case DRM_MODE_CONNECTOR_Composite:
673 case DRM_MODE_CONNECTOR_SVIDEO:
674 case DRM_MODE_CONNECTOR_9PinDIN:
676 return ATOM_ENCODER_MODE_TV;
677 /*return ATOM_ENCODER_MODE_CV;*/
683 * DIG Encoder/Transmitter Setup
686 * - 2 DIG transmitter blocks. UNIPHY (links A and B) and LVTMA.
687 * Supports up to 3 digital outputs
688 * - 2 DIG encoder blocks.
689 * DIG1 can drive UNIPHY link A or link B
690 * DIG2 can drive UNIPHY link B or LVTMA
693 * - 3 DIG transmitter blocks. UNIPHY0/1/2 (links A and B).
694 * Supports up to 5 digital outputs
695 * - 2 DIG encoder blocks.
696 * DIG1/2 can drive UNIPHY0/1/2 link A or link B
699 * - 3 DIG transmitter blocks UNPHY0/1/2 (links A and B).
700 * Supports up to 6 digital outputs
701 * - 6 DIG encoder blocks.
702 * - DIG to PHY mapping is hardcoded
703 * DIG1 drives UNIPHY0 link A, A+B
704 * DIG2 drives UNIPHY0 link B
705 * DIG3 drives UNIPHY1 link A, A+B
706 * DIG4 drives UNIPHY1 link B
707 * DIG5 drives UNIPHY2 link A, A+B
708 * DIG6 drives UNIPHY2 link B
711 * crtc -> dig encoder -> UNIPHY/LVTMA (1 or 2 links)
713 * crtc0 -> dig2 -> LVTMA links A+B -> TMDS/HDMI
714 * crtc1 -> dig1 -> UNIPHY0 link B -> DP
715 * crtc0 -> dig1 -> UNIPHY2 link A -> LVDS
716 * crtc1 -> dig2 -> UNIPHY1 link B+A -> TMDS/HDMI
719 union dig_encoder_control {
720 DIG_ENCODER_CONTROL_PS_ALLOCATION v1;
721 DIG_ENCODER_CONTROL_PARAMETERS_V2 v2;
722 DIG_ENCODER_CONTROL_PARAMETERS_V3 v3;
726 atombios_dig_encoder_setup(struct drm_encoder *encoder, int action)
728 struct drm_device *dev = encoder->dev;
729 struct radeon_device *rdev = dev->dev_private;
730 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
731 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
732 struct radeon_connector_atom_dig *dig_connector =
733 radeon_get_atom_connector_priv_from_encoder(encoder);
734 union dig_encoder_control args;
738 if (!dig || !dig_connector)
741 memset(&args, 0, sizeof(args));
743 if (ASIC_IS_DCE4(rdev))
744 index = GetIndexIntoMasterTable(COMMAND, DIGxEncoderControl);
746 if (dig->dig_encoder)
747 index = GetIndexIntoMasterTable(COMMAND, DIG2EncoderControl);
749 index = GetIndexIntoMasterTable(COMMAND, DIG1EncoderControl);
752 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
755 args.v1.ucAction = action;
756 args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
757 args.v1.ucEncoderMode = atombios_get_encoder_mode(encoder);
759 if (args.v1.ucEncoderMode == ATOM_ENCODER_MODE_DP) {
760 if (dig_connector->dp_clock == 270000)
761 args.v1.ucConfig |= ATOM_ENCODER_CONFIG_DPLINKRATE_2_70GHZ;
762 args.v1.ucLaneNum = dig_connector->dp_lane_count;
763 } else if (radeon_encoder->pixel_clock > 165000)
764 args.v1.ucLaneNum = 8;
766 args.v1.ucLaneNum = 4;
768 if (ASIC_IS_DCE4(rdev)) {
769 args.v3.acConfig.ucDigSel = dig->dig_encoder;
770 args.v3.ucBitPerColor = PANEL_8BIT_PER_COLOR;
772 switch (radeon_encoder->encoder_id) {
773 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
774 args.v1.ucConfig = ATOM_ENCODER_CONFIG_V2_TRANSMITTER1;
776 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
777 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
778 args.v1.ucConfig = ATOM_ENCODER_CONFIG_V2_TRANSMITTER2;
780 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
781 args.v1.ucConfig = ATOM_ENCODER_CONFIG_V2_TRANSMITTER3;
784 if (dig_connector->linkb)
785 args.v1.ucConfig |= ATOM_ENCODER_CONFIG_LINKB;
787 args.v1.ucConfig |= ATOM_ENCODER_CONFIG_LINKA;
790 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
794 union dig_transmitter_control {
795 DIG_TRANSMITTER_CONTROL_PS_ALLOCATION v1;
796 DIG_TRANSMITTER_CONTROL_PARAMETERS_V2 v2;
797 DIG_TRANSMITTER_CONTROL_PARAMETERS_V3 v3;
801 atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t lane_num, uint8_t lane_set)
803 struct drm_device *dev = encoder->dev;
804 struct radeon_device *rdev = dev->dev_private;
805 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
806 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
807 struct radeon_connector_atom_dig *dig_connector =
808 radeon_get_atom_connector_priv_from_encoder(encoder);
809 struct drm_connector *connector;
810 struct radeon_connector *radeon_connector;
811 union dig_transmitter_control args;
817 if (!dig || !dig_connector)
820 connector = radeon_get_connector_for_encoder(encoder);
821 radeon_connector = to_radeon_connector(connector);
823 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP)
826 memset(&args, 0, sizeof(args));
828 if (ASIC_IS_DCE32(rdev) || ASIC_IS_DCE4(rdev))
829 index = GetIndexIntoMasterTable(COMMAND, UNIPHYTransmitterControl);
831 switch (radeon_encoder->encoder_id) {
832 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
833 index = GetIndexIntoMasterTable(COMMAND, DIG1TransmitterControl);
835 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
836 index = GetIndexIntoMasterTable(COMMAND, DIG2TransmitterControl);
841 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
844 args.v1.ucAction = action;
845 if (action == ATOM_TRANSMITTER_ACTION_INIT) {
846 args.v1.usInitInfo = radeon_connector->connector_object_id;
847 } else if (action == ATOM_TRANSMITTER_ACTION_SETUP_VSEMPH) {
848 args.v1.asMode.ucLaneSel = lane_num;
849 args.v1.asMode.ucLaneSet = lane_set;
852 args.v1.usPixelClock =
853 cpu_to_le16(dig_connector->dp_clock / 10);
854 else if (radeon_encoder->pixel_clock > 165000)
855 args.v1.usPixelClock = cpu_to_le16((radeon_encoder->pixel_clock / 2) / 10);
857 args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
859 if (ASIC_IS_DCE4(rdev)) {
861 args.v3.ucLaneNum = dig_connector->dp_lane_count;
862 else if (radeon_encoder->pixel_clock > 165000)
863 args.v3.ucLaneNum = 8;
865 args.v3.ucLaneNum = 4;
867 if (dig_connector->linkb) {
868 args.v3.acConfig.ucLinkSel = 1;
869 args.v3.acConfig.ucEncoderSel = 1;
872 /* Select the PLL for the PHY
873 * DP PHY should be clocked from external src if there is
877 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
878 pll_id = radeon_crtc->pll_id;
880 if (is_dp && rdev->clock.dp_extclk)
881 args.v3.acConfig.ucRefClkSource = 2; /* external src */
883 args.v3.acConfig.ucRefClkSource = pll_id;
885 switch (radeon_encoder->encoder_id) {
886 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
887 args.v3.acConfig.ucTransmitterSel = 0;
889 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
890 args.v3.acConfig.ucTransmitterSel = 1;
892 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
893 args.v3.acConfig.ucTransmitterSel = 2;
898 args.v3.acConfig.fCoherentMode = 1; /* DP requires coherent */
899 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
900 if (dig->coherent_mode)
901 args.v3.acConfig.fCoherentMode = 1;
902 if (radeon_encoder->pixel_clock > 165000)
903 args.v3.acConfig.fDualLinkConnector = 1;
905 } else if (ASIC_IS_DCE32(rdev)) {
906 args.v2.acConfig.ucEncoderSel = dig->dig_encoder;
907 if (dig_connector->linkb)
908 args.v2.acConfig.ucLinkSel = 1;
910 switch (radeon_encoder->encoder_id) {
911 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
912 args.v2.acConfig.ucTransmitterSel = 0;
914 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
915 args.v2.acConfig.ucTransmitterSel = 1;
917 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
918 args.v2.acConfig.ucTransmitterSel = 2;
923 args.v2.acConfig.fCoherentMode = 1;
924 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
925 if (dig->coherent_mode)
926 args.v2.acConfig.fCoherentMode = 1;
927 if (radeon_encoder->pixel_clock > 165000)
928 args.v2.acConfig.fDualLinkConnector = 1;
931 args.v1.ucConfig = ATOM_TRANSMITTER_CONFIG_CLKSRC_PPLL;
933 if (dig->dig_encoder)
934 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_DIG2_ENCODER;
936 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_DIG1_ENCODER;
938 if ((rdev->flags & RADEON_IS_IGP) &&
939 (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_UNIPHY)) {
940 if (is_dp || (radeon_encoder->pixel_clock <= 165000)) {
941 if (dig_connector->igp_lane_info & 0x1)
942 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_3;
943 else if (dig_connector->igp_lane_info & 0x2)
944 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_4_7;
945 else if (dig_connector->igp_lane_info & 0x4)
946 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_11;
947 else if (dig_connector->igp_lane_info & 0x8)
948 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_12_15;
950 if (dig_connector->igp_lane_info & 0x3)
951 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_7;
952 else if (dig_connector->igp_lane_info & 0xc)
953 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_15;
957 if (dig_connector->linkb)
958 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LINKB;
960 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LINKA;
963 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_COHERENT;
964 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
965 if (dig->coherent_mode)
966 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_COHERENT;
967 if (radeon_encoder->pixel_clock > 165000)
968 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_8LANE_LINK;
972 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
976 atombios_yuv_setup(struct drm_encoder *encoder, bool enable)
978 struct drm_device *dev = encoder->dev;
979 struct radeon_device *rdev = dev->dev_private;
980 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
981 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
982 ENABLE_YUV_PS_ALLOCATION args;
983 int index = GetIndexIntoMasterTable(COMMAND, EnableYUV);
986 memset(&args, 0, sizeof(args));
988 if (rdev->family >= CHIP_R600)
989 reg = R600_BIOS_3_SCRATCH;
991 reg = RADEON_BIOS_3_SCRATCH;
993 /* XXX: fix up scratch reg handling */
995 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))
996 WREG32(reg, (ATOM_S3_TV1_ACTIVE |
997 (radeon_crtc->crtc_id << 18)));
998 else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
999 WREG32(reg, (ATOM_S3_CV_ACTIVE | (radeon_crtc->crtc_id << 24)));
1004 args.ucEnable = ATOM_ENABLE;
1005 args.ucCRTC = radeon_crtc->crtc_id;
1007 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1013 radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1015 struct drm_device *dev = encoder->dev;
1016 struct radeon_device *rdev = dev->dev_private;
1017 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1018 DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION args;
1020 bool is_dig = false;
1022 memset(&args, 0, sizeof(args));
1024 DRM_DEBUG_KMS("encoder dpms %d to mode %d, devices %08x, active_devices %08x\n",
1025 radeon_encoder->encoder_id, mode, radeon_encoder->devices,
1026 radeon_encoder->active_device);
1027 switch (radeon_encoder->encoder_id) {
1028 case ENCODER_OBJECT_ID_INTERNAL_TMDS1:
1029 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
1030 index = GetIndexIntoMasterTable(COMMAND, TMDSAOutputControl);
1032 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
1033 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
1034 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
1035 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
1038 case ENCODER_OBJECT_ID_INTERNAL_DVO1:
1039 case ENCODER_OBJECT_ID_INTERNAL_DDI:
1040 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
1041 index = GetIndexIntoMasterTable(COMMAND, DVOOutputControl);
1043 case ENCODER_OBJECT_ID_INTERNAL_LVDS:
1044 index = GetIndexIntoMasterTable(COMMAND, LCD1OutputControl);
1046 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
1047 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
1048 index = GetIndexIntoMasterTable(COMMAND, LCD1OutputControl);
1050 index = GetIndexIntoMasterTable(COMMAND, LVTMAOutputControl);
1052 case ENCODER_OBJECT_ID_INTERNAL_DAC1:
1053 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
1054 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))
1055 index = GetIndexIntoMasterTable(COMMAND, TV1OutputControl);
1056 else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
1057 index = GetIndexIntoMasterTable(COMMAND, CV1OutputControl);
1059 index = GetIndexIntoMasterTable(COMMAND, DAC1OutputControl);
1061 case ENCODER_OBJECT_ID_INTERNAL_DAC2:
1062 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
1063 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))
1064 index = GetIndexIntoMasterTable(COMMAND, TV1OutputControl);
1065 else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
1066 index = GetIndexIntoMasterTable(COMMAND, CV1OutputControl);
1068 index = GetIndexIntoMasterTable(COMMAND, DAC2OutputControl);
1074 case DRM_MODE_DPMS_ON:
1075 if (!ASIC_IS_DCE4(rdev))
1076 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
1077 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) {
1078 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1080 dp_link_train(encoder, connector);
1081 if (ASIC_IS_DCE4(rdev))
1082 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON);
1085 case DRM_MODE_DPMS_STANDBY:
1086 case DRM_MODE_DPMS_SUSPEND:
1087 case DRM_MODE_DPMS_OFF:
1088 if (!ASIC_IS_DCE4(rdev))
1089 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT, 0, 0);
1090 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) {
1091 if (ASIC_IS_DCE4(rdev))
1092 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_OFF);
1098 case DRM_MODE_DPMS_ON:
1099 args.ucAction = ATOM_ENABLE;
1101 case DRM_MODE_DPMS_STANDBY:
1102 case DRM_MODE_DPMS_SUSPEND:
1103 case DRM_MODE_DPMS_OFF:
1104 args.ucAction = ATOM_DISABLE;
1107 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1109 radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
1113 union crtc_source_param {
1114 SELECT_CRTC_SOURCE_PS_ALLOCATION v1;
1115 SELECT_CRTC_SOURCE_PARAMETERS_V2 v2;
1119 atombios_set_encoder_crtc_source(struct drm_encoder *encoder)
1121 struct drm_device *dev = encoder->dev;
1122 struct radeon_device *rdev = dev->dev_private;
1123 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1124 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
1125 union crtc_source_param args;
1126 int index = GetIndexIntoMasterTable(COMMAND, SelectCRTC_Source);
1128 struct radeon_encoder_atom_dig *dig;
1130 memset(&args, 0, sizeof(args));
1132 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
1140 if (ASIC_IS_AVIVO(rdev))
1141 args.v1.ucCRTC = radeon_crtc->crtc_id;
1143 if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_DAC1) {
1144 args.v1.ucCRTC = radeon_crtc->crtc_id;
1146 args.v1.ucCRTC = radeon_crtc->crtc_id << 2;
1149 switch (radeon_encoder->encoder_id) {
1150 case ENCODER_OBJECT_ID_INTERNAL_TMDS1:
1151 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
1152 args.v1.ucDevice = ATOM_DEVICE_DFP1_INDEX;
1154 case ENCODER_OBJECT_ID_INTERNAL_LVDS:
1155 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
1156 if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT)
1157 args.v1.ucDevice = ATOM_DEVICE_LCD1_INDEX;
1159 args.v1.ucDevice = ATOM_DEVICE_DFP3_INDEX;
1161 case ENCODER_OBJECT_ID_INTERNAL_DVO1:
1162 case ENCODER_OBJECT_ID_INTERNAL_DDI:
1163 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
1164 args.v1.ucDevice = ATOM_DEVICE_DFP2_INDEX;
1166 case ENCODER_OBJECT_ID_INTERNAL_DAC1:
1167 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
1168 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))
1169 args.v1.ucDevice = ATOM_DEVICE_TV1_INDEX;
1170 else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
1171 args.v1.ucDevice = ATOM_DEVICE_CV_INDEX;
1173 args.v1.ucDevice = ATOM_DEVICE_CRT1_INDEX;
1175 case ENCODER_OBJECT_ID_INTERNAL_DAC2:
1176 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
1177 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))
1178 args.v1.ucDevice = ATOM_DEVICE_TV1_INDEX;
1179 else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
1180 args.v1.ucDevice = ATOM_DEVICE_CV_INDEX;
1182 args.v1.ucDevice = ATOM_DEVICE_CRT2_INDEX;
1187 args.v2.ucCRTC = radeon_crtc->crtc_id;
1188 args.v2.ucEncodeMode = atombios_get_encoder_mode(encoder);
1189 switch (radeon_encoder->encoder_id) {
1190 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
1191 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
1192 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
1193 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
1194 dig = radeon_encoder->enc_priv;
1195 switch (dig->dig_encoder) {
1197 args.v2.ucEncoderID = ASIC_INT_DIG1_ENCODER_ID;
1200 args.v2.ucEncoderID = ASIC_INT_DIG2_ENCODER_ID;
1203 args.v2.ucEncoderID = ASIC_INT_DIG3_ENCODER_ID;
1206 args.v2.ucEncoderID = ASIC_INT_DIG4_ENCODER_ID;
1209 args.v2.ucEncoderID = ASIC_INT_DIG5_ENCODER_ID;
1212 args.v2.ucEncoderID = ASIC_INT_DIG6_ENCODER_ID;
1216 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
1217 args.v2.ucEncoderID = ASIC_INT_DVO_ENCODER_ID;
1219 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
1220 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))
1221 args.v2.ucEncoderID = ASIC_INT_TV_ENCODER_ID;
1222 else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
1223 args.v2.ucEncoderID = ASIC_INT_TV_ENCODER_ID;
1225 args.v2.ucEncoderID = ASIC_INT_DAC1_ENCODER_ID;
1227 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
1228 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))
1229 args.v2.ucEncoderID = ASIC_INT_TV_ENCODER_ID;
1230 else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
1231 args.v2.ucEncoderID = ASIC_INT_TV_ENCODER_ID;
1233 args.v2.ucEncoderID = ASIC_INT_DAC2_ENCODER_ID;
1240 DRM_ERROR("Unknown table version: %d, %d\n", frev, crev);
1244 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1246 /* update scratch regs with new routing */
1247 radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
1251 atombios_apply_encoder_quirks(struct drm_encoder *encoder,
1252 struct drm_display_mode *mode)
1254 struct drm_device *dev = encoder->dev;
1255 struct radeon_device *rdev = dev->dev_private;
1256 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1257 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
1259 /* Funky macbooks */
1260 if ((dev->pdev->device == 0x71C5) &&
1261 (dev->pdev->subsystem_vendor == 0x106b) &&
1262 (dev->pdev->subsystem_device == 0x0080)) {
1263 if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
1264 uint32_t lvtma_bit_depth_control = RREG32(AVIVO_LVTMA_BIT_DEPTH_CONTROL);
1266 lvtma_bit_depth_control &= ~AVIVO_LVTMA_BIT_DEPTH_CONTROL_TRUNCATE_EN;
1267 lvtma_bit_depth_control &= ~AVIVO_LVTMA_BIT_DEPTH_CONTROL_SPATIAL_DITHER_EN;
1269 WREG32(AVIVO_LVTMA_BIT_DEPTH_CONTROL, lvtma_bit_depth_control);
1273 /* set scaler clears this on some chips */
1274 /* XXX check DCE4 */
1275 if (!(radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))) {
1276 if (ASIC_IS_AVIVO(rdev) && (mode->flags & DRM_MODE_FLAG_INTERLACE))
1277 WREG32(AVIVO_D1MODE_DATA_FORMAT + radeon_crtc->crtc_offset,
1278 AVIVO_D1MODE_INTERLEAVE_EN);
1282 static int radeon_atom_pick_dig_encoder(struct drm_encoder *encoder)
1284 struct drm_device *dev = encoder->dev;
1285 struct radeon_device *rdev = dev->dev_private;
1286 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
1287 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1288 struct drm_encoder *test_encoder;
1289 struct radeon_encoder_atom_dig *dig;
1290 uint32_t dig_enc_in_use = 0;
1292 if (ASIC_IS_DCE4(rdev)) {
1293 struct radeon_connector_atom_dig *dig_connector =
1294 radeon_get_atom_connector_priv_from_encoder(encoder);
1296 switch (radeon_encoder->encoder_id) {
1297 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
1298 if (dig_connector->linkb)
1303 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
1304 if (dig_connector->linkb)
1309 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
1310 if (dig_connector->linkb)
1318 /* on DCE32 and encoder can driver any block so just crtc id */
1319 if (ASIC_IS_DCE32(rdev)) {
1320 return radeon_crtc->crtc_id;
1323 /* on DCE3 - LVTMA can only be driven by DIGB */
1324 list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) {
1325 struct radeon_encoder *radeon_test_encoder;
1327 if (encoder == test_encoder)
1330 if (!radeon_encoder_is_digital(test_encoder))
1333 radeon_test_encoder = to_radeon_encoder(test_encoder);
1334 dig = radeon_test_encoder->enc_priv;
1336 if (dig->dig_encoder >= 0)
1337 dig_enc_in_use |= (1 << dig->dig_encoder);
1340 if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA) {
1341 if (dig_enc_in_use & 0x2)
1342 DRM_ERROR("LVDS required digital encoder 2 but it was in use - stealing\n");
1345 if (!(dig_enc_in_use & 1))
1351 radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
1352 struct drm_display_mode *mode,
1353 struct drm_display_mode *adjusted_mode)
1355 struct drm_device *dev = encoder->dev;
1356 struct radeon_device *rdev = dev->dev_private;
1357 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1359 radeon_encoder->pixel_clock = adjusted_mode->clock;
1361 if (ASIC_IS_AVIVO(rdev) && !ASIC_IS_DCE4(rdev)) {
1362 if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT | ATOM_DEVICE_TV_SUPPORT))
1363 atombios_yuv_setup(encoder, true);
1365 atombios_yuv_setup(encoder, false);
1368 switch (radeon_encoder->encoder_id) {
1369 case ENCODER_OBJECT_ID_INTERNAL_TMDS1:
1370 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
1371 case ENCODER_OBJECT_ID_INTERNAL_LVDS:
1372 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
1373 atombios_digital_setup(encoder, PANEL_ENCODER_ACTION_ENABLE);
1375 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
1376 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
1377 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
1378 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
1379 if (ASIC_IS_DCE4(rdev)) {
1380 /* disable the transmitter */
1381 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE, 0, 0);
1382 /* setup and enable the encoder */
1383 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_SETUP);
1385 /* init and enable the transmitter */
1386 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_INIT, 0, 0);
1387 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0);
1389 /* disable the encoder and transmitter */
1390 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE, 0, 0);
1391 atombios_dig_encoder_setup(encoder, ATOM_DISABLE);
1393 /* setup and enable the encoder and transmitter */
1394 atombios_dig_encoder_setup(encoder, ATOM_ENABLE);
1395 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_INIT, 0, 0);
1396 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0);
1397 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0);
1400 case ENCODER_OBJECT_ID_INTERNAL_DDI:
1401 atombios_ddia_setup(encoder, ATOM_ENABLE);
1403 case ENCODER_OBJECT_ID_INTERNAL_DVO1:
1404 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
1405 atombios_external_tmds_setup(encoder, ATOM_ENABLE);
1407 case ENCODER_OBJECT_ID_INTERNAL_DAC1:
1408 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
1409 case ENCODER_OBJECT_ID_INTERNAL_DAC2:
1410 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
1411 atombios_dac_setup(encoder, ATOM_ENABLE);
1412 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT)) {
1413 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT))
1414 atombios_tv_setup(encoder, ATOM_ENABLE);
1416 atombios_tv_setup(encoder, ATOM_DISABLE);
1420 atombios_apply_encoder_quirks(encoder, adjusted_mode);
1422 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) {
1423 r600_hdmi_enable(encoder);
1424 r600_hdmi_setmode(encoder, adjusted_mode);
1429 atombios_dac_load_detect(struct drm_encoder *encoder, struct drm_connector *connector)
1431 struct drm_device *dev = encoder->dev;
1432 struct radeon_device *rdev = dev->dev_private;
1433 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1434 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1436 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT |
1437 ATOM_DEVICE_CV_SUPPORT |
1438 ATOM_DEVICE_CRT_SUPPORT)) {
1439 DAC_LOAD_DETECTION_PS_ALLOCATION args;
1440 int index = GetIndexIntoMasterTable(COMMAND, DAC_LoadDetection);
1443 memset(&args, 0, sizeof(args));
1445 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
1448 args.sDacload.ucMisc = 0;
1450 if ((radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_DAC1) ||
1451 (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1))
1452 args.sDacload.ucDacType = ATOM_DAC_A;
1454 args.sDacload.ucDacType = ATOM_DAC_B;
1456 if (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)
1457 args.sDacload.usDeviceID = cpu_to_le16(ATOM_DEVICE_CRT1_SUPPORT);
1458 else if (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)
1459 args.sDacload.usDeviceID = cpu_to_le16(ATOM_DEVICE_CRT2_SUPPORT);
1460 else if (radeon_connector->devices & ATOM_DEVICE_CV_SUPPORT) {
1461 args.sDacload.usDeviceID = cpu_to_le16(ATOM_DEVICE_CV_SUPPORT);
1463 args.sDacload.ucMisc = DAC_LOAD_MISC_YPrPb;
1464 } else if (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT) {
1465 args.sDacload.usDeviceID = cpu_to_le16(ATOM_DEVICE_TV1_SUPPORT);
1467 args.sDacload.ucMisc = DAC_LOAD_MISC_YPrPb;
1470 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1477 static enum drm_connector_status
1478 radeon_atom_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector)
1480 struct drm_device *dev = encoder->dev;
1481 struct radeon_device *rdev = dev->dev_private;
1482 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1483 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1484 uint32_t bios_0_scratch;
1486 if (!atombios_dac_load_detect(encoder, connector)) {
1487 DRM_DEBUG_KMS("detect returned false \n");
1488 return connector_status_unknown;
1491 if (rdev->family >= CHIP_R600)
1492 bios_0_scratch = RREG32(R600_BIOS_0_SCRATCH);
1494 bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH);
1496 DRM_DEBUG_KMS("Bios 0 scratch %x %08x\n", bios_0_scratch, radeon_encoder->devices);
1497 if (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT) {
1498 if (bios_0_scratch & ATOM_S0_CRT1_MASK)
1499 return connector_status_connected;
1501 if (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT) {
1502 if (bios_0_scratch & ATOM_S0_CRT2_MASK)
1503 return connector_status_connected;
1505 if (radeon_connector->devices & ATOM_DEVICE_CV_SUPPORT) {
1506 if (bios_0_scratch & (ATOM_S0_CV_MASK|ATOM_S0_CV_MASK_A))
1507 return connector_status_connected;
1509 if (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT) {
1510 if (bios_0_scratch & (ATOM_S0_TV1_COMPOSITE | ATOM_S0_TV1_COMPOSITE_A))
1511 return connector_status_connected; /* CTV */
1512 else if (bios_0_scratch & (ATOM_S0_TV1_SVIDEO | ATOM_S0_TV1_SVIDEO_A))
1513 return connector_status_connected; /* STV */
1515 return connector_status_disconnected;
1518 static void radeon_atom_encoder_prepare(struct drm_encoder *encoder)
1520 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1522 if (radeon_encoder->active_device &
1523 (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT)) {
1524 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
1526 dig->dig_encoder = radeon_atom_pick_dig_encoder(encoder);
1529 radeon_atom_output_lock(encoder, true);
1530 radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
1532 /* this is needed for the pll/ss setup to work correctly in some cases */
1533 atombios_set_encoder_crtc_source(encoder);
1536 static void radeon_atom_encoder_commit(struct drm_encoder *encoder)
1538 radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_ON);
1539 radeon_atom_output_lock(encoder, false);
1542 static void radeon_atom_encoder_disable(struct drm_encoder *encoder)
1544 struct drm_device *dev = encoder->dev;
1545 struct radeon_device *rdev = dev->dev_private;
1546 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1547 struct radeon_encoder_atom_dig *dig;
1548 radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
1550 switch (radeon_encoder->encoder_id) {
1551 case ENCODER_OBJECT_ID_INTERNAL_TMDS1:
1552 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
1553 case ENCODER_OBJECT_ID_INTERNAL_LVDS:
1554 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
1555 atombios_digital_setup(encoder, PANEL_ENCODER_ACTION_DISABLE);
1557 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
1558 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
1559 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
1560 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
1561 if (ASIC_IS_DCE4(rdev))
1562 /* disable the transmitter */
1563 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE, 0, 0);
1565 /* disable the encoder and transmitter */
1566 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE, 0, 0);
1567 atombios_dig_encoder_setup(encoder, ATOM_DISABLE);
1570 case ENCODER_OBJECT_ID_INTERNAL_DDI:
1571 atombios_ddia_setup(encoder, ATOM_DISABLE);
1573 case ENCODER_OBJECT_ID_INTERNAL_DVO1:
1574 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
1575 atombios_external_tmds_setup(encoder, ATOM_DISABLE);
1577 case ENCODER_OBJECT_ID_INTERNAL_DAC1:
1578 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
1579 case ENCODER_OBJECT_ID_INTERNAL_DAC2:
1580 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
1581 atombios_dac_setup(encoder, ATOM_DISABLE);
1582 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT))
1583 atombios_tv_setup(encoder, ATOM_DISABLE);
1587 if (radeon_encoder_is_digital(encoder)) {
1588 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI)
1589 r600_hdmi_disable(encoder);
1590 dig = radeon_encoder->enc_priv;
1591 dig->dig_encoder = -1;
1593 radeon_encoder->active_device = 0;
1596 static const struct drm_encoder_helper_funcs radeon_atom_dig_helper_funcs = {
1597 .dpms = radeon_atom_encoder_dpms,
1598 .mode_fixup = radeon_atom_mode_fixup,
1599 .prepare = radeon_atom_encoder_prepare,
1600 .mode_set = radeon_atom_encoder_mode_set,
1601 .commit = radeon_atom_encoder_commit,
1602 .disable = radeon_atom_encoder_disable,
1603 /* no detect for TMDS/LVDS yet */
1606 static const struct drm_encoder_helper_funcs radeon_atom_dac_helper_funcs = {
1607 .dpms = radeon_atom_encoder_dpms,
1608 .mode_fixup = radeon_atom_mode_fixup,
1609 .prepare = radeon_atom_encoder_prepare,
1610 .mode_set = radeon_atom_encoder_mode_set,
1611 .commit = radeon_atom_encoder_commit,
1612 .detect = radeon_atom_dac_detect,
1615 void radeon_enc_destroy(struct drm_encoder *encoder)
1617 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1618 kfree(radeon_encoder->enc_priv);
1619 drm_encoder_cleanup(encoder);
1620 kfree(radeon_encoder);
1623 static const struct drm_encoder_funcs radeon_atom_enc_funcs = {
1624 .destroy = radeon_enc_destroy,
1627 struct radeon_encoder_atom_dac *
1628 radeon_atombios_set_dac_info(struct radeon_encoder *radeon_encoder)
1630 struct drm_device *dev = radeon_encoder->base.dev;
1631 struct radeon_device *rdev = dev->dev_private;
1632 struct radeon_encoder_atom_dac *dac = kzalloc(sizeof(struct radeon_encoder_atom_dac), GFP_KERNEL);
1637 dac->tv_std = radeon_atombios_get_tv_info(rdev);
1641 struct radeon_encoder_atom_dig *
1642 radeon_atombios_set_dig_info(struct radeon_encoder *radeon_encoder)
1644 struct radeon_encoder_atom_dig *dig = kzalloc(sizeof(struct radeon_encoder_atom_dig), GFP_KERNEL);
1649 /* coherent mode by default */
1650 dig->coherent_mode = true;
1651 dig->dig_encoder = -1;
1657 radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_id, uint32_t supported_device)
1659 struct radeon_device *rdev = dev->dev_private;
1660 struct drm_encoder *encoder;
1661 struct radeon_encoder *radeon_encoder;
1663 /* see if we already added it */
1664 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
1665 radeon_encoder = to_radeon_encoder(encoder);
1666 if (radeon_encoder->encoder_id == encoder_id) {
1667 radeon_encoder->devices |= supported_device;
1674 radeon_encoder = kzalloc(sizeof(struct radeon_encoder), GFP_KERNEL);
1675 if (!radeon_encoder)
1678 encoder = &radeon_encoder->base;
1679 switch (rdev->num_crtc) {
1681 encoder->possible_crtcs = 0x1;
1685 encoder->possible_crtcs = 0x3;
1688 encoder->possible_crtcs = 0x3f;
1692 radeon_encoder->enc_priv = NULL;
1694 radeon_encoder->encoder_id = encoder_id;
1695 radeon_encoder->devices = supported_device;
1696 radeon_encoder->rmx_type = RMX_OFF;
1697 radeon_encoder->underscan_type = UNDERSCAN_OFF;
1699 switch (radeon_encoder->encoder_id) {
1700 case ENCODER_OBJECT_ID_INTERNAL_LVDS:
1701 case ENCODER_OBJECT_ID_INTERNAL_TMDS1:
1702 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
1703 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
1704 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
1705 radeon_encoder->rmx_type = RMX_FULL;
1706 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_LVDS);
1707 radeon_encoder->enc_priv = radeon_atombios_get_lvds_info(radeon_encoder);
1709 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_TMDS);
1710 radeon_encoder->enc_priv = radeon_atombios_set_dig_info(radeon_encoder);
1711 if (ASIC_IS_AVIVO(rdev))
1712 radeon_encoder->underscan_type = UNDERSCAN_AUTO;
1714 drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs);
1716 case ENCODER_OBJECT_ID_INTERNAL_DAC1:
1717 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_DAC);
1718 radeon_encoder->enc_priv = radeon_atombios_set_dac_info(radeon_encoder);
1719 drm_encoder_helper_add(encoder, &radeon_atom_dac_helper_funcs);
1721 case ENCODER_OBJECT_ID_INTERNAL_DAC2:
1722 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
1723 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
1724 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_TVDAC);
1725 radeon_encoder->enc_priv = radeon_atombios_set_dac_info(radeon_encoder);
1726 drm_encoder_helper_add(encoder, &radeon_atom_dac_helper_funcs);
1728 case ENCODER_OBJECT_ID_INTERNAL_DVO1:
1729 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
1730 case ENCODER_OBJECT_ID_INTERNAL_DDI:
1731 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
1732 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
1733 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
1734 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
1735 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
1736 radeon_encoder->rmx_type = RMX_FULL;
1737 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_LVDS);
1738 radeon_encoder->enc_priv = radeon_atombios_get_lvds_info(radeon_encoder);
1740 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_TMDS);
1741 radeon_encoder->enc_priv = radeon_atombios_set_dig_info(radeon_encoder);
1742 if (ASIC_IS_AVIVO(rdev))
1743 radeon_encoder->underscan_type = UNDERSCAN_AUTO;
1745 drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs);