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_edid.h" |
| 28 | #include "drm_crtc_helper.h" |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 29 | #include "drm_fb_helper.h" |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 30 | #include "radeon_drm.h" |
| 31 | #include "radeon.h" |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 32 | #include "atom.h" |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 33 | |
| 34 | extern void |
| 35 | radeon_combios_connected_scratch_regs(struct drm_connector *connector, |
| 36 | struct drm_encoder *encoder, |
| 37 | bool connected); |
| 38 | extern void |
| 39 | radeon_atombios_connected_scratch_regs(struct drm_connector *connector, |
| 40 | struct drm_encoder *encoder, |
| 41 | bool connected); |
| 42 | |
Michel Dänzer | 63ec011 | 2011-03-22 16:30:23 -0700 | [diff] [blame] | 43 | extern void |
| 44 | radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder, |
| 45 | struct drm_connector *drm_connector); |
| 46 | |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 47 | void radeon_connector_hotplug(struct drm_connector *connector) |
| 48 | { |
| 49 | struct drm_device *dev = connector->dev; |
| 50 | struct radeon_device *rdev = dev->dev_private; |
| 51 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 52 | |
Alex Deucher | cbac954 | 2011-07-11 14:49:28 +0000 | [diff] [blame] | 53 | /* bail if the connector does not have hpd pin, e.g., |
| 54 | * VGA, TV, etc. |
| 55 | */ |
| 56 | if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) |
| 57 | return; |
| 58 | |
Alex Deucher | 1e85e1d | 2011-05-20 04:34:29 -0400 | [diff] [blame] | 59 | radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 60 | |
Alex Deucher | 73104b5 | 2011-08-09 17:09:06 +0000 | [diff] [blame] | 61 | /* if the connector is already off, don't turn it back on */ |
| 62 | if (connector->dpms != DRM_MODE_DPMS_ON) |
| 63 | return; |
| 64 | |
Alex Deucher | d5811e8 | 2011-08-13 13:36:13 -0400 | [diff] [blame] | 65 | /* just deal with DP (not eDP) here. */ |
| 66 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) { |
| 67 | int saved_dpms = connector->dpms; |
Alex Deucher | 7c3ed0f | 2011-05-20 04:34:30 -0400 | [diff] [blame] | 68 | |
Alex Deucher | 5ba7ddf | 2011-10-03 08:37:33 -0400 | [diff] [blame] | 69 | /* Only turn off the display it it's physically disconnected */ |
| 70 | if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) |
Alex Deucher | 1e85e1d | 2011-05-20 04:34:29 -0400 | [diff] [blame] | 71 | drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); |
Alex Deucher | 5ba7ddf | 2011-10-03 08:37:33 -0400 | [diff] [blame] | 72 | else if (radeon_dp_needs_link_train(radeon_connector)) |
| 73 | drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); |
Alex Deucher | d5811e8 | 2011-08-13 13:36:13 -0400 | [diff] [blame] | 74 | connector->dpms = saved_dpms; |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 75 | } |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 76 | } |
| 77 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 78 | static void radeon_property_change_mode(struct drm_encoder *encoder) |
| 79 | { |
| 80 | struct drm_crtc *crtc = encoder->crtc; |
| 81 | |
| 82 | if (crtc && crtc->enabled) { |
| 83 | drm_crtc_helper_set_mode(crtc, &crtc->mode, |
| 84 | crtc->x, crtc->y, crtc->fb); |
| 85 | } |
| 86 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 87 | static void |
| 88 | radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_connector_status status) |
| 89 | { |
| 90 | struct drm_device *dev = connector->dev; |
| 91 | struct radeon_device *rdev = dev->dev_private; |
| 92 | struct drm_encoder *best_encoder = NULL; |
| 93 | struct drm_encoder *encoder = NULL; |
| 94 | struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; |
| 95 | struct drm_mode_object *obj; |
| 96 | bool connected; |
| 97 | int i; |
| 98 | |
| 99 | best_encoder = connector_funcs->best_encoder(connector); |
| 100 | |
| 101 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
| 102 | if (connector->encoder_ids[i] == 0) |
| 103 | break; |
| 104 | |
| 105 | obj = drm_mode_object_find(connector->dev, |
| 106 | connector->encoder_ids[i], |
| 107 | DRM_MODE_OBJECT_ENCODER); |
| 108 | if (!obj) |
| 109 | continue; |
| 110 | |
| 111 | encoder = obj_to_encoder(obj); |
| 112 | |
| 113 | if ((encoder == best_encoder) && (status == connector_status_connected)) |
| 114 | connected = true; |
| 115 | else |
| 116 | connected = false; |
| 117 | |
| 118 | if (rdev->is_atom_bios) |
| 119 | radeon_atombios_connected_scratch_regs(connector, encoder, connected); |
| 120 | else |
| 121 | radeon_combios_connected_scratch_regs(connector, encoder, connected); |
| 122 | |
| 123 | } |
| 124 | } |
| 125 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 126 | struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type) |
| 127 | { |
| 128 | struct drm_mode_object *obj; |
| 129 | struct drm_encoder *encoder; |
| 130 | int i; |
| 131 | |
| 132 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
| 133 | if (connector->encoder_ids[i] == 0) |
| 134 | break; |
| 135 | |
| 136 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); |
| 137 | if (!obj) |
| 138 | continue; |
| 139 | |
| 140 | encoder = obj_to_encoder(obj); |
| 141 | if (encoder->encoder_type == encoder_type) |
| 142 | return encoder; |
| 143 | } |
| 144 | return NULL; |
| 145 | } |
| 146 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 147 | struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector) |
| 148 | { |
| 149 | int enc_id = connector->encoder_ids[0]; |
| 150 | struct drm_mode_object *obj; |
| 151 | struct drm_encoder *encoder; |
| 152 | |
| 153 | /* pick the encoder ids */ |
| 154 | if (enc_id) { |
| 155 | obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); |
| 156 | if (!obj) |
| 157 | return NULL; |
| 158 | encoder = obj_to_encoder(obj); |
| 159 | return encoder; |
| 160 | } |
| 161 | return NULL; |
| 162 | } |
| 163 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 164 | /* |
| 165 | * radeon_connector_analog_encoder_conflict_solve |
| 166 | * - search for other connectors sharing this encoder |
| 167 | * if priority is true, then set them disconnected if this is connected |
| 168 | * if priority is false, set us disconnected if they are connected |
| 169 | */ |
| 170 | static enum drm_connector_status |
| 171 | radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector, |
| 172 | struct drm_encoder *encoder, |
| 173 | enum drm_connector_status current_status, |
| 174 | bool priority) |
| 175 | { |
| 176 | struct drm_device *dev = connector->dev; |
| 177 | struct drm_connector *conflict; |
Alex Deucher | 08d0751 | 2010-04-15 13:31:12 -0400 | [diff] [blame] | 178 | struct radeon_connector *radeon_conflict; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 179 | int i; |
| 180 | |
| 181 | list_for_each_entry(conflict, &dev->mode_config.connector_list, head) { |
| 182 | if (conflict == connector) |
| 183 | continue; |
| 184 | |
Alex Deucher | 08d0751 | 2010-04-15 13:31:12 -0400 | [diff] [blame] | 185 | radeon_conflict = to_radeon_connector(conflict); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 186 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
| 187 | if (conflict->encoder_ids[i] == 0) |
| 188 | break; |
| 189 | |
| 190 | /* if the IDs match */ |
| 191 | if (conflict->encoder_ids[i] == encoder->base.id) { |
| 192 | if (conflict->status != connector_status_connected) |
| 193 | continue; |
| 194 | |
Alex Deucher | 08d0751 | 2010-04-15 13:31:12 -0400 | [diff] [blame] | 195 | if (radeon_conflict->use_digital) |
| 196 | continue; |
| 197 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 198 | if (priority == true) { |
Alex Deucher | c5d46b4 | 2010-10-29 13:49:25 -0400 | [diff] [blame] | 199 | DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict)); |
| 200 | DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(connector)); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 201 | conflict->status = connector_status_disconnected; |
| 202 | radeon_connector_update_scratch_regs(conflict, connector_status_disconnected); |
| 203 | } else { |
Alex Deucher | c5d46b4 | 2010-10-29 13:49:25 -0400 | [diff] [blame] | 204 | DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector)); |
| 205 | DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(conflict)); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 206 | current_status = connector_status_disconnected; |
| 207 | } |
| 208 | break; |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | return current_status; |
| 213 | |
| 214 | } |
| 215 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 216 | static struct drm_display_mode *radeon_fp_native_mode(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_display_mode *mode = NULL; |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 221 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 222 | |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 223 | if (native_mode->hdisplay != 0 && |
| 224 | native_mode->vdisplay != 0 && |
| 225 | native_mode->clock != 0) { |
Alex Deucher | fb06ca8 | 2009-10-12 11:25:05 -0400 | [diff] [blame] | 226 | mode = drm_mode_duplicate(dev, native_mode); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 227 | mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; |
| 228 | drm_mode_set_name(mode); |
| 229 | |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 230 | DRM_DEBUG_KMS("Adding native panel mode %s\n", mode->name); |
Alex Deucher | d2efdf6 | 2009-12-22 10:06:49 -0500 | [diff] [blame] | 231 | } else if (native_mode->hdisplay != 0 && |
| 232 | native_mode->vdisplay != 0) { |
| 233 | /* mac laptops without an edid */ |
| 234 | /* Note that this is not necessarily the exact panel mode, |
| 235 | * but an approximation based on the cvt formula. For these |
| 236 | * systems we should ideally read the mode info out of the |
| 237 | * registers or add a mode table, but this works and is much |
| 238 | * simpler. |
| 239 | */ |
| 240 | mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false); |
| 241 | mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 242 | DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode->name); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 243 | } |
| 244 | return mode; |
| 245 | } |
| 246 | |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 247 | static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_connector *connector) |
| 248 | { |
| 249 | struct drm_device *dev = encoder->dev; |
| 250 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 251 | struct drm_display_mode *mode = NULL; |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 252 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 253 | int i; |
| 254 | struct mode_size { |
| 255 | int w; |
| 256 | int h; |
| 257 | } common_modes[17] = { |
| 258 | { 640, 480}, |
| 259 | { 720, 480}, |
| 260 | { 800, 600}, |
| 261 | { 848, 480}, |
| 262 | {1024, 768}, |
| 263 | {1152, 768}, |
| 264 | {1280, 720}, |
| 265 | {1280, 800}, |
| 266 | {1280, 854}, |
| 267 | {1280, 960}, |
| 268 | {1280, 1024}, |
| 269 | {1440, 900}, |
| 270 | {1400, 1050}, |
| 271 | {1680, 1050}, |
| 272 | {1600, 1200}, |
| 273 | {1920, 1080}, |
| 274 | {1920, 1200} |
| 275 | }; |
| 276 | |
| 277 | for (i = 0; i < 17; i++) { |
Alex Deucher | dfdd646 | 2009-10-13 12:48:44 -0400 | [diff] [blame] | 278 | if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { |
| 279 | if (common_modes[i].w > 1024 || |
| 280 | common_modes[i].h > 768) |
| 281 | continue; |
| 282 | } |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 283 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 284 | if (common_modes[i].w > native_mode->hdisplay || |
| 285 | common_modes[i].h > native_mode->vdisplay || |
| 286 | (common_modes[i].w == native_mode->hdisplay && |
| 287 | common_modes[i].h == native_mode->vdisplay)) |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 288 | continue; |
| 289 | } |
| 290 | if (common_modes[i].w < 320 || common_modes[i].h < 200) |
| 291 | continue; |
| 292 | |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 293 | mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false); |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 294 | drm_mode_probed_add(connector, mode); |
| 295 | } |
| 296 | } |
| 297 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 298 | int radeon_connector_set_property(struct drm_connector *connector, struct drm_property *property, |
| 299 | uint64_t val) |
| 300 | { |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 301 | struct drm_device *dev = connector->dev; |
| 302 | struct radeon_device *rdev = dev->dev_private; |
| 303 | struct drm_encoder *encoder; |
| 304 | struct radeon_encoder *radeon_encoder; |
| 305 | |
| 306 | if (property == rdev->mode_info.coherent_mode_property) { |
| 307 | struct radeon_encoder_atom_dig *dig; |
Dave Airlie | ce227c4 | 2010-04-09 06:27:00 +0000 | [diff] [blame] | 308 | bool new_coherent_mode; |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 309 | |
| 310 | /* need to find digital encoder on connector */ |
| 311 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); |
| 312 | if (!encoder) |
| 313 | return 0; |
| 314 | |
| 315 | radeon_encoder = to_radeon_encoder(encoder); |
| 316 | |
| 317 | if (!radeon_encoder->enc_priv) |
| 318 | return 0; |
| 319 | |
| 320 | dig = radeon_encoder->enc_priv; |
Dave Airlie | ce227c4 | 2010-04-09 06:27:00 +0000 | [diff] [blame] | 321 | new_coherent_mode = val ? true : false; |
| 322 | if (dig->coherent_mode != new_coherent_mode) { |
| 323 | dig->coherent_mode = new_coherent_mode; |
| 324 | radeon_property_change_mode(&radeon_encoder->base); |
| 325 | } |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 326 | } |
| 327 | |
Alex Deucher | 5b1714d | 2010-08-03 19:59:20 -0400 | [diff] [blame] | 328 | if (property == rdev->mode_info.underscan_property) { |
| 329 | /* need to find digital encoder on connector */ |
| 330 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); |
| 331 | if (!encoder) |
| 332 | return 0; |
| 333 | |
| 334 | radeon_encoder = to_radeon_encoder(encoder); |
| 335 | |
| 336 | if (radeon_encoder->underscan_type != val) { |
| 337 | radeon_encoder->underscan_type = val; |
| 338 | radeon_property_change_mode(&radeon_encoder->base); |
| 339 | } |
| 340 | } |
| 341 | |
Marius Gröger | 5bccf5e | 2010-09-21 21:30:59 +0200 | [diff] [blame] | 342 | if (property == rdev->mode_info.underscan_hborder_property) { |
| 343 | /* need to find digital encoder on connector */ |
| 344 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); |
| 345 | if (!encoder) |
| 346 | return 0; |
| 347 | |
| 348 | radeon_encoder = to_radeon_encoder(encoder); |
| 349 | |
| 350 | if (radeon_encoder->underscan_hborder != val) { |
| 351 | radeon_encoder->underscan_hborder = val; |
| 352 | radeon_property_change_mode(&radeon_encoder->base); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | if (property == rdev->mode_info.underscan_vborder_property) { |
| 357 | /* need to find digital encoder on connector */ |
| 358 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); |
| 359 | if (!encoder) |
| 360 | return 0; |
| 361 | |
| 362 | radeon_encoder = to_radeon_encoder(encoder); |
| 363 | |
| 364 | if (radeon_encoder->underscan_vborder != val) { |
| 365 | radeon_encoder->underscan_vborder = val; |
| 366 | radeon_property_change_mode(&radeon_encoder->base); |
| 367 | } |
| 368 | } |
| 369 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 370 | if (property == rdev->mode_info.tv_std_property) { |
| 371 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC); |
| 372 | if (!encoder) { |
| 373 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_DAC); |
| 374 | } |
| 375 | |
| 376 | if (!encoder) |
| 377 | return 0; |
| 378 | |
| 379 | radeon_encoder = to_radeon_encoder(encoder); |
| 380 | if (!radeon_encoder->enc_priv) |
| 381 | return 0; |
Alex Deucher | 643acac | 2010-04-05 23:57:52 -0400 | [diff] [blame] | 382 | if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom) { |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 383 | struct radeon_encoder_atom_dac *dac_int; |
| 384 | dac_int = radeon_encoder->enc_priv; |
| 385 | dac_int->tv_std = val; |
| 386 | } else { |
| 387 | struct radeon_encoder_tv_dac *dac_int; |
| 388 | dac_int = radeon_encoder->enc_priv; |
| 389 | dac_int->tv_std = val; |
| 390 | } |
| 391 | radeon_property_change_mode(&radeon_encoder->base); |
| 392 | } |
| 393 | |
| 394 | if (property == rdev->mode_info.load_detect_property) { |
| 395 | struct radeon_connector *radeon_connector = |
| 396 | to_radeon_connector(connector); |
| 397 | |
| 398 | if (val == 0) |
| 399 | radeon_connector->dac_load_detect = false; |
| 400 | else |
| 401 | radeon_connector->dac_load_detect = true; |
| 402 | } |
| 403 | |
| 404 | if (property == rdev->mode_info.tmds_pll_property) { |
| 405 | struct radeon_encoder_int_tmds *tmds = NULL; |
| 406 | bool ret = false; |
| 407 | /* need to find digital encoder on connector */ |
| 408 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); |
| 409 | if (!encoder) |
| 410 | return 0; |
| 411 | |
| 412 | radeon_encoder = to_radeon_encoder(encoder); |
| 413 | |
| 414 | tmds = radeon_encoder->enc_priv; |
| 415 | if (!tmds) |
| 416 | return 0; |
| 417 | |
| 418 | if (val == 0) { |
| 419 | if (rdev->is_atom_bios) |
| 420 | ret = radeon_atombios_get_tmds_info(radeon_encoder, tmds); |
| 421 | else |
| 422 | ret = radeon_legacy_get_tmds_info_from_combios(radeon_encoder, tmds); |
| 423 | } |
| 424 | if (val == 1 || ret == false) { |
| 425 | radeon_legacy_get_tmds_info_from_table(radeon_encoder, tmds); |
| 426 | } |
| 427 | radeon_property_change_mode(&radeon_encoder->base); |
| 428 | } |
| 429 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 430 | return 0; |
| 431 | } |
| 432 | |
Michel Dänzer | 8dfaa8a | 2009-09-15 17:09:27 +0200 | [diff] [blame] | 433 | static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder, |
| 434 | struct drm_connector *connector) |
| 435 | { |
| 436 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 437 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
Matthew Garrett | 13bb943 | 2011-08-08 16:21:15 +0000 | [diff] [blame] | 438 | struct drm_display_mode *t, *mode; |
| 439 | |
| 440 | /* If the EDID preferred mode doesn't match the native mode, use it */ |
| 441 | list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { |
| 442 | if (mode->type & DRM_MODE_TYPE_PREFERRED) { |
| 443 | if (mode->hdisplay != native_mode->hdisplay || |
| 444 | mode->vdisplay != native_mode->vdisplay) |
| 445 | memcpy(native_mode, mode, sizeof(*mode)); |
| 446 | } |
| 447 | } |
Michel Dänzer | 8dfaa8a | 2009-09-15 17:09:27 +0200 | [diff] [blame] | 448 | |
| 449 | /* Try to get native mode details from EDID if necessary */ |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 450 | if (!native_mode->clock) { |
Michel Dänzer | 8dfaa8a | 2009-09-15 17:09:27 +0200 | [diff] [blame] | 451 | list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 452 | if (mode->hdisplay == native_mode->hdisplay && |
| 453 | mode->vdisplay == native_mode->vdisplay) { |
| 454 | *native_mode = *mode; |
| 455 | drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V); |
Alex Deucher | c5d46b4 | 2010-10-29 13:49:25 -0400 | [diff] [blame] | 456 | DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n"); |
Michel Dänzer | 8dfaa8a | 2009-09-15 17:09:27 +0200 | [diff] [blame] | 457 | break; |
| 458 | } |
| 459 | } |
| 460 | } |
Matthew Garrett | 13bb943 | 2011-08-08 16:21:15 +0000 | [diff] [blame] | 461 | |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 462 | if (!native_mode->clock) { |
Alex Deucher | c5d46b4 | 2010-10-29 13:49:25 -0400 | [diff] [blame] | 463 | DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n"); |
Michel Dänzer | 8dfaa8a | 2009-09-15 17:09:27 +0200 | [diff] [blame] | 464 | radeon_encoder->rmx_type = RMX_OFF; |
| 465 | } |
| 466 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 467 | |
| 468 | static int radeon_lvds_get_modes(struct drm_connector *connector) |
| 469 | { |
| 470 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 471 | struct drm_encoder *encoder; |
| 472 | int ret = 0; |
| 473 | struct drm_display_mode *mode; |
| 474 | |
| 475 | if (radeon_connector->ddc_bus) { |
| 476 | ret = radeon_ddc_get_modes(radeon_connector); |
| 477 | if (ret > 0) { |
Alex Deucher | 7747b71 | 2009-09-11 11:15:43 -0400 | [diff] [blame] | 478 | encoder = radeon_best_single_encoder(connector); |
Michel Dänzer | 8dfaa8a | 2009-09-15 17:09:27 +0200 | [diff] [blame] | 479 | if (encoder) { |
| 480 | radeon_fixup_lvds_native_mode(encoder, connector); |
Alex Deucher | 7747b71 | 2009-09-11 11:15:43 -0400 | [diff] [blame] | 481 | /* add scaled modes */ |
| 482 | radeon_add_common_modes(encoder, connector); |
Michel Dänzer | 8dfaa8a | 2009-09-15 17:09:27 +0200 | [diff] [blame] | 483 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 484 | return ret; |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | encoder = radeon_best_single_encoder(connector); |
| 489 | if (!encoder) |
| 490 | return 0; |
| 491 | |
| 492 | /* we have no EDID modes */ |
| 493 | mode = radeon_fp_native_mode(encoder); |
| 494 | if (mode) { |
| 495 | ret = 1; |
| 496 | drm_mode_probed_add(connector, mode); |
Alex Deucher | 7a868e1 | 2010-12-08 22:13:05 -0500 | [diff] [blame] | 497 | /* add the width/height from vbios tables if available */ |
| 498 | connector->display_info.width_mm = mode->width_mm; |
| 499 | connector->display_info.height_mm = mode->height_mm; |
Alex Deucher | 7747b71 | 2009-09-11 11:15:43 -0400 | [diff] [blame] | 500 | /* add scaled modes */ |
| 501 | radeon_add_common_modes(encoder, connector); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 502 | } |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 503 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 504 | return ret; |
| 505 | } |
| 506 | |
| 507 | static int radeon_lvds_mode_valid(struct drm_connector *connector, |
| 508 | struct drm_display_mode *mode) |
| 509 | { |
Alex Deucher | a3fa632 | 2009-11-05 11:57:07 -0500 | [diff] [blame] | 510 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
| 511 | |
| 512 | if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) |
| 513 | return MODE_PANEL; |
| 514 | |
| 515 | if (encoder) { |
| 516 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 517 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
| 518 | |
| 519 | /* AVIVO hardware supports downscaling modes larger than the panel |
| 520 | * to the panel size, but I'm not sure this is desirable. |
| 521 | */ |
| 522 | if ((mode->hdisplay > native_mode->hdisplay) || |
| 523 | (mode->vdisplay > native_mode->vdisplay)) |
| 524 | return MODE_PANEL; |
| 525 | |
| 526 | /* if scaling is disabled, block non-native modes */ |
| 527 | if (radeon_encoder->rmx_type == RMX_OFF) { |
| 528 | if ((mode->hdisplay != native_mode->hdisplay) || |
| 529 | (mode->vdisplay != native_mode->vdisplay)) |
| 530 | return MODE_PANEL; |
| 531 | } |
| 532 | } |
| 533 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 534 | return MODE_OK; |
| 535 | } |
| 536 | |
Chris Wilson | 7b334fc | 2010-09-09 23:51:02 +0100 | [diff] [blame] | 537 | static enum drm_connector_status |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 538 | radeon_lvds_detect(struct drm_connector *connector, bool force) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 539 | { |
Alex Deucher | 0549a061 | 2009-10-09 18:41:19 -0400 | [diff] [blame] | 540 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
Alex Deucher | 2ffb842 | 2009-10-08 13:02:19 -0400 | [diff] [blame] | 541 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
Alex Deucher | 0549a061 | 2009-10-09 18:41:19 -0400 | [diff] [blame] | 542 | enum drm_connector_status ret = connector_status_disconnected; |
Alex Deucher | 2ffb842 | 2009-10-08 13:02:19 -0400 | [diff] [blame] | 543 | |
| 544 | if (encoder) { |
| 545 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 546 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
Alex Deucher | 2ffb842 | 2009-10-08 13:02:19 -0400 | [diff] [blame] | 547 | |
| 548 | /* check if panel is valid */ |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 549 | if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) |
Alex Deucher | 2ffb842 | 2009-10-08 13:02:19 -0400 | [diff] [blame] | 550 | ret = connector_status_connected; |
| 551 | |
| 552 | } |
Alex Deucher | 0549a061 | 2009-10-09 18:41:19 -0400 | [diff] [blame] | 553 | |
| 554 | /* check for edid as well */ |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 555 | if (radeon_connector->edid) |
| 556 | ret = connector_status_connected; |
| 557 | else { |
| 558 | if (radeon_connector->ddc_bus) { |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 559 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, |
| 560 | &radeon_connector->ddc_bus->adapter); |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 561 | if (radeon_connector->edid) |
| 562 | ret = connector_status_connected; |
| 563 | } |
Alex Deucher | 0549a061 | 2009-10-09 18:41:19 -0400 | [diff] [blame] | 564 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 565 | /* check acpi lid status ??? */ |
Alex Deucher | 2ffb842 | 2009-10-08 13:02:19 -0400 | [diff] [blame] | 566 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 567 | radeon_connector_update_scratch_regs(connector, ret); |
| 568 | return ret; |
| 569 | } |
| 570 | |
| 571 | static void radeon_connector_destroy(struct drm_connector *connector) |
| 572 | { |
| 573 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 574 | |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 575 | if (radeon_connector->edid) |
| 576 | kfree(radeon_connector->edid); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 577 | kfree(radeon_connector->con_priv); |
| 578 | drm_sysfs_connector_remove(connector); |
| 579 | drm_connector_cleanup(connector); |
| 580 | kfree(connector); |
| 581 | } |
| 582 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 583 | static int radeon_lvds_set_property(struct drm_connector *connector, |
| 584 | struct drm_property *property, |
| 585 | uint64_t value) |
| 586 | { |
| 587 | struct drm_device *dev = connector->dev; |
| 588 | struct radeon_encoder *radeon_encoder; |
| 589 | enum radeon_rmx_type rmx_type; |
| 590 | |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 591 | DRM_DEBUG_KMS("\n"); |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 592 | if (property != dev->mode_config.scaling_mode_property) |
| 593 | return 0; |
| 594 | |
| 595 | if (connector->encoder) |
| 596 | radeon_encoder = to_radeon_encoder(connector->encoder); |
| 597 | else { |
| 598 | struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; |
| 599 | radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); |
| 600 | } |
| 601 | |
| 602 | switch (value) { |
| 603 | case DRM_MODE_SCALE_NONE: rmx_type = RMX_OFF; break; |
| 604 | case DRM_MODE_SCALE_CENTER: rmx_type = RMX_CENTER; break; |
| 605 | case DRM_MODE_SCALE_ASPECT: rmx_type = RMX_ASPECT; break; |
| 606 | default: |
| 607 | case DRM_MODE_SCALE_FULLSCREEN: rmx_type = RMX_FULL; break; |
| 608 | } |
| 609 | if (radeon_encoder->rmx_type == rmx_type) |
| 610 | return 0; |
| 611 | |
| 612 | radeon_encoder->rmx_type = rmx_type; |
| 613 | |
| 614 | radeon_property_change_mode(&radeon_encoder->base); |
| 615 | return 0; |
| 616 | } |
| 617 | |
| 618 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 619 | struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs = { |
| 620 | .get_modes = radeon_lvds_get_modes, |
| 621 | .mode_valid = radeon_lvds_mode_valid, |
| 622 | .best_encoder = radeon_best_single_encoder, |
| 623 | }; |
| 624 | |
| 625 | struct drm_connector_funcs radeon_lvds_connector_funcs = { |
| 626 | .dpms = drm_helper_connector_dpms, |
| 627 | .detect = radeon_lvds_detect, |
| 628 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 629 | .destroy = radeon_connector_destroy, |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 630 | .set_property = radeon_lvds_set_property, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 631 | }; |
| 632 | |
| 633 | static int radeon_vga_get_modes(struct drm_connector *connector) |
| 634 | { |
| 635 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 636 | int ret; |
| 637 | |
| 638 | ret = radeon_ddc_get_modes(radeon_connector); |
| 639 | |
| 640 | return ret; |
| 641 | } |
| 642 | |
| 643 | static int radeon_vga_mode_valid(struct drm_connector *connector, |
| 644 | struct drm_display_mode *mode) |
| 645 | { |
Alex Deucher | b20f9be | 2011-06-08 13:01:11 -0400 | [diff] [blame] | 646 | struct drm_device *dev = connector->dev; |
| 647 | struct radeon_device *rdev = dev->dev_private; |
| 648 | |
Alex Deucher | a3fa632 | 2009-11-05 11:57:07 -0500 | [diff] [blame] | 649 | /* XXX check mode bandwidth */ |
Alex Deucher | b20f9be | 2011-06-08 13:01:11 -0400 | [diff] [blame] | 650 | |
| 651 | if ((mode->clock / 10) > rdev->clock.max_pixel_clock) |
| 652 | return MODE_CLOCK_HIGH; |
| 653 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 654 | return MODE_OK; |
| 655 | } |
| 656 | |
Chris Wilson | 7b334fc | 2010-09-09 23:51:02 +0100 | [diff] [blame] | 657 | static enum drm_connector_status |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 658 | radeon_vga_detect(struct drm_connector *connector, bool force) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 659 | { |
Alex Deucher | fafcf94 | 2011-03-23 08:10:10 +0000 | [diff] [blame] | 660 | struct drm_device *dev = connector->dev; |
| 661 | struct radeon_device *rdev = dev->dev_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 662 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 663 | struct drm_encoder *encoder; |
| 664 | struct drm_encoder_helper_funcs *encoder_funcs; |
Dave Airlie | 4b9d2a2 | 2010-02-08 13:16:55 +1000 | [diff] [blame] | 665 | bool dret = false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 666 | enum drm_connector_status ret = connector_status_disconnected; |
| 667 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 668 | encoder = radeon_best_single_encoder(connector); |
| 669 | if (!encoder) |
| 670 | ret = connector_status_disconnected; |
| 671 | |
Dave Airlie | eb6b6d7 | 2010-02-25 13:44:04 +1000 | [diff] [blame] | 672 | if (radeon_connector->ddc_bus) |
Alex Deucher | bc1c4dc | 2011-10-30 16:54:27 -0400 | [diff] [blame] | 673 | dret = radeon_ddc_probe(radeon_connector); |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 674 | if (dret) { |
Alex Deucher | d0d0a22 | 2011-10-07 14:23:48 -0400 | [diff] [blame] | 675 | radeon_connector->detected_by_load = false; |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 676 | if (radeon_connector->edid) { |
| 677 | kfree(radeon_connector->edid); |
| 678 | radeon_connector->edid = NULL; |
| 679 | } |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 680 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 681 | |
| 682 | if (!radeon_connector->edid) { |
Jerome Glisse | f82f5f3 | 2009-11-12 14:13:53 +0100 | [diff] [blame] | 683 | DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", |
| 684 | drm_get_connector_name(connector)); |
| 685 | ret = connector_status_connected; |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 686 | } else { |
| 687 | radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); |
| 688 | |
| 689 | /* some oems have boards with separate digital and analog connectors |
| 690 | * with a shared ddc line (often vga + hdmi) |
| 691 | */ |
| 692 | if (radeon_connector->use_digital && radeon_connector->shared_ddc) { |
| 693 | kfree(radeon_connector->edid); |
| 694 | radeon_connector->edid = NULL; |
| 695 | ret = connector_status_disconnected; |
| 696 | } else |
| 697 | ret = connector_status_connected; |
| 698 | } |
| 699 | } else { |
Dave Airlie | c3cceed | 2010-10-26 12:55:52 +1000 | [diff] [blame] | 700 | |
| 701 | /* if we aren't forcing don't do destructive polling */ |
Alex Deucher | d0d0a22 | 2011-10-07 14:23:48 -0400 | [diff] [blame] | 702 | if (!force) { |
| 703 | /* only return the previous status if we last |
| 704 | * detected a monitor via load. |
| 705 | */ |
| 706 | if (radeon_connector->detected_by_load) |
| 707 | return connector->status; |
| 708 | else |
| 709 | return ret; |
| 710 | } |
Dave Airlie | c3cceed | 2010-10-26 12:55:52 +1000 | [diff] [blame] | 711 | |
Darren Jenkins | d8a7f79 | 2009-12-30 12:22:55 +1100 | [diff] [blame] | 712 | if (radeon_connector->dac_load_detect && encoder) { |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 713 | encoder_funcs = encoder->helper_private; |
| 714 | ret = encoder_funcs->detect(encoder, connector); |
Jerome Glisse | 3407644 | 2011-10-24 18:16:34 -0400 | [diff] [blame] | 715 | if (ret != connector_status_disconnected) |
Alex Deucher | d0d0a22 | 2011-10-07 14:23:48 -0400 | [diff] [blame] | 716 | radeon_connector->detected_by_load = true; |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 717 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 718 | } |
| 719 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 720 | if (ret == connector_status_connected) |
| 721 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); |
Alex Deucher | fafcf94 | 2011-03-23 08:10:10 +0000 | [diff] [blame] | 722 | |
| 723 | /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the |
| 724 | * vbios to deal with KVMs. If we have one and are not able to detect a monitor |
| 725 | * by other means, assume the CRT is connected and use that EDID. |
| 726 | */ |
| 727 | if ((!rdev->is_atom_bios) && |
| 728 | (ret == connector_status_disconnected) && |
| 729 | rdev->mode_info.bios_hardcoded_edid_size) { |
| 730 | ret = connector_status_connected; |
| 731 | } |
| 732 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 733 | radeon_connector_update_scratch_regs(connector, ret); |
| 734 | return ret; |
| 735 | } |
| 736 | |
| 737 | struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs = { |
| 738 | .get_modes = radeon_vga_get_modes, |
| 739 | .mode_valid = radeon_vga_mode_valid, |
| 740 | .best_encoder = radeon_best_single_encoder, |
| 741 | }; |
| 742 | |
| 743 | struct drm_connector_funcs radeon_vga_connector_funcs = { |
| 744 | .dpms = drm_helper_connector_dpms, |
| 745 | .detect = radeon_vga_detect, |
| 746 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 747 | .destroy = radeon_connector_destroy, |
| 748 | .set_property = radeon_connector_set_property, |
| 749 | }; |
| 750 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 751 | static int radeon_tv_get_modes(struct drm_connector *connector) |
| 752 | { |
| 753 | struct drm_device *dev = connector->dev; |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 754 | struct radeon_device *rdev = dev->dev_private; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 755 | struct drm_display_mode *tv_mode; |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 756 | struct drm_encoder *encoder; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 757 | |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 758 | encoder = radeon_best_single_encoder(connector); |
| 759 | if (!encoder) |
| 760 | return 0; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 761 | |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 762 | /* avivo chips can scale any mode */ |
| 763 | if (rdev->family >= CHIP_RS600) |
| 764 | /* add scaled modes */ |
| 765 | radeon_add_common_modes(encoder, connector); |
| 766 | else { |
| 767 | /* only 800x600 is supported right now on pre-avivo chips */ |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 768 | tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false); |
Alex Deucher | 923f684 | 2009-09-10 17:53:39 -0400 | [diff] [blame] | 769 | tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; |
| 770 | drm_mode_probed_add(connector, tv_mode); |
| 771 | } |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 772 | return 1; |
| 773 | } |
| 774 | |
| 775 | static int radeon_tv_mode_valid(struct drm_connector *connector, |
| 776 | struct drm_display_mode *mode) |
| 777 | { |
Alex Deucher | a3fa632 | 2009-11-05 11:57:07 -0500 | [diff] [blame] | 778 | if ((mode->hdisplay > 1024) || (mode->vdisplay > 768)) |
| 779 | return MODE_CLOCK_RANGE; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 780 | return MODE_OK; |
| 781 | } |
| 782 | |
Chris Wilson | 7b334fc | 2010-09-09 23:51:02 +0100 | [diff] [blame] | 783 | static enum drm_connector_status |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 784 | radeon_tv_detect(struct drm_connector *connector, bool force) |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 785 | { |
| 786 | struct drm_encoder *encoder; |
| 787 | struct drm_encoder_helper_funcs *encoder_funcs; |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 788 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 789 | enum drm_connector_status ret = connector_status_disconnected; |
| 790 | |
| 791 | if (!radeon_connector->dac_load_detect) |
| 792 | return ret; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 793 | |
| 794 | encoder = radeon_best_single_encoder(connector); |
| 795 | if (!encoder) |
| 796 | ret = connector_status_disconnected; |
| 797 | else { |
| 798 | encoder_funcs = encoder->helper_private; |
| 799 | ret = encoder_funcs->detect(encoder, connector); |
| 800 | } |
| 801 | if (ret == connector_status_connected) |
| 802 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false); |
| 803 | radeon_connector_update_scratch_regs(connector, ret); |
| 804 | return ret; |
| 805 | } |
| 806 | |
| 807 | struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs = { |
| 808 | .get_modes = radeon_tv_get_modes, |
| 809 | .mode_valid = radeon_tv_mode_valid, |
| 810 | .best_encoder = radeon_best_single_encoder, |
| 811 | }; |
| 812 | |
| 813 | struct drm_connector_funcs radeon_tv_connector_funcs = { |
| 814 | .dpms = drm_helper_connector_dpms, |
| 815 | .detect = radeon_tv_detect, |
| 816 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 817 | .destroy = radeon_connector_destroy, |
| 818 | .set_property = radeon_connector_set_property, |
| 819 | }; |
| 820 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 821 | static int radeon_dvi_get_modes(struct drm_connector *connector) |
| 822 | { |
| 823 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 824 | int ret; |
| 825 | |
| 826 | ret = radeon_ddc_get_modes(radeon_connector); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 827 | return ret; |
| 828 | } |
| 829 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 830 | /* |
| 831 | * DVI is complicated |
| 832 | * Do a DDC probe, if DDC probe passes, get the full EDID so |
| 833 | * we can do analog/digital monitor detection at this point. |
| 834 | * If the monitor is an analog monitor or we got no DDC, |
| 835 | * we need to find the DAC encoder object for this connector. |
| 836 | * If we got no DDC, we do load detection on the DAC encoder object. |
| 837 | * If we got analog DDC or load detection passes on the DAC encoder |
| 838 | * we have to check if this analog encoder is shared with anyone else (TV) |
| 839 | * if its shared we have to set the other connector to disconnected. |
| 840 | */ |
Chris Wilson | 7b334fc | 2010-09-09 23:51:02 +0100 | [diff] [blame] | 841 | static enum drm_connector_status |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 842 | radeon_dvi_detect(struct drm_connector *connector, bool force) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 843 | { |
Alex Deucher | fafcf94 | 2011-03-23 08:10:10 +0000 | [diff] [blame] | 844 | struct drm_device *dev = connector->dev; |
| 845 | struct radeon_device *rdev = dev->dev_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 846 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 847 | struct drm_encoder *encoder = NULL; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 848 | struct drm_encoder_helper_funcs *encoder_funcs; |
| 849 | struct drm_mode_object *obj; |
| 850 | int i; |
| 851 | enum drm_connector_status ret = connector_status_disconnected; |
Dave Airlie | 4b9d2a2 | 2010-02-08 13:16:55 +1000 | [diff] [blame] | 852 | bool dret = false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 853 | |
Dave Airlie | eb6b6d7 | 2010-02-25 13:44:04 +1000 | [diff] [blame] | 854 | if (radeon_connector->ddc_bus) |
Alex Deucher | bc1c4dc | 2011-10-30 16:54:27 -0400 | [diff] [blame] | 855 | dret = radeon_ddc_probe(radeon_connector); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 856 | if (dret) { |
Alex Deucher | d0d0a22 | 2011-10-07 14:23:48 -0400 | [diff] [blame] | 857 | radeon_connector->detected_by_load = false; |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 858 | if (radeon_connector->edid) { |
| 859 | kfree(radeon_connector->edid); |
| 860 | radeon_connector->edid = NULL; |
| 861 | } |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 862 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 863 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 864 | if (!radeon_connector->edid) { |
Jerome Glisse | f82f5f3 | 2009-11-12 14:13:53 +0100 | [diff] [blame] | 865 | DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", |
| 866 | drm_get_connector_name(connector)); |
Dave Airlie | 4a9a8b7 | 2011-06-14 06:13:55 +0000 | [diff] [blame] | 867 | /* rs690 seems to have a problem with connectors not existing and always |
| 868 | * return a block of 0's. If we see this just stop polling on this output */ |
| 869 | if ((rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) && radeon_connector->base.null_edid_counter) { |
| 870 | ret = connector_status_disconnected; |
| 871 | DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", drm_get_connector_name(connector)); |
| 872 | radeon_connector->ddc_bus = NULL; |
| 873 | } |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 874 | } else { |
| 875 | radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 876 | |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 877 | /* some oems have boards with separate digital and analog connectors |
| 878 | * with a shared ddc line (often vga + hdmi) |
| 879 | */ |
| 880 | if ((!radeon_connector->use_digital) && radeon_connector->shared_ddc) { |
| 881 | kfree(radeon_connector->edid); |
| 882 | radeon_connector->edid = NULL; |
| 883 | ret = connector_status_disconnected; |
| 884 | } else |
| 885 | ret = connector_status_connected; |
Alex Deucher | 71407c4 | 2009-11-17 15:44:01 -0500 | [diff] [blame] | 886 | |
Alex Deucher | 42f14c4 | 2010-07-20 11:27:54 -0400 | [diff] [blame] | 887 | /* This gets complicated. We have boards with VGA + HDMI with a |
| 888 | * shared DDC line and we have boards with DVI-D + HDMI with a shared |
| 889 | * DDC line. The latter is more complex because with DVI<->HDMI adapters |
| 890 | * you don't really know what's connected to which port as both are digital. |
Alex Deucher | 71407c4 | 2009-11-17 15:44:01 -0500 | [diff] [blame] | 891 | */ |
Alex Deucher | d3932d6 | 2010-02-19 02:13:56 -0500 | [diff] [blame] | 892 | if (radeon_connector->shared_ddc && (ret == connector_status_connected)) { |
Alex Deucher | 71407c4 | 2009-11-17 15:44:01 -0500 | [diff] [blame] | 893 | struct drm_connector *list_connector; |
| 894 | struct radeon_connector *list_radeon_connector; |
| 895 | list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) { |
| 896 | if (connector == list_connector) |
| 897 | continue; |
| 898 | list_radeon_connector = to_radeon_connector(list_connector); |
Alex Deucher | b2ea4aa | 2010-07-01 10:34:56 -0400 | [diff] [blame] | 899 | if (list_radeon_connector->shared_ddc && |
| 900 | (list_radeon_connector->ddc_bus->rec.i2c_id == |
| 901 | radeon_connector->ddc_bus->rec.i2c_id)) { |
Alex Deucher | 42f14c4 | 2010-07-20 11:27:54 -0400 | [diff] [blame] | 902 | /* cases where both connectors are digital */ |
| 903 | if (list_connector->connector_type != DRM_MODE_CONNECTOR_VGA) { |
| 904 | /* hpd is our only option in this case */ |
| 905 | if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { |
Alex Deucher | 71407c4 | 2009-11-17 15:44:01 -0500 | [diff] [blame] | 906 | kfree(radeon_connector->edid); |
| 907 | radeon_connector->edid = NULL; |
| 908 | ret = connector_status_disconnected; |
| 909 | } |
| 910 | } |
| 911 | } |
| 912 | } |
| 913 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 914 | } |
| 915 | } |
| 916 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 917 | if ((ret == connector_status_connected) && (radeon_connector->use_digital == true)) |
| 918 | goto out; |
| 919 | |
Alex Deucher | 5f0a261 | 2011-10-07 14:23:47 -0400 | [diff] [blame] | 920 | /* DVI-D and HDMI-A are digital only */ |
| 921 | if ((connector->connector_type == DRM_MODE_CONNECTOR_DVID) || |
| 922 | (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA)) |
| 923 | goto out; |
| 924 | |
Alex Deucher | d0d0a22 | 2011-10-07 14:23:48 -0400 | [diff] [blame] | 925 | /* if we aren't forcing don't do destructive polling */ |
Dave Airlie | c3cceed | 2010-10-26 12:55:52 +1000 | [diff] [blame] | 926 | if (!force) { |
Alex Deucher | d0d0a22 | 2011-10-07 14:23:48 -0400 | [diff] [blame] | 927 | /* only return the previous status if we last |
| 928 | * detected a monitor via load. |
| 929 | */ |
| 930 | if (radeon_connector->detected_by_load) |
| 931 | ret = connector->status; |
Dave Airlie | c3cceed | 2010-10-26 12:55:52 +1000 | [diff] [blame] | 932 | goto out; |
| 933 | } |
| 934 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 935 | /* find analog encoder */ |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 936 | if (radeon_connector->dac_load_detect) { |
| 937 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
| 938 | if (connector->encoder_ids[i] == 0) |
| 939 | break; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 940 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 941 | obj = drm_mode_object_find(connector->dev, |
| 942 | connector->encoder_ids[i], |
| 943 | DRM_MODE_OBJECT_ENCODER); |
| 944 | if (!obj) |
| 945 | continue; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 946 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 947 | encoder = obj_to_encoder(obj); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 948 | |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 949 | encoder_funcs = encoder->helper_private; |
| 950 | if (encoder_funcs->detect) { |
| 951 | if (ret != connector_status_connected) { |
| 952 | ret = encoder_funcs->detect(encoder, connector); |
| 953 | if (ret == connector_status_connected) { |
| 954 | radeon_connector->use_digital = false; |
| 955 | } |
Jerome Glisse | 3407644 | 2011-10-24 18:16:34 -0400 | [diff] [blame] | 956 | if (ret != connector_status_disconnected) |
| 957 | radeon_connector->detected_by_load = true; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 958 | } |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 959 | break; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 960 | } |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 961 | } |
| 962 | } |
| 963 | |
| 964 | if ((ret == connector_status_connected) && (radeon_connector->use_digital == false) && |
| 965 | encoder) { |
| 966 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); |
| 967 | } |
| 968 | |
Alex Deucher | fafcf94 | 2011-03-23 08:10:10 +0000 | [diff] [blame] | 969 | /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the |
| 970 | * vbios to deal with KVMs. If we have one and are not able to detect a monitor |
| 971 | * by other means, assume the DFP is connected and use that EDID. In most |
| 972 | * cases the DVI port is actually a virtual KVM port connected to the service |
| 973 | * processor. |
| 974 | */ |
| 975 | if ((!rdev->is_atom_bios) && |
| 976 | (ret == connector_status_disconnected) && |
| 977 | rdev->mode_info.bios_hardcoded_edid_size) { |
| 978 | radeon_connector->use_digital = true; |
| 979 | ret = connector_status_connected; |
| 980 | } |
| 981 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 982 | out: |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 983 | /* updated in get modes as well since we need to know if it's analog or digital */ |
| 984 | radeon_connector_update_scratch_regs(connector, ret); |
| 985 | return ret; |
| 986 | } |
| 987 | |
| 988 | /* okay need to be smart in here about which encoder to pick */ |
| 989 | struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector) |
| 990 | { |
| 991 | int enc_id = connector->encoder_ids[0]; |
| 992 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 993 | struct drm_mode_object *obj; |
| 994 | struct drm_encoder *encoder; |
| 995 | int i; |
| 996 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
| 997 | if (connector->encoder_ids[i] == 0) |
| 998 | break; |
| 999 | |
| 1000 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); |
| 1001 | if (!obj) |
| 1002 | continue; |
| 1003 | |
| 1004 | encoder = obj_to_encoder(obj); |
| 1005 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1006 | if (radeon_connector->use_digital == true) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1007 | if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) |
| 1008 | return encoder; |
| 1009 | } else { |
| 1010 | if (encoder->encoder_type == DRM_MODE_ENCODER_DAC || |
| 1011 | encoder->encoder_type == DRM_MODE_ENCODER_TVDAC) |
| 1012 | return encoder; |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | /* see if we have a default encoder TODO */ |
| 1017 | |
| 1018 | /* then check use digitial */ |
| 1019 | /* pick the first one */ |
| 1020 | if (enc_id) { |
| 1021 | obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); |
| 1022 | if (!obj) |
| 1023 | return NULL; |
| 1024 | encoder = obj_to_encoder(obj); |
| 1025 | return encoder; |
| 1026 | } |
| 1027 | return NULL; |
| 1028 | } |
| 1029 | |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 1030 | static void radeon_dvi_force(struct drm_connector *connector) |
| 1031 | { |
| 1032 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 1033 | if (connector->force == DRM_FORCE_ON) |
| 1034 | radeon_connector->use_digital = false; |
| 1035 | if (connector->force == DRM_FORCE_ON_DIGITAL) |
| 1036 | radeon_connector->use_digital = true; |
| 1037 | } |
| 1038 | |
Alex Deucher | a3fa632 | 2009-11-05 11:57:07 -0500 | [diff] [blame] | 1039 | static int radeon_dvi_mode_valid(struct drm_connector *connector, |
| 1040 | struct drm_display_mode *mode) |
| 1041 | { |
Alex Deucher | 1b24203 | 2010-01-11 15:02:31 -0500 | [diff] [blame] | 1042 | struct drm_device *dev = connector->dev; |
| 1043 | struct radeon_device *rdev = dev->dev_private; |
Alex Deucher | a3fa632 | 2009-11-05 11:57:07 -0500 | [diff] [blame] | 1044 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 1045 | |
| 1046 | /* XXX check mode bandwidth */ |
| 1047 | |
Alex Deucher | 1b24203 | 2010-01-11 15:02:31 -0500 | [diff] [blame] | 1048 | /* clocks over 135 MHz have heat issues with DVI on RV100 */ |
| 1049 | if (radeon_connector->use_digital && |
| 1050 | (rdev->family == CHIP_RV100) && |
| 1051 | (mode->clock > 135000)) |
| 1052 | return MODE_CLOCK_HIGH; |
| 1053 | |
Alex Deucher | a3fa632 | 2009-11-05 11:57:07 -0500 | [diff] [blame] | 1054 | if (radeon_connector->use_digital && (mode->clock > 165000)) { |
| 1055 | if ((radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I) || |
| 1056 | (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) || |
| 1057 | (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B)) |
| 1058 | return MODE_OK; |
Alex Deucher | e1e8401 | 2011-03-02 10:21:05 -0500 | [diff] [blame] | 1059 | else if (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_A) { |
| 1060 | if (ASIC_IS_DCE3(rdev)) { |
| 1061 | /* HDMI 1.3+ supports max clock of 340 Mhz */ |
| 1062 | if (mode->clock > 340000) |
| 1063 | return MODE_CLOCK_HIGH; |
| 1064 | else |
| 1065 | return MODE_OK; |
| 1066 | } else |
| 1067 | return MODE_CLOCK_HIGH; |
| 1068 | } else |
Alex Deucher | a3fa632 | 2009-11-05 11:57:07 -0500 | [diff] [blame] | 1069 | return MODE_CLOCK_HIGH; |
| 1070 | } |
Alex Deucher | b20f9be | 2011-06-08 13:01:11 -0400 | [diff] [blame] | 1071 | |
| 1072 | /* check against the max pixel clock */ |
| 1073 | if ((mode->clock / 10) > rdev->clock.max_pixel_clock) |
| 1074 | return MODE_CLOCK_HIGH; |
| 1075 | |
Alex Deucher | a3fa632 | 2009-11-05 11:57:07 -0500 | [diff] [blame] | 1076 | return MODE_OK; |
| 1077 | } |
| 1078 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1079 | struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = { |
| 1080 | .get_modes = radeon_dvi_get_modes, |
Alex Deucher | a3fa632 | 2009-11-05 11:57:07 -0500 | [diff] [blame] | 1081 | .mode_valid = radeon_dvi_mode_valid, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1082 | .best_encoder = radeon_dvi_encoder, |
| 1083 | }; |
| 1084 | |
| 1085 | struct drm_connector_funcs radeon_dvi_connector_funcs = { |
| 1086 | .dpms = drm_helper_connector_dpms, |
| 1087 | .detect = radeon_dvi_detect, |
| 1088 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 1089 | .set_property = radeon_connector_set_property, |
| 1090 | .destroy = radeon_connector_destroy, |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 1091 | .force = radeon_dvi_force, |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1092 | }; |
| 1093 | |
Alex Deucher | ffd09c6 | 2009-11-24 16:13:23 -0500 | [diff] [blame] | 1094 | static void radeon_dp_connector_destroy(struct drm_connector *connector) |
| 1095 | { |
| 1096 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 1097 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
| 1098 | |
Alex Deucher | ffd09c6 | 2009-11-24 16:13:23 -0500 | [diff] [blame] | 1099 | if (radeon_connector->edid) |
| 1100 | kfree(radeon_connector->edid); |
| 1101 | if (radeon_dig_connector->dp_i2c_bus) |
Alex Deucher | ac1aade | 2010-03-14 12:22:44 -0400 | [diff] [blame] | 1102 | radeon_i2c_destroy(radeon_dig_connector->dp_i2c_bus); |
Alex Deucher | ffd09c6 | 2009-11-24 16:13:23 -0500 | [diff] [blame] | 1103 | kfree(radeon_connector->con_priv); |
| 1104 | drm_sysfs_connector_remove(connector); |
| 1105 | drm_connector_cleanup(connector); |
| 1106 | kfree(connector); |
| 1107 | } |
| 1108 | |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1109 | static int radeon_dp_get_modes(struct drm_connector *connector) |
| 1110 | { |
| 1111 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
Alex Deucher | 8b83485 | 2010-11-17 02:54:42 -0500 | [diff] [blame] | 1112 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
Alex Deucher | 591a10e | 2011-06-13 17:13:34 -0400 | [diff] [blame] | 1113 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1114 | int ret; |
| 1115 | |
Alex Deucher | f89931f | 2011-06-13 17:13:35 -0400 | [diff] [blame] | 1116 | if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) || |
| 1117 | (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) { |
Alex Deucher | d291767 | 2011-05-20 04:34:31 -0400 | [diff] [blame] | 1118 | struct drm_display_mode *mode; |
| 1119 | |
Alex Deucher | 2b69ffb | 2012-02-28 11:08:22 -0500 | [diff] [blame] | 1120 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { |
| 1121 | if (!radeon_dig_connector->edp_on) |
| 1122 | atombios_set_edp_panel_power(connector, |
| 1123 | ATOM_TRANSMITTER_ACTION_POWER_ON); |
| 1124 | ret = radeon_ddc_get_modes(radeon_connector); |
| 1125 | if (!radeon_dig_connector->edp_on) |
| 1126 | atombios_set_edp_panel_power(connector, |
| 1127 | ATOM_TRANSMITTER_ACTION_POWER_OFF); |
| 1128 | } else { |
| 1129 | /* need to setup ddc on the bridge */ |
| 1130 | if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) != |
| 1131 | ENCODER_OBJECT_ID_NONE) { |
| 1132 | if (encoder) |
| 1133 | radeon_atom_ext_encoder_setup_ddc(encoder); |
| 1134 | } |
| 1135 | ret = radeon_ddc_get_modes(radeon_connector); |
| 1136 | } |
Alex Deucher | d291767 | 2011-05-20 04:34:31 -0400 | [diff] [blame] | 1137 | |
| 1138 | if (ret > 0) { |
Alex Deucher | d291767 | 2011-05-20 04:34:31 -0400 | [diff] [blame] | 1139 | if (encoder) { |
| 1140 | radeon_fixup_lvds_native_mode(encoder, connector); |
| 1141 | /* add scaled modes */ |
| 1142 | radeon_add_common_modes(encoder, connector); |
| 1143 | } |
| 1144 | return ret; |
| 1145 | } |
| 1146 | |
Alex Deucher | d291767 | 2011-05-20 04:34:31 -0400 | [diff] [blame] | 1147 | if (!encoder) |
| 1148 | return 0; |
| 1149 | |
| 1150 | /* we have no EDID modes */ |
| 1151 | mode = radeon_fp_native_mode(encoder); |
| 1152 | if (mode) { |
| 1153 | ret = 1; |
| 1154 | drm_mode_probed_add(connector, mode); |
| 1155 | /* add the width/height from vbios tables if available */ |
| 1156 | connector->display_info.width_mm = mode->width_mm; |
| 1157 | connector->display_info.height_mm = mode->height_mm; |
| 1158 | /* add scaled modes */ |
| 1159 | radeon_add_common_modes(encoder, connector); |
| 1160 | } |
Alex Deucher | 591a10e | 2011-06-13 17:13:34 -0400 | [diff] [blame] | 1161 | } else { |
| 1162 | /* need to setup ddc on the bridge */ |
Alex Deucher | 1d33e1f | 2011-10-31 08:58:47 -0400 | [diff] [blame] | 1163 | if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) != |
| 1164 | ENCODER_OBJECT_ID_NONE) { |
Alex Deucher | 591a10e | 2011-06-13 17:13:34 -0400 | [diff] [blame] | 1165 | if (encoder) |
| 1166 | radeon_atom_ext_encoder_setup_ddc(encoder); |
| 1167 | } |
Alex Deucher | d291767 | 2011-05-20 04:34:31 -0400 | [diff] [blame] | 1168 | ret = radeon_ddc_get_modes(radeon_connector); |
Alex Deucher | 591a10e | 2011-06-13 17:13:34 -0400 | [diff] [blame] | 1169 | } |
Alex Deucher | 8b83485 | 2010-11-17 02:54:42 -0500 | [diff] [blame] | 1170 | |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1171 | return ret; |
| 1172 | } |
| 1173 | |
Alex Deucher | 1d33e1f | 2011-10-31 08:58:47 -0400 | [diff] [blame] | 1174 | u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *connector) |
Alex Deucher | d7fa8bb | 2011-05-20 04:34:21 -0400 | [diff] [blame] | 1175 | { |
| 1176 | struct drm_mode_object *obj; |
| 1177 | struct drm_encoder *encoder; |
| 1178 | struct radeon_encoder *radeon_encoder; |
| 1179 | int i; |
Alex Deucher | d7fa8bb | 2011-05-20 04:34:21 -0400 | [diff] [blame] | 1180 | |
| 1181 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
| 1182 | if (connector->encoder_ids[i] == 0) |
| 1183 | break; |
| 1184 | |
| 1185 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); |
| 1186 | if (!obj) |
| 1187 | continue; |
| 1188 | |
| 1189 | encoder = obj_to_encoder(obj); |
| 1190 | radeon_encoder = to_radeon_encoder(encoder); |
| 1191 | |
| 1192 | switch (radeon_encoder->encoder_id) { |
| 1193 | case ENCODER_OBJECT_ID_TRAVIS: |
| 1194 | case ENCODER_OBJECT_ID_NUTMEG: |
Alex Deucher | 1d33e1f | 2011-10-31 08:58:47 -0400 | [diff] [blame] | 1195 | return radeon_encoder->encoder_id; |
Alex Deucher | d7fa8bb | 2011-05-20 04:34:21 -0400 | [diff] [blame] | 1196 | default: |
| 1197 | break; |
| 1198 | } |
| 1199 | } |
| 1200 | |
Alex Deucher | 1d33e1f | 2011-10-31 08:58:47 -0400 | [diff] [blame] | 1201 | return ENCODER_OBJECT_ID_NONE; |
Alex Deucher | d7fa8bb | 2011-05-20 04:34:21 -0400 | [diff] [blame] | 1202 | } |
| 1203 | |
| 1204 | bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector) |
| 1205 | { |
| 1206 | struct drm_mode_object *obj; |
| 1207 | struct drm_encoder *encoder; |
| 1208 | struct radeon_encoder *radeon_encoder; |
| 1209 | int i; |
| 1210 | bool found = false; |
| 1211 | |
| 1212 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
| 1213 | if (connector->encoder_ids[i] == 0) |
| 1214 | break; |
| 1215 | |
| 1216 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); |
| 1217 | if (!obj) |
| 1218 | continue; |
| 1219 | |
| 1220 | encoder = obj_to_encoder(obj); |
| 1221 | radeon_encoder = to_radeon_encoder(encoder); |
| 1222 | if (radeon_encoder->caps & ATOM_ENCODER_CAP_RECORD_HBR2) |
| 1223 | found = true; |
| 1224 | } |
| 1225 | |
| 1226 | return found; |
| 1227 | } |
| 1228 | |
| 1229 | bool radeon_connector_is_dp12_capable(struct drm_connector *connector) |
| 1230 | { |
| 1231 | struct drm_device *dev = connector->dev; |
| 1232 | struct radeon_device *rdev = dev->dev_private; |
| 1233 | |
| 1234 | if (ASIC_IS_DCE5(rdev) && |
| 1235 | (rdev->clock.dp_extclk >= 53900) && |
| 1236 | radeon_connector_encoder_is_hbr2(connector)) { |
| 1237 | return true; |
| 1238 | } |
| 1239 | |
| 1240 | return false; |
| 1241 | } |
| 1242 | |
Chris Wilson | 7b334fc | 2010-09-09 23:51:02 +0100 | [diff] [blame] | 1243 | static enum drm_connector_status |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 1244 | radeon_dp_detect(struct drm_connector *connector, bool force) |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1245 | { |
Alex Deucher | f8d0edd | 2011-05-20 04:34:23 -0400 | [diff] [blame] | 1246 | struct drm_device *dev = connector->dev; |
| 1247 | struct radeon_device *rdev = dev->dev_private; |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1248 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1249 | enum drm_connector_status ret = connector_status_disconnected; |
Alex Deucher | 4143e91 | 2009-11-23 18:02:35 -0500 | [diff] [blame] | 1250 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
Alex Deucher | 591a10e | 2011-06-13 17:13:34 -0400 | [diff] [blame] | 1251 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1252 | |
| 1253 | if (radeon_connector->edid) { |
| 1254 | kfree(radeon_connector->edid); |
| 1255 | radeon_connector->edid = NULL; |
| 1256 | } |
| 1257 | |
Alex Deucher | f89931f | 2011-06-13 17:13:35 -0400 | [diff] [blame] | 1258 | if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) || |
| 1259 | (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) { |
Alex Deucher | d291767 | 2011-05-20 04:34:31 -0400 | [diff] [blame] | 1260 | if (encoder) { |
| 1261 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 1262 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
| 1263 | |
| 1264 | /* check if panel is valid */ |
| 1265 | if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) |
| 1266 | ret = connector_status_connected; |
| 1267 | } |
Alex Deucher | 6f50eae | 2010-08-19 17:29:03 -0400 | [diff] [blame] | 1268 | /* eDP is always DP */ |
| 1269 | radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT; |
Alex Deucher | 8b83485 | 2010-11-17 02:54:42 -0500 | [diff] [blame] | 1270 | if (!radeon_dig_connector->edp_on) |
| 1271 | atombios_set_edp_panel_power(connector, |
| 1272 | ATOM_TRANSMITTER_ACTION_POWER_ON); |
Alex Deucher | 6f50eae | 2010-08-19 17:29:03 -0400 | [diff] [blame] | 1273 | if (radeon_dp_getdpcd(radeon_connector)) |
Alex Deucher | 9fa05c9 | 2009-11-27 13:01:46 -0500 | [diff] [blame] | 1274 | ret = connector_status_connected; |
Alex Deucher | 8b83485 | 2010-11-17 02:54:42 -0500 | [diff] [blame] | 1275 | if (!radeon_dig_connector->edp_on) |
| 1276 | atombios_set_edp_panel_power(connector, |
| 1277 | ATOM_TRANSMITTER_ACTION_POWER_OFF); |
Alex Deucher | 1d33e1f | 2011-10-31 08:58:47 -0400 | [diff] [blame] | 1278 | } else if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) != |
| 1279 | ENCODER_OBJECT_ID_NONE) { |
Alex Deucher | b06947b | 2011-09-02 14:23:09 +0000 | [diff] [blame] | 1280 | /* DP bridges are always DP */ |
| 1281 | radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT; |
| 1282 | /* get the DPCD from the bridge */ |
| 1283 | radeon_dp_getdpcd(radeon_connector); |
| 1284 | |
Alex Deucher | 6777a4f | 2011-10-04 12:23:24 -0400 | [diff] [blame] | 1285 | if (encoder) { |
| 1286 | /* setup ddc on the bridge */ |
| 1287 | radeon_atom_ext_encoder_setup_ddc(encoder); |
Alex Deucher | bc1c4dc | 2011-10-30 16:54:27 -0400 | [diff] [blame] | 1288 | if (radeon_ddc_probe(radeon_connector)) /* try DDC */ |
Alex Deucher | b06947b | 2011-09-02 14:23:09 +0000 | [diff] [blame] | 1289 | ret = connector_status_connected; |
Alex Deucher | 6777a4f | 2011-10-04 12:23:24 -0400 | [diff] [blame] | 1290 | else if (radeon_connector->dac_load_detect) { /* try load detection */ |
| 1291 | struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private; |
Alex Deucher | b06947b | 2011-09-02 14:23:09 +0000 | [diff] [blame] | 1292 | ret = encoder_funcs->detect(encoder, connector); |
| 1293 | } |
| 1294 | } |
| 1295 | } else { |
Alex Deucher | 6f50eae | 2010-08-19 17:29:03 -0400 | [diff] [blame] | 1296 | radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector); |
Alex Deucher | f8d0edd | 2011-05-20 04:34:23 -0400 | [diff] [blame] | 1297 | if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { |
| 1298 | ret = connector_status_connected; |
| 1299 | if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) |
| 1300 | radeon_dp_getdpcd(radeon_connector); |
Alex Deucher | 6f50eae | 2010-08-19 17:29:03 -0400 | [diff] [blame] | 1301 | } else { |
Alex Deucher | f8d0edd | 2011-05-20 04:34:23 -0400 | [diff] [blame] | 1302 | if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) { |
| 1303 | if (radeon_dp_getdpcd(radeon_connector)) |
| 1304 | ret = connector_status_connected; |
| 1305 | } else { |
Alex Deucher | bc1c4dc | 2011-10-30 16:54:27 -0400 | [diff] [blame] | 1306 | if (radeon_ddc_probe(radeon_connector)) |
Alex Deucher | f8d0edd | 2011-05-20 04:34:23 -0400 | [diff] [blame] | 1307 | ret = connector_status_connected; |
| 1308 | } |
Alex Deucher | 4143e91 | 2009-11-23 18:02:35 -0500 | [diff] [blame] | 1309 | } |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1310 | } |
Alex Deucher | 4143e91 | 2009-11-23 18:02:35 -0500 | [diff] [blame] | 1311 | |
Alex Deucher | 30f4437 | 2010-08-21 11:09:14 -0400 | [diff] [blame] | 1312 | radeon_connector_update_scratch_regs(connector, ret); |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1313 | return ret; |
| 1314 | } |
| 1315 | |
Alex Deucher | 5801ead | 2009-11-24 13:32:59 -0500 | [diff] [blame] | 1316 | static int radeon_dp_mode_valid(struct drm_connector *connector, |
| 1317 | struct drm_display_mode *mode) |
| 1318 | { |
| 1319 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 1320 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
| 1321 | |
| 1322 | /* XXX check mode bandwidth */ |
| 1323 | |
Alex Deucher | f89931f | 2011-06-13 17:13:35 -0400 | [diff] [blame] | 1324 | if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) || |
| 1325 | (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) { |
Alex Deucher | d291767 | 2011-05-20 04:34:31 -0400 | [diff] [blame] | 1326 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
| 1327 | |
| 1328 | if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) |
| 1329 | return MODE_PANEL; |
| 1330 | |
| 1331 | if (encoder) { |
| 1332 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 1333 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
| 1334 | |
Alex Deucher | f89931f | 2011-06-13 17:13:35 -0400 | [diff] [blame] | 1335 | /* AVIVO hardware supports downscaling modes larger than the panel |
Alex Deucher | d291767 | 2011-05-20 04:34:31 -0400 | [diff] [blame] | 1336 | * to the panel size, but I'm not sure this is desirable. |
| 1337 | */ |
| 1338 | if ((mode->hdisplay > native_mode->hdisplay) || |
| 1339 | (mode->vdisplay > native_mode->vdisplay)) |
| 1340 | return MODE_PANEL; |
| 1341 | |
| 1342 | /* if scaling is disabled, block non-native modes */ |
| 1343 | if (radeon_encoder->rmx_type == RMX_OFF) { |
| 1344 | if ((mode->hdisplay != native_mode->hdisplay) || |
| 1345 | (mode->vdisplay != native_mode->vdisplay)) |
| 1346 | return MODE_PANEL; |
| 1347 | } |
| 1348 | } |
Alex Deucher | 5801ead | 2009-11-24 13:32:59 -0500 | [diff] [blame] | 1349 | return MODE_OK; |
Alex Deucher | d291767 | 2011-05-20 04:34:31 -0400 | [diff] [blame] | 1350 | } else { |
| 1351 | if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
| 1352 | (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) |
| 1353 | return radeon_dp_mode_valid_helper(connector, mode); |
| 1354 | else |
| 1355 | return MODE_OK; |
| 1356 | } |
Alex Deucher | 5801ead | 2009-11-24 13:32:59 -0500 | [diff] [blame] | 1357 | } |
| 1358 | |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1359 | struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = { |
| 1360 | .get_modes = radeon_dp_get_modes, |
Alex Deucher | 5801ead | 2009-11-24 13:32:59 -0500 | [diff] [blame] | 1361 | .mode_valid = radeon_dp_mode_valid, |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1362 | .best_encoder = radeon_dvi_encoder, |
| 1363 | }; |
| 1364 | |
| 1365 | struct drm_connector_funcs radeon_dp_connector_funcs = { |
| 1366 | .dpms = drm_helper_connector_dpms, |
| 1367 | .detect = radeon_dp_detect, |
| 1368 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 1369 | .set_property = radeon_connector_set_property, |
Alex Deucher | ffd09c6 | 2009-11-24 16:13:23 -0500 | [diff] [blame] | 1370 | .destroy = radeon_dp_connector_destroy, |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 1371 | .force = radeon_dvi_force, |
| 1372 | }; |
| 1373 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1374 | void |
| 1375 | radeon_add_atom_connector(struct drm_device *dev, |
| 1376 | uint32_t connector_id, |
| 1377 | uint32_t supported_device, |
| 1378 | int connector_type, |
| 1379 | struct radeon_i2c_bus_rec *i2c_bus, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1380 | uint32_t igp_lane_info, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1381 | uint16_t connector_object_id, |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 1382 | struct radeon_hpd *hpd, |
| 1383 | struct radeon_router *router) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1384 | { |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1385 | struct radeon_device *rdev = dev->dev_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1386 | struct drm_connector *connector; |
| 1387 | struct radeon_connector *radeon_connector; |
| 1388 | struct radeon_connector_atom_dig *radeon_dig_connector; |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1389 | struct drm_encoder *encoder; |
| 1390 | struct radeon_encoder *radeon_encoder; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1391 | uint32_t subpixel_order = SubPixelNone; |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 1392 | bool shared_ddc = false; |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1393 | bool is_dp_bridge = false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1394 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1395 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1396 | return; |
| 1397 | |
Alex Deucher | cf4c12f | 2010-09-01 17:15:06 -0400 | [diff] [blame] | 1398 | /* if the user selected tv=0 don't try and add the connector */ |
| 1399 | if (((connector_type == DRM_MODE_CONNECTOR_SVIDEO) || |
| 1400 | (connector_type == DRM_MODE_CONNECTOR_Composite) || |
| 1401 | (connector_type == DRM_MODE_CONNECTOR_9PinDIN)) && |
| 1402 | (radeon_tv == 0)) |
| 1403 | return; |
| 1404 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1405 | /* see if we already added it */ |
| 1406 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 1407 | radeon_connector = to_radeon_connector(connector); |
| 1408 | if (radeon_connector->connector_id == connector_id) { |
| 1409 | radeon_connector->devices |= supported_device; |
| 1410 | return; |
| 1411 | } |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 1412 | if (radeon_connector->ddc_bus && i2c_bus->valid) { |
Alex Deucher | d3932d6 | 2010-02-19 02:13:56 -0500 | [diff] [blame] | 1413 | if (radeon_connector->ddc_bus->rec.i2c_id == i2c_bus->i2c_id) { |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 1414 | radeon_connector->shared_ddc = true; |
| 1415 | shared_ddc = true; |
| 1416 | } |
Alex Deucher | fb939df | 2010-11-08 16:08:29 +0000 | [diff] [blame] | 1417 | if (radeon_connector->router_bus && router->ddc_valid && |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 1418 | (radeon_connector->router.router_id == router->router_id)) { |
| 1419 | radeon_connector->shared_ddc = false; |
| 1420 | shared_ddc = false; |
| 1421 | } |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 1422 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1423 | } |
| 1424 | |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1425 | /* check if it's a dp bridge */ |
| 1426 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
| 1427 | radeon_encoder = to_radeon_encoder(encoder); |
| 1428 | if (radeon_encoder->devices & supported_device) { |
| 1429 | switch (radeon_encoder->encoder_id) { |
| 1430 | case ENCODER_OBJECT_ID_TRAVIS: |
| 1431 | case ENCODER_OBJECT_ID_NUTMEG: |
| 1432 | is_dp_bridge = true; |
| 1433 | break; |
| 1434 | default: |
| 1435 | break; |
| 1436 | } |
| 1437 | } |
| 1438 | } |
| 1439 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1440 | radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); |
| 1441 | if (!radeon_connector) |
| 1442 | return; |
| 1443 | |
| 1444 | connector = &radeon_connector->base; |
| 1445 | |
| 1446 | radeon_connector->connector_id = connector_id; |
| 1447 | radeon_connector->devices = supported_device; |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 1448 | radeon_connector->shared_ddc = shared_ddc; |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1449 | radeon_connector->connector_object_id = connector_object_id; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1450 | radeon_connector->hpd = *hpd; |
Alex Deucher | bc1c4dc | 2011-10-30 16:54:27 -0400 | [diff] [blame] | 1451 | |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 1452 | radeon_connector->router = *router; |
Alex Deucher | fb939df | 2010-11-08 16:08:29 +0000 | [diff] [blame] | 1453 | if (router->ddc_valid || router->cd_valid) { |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 1454 | radeon_connector->router_bus = radeon_i2c_lookup(rdev, &router->i2c_info); |
| 1455 | if (!radeon_connector->router_bus) |
Alex Deucher | a70882a | 2011-04-14 17:24:07 -0400 | [diff] [blame] | 1456 | DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n"); |
Alex Deucher | 26b5bc9 | 2010-08-05 21:21:18 -0400 | [diff] [blame] | 1457 | } |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1458 | |
| 1459 | if (is_dp_bridge) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1460 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
| 1461 | if (!radeon_dig_connector) |
| 1462 | goto failed; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1463 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
| 1464 | radeon_connector->con_priv = radeon_dig_connector; |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1465 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); |
| 1466 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1467 | if (i2c_bus->valid) { |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1468 | /* add DP i2c bus */ |
| 1469 | if (connector_type == DRM_MODE_CONNECTOR_eDP) |
| 1470 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch"); |
| 1471 | else |
| 1472 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); |
| 1473 | if (!radeon_dig_connector->dp_i2c_bus) |
| 1474 | DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 1475 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1476 | if (!radeon_connector->ddc_bus) |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1477 | DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1478 | } |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1479 | switch (connector_type) { |
| 1480 | case DRM_MODE_CONNECTOR_VGA: |
| 1481 | case DRM_MODE_CONNECTOR_DVIA: |
| 1482 | default: |
| 1483 | connector->interlace_allowed = true; |
| 1484 | connector->doublescan_allowed = true; |
Alex Deucher | d629a3c | 2011-06-13 17:13:33 -0400 | [diff] [blame] | 1485 | radeon_connector->dac_load_detect = true; |
| 1486 | drm_connector_attach_property(&radeon_connector->base, |
| 1487 | rdev->mode_info.load_detect_property, |
| 1488 | 1); |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1489 | break; |
| 1490 | case DRM_MODE_CONNECTOR_DVII: |
| 1491 | case DRM_MODE_CONNECTOR_DVID: |
| 1492 | case DRM_MODE_CONNECTOR_HDMIA: |
| 1493 | case DRM_MODE_CONNECTOR_HDMIB: |
| 1494 | case DRM_MODE_CONNECTOR_DisplayPort: |
Alex Deucher | 430f70d | 2010-08-04 03:45:04 -0400 | [diff] [blame] | 1495 | drm_connector_attach_property(&radeon_connector->base, |
| 1496 | rdev->mode_info.underscan_property, |
Alex Deucher | 56bec7c | 2011-01-05 11:57:52 -0500 | [diff] [blame] | 1497 | UNDERSCAN_OFF); |
Marius Gröger | 5bccf5e | 2010-09-21 21:30:59 +0200 | [diff] [blame] | 1498 | drm_connector_attach_property(&radeon_connector->base, |
| 1499 | rdev->mode_info.underscan_hborder_property, |
| 1500 | 0); |
| 1501 | drm_connector_attach_property(&radeon_connector->base, |
| 1502 | rdev->mode_info.underscan_vborder_property, |
| 1503 | 0); |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1504 | subpixel_order = SubPixelHorizontalRGB; |
| 1505 | connector->interlace_allowed = true; |
| 1506 | if (connector_type == DRM_MODE_CONNECTOR_HDMIB) |
| 1507 | connector->doublescan_allowed = true; |
| 1508 | else |
| 1509 | connector->doublescan_allowed = false; |
Alex Deucher | d629a3c | 2011-06-13 17:13:33 -0400 | [diff] [blame] | 1510 | if (connector_type == DRM_MODE_CONNECTOR_DVII) { |
| 1511 | radeon_connector->dac_load_detect = true; |
| 1512 | drm_connector_attach_property(&radeon_connector->base, |
| 1513 | rdev->mode_info.load_detect_property, |
| 1514 | 1); |
| 1515 | } |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1516 | break; |
| 1517 | case DRM_MODE_CONNECTOR_LVDS: |
| 1518 | case DRM_MODE_CONNECTOR_eDP: |
| 1519 | drm_connector_attach_property(&radeon_connector->base, |
| 1520 | dev->mode_config.scaling_mode_property, |
| 1521 | DRM_MODE_SCALE_FULLSCREEN); |
| 1522 | subpixel_order = SubPixelHorizontalRGB; |
| 1523 | connector->interlace_allowed = false; |
| 1524 | connector->doublescan_allowed = false; |
| 1525 | break; |
Marius Gröger | 5bccf5e | 2010-09-21 21:30:59 +0200 | [diff] [blame] | 1526 | } |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1527 | } else { |
| 1528 | switch (connector_type) { |
| 1529 | case DRM_MODE_CONNECTOR_VGA: |
| 1530 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
| 1531 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
| 1532 | if (i2c_bus->valid) { |
| 1533 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
| 1534 | if (!radeon_connector->ddc_bus) |
| 1535 | DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
| 1536 | } |
Alex Deucher | 390d0bb | 2009-12-08 12:48:20 -0500 | [diff] [blame] | 1537 | radeon_connector->dac_load_detect = true; |
| 1538 | drm_connector_attach_property(&radeon_connector->base, |
| 1539 | rdev->mode_info.load_detect_property, |
| 1540 | 1); |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1541 | /* no HPD on analog connectors */ |
| 1542 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; |
| 1543 | connector->polled = DRM_CONNECTOR_POLL_CONNECT; |
| 1544 | connector->interlace_allowed = true; |
Alex Deucher | c49948f | 2010-11-30 15:46:47 -0500 | [diff] [blame] | 1545 | connector->doublescan_allowed = true; |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1546 | break; |
| 1547 | case DRM_MODE_CONNECTOR_DVIA: |
| 1548 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
| 1549 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
| 1550 | if (i2c_bus->valid) { |
| 1551 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
| 1552 | if (!radeon_connector->ddc_bus) |
| 1553 | DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
| 1554 | } |
| 1555 | radeon_connector->dac_load_detect = true; |
Alex Deucher | 430f70d | 2010-08-04 03:45:04 -0400 | [diff] [blame] | 1556 | drm_connector_attach_property(&radeon_connector->base, |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1557 | rdev->mode_info.load_detect_property, |
| 1558 | 1); |
| 1559 | /* no HPD on analog connectors */ |
| 1560 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; |
| 1561 | connector->interlace_allowed = true; |
Alex Deucher | c49948f | 2010-11-30 15:46:47 -0500 | [diff] [blame] | 1562 | connector->doublescan_allowed = true; |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1563 | break; |
| 1564 | case DRM_MODE_CONNECTOR_DVII: |
| 1565 | case DRM_MODE_CONNECTOR_DVID: |
| 1566 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
| 1567 | if (!radeon_dig_connector) |
| 1568 | goto failed; |
| 1569 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
| 1570 | radeon_connector->con_priv = radeon_dig_connector; |
| 1571 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); |
| 1572 | drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); |
| 1573 | if (i2c_bus->valid) { |
| 1574 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
| 1575 | if (!radeon_connector->ddc_bus) |
| 1576 | DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
| 1577 | } |
| 1578 | subpixel_order = SubPixelHorizontalRGB; |
| 1579 | drm_connector_attach_property(&radeon_connector->base, |
| 1580 | rdev->mode_info.coherent_mode_property, |
| 1581 | 1); |
| 1582 | if (ASIC_IS_AVIVO(rdev)) { |
| 1583 | drm_connector_attach_property(&radeon_connector->base, |
| 1584 | rdev->mode_info.underscan_property, |
| 1585 | UNDERSCAN_OFF); |
| 1586 | drm_connector_attach_property(&radeon_connector->base, |
| 1587 | rdev->mode_info.underscan_hborder_property, |
| 1588 | 0); |
| 1589 | drm_connector_attach_property(&radeon_connector->base, |
| 1590 | rdev->mode_info.underscan_vborder_property, |
| 1591 | 0); |
| 1592 | } |
| 1593 | if (connector_type == DRM_MODE_CONNECTOR_DVII) { |
| 1594 | radeon_connector->dac_load_detect = true; |
| 1595 | drm_connector_attach_property(&radeon_connector->base, |
| 1596 | rdev->mode_info.load_detect_property, |
| 1597 | 1); |
| 1598 | } |
| 1599 | connector->interlace_allowed = true; |
| 1600 | if (connector_type == DRM_MODE_CONNECTOR_DVII) |
| 1601 | connector->doublescan_allowed = true; |
| 1602 | else |
| 1603 | connector->doublescan_allowed = false; |
| 1604 | break; |
| 1605 | case DRM_MODE_CONNECTOR_HDMIA: |
| 1606 | case DRM_MODE_CONNECTOR_HDMIB: |
| 1607 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
| 1608 | if (!radeon_dig_connector) |
| 1609 | goto failed; |
| 1610 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
| 1611 | radeon_connector->con_priv = radeon_dig_connector; |
| 1612 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); |
| 1613 | drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); |
| 1614 | if (i2c_bus->valid) { |
| 1615 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
| 1616 | if (!radeon_connector->ddc_bus) |
| 1617 | DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
| 1618 | } |
| 1619 | drm_connector_attach_property(&radeon_connector->base, |
| 1620 | rdev->mode_info.coherent_mode_property, |
| 1621 | 1); |
| 1622 | if (ASIC_IS_AVIVO(rdev)) { |
| 1623 | drm_connector_attach_property(&radeon_connector->base, |
| 1624 | rdev->mode_info.underscan_property, |
| 1625 | UNDERSCAN_OFF); |
| 1626 | drm_connector_attach_property(&radeon_connector->base, |
| 1627 | rdev->mode_info.underscan_hborder_property, |
| 1628 | 0); |
| 1629 | drm_connector_attach_property(&radeon_connector->base, |
| 1630 | rdev->mode_info.underscan_vborder_property, |
| 1631 | 0); |
| 1632 | } |
| 1633 | subpixel_order = SubPixelHorizontalRGB; |
| 1634 | connector->interlace_allowed = true; |
| 1635 | if (connector_type == DRM_MODE_CONNECTOR_HDMIB) |
| 1636 | connector->doublescan_allowed = true; |
| 1637 | else |
| 1638 | connector->doublescan_allowed = false; |
| 1639 | break; |
| 1640 | case DRM_MODE_CONNECTOR_DisplayPort: |
| 1641 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
| 1642 | if (!radeon_dig_connector) |
| 1643 | goto failed; |
| 1644 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
| 1645 | radeon_connector->con_priv = radeon_dig_connector; |
| 1646 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); |
| 1647 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); |
| 1648 | if (i2c_bus->valid) { |
| 1649 | /* add DP i2c bus */ |
| 1650 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); |
| 1651 | if (!radeon_dig_connector->dp_i2c_bus) |
| 1652 | DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); |
| 1653 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
| 1654 | if (!radeon_connector->ddc_bus) |
| 1655 | DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
| 1656 | } |
| 1657 | subpixel_order = SubPixelHorizontalRGB; |
| 1658 | drm_connector_attach_property(&radeon_connector->base, |
| 1659 | rdev->mode_info.coherent_mode_property, |
| 1660 | 1); |
| 1661 | if (ASIC_IS_AVIVO(rdev)) { |
| 1662 | drm_connector_attach_property(&radeon_connector->base, |
| 1663 | rdev->mode_info.underscan_property, |
| 1664 | UNDERSCAN_OFF); |
| 1665 | drm_connector_attach_property(&radeon_connector->base, |
| 1666 | rdev->mode_info.underscan_hborder_property, |
| 1667 | 0); |
| 1668 | drm_connector_attach_property(&radeon_connector->base, |
| 1669 | rdev->mode_info.underscan_vborder_property, |
| 1670 | 0); |
| 1671 | } |
| 1672 | connector->interlace_allowed = true; |
| 1673 | /* in theory with a DP to VGA converter... */ |
Alex Deucher | c49948f | 2010-11-30 15:46:47 -0500 | [diff] [blame] | 1674 | connector->doublescan_allowed = false; |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1675 | break; |
| 1676 | case DRM_MODE_CONNECTOR_eDP: |
| 1677 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
| 1678 | if (!radeon_dig_connector) |
| 1679 | goto failed; |
| 1680 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
| 1681 | radeon_connector->con_priv = radeon_dig_connector; |
| 1682 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); |
| 1683 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); |
| 1684 | if (i2c_bus->valid) { |
| 1685 | /* add DP i2c bus */ |
| 1686 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch"); |
| 1687 | if (!radeon_dig_connector->dp_i2c_bus) |
| 1688 | DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); |
| 1689 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
| 1690 | if (!radeon_connector->ddc_bus) |
| 1691 | DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
| 1692 | } |
Alex Deucher | 430f70d | 2010-08-04 03:45:04 -0400 | [diff] [blame] | 1693 | drm_connector_attach_property(&radeon_connector->base, |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1694 | dev->mode_config.scaling_mode_property, |
| 1695 | DRM_MODE_SCALE_FULLSCREEN); |
| 1696 | subpixel_order = SubPixelHorizontalRGB; |
| 1697 | connector->interlace_allowed = false; |
| 1698 | connector->doublescan_allowed = false; |
| 1699 | break; |
| 1700 | case DRM_MODE_CONNECTOR_SVIDEO: |
| 1701 | case DRM_MODE_CONNECTOR_Composite: |
| 1702 | case DRM_MODE_CONNECTOR_9PinDIN: |
| 1703 | drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); |
| 1704 | drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); |
| 1705 | radeon_connector->dac_load_detect = true; |
Marius Gröger | 5bccf5e | 2010-09-21 21:30:59 +0200 | [diff] [blame] | 1706 | drm_connector_attach_property(&radeon_connector->base, |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1707 | rdev->mode_info.load_detect_property, |
| 1708 | 1); |
Marius Gröger | 5bccf5e | 2010-09-21 21:30:59 +0200 | [diff] [blame] | 1709 | drm_connector_attach_property(&radeon_connector->base, |
Alex Deucher | eac4dff | 2011-05-20 04:34:22 -0400 | [diff] [blame] | 1710 | rdev->mode_info.tv_std_property, |
| 1711 | radeon_atombios_get_tv_info(rdev)); |
| 1712 | /* no HPD on analog connectors */ |
| 1713 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; |
| 1714 | connector->interlace_allowed = false; |
| 1715 | connector->doublescan_allowed = false; |
| 1716 | break; |
| 1717 | case DRM_MODE_CONNECTOR_LVDS: |
| 1718 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
| 1719 | if (!radeon_dig_connector) |
| 1720 | goto failed; |
| 1721 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
| 1722 | radeon_connector->con_priv = radeon_dig_connector; |
| 1723 | drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); |
| 1724 | drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); |
| 1725 | if (i2c_bus->valid) { |
| 1726 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
| 1727 | if (!radeon_connector->ddc_bus) |
| 1728 | DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
| 1729 | } |
| 1730 | drm_connector_attach_property(&radeon_connector->base, |
| 1731 | dev->mode_config.scaling_mode_property, |
| 1732 | DRM_MODE_SCALE_FULLSCREEN); |
| 1733 | subpixel_order = SubPixelHorizontalRGB; |
| 1734 | connector->interlace_allowed = false; |
| 1735 | connector->doublescan_allowed = false; |
| 1736 | break; |
Marius Gröger | 5bccf5e | 2010-09-21 21:30:59 +0200 | [diff] [blame] | 1737 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1738 | } |
| 1739 | |
Alex Deucher | 2581afc | 2010-07-20 03:24:11 -0400 | [diff] [blame] | 1740 | if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) { |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1741 | if (i2c_bus->valid) |
| 1742 | connector->polled = DRM_CONNECTOR_POLL_CONNECT; |
| 1743 | } else |
| 1744 | connector->polled = DRM_CONNECTOR_POLL_HPD; |
| 1745 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1746 | connector->display_info.subpixel_order = subpixel_order; |
| 1747 | drm_sysfs_connector_add(connector); |
| 1748 | return; |
| 1749 | |
| 1750 | failed: |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1751 | drm_connector_cleanup(connector); |
| 1752 | kfree(connector); |
| 1753 | } |
| 1754 | |
| 1755 | void |
| 1756 | radeon_add_legacy_connector(struct drm_device *dev, |
| 1757 | uint32_t connector_id, |
| 1758 | uint32_t supported_device, |
| 1759 | int connector_type, |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1760 | struct radeon_i2c_bus_rec *i2c_bus, |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1761 | uint16_t connector_object_id, |
| 1762 | struct radeon_hpd *hpd) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1763 | { |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1764 | struct radeon_device *rdev = dev->dev_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1765 | struct drm_connector *connector; |
| 1766 | struct radeon_connector *radeon_connector; |
| 1767 | uint32_t subpixel_order = SubPixelNone; |
| 1768 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 1769 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1770 | return; |
| 1771 | |
Alex Deucher | cf4c12f | 2010-09-01 17:15:06 -0400 | [diff] [blame] | 1772 | /* if the user selected tv=0 don't try and add the connector */ |
| 1773 | if (((connector_type == DRM_MODE_CONNECTOR_SVIDEO) || |
| 1774 | (connector_type == DRM_MODE_CONNECTOR_Composite) || |
| 1775 | (connector_type == DRM_MODE_CONNECTOR_9PinDIN)) && |
| 1776 | (radeon_tv == 0)) |
| 1777 | return; |
| 1778 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1779 | /* see if we already added it */ |
| 1780 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 1781 | radeon_connector = to_radeon_connector(connector); |
| 1782 | if (radeon_connector->connector_id == connector_id) { |
| 1783 | radeon_connector->devices |= supported_device; |
| 1784 | return; |
| 1785 | } |
| 1786 | } |
| 1787 | |
| 1788 | radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); |
| 1789 | if (!radeon_connector) |
| 1790 | return; |
| 1791 | |
| 1792 | connector = &radeon_connector->base; |
| 1793 | |
| 1794 | radeon_connector->connector_id = connector_id; |
| 1795 | radeon_connector->devices = supported_device; |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 1796 | radeon_connector->connector_object_id = connector_object_id; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 1797 | radeon_connector->hpd = *hpd; |
Alex Deucher | bc1c4dc | 2011-10-30 16:54:27 -0400 | [diff] [blame] | 1798 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1799 | switch (connector_type) { |
| 1800 | case DRM_MODE_CONNECTOR_VGA: |
| 1801 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
Dave Airlie | 0b4c0f3 | 2010-03-30 05:34:15 +0000 | [diff] [blame] | 1802 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1803 | if (i2c_bus->valid) { |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 1804 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1805 | if (!radeon_connector->ddc_bus) |
Alex Deucher | a70882a | 2011-04-14 17:24:07 -0400 | [diff] [blame] | 1806 | DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1807 | } |
Dave Airlie | 35e4b7a | 2009-09-25 11:56:50 +1000 | [diff] [blame] | 1808 | radeon_connector->dac_load_detect = true; |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1809 | drm_connector_attach_property(&radeon_connector->base, |
| 1810 | rdev->mode_info.load_detect_property, |
| 1811 | 1); |
Alex Deucher | 2581afc | 2010-07-20 03:24:11 -0400 | [diff] [blame] | 1812 | /* no HPD on analog connectors */ |
| 1813 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1814 | connector->polled = DRM_CONNECTOR_POLL_CONNECT; |
Alex Deucher | c49948f | 2010-11-30 15:46:47 -0500 | [diff] [blame] | 1815 | connector->interlace_allowed = true; |
| 1816 | connector->doublescan_allowed = true; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1817 | break; |
| 1818 | case DRM_MODE_CONNECTOR_DVIA: |
| 1819 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
Dave Airlie | 0b4c0f3 | 2010-03-30 05:34:15 +0000 | [diff] [blame] | 1820 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1821 | if (i2c_bus->valid) { |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 1822 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1823 | if (!radeon_connector->ddc_bus) |
Alex Deucher | a70882a | 2011-04-14 17:24:07 -0400 | [diff] [blame] | 1824 | DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1825 | } |
Dave Airlie | 35e4b7a | 2009-09-25 11:56:50 +1000 | [diff] [blame] | 1826 | radeon_connector->dac_load_detect = true; |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1827 | drm_connector_attach_property(&radeon_connector->base, |
| 1828 | rdev->mode_info.load_detect_property, |
| 1829 | 1); |
Alex Deucher | 2581afc | 2010-07-20 03:24:11 -0400 | [diff] [blame] | 1830 | /* no HPD on analog connectors */ |
| 1831 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; |
Alex Deucher | c49948f | 2010-11-30 15:46:47 -0500 | [diff] [blame] | 1832 | connector->interlace_allowed = true; |
| 1833 | connector->doublescan_allowed = true; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1834 | break; |
| 1835 | case DRM_MODE_CONNECTOR_DVII: |
| 1836 | case DRM_MODE_CONNECTOR_DVID: |
| 1837 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); |
Dave Airlie | 0b4c0f3 | 2010-03-30 05:34:15 +0000 | [diff] [blame] | 1838 | drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1839 | if (i2c_bus->valid) { |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 1840 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1841 | if (!radeon_connector->ddc_bus) |
Alex Deucher | a70882a | 2011-04-14 17:24:07 -0400 | [diff] [blame] | 1842 | DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
Alex Deucher | 68b3adb | 2010-04-30 12:37:31 -0400 | [diff] [blame] | 1843 | } |
| 1844 | if (connector_type == DRM_MODE_CONNECTOR_DVII) { |
Dave Airlie | 35e4b7a | 2009-09-25 11:56:50 +1000 | [diff] [blame] | 1845 | radeon_connector->dac_load_detect = true; |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1846 | drm_connector_attach_property(&radeon_connector->base, |
| 1847 | rdev->mode_info.load_detect_property, |
| 1848 | 1); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1849 | } |
| 1850 | subpixel_order = SubPixelHorizontalRGB; |
Alex Deucher | c49948f | 2010-11-30 15:46:47 -0500 | [diff] [blame] | 1851 | connector->interlace_allowed = true; |
| 1852 | if (connector_type == DRM_MODE_CONNECTOR_DVII) |
| 1853 | connector->doublescan_allowed = true; |
| 1854 | else |
| 1855 | connector->doublescan_allowed = false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1856 | break; |
| 1857 | case DRM_MODE_CONNECTOR_SVIDEO: |
| 1858 | case DRM_MODE_CONNECTOR_Composite: |
| 1859 | case DRM_MODE_CONNECTOR_9PinDIN: |
Alex Deucher | cf4c12f | 2010-09-01 17:15:06 -0400 | [diff] [blame] | 1860 | drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); |
| 1861 | drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); |
| 1862 | radeon_connector->dac_load_detect = true; |
| 1863 | /* RS400,RC410,RS480 chipset seems to report a lot |
| 1864 | * of false positive on load detect, we haven't yet |
| 1865 | * found a way to make load detect reliable on those |
| 1866 | * chipset, thus just disable it for TV. |
| 1867 | */ |
| 1868 | if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) |
| 1869 | radeon_connector->dac_load_detect = false; |
| 1870 | drm_connector_attach_property(&radeon_connector->base, |
| 1871 | rdev->mode_info.load_detect_property, |
| 1872 | radeon_connector->dac_load_detect); |
| 1873 | drm_connector_attach_property(&radeon_connector->base, |
| 1874 | rdev->mode_info.tv_std_property, |
| 1875 | radeon_combios_get_tv_info(rdev)); |
| 1876 | /* no HPD on analog connectors */ |
| 1877 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; |
Alex Deucher | c49948f | 2010-11-30 15:46:47 -0500 | [diff] [blame] | 1878 | connector->interlace_allowed = false; |
| 1879 | connector->doublescan_allowed = false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1880 | break; |
| 1881 | case DRM_MODE_CONNECTOR_LVDS: |
| 1882 | drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); |
Dave Airlie | 0b4c0f3 | 2010-03-30 05:34:15 +0000 | [diff] [blame] | 1883 | drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1884 | if (i2c_bus->valid) { |
Alex Deucher | f376b94 | 2010-08-05 21:21:16 -0400 | [diff] [blame] | 1885 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1886 | if (!radeon_connector->ddc_bus) |
Alex Deucher | a70882a | 2011-04-14 17:24:07 -0400 | [diff] [blame] | 1887 | DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1888 | } |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 1889 | drm_connector_attach_property(&radeon_connector->base, |
| 1890 | dev->mode_config.scaling_mode_property, |
| 1891 | DRM_MODE_SCALE_FULLSCREEN); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1892 | subpixel_order = SubPixelHorizontalRGB; |
Alex Deucher | c49948f | 2010-11-30 15:46:47 -0500 | [diff] [blame] | 1893 | connector->interlace_allowed = false; |
| 1894 | connector->doublescan_allowed = false; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1895 | break; |
| 1896 | } |
| 1897 | |
Alex Deucher | 2581afc | 2010-07-20 03:24:11 -0400 | [diff] [blame] | 1898 | if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) { |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1899 | if (i2c_bus->valid) |
| 1900 | connector->polled = DRM_CONNECTOR_POLL_CONNECT; |
| 1901 | } else |
| 1902 | connector->polled = DRM_CONNECTOR_POLL_HPD; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1903 | connector->display_info.subpixel_order = subpixel_order; |
| 1904 | drm_sysfs_connector_add(connector); |
Michel Dänzer | 63ec011 | 2011-03-22 16:30:23 -0700 | [diff] [blame] | 1905 | if (connector_type == DRM_MODE_CONNECTOR_LVDS) { |
| 1906 | struct drm_encoder *drm_encoder; |
| 1907 | |
| 1908 | list_for_each_entry(drm_encoder, &dev->mode_config.encoder_list, head) { |
| 1909 | struct radeon_encoder *radeon_encoder; |
| 1910 | |
| 1911 | radeon_encoder = to_radeon_encoder(drm_encoder); |
| 1912 | if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_LVDS) |
| 1913 | radeon_legacy_backlight_init(radeon_encoder, connector); |
| 1914 | } |
| 1915 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1916 | } |