Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2006-2007 Intel Corporation |
| 3 | * Copyright (c) 2006 Dave Airlie <airlied@linux.ie> |
| 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 (including the next |
| 13 | * paragraph) shall be included in all copies or substantial portions of the |
| 14 | * Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
| 25 | * Eric Anholt <eric@anholt.net> |
| 26 | * Dave Airlie <airlied@linux.ie> |
| 27 | * Jesse Barnes <jesse.barnes@intel.com> |
| 28 | */ |
| 29 | |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 30 | #include <acpi/button.h> |
Paul Collins | 565dcd4 | 2009-02-04 23:05:41 +1300 | [diff] [blame] | 31 | #include <linux/dmi.h> |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 32 | #include <linux/i2c.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 33 | #include <linux/slab.h> |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 34 | #include "drmP.h" |
| 35 | #include "drm.h" |
| 36 | #include "drm_crtc.h" |
| 37 | #include "drm_edid.h" |
| 38 | #include "intel_drv.h" |
| 39 | #include "i915_drm.h" |
| 40 | #include "i915_drv.h" |
Zhao Yakui | e99da35 | 2009-06-26 09:46:18 +0800 | [diff] [blame] | 41 | #include <linux/acpi.h> |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 42 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 43 | /* Private structure for the integrated LVDS support */ |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 44 | struct intel_lvds { |
| 45 | struct intel_encoder base; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 46 | int fitting_mode; |
| 47 | u32 pfit_control; |
| 48 | u32 pfit_pgm_ratios; |
| 49 | }; |
| 50 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 51 | static struct intel_lvds *enc_to_intel_lvds(struct drm_encoder *encoder) |
| 52 | { |
Chris Wilson | 4ef69c7 | 2010-09-09 15:14:28 +0100 | [diff] [blame] | 53 | return container_of(encoder, struct intel_lvds, base.base); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 54 | } |
| 55 | |
Matthew Garrett | 309b1e3 | 2010-05-18 13:53:16 -0400 | [diff] [blame] | 56 | static void intel_lvds_lock_panel(struct drm_device *dev, bool lock) |
| 57 | { |
| 58 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 59 | |
| 60 | if (lock) |
| 61 | I915_WRITE(PP_CONTROL, I915_READ(PP_CONTROL) & 0x3); |
| 62 | else |
| 63 | I915_WRITE(PP_CONTROL, I915_READ(PP_CONTROL) | PANEL_UNLOCK_REGS); |
| 64 | } |
| 65 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 66 | /** |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 67 | * Sets the power state for the panel. |
| 68 | */ |
| 69 | static void intel_lvds_set_power(struct drm_device *dev, bool on) |
| 70 | { |
| 71 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 913d8d1 | 2010-08-07 11:01:35 +0100 | [diff] [blame] | 72 | u32 ctl_reg, status_reg, lvds_reg; |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 73 | |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 74 | if (HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 75 | ctl_reg = PCH_PP_CONTROL; |
| 76 | status_reg = PCH_PP_STATUS; |
Jesse Barnes | 469d129 | 2010-02-11 12:41:05 -0800 | [diff] [blame] | 77 | lvds_reg = PCH_LVDS; |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 78 | } else { |
| 79 | ctl_reg = PP_CONTROL; |
| 80 | status_reg = PP_STATUS; |
Jesse Barnes | 469d129 | 2010-02-11 12:41:05 -0800 | [diff] [blame] | 81 | lvds_reg = LVDS; |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 82 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 83 | |
| 84 | if (on) { |
Jesse Barnes | 469d129 | 2010-02-11 12:41:05 -0800 | [diff] [blame] | 85 | I915_WRITE(lvds_reg, I915_READ(lvds_reg) | LVDS_PORT_EN); |
| 86 | POSTING_READ(lvds_reg); |
| 87 | |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 88 | I915_WRITE(ctl_reg, I915_READ(ctl_reg) | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 89 | POWER_TARGET_ON); |
Chris Wilson | 481b6af | 2010-08-23 17:43:35 +0100 | [diff] [blame] | 90 | if (wait_for(I915_READ(status_reg) & PP_ON, 1000)) |
Chris Wilson | 913d8d1 | 2010-08-07 11:01:35 +0100 | [diff] [blame] | 91 | DRM_ERROR("timed out waiting to enable LVDS pipe"); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 92 | |
Chris Wilson | a957355 | 2010-08-22 13:18:16 +0100 | [diff] [blame] | 93 | intel_panel_set_backlight(dev, dev_priv->backlight_level); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 94 | } else { |
Chris Wilson | a957355 | 2010-08-22 13:18:16 +0100 | [diff] [blame] | 95 | intel_panel_set_backlight(dev, 0); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 96 | |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 97 | I915_WRITE(ctl_reg, I915_READ(ctl_reg) & |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 98 | ~POWER_TARGET_ON); |
Chris Wilson | 481b6af | 2010-08-23 17:43:35 +0100 | [diff] [blame] | 99 | if (wait_for((I915_READ(status_reg) & PP_ON) == 0, 1000)) |
Chris Wilson | 913d8d1 | 2010-08-07 11:01:35 +0100 | [diff] [blame] | 100 | DRM_ERROR("timed out waiting for LVDS pipe to turn off"); |
Jesse Barnes | 469d129 | 2010-02-11 12:41:05 -0800 | [diff] [blame] | 101 | |
| 102 | I915_WRITE(lvds_reg, I915_READ(lvds_reg) & ~LVDS_PORT_EN); |
| 103 | POSTING_READ(lvds_reg); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
| 107 | static void intel_lvds_dpms(struct drm_encoder *encoder, int mode) |
| 108 | { |
| 109 | struct drm_device *dev = encoder->dev; |
| 110 | |
| 111 | if (mode == DRM_MODE_DPMS_ON) |
| 112 | intel_lvds_set_power(dev, true); |
| 113 | else |
| 114 | intel_lvds_set_power(dev, false); |
| 115 | |
| 116 | /* XXX: We never power down the LVDS pairs. */ |
| 117 | } |
| 118 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 119 | static int intel_lvds_mode_valid(struct drm_connector *connector, |
| 120 | struct drm_display_mode *mode) |
| 121 | { |
| 122 | struct drm_device *dev = connector->dev; |
| 123 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 124 | struct drm_display_mode *fixed_mode = dev_priv->panel_fixed_mode; |
| 125 | |
| 126 | if (fixed_mode) { |
| 127 | if (mode->hdisplay > fixed_mode->hdisplay) |
| 128 | return MODE_PANEL; |
| 129 | if (mode->vdisplay > fixed_mode->vdisplay) |
| 130 | return MODE_PANEL; |
| 131 | } |
| 132 | |
| 133 | return MODE_OK; |
| 134 | } |
| 135 | |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 136 | static void |
| 137 | centre_horizontally(struct drm_display_mode *mode, |
| 138 | int width) |
| 139 | { |
| 140 | u32 border, sync_pos, blank_width, sync_width; |
| 141 | |
| 142 | /* keep the hsync and hblank widths constant */ |
| 143 | sync_width = mode->crtc_hsync_end - mode->crtc_hsync_start; |
| 144 | blank_width = mode->crtc_hblank_end - mode->crtc_hblank_start; |
| 145 | sync_pos = (blank_width - sync_width + 1) / 2; |
| 146 | |
| 147 | border = (mode->hdisplay - width + 1) / 2; |
| 148 | border += border & 1; /* make the border even */ |
| 149 | |
| 150 | mode->crtc_hdisplay = width; |
| 151 | mode->crtc_hblank_start = width + border; |
| 152 | mode->crtc_hblank_end = mode->crtc_hblank_start + blank_width; |
| 153 | |
| 154 | mode->crtc_hsync_start = mode->crtc_hblank_start + sync_pos; |
| 155 | mode->crtc_hsync_end = mode->crtc_hsync_start + sync_width; |
| 156 | } |
| 157 | |
| 158 | static void |
| 159 | centre_vertically(struct drm_display_mode *mode, |
| 160 | int height) |
| 161 | { |
| 162 | u32 border, sync_pos, blank_width, sync_width; |
| 163 | |
| 164 | /* keep the vsync and vblank widths constant */ |
| 165 | sync_width = mode->crtc_vsync_end - mode->crtc_vsync_start; |
| 166 | blank_width = mode->crtc_vblank_end - mode->crtc_vblank_start; |
| 167 | sync_pos = (blank_width - sync_width + 1) / 2; |
| 168 | |
| 169 | border = (mode->vdisplay - height + 1) / 2; |
| 170 | |
| 171 | mode->crtc_vdisplay = height; |
| 172 | mode->crtc_vblank_start = height + border; |
| 173 | mode->crtc_vblank_end = mode->crtc_vblank_start + blank_width; |
| 174 | |
| 175 | mode->crtc_vsync_start = mode->crtc_vblank_start + sync_pos; |
| 176 | mode->crtc_vsync_end = mode->crtc_vsync_start + sync_width; |
| 177 | } |
| 178 | |
| 179 | static inline u32 panel_fitter_scaling(u32 source, u32 target) |
| 180 | { |
| 181 | /* |
| 182 | * Floating point operation is not supported. So the FACTOR |
| 183 | * is defined, which can avoid the floating point computation |
| 184 | * when calculating the panel ratio. |
| 185 | */ |
| 186 | #define ACCURACY 12 |
| 187 | #define FACTOR (1 << ACCURACY) |
| 188 | u32 ratio = source * FACTOR / target; |
| 189 | return (FACTOR * ratio + FACTOR/2) / FACTOR; |
| 190 | } |
| 191 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 192 | static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, |
| 193 | struct drm_display_mode *mode, |
| 194 | struct drm_display_mode *adjusted_mode) |
| 195 | { |
| 196 | struct drm_device *dev = encoder->dev; |
| 197 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 198 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 199 | struct intel_lvds *intel_lvds = enc_to_intel_lvds(encoder); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 200 | struct drm_encoder *tmp_encoder; |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 201 | u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 202 | |
| 203 | /* Should never happen!! */ |
| 204 | if (!IS_I965G(dev) && intel_crtc->pipe == 0) { |
Keith Packard | 1ae8c0a | 2009-06-28 15:42:17 -0700 | [diff] [blame] | 205 | DRM_ERROR("Can't support LVDS on pipe A\n"); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 206 | return false; |
| 207 | } |
| 208 | |
| 209 | /* Should never happen!! */ |
| 210 | list_for_each_entry(tmp_encoder, &dev->mode_config.encoder_list, head) { |
| 211 | if (tmp_encoder != encoder && tmp_encoder->crtc == encoder->crtc) { |
Keith Packard | 1ae8c0a | 2009-06-28 15:42:17 -0700 | [diff] [blame] | 212 | DRM_ERROR("Can't enable LVDS and another " |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 213 | "encoder on the same pipe\n"); |
| 214 | return false; |
| 215 | } |
| 216 | } |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 217 | /* If we don't have a panel mode, there is nothing we can do */ |
| 218 | if (dev_priv->panel_fixed_mode == NULL) |
| 219 | return true; |
Chris Wilson | 1d8e1c7 | 2010-08-07 11:01:28 +0100 | [diff] [blame] | 220 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 221 | /* |
Chris Wilson | 7167704 | 2010-07-17 13:38:43 +0100 | [diff] [blame] | 222 | * We have timings from the BIOS for the panel, put them in |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 223 | * to the adjusted mode. The CRTC will be set up for this mode, |
| 224 | * with the panel scaling set up to source from the H/VDisplay |
| 225 | * of the original mode. |
| 226 | */ |
Chris Wilson | 1d8e1c7 | 2010-08-07 11:01:28 +0100 | [diff] [blame] | 227 | intel_fixed_panel_mode(dev_priv->panel_fixed_mode, adjusted_mode); |
| 228 | |
| 229 | if (HAS_PCH_SPLIT(dev)) { |
| 230 | intel_pch_panel_fitting(dev, intel_lvds->fitting_mode, |
| 231 | mode, adjusted_mode); |
| 232 | return true; |
| 233 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 234 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 235 | /* Make sure pre-965s set dither correctly */ |
| 236 | if (!IS_I965G(dev)) { |
| 237 | if (dev_priv->panel_wants_dither || dev_priv->lvds_dither) |
| 238 | pfit_control |= PANEL_8TO6_DITHER_ENABLE; |
| 239 | } |
| 240 | |
| 241 | /* Native modes don't need fitting */ |
| 242 | if (adjusted_mode->hdisplay == mode->hdisplay && |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 243 | adjusted_mode->vdisplay == mode->vdisplay) |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 244 | goto out; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 245 | |
| 246 | /* 965+ wants fuzzy fitting */ |
| 247 | if (IS_I965G(dev)) |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 248 | pfit_control |= ((intel_crtc->pipe << PFIT_PIPE_SHIFT) | |
| 249 | PFIT_FILTER_FUZZY); |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 250 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 251 | /* |
| 252 | * Enable automatic panel scaling for non-native modes so that they fill |
| 253 | * the screen. Should be enabled before the pipe is enabled, according |
| 254 | * to register description and PRM. |
| 255 | * Change the value here to see the borders for debugging |
| 256 | */ |
Chris Wilson | 1d8e1c7 | 2010-08-07 11:01:28 +0100 | [diff] [blame] | 257 | I915_WRITE(BCLRPAT_A, 0); |
| 258 | I915_WRITE(BCLRPAT_B, 0); |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 259 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 260 | switch (intel_lvds->fitting_mode) { |
Jesse Barnes | 53bd838 | 2009-07-01 10:04:40 -0700 | [diff] [blame] | 261 | case DRM_MODE_SCALE_CENTER: |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 262 | /* |
| 263 | * For centered modes, we have to calculate border widths & |
| 264 | * heights and modify the values programmed into the CRTC. |
| 265 | */ |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 266 | centre_horizontally(adjusted_mode, mode->hdisplay); |
| 267 | centre_vertically(adjusted_mode, mode->vdisplay); |
| 268 | border = LVDS_BORDER_ENABLE; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 269 | break; |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 270 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 271 | case DRM_MODE_SCALE_ASPECT: |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 272 | /* Scale but preserve the aspect ratio */ |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 273 | if (IS_I965G(dev)) { |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 274 | u32 scaled_width = adjusted_mode->hdisplay * mode->vdisplay; |
| 275 | u32 scaled_height = mode->hdisplay * adjusted_mode->vdisplay; |
| 276 | |
| 277 | pfit_control |= PFIT_ENABLE; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 278 | /* 965+ is easy, it does everything in hw */ |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 279 | if (scaled_width > scaled_height) |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 280 | pfit_control |= PFIT_SCALING_PILLAR; |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 281 | else if (scaled_width < scaled_height) |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 282 | pfit_control |= PFIT_SCALING_LETTER; |
| 283 | else |
| 284 | pfit_control |= PFIT_SCALING_AUTO; |
| 285 | } else { |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 286 | u32 scaled_width = adjusted_mode->hdisplay * mode->vdisplay; |
| 287 | u32 scaled_height = mode->hdisplay * adjusted_mode->vdisplay; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 288 | /* |
| 289 | * For earlier chips we have to calculate the scaling |
| 290 | * ratio by hand and program it into the |
| 291 | * PFIT_PGM_RATIO register |
| 292 | */ |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 293 | if (scaled_width > scaled_height) { /* pillar */ |
| 294 | centre_horizontally(adjusted_mode, scaled_height / mode->vdisplay); |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 295 | |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 296 | border = LVDS_BORDER_ENABLE; |
| 297 | if (mode->vdisplay != adjusted_mode->vdisplay) { |
| 298 | u32 bits = panel_fitter_scaling(mode->vdisplay, adjusted_mode->vdisplay); |
| 299 | pfit_pgm_ratios |= (bits << PFIT_HORIZ_SCALE_SHIFT | |
| 300 | bits << PFIT_VERT_SCALE_SHIFT); |
| 301 | pfit_control |= (PFIT_ENABLE | |
| 302 | VERT_INTERP_BILINEAR | |
| 303 | HORIZ_INTERP_BILINEAR); |
| 304 | } |
| 305 | } else if (scaled_width < scaled_height) { /* letter */ |
| 306 | centre_vertically(adjusted_mode, scaled_width / mode->hdisplay); |
| 307 | |
| 308 | border = LVDS_BORDER_ENABLE; |
| 309 | if (mode->hdisplay != adjusted_mode->hdisplay) { |
| 310 | u32 bits = panel_fitter_scaling(mode->hdisplay, adjusted_mode->hdisplay); |
| 311 | pfit_pgm_ratios |= (bits << PFIT_HORIZ_SCALE_SHIFT | |
| 312 | bits << PFIT_VERT_SCALE_SHIFT); |
| 313 | pfit_control |= (PFIT_ENABLE | |
| 314 | VERT_INTERP_BILINEAR | |
| 315 | HORIZ_INTERP_BILINEAR); |
| 316 | } |
| 317 | } else |
| 318 | /* Aspects match, Let hw scale both directions */ |
| 319 | pfit_control |= (PFIT_ENABLE | |
| 320 | VERT_AUTO_SCALE | HORIZ_AUTO_SCALE | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 321 | VERT_INTERP_BILINEAR | |
| 322 | HORIZ_INTERP_BILINEAR); |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 323 | } |
| 324 | break; |
| 325 | |
| 326 | case DRM_MODE_SCALE_FULLSCREEN: |
| 327 | /* |
| 328 | * Full scaling, even if it changes the aspect ratio. |
| 329 | * Fortunately this is all done for us in hw. |
| 330 | */ |
| 331 | pfit_control |= PFIT_ENABLE; |
| 332 | if (IS_I965G(dev)) |
| 333 | pfit_control |= PFIT_SCALING_AUTO; |
| 334 | else |
| 335 | pfit_control |= (VERT_AUTO_SCALE | HORIZ_AUTO_SCALE | |
| 336 | VERT_INTERP_BILINEAR | |
| 337 | HORIZ_INTERP_BILINEAR); |
| 338 | break; |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 339 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 340 | default: |
| 341 | break; |
| 342 | } |
| 343 | |
| 344 | out: |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 345 | intel_lvds->pfit_control = pfit_control; |
| 346 | intel_lvds->pfit_pgm_ratios = pfit_pgm_ratios; |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 347 | dev_priv->lvds_border_bits = border; |
| 348 | |
Zhao Yakui | a3e17eb | 2009-10-10 10:42:37 +0800 | [diff] [blame] | 349 | /* |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 350 | * XXX: It would be nice to support lower refresh rates on the |
| 351 | * panels to reduce power consumption, and perhaps match the |
| 352 | * user's requested refresh rate. |
| 353 | */ |
| 354 | |
| 355 | return true; |
| 356 | } |
| 357 | |
| 358 | static void intel_lvds_prepare(struct drm_encoder *encoder) |
| 359 | { |
| 360 | struct drm_device *dev = encoder->dev; |
| 361 | struct drm_i915_private *dev_priv = dev->dev_private; |
Matthew Garrett | 309b1e3 | 2010-05-18 13:53:16 -0400 | [diff] [blame] | 362 | struct intel_lvds *intel_lvds = enc_to_intel_lvds(encoder); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 363 | |
Chris Wilson | a957355 | 2010-08-22 13:18:16 +0100 | [diff] [blame] | 364 | dev_priv->backlight_level = intel_panel_get_backlight(dev); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 365 | |
Matthew Garrett | 309b1e3 | 2010-05-18 13:53:16 -0400 | [diff] [blame] | 366 | if (intel_lvds->pfit_control == I915_READ(PFIT_CONTROL)) |
| 367 | intel_lvds_lock_panel(dev, false); |
| 368 | else |
| 369 | intel_lvds_set_power(dev, false); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | static void intel_lvds_commit( struct drm_encoder *encoder) |
| 373 | { |
| 374 | struct drm_device *dev = encoder->dev; |
| 375 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 376 | |
Chris Wilson | a957355 | 2010-08-22 13:18:16 +0100 | [diff] [blame] | 377 | if (dev_priv->backlight_level == 0) |
| 378 | dev_priv->backlight_level = intel_panel_get_max_backlight(dev); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 379 | |
Matthew Garrett | 309b1e3 | 2010-05-18 13:53:16 -0400 | [diff] [blame] | 380 | if ((I915_READ(PP_CONTROL) & PANEL_UNLOCK_REGS) == PANEL_UNLOCK_REGS) |
| 381 | intel_lvds_lock_panel(dev, true); |
| 382 | else |
| 383 | intel_lvds_set_power(dev, true); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | static void intel_lvds_mode_set(struct drm_encoder *encoder, |
| 387 | struct drm_display_mode *mode, |
| 388 | struct drm_display_mode *adjusted_mode) |
| 389 | { |
| 390 | struct drm_device *dev = encoder->dev; |
| 391 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 392 | struct intel_lvds *intel_lvds = enc_to_intel_lvds(encoder); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 393 | |
| 394 | /* |
| 395 | * The LVDS pin pair will already have been turned on in the |
| 396 | * intel_crtc_mode_set since it has a large impact on the DPLL |
| 397 | * settings. |
| 398 | */ |
| 399 | |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 400 | if (HAS_PCH_SPLIT(dev)) |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 401 | return; |
| 402 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 403 | /* |
| 404 | * Enable automatic panel scaling so that non-native modes fill the |
| 405 | * screen. Should be enabled before the pipe is enabled, according to |
| 406 | * register description and PRM. |
| 407 | */ |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 408 | I915_WRITE(PFIT_PGM_RATIOS, intel_lvds->pfit_pgm_ratios); |
| 409 | I915_WRITE(PFIT_CONTROL, intel_lvds->pfit_control); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | /** |
| 413 | * Detect the LVDS connection. |
| 414 | * |
Jesse Barnes | b42d4c5 | 2009-09-10 15:28:04 -0700 | [diff] [blame] | 415 | * Since LVDS doesn't have hotlug, we use the lid as a proxy. Open means |
| 416 | * connected and closed means disconnected. We also send hotplug events as |
| 417 | * needed, using lid status notification from the input layer. |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 418 | */ |
| 419 | static enum drm_connector_status intel_lvds_detect(struct drm_connector *connector) |
| 420 | { |
Jesse Barnes | 7b9c5ab | 2010-02-12 09:30:00 -0800 | [diff] [blame] | 421 | struct drm_device *dev = connector->dev; |
Jesse Barnes | b42d4c5 | 2009-09-10 15:28:04 -0700 | [diff] [blame] | 422 | enum drm_connector_status status = connector_status_connected; |
| 423 | |
Jesse Barnes | 7b9c5ab | 2010-02-12 09:30:00 -0800 | [diff] [blame] | 424 | /* ACPI lid methods were generally unreliable in this generation, so |
| 425 | * don't even bother. |
| 426 | */ |
Eric Anholt | 6e6c822 | 2010-03-17 13:48:06 -0700 | [diff] [blame] | 427 | if (IS_GEN2(dev) || IS_GEN3(dev)) |
Jesse Barnes | 7b9c5ab | 2010-02-12 09:30:00 -0800 | [diff] [blame] | 428 | return connector_status_connected; |
| 429 | |
Jesse Barnes | b42d4c5 | 2009-09-10 15:28:04 -0700 | [diff] [blame] | 430 | return status; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | /** |
| 434 | * Return the list of DDC modes if available, or the BIOS fixed mode otherwise. |
| 435 | */ |
| 436 | static int intel_lvds_get_modes(struct drm_connector *connector) |
| 437 | { |
| 438 | struct drm_device *dev = connector->dev; |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 439 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
Chris Wilson | 4ef69c7 | 2010-09-09 15:14:28 +0100 | [diff] [blame] | 440 | struct intel_encoder *intel_encoder = to_intel_encoder(encoder); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 441 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 442 | int ret = 0; |
| 443 | |
Zhao Yakui | bfac4d6 | 2010-04-07 17:11:22 +0800 | [diff] [blame] | 444 | if (dev_priv->lvds_edid_good) { |
Zhenyu Wang | 335af9a | 2010-03-30 14:39:31 +0800 | [diff] [blame] | 445 | ret = intel_ddc_get_modes(connector, intel_encoder->ddc_bus); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 446 | |
Zhao Yakui | bfac4d6 | 2010-04-07 17:11:22 +0800 | [diff] [blame] | 447 | if (ret) |
| 448 | return ret; |
| 449 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 450 | |
| 451 | /* Didn't get an EDID, so |
| 452 | * Set wide sync ranges so we get all modes |
| 453 | * handed to valid_mode for checking |
| 454 | */ |
| 455 | connector->display_info.min_vfreq = 0; |
| 456 | connector->display_info.max_vfreq = 200; |
| 457 | connector->display_info.min_hfreq = 0; |
| 458 | connector->display_info.max_hfreq = 200; |
| 459 | |
| 460 | if (dev_priv->panel_fixed_mode != NULL) { |
| 461 | struct drm_display_mode *mode; |
| 462 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 463 | mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); |
| 464 | drm_mode_probed_add(connector, mode); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 465 | |
| 466 | return 1; |
| 467 | } |
| 468 | |
| 469 | return 0; |
| 470 | } |
| 471 | |
Thomas Bächler | 0544edf | 2010-07-02 10:44:23 +0200 | [diff] [blame] | 472 | static int intel_no_modeset_on_lid_dmi_callback(const struct dmi_system_id *id) |
| 473 | { |
| 474 | DRM_DEBUG_KMS("Skipping forced modeset for %s\n", id->ident); |
| 475 | return 1; |
| 476 | } |
| 477 | |
| 478 | /* The GPU hangs up on these systems if modeset is performed on LID open */ |
| 479 | static const struct dmi_system_id intel_no_modeset_on_lid[] = { |
| 480 | { |
| 481 | .callback = intel_no_modeset_on_lid_dmi_callback, |
| 482 | .ident = "Toshiba Tecra A11", |
| 483 | .matches = { |
| 484 | DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), |
| 485 | DMI_MATCH(DMI_PRODUCT_NAME, "TECRA A11"), |
| 486 | }, |
| 487 | }, |
| 488 | |
| 489 | { } /* terminating entry */ |
| 490 | }; |
| 491 | |
Linus Torvalds | c9354c8 | 2009-11-02 09:29:55 -0800 | [diff] [blame] | 492 | /* |
| 493 | * Lid events. Note the use of 'modeset_on_lid': |
| 494 | * - we set it on lid close, and reset it on open |
| 495 | * - we use it as a "only once" bit (ie we ignore |
| 496 | * duplicate events where it was already properly |
| 497 | * set/reset) |
| 498 | * - the suspend/resume paths will also set it to |
| 499 | * zero, since they restore the mode ("lid open"). |
| 500 | */ |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 501 | static int intel_lid_notify(struct notifier_block *nb, unsigned long val, |
| 502 | void *unused) |
| 503 | { |
| 504 | struct drm_i915_private *dev_priv = |
| 505 | container_of(nb, struct drm_i915_private, lid_notifier); |
| 506 | struct drm_device *dev = dev_priv->dev; |
Zhao Yakui | a256537 | 2009-12-11 09:26:11 +0800 | [diff] [blame] | 507 | struct drm_connector *connector = dev_priv->int_lvds_connector; |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 508 | |
Zhao Yakui | a256537 | 2009-12-11 09:26:11 +0800 | [diff] [blame] | 509 | /* |
| 510 | * check and update the status of LVDS connector after receiving |
| 511 | * the LID nofication event. |
| 512 | */ |
| 513 | if (connector) |
| 514 | connector->status = connector->funcs->detect(connector); |
Thomas Bächler | 0544edf | 2010-07-02 10:44:23 +0200 | [diff] [blame] | 515 | /* Don't force modeset on machines where it causes a GPU lockup */ |
| 516 | if (dmi_check_system(intel_no_modeset_on_lid)) |
| 517 | return NOTIFY_OK; |
Linus Torvalds | c9354c8 | 2009-11-02 09:29:55 -0800 | [diff] [blame] | 518 | if (!acpi_lid_open()) { |
| 519 | dev_priv->modeset_on_lid = 1; |
| 520 | return NOTIFY_OK; |
Jesse Barnes | 06891e2 | 2009-09-14 10:58:48 -0700 | [diff] [blame] | 521 | } |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 522 | |
Linus Torvalds | c9354c8 | 2009-11-02 09:29:55 -0800 | [diff] [blame] | 523 | if (!dev_priv->modeset_on_lid) |
| 524 | return NOTIFY_OK; |
| 525 | |
| 526 | dev_priv->modeset_on_lid = 0; |
| 527 | |
| 528 | mutex_lock(&dev->mode_config.mutex); |
| 529 | drm_helper_resume_force_mode(dev); |
| 530 | mutex_unlock(&dev->mode_config.mutex); |
Jesse Barnes | 0632419 | 2009-09-10 15:28:05 -0700 | [diff] [blame] | 531 | |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 532 | return NOTIFY_OK; |
| 533 | } |
| 534 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 535 | /** |
| 536 | * intel_lvds_destroy - unregister and free LVDS structures |
| 537 | * @connector: connector to free |
| 538 | * |
| 539 | * Unregister the DDC bus for this connector then free the driver private |
| 540 | * structure. |
| 541 | */ |
| 542 | static void intel_lvds_destroy(struct drm_connector *connector) |
| 543 | { |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 544 | struct drm_device *dev = connector->dev; |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 545 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 546 | |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 547 | if (dev_priv->lid_notifier.notifier_call) |
| 548 | acpi_lid_notifier_unregister(&dev_priv->lid_notifier); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 549 | drm_sysfs_connector_remove(connector); |
| 550 | drm_connector_cleanup(connector); |
| 551 | kfree(connector); |
| 552 | } |
| 553 | |
Jesse Barnes | 335041e | 2009-01-22 22:22:06 +1000 | [diff] [blame] | 554 | static int intel_lvds_set_property(struct drm_connector *connector, |
| 555 | struct drm_property *property, |
| 556 | uint64_t value) |
| 557 | { |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 558 | struct drm_device *dev = connector->dev; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 559 | |
| 560 | if (property == dev->mode_config.scaling_mode_property && |
| 561 | connector->encoder) { |
| 562 | struct drm_crtc *crtc = connector->encoder->crtc; |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 563 | struct drm_encoder *encoder = connector->encoder; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 564 | struct intel_lvds *intel_lvds = enc_to_intel_lvds(encoder); |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 565 | |
Jesse Barnes | 53bd838 | 2009-07-01 10:04:40 -0700 | [diff] [blame] | 566 | if (value == DRM_MODE_SCALE_NONE) { |
| 567 | DRM_DEBUG_KMS("no scaling not supported\n"); |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 568 | return 0; |
| 569 | } |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 570 | if (intel_lvds->fitting_mode == value) { |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 571 | /* the LVDS scaling property is not changed */ |
| 572 | return 0; |
| 573 | } |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 574 | intel_lvds->fitting_mode = value; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 575 | if (crtc && crtc->enabled) { |
| 576 | /* |
| 577 | * If the CRTC is enabled, the display will be changed |
| 578 | * according to the new panel fitting mode. |
| 579 | */ |
| 580 | drm_crtc_helper_set_mode(crtc, &crtc->mode, |
| 581 | crtc->x, crtc->y, crtc->fb); |
| 582 | } |
| 583 | } |
| 584 | |
Jesse Barnes | 335041e | 2009-01-22 22:22:06 +1000 | [diff] [blame] | 585 | return 0; |
| 586 | } |
| 587 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 588 | static const struct drm_encoder_helper_funcs intel_lvds_helper_funcs = { |
| 589 | .dpms = intel_lvds_dpms, |
| 590 | .mode_fixup = intel_lvds_mode_fixup, |
| 591 | .prepare = intel_lvds_prepare, |
| 592 | .mode_set = intel_lvds_mode_set, |
| 593 | .commit = intel_lvds_commit, |
| 594 | }; |
| 595 | |
| 596 | static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = { |
| 597 | .get_modes = intel_lvds_get_modes, |
| 598 | .mode_valid = intel_lvds_mode_valid, |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 599 | .best_encoder = intel_attached_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 600 | }; |
| 601 | |
| 602 | static const struct drm_connector_funcs intel_lvds_connector_funcs = { |
Keith Packard | c9fb15f | 2009-05-30 20:42:28 -0700 | [diff] [blame] | 603 | .dpms = drm_helper_connector_dpms, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 604 | .detect = intel_lvds_detect, |
| 605 | .fill_modes = drm_helper_probe_single_connector_modes, |
Jesse Barnes | 335041e | 2009-01-22 22:22:06 +1000 | [diff] [blame] | 606 | .set_property = intel_lvds_set_property, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 607 | .destroy = intel_lvds_destroy, |
| 608 | }; |
| 609 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 610 | static const struct drm_encoder_funcs intel_lvds_enc_funcs = { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 611 | .destroy = intel_encoder_destroy, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 612 | }; |
| 613 | |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 614 | static int __init intel_no_lvds_dmi_callback(const struct dmi_system_id *id) |
| 615 | { |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 616 | DRM_DEBUG_KMS("Skipping LVDS initialization for %s\n", id->ident); |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 617 | return 1; |
| 618 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 619 | |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 620 | /* These systems claim to have LVDS, but really don't */ |
Jaswinder Singh Rajput | 93c05f2 | 2009-06-04 09:41:19 +1000 | [diff] [blame] | 621 | static const struct dmi_system_id intel_no_lvds[] = { |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 622 | { |
| 623 | .callback = intel_no_lvds_dmi_callback, |
| 624 | .ident = "Apple Mac Mini (Core series)", |
| 625 | .matches = { |
Keith Packard | 98acd46 | 2009-06-14 12:31:58 -0700 | [diff] [blame] | 626 | DMI_MATCH(DMI_SYS_VENDOR, "Apple"), |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 627 | DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"), |
| 628 | }, |
| 629 | }, |
| 630 | { |
| 631 | .callback = intel_no_lvds_dmi_callback, |
| 632 | .ident = "Apple Mac Mini (Core 2 series)", |
| 633 | .matches = { |
Keith Packard | 98acd46 | 2009-06-14 12:31:58 -0700 | [diff] [blame] | 634 | DMI_MATCH(DMI_SYS_VENDOR, "Apple"), |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 635 | DMI_MATCH(DMI_PRODUCT_NAME, "Macmini2,1"), |
| 636 | }, |
| 637 | }, |
| 638 | { |
| 639 | .callback = intel_no_lvds_dmi_callback, |
| 640 | .ident = "MSI IM-945GSE-A", |
| 641 | .matches = { |
| 642 | DMI_MATCH(DMI_SYS_VENDOR, "MSI"), |
| 643 | DMI_MATCH(DMI_PRODUCT_NAME, "A9830IMS"), |
| 644 | }, |
| 645 | }, |
| 646 | { |
| 647 | .callback = intel_no_lvds_dmi_callback, |
| 648 | .ident = "Dell Studio Hybrid", |
| 649 | .matches = { |
| 650 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 651 | DMI_MATCH(DMI_PRODUCT_NAME, "Studio Hybrid 140g"), |
| 652 | }, |
| 653 | }, |
Jarod Wilson | 70aa96c | 2009-05-27 17:20:39 -0400 | [diff] [blame] | 654 | { |
| 655 | .callback = intel_no_lvds_dmi_callback, |
| 656 | .ident = "AOpen Mini PC", |
| 657 | .matches = { |
| 658 | DMI_MATCH(DMI_SYS_VENDOR, "AOpen"), |
| 659 | DMI_MATCH(DMI_PRODUCT_NAME, "i965GMx-IF"), |
| 660 | }, |
| 661 | }, |
Michael Cousin | fa0864b | 2009-06-05 21:16:22 +0200 | [diff] [blame] | 662 | { |
| 663 | .callback = intel_no_lvds_dmi_callback, |
Tormod Volden | ed8c754 | 2009-07-13 22:26:48 +0200 | [diff] [blame] | 664 | .ident = "AOpen Mini PC MP915", |
| 665 | .matches = { |
| 666 | DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"), |
| 667 | DMI_MATCH(DMI_BOARD_NAME, "i915GMx-F"), |
| 668 | }, |
| 669 | }, |
| 670 | { |
| 671 | .callback = intel_no_lvds_dmi_callback, |
Michael Cousin | fa0864b | 2009-06-05 21:16:22 +0200 | [diff] [blame] | 672 | .ident = "Aopen i945GTt-VFA", |
| 673 | .matches = { |
| 674 | DMI_MATCH(DMI_PRODUCT_VERSION, "AO00001JW"), |
| 675 | }, |
| 676 | }, |
Stefan Bader | 9875557ee8 | 2010-03-29 17:53:12 +0200 | [diff] [blame] | 677 | { |
| 678 | .callback = intel_no_lvds_dmi_callback, |
| 679 | .ident = "Clientron U800", |
| 680 | .matches = { |
| 681 | DMI_MATCH(DMI_SYS_VENDOR, "Clientron"), |
| 682 | DMI_MATCH(DMI_PRODUCT_NAME, "U800"), |
| 683 | }, |
| 684 | }, |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 685 | |
| 686 | { } /* terminating entry */ |
| 687 | }; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 688 | |
| 689 | /** |
Zhao Yakui | 18f9ed1 | 2009-11-20 03:24:16 +0000 | [diff] [blame] | 690 | * intel_find_lvds_downclock - find the reduced downclock for LVDS in EDID |
| 691 | * @dev: drm device |
| 692 | * @connector: LVDS connector |
| 693 | * |
| 694 | * Find the reduced downclock for LVDS in EDID. |
| 695 | */ |
| 696 | static void intel_find_lvds_downclock(struct drm_device *dev, |
| 697 | struct drm_connector *connector) |
| 698 | { |
| 699 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 700 | struct drm_display_mode *scan, *panel_fixed_mode; |
| 701 | int temp_downclock; |
| 702 | |
| 703 | panel_fixed_mode = dev_priv->panel_fixed_mode; |
| 704 | temp_downclock = panel_fixed_mode->clock; |
| 705 | |
| 706 | mutex_lock(&dev->mode_config.mutex); |
| 707 | list_for_each_entry(scan, &connector->probed_modes, head) { |
| 708 | /* |
| 709 | * If one mode has the same resolution with the fixed_panel |
| 710 | * mode while they have the different refresh rate, it means |
| 711 | * that the reduced downclock is found for the LVDS. In such |
| 712 | * case we can set the different FPx0/1 to dynamically select |
| 713 | * between low and high frequency. |
| 714 | */ |
| 715 | if (scan->hdisplay == panel_fixed_mode->hdisplay && |
| 716 | scan->hsync_start == panel_fixed_mode->hsync_start && |
| 717 | scan->hsync_end == panel_fixed_mode->hsync_end && |
| 718 | scan->htotal == panel_fixed_mode->htotal && |
| 719 | scan->vdisplay == panel_fixed_mode->vdisplay && |
| 720 | scan->vsync_start == panel_fixed_mode->vsync_start && |
| 721 | scan->vsync_end == panel_fixed_mode->vsync_end && |
| 722 | scan->vtotal == panel_fixed_mode->vtotal) { |
| 723 | if (scan->clock < temp_downclock) { |
| 724 | /* |
| 725 | * The downclock is already found. But we |
| 726 | * expect to find the lower downclock. |
| 727 | */ |
| 728 | temp_downclock = scan->clock; |
| 729 | } |
| 730 | } |
| 731 | } |
| 732 | mutex_unlock(&dev->mode_config.mutex); |
Jesse Barnes | 3381434 | 2010-01-14 20:48:02 +0000 | [diff] [blame] | 733 | if (temp_downclock < panel_fixed_mode->clock && |
| 734 | i915_lvds_downclock) { |
Zhao Yakui | 18f9ed1 | 2009-11-20 03:24:16 +0000 | [diff] [blame] | 735 | /* We found the downclock for LVDS. */ |
| 736 | dev_priv->lvds_downclock_avail = 1; |
| 737 | dev_priv->lvds_downclock = temp_downclock; |
| 738 | DRM_DEBUG_KMS("LVDS downclock is found in EDID. " |
| 739 | "Normal clock %dKhz, downclock %dKhz\n", |
| 740 | panel_fixed_mode->clock, temp_downclock); |
| 741 | } |
| 742 | return; |
| 743 | } |
| 744 | |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 745 | /* |
| 746 | * Enumerate the child dev array parsed from VBT to check whether |
| 747 | * the LVDS is present. |
| 748 | * If it is present, return 1. |
| 749 | * If it is not present, return false. |
| 750 | * If no child dev is parsed from VBT, it assumes that the LVDS is present. |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 751 | */ |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 752 | static bool lvds_is_present_in_vbt(struct drm_device *dev) |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 753 | { |
| 754 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 755 | int i; |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 756 | |
| 757 | if (!dev_priv->child_dev_num) |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 758 | return true; |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 759 | |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 760 | for (i = 0; i < dev_priv->child_dev_num; i++) { |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 761 | struct child_device_config *child = dev_priv->child_dev + i; |
| 762 | |
| 763 | /* If the device type is not LFP, continue. |
| 764 | * We have to check both the new identifiers as well as the |
| 765 | * old for compatibility with some BIOSes. |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 766 | */ |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 767 | if (child->device_type != DEVICE_TYPE_INT_LFP && |
| 768 | child->device_type != DEVICE_TYPE_LFP) |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 769 | continue; |
| 770 | |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 771 | /* However, we cannot trust the BIOS writers to populate |
| 772 | * the VBT correctly. Since LVDS requires additional |
| 773 | * information from AIM blocks, a non-zero addin offset is |
| 774 | * a good indicator that the LVDS is actually present. |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 775 | */ |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 776 | if (child->addin_offset) |
| 777 | return true; |
| 778 | |
| 779 | /* But even then some BIOS writers perform some black magic |
| 780 | * and instantiate the device without reference to any |
| 781 | * additional data. Trust that if the VBT was written into |
| 782 | * the OpRegion then they have validated the LVDS's existence. |
| 783 | */ |
| 784 | if (dev_priv->opregion.vbt) |
| 785 | return true; |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 786 | } |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 787 | |
| 788 | return false; |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 789 | } |
| 790 | |
Zhao Yakui | 18f9ed1 | 2009-11-20 03:24:16 +0000 | [diff] [blame] | 791 | /** |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 792 | * intel_lvds_init - setup LVDS connectors on this device |
| 793 | * @dev: drm device |
| 794 | * |
| 795 | * Create the connector, register the LVDS DDC bus, and try to figure out what |
| 796 | * modes we can display on the LVDS panel (if present). |
| 797 | */ |
| 798 | void intel_lvds_init(struct drm_device *dev) |
| 799 | { |
| 800 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 801 | struct intel_lvds *intel_lvds; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 802 | struct intel_encoder *intel_encoder; |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 803 | struct intel_connector *intel_connector; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 804 | struct drm_connector *connector; |
| 805 | struct drm_encoder *encoder; |
| 806 | struct drm_display_mode *scan; /* *modes, *bios_mode; */ |
| 807 | struct drm_crtc *crtc; |
| 808 | u32 lvds; |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 809 | int pipe, gpio = GPIOC; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 810 | |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 811 | /* Skip init on machines we know falsely report LVDS */ |
| 812 | if (dmi_check_system(intel_no_lvds)) |
Paul Collins | 565dcd4 | 2009-02-04 23:05:41 +1300 | [diff] [blame] | 813 | return; |
Paul Collins | 565dcd4 | 2009-02-04 23:05:41 +1300 | [diff] [blame] | 814 | |
Matthew Garrett | 11ba159 | 2009-12-15 13:55:24 -0500 | [diff] [blame] | 815 | if (!lvds_is_present_in_vbt(dev)) { |
| 816 | DRM_DEBUG_KMS("LVDS is not present in VBT\n"); |
Zhao Yakui | e99da35 | 2009-06-26 09:46:18 +0800 | [diff] [blame] | 817 | return; |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 818 | } |
Zhao Yakui | e99da35 | 2009-06-26 09:46:18 +0800 | [diff] [blame] | 819 | |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 820 | if (HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 821 | if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0) |
| 822 | return; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 823 | if (dev_priv->edp_support) { |
Zhao Yakui | 28c9773 | 2009-10-09 11:39:41 +0800 | [diff] [blame] | 824 | DRM_DEBUG_KMS("disable LVDS for eDP support\n"); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 825 | return; |
| 826 | } |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 827 | gpio = PCH_GPIOC; |
| 828 | } |
| 829 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 830 | intel_lvds = kzalloc(sizeof(struct intel_lvds), GFP_KERNEL); |
| 831 | if (!intel_lvds) { |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 832 | return; |
| 833 | } |
| 834 | |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 835 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
| 836 | if (!intel_connector) { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 837 | kfree(intel_lvds); |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 838 | return; |
| 839 | } |
| 840 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 841 | intel_encoder = &intel_lvds->base; |
Chris Wilson | 4ef69c7 | 2010-09-09 15:14:28 +0100 | [diff] [blame] | 842 | encoder = &intel_encoder->base; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 843 | connector = &intel_connector->base; |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 844 | drm_connector_init(dev, &intel_connector->base, &intel_lvds_connector_funcs, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 845 | DRM_MODE_CONNECTOR_LVDS); |
| 846 | |
Chris Wilson | 4ef69c7 | 2010-09-09 15:14:28 +0100 | [diff] [blame] | 847 | drm_encoder_init(dev, &intel_encoder->base, &intel_lvds_enc_funcs, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 848 | DRM_MODE_ENCODER_LVDS); |
| 849 | |
Chris Wilson | 4ef69c7 | 2010-09-09 15:14:28 +0100 | [diff] [blame] | 850 | drm_mode_connector_attach_encoder(&intel_connector->base, &intel_encoder->base); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 851 | intel_encoder->type = INTEL_OUTPUT_LVDS; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 852 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 853 | intel_encoder->clone_mask = (1 << INTEL_LVDS_CLONE_BIT); |
| 854 | intel_encoder->crtc_mask = (1 << 1); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 855 | drm_encoder_helper_add(encoder, &intel_lvds_helper_funcs); |
| 856 | drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs); |
| 857 | connector->display_info.subpixel_order = SubPixelHorizontalRGB; |
| 858 | connector->interlace_allowed = false; |
| 859 | connector->doublescan_allowed = false; |
| 860 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 861 | /* create the scaling mode property */ |
| 862 | drm_mode_create_scaling_mode_property(dev); |
| 863 | /* |
| 864 | * the initial panel fitting mode will be FULL_SCREEN. |
| 865 | */ |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 866 | |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 867 | drm_connector_attach_property(&intel_connector->base, |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 868 | dev->mode_config.scaling_mode_property, |
Jesse Barnes | dd1ea37 | 2010-06-24 11:05:10 -0700 | [diff] [blame] | 869 | DRM_MODE_SCALE_ASPECT); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 870 | intel_lvds->fitting_mode = DRM_MODE_SCALE_ASPECT; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 871 | /* |
| 872 | * LVDS discovery: |
| 873 | * 1) check for EDID on DDC |
| 874 | * 2) check for VBT data |
| 875 | * 3) check to see if LVDS is already on |
| 876 | * if none of the above, no panel |
| 877 | * 4) make sure lid is open |
| 878 | * if closed, act like it's not there for now |
| 879 | */ |
| 880 | |
| 881 | /* Set up the DDC bus. */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 882 | intel_encoder->ddc_bus = intel_i2c_create(dev, gpio, "LVDSDDC_C"); |
| 883 | if (!intel_encoder->ddc_bus) { |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 884 | dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " |
| 885 | "failed.\n"); |
| 886 | goto failed; |
| 887 | } |
| 888 | |
| 889 | /* |
| 890 | * Attempt to get the fixed panel mode from DDC. Assume that the |
| 891 | * preferred mode is the right one. |
| 892 | */ |
Zhao Yakui | bfac4d6 | 2010-04-07 17:11:22 +0800 | [diff] [blame] | 893 | dev_priv->lvds_edid_good = true; |
| 894 | |
Zhenyu Wang | 335af9a | 2010-03-30 14:39:31 +0800 | [diff] [blame] | 895 | if (!intel_ddc_get_modes(connector, intel_encoder->ddc_bus)) |
Zhao Yakui | bfac4d6 | 2010-04-07 17:11:22 +0800 | [diff] [blame] | 896 | dev_priv->lvds_edid_good = false; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 897 | |
| 898 | list_for_each_entry(scan, &connector->probed_modes, head) { |
| 899 | mutex_lock(&dev->mode_config.mutex); |
| 900 | if (scan->type & DRM_MODE_TYPE_PREFERRED) { |
| 901 | dev_priv->panel_fixed_mode = |
| 902 | drm_mode_duplicate(dev, scan); |
| 903 | mutex_unlock(&dev->mode_config.mutex); |
Zhao Yakui | 18f9ed1 | 2009-11-20 03:24:16 +0000 | [diff] [blame] | 904 | intel_find_lvds_downclock(dev, connector); |
Paul Collins | 565dcd4 | 2009-02-04 23:05:41 +1300 | [diff] [blame] | 905 | goto out; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 906 | } |
| 907 | mutex_unlock(&dev->mode_config.mutex); |
| 908 | } |
| 909 | |
| 910 | /* Failed to get EDID, what about VBT? */ |
Ma Ling | 8863170 | 2009-05-13 11:19:55 +0800 | [diff] [blame] | 911 | if (dev_priv->lfp_lvds_vbt_mode) { |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 912 | mutex_lock(&dev->mode_config.mutex); |
| 913 | dev_priv->panel_fixed_mode = |
Ma Ling | 8863170 | 2009-05-13 11:19:55 +0800 | [diff] [blame] | 914 | drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 915 | mutex_unlock(&dev->mode_config.mutex); |
Jesse Barnes | e285f3c | 2009-01-14 10:53:36 -0800 | [diff] [blame] | 916 | if (dev_priv->panel_fixed_mode) { |
| 917 | dev_priv->panel_fixed_mode->type |= |
| 918 | DRM_MODE_TYPE_PREFERRED; |
Jesse Barnes | e285f3c | 2009-01-14 10:53:36 -0800 | [diff] [blame] | 919 | goto out; |
| 920 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 921 | } |
| 922 | |
| 923 | /* |
| 924 | * If we didn't get EDID, try checking if the panel is already turned |
| 925 | * on. If so, assume that whatever is currently programmed is the |
| 926 | * correct mode. |
| 927 | */ |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 928 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 929 | /* Ironlake: FIXME if still fail, not try pipe mode now */ |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 930 | if (HAS_PCH_SPLIT(dev)) |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 931 | goto failed; |
| 932 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 933 | lvds = I915_READ(LVDS); |
| 934 | pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0; |
Chris Wilson | f875c15 | 2010-09-09 15:44:14 +0100 | [diff] [blame^] | 935 | crtc = intel_get_crtc_for_pipe(dev, pipe); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 936 | |
| 937 | if (crtc && (lvds & LVDS_PORT_EN)) { |
| 938 | dev_priv->panel_fixed_mode = intel_crtc_mode_get(dev, crtc); |
| 939 | if (dev_priv->panel_fixed_mode) { |
| 940 | dev_priv->panel_fixed_mode->type |= |
| 941 | DRM_MODE_TYPE_PREFERRED; |
Paul Collins | 565dcd4 | 2009-02-04 23:05:41 +1300 | [diff] [blame] | 942 | goto out; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 943 | } |
| 944 | } |
| 945 | |
| 946 | /* If we still don't have a mode after all that, give up. */ |
| 947 | if (!dev_priv->panel_fixed_mode) |
| 948 | goto failed; |
| 949 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 950 | out: |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 951 | if (HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 952 | u32 pwm; |
| 953 | /* make sure PWM is enabled */ |
| 954 | pwm = I915_READ(BLC_PWM_CPU_CTL2); |
| 955 | pwm |= (PWM_ENABLE | PWM_PIPE_B); |
| 956 | I915_WRITE(BLC_PWM_CPU_CTL2, pwm); |
| 957 | |
| 958 | pwm = I915_READ(BLC_PWM_PCH_CTL1); |
| 959 | pwm |= PWM_PCH_ENABLE; |
| 960 | I915_WRITE(BLC_PWM_PCH_CTL1, pwm); |
| 961 | } |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 962 | dev_priv->lid_notifier.notifier_call = intel_lid_notify; |
| 963 | if (acpi_lid_notifier_register(&dev_priv->lid_notifier)) { |
Zhao Yakui | 28c9773 | 2009-10-09 11:39:41 +0800 | [diff] [blame] | 964 | DRM_DEBUG_KMS("lid notifier registration failed\n"); |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 965 | dev_priv->lid_notifier.notifier_call = NULL; |
| 966 | } |
Zhao Yakui | a256537 | 2009-12-11 09:26:11 +0800 | [diff] [blame] | 967 | /* keep the LVDS connector */ |
| 968 | dev_priv->int_lvds_connector = connector; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 969 | drm_sysfs_connector_add(connector); |
| 970 | return; |
| 971 | |
| 972 | failed: |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 973 | DRM_DEBUG_KMS("No LVDS modes found, disabling.\n"); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 974 | if (intel_encoder->ddc_bus) |
| 975 | intel_i2c_destroy(intel_encoder->ddc_bus); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 976 | drm_connector_cleanup(connector); |
Shaohua Li | 1991bdf | 2009-11-17 17:19:23 +0800 | [diff] [blame] | 977 | drm_encoder_cleanup(encoder); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 978 | kfree(intel_lvds); |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 979 | kfree(intel_connector); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 980 | } |