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