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