Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2007-8 Advanced Micro Devices, Inc. |
| 3 | * Copyright 2008 Red Hat Inc. |
| 4 | * |
| 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: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be included in |
| 13 | * all copies or substantial portions of the Software. |
| 14 | * |
| 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. |
| 22 | * |
| 23 | * Authors: Dave Airlie |
| 24 | * Alex Deucher |
| 25 | */ |
| 26 | #include "drmP.h" |
| 27 | #include "drm_crtc_helper.h" |
| 28 | #include "radeon_drm.h" |
| 29 | #include "radeon.h" |
| 30 | #include "atom.h" |
| 31 | |
| 32 | extern int atom_debug; |
| 33 | |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 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); |
| 37 | |
Dave Airlie | 1f3b6a4 | 2009-10-13 14:10:37 +1000 | [diff] [blame] | 38 | static uint32_t radeon_encoder_clones(struct drm_encoder *encoder) |
| 39 | { |
| 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; |
| 45 | int count; |
| 46 | |
| 47 | /* DIG routing gets problematic */ |
| 48 | if (rdev->family >= CHIP_R600) |
| 49 | return index_mask; |
| 50 | /* LVDS/TV are too wacky */ |
| 51 | if (radeon_encoder->devices & ATOM_DEVICE_LCD_SUPPORT) |
| 52 | return index_mask; |
| 53 | /* DVO requires 2x ppll clocks depending on tmds chip */ |
| 54 | if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) |
| 55 | return index_mask; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 56 | |
Dave Airlie | 1f3b6a4 | 2009-10-13 14:10:37 +1000 | [diff] [blame] | 57 | count = -1; |
| 58 | list_for_each_entry(clone_encoder, &dev->mode_config.encoder_list, head) { |
| 59 | struct radeon_encoder *radeon_clone = to_radeon_encoder(clone_encoder); |
| 60 | count++; |
| 61 | |
| 62 | if (clone_encoder == encoder) |
| 63 | continue; |
| 64 | if (radeon_clone->devices & (ATOM_DEVICE_LCD_SUPPORT)) |
| 65 | continue; |
| 66 | if (radeon_clone->devices & ATOM_DEVICE_DFP2_SUPPORT) |
| 67 | continue; |
| 68 | else |
| 69 | index_mask |= (1 << count); |
| 70 | } |
| 71 | return index_mask; |
| 72 | } |
| 73 | |
| 74 | void radeon_setup_encoder_clones(struct drm_device *dev) |
| 75 | { |
| 76 | struct drm_encoder *encoder; |
| 77 | |
| 78 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 79 | encoder->possible_clones = radeon_encoder_clones(encoder); |
| 80 | } |
| 81 | } |
| 82 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 83 | uint32_t |
| 84 | radeon_get_encoder_id(struct drm_device *dev, uint32_t supported_device, uint8_t dac) |
| 85 | { |
| 86 | struct radeon_device *rdev = dev->dev_private; |
| 87 | uint32_t ret = 0; |
| 88 | |
| 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: |
| 95 | switch (dac) { |
| 96 | case 1: /* dac a */ |
| 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; |
| 103 | else |
| 104 | ret = ENCODER_OBJECT_ID_INTERNAL_DAC1; |
| 105 | break; |
| 106 | case 2: /* dac b */ |
| 107 | if (ASIC_IS_AVIVO(rdev)) |
| 108 | ret = ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2; |
| 109 | else { |
| 110 | /*if (rdev->family == CHIP_R200) |
| 111 | ret = ENCODER_OBJECT_ID_INTERNAL_DVO1; |
| 112 | else*/ |
| 113 | ret = ENCODER_OBJECT_ID_INTERNAL_DAC2; |
| 114 | } |
| 115 | break; |
| 116 | case 3: /* external dac */ |
| 117 | if (ASIC_IS_AVIVO(rdev)) |
| 118 | ret = ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1; |
| 119 | else |
| 120 | ret = ENCODER_OBJECT_ID_INTERNAL_DVO1; |
| 121 | break; |
| 122 | } |
| 123 | break; |
| 124 | case ATOM_DEVICE_LCD1_SUPPORT: |
| 125 | if (ASIC_IS_AVIVO(rdev)) |
| 126 | ret = ENCODER_OBJECT_ID_INTERNAL_LVTM1; |
| 127 | else |
| 128 | ret = ENCODER_OBJECT_ID_INTERNAL_LVDS; |
| 129 | break; |
| 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; |
| 137 | else |
| 138 | ret = ENCODER_OBJECT_ID_INTERNAL_TMDS1; |
| 139 | break; |
| 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; |
| 148 | else |
| 149 | ret = ENCODER_OBJECT_ID_INTERNAL_DVO1; |
| 150 | break; |
| 151 | case ATOM_DEVICE_DFP3_SUPPORT: |
| 152 | ret = ENCODER_OBJECT_ID_INTERNAL_LVTM1; |
| 153 | break; |
| 154 | } |
| 155 | |
| 156 | return ret; |
| 157 | } |
| 158 | |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 159 | static inline bool radeon_encoder_is_digital(struct drm_encoder *encoder) |
| 160 | { |
| 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: |
| 174 | return true; |
| 175 | default: |
| 176 | return false; |
| 177 | } |
| 178 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 179 | void |
| 180 | radeon_link_encoder_connector(struct drm_device *dev) |
| 181 | { |
| 182 | struct drm_connector *connector; |
| 183 | struct radeon_connector *radeon_connector; |
| 184 | struct drm_encoder *encoder; |
| 185 | struct radeon_encoder *radeon_encoder; |
| 186 | |
| 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); |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 198 | void radeon_encoder_set_active_device(struct drm_encoder *encoder) |
| 199 | { |
| 200 | struct drm_device *dev = encoder->dev; |
| 201 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 202 | struct drm_connector *connector; |
| 203 | |
| 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; |
Dave Airlie | f641e51 | 2009-09-08 11:17:38 +1000 | [diff] [blame] | 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); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 215 | static struct drm_connector * |
| 216 | radeon_get_connector_for_encoder(struct drm_encoder *encoder) |
| 217 | { |
| 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; |
| 222 | |
| 223 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 224 | radeon_connector = to_radeon_connector(connector); |
Dave Airlie | 43c33ed | 2010-01-29 15:55:30 +1000 | [diff] [blame] | 225 | if (radeon_encoder->active_device & radeon_connector->devices) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 226 | return connector; |
| 227 | } |
| 228 | return NULL; |
| 229 | } |
| 230 | |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 231 | static struct radeon_connector_atom_dig * |
| 232 | radeon_get_atom_connector_priv_from_encoder(struct drm_encoder *encoder) |
| 233 | { |
| 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; |
| 239 | |
| 240 | if (!rdev->is_atom_bios) |
| 241 | return NULL; |
| 242 | |
| 243 | connector = radeon_get_connector_for_encoder(encoder); |
| 244 | if (!connector) |
| 245 | return NULL; |
| 246 | |
| 247 | radeon_connector = to_radeon_connector(connector); |
| 248 | |
| 249 | if (!radeon_connector->con_priv) |
| 250 | return NULL; |
| 251 | |
| 252 | dig_connector = radeon_connector->con_priv; |
| 253 | |
| 254 | return dig_connector; |
| 255 | } |
| 256 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 257 | static bool radeon_atom_mode_fixup(struct drm_encoder *encoder, |
| 258 | struct drm_display_mode *mode, |
| 259 | struct drm_display_mode *adjusted_mode) |
| 260 | { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 261 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 262 | struct drm_device *dev = encoder->dev; |
| 263 | struct radeon_device *rdev = dev->dev_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 264 | |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 265 | /* adjust pm to upcoming mode change */ |
| 266 | radeon_pm_compute_clocks(rdev); |
| 267 | |
Alex Deucher | 8c2a6d7 | 2009-10-14 02:00:42 -0400 | [diff] [blame] | 268 | /* set the active encoder to connector routing */ |
| 269 | radeon_encoder_set_active_device(encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 270 | drm_mode_set_crtcinfo(adjusted_mode, 0); |
| 271 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 272 | /* hw bug */ |
| 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; |
| 276 | |
Alex Deucher | 80297e8 | 2009-11-12 14:55:14 -0500 | [diff] [blame] | 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; |
Alex Deucher | 310a82c | 2009-12-17 01:24:59 -0500 | [diff] [blame] | 285 | adjusted_mode->crtc_hdisplay = mode->hdisplay; |
| 286 | adjusted_mode->crtc_vdisplay = mode->vdisplay; |
Alex Deucher | 80297e8 | 2009-11-12 14:55:14 -0500 | [diff] [blame] | 287 | } |
| 288 | adjusted_mode->base.id = mode_id; |
| 289 | } |
| 290 | |
| 291 | /* get the native mode for TV */ |
Alex Deucher | ceefedd | 2009-10-13 23:57:47 -0400 | [diff] [blame] | 292 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) { |
Alex Deucher | 5a9bcac | 2009-10-08 15:09:31 -0400 | [diff] [blame] | 293 | struct radeon_encoder_atom_dac *tv_dac = radeon_encoder->enc_priv; |
| 294 | if (tv_dac) { |
| 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); |
| 299 | else |
| 300 | radeon_atom_get_tv_timings(rdev, 1, adjusted_mode); |
| 301 | } |
| 302 | } |
| 303 | |
Alex Deucher | 5801ead | 2009-11-24 13:32:59 -0500 | [diff] [blame] | 304 | if (ASIC_IS_DCE3(rdev) && |
| 305 | (radeon_encoder->active_device & (ATOM_DEVICE_DFP_SUPPORT))) { |
| 306 | struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); |
| 307 | radeon_dp_set_link_config(connector, mode); |
| 308 | } |
| 309 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 310 | return true; |
| 311 | } |
| 312 | |
| 313 | static void |
| 314 | atombios_dac_setup(struct drm_encoder *encoder, int action) |
| 315 | { |
| 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; |
| 320 | int index = 0, num = 0; |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 321 | struct radeon_encoder_atom_dac *dac_info = radeon_encoder->enc_priv; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 322 | enum radeon_tv_std tv_std = TV_STD_NTSC; |
| 323 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 324 | if (dac_info->tv_std) |
| 325 | tv_std = dac_info->tv_std; |
| 326 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 327 | memset(&args, 0, sizeof(args)); |
| 328 | |
| 329 | switch (radeon_encoder->encoder_id) { |
| 330 | case ENCODER_OBJECT_ID_INTERNAL_DAC1: |
| 331 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1: |
| 332 | index = GetIndexIntoMasterTable(COMMAND, DAC1EncoderControl); |
| 333 | num = 1; |
| 334 | break; |
| 335 | case ENCODER_OBJECT_ID_INTERNAL_DAC2: |
| 336 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2: |
| 337 | index = GetIndexIntoMasterTable(COMMAND, DAC2EncoderControl); |
| 338 | num = 2; |
| 339 | break; |
| 340 | } |
| 341 | |
| 342 | args.ucAction = action; |
| 343 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 344 | if (radeon_encoder->active_device & (ATOM_DEVICE_CRT_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 345 | args.ucDacStandard = ATOM_DAC1_PS2; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 346 | else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 347 | args.ucDacStandard = ATOM_DAC1_CV; |
| 348 | else { |
| 349 | switch (tv_std) { |
| 350 | case TV_STD_PAL: |
| 351 | case TV_STD_PAL_M: |
| 352 | case TV_STD_SCART_PAL: |
| 353 | case TV_STD_SECAM: |
| 354 | case TV_STD_PAL_CN: |
| 355 | args.ucDacStandard = ATOM_DAC1_PAL; |
| 356 | break; |
| 357 | case TV_STD_NTSC: |
| 358 | case TV_STD_NTSC_J: |
| 359 | case TV_STD_PAL_60: |
| 360 | default: |
| 361 | args.ucDacStandard = ATOM_DAC1_NTSC; |
| 362 | break; |
| 363 | } |
| 364 | } |
| 365 | args.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); |
| 366 | |
| 367 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 368 | |
| 369 | } |
| 370 | |
| 371 | static void |
| 372 | atombios_tv_setup(struct drm_encoder *encoder, int action) |
| 373 | { |
| 374 | struct drm_device *dev = encoder->dev; |
| 375 | struct radeon_device *rdev = dev->dev_private; |
| 376 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 377 | TV_ENCODER_CONTROL_PS_ALLOCATION args; |
| 378 | int index = 0; |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 379 | struct radeon_encoder_atom_dac *dac_info = radeon_encoder->enc_priv; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 380 | enum radeon_tv_std tv_std = TV_STD_NTSC; |
| 381 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 382 | if (dac_info->tv_std) |
| 383 | tv_std = dac_info->tv_std; |
| 384 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 385 | memset(&args, 0, sizeof(args)); |
| 386 | |
| 387 | index = GetIndexIntoMasterTable(COMMAND, TVEncoderControl); |
| 388 | |
| 389 | args.sTVEncoder.ucAction = action; |
| 390 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 391 | if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 392 | args.sTVEncoder.ucTvStandard = ATOM_TV_CV; |
| 393 | else { |
| 394 | switch (tv_std) { |
| 395 | case TV_STD_NTSC: |
| 396 | args.sTVEncoder.ucTvStandard = ATOM_TV_NTSC; |
| 397 | break; |
| 398 | case TV_STD_PAL: |
| 399 | args.sTVEncoder.ucTvStandard = ATOM_TV_PAL; |
| 400 | break; |
| 401 | case TV_STD_PAL_M: |
| 402 | args.sTVEncoder.ucTvStandard = ATOM_TV_PALM; |
| 403 | break; |
| 404 | case TV_STD_PAL_60: |
| 405 | args.sTVEncoder.ucTvStandard = ATOM_TV_PAL60; |
| 406 | break; |
| 407 | case TV_STD_NTSC_J: |
| 408 | args.sTVEncoder.ucTvStandard = ATOM_TV_NTSCJ; |
| 409 | break; |
| 410 | case TV_STD_SCART_PAL: |
| 411 | args.sTVEncoder.ucTvStandard = ATOM_TV_PAL; /* ??? */ |
| 412 | break; |
| 413 | case TV_STD_SECAM: |
| 414 | args.sTVEncoder.ucTvStandard = ATOM_TV_SECAM; |
| 415 | break; |
| 416 | case TV_STD_PAL_CN: |
| 417 | args.sTVEncoder.ucTvStandard = ATOM_TV_PALCN; |
| 418 | break; |
| 419 | default: |
| 420 | args.sTVEncoder.ucTvStandard = ATOM_TV_NTSC; |
| 421 | break; |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | args.sTVEncoder.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); |
| 426 | |
| 427 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 428 | |
| 429 | } |
| 430 | |
| 431 | void |
| 432 | atombios_external_tmds_setup(struct drm_encoder *encoder, int action) |
| 433 | { |
| 434 | struct drm_device *dev = encoder->dev; |
| 435 | struct radeon_device *rdev = dev->dev_private; |
| 436 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 437 | ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION args; |
| 438 | int index = 0; |
| 439 | |
| 440 | memset(&args, 0, sizeof(args)); |
| 441 | |
| 442 | index = GetIndexIntoMasterTable(COMMAND, DVOEncoderControl); |
| 443 | |
| 444 | args.sXTmdsEncoder.ucEnable = action; |
| 445 | |
| 446 | if (radeon_encoder->pixel_clock > 165000) |
| 447 | args.sXTmdsEncoder.ucMisc = PANEL_ENCODER_MISC_DUAL; |
| 448 | |
| 449 | /*if (pScrn->rgbBits == 8)*/ |
| 450 | args.sXTmdsEncoder.ucMisc |= (1 << 1); |
| 451 | |
| 452 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 453 | |
| 454 | } |
| 455 | |
| 456 | static void |
| 457 | atombios_ddia_setup(struct drm_encoder *encoder, int action) |
| 458 | { |
| 459 | struct drm_device *dev = encoder->dev; |
| 460 | struct radeon_device *rdev = dev->dev_private; |
| 461 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 462 | DVO_ENCODER_CONTROL_PS_ALLOCATION args; |
| 463 | int index = 0; |
| 464 | |
| 465 | memset(&args, 0, sizeof(args)); |
| 466 | |
| 467 | index = GetIndexIntoMasterTable(COMMAND, DVOEncoderControl); |
| 468 | |
| 469 | args.sDVOEncoder.ucAction = action; |
| 470 | args.sDVOEncoder.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); |
| 471 | |
| 472 | if (radeon_encoder->pixel_clock > 165000) |
| 473 | args.sDVOEncoder.usDevAttr.sDigAttrib.ucAttribute = PANEL_ENCODER_MISC_DUAL; |
| 474 | |
| 475 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 476 | |
| 477 | } |
| 478 | |
| 479 | union lvds_encoder_control { |
| 480 | LVDS_ENCODER_CONTROL_PS_ALLOCATION v1; |
| 481 | LVDS_ENCODER_CONTROL_PS_ALLOCATION_V2 v2; |
| 482 | }; |
| 483 | |
Alex Deucher | 32f48ff | 2009-11-30 01:54:16 -0500 | [diff] [blame] | 484 | void |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 485 | atombios_digital_setup(struct drm_encoder *encoder, int action) |
| 486 | { |
| 487 | struct drm_device *dev = encoder->dev; |
| 488 | struct radeon_device *rdev = dev->dev_private; |
| 489 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 490 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
| 491 | struct radeon_connector_atom_dig *dig_connector = |
| 492 | radeon_get_atom_connector_priv_from_encoder(encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 493 | union lvds_encoder_control args; |
| 494 | int index = 0; |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 495 | int hdmi_detected = 0; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 496 | uint8_t frev, crev; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 497 | |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 498 | if (!dig || !dig_connector) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 499 | return; |
| 500 | |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 501 | if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 502 | hdmi_detected = 1; |
| 503 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 504 | memset(&args, 0, sizeof(args)); |
| 505 | |
| 506 | switch (radeon_encoder->encoder_id) { |
| 507 | case ENCODER_OBJECT_ID_INTERNAL_LVDS: |
| 508 | index = GetIndexIntoMasterTable(COMMAND, LVDSEncoderControl); |
| 509 | break; |
| 510 | case ENCODER_OBJECT_ID_INTERNAL_TMDS1: |
| 511 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1: |
| 512 | index = GetIndexIntoMasterTable(COMMAND, TMDS1EncoderControl); |
| 513 | break; |
| 514 | case ENCODER_OBJECT_ID_INTERNAL_LVTM1: |
| 515 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) |
| 516 | index = GetIndexIntoMasterTable(COMMAND, LVDSEncoderControl); |
| 517 | else |
| 518 | index = GetIndexIntoMasterTable(COMMAND, TMDS2EncoderControl); |
| 519 | break; |
| 520 | } |
| 521 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame^] | 522 | if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev)) |
| 523 | return; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 524 | |
| 525 | switch (frev) { |
| 526 | case 1: |
| 527 | case 2: |
| 528 | switch (crev) { |
| 529 | case 1: |
| 530 | args.v1.ucMisc = 0; |
| 531 | args.v1.ucAction = action; |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 532 | if (hdmi_detected) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 533 | args.v1.ucMisc |= PANEL_ENCODER_MISC_HDMI_TYPE; |
| 534 | args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); |
| 535 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
Alex Deucher | edc664e | 2009-12-17 11:22:01 -0500 | [diff] [blame] | 536 | if (dig->lvds_misc & ATOM_PANEL_MISC_DUAL) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 537 | args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL; |
Alex Deucher | edc664e | 2009-12-17 11:22:01 -0500 | [diff] [blame] | 538 | if (dig->lvds_misc & ATOM_PANEL_MISC_888RGB) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 539 | args.v1.ucMisc |= (1 << 1); |
| 540 | } else { |
| 541 | if (dig_connector->linkb) |
| 542 | args.v1.ucMisc |= PANEL_ENCODER_MISC_TMDS_LINKB; |
| 543 | if (radeon_encoder->pixel_clock > 165000) |
| 544 | args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL; |
| 545 | /*if (pScrn->rgbBits == 8) */ |
| 546 | args.v1.ucMisc |= (1 << 1); |
| 547 | } |
| 548 | break; |
| 549 | case 2: |
| 550 | case 3: |
| 551 | args.v2.ucMisc = 0; |
| 552 | args.v2.ucAction = action; |
| 553 | if (crev == 3) { |
| 554 | if (dig->coherent_mode) |
| 555 | args.v2.ucMisc |= PANEL_ENCODER_MISC_COHERENT; |
| 556 | } |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 557 | if (hdmi_detected) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 558 | args.v2.ucMisc |= PANEL_ENCODER_MISC_HDMI_TYPE; |
| 559 | args.v2.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); |
| 560 | args.v2.ucTruncate = 0; |
| 561 | args.v2.ucSpatial = 0; |
| 562 | args.v2.ucTemporal = 0; |
| 563 | args.v2.ucFRC = 0; |
| 564 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
Alex Deucher | edc664e | 2009-12-17 11:22:01 -0500 | [diff] [blame] | 565 | if (dig->lvds_misc & ATOM_PANEL_MISC_DUAL) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 566 | args.v2.ucMisc |= PANEL_ENCODER_MISC_DUAL; |
Alex Deucher | edc664e | 2009-12-17 11:22:01 -0500 | [diff] [blame] | 567 | if (dig->lvds_misc & ATOM_PANEL_MISC_SPATIAL) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 568 | args.v2.ucSpatial = PANEL_ENCODER_SPATIAL_DITHER_EN; |
Alex Deucher | edc664e | 2009-12-17 11:22:01 -0500 | [diff] [blame] | 569 | if (dig->lvds_misc & ATOM_PANEL_MISC_888RGB) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 570 | args.v2.ucSpatial |= PANEL_ENCODER_SPATIAL_DITHER_DEPTH; |
| 571 | } |
Alex Deucher | edc664e | 2009-12-17 11:22:01 -0500 | [diff] [blame] | 572 | if (dig->lvds_misc & ATOM_PANEL_MISC_TEMPORAL) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 573 | args.v2.ucTemporal = PANEL_ENCODER_TEMPORAL_DITHER_EN; |
Alex Deucher | edc664e | 2009-12-17 11:22:01 -0500 | [diff] [blame] | 574 | if (dig->lvds_misc & ATOM_PANEL_MISC_888RGB) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 575 | args.v2.ucTemporal |= PANEL_ENCODER_TEMPORAL_DITHER_DEPTH; |
Alex Deucher | edc664e | 2009-12-17 11:22:01 -0500 | [diff] [blame] | 576 | if (((dig->lvds_misc >> ATOM_PANEL_MISC_GREY_LEVEL_SHIFT) & 0x3) == 2) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 577 | args.v2.ucTemporal |= PANEL_ENCODER_TEMPORAL_LEVEL_4; |
| 578 | } |
| 579 | } else { |
| 580 | if (dig_connector->linkb) |
| 581 | args.v2.ucMisc |= PANEL_ENCODER_MISC_TMDS_LINKB; |
| 582 | if (radeon_encoder->pixel_clock > 165000) |
| 583 | args.v2.ucMisc |= PANEL_ENCODER_MISC_DUAL; |
| 584 | } |
| 585 | break; |
| 586 | default: |
| 587 | DRM_ERROR("Unknown table version %d, %d\n", frev, crev); |
| 588 | break; |
| 589 | } |
| 590 | break; |
| 591 | default: |
| 592 | DRM_ERROR("Unknown table version %d, %d\n", frev, crev); |
| 593 | break; |
| 594 | } |
| 595 | |
| 596 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | int |
| 600 | atombios_get_encoder_mode(struct drm_encoder *encoder) |
| 601 | { |
| 602 | struct drm_connector *connector; |
| 603 | struct radeon_connector *radeon_connector; |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 604 | struct radeon_connector_atom_dig *dig_connector; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 605 | |
| 606 | connector = radeon_get_connector_for_encoder(encoder); |
| 607 | if (!connector) |
| 608 | return 0; |
| 609 | |
| 610 | radeon_connector = to_radeon_connector(connector); |
| 611 | |
| 612 | switch (connector->connector_type) { |
| 613 | case DRM_MODE_CONNECTOR_DVII: |
Alex Deucher | 705af9c | 2009-09-10 16:31:13 -0400 | [diff] [blame] | 614 | case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */ |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 615 | if (drm_detect_hdmi_monitor(radeon_connector->edid)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 616 | return ATOM_ENCODER_MODE_HDMI; |
| 617 | else if (radeon_connector->use_digital) |
| 618 | return ATOM_ENCODER_MODE_DVI; |
| 619 | else |
| 620 | return ATOM_ENCODER_MODE_CRT; |
| 621 | break; |
| 622 | case DRM_MODE_CONNECTOR_DVID: |
| 623 | case DRM_MODE_CONNECTOR_HDMIA: |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 624 | default: |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 625 | if (drm_detect_hdmi_monitor(radeon_connector->edid)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 626 | return ATOM_ENCODER_MODE_HDMI; |
| 627 | else |
| 628 | return ATOM_ENCODER_MODE_DVI; |
| 629 | break; |
| 630 | case DRM_MODE_CONNECTOR_LVDS: |
| 631 | return ATOM_ENCODER_MODE_LVDS; |
| 632 | break; |
| 633 | case DRM_MODE_CONNECTOR_DisplayPort: |
Alex Deucher | 196c58d | 2010-01-07 14:22:32 -0500 | [diff] [blame] | 634 | case DRM_MODE_CONNECTOR_eDP: |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 635 | dig_connector = radeon_connector->con_priv; |
| 636 | if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
| 637 | (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) |
Alex Deucher | f92a8b6 | 2009-11-23 18:40:40 -0500 | [diff] [blame] | 638 | return ATOM_ENCODER_MODE_DP; |
| 639 | else if (drm_detect_hdmi_monitor(radeon_connector->edid)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 640 | return ATOM_ENCODER_MODE_HDMI; |
| 641 | else |
| 642 | return ATOM_ENCODER_MODE_DVI; |
| 643 | break; |
Alex Deucher | a5899fc | 2010-01-07 14:19:47 -0500 | [diff] [blame] | 644 | case DRM_MODE_CONNECTOR_DVIA: |
| 645 | case DRM_MODE_CONNECTOR_VGA: |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 646 | return ATOM_ENCODER_MODE_CRT; |
| 647 | break; |
Alex Deucher | a5899fc | 2010-01-07 14:19:47 -0500 | [diff] [blame] | 648 | case DRM_MODE_CONNECTOR_Composite: |
| 649 | case DRM_MODE_CONNECTOR_SVIDEO: |
| 650 | case DRM_MODE_CONNECTOR_9PinDIN: |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 651 | /* fix me */ |
| 652 | return ATOM_ENCODER_MODE_TV; |
| 653 | /*return ATOM_ENCODER_MODE_CV;*/ |
| 654 | break; |
| 655 | } |
| 656 | } |
| 657 | |
Alex Deucher | 1a66c95 | 2009-11-20 19:40:13 -0500 | [diff] [blame] | 658 | /* |
| 659 | * DIG Encoder/Transmitter Setup |
| 660 | * |
| 661 | * DCE 3.0/3.1 |
| 662 | * - 2 DIG transmitter blocks. UNIPHY (links A and B) and LVTMA. |
| 663 | * Supports up to 3 digital outputs |
| 664 | * - 2 DIG encoder blocks. |
| 665 | * DIG1 can drive UNIPHY link A or link B |
| 666 | * DIG2 can drive UNIPHY link B or LVTMA |
| 667 | * |
| 668 | * DCE 3.2 |
| 669 | * - 3 DIG transmitter blocks. UNIPHY0/1/2 (links A and B). |
| 670 | * Supports up to 5 digital outputs |
| 671 | * - 2 DIG encoder blocks. |
| 672 | * DIG1/2 can drive UNIPHY0/1/2 link A or link B |
| 673 | * |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 674 | * DCE 4.0 |
| 675 | * - 3 DIG transmitter blocks UNPHY0/1/2 (links A and B). |
| 676 | * Supports up to 6 digital outputs |
| 677 | * - 6 DIG encoder blocks. |
| 678 | * - DIG to PHY mapping is hardcoded |
| 679 | * DIG1 drives UNIPHY0 link A, A+B |
| 680 | * DIG2 drives UNIPHY0 link B |
| 681 | * DIG3 drives UNIPHY1 link A, A+B |
| 682 | * DIG4 drives UNIPHY1 link B |
| 683 | * DIG5 drives UNIPHY2 link A, A+B |
| 684 | * DIG6 drives UNIPHY2 link B |
| 685 | * |
Alex Deucher | 1a66c95 | 2009-11-20 19:40:13 -0500 | [diff] [blame] | 686 | * Routing |
| 687 | * crtc -> dig encoder -> UNIPHY/LVTMA (1 or 2 links) |
| 688 | * Examples: |
| 689 | * crtc0 -> dig2 -> LVTMA links A+B -> TMDS/HDMI |
| 690 | * crtc1 -> dig1 -> UNIPHY0 link B -> DP |
| 691 | * crtc0 -> dig1 -> UNIPHY2 link A -> LVDS |
| 692 | * crtc1 -> dig2 -> UNIPHY1 link B+A -> TMDS/HDMI |
| 693 | */ |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 694 | |
| 695 | union dig_encoder_control { |
| 696 | DIG_ENCODER_CONTROL_PS_ALLOCATION v1; |
| 697 | DIG_ENCODER_CONTROL_PARAMETERS_V2 v2; |
| 698 | DIG_ENCODER_CONTROL_PARAMETERS_V3 v3; |
| 699 | }; |
| 700 | |
| 701 | void |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 702 | atombios_dig_encoder_setup(struct drm_encoder *encoder, int action) |
| 703 | { |
| 704 | struct drm_device *dev = encoder->dev; |
| 705 | struct radeon_device *rdev = dev->dev_private; |
| 706 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 707 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
| 708 | struct radeon_connector_atom_dig *dig_connector = |
| 709 | radeon_get_atom_connector_priv_from_encoder(encoder); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 710 | union dig_encoder_control args; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 711 | int index = 0, num = 0; |
| 712 | uint8_t frev, crev; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 713 | |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 714 | if (!dig || !dig_connector) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 715 | return; |
| 716 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 717 | memset(&args, 0, sizeof(args)); |
| 718 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 719 | if (ASIC_IS_DCE4(rdev)) |
| 720 | index = GetIndexIntoMasterTable(COMMAND, DIGxEncoderControl); |
| 721 | else { |
| 722 | if (dig->dig_encoder) |
| 723 | index = GetIndexIntoMasterTable(COMMAND, DIG2EncoderControl); |
| 724 | else |
| 725 | index = GetIndexIntoMasterTable(COMMAND, DIG1EncoderControl); |
| 726 | } |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 727 | num = dig->dig_encoder + 1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 728 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame^] | 729 | if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev)) |
| 730 | return; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 731 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 732 | args.v1.ucAction = action; |
| 733 | args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); |
| 734 | args.v1.ucEncoderMode = atombios_get_encoder_mode(encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 735 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 736 | if (args.v1.ucEncoderMode == ATOM_ENCODER_MODE_DP) { |
| 737 | if (dig_connector->dp_clock == 270000) |
| 738 | args.v1.ucConfig |= ATOM_ENCODER_CONFIG_DPLINKRATE_2_70GHZ; |
| 739 | args.v1.ucLaneNum = dig_connector->dp_lane_count; |
| 740 | } else if (radeon_encoder->pixel_clock > 165000) |
| 741 | args.v1.ucLaneNum = 8; |
| 742 | else |
| 743 | args.v1.ucLaneNum = 4; |
| 744 | |
| 745 | if (ASIC_IS_DCE4(rdev)) { |
| 746 | args.v3.acConfig.ucDigSel = dig->dig_encoder; |
| 747 | args.v3.ucBitPerColor = PANEL_8BIT_PER_COLOR; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 748 | } else { |
| 749 | switch (radeon_encoder->encoder_id) { |
| 750 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 751 | args.v1.ucConfig = ATOM_ENCODER_CONFIG_V2_TRANSMITTER1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 752 | break; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 753 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 754 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 755 | args.v1.ucConfig = ATOM_ENCODER_CONFIG_V2_TRANSMITTER2; |
| 756 | break; |
| 757 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: |
| 758 | args.v1.ucConfig = ATOM_ENCODER_CONFIG_V2_TRANSMITTER3; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 759 | break; |
| 760 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 761 | if (dig_connector->linkb) |
| 762 | args.v1.ucConfig |= ATOM_ENCODER_CONFIG_LINKB; |
| 763 | else |
| 764 | args.v1.ucConfig |= ATOM_ENCODER_CONFIG_LINKA; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 765 | } |
| 766 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 767 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 768 | |
| 769 | } |
| 770 | |
| 771 | union dig_transmitter_control { |
| 772 | DIG_TRANSMITTER_CONTROL_PS_ALLOCATION v1; |
| 773 | DIG_TRANSMITTER_CONTROL_PARAMETERS_V2 v2; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 774 | DIG_TRANSMITTER_CONTROL_PARAMETERS_V3 v3; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 775 | }; |
| 776 | |
Alex Deucher | 5801ead | 2009-11-24 13:32:59 -0500 | [diff] [blame] | 777 | void |
Alex Deucher | 1a66c95 | 2009-11-20 19:40:13 -0500 | [diff] [blame] | 778 | atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t lane_num, uint8_t lane_set) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 779 | { |
| 780 | struct drm_device *dev = encoder->dev; |
| 781 | struct radeon_device *rdev = dev->dev_private; |
| 782 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 783 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
| 784 | struct radeon_connector_atom_dig *dig_connector = |
| 785 | radeon_get_atom_connector_priv_from_encoder(encoder); |
| 786 | struct drm_connector *connector; |
| 787 | struct radeon_connector *radeon_connector; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 788 | union dig_transmitter_control args; |
| 789 | int index = 0, num = 0; |
| 790 | uint8_t frev, crev; |
Alex Deucher | f92a8b6 | 2009-11-23 18:40:40 -0500 | [diff] [blame] | 791 | bool is_dp = false; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 792 | int pll_id = 0; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 793 | |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 794 | if (!dig || !dig_connector) |
| 795 | return; |
| 796 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 797 | connector = radeon_get_connector_for_encoder(encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 798 | radeon_connector = to_radeon_connector(connector); |
| 799 | |
Alex Deucher | f92a8b6 | 2009-11-23 18:40:40 -0500 | [diff] [blame] | 800 | if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) |
| 801 | is_dp = true; |
| 802 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 803 | memset(&args, 0, sizeof(args)); |
| 804 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 805 | if (ASIC_IS_DCE32(rdev) || ASIC_IS_DCE4(rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 806 | index = GetIndexIntoMasterTable(COMMAND, UNIPHYTransmitterControl); |
| 807 | else { |
| 808 | switch (radeon_encoder->encoder_id) { |
| 809 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: |
| 810 | index = GetIndexIntoMasterTable(COMMAND, DIG1TransmitterControl); |
| 811 | break; |
| 812 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: |
| 813 | index = GetIndexIntoMasterTable(COMMAND, DIG2TransmitterControl); |
| 814 | break; |
| 815 | } |
| 816 | } |
| 817 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame^] | 818 | if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev)) |
| 819 | return; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 820 | |
| 821 | args.v1.ucAction = action; |
Alex Deucher | f95a9f0 | 2009-11-05 02:21:06 -0500 | [diff] [blame] | 822 | if (action == ATOM_TRANSMITTER_ACTION_INIT) { |
| 823 | args.v1.usInitInfo = radeon_connector->connector_object_id; |
Alex Deucher | 1a66c95 | 2009-11-20 19:40:13 -0500 | [diff] [blame] | 824 | } else if (action == ATOM_TRANSMITTER_ACTION_SETUP_VSEMPH) { |
| 825 | args.v1.asMode.ucLaneSel = lane_num; |
| 826 | args.v1.asMode.ucLaneSet = lane_set; |
Alex Deucher | f95a9f0 | 2009-11-05 02:21:06 -0500 | [diff] [blame] | 827 | } else { |
Alex Deucher | f92a8b6 | 2009-11-23 18:40:40 -0500 | [diff] [blame] | 828 | if (is_dp) |
| 829 | args.v1.usPixelClock = |
Alex Deucher | 5801ead | 2009-11-24 13:32:59 -0500 | [diff] [blame] | 830 | cpu_to_le16(dig_connector->dp_clock / 10); |
Alex Deucher | f92a8b6 | 2009-11-23 18:40:40 -0500 | [diff] [blame] | 831 | else if (radeon_encoder->pixel_clock > 165000) |
Alex Deucher | f95a9f0 | 2009-11-05 02:21:06 -0500 | [diff] [blame] | 832 | args.v1.usPixelClock = cpu_to_le16((radeon_encoder->pixel_clock / 2) / 10); |
| 833 | else |
| 834 | args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); |
| 835 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 836 | if (ASIC_IS_DCE4(rdev)) { |
| 837 | if (is_dp) |
| 838 | args.v3.ucLaneNum = dig_connector->dp_lane_count; |
| 839 | else if (radeon_encoder->pixel_clock > 165000) |
| 840 | args.v3.ucLaneNum = 8; |
| 841 | else |
| 842 | args.v3.ucLaneNum = 4; |
| 843 | |
| 844 | if (dig_connector->linkb) { |
| 845 | args.v3.acConfig.ucLinkSel = 1; |
| 846 | args.v3.acConfig.ucEncoderSel = 1; |
| 847 | } |
| 848 | |
| 849 | /* Select the PLL for the PHY |
| 850 | * DP PHY should be clocked from external src if there is |
| 851 | * one. |
| 852 | */ |
| 853 | if (encoder->crtc) { |
| 854 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); |
| 855 | pll_id = radeon_crtc->pll_id; |
| 856 | } |
| 857 | if (is_dp && rdev->clock.dp_extclk) |
| 858 | args.v3.acConfig.ucRefClkSource = 2; /* external src */ |
| 859 | else |
| 860 | args.v3.acConfig.ucRefClkSource = pll_id; |
| 861 | |
| 862 | switch (radeon_encoder->encoder_id) { |
| 863 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: |
| 864 | args.v3.acConfig.ucTransmitterSel = 0; |
| 865 | num = 0; |
| 866 | break; |
| 867 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: |
| 868 | args.v3.acConfig.ucTransmitterSel = 1; |
| 869 | num = 1; |
| 870 | break; |
| 871 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: |
| 872 | args.v3.acConfig.ucTransmitterSel = 2; |
| 873 | num = 2; |
| 874 | break; |
| 875 | } |
| 876 | |
| 877 | if (is_dp) |
| 878 | args.v3.acConfig.fCoherentMode = 1; /* DP requires coherent */ |
| 879 | else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { |
| 880 | if (dig->coherent_mode) |
| 881 | args.v3.acConfig.fCoherentMode = 1; |
| 882 | } |
| 883 | } else if (ASIC_IS_DCE32(rdev)) { |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 884 | if (dig->dig_encoder == 1) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 885 | args.v2.acConfig.ucEncoderSel = 1; |
Alex Deucher | 1a66c95 | 2009-11-20 19:40:13 -0500 | [diff] [blame] | 886 | if (dig_connector->linkb) |
| 887 | args.v2.acConfig.ucLinkSel = 1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 888 | |
| 889 | switch (radeon_encoder->encoder_id) { |
| 890 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: |
| 891 | args.v2.acConfig.ucTransmitterSel = 0; |
| 892 | num = 0; |
| 893 | break; |
| 894 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: |
| 895 | args.v2.acConfig.ucTransmitterSel = 1; |
| 896 | num = 1; |
| 897 | break; |
| 898 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: |
| 899 | args.v2.acConfig.ucTransmitterSel = 2; |
| 900 | num = 2; |
| 901 | break; |
| 902 | } |
| 903 | |
Alex Deucher | f92a8b6 | 2009-11-23 18:40:40 -0500 | [diff] [blame] | 904 | if (is_dp) |
| 905 | args.v2.acConfig.fCoherentMode = 1; |
| 906 | else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 907 | if (dig->coherent_mode) |
| 908 | args.v2.acConfig.fCoherentMode = 1; |
| 909 | } |
| 910 | } else { |
| 911 | args.v1.ucConfig = ATOM_TRANSMITTER_CONFIG_CLKSRC_PPLL; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 912 | |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 913 | if (dig->dig_encoder) |
| 914 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_DIG2_ENCODER; |
| 915 | else |
| 916 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_DIG1_ENCODER; |
| 917 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 918 | switch (radeon_encoder->encoder_id) { |
| 919 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 920 | if (rdev->flags & RADEON_IS_IGP) { |
| 921 | if (radeon_encoder->pixel_clock > 165000) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 922 | if (dig_connector->igp_lane_info & 0x3) |
| 923 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_7; |
| 924 | else if (dig_connector->igp_lane_info & 0xc) |
| 925 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_15; |
| 926 | } else { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 927 | if (dig_connector->igp_lane_info & 0x1) |
| 928 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_3; |
| 929 | else if (dig_connector->igp_lane_info & 0x2) |
| 930 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_4_7; |
| 931 | else if (dig_connector->igp_lane_info & 0x4) |
| 932 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_11; |
| 933 | else if (dig_connector->igp_lane_info & 0x8) |
| 934 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_12_15; |
| 935 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 936 | } |
| 937 | break; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 938 | } |
| 939 | |
Alex Deucher | 1a66c95 | 2009-11-20 19:40:13 -0500 | [diff] [blame] | 940 | if (radeon_encoder->pixel_clock > 165000) |
| 941 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_8LANE_LINK; |
| 942 | |
| 943 | if (dig_connector->linkb) |
| 944 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LINKB; |
| 945 | else |
| 946 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LINKA; |
| 947 | |
Alex Deucher | f92a8b6 | 2009-11-23 18:40:40 -0500 | [diff] [blame] | 948 | if (is_dp) |
| 949 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_COHERENT; |
| 950 | else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 951 | if (dig->coherent_mode) |
| 952 | args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_COHERENT; |
| 953 | } |
| 954 | } |
| 955 | |
| 956 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 957 | } |
| 958 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 959 | static void |
| 960 | atombios_yuv_setup(struct drm_encoder *encoder, bool enable) |
| 961 | { |
| 962 | struct drm_device *dev = encoder->dev; |
| 963 | struct radeon_device *rdev = dev->dev_private; |
| 964 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 965 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); |
| 966 | ENABLE_YUV_PS_ALLOCATION args; |
| 967 | int index = GetIndexIntoMasterTable(COMMAND, EnableYUV); |
| 968 | uint32_t temp, reg; |
| 969 | |
| 970 | memset(&args, 0, sizeof(args)); |
| 971 | |
| 972 | if (rdev->family >= CHIP_R600) |
| 973 | reg = R600_BIOS_3_SCRATCH; |
| 974 | else |
| 975 | reg = RADEON_BIOS_3_SCRATCH; |
| 976 | |
| 977 | /* XXX: fix up scratch reg handling */ |
| 978 | temp = RREG32(reg); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 979 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 980 | WREG32(reg, (ATOM_S3_TV1_ACTIVE | |
| 981 | (radeon_crtc->crtc_id << 18))); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 982 | else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 983 | WREG32(reg, (ATOM_S3_CV_ACTIVE | (radeon_crtc->crtc_id << 24))); |
| 984 | else |
| 985 | WREG32(reg, 0); |
| 986 | |
| 987 | if (enable) |
| 988 | args.ucEnable = ATOM_ENABLE; |
| 989 | args.ucCRTC = radeon_crtc->crtc_id; |
| 990 | |
| 991 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 992 | |
| 993 | WREG32(reg, temp); |
| 994 | } |
| 995 | |
| 996 | static void |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 997 | radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode) |
| 998 | { |
| 999 | struct drm_device *dev = encoder->dev; |
| 1000 | struct radeon_device *rdev = dev->dev_private; |
| 1001 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 1002 | DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION args; |
| 1003 | int index = 0; |
| 1004 | bool is_dig = false; |
| 1005 | |
| 1006 | memset(&args, 0, sizeof(args)); |
| 1007 | |
Dave Airlie | f641e51 | 2009-09-08 11:17:38 +1000 | [diff] [blame] | 1008 | DRM_DEBUG("encoder dpms %d to mode %d, devices %08x, active_devices %08x\n", |
| 1009 | radeon_encoder->encoder_id, mode, radeon_encoder->devices, |
| 1010 | radeon_encoder->active_device); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1011 | switch (radeon_encoder->encoder_id) { |
| 1012 | case ENCODER_OBJECT_ID_INTERNAL_TMDS1: |
| 1013 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1: |
| 1014 | index = GetIndexIntoMasterTable(COMMAND, TMDSAOutputControl); |
| 1015 | break; |
| 1016 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: |
| 1017 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: |
| 1018 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: |
| 1019 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: |
| 1020 | is_dig = true; |
| 1021 | break; |
| 1022 | case ENCODER_OBJECT_ID_INTERNAL_DVO1: |
| 1023 | case ENCODER_OBJECT_ID_INTERNAL_DDI: |
| 1024 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1: |
| 1025 | index = GetIndexIntoMasterTable(COMMAND, DVOOutputControl); |
| 1026 | break; |
| 1027 | case ENCODER_OBJECT_ID_INTERNAL_LVDS: |
| 1028 | index = GetIndexIntoMasterTable(COMMAND, LCD1OutputControl); |
| 1029 | break; |
| 1030 | case ENCODER_OBJECT_ID_INTERNAL_LVTM1: |
| 1031 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) |
| 1032 | index = GetIndexIntoMasterTable(COMMAND, LCD1OutputControl); |
| 1033 | else |
| 1034 | index = GetIndexIntoMasterTable(COMMAND, LVTMAOutputControl); |
| 1035 | break; |
| 1036 | case ENCODER_OBJECT_ID_INTERNAL_DAC1: |
| 1037 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1: |
Alex Deucher | 8c2a6d7 | 2009-10-14 02:00:42 -0400 | [diff] [blame] | 1038 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1039 | index = GetIndexIntoMasterTable(COMMAND, TV1OutputControl); |
Alex Deucher | 8c2a6d7 | 2009-10-14 02:00:42 -0400 | [diff] [blame] | 1040 | else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1041 | index = GetIndexIntoMasterTable(COMMAND, CV1OutputControl); |
| 1042 | else |
| 1043 | index = GetIndexIntoMasterTable(COMMAND, DAC1OutputControl); |
| 1044 | break; |
| 1045 | case ENCODER_OBJECT_ID_INTERNAL_DAC2: |
| 1046 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2: |
Alex Deucher | 8c2a6d7 | 2009-10-14 02:00:42 -0400 | [diff] [blame] | 1047 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1048 | index = GetIndexIntoMasterTable(COMMAND, TV1OutputControl); |
Alex Deucher | 8c2a6d7 | 2009-10-14 02:00:42 -0400 | [diff] [blame] | 1049 | else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1050 | index = GetIndexIntoMasterTable(COMMAND, CV1OutputControl); |
| 1051 | else |
| 1052 | index = GetIndexIntoMasterTable(COMMAND, DAC2OutputControl); |
| 1053 | break; |
| 1054 | } |
| 1055 | |
| 1056 | if (is_dig) { |
| 1057 | switch (mode) { |
| 1058 | case DRM_MODE_DPMS_ON: |
Dave Airlie | 58682f1 | 2009-11-26 08:56:35 +1000 | [diff] [blame] | 1059 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); |
| 1060 | { |
| 1061 | struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); |
| 1062 | dp_link_train(encoder, connector); |
| 1063 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1064 | break; |
| 1065 | case DRM_MODE_DPMS_STANDBY: |
| 1066 | case DRM_MODE_DPMS_SUSPEND: |
| 1067 | case DRM_MODE_DPMS_OFF: |
Dave Airlie | 58682f1 | 2009-11-26 08:56:35 +1000 | [diff] [blame] | 1068 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT, 0, 0); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1069 | break; |
| 1070 | } |
| 1071 | } else { |
| 1072 | switch (mode) { |
| 1073 | case DRM_MODE_DPMS_ON: |
| 1074 | args.ucAction = ATOM_ENABLE; |
| 1075 | break; |
| 1076 | case DRM_MODE_DPMS_STANDBY: |
| 1077 | case DRM_MODE_DPMS_SUSPEND: |
| 1078 | case DRM_MODE_DPMS_OFF: |
| 1079 | args.ucAction = ATOM_DISABLE; |
| 1080 | break; |
| 1081 | } |
| 1082 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 1083 | } |
| 1084 | radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false); |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 1085 | |
| 1086 | /* adjust pm to dpms change */ |
| 1087 | radeon_pm_compute_clocks(rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1088 | } |
| 1089 | |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 1090 | union crtc_source_param { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1091 | SELECT_CRTC_SOURCE_PS_ALLOCATION v1; |
| 1092 | SELECT_CRTC_SOURCE_PARAMETERS_V2 v2; |
| 1093 | }; |
| 1094 | |
| 1095 | static void |
| 1096 | atombios_set_encoder_crtc_source(struct drm_encoder *encoder) |
| 1097 | { |
| 1098 | struct drm_device *dev = encoder->dev; |
| 1099 | struct radeon_device *rdev = dev->dev_private; |
| 1100 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 1101 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); |
Alex Deucher | 9ae4786 | 2010-02-01 19:06:06 -0500 | [diff] [blame] | 1102 | union crtc_source_param args; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1103 | int index = GetIndexIntoMasterTable(COMMAND, SelectCRTC_Source); |
| 1104 | uint8_t frev, crev; |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 1105 | struct radeon_encoder_atom_dig *dig; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1106 | |
| 1107 | memset(&args, 0, sizeof(args)); |
| 1108 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame^] | 1109 | if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev)) |
| 1110 | return; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1111 | |
| 1112 | switch (frev) { |
| 1113 | case 1: |
| 1114 | switch (crev) { |
| 1115 | case 1: |
| 1116 | default: |
| 1117 | if (ASIC_IS_AVIVO(rdev)) |
| 1118 | args.v1.ucCRTC = radeon_crtc->crtc_id; |
| 1119 | else { |
| 1120 | if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_DAC1) { |
| 1121 | args.v1.ucCRTC = radeon_crtc->crtc_id; |
| 1122 | } else { |
| 1123 | args.v1.ucCRTC = radeon_crtc->crtc_id << 2; |
| 1124 | } |
| 1125 | } |
| 1126 | switch (radeon_encoder->encoder_id) { |
| 1127 | case ENCODER_OBJECT_ID_INTERNAL_TMDS1: |
| 1128 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1: |
| 1129 | args.v1.ucDevice = ATOM_DEVICE_DFP1_INDEX; |
| 1130 | break; |
| 1131 | case ENCODER_OBJECT_ID_INTERNAL_LVDS: |
| 1132 | case ENCODER_OBJECT_ID_INTERNAL_LVTM1: |
| 1133 | if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) |
| 1134 | args.v1.ucDevice = ATOM_DEVICE_LCD1_INDEX; |
| 1135 | else |
| 1136 | args.v1.ucDevice = ATOM_DEVICE_DFP3_INDEX; |
| 1137 | break; |
| 1138 | case ENCODER_OBJECT_ID_INTERNAL_DVO1: |
| 1139 | case ENCODER_OBJECT_ID_INTERNAL_DDI: |
| 1140 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1: |
| 1141 | args.v1.ucDevice = ATOM_DEVICE_DFP2_INDEX; |
| 1142 | break; |
| 1143 | case ENCODER_OBJECT_ID_INTERNAL_DAC1: |
| 1144 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1: |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1145 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1146 | args.v1.ucDevice = ATOM_DEVICE_TV1_INDEX; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1147 | else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1148 | args.v1.ucDevice = ATOM_DEVICE_CV_INDEX; |
| 1149 | else |
| 1150 | args.v1.ucDevice = ATOM_DEVICE_CRT1_INDEX; |
| 1151 | break; |
| 1152 | case ENCODER_OBJECT_ID_INTERNAL_DAC2: |
| 1153 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2: |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1154 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1155 | args.v1.ucDevice = ATOM_DEVICE_TV1_INDEX; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1156 | else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1157 | args.v1.ucDevice = ATOM_DEVICE_CV_INDEX; |
| 1158 | else |
| 1159 | args.v1.ucDevice = ATOM_DEVICE_CRT2_INDEX; |
| 1160 | break; |
| 1161 | } |
| 1162 | break; |
| 1163 | case 2: |
| 1164 | args.v2.ucCRTC = radeon_crtc->crtc_id; |
| 1165 | args.v2.ucEncodeMode = atombios_get_encoder_mode(encoder); |
| 1166 | switch (radeon_encoder->encoder_id) { |
| 1167 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: |
| 1168 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: |
| 1169 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 1170 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: |
| 1171 | dig = radeon_encoder->enc_priv; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1172 | switch (dig->dig_encoder) { |
| 1173 | case 0: |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 1174 | args.v2.ucEncoderID = ASIC_INT_DIG1_ENCODER_ID; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1175 | break; |
| 1176 | case 1: |
| 1177 | args.v2.ucEncoderID = ASIC_INT_DIG2_ENCODER_ID; |
| 1178 | break; |
| 1179 | case 2: |
| 1180 | args.v2.ucEncoderID = ASIC_INT_DIG3_ENCODER_ID; |
| 1181 | break; |
| 1182 | case 3: |
| 1183 | args.v2.ucEncoderID = ASIC_INT_DIG4_ENCODER_ID; |
| 1184 | break; |
| 1185 | case 4: |
| 1186 | args.v2.ucEncoderID = ASIC_INT_DIG5_ENCODER_ID; |
| 1187 | break; |
| 1188 | case 5: |
| 1189 | args.v2.ucEncoderID = ASIC_INT_DIG6_ENCODER_ID; |
| 1190 | break; |
| 1191 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1192 | break; |
| 1193 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1: |
| 1194 | args.v2.ucEncoderID = ASIC_INT_DVO_ENCODER_ID; |
| 1195 | break; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1196 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1: |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1197 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1198 | args.v2.ucEncoderID = ASIC_INT_TV_ENCODER_ID; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1199 | else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1200 | args.v2.ucEncoderID = ASIC_INT_TV_ENCODER_ID; |
| 1201 | else |
| 1202 | args.v2.ucEncoderID = ASIC_INT_DAC1_ENCODER_ID; |
| 1203 | break; |
| 1204 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2: |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1205 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1206 | args.v2.ucEncoderID = ASIC_INT_TV_ENCODER_ID; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1207 | else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1208 | args.v2.ucEncoderID = ASIC_INT_TV_ENCODER_ID; |
| 1209 | else |
| 1210 | args.v2.ucEncoderID = ASIC_INT_DAC2_ENCODER_ID; |
| 1211 | break; |
| 1212 | } |
| 1213 | break; |
| 1214 | } |
| 1215 | break; |
| 1216 | default: |
| 1217 | DRM_ERROR("Unknown table version: %d, %d\n", frev, crev); |
| 1218 | break; |
| 1219 | } |
| 1220 | |
| 1221 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
Alex Deucher | 267364a | 2010-03-08 17:10:41 -0500 | [diff] [blame] | 1222 | |
| 1223 | /* update scratch regs with new routing */ |
| 1224 | radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | static void |
| 1228 | atombios_apply_encoder_quirks(struct drm_encoder *encoder, |
| 1229 | struct drm_display_mode *mode) |
| 1230 | { |
| 1231 | struct drm_device *dev = encoder->dev; |
| 1232 | struct radeon_device *rdev = dev->dev_private; |
| 1233 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 1234 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); |
| 1235 | |
| 1236 | /* Funky macbooks */ |
| 1237 | if ((dev->pdev->device == 0x71C5) && |
| 1238 | (dev->pdev->subsystem_vendor == 0x106b) && |
| 1239 | (dev->pdev->subsystem_device == 0x0080)) { |
| 1240 | if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { |
| 1241 | uint32_t lvtma_bit_depth_control = RREG32(AVIVO_LVTMA_BIT_DEPTH_CONTROL); |
| 1242 | |
| 1243 | lvtma_bit_depth_control &= ~AVIVO_LVTMA_BIT_DEPTH_CONTROL_TRUNCATE_EN; |
| 1244 | lvtma_bit_depth_control &= ~AVIVO_LVTMA_BIT_DEPTH_CONTROL_SPATIAL_DITHER_EN; |
| 1245 | |
| 1246 | WREG32(AVIVO_LVTMA_BIT_DEPTH_CONTROL, lvtma_bit_depth_control); |
| 1247 | } |
| 1248 | } |
| 1249 | |
| 1250 | /* set scaler clears this on some chips */ |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1251 | /* XXX check DCE4 */ |
Alex Deucher | ceefedd | 2009-10-13 23:57:47 -0400 | [diff] [blame] | 1252 | if (!(radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))) { |
| 1253 | if (ASIC_IS_AVIVO(rdev) && (mode->flags & DRM_MODE_FLAG_INTERLACE)) |
| 1254 | WREG32(AVIVO_D1MODE_DATA_FORMAT + radeon_crtc->crtc_offset, |
| 1255 | AVIVO_D1MODE_INTERLEAVE_EN); |
| 1256 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1257 | } |
| 1258 | |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 1259 | static int radeon_atom_pick_dig_encoder(struct drm_encoder *encoder) |
| 1260 | { |
| 1261 | struct drm_device *dev = encoder->dev; |
| 1262 | struct radeon_device *rdev = dev->dev_private; |
| 1263 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); |
| 1264 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 1265 | struct drm_encoder *test_encoder; |
| 1266 | struct radeon_encoder_atom_dig *dig; |
| 1267 | uint32_t dig_enc_in_use = 0; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1268 | |
| 1269 | if (ASIC_IS_DCE4(rdev)) { |
| 1270 | struct radeon_connector_atom_dig *dig_connector = |
| 1271 | radeon_get_atom_connector_priv_from_encoder(encoder); |
| 1272 | |
| 1273 | switch (radeon_encoder->encoder_id) { |
| 1274 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: |
| 1275 | if (dig_connector->linkb) |
| 1276 | return 1; |
| 1277 | else |
| 1278 | return 0; |
| 1279 | break; |
| 1280 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: |
| 1281 | if (dig_connector->linkb) |
| 1282 | return 3; |
| 1283 | else |
| 1284 | return 2; |
| 1285 | break; |
| 1286 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: |
| 1287 | if (dig_connector->linkb) |
| 1288 | return 5; |
| 1289 | else |
| 1290 | return 4; |
| 1291 | break; |
| 1292 | } |
| 1293 | } |
| 1294 | |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 1295 | /* on DCE32 and encoder can driver any block so just crtc id */ |
| 1296 | if (ASIC_IS_DCE32(rdev)) { |
| 1297 | return radeon_crtc->crtc_id; |
| 1298 | } |
| 1299 | |
| 1300 | /* on DCE3 - LVTMA can only be driven by DIGB */ |
| 1301 | list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) { |
| 1302 | struct radeon_encoder *radeon_test_encoder; |
| 1303 | |
| 1304 | if (encoder == test_encoder) |
| 1305 | continue; |
| 1306 | |
| 1307 | if (!radeon_encoder_is_digital(test_encoder)) |
| 1308 | continue; |
| 1309 | |
| 1310 | radeon_test_encoder = to_radeon_encoder(test_encoder); |
| 1311 | dig = radeon_test_encoder->enc_priv; |
| 1312 | |
| 1313 | if (dig->dig_encoder >= 0) |
| 1314 | dig_enc_in_use |= (1 << dig->dig_encoder); |
| 1315 | } |
| 1316 | |
| 1317 | if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA) { |
| 1318 | if (dig_enc_in_use & 0x2) |
| 1319 | DRM_ERROR("LVDS required digital encoder 2 but it was in use - stealing\n"); |
| 1320 | return 1; |
| 1321 | } |
| 1322 | if (!(dig_enc_in_use & 1)) |
| 1323 | return 0; |
| 1324 | return 1; |
| 1325 | } |
| 1326 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1327 | static void |
| 1328 | radeon_atom_encoder_mode_set(struct drm_encoder *encoder, |
| 1329 | struct drm_display_mode *mode, |
| 1330 | struct drm_display_mode *adjusted_mode) |
| 1331 | { |
| 1332 | struct drm_device *dev = encoder->dev; |
| 1333 | struct radeon_device *rdev = dev->dev_private; |
| 1334 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1335 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1336 | radeon_encoder->pixel_clock = adjusted_mode->clock; |
| 1337 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1338 | if (ASIC_IS_AVIVO(rdev)) { |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1339 | if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT | ATOM_DEVICE_TV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1340 | atombios_yuv_setup(encoder, true); |
| 1341 | else |
| 1342 | atombios_yuv_setup(encoder, false); |
| 1343 | } |
| 1344 | |
| 1345 | switch (radeon_encoder->encoder_id) { |
| 1346 | case ENCODER_OBJECT_ID_INTERNAL_TMDS1: |
| 1347 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1: |
| 1348 | case ENCODER_OBJECT_ID_INTERNAL_LVDS: |
| 1349 | case ENCODER_OBJECT_ID_INTERNAL_LVTM1: |
| 1350 | atombios_digital_setup(encoder, PANEL_ENCODER_ACTION_ENABLE); |
| 1351 | break; |
| 1352 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: |
| 1353 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: |
| 1354 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: |
| 1355 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1356 | if (ASIC_IS_DCE4(rdev)) { |
| 1357 | /* disable the transmitter */ |
| 1358 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE, 0, 0); |
| 1359 | /* setup and enable the encoder */ |
| 1360 | atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_SETUP); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1361 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1362 | /* init and enable the transmitter */ |
| 1363 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_INIT, 0, 0); |
| 1364 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); |
| 1365 | } else { |
| 1366 | /* disable the encoder and transmitter */ |
| 1367 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE, 0, 0); |
| 1368 | atombios_dig_encoder_setup(encoder, ATOM_DISABLE); |
| 1369 | |
| 1370 | /* setup and enable the encoder and transmitter */ |
| 1371 | atombios_dig_encoder_setup(encoder, ATOM_ENABLE); |
| 1372 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_INIT, 0, 0); |
| 1373 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0); |
| 1374 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); |
| 1375 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1376 | break; |
| 1377 | case ENCODER_OBJECT_ID_INTERNAL_DDI: |
| 1378 | atombios_ddia_setup(encoder, ATOM_ENABLE); |
| 1379 | break; |
| 1380 | case ENCODER_OBJECT_ID_INTERNAL_DVO1: |
| 1381 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1: |
| 1382 | atombios_external_tmds_setup(encoder, ATOM_ENABLE); |
| 1383 | break; |
| 1384 | case ENCODER_OBJECT_ID_INTERNAL_DAC1: |
| 1385 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1: |
| 1386 | case ENCODER_OBJECT_ID_INTERNAL_DAC2: |
| 1387 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2: |
| 1388 | atombios_dac_setup(encoder, ATOM_ENABLE); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1389 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1390 | atombios_tv_setup(encoder, ATOM_ENABLE); |
| 1391 | break; |
| 1392 | } |
| 1393 | atombios_apply_encoder_quirks(encoder, adjusted_mode); |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 1394 | |
Rafał Miłecki | 2cd6218 | 2010-03-08 22:14:01 +0000 | [diff] [blame] | 1395 | if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) { |
| 1396 | r600_hdmi_enable(encoder); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1397 | r600_hdmi_setmode(encoder, adjusted_mode); |
Rafał Miłecki | 2cd6218 | 2010-03-08 22:14:01 +0000 | [diff] [blame] | 1398 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1399 | } |
| 1400 | |
| 1401 | static bool |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1402 | atombios_dac_load_detect(struct drm_encoder *encoder, struct drm_connector *connector) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1403 | { |
| 1404 | struct drm_device *dev = encoder->dev; |
| 1405 | struct radeon_device *rdev = dev->dev_private; |
| 1406 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1407 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1408 | |
| 1409 | if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT | |
| 1410 | ATOM_DEVICE_CV_SUPPORT | |
| 1411 | ATOM_DEVICE_CRT_SUPPORT)) { |
| 1412 | DAC_LOAD_DETECTION_PS_ALLOCATION args; |
| 1413 | int index = GetIndexIntoMasterTable(COMMAND, DAC_LoadDetection); |
| 1414 | uint8_t frev, crev; |
| 1415 | |
| 1416 | memset(&args, 0, sizeof(args)); |
| 1417 | |
Alex Deucher | a084e6e | 2010-03-18 01:04:01 -0400 | [diff] [blame^] | 1418 | if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev)) |
| 1419 | return false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1420 | |
| 1421 | args.sDacload.ucMisc = 0; |
| 1422 | |
| 1423 | if ((radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_DAC1) || |
| 1424 | (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1)) |
| 1425 | args.sDacload.ucDacType = ATOM_DAC_A; |
| 1426 | else |
| 1427 | args.sDacload.ucDacType = ATOM_DAC_B; |
| 1428 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1429 | if (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1430 | args.sDacload.usDeviceID = cpu_to_le16(ATOM_DEVICE_CRT1_SUPPORT); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1431 | else if (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1432 | args.sDacload.usDeviceID = cpu_to_le16(ATOM_DEVICE_CRT2_SUPPORT); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1433 | else if (radeon_connector->devices & ATOM_DEVICE_CV_SUPPORT) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1434 | args.sDacload.usDeviceID = cpu_to_le16(ATOM_DEVICE_CV_SUPPORT); |
| 1435 | if (crev >= 3) |
| 1436 | args.sDacload.ucMisc = DAC_LOAD_MISC_YPrPb; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1437 | } else if (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1438 | args.sDacload.usDeviceID = cpu_to_le16(ATOM_DEVICE_TV1_SUPPORT); |
| 1439 | if (crev >= 3) |
| 1440 | args.sDacload.ucMisc = DAC_LOAD_MISC_YPrPb; |
| 1441 | } |
| 1442 | |
| 1443 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
| 1444 | |
| 1445 | return true; |
| 1446 | } else |
| 1447 | return false; |
| 1448 | } |
| 1449 | |
| 1450 | static enum drm_connector_status |
| 1451 | radeon_atom_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector) |
| 1452 | { |
| 1453 | struct drm_device *dev = encoder->dev; |
| 1454 | struct radeon_device *rdev = dev->dev_private; |
| 1455 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1456 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1457 | uint32_t bios_0_scratch; |
| 1458 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1459 | if (!atombios_dac_load_detect(encoder, connector)) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1460 | DRM_DEBUG("detect returned false \n"); |
| 1461 | return connector_status_unknown; |
| 1462 | } |
| 1463 | |
| 1464 | if (rdev->family >= CHIP_R600) |
| 1465 | bios_0_scratch = RREG32(R600_BIOS_0_SCRATCH); |
| 1466 | else |
| 1467 | bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); |
| 1468 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1469 | DRM_DEBUG("Bios 0 scratch %x %08x\n", bios_0_scratch, radeon_encoder->devices); |
| 1470 | if (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1471 | if (bios_0_scratch & ATOM_S0_CRT1_MASK) |
| 1472 | return connector_status_connected; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1473 | } |
| 1474 | if (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1475 | if (bios_0_scratch & ATOM_S0_CRT2_MASK) |
| 1476 | return connector_status_connected; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1477 | } |
| 1478 | if (radeon_connector->devices & ATOM_DEVICE_CV_SUPPORT) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1479 | if (bios_0_scratch & (ATOM_S0_CV_MASK|ATOM_S0_CV_MASK_A)) |
| 1480 | return connector_status_connected; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1481 | } |
| 1482 | if (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1483 | if (bios_0_scratch & (ATOM_S0_TV1_COMPOSITE | ATOM_S0_TV1_COMPOSITE_A)) |
| 1484 | return connector_status_connected; /* CTV */ |
| 1485 | else if (bios_0_scratch & (ATOM_S0_TV1_SVIDEO | ATOM_S0_TV1_SVIDEO_A)) |
| 1486 | return connector_status_connected; /* STV */ |
| 1487 | } |
| 1488 | return connector_status_disconnected; |
| 1489 | } |
| 1490 | |
| 1491 | static void radeon_atom_encoder_prepare(struct drm_encoder *encoder) |
| 1492 | { |
Alex Deucher | 267364a | 2010-03-08 17:10:41 -0500 | [diff] [blame] | 1493 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 1494 | |
| 1495 | if (radeon_encoder->active_device & |
| 1496 | (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT)) { |
| 1497 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
| 1498 | if (dig) |
| 1499 | dig->dig_encoder = radeon_atom_pick_dig_encoder(encoder); |
| 1500 | } |
| 1501 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1502 | radeon_atom_output_lock(encoder, true); |
| 1503 | radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_OFF); |
Alex Deucher | 267364a | 2010-03-08 17:10:41 -0500 | [diff] [blame] | 1504 | |
| 1505 | /* this is needed for the pll/ss setup to work correctly in some cases */ |
| 1506 | atombios_set_encoder_crtc_source(encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1507 | } |
| 1508 | |
| 1509 | static void radeon_atom_encoder_commit(struct drm_encoder *encoder) |
| 1510 | { |
| 1511 | radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_ON); |
| 1512 | radeon_atom_output_lock(encoder, false); |
| 1513 | } |
| 1514 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1515 | static void radeon_atom_encoder_disable(struct drm_encoder *encoder) |
| 1516 | { |
| 1517 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 1518 | struct radeon_encoder_atom_dig *dig; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1519 | radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_OFF); |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 1520 | |
| 1521 | if (radeon_encoder_is_digital(encoder)) { |
Rafał Miłecki | 2cd6218 | 2010-03-08 22:14:01 +0000 | [diff] [blame] | 1522 | if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) |
| 1523 | r600_hdmi_disable(encoder); |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 1524 | dig = radeon_encoder->enc_priv; |
| 1525 | dig->dig_encoder = -1; |
| 1526 | } |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1527 | radeon_encoder->active_device = 0; |
| 1528 | } |
| 1529 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1530 | static const struct drm_encoder_helper_funcs radeon_atom_dig_helper_funcs = { |
| 1531 | .dpms = radeon_atom_encoder_dpms, |
| 1532 | .mode_fixup = radeon_atom_mode_fixup, |
| 1533 | .prepare = radeon_atom_encoder_prepare, |
| 1534 | .mode_set = radeon_atom_encoder_mode_set, |
| 1535 | .commit = radeon_atom_encoder_commit, |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1536 | .disable = radeon_atom_encoder_disable, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1537 | /* no detect for TMDS/LVDS yet */ |
| 1538 | }; |
| 1539 | |
| 1540 | static const struct drm_encoder_helper_funcs radeon_atom_dac_helper_funcs = { |
| 1541 | .dpms = radeon_atom_encoder_dpms, |
| 1542 | .mode_fixup = radeon_atom_mode_fixup, |
| 1543 | .prepare = radeon_atom_encoder_prepare, |
| 1544 | .mode_set = radeon_atom_encoder_mode_set, |
| 1545 | .commit = radeon_atom_encoder_commit, |
| 1546 | .detect = radeon_atom_dac_detect, |
| 1547 | }; |
| 1548 | |
| 1549 | void radeon_enc_destroy(struct drm_encoder *encoder) |
| 1550 | { |
| 1551 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 1552 | kfree(radeon_encoder->enc_priv); |
| 1553 | drm_encoder_cleanup(encoder); |
| 1554 | kfree(radeon_encoder); |
| 1555 | } |
| 1556 | |
| 1557 | static const struct drm_encoder_funcs radeon_atom_enc_funcs = { |
| 1558 | .destroy = radeon_enc_destroy, |
| 1559 | }; |
| 1560 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1561 | struct radeon_encoder_atom_dac * |
| 1562 | radeon_atombios_set_dac_info(struct radeon_encoder *radeon_encoder) |
| 1563 | { |
| 1564 | struct radeon_encoder_atom_dac *dac = kzalloc(sizeof(struct radeon_encoder_atom_dac), GFP_KERNEL); |
| 1565 | |
| 1566 | if (!dac) |
| 1567 | return NULL; |
| 1568 | |
| 1569 | dac->tv_std = TV_STD_NTSC; |
| 1570 | return dac; |
| 1571 | } |
| 1572 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1573 | struct radeon_encoder_atom_dig * |
| 1574 | radeon_atombios_set_dig_info(struct radeon_encoder *radeon_encoder) |
| 1575 | { |
| 1576 | struct radeon_encoder_atom_dig *dig = kzalloc(sizeof(struct radeon_encoder_atom_dig), GFP_KERNEL); |
| 1577 | |
| 1578 | if (!dig) |
| 1579 | return NULL; |
| 1580 | |
| 1581 | /* coherent mode by default */ |
| 1582 | dig->coherent_mode = true; |
Dave Airlie | f28cf33 | 2010-01-28 17:15:25 +1000 | [diff] [blame] | 1583 | dig->dig_encoder = -1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1584 | |
| 1585 | return dig; |
| 1586 | } |
| 1587 | |
| 1588 | void |
| 1589 | radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_id, uint32_t supported_device) |
| 1590 | { |
Dave Airlie | dfee561 | 2009-10-02 09:19:09 +1000 | [diff] [blame] | 1591 | struct radeon_device *rdev = dev->dev_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1592 | struct drm_encoder *encoder; |
| 1593 | struct radeon_encoder *radeon_encoder; |
| 1594 | |
| 1595 | /* see if we already added it */ |
| 1596 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 1597 | radeon_encoder = to_radeon_encoder(encoder); |
| 1598 | if (radeon_encoder->encoder_id == encoder_id) { |
| 1599 | radeon_encoder->devices |= supported_device; |
| 1600 | return; |
| 1601 | } |
| 1602 | |
| 1603 | } |
| 1604 | |
| 1605 | /* add a new one */ |
| 1606 | radeon_encoder = kzalloc(sizeof(struct radeon_encoder), GFP_KERNEL); |
| 1607 | if (!radeon_encoder) |
| 1608 | return; |
| 1609 | |
| 1610 | encoder = &radeon_encoder->base; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1611 | switch (rdev->num_crtc) { |
| 1612 | case 1: |
Dave Airlie | dfee561 | 2009-10-02 09:19:09 +1000 | [diff] [blame] | 1613 | encoder->possible_crtcs = 0x1; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1614 | break; |
| 1615 | case 2: |
| 1616 | default: |
Dave Airlie | dfee561 | 2009-10-02 09:19:09 +1000 | [diff] [blame] | 1617 | encoder->possible_crtcs = 0x3; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1618 | break; |
| 1619 | case 6: |
| 1620 | encoder->possible_crtcs = 0x3f; |
| 1621 | break; |
| 1622 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1623 | |
| 1624 | radeon_encoder->enc_priv = NULL; |
| 1625 | |
| 1626 | radeon_encoder->encoder_id = encoder_id; |
| 1627 | radeon_encoder->devices = supported_device; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 1628 | radeon_encoder->rmx_type = RMX_OFF; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1629 | |
| 1630 | switch (radeon_encoder->encoder_id) { |
| 1631 | case ENCODER_OBJECT_ID_INTERNAL_LVDS: |
| 1632 | case ENCODER_OBJECT_ID_INTERNAL_TMDS1: |
| 1633 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1: |
| 1634 | case ENCODER_OBJECT_ID_INTERNAL_LVTM1: |
| 1635 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
| 1636 | radeon_encoder->rmx_type = RMX_FULL; |
| 1637 | drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_LVDS); |
| 1638 | radeon_encoder->enc_priv = radeon_atombios_get_lvds_info(radeon_encoder); |
| 1639 | } else { |
| 1640 | drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_TMDS); |
| 1641 | radeon_encoder->enc_priv = radeon_atombios_set_dig_info(radeon_encoder); |
| 1642 | } |
| 1643 | drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs); |
| 1644 | break; |
| 1645 | case ENCODER_OBJECT_ID_INTERNAL_DAC1: |
| 1646 | drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_DAC); |
| 1647 | drm_encoder_helper_add(encoder, &radeon_atom_dac_helper_funcs); |
| 1648 | break; |
| 1649 | case ENCODER_OBJECT_ID_INTERNAL_DAC2: |
| 1650 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1: |
| 1651 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2: |
| 1652 | drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_TVDAC); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1653 | radeon_encoder->enc_priv = radeon_atombios_set_dac_info(radeon_encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1654 | drm_encoder_helper_add(encoder, &radeon_atom_dac_helper_funcs); |
| 1655 | break; |
| 1656 | case ENCODER_OBJECT_ID_INTERNAL_DVO1: |
| 1657 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1: |
| 1658 | case ENCODER_OBJECT_ID_INTERNAL_DDI: |
| 1659 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: |
| 1660 | case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: |
| 1661 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: |
| 1662 | case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: |
Alex Deucher | 60d15f5 | 2009-09-08 14:22:45 -0400 | [diff] [blame] | 1663 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
| 1664 | radeon_encoder->rmx_type = RMX_FULL; |
| 1665 | drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_LVDS); |
| 1666 | radeon_encoder->enc_priv = radeon_atombios_get_lvds_info(radeon_encoder); |
| 1667 | } else { |
| 1668 | drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_TMDS); |
| 1669 | radeon_encoder->enc_priv = radeon_atombios_set_dig_info(radeon_encoder); |
| 1670 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1671 | drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs); |
| 1672 | break; |
| 1673 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1674 | } |