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