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