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