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 | */ |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 26 | #include <drm/drmP.h> |
| 27 | #include <drm/drm_crtc_helper.h> |
| 28 | #include <drm/radeon_drm.h> |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 29 | #include "radeon.h" |
| 30 | #include "atom.h" |
| 31 | |
Alex Deucher | f372873 | 2012-07-26 11:32:03 -0400 | [diff] [blame] | 32 | extern void |
| 33 | radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder, |
| 34 | struct drm_connector *drm_connector); |
| 35 | extern void |
| 36 | radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder, |
| 37 | struct drm_connector *drm_connector); |
| 38 | |
| 39 | |
Dave Airlie | 1f3b6a4 | 2009-10-13 14:10:37 +1000 | [diff] [blame] | 40 | static uint32_t radeon_encoder_clones(struct drm_encoder *encoder) |
| 41 | { |
| 42 | struct drm_device *dev = encoder->dev; |
| 43 | struct radeon_device *rdev = dev->dev_private; |
| 44 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 45 | struct drm_encoder *clone_encoder; |
| 46 | uint32_t index_mask = 0; |
| 47 | int count; |
| 48 | |
| 49 | /* DIG routing gets problematic */ |
| 50 | if (rdev->family >= CHIP_R600) |
| 51 | return index_mask; |
| 52 | /* LVDS/TV are too wacky */ |
| 53 | if (radeon_encoder->devices & ATOM_DEVICE_LCD_SUPPORT) |
| 54 | return index_mask; |
| 55 | /* DVO requires 2x ppll clocks depending on tmds chip */ |
| 56 | if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) |
| 57 | return index_mask; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 58 | |
Dave Airlie | 1f3b6a4 | 2009-10-13 14:10:37 +1000 | [diff] [blame] | 59 | count = -1; |
| 60 | list_for_each_entry(clone_encoder, &dev->mode_config.encoder_list, head) { |
| 61 | struct radeon_encoder *radeon_clone = to_radeon_encoder(clone_encoder); |
| 62 | count++; |
| 63 | |
| 64 | if (clone_encoder == encoder) |
| 65 | continue; |
| 66 | if (radeon_clone->devices & (ATOM_DEVICE_LCD_SUPPORT)) |
| 67 | continue; |
| 68 | if (radeon_clone->devices & ATOM_DEVICE_DFP2_SUPPORT) |
| 69 | continue; |
| 70 | else |
| 71 | index_mask |= (1 << count); |
| 72 | } |
| 73 | return index_mask; |
| 74 | } |
| 75 | |
| 76 | void radeon_setup_encoder_clones(struct drm_device *dev) |
| 77 | { |
| 78 | struct drm_encoder *encoder; |
| 79 | |
| 80 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 81 | encoder->possible_clones = radeon_encoder_clones(encoder); |
| 82 | } |
| 83 | } |
| 84 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 85 | uint32_t |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 86 | radeon_get_encoder_enum(struct drm_device *dev, uint32_t supported_device, uint8_t dac) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 87 | { |
| 88 | struct radeon_device *rdev = dev->dev_private; |
| 89 | uint32_t ret = 0; |
| 90 | |
| 91 | switch (supported_device) { |
| 92 | case ATOM_DEVICE_CRT1_SUPPORT: |
| 93 | case ATOM_DEVICE_TV1_SUPPORT: |
| 94 | case ATOM_DEVICE_TV2_SUPPORT: |
| 95 | case ATOM_DEVICE_CRT2_SUPPORT: |
| 96 | case ATOM_DEVICE_CV_SUPPORT: |
| 97 | switch (dac) { |
| 98 | case 1: /* dac a */ |
| 99 | if ((rdev->family == CHIP_RS300) || |
| 100 | (rdev->family == CHIP_RS400) || |
| 101 | (rdev->family == CHIP_RS480)) |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 102 | ret = ENCODER_INTERNAL_DAC2_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 103 | else if (ASIC_IS_AVIVO(rdev)) |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 104 | ret = ENCODER_INTERNAL_KLDSCP_DAC1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 105 | else |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 106 | ret = ENCODER_INTERNAL_DAC1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 107 | break; |
| 108 | case 2: /* dac b */ |
| 109 | if (ASIC_IS_AVIVO(rdev)) |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 110 | ret = ENCODER_INTERNAL_KLDSCP_DAC2_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 111 | else { |
| 112 | /*if (rdev->family == CHIP_R200) |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 113 | ret = ENCODER_INTERNAL_DVO1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 114 | else*/ |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 115 | ret = ENCODER_INTERNAL_DAC2_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 116 | } |
| 117 | break; |
| 118 | case 3: /* external dac */ |
| 119 | if (ASIC_IS_AVIVO(rdev)) |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 120 | ret = ENCODER_INTERNAL_KLDSCP_DVO1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 121 | else |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 122 | ret = ENCODER_INTERNAL_DVO1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 123 | break; |
| 124 | } |
| 125 | break; |
| 126 | case ATOM_DEVICE_LCD1_SUPPORT: |
| 127 | if (ASIC_IS_AVIVO(rdev)) |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 128 | ret = ENCODER_INTERNAL_LVTM1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 129 | else |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 130 | ret = ENCODER_INTERNAL_LVDS_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 131 | break; |
| 132 | case ATOM_DEVICE_DFP1_SUPPORT: |
| 133 | if ((rdev->family == CHIP_RS300) || |
| 134 | (rdev->family == CHIP_RS400) || |
| 135 | (rdev->family == CHIP_RS480)) |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 136 | ret = ENCODER_INTERNAL_DVO1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 137 | else if (ASIC_IS_AVIVO(rdev)) |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 138 | ret = ENCODER_INTERNAL_KLDSCP_TMDS1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 139 | else |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 140 | ret = ENCODER_INTERNAL_TMDS1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 141 | break; |
| 142 | case ATOM_DEVICE_LCD2_SUPPORT: |
| 143 | case ATOM_DEVICE_DFP2_SUPPORT: |
| 144 | if ((rdev->family == CHIP_RS600) || |
| 145 | (rdev->family == CHIP_RS690) || |
| 146 | (rdev->family == CHIP_RS740)) |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 147 | ret = ENCODER_INTERNAL_DDI_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 148 | else if (ASIC_IS_AVIVO(rdev)) |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 149 | ret = ENCODER_INTERNAL_KLDSCP_DVO1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 150 | else |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 151 | ret = ENCODER_INTERNAL_DVO1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 152 | break; |
| 153 | case ATOM_DEVICE_DFP3_SUPPORT: |
Alex Deucher | 5137ee9 | 2010-08-12 18:58:47 -0400 | [diff] [blame] | 154 | ret = ENCODER_INTERNAL_LVTM1_ENUM_ID1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 155 | break; |
| 156 | } |
| 157 | |
| 158 | return ret; |
| 159 | } |
| 160 | |
Alex Deucher | bc13018 | 2014-09-16 20:57:26 -0400 | [diff] [blame^] | 161 | static void radeon_encoder_add_backlight(struct radeon_encoder *radeon_encoder, |
| 162 | struct drm_connector *connector) |
| 163 | { |
| 164 | struct drm_device *dev = radeon_encoder->base.dev; |
| 165 | struct radeon_device *rdev = dev->dev_private; |
| 166 | bool use_bl = false; |
| 167 | |
| 168 | if (!(radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))) |
| 169 | return; |
| 170 | |
| 171 | if (radeon_backlight == 0) { |
| 172 | return; |
| 173 | } else if (radeon_backlight == 1) { |
| 174 | use_bl = true; |
| 175 | } else if (radeon_backlight == -1) { |
| 176 | use_bl = true; |
| 177 | } |
| 178 | |
| 179 | if (use_bl) { |
| 180 | if (rdev->is_atom_bios) |
| 181 | radeon_atom_backlight_init(radeon_encoder, connector); |
| 182 | else |
| 183 | radeon_legacy_backlight_init(radeon_encoder, connector); |
| 184 | rdev->mode_info.bl_encoder = radeon_encoder; |
| 185 | } |
| 186 | } |
| 187 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 188 | void |
| 189 | radeon_link_encoder_connector(struct drm_device *dev) |
| 190 | { |
| 191 | struct drm_connector *connector; |
| 192 | struct radeon_connector *radeon_connector; |
| 193 | struct drm_encoder *encoder; |
| 194 | struct radeon_encoder *radeon_encoder; |
| 195 | |
| 196 | /* walk the list and link encoders to connectors */ |
| 197 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 198 | radeon_connector = to_radeon_connector(connector); |
| 199 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 200 | radeon_encoder = to_radeon_encoder(encoder); |
Alex Deucher | f372873 | 2012-07-26 11:32:03 -0400 | [diff] [blame] | 201 | if (radeon_encoder->devices & radeon_connector->devices) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 202 | drm_mode_connector_attach_encoder(connector, encoder); |
Alex Deucher | bc13018 | 2014-09-16 20:57:26 -0400 | [diff] [blame^] | 203 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) |
| 204 | radeon_encoder_add_backlight(radeon_encoder, connector); |
Alex Deucher | f372873 | 2012-07-26 11:32:03 -0400 | [diff] [blame] | 205 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 210 | void radeon_encoder_set_active_device(struct drm_encoder *encoder) |
| 211 | { |
| 212 | struct drm_device *dev = encoder->dev; |
| 213 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 214 | struct drm_connector *connector; |
| 215 | |
| 216 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 217 | if (connector->encoder == encoder) { |
| 218 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 219 | radeon_encoder->active_device = radeon_encoder->devices & radeon_connector->devices; |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 220 | DRM_DEBUG_KMS("setting active device to %08x from %08x %08x for encoder %d\n", |
Dave Airlie | f641e51 | 2009-09-08 11:17:38 +1000 | [diff] [blame] | 221 | radeon_encoder->active_device, radeon_encoder->devices, |
| 222 | radeon_connector->devices, encoder->encoder_type); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
Alex Deucher | 5b1714d | 2010-08-03 19:59:20 -0400 | [diff] [blame] | 227 | struct drm_connector * |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 228 | radeon_get_connector_for_encoder(struct drm_encoder *encoder) |
| 229 | { |
| 230 | struct drm_device *dev = encoder->dev; |
| 231 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 232 | struct drm_connector *connector; |
| 233 | struct radeon_connector *radeon_connector; |
| 234 | |
| 235 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 236 | radeon_connector = to_radeon_connector(connector); |
Dave Airlie | 43c33ed | 2010-01-29 15:55:30 +1000 | [diff] [blame] | 237 | if (radeon_encoder->active_device & radeon_connector->devices) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 238 | return connector; |
| 239 | } |
| 240 | return NULL; |
| 241 | } |
| 242 | |
Alex Deucher | 9aa5999 | 2012-01-20 15:03:30 -0500 | [diff] [blame] | 243 | struct drm_connector * |
| 244 | radeon_get_connector_for_encoder_init(struct drm_encoder *encoder) |
| 245 | { |
| 246 | struct drm_device *dev = encoder->dev; |
| 247 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 248 | struct drm_connector *connector; |
| 249 | struct radeon_connector *radeon_connector; |
| 250 | |
| 251 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 252 | radeon_connector = to_radeon_connector(connector); |
| 253 | if (radeon_encoder->devices & radeon_connector->devices) |
| 254 | return connector; |
| 255 | } |
| 256 | return NULL; |
| 257 | } |
| 258 | |
Alex Deucher | 3f03ced | 2011-10-30 17:20:22 -0400 | [diff] [blame] | 259 | struct drm_encoder *radeon_get_external_encoder(struct drm_encoder *encoder) |
Alex Deucher | 3e4b998 | 2010-11-16 12:09:42 -0500 | [diff] [blame] | 260 | { |
| 261 | struct drm_device *dev = encoder->dev; |
| 262 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 263 | struct drm_encoder *other_encoder; |
| 264 | struct radeon_encoder *other_radeon_encoder; |
| 265 | |
| 266 | if (radeon_encoder->is_ext_encoder) |
| 267 | return NULL; |
| 268 | |
| 269 | list_for_each_entry(other_encoder, &dev->mode_config.encoder_list, head) { |
| 270 | if (other_encoder == encoder) |
| 271 | continue; |
| 272 | other_radeon_encoder = to_radeon_encoder(other_encoder); |
| 273 | if (other_radeon_encoder->is_ext_encoder && |
| 274 | (radeon_encoder->devices & other_radeon_encoder->devices)) |
| 275 | return other_encoder; |
| 276 | } |
| 277 | return NULL; |
| 278 | } |
| 279 | |
Alex Deucher | 1d33e1f | 2011-10-31 08:58:47 -0400 | [diff] [blame] | 280 | u16 radeon_encoder_get_dp_bridge_encoder_id(struct drm_encoder *encoder) |
Alex Deucher | d7fa8bb | 2011-05-20 04:34:21 -0400 | [diff] [blame] | 281 | { |
Alex Deucher | 3f03ced | 2011-10-30 17:20:22 -0400 | [diff] [blame] | 282 | struct drm_encoder *other_encoder = radeon_get_external_encoder(encoder); |
Alex Deucher | d7fa8bb | 2011-05-20 04:34:21 -0400 | [diff] [blame] | 283 | |
| 284 | if (other_encoder) { |
| 285 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(other_encoder); |
| 286 | |
| 287 | switch (radeon_encoder->encoder_id) { |
| 288 | case ENCODER_OBJECT_ID_TRAVIS: |
| 289 | case ENCODER_OBJECT_ID_NUTMEG: |
Alex Deucher | dc87cd5 | 2011-12-02 18:15:27 -0500 | [diff] [blame] | 290 | return radeon_encoder->encoder_id; |
Alex Deucher | d7fa8bb | 2011-05-20 04:34:21 -0400 | [diff] [blame] | 291 | default: |
Alex Deucher | dc87cd5 | 2011-12-02 18:15:27 -0500 | [diff] [blame] | 292 | return ENCODER_OBJECT_ID_NONE; |
Alex Deucher | d7fa8bb | 2011-05-20 04:34:21 -0400 | [diff] [blame] | 293 | } |
| 294 | } |
Alex Deucher | dc87cd5 | 2011-12-02 18:15:27 -0500 | [diff] [blame] | 295 | return ENCODER_OBJECT_ID_NONE; |
Alex Deucher | d7fa8bb | 2011-05-20 04:34:21 -0400 | [diff] [blame] | 296 | } |
| 297 | |
Alex Deucher | 3515387 | 2010-04-30 12:00:44 -0400 | [diff] [blame] | 298 | void radeon_panel_mode_fixup(struct drm_encoder *encoder, |
| 299 | struct drm_display_mode *adjusted_mode) |
| 300 | { |
| 301 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 302 | struct drm_device *dev = encoder->dev; |
| 303 | struct radeon_device *rdev = dev->dev_private; |
| 304 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
| 305 | unsigned hblank = native_mode->htotal - native_mode->hdisplay; |
| 306 | unsigned vblank = native_mode->vtotal - native_mode->vdisplay; |
| 307 | unsigned hover = native_mode->hsync_start - native_mode->hdisplay; |
| 308 | unsigned vover = native_mode->vsync_start - native_mode->vdisplay; |
| 309 | unsigned hsync_width = native_mode->hsync_end - native_mode->hsync_start; |
| 310 | unsigned vsync_width = native_mode->vsync_end - native_mode->vsync_start; |
| 311 | |
| 312 | adjusted_mode->clock = native_mode->clock; |
| 313 | adjusted_mode->flags = native_mode->flags; |
| 314 | |
| 315 | if (ASIC_IS_AVIVO(rdev)) { |
| 316 | adjusted_mode->hdisplay = native_mode->hdisplay; |
| 317 | adjusted_mode->vdisplay = native_mode->vdisplay; |
| 318 | } |
| 319 | |
| 320 | adjusted_mode->htotal = native_mode->hdisplay + hblank; |
| 321 | adjusted_mode->hsync_start = native_mode->hdisplay + hover; |
| 322 | adjusted_mode->hsync_end = adjusted_mode->hsync_start + hsync_width; |
| 323 | |
| 324 | adjusted_mode->vtotal = native_mode->vdisplay + vblank; |
| 325 | adjusted_mode->vsync_start = native_mode->vdisplay + vover; |
| 326 | adjusted_mode->vsync_end = adjusted_mode->vsync_start + vsync_width; |
| 327 | |
| 328 | drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V); |
| 329 | |
| 330 | if (ASIC_IS_AVIVO(rdev)) { |
| 331 | adjusted_mode->crtc_hdisplay = native_mode->hdisplay; |
| 332 | adjusted_mode->crtc_vdisplay = native_mode->vdisplay; |
| 333 | } |
| 334 | |
| 335 | adjusted_mode->crtc_htotal = adjusted_mode->crtc_hdisplay + hblank; |
| 336 | adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hdisplay + hover; |
| 337 | adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + hsync_width; |
| 338 | |
| 339 | adjusted_mode->crtc_vtotal = adjusted_mode->crtc_vdisplay + vblank; |
| 340 | adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + vover; |
| 341 | adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + vsync_width; |
| 342 | |
| 343 | } |
| 344 | |
Alex Deucher | 9aa5999 | 2012-01-20 15:03:30 -0500 | [diff] [blame] | 345 | bool radeon_dig_monitor_is_duallink(struct drm_encoder *encoder, |
| 346 | u32 pixel_clock) |
| 347 | { |
Alex Deucher | 1b2681b | 2012-03-20 17:18:42 -0400 | [diff] [blame] | 348 | struct drm_device *dev = encoder->dev; |
| 349 | struct radeon_device *rdev = dev->dev_private; |
Alex Deucher | 9aa5999 | 2012-01-20 15:03:30 -0500 | [diff] [blame] | 350 | struct drm_connector *connector; |
| 351 | struct radeon_connector *radeon_connector; |
| 352 | struct radeon_connector_atom_dig *dig_connector; |
| 353 | |
| 354 | connector = radeon_get_connector_for_encoder(encoder); |
| 355 | /* if we don't have an active device yet, just use one of |
| 356 | * the connectors tied to the encoder. |
| 357 | */ |
| 358 | if (!connector) |
| 359 | connector = radeon_get_connector_for_encoder_init(encoder); |
| 360 | radeon_connector = to_radeon_connector(connector); |
| 361 | |
| 362 | switch (connector->connector_type) { |
| 363 | case DRM_MODE_CONNECTOR_DVII: |
| 364 | case DRM_MODE_CONNECTOR_HDMIB: |
| 365 | if (radeon_connector->use_digital) { |
| 366 | /* HDMI 1.3 supports up to 340 Mhz over single link */ |
Alex Deucher | 377bd8a | 2014-07-15 11:00:47 -0400 | [diff] [blame] | 367 | if (ASIC_IS_DCE6(rdev) && drm_detect_hdmi_monitor(radeon_connector_edid(connector))) { |
Alex Deucher | 9aa5999 | 2012-01-20 15:03:30 -0500 | [diff] [blame] | 368 | if (pixel_clock > 340000) |
| 369 | return true; |
| 370 | else |
| 371 | return false; |
| 372 | } else { |
| 373 | if (pixel_clock > 165000) |
| 374 | return true; |
| 375 | else |
| 376 | return false; |
| 377 | } |
| 378 | } else |
| 379 | return false; |
| 380 | case DRM_MODE_CONNECTOR_DVID: |
| 381 | case DRM_MODE_CONNECTOR_HDMIA: |
| 382 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 383 | dig_connector = radeon_connector->con_priv; |
| 384 | if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
| 385 | (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) |
| 386 | return false; |
| 387 | else { |
| 388 | /* HDMI 1.3 supports up to 340 Mhz over single link */ |
Alex Deucher | 377bd8a | 2014-07-15 11:00:47 -0400 | [diff] [blame] | 389 | if (ASIC_IS_DCE6(rdev) && drm_detect_hdmi_monitor(radeon_connector_edid(connector))) { |
Alex Deucher | 9aa5999 | 2012-01-20 15:03:30 -0500 | [diff] [blame] | 390 | if (pixel_clock > 340000) |
| 391 | return true; |
| 392 | else |
| 393 | return false; |
| 394 | } else { |
| 395 | if (pixel_clock > 165000) |
| 396 | return true; |
| 397 | else |
| 398 | return false; |
| 399 | } |
| 400 | } |
| 401 | default: |
| 402 | return false; |
| 403 | } |
| 404 | } |
| 405 | |