Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2006 Dave Airlie <airlied@linux.ie> |
| 3 | * Copyright © 2006-2009 Intel Corporation |
| 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 | * Jesse Barnes <jesse.barnes@intel.com> |
| 27 | */ |
| 28 | |
| 29 | #include <linux/i2c.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 30 | #include <linux/slab.h> |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 31 | #include <linux/delay.h> |
| 32 | #include "drmP.h" |
| 33 | #include "drm.h" |
| 34 | #include "drm_crtc.h" |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 35 | #include "drm_edid.h" |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 36 | #include "intel_drv.h" |
| 37 | #include "i915_drm.h" |
| 38 | #include "i915_drv.h" |
| 39 | |
Eugeni Dodonov | f5bbfca | 2012-05-09 15:37:30 -0300 | [diff] [blame] | 40 | struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder) |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 41 | { |
Chris Wilson | 4ef69c7 | 2010-09-09 15:14:28 +0100 | [diff] [blame] | 42 | return container_of(encoder, struct intel_hdmi, base.base); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 43 | } |
| 44 | |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 45 | static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector) |
| 46 | { |
| 47 | return container_of(intel_attached_encoder(connector), |
| 48 | struct intel_hdmi, base); |
| 49 | } |
| 50 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 51 | void intel_dip_infoframe_csum(struct dip_infoframe *frame) |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 52 | { |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 53 | uint8_t *data = (uint8_t *)frame; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 54 | uint8_t sum = 0; |
| 55 | unsigned i; |
| 56 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 57 | frame->checksum = 0; |
| 58 | frame->ecc = 0; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 59 | |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 60 | for (i = 0; i < frame->len + DIP_HEADER_SIZE; i++) |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 61 | sum += data[i]; |
| 62 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 63 | frame->checksum = 0x100 - sum; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 64 | } |
| 65 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 66 | static u32 g4x_infoframe_index(struct dip_infoframe *frame) |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 67 | { |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 68 | switch (frame->type) { |
| 69 | case DIP_TYPE_AVI: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 70 | return VIDEO_DIP_SELECT_AVI; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 71 | case DIP_TYPE_SPD: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 72 | return VIDEO_DIP_SELECT_SPD; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 73 | default: |
| 74 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type); |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 75 | return 0; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 76 | } |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 77 | } |
| 78 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 79 | static u32 g4x_infoframe_enable(struct dip_infoframe *frame) |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 80 | { |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 81 | switch (frame->type) { |
| 82 | case DIP_TYPE_AVI: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 83 | return VIDEO_DIP_ENABLE_AVI; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 84 | case DIP_TYPE_SPD: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 85 | return VIDEO_DIP_ENABLE_SPD; |
Paulo Zanoni | fa193ff | 2012-05-04 17:18:20 -0300 | [diff] [blame] | 86 | default: |
| 87 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type); |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 88 | return 0; |
Paulo Zanoni | fa193ff | 2012-05-04 17:18:20 -0300 | [diff] [blame] | 89 | } |
Paulo Zanoni | fa193ff | 2012-05-04 17:18:20 -0300 | [diff] [blame] | 90 | } |
| 91 | |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 92 | static u32 hsw_infoframe_enable(struct dip_infoframe *frame) |
| 93 | { |
| 94 | switch (frame->type) { |
| 95 | case DIP_TYPE_AVI: |
| 96 | return VIDEO_DIP_ENABLE_AVI_HSW; |
| 97 | case DIP_TYPE_SPD: |
| 98 | return VIDEO_DIP_ENABLE_SPD_HSW; |
| 99 | default: |
| 100 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type); |
| 101 | return 0; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | static u32 hsw_infoframe_data_reg(struct dip_infoframe *frame, enum pipe pipe) |
| 106 | { |
| 107 | switch (frame->type) { |
| 108 | case DIP_TYPE_AVI: |
| 109 | return HSW_TVIDEO_DIP_AVI_DATA(pipe); |
| 110 | case DIP_TYPE_SPD: |
| 111 | return HSW_TVIDEO_DIP_SPD_DATA(pipe); |
| 112 | default: |
| 113 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type); |
| 114 | return 0; |
| 115 | } |
| 116 | } |
| 117 | |
Daniel Vetter | a3da1df | 2012-05-08 15:19:06 +0200 | [diff] [blame] | 118 | static void g4x_write_infoframe(struct drm_encoder *encoder, |
| 119 | struct dip_infoframe *frame) |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 120 | { |
| 121 | uint32_t *data = (uint32_t *)frame; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 122 | struct drm_device *dev = encoder->dev; |
| 123 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 124 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 125 | u32 val = I915_READ(VIDEO_DIP_CTL); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 126 | unsigned i, len = DIP_HEADER_SIZE + frame->len; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 127 | |
Paulo Zanoni | 3e6e639 | 2012-05-04 17:18:19 -0300 | [diff] [blame] | 128 | val &= ~VIDEO_DIP_PORT_MASK; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 129 | if (intel_hdmi->sdvox_reg == SDVOB) |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 130 | val |= VIDEO_DIP_PORT_B; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 131 | else if (intel_hdmi->sdvox_reg == SDVOC) |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 132 | val |= VIDEO_DIP_PORT_C; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 133 | else |
| 134 | return; |
| 135 | |
Paulo Zanoni | 1d4f85a | 2012-05-04 17:18:18 -0300 | [diff] [blame] | 136 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 137 | val |= g4x_infoframe_index(frame); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 138 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 139 | val &= ~g4x_infoframe_enable(frame); |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 140 | val |= VIDEO_DIP_ENABLE; |
| 141 | |
| 142 | I915_WRITE(VIDEO_DIP_CTL, val); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 143 | |
| 144 | for (i = 0; i < len; i += 4) { |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 145 | I915_WRITE(VIDEO_DIP_DATA, *data); |
| 146 | data++; |
| 147 | } |
| 148 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 149 | val |= g4x_infoframe_enable(frame); |
Paulo Zanoni | 60c5ea2 | 2012-05-04 17:18:22 -0300 | [diff] [blame] | 150 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 151 | val |= VIDEO_DIP_FREQ_VSYNC; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 152 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 153 | I915_WRITE(VIDEO_DIP_CTL, val); |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 154 | } |
| 155 | |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 156 | static void ibx_write_infoframe(struct drm_encoder *encoder, |
| 157 | struct dip_infoframe *frame) |
| 158 | { |
| 159 | uint32_t *data = (uint32_t *)frame; |
| 160 | struct drm_device *dev = encoder->dev; |
| 161 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 162 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
Paulo Zanoni | 4e89ee1 | 2012-05-04 17:18:26 -0300 | [diff] [blame] | 163 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 164 | int reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 165 | unsigned i, len = DIP_HEADER_SIZE + frame->len; |
| 166 | u32 val = I915_READ(reg); |
| 167 | |
Paulo Zanoni | 4e89ee1 | 2012-05-04 17:18:26 -0300 | [diff] [blame] | 168 | val &= ~VIDEO_DIP_PORT_MASK; |
| 169 | switch (intel_hdmi->sdvox_reg) { |
| 170 | case HDMIB: |
| 171 | val |= VIDEO_DIP_PORT_B; |
| 172 | break; |
| 173 | case HDMIC: |
| 174 | val |= VIDEO_DIP_PORT_C; |
| 175 | break; |
| 176 | case HDMID: |
| 177 | val |= VIDEO_DIP_PORT_D; |
| 178 | break; |
| 179 | default: |
| 180 | return; |
| 181 | } |
| 182 | |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 183 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
| 184 | |
| 185 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 186 | val |= g4x_infoframe_index(frame); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 187 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 188 | val &= ~g4x_infoframe_enable(frame); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 189 | val |= VIDEO_DIP_ENABLE; |
| 190 | |
| 191 | I915_WRITE(reg, val); |
| 192 | |
| 193 | for (i = 0; i < len; i += 4) { |
| 194 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
| 195 | data++; |
| 196 | } |
| 197 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 198 | val |= g4x_infoframe_enable(frame); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 199 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 200 | val |= VIDEO_DIP_FREQ_VSYNC; |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 201 | |
| 202 | I915_WRITE(reg, val); |
| 203 | } |
| 204 | |
| 205 | static void cpt_write_infoframe(struct drm_encoder *encoder, |
| 206 | struct dip_infoframe *frame) |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 207 | { |
| 208 | uint32_t *data = (uint32_t *)frame; |
| 209 | struct drm_device *dev = encoder->dev; |
| 210 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 211 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 212 | int reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 213 | unsigned i, len = DIP_HEADER_SIZE + frame->len; |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 214 | u32 val = I915_READ(reg); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 215 | |
| 216 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
| 217 | |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 218 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 219 | val |= g4x_infoframe_index(frame); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 220 | |
Paulo Zanoni | ecb9785 | 2012-05-04 17:18:21 -0300 | [diff] [blame] | 221 | /* The DIP control register spec says that we need to update the AVI |
| 222 | * infoframe without clearing its enable bit */ |
| 223 | if (frame->type == DIP_TYPE_AVI) |
| 224 | val |= VIDEO_DIP_ENABLE_AVI; |
| 225 | else |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 226 | val &= ~g4x_infoframe_enable(frame); |
Paulo Zanoni | ecb9785 | 2012-05-04 17:18:21 -0300 | [diff] [blame] | 227 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 228 | val |= VIDEO_DIP_ENABLE; |
| 229 | |
| 230 | I915_WRITE(reg, val); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 231 | |
| 232 | for (i = 0; i < len; i += 4) { |
| 233 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
| 234 | data++; |
| 235 | } |
| 236 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 237 | val |= g4x_infoframe_enable(frame); |
Paulo Zanoni | 60c5ea2 | 2012-05-04 17:18:22 -0300 | [diff] [blame] | 238 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 239 | val |= VIDEO_DIP_FREQ_VSYNC; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 240 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 241 | I915_WRITE(reg, val); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 242 | } |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 243 | |
| 244 | static void vlv_write_infoframe(struct drm_encoder *encoder, |
| 245 | struct dip_infoframe *frame) |
| 246 | { |
| 247 | uint32_t *data = (uint32_t *)frame; |
| 248 | struct drm_device *dev = encoder->dev; |
| 249 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 250 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 251 | int reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 252 | unsigned i, len = DIP_HEADER_SIZE + frame->len; |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 253 | u32 val = I915_READ(reg); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 254 | |
| 255 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
| 256 | |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 257 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 258 | val |= g4x_infoframe_index(frame); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 259 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 260 | val &= ~g4x_infoframe_enable(frame); |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 261 | val |= VIDEO_DIP_ENABLE; |
| 262 | |
| 263 | I915_WRITE(reg, val); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 264 | |
| 265 | for (i = 0; i < len; i += 4) { |
| 266 | I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
| 267 | data++; |
| 268 | } |
| 269 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 270 | val |= g4x_infoframe_enable(frame); |
Paulo Zanoni | 60c5ea2 | 2012-05-04 17:18:22 -0300 | [diff] [blame] | 271 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 272 | val |= VIDEO_DIP_FREQ_VSYNC; |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 273 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 274 | I915_WRITE(reg, val); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 277 | static void hsw_write_infoframe(struct drm_encoder *encoder, |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 278 | struct dip_infoframe *frame) |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 279 | { |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 280 | uint32_t *data = (uint32_t *)frame; |
| 281 | struct drm_device *dev = encoder->dev; |
| 282 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 283 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
| 284 | u32 ctl_reg = HSW_TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 285 | u32 data_reg = hsw_infoframe_data_reg(frame, intel_crtc->pipe); |
| 286 | unsigned int i, len = DIP_HEADER_SIZE + frame->len; |
| 287 | u32 val = I915_READ(ctl_reg); |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 288 | |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 289 | if (data_reg == 0) |
| 290 | return; |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 291 | |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 292 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
| 293 | |
| 294 | val &= ~hsw_infoframe_enable(frame); |
| 295 | I915_WRITE(ctl_reg, val); |
| 296 | |
| 297 | for (i = 0; i < len; i += 4) { |
| 298 | I915_WRITE(data_reg + i, *data); |
| 299 | data++; |
| 300 | } |
| 301 | |
| 302 | val |= hsw_infoframe_enable(frame); |
| 303 | I915_WRITE(ctl_reg, val); |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 304 | } |
| 305 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 306 | static void intel_set_infoframe(struct drm_encoder *encoder, |
| 307 | struct dip_infoframe *frame) |
| 308 | { |
| 309 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
| 310 | |
| 311 | if (!intel_hdmi->has_hdmi_sink) |
| 312 | return; |
| 313 | |
| 314 | intel_dip_infoframe_csum(frame); |
| 315 | intel_hdmi->write_infoframe(encoder, frame); |
| 316 | } |
| 317 | |
Eugeni Dodonov | f5bbfca | 2012-05-09 15:37:30 -0300 | [diff] [blame] | 318 | void intel_hdmi_set_avi_infoframe(struct drm_encoder *encoder, |
Paulo Zanoni | c846b61 | 2012-04-13 16:31:41 -0300 | [diff] [blame] | 319 | struct drm_display_mode *adjusted_mode) |
Jesse Barnes | b055c8f | 2011-07-08 11:31:57 -0700 | [diff] [blame] | 320 | { |
| 321 | struct dip_infoframe avi_if = { |
| 322 | .type = DIP_TYPE_AVI, |
| 323 | .ver = DIP_VERSION_AVI, |
| 324 | .len = DIP_LEN_AVI, |
| 325 | }; |
Jesse Barnes | b055c8f | 2011-07-08 11:31:57 -0700 | [diff] [blame] | 326 | |
Paulo Zanoni | c846b61 | 2012-04-13 16:31:41 -0300 | [diff] [blame] | 327 | if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) |
| 328 | avi_if.body.avi.YQ_CN_PR |= DIP_AVI_PR_2; |
| 329 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 330 | intel_set_infoframe(encoder, &avi_if); |
Jesse Barnes | b055c8f | 2011-07-08 11:31:57 -0700 | [diff] [blame] | 331 | } |
| 332 | |
Eugeni Dodonov | f5bbfca | 2012-05-09 15:37:30 -0300 | [diff] [blame] | 333 | void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder) |
Jesse Barnes | c0864cb | 2011-08-03 09:22:56 -0700 | [diff] [blame] | 334 | { |
| 335 | struct dip_infoframe spd_if; |
| 336 | |
| 337 | memset(&spd_if, 0, sizeof(spd_if)); |
| 338 | spd_if.type = DIP_TYPE_SPD; |
| 339 | spd_if.ver = DIP_VERSION_SPD; |
| 340 | spd_if.len = DIP_LEN_SPD; |
| 341 | strcpy(spd_if.body.spd.vn, "Intel"); |
| 342 | strcpy(spd_if.body.spd.pd, "Integrated gfx"); |
| 343 | spd_if.body.spd.sdi = DIP_SPD_PC; |
| 344 | |
| 345 | intel_set_infoframe(encoder, &spd_if); |
| 346 | } |
| 347 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 348 | static void intel_hdmi_mode_set(struct drm_encoder *encoder, |
| 349 | struct drm_display_mode *mode, |
| 350 | struct drm_display_mode *adjusted_mode) |
| 351 | { |
| 352 | struct drm_device *dev = encoder->dev; |
| 353 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 354 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 355 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 356 | u32 sdvox; |
| 357 | |
Adam Jackson | b599c0b | 2010-07-16 14:46:31 -0400 | [diff] [blame] | 358 | sdvox = SDVO_ENCODING_HDMI | SDVO_BORDER_ENABLE; |
Jesse Barnes | 5d4fac9 | 2011-06-24 12:19:19 -0700 | [diff] [blame] | 359 | if (!HAS_PCH_SPLIT(dev)) |
| 360 | sdvox |= intel_hdmi->color_range; |
Adam Jackson | b599c0b | 2010-07-16 14:46:31 -0400 | [diff] [blame] | 361 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
| 362 | sdvox |= SDVO_VSYNC_ACTIVE_HIGH; |
| 363 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
| 364 | sdvox |= SDVO_HSYNC_ACTIVE_HIGH; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 365 | |
Jesse Barnes | 020f670 | 2011-06-24 12:19:25 -0700 | [diff] [blame] | 366 | if (intel_crtc->bpp > 24) |
| 367 | sdvox |= COLOR_FORMAT_12bpc; |
| 368 | else |
| 369 | sdvox |= COLOR_FORMAT_8bpc; |
| 370 | |
Zhenyu Wang | 2e3d600 | 2010-09-10 10:39:40 +0800 | [diff] [blame] | 371 | /* Required on CPT */ |
| 372 | if (intel_hdmi->has_hdmi_sink && HAS_PCH_CPT(dev)) |
| 373 | sdvox |= HDMI_MODE_SELECT; |
| 374 | |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 375 | if (intel_hdmi->has_audio) { |
Wu Fengguang | e0dac65 | 2011-09-05 14:25:34 +0800 | [diff] [blame] | 376 | DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n", |
| 377 | pipe_name(intel_crtc->pipe)); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 378 | sdvox |= SDVO_AUDIO_ENABLE; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 379 | sdvox |= SDVO_NULL_PACKETS_DURING_VSYNC; |
Wu Fengguang | e0dac65 | 2011-09-05 14:25:34 +0800 | [diff] [blame] | 380 | intel_write_eld(encoder, adjusted_mode); |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 381 | } |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 382 | |
Jesse Barnes | 7577056 | 2011-10-12 09:01:58 -0700 | [diff] [blame] | 383 | if (HAS_PCH_CPT(dev)) |
| 384 | sdvox |= PORT_TRANS_SEL_CPT(intel_crtc->pipe); |
| 385 | else if (intel_crtc->pipe == 1) |
| 386 | sdvox |= SDVO_PIPE_B_SELECT; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 387 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 388 | I915_WRITE(intel_hdmi->sdvox_reg, sdvox); |
| 389 | POSTING_READ(intel_hdmi->sdvox_reg); |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 390 | |
Paulo Zanoni | c846b61 | 2012-04-13 16:31:41 -0300 | [diff] [blame] | 391 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
Jesse Barnes | c0864cb | 2011-08-03 09:22:56 -0700 | [diff] [blame] | 392 | intel_hdmi_set_spd_infoframe(encoder); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | static void intel_hdmi_dpms(struct drm_encoder *encoder, int mode) |
| 396 | { |
| 397 | struct drm_device *dev = encoder->dev; |
| 398 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 399 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 400 | u32 temp; |
Wu Fengguang | 2deed76 | 2011-12-09 20:42:20 +0800 | [diff] [blame] | 401 | u32 enable_bits = SDVO_ENABLE; |
| 402 | |
| 403 | if (intel_hdmi->has_audio) |
| 404 | enable_bits |= SDVO_AUDIO_ENABLE; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 405 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 406 | temp = I915_READ(intel_hdmi->sdvox_reg); |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 407 | |
| 408 | /* HW workaround, need to toggle enable bit off and on for 12bpc, but |
| 409 | * we do this anyway which shows more stable in testing. |
| 410 | */ |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 411 | if (HAS_PCH_SPLIT(dev)) { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 412 | I915_WRITE(intel_hdmi->sdvox_reg, temp & ~SDVO_ENABLE); |
| 413 | POSTING_READ(intel_hdmi->sdvox_reg); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 414 | } |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 415 | |
| 416 | if (mode != DRM_MODE_DPMS_ON) { |
Wu Fengguang | 2deed76 | 2011-12-09 20:42:20 +0800 | [diff] [blame] | 417 | temp &= ~enable_bits; |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 418 | } else { |
Wu Fengguang | 2deed76 | 2011-12-09 20:42:20 +0800 | [diff] [blame] | 419 | temp |= enable_bits; |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 420 | } |
| 421 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 422 | I915_WRITE(intel_hdmi->sdvox_reg, temp); |
| 423 | POSTING_READ(intel_hdmi->sdvox_reg); |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 424 | |
| 425 | /* HW workaround, need to write this twice for issue that may result |
| 426 | * in first write getting masked. |
| 427 | */ |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 428 | if (HAS_PCH_SPLIT(dev)) { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 429 | I915_WRITE(intel_hdmi->sdvox_reg, temp); |
| 430 | POSTING_READ(intel_hdmi->sdvox_reg); |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 431 | } |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 432 | } |
| 433 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 434 | static int intel_hdmi_mode_valid(struct drm_connector *connector, |
| 435 | struct drm_display_mode *mode) |
| 436 | { |
| 437 | if (mode->clock > 165000) |
| 438 | return MODE_CLOCK_HIGH; |
| 439 | if (mode->clock < 20000) |
Nicolas Kaiser | 5cbba41 | 2011-05-30 12:48:26 +0200 | [diff] [blame] | 440 | return MODE_CLOCK_LOW; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 441 | |
| 442 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
| 443 | return MODE_NO_DBLESCAN; |
| 444 | |
| 445 | return MODE_OK; |
| 446 | } |
| 447 | |
| 448 | static bool intel_hdmi_mode_fixup(struct drm_encoder *encoder, |
| 449 | struct drm_display_mode *mode, |
| 450 | struct drm_display_mode *adjusted_mode) |
| 451 | { |
| 452 | return true; |
| 453 | } |
| 454 | |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 455 | static bool g4x_hdmi_connected(struct intel_hdmi *intel_hdmi) |
| 456 | { |
| 457 | struct drm_device *dev = intel_hdmi->base.base.dev; |
| 458 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 459 | uint32_t bit; |
| 460 | |
| 461 | switch (intel_hdmi->sdvox_reg) { |
Chris Wilson | eeafaac | 2012-05-25 10:23:37 +0100 | [diff] [blame^] | 462 | case SDVOB: |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 463 | bit = HDMIB_HOTPLUG_LIVE_STATUS; |
| 464 | break; |
Chris Wilson | eeafaac | 2012-05-25 10:23:37 +0100 | [diff] [blame^] | 465 | case SDVOC: |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 466 | bit = HDMIC_HOTPLUG_LIVE_STATUS; |
| 467 | break; |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 468 | default: |
| 469 | bit = 0; |
| 470 | break; |
| 471 | } |
| 472 | |
| 473 | return I915_READ(PORT_HOTPLUG_STAT) & bit; |
| 474 | } |
| 475 | |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 476 | static enum drm_connector_status |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 477 | intel_hdmi_detect(struct drm_connector *connector, bool force) |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 478 | { |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 479 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 480 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
| 481 | struct edid *edid; |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 482 | enum drm_connector_status status = connector_status_disconnected; |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 483 | |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 484 | if (IS_G4X(connector->dev) && !g4x_hdmi_connected(intel_hdmi)) |
| 485 | return status; |
| 486 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 487 | intel_hdmi->has_hdmi_sink = false; |
Zhenyu Wang | 2e3d600 | 2010-09-10 10:39:40 +0800 | [diff] [blame] | 488 | intel_hdmi->has_audio = false; |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 489 | edid = drm_get_edid(connector, |
Daniel Kurtz | 3bd7d90 | 2012-03-28 02:36:14 +0800 | [diff] [blame] | 490 | intel_gmbus_get_adapter(dev_priv, |
| 491 | intel_hdmi->ddc_bus)); |
ling.ma@intel.com | 2ded9e2 | 2009-07-16 17:23:09 +0800 | [diff] [blame] | 492 | |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 493 | if (edid) { |
Eric Anholt | be9f1c4 | 2009-06-21 22:14:55 -0700 | [diff] [blame] | 494 | if (edid->input & DRM_EDID_INPUT_DIGITAL) { |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 495 | status = connector_status_connected; |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 496 | if (intel_hdmi->force_audio != HDMI_AUDIO_OFF_DVI) |
| 497 | intel_hdmi->has_hdmi_sink = |
| 498 | drm_detect_hdmi_monitor(edid); |
Zhenyu Wang | 2e3d600 | 2010-09-10 10:39:40 +0800 | [diff] [blame] | 499 | intel_hdmi->has_audio = drm_detect_monitor_audio(edid); |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 500 | } |
Zhenyu Wang | 674e2d0 | 2010-03-29 15:57:42 +0800 | [diff] [blame] | 501 | connector->display_info.raw_edid = NULL; |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 502 | kfree(edid); |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 503 | } |
ling.ma@intel.com | 2ded9e2 | 2009-07-16 17:23:09 +0800 | [diff] [blame] | 504 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 505 | if (status == connector_status_connected) { |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 506 | if (intel_hdmi->force_audio != HDMI_AUDIO_AUTO) |
| 507 | intel_hdmi->has_audio = |
| 508 | (intel_hdmi->force_audio == HDMI_AUDIO_ON); |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 509 | } |
| 510 | |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 511 | return status; |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 512 | } |
| 513 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 514 | static int intel_hdmi_get_modes(struct drm_connector *connector) |
| 515 | { |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 516 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 517 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 518 | |
| 519 | /* We should parse the EDID data and find out if it's an HDMI sink so |
| 520 | * we can send audio to it. |
| 521 | */ |
| 522 | |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 523 | return intel_ddc_get_modes(connector, |
Daniel Kurtz | 3bd7d90 | 2012-03-28 02:36:14 +0800 | [diff] [blame] | 524 | intel_gmbus_get_adapter(dev_priv, |
| 525 | intel_hdmi->ddc_bus)); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 526 | } |
| 527 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 528 | static bool |
| 529 | intel_hdmi_detect_audio(struct drm_connector *connector) |
| 530 | { |
| 531 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
| 532 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
| 533 | struct edid *edid; |
| 534 | bool has_audio = false; |
| 535 | |
| 536 | edid = drm_get_edid(connector, |
Daniel Kurtz | 3bd7d90 | 2012-03-28 02:36:14 +0800 | [diff] [blame] | 537 | intel_gmbus_get_adapter(dev_priv, |
| 538 | intel_hdmi->ddc_bus)); |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 539 | if (edid) { |
| 540 | if (edid->input & DRM_EDID_INPUT_DIGITAL) |
| 541 | has_audio = drm_detect_monitor_audio(edid); |
| 542 | |
| 543 | connector->display_info.raw_edid = NULL; |
| 544 | kfree(edid); |
| 545 | } |
| 546 | |
| 547 | return has_audio; |
| 548 | } |
| 549 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 550 | static int |
| 551 | intel_hdmi_set_property(struct drm_connector *connector, |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 552 | struct drm_property *property, |
| 553 | uint64_t val) |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 554 | { |
| 555 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 556 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 557 | int ret; |
| 558 | |
| 559 | ret = drm_connector_property_set_value(connector, property, val); |
| 560 | if (ret) |
| 561 | return ret; |
| 562 | |
Chris Wilson | 3f43c48 | 2011-05-12 22:17:24 +0100 | [diff] [blame] | 563 | if (property == dev_priv->force_audio_property) { |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 564 | enum hdmi_force_audio i = val; |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 565 | bool has_audio; |
| 566 | |
| 567 | if (i == intel_hdmi->force_audio) |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 568 | return 0; |
| 569 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 570 | intel_hdmi->force_audio = i; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 571 | |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 572 | if (i == HDMI_AUDIO_AUTO) |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 573 | has_audio = intel_hdmi_detect_audio(connector); |
| 574 | else |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 575 | has_audio = (i == HDMI_AUDIO_ON); |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 576 | |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 577 | if (i == HDMI_AUDIO_OFF_DVI) |
| 578 | intel_hdmi->has_hdmi_sink = 0; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 579 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 580 | intel_hdmi->has_audio = has_audio; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 581 | goto done; |
| 582 | } |
| 583 | |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 584 | if (property == dev_priv->broadcast_rgb_property) { |
| 585 | if (val == !!intel_hdmi->color_range) |
| 586 | return 0; |
| 587 | |
| 588 | intel_hdmi->color_range = val ? SDVO_COLOR_RANGE_16_235 : 0; |
| 589 | goto done; |
| 590 | } |
| 591 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 592 | return -EINVAL; |
| 593 | |
| 594 | done: |
| 595 | if (intel_hdmi->base.base.crtc) { |
| 596 | struct drm_crtc *crtc = intel_hdmi->base.base.crtc; |
| 597 | drm_crtc_helper_set_mode(crtc, &crtc->mode, |
| 598 | crtc->x, crtc->y, |
| 599 | crtc->fb); |
| 600 | } |
| 601 | |
| 602 | return 0; |
| 603 | } |
| 604 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 605 | static void intel_hdmi_destroy(struct drm_connector *connector) |
| 606 | { |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 607 | drm_sysfs_connector_remove(connector); |
| 608 | drm_connector_cleanup(connector); |
Zhenyu Wang | 674e2d0 | 2010-03-29 15:57:42 +0800 | [diff] [blame] | 609 | kfree(connector); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 610 | } |
| 611 | |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 612 | static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs_hsw = { |
| 613 | .dpms = intel_ddi_dpms, |
| 614 | .mode_fixup = intel_hdmi_mode_fixup, |
| 615 | .prepare = intel_encoder_prepare, |
| 616 | .mode_set = intel_ddi_mode_set, |
| 617 | .commit = intel_encoder_commit, |
| 618 | }; |
| 619 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 620 | static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs = { |
| 621 | .dpms = intel_hdmi_dpms, |
| 622 | .mode_fixup = intel_hdmi_mode_fixup, |
| 623 | .prepare = intel_encoder_prepare, |
| 624 | .mode_set = intel_hdmi_mode_set, |
| 625 | .commit = intel_encoder_commit, |
| 626 | }; |
| 627 | |
| 628 | static const struct drm_connector_funcs intel_hdmi_connector_funcs = { |
Keith Packard | c9fb15f | 2009-05-30 20:42:28 -0700 | [diff] [blame] | 629 | .dpms = drm_helper_connector_dpms, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 630 | .detect = intel_hdmi_detect, |
| 631 | .fill_modes = drm_helper_probe_single_connector_modes, |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 632 | .set_property = intel_hdmi_set_property, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 633 | .destroy = intel_hdmi_destroy, |
| 634 | }; |
| 635 | |
| 636 | static const struct drm_connector_helper_funcs intel_hdmi_connector_helper_funcs = { |
| 637 | .get_modes = intel_hdmi_get_modes, |
| 638 | .mode_valid = intel_hdmi_mode_valid, |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 639 | .best_encoder = intel_best_encoder, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 640 | }; |
| 641 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 642 | static const struct drm_encoder_funcs intel_hdmi_enc_funcs = { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 643 | .destroy = intel_encoder_destroy, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 644 | }; |
| 645 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 646 | static void |
| 647 | intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector) |
| 648 | { |
Chris Wilson | 3f43c48 | 2011-05-12 22:17:24 +0100 | [diff] [blame] | 649 | intel_attach_force_audio_property(connector); |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 650 | intel_attach_broadcast_rgb_property(connector); |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 651 | } |
| 652 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 653 | void intel_hdmi_init(struct drm_device *dev, int sdvox_reg) |
| 654 | { |
| 655 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 656 | struct drm_connector *connector; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 657 | struct intel_encoder *intel_encoder; |
Zhenyu Wang | 674e2d0 | 2010-03-29 15:57:42 +0800 | [diff] [blame] | 658 | struct intel_connector *intel_connector; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 659 | struct intel_hdmi *intel_hdmi; |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 660 | int i; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 661 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 662 | intel_hdmi = kzalloc(sizeof(struct intel_hdmi), GFP_KERNEL); |
| 663 | if (!intel_hdmi) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 664 | return; |
Zhenyu Wang | 674e2d0 | 2010-03-29 15:57:42 +0800 | [diff] [blame] | 665 | |
| 666 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
| 667 | if (!intel_connector) { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 668 | kfree(intel_hdmi); |
Zhenyu Wang | 674e2d0 | 2010-03-29 15:57:42 +0800 | [diff] [blame] | 669 | return; |
| 670 | } |
| 671 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 672 | intel_encoder = &intel_hdmi->base; |
Chris Wilson | 373a3cf | 2010-09-15 12:03:59 +0100 | [diff] [blame] | 673 | drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs, |
| 674 | DRM_MODE_ENCODER_TMDS); |
| 675 | |
Zhenyu Wang | 674e2d0 | 2010-03-29 15:57:42 +0800 | [diff] [blame] | 676 | connector = &intel_connector->base; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 677 | drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, |
Adam Jackson | 8d91104 | 2009-09-23 15:08:29 -0400 | [diff] [blame] | 678 | DRM_MODE_CONNECTOR_HDMIA); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 679 | drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs); |
| 680 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 681 | intel_encoder->type = INTEL_OUTPUT_HDMI; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 682 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 683 | connector->polled = DRM_CONNECTOR_POLL_HPD; |
Peter Ross | c3febcc | 2012-01-28 14:49:26 +0100 | [diff] [blame] | 684 | connector->interlace_allowed = 1; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 685 | connector->doublescan_allowed = 0; |
Jesse Barnes | 27f8227 | 2011-09-02 12:54:37 -0700 | [diff] [blame] | 686 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 687 | |
| 688 | /* Set up the DDC bus. */ |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 689 | if (sdvox_reg == SDVOB) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 690 | intel_encoder->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT); |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 691 | intel_hdmi->ddc_bus = GMBUS_PORT_DPB; |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 692 | dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS; |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 693 | } else if (sdvox_reg == SDVOC) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 694 | intel_encoder->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT); |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 695 | intel_hdmi->ddc_bus = GMBUS_PORT_DPC; |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 696 | dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS; |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 697 | } else if (sdvox_reg == HDMIB) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 698 | intel_encoder->clone_mask = (1 << INTEL_HDMID_CLONE_BIT); |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 699 | intel_hdmi->ddc_bus = GMBUS_PORT_DPB; |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 700 | dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS; |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 701 | } else if (sdvox_reg == HDMIC) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 702 | intel_encoder->clone_mask = (1 << INTEL_HDMIE_CLONE_BIT); |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 703 | intel_hdmi->ddc_bus = GMBUS_PORT_DPC; |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 704 | dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS; |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 705 | } else if (sdvox_reg == HDMID) { |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 706 | intel_encoder->clone_mask = (1 << INTEL_HDMIF_CLONE_BIT); |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 707 | intel_hdmi->ddc_bus = GMBUS_PORT_DPD; |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 708 | dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS; |
Eugeni Dodonov | 7ceae0a | 2012-05-09 15:37:28 -0300 | [diff] [blame] | 709 | } else if (sdvox_reg == DDI_BUF_CTL(PORT_B)) { |
| 710 | DRM_DEBUG_DRIVER("LPT: detected output on DDI B\n"); |
| 711 | intel_encoder->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT); |
| 712 | intel_hdmi->ddc_bus = GMBUS_PORT_DPB; |
| 713 | intel_hdmi->ddi_port = PORT_B; |
| 714 | dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS; |
| 715 | } else if (sdvox_reg == DDI_BUF_CTL(PORT_C)) { |
| 716 | DRM_DEBUG_DRIVER("LPT: detected output on DDI C\n"); |
| 717 | intel_encoder->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT); |
| 718 | intel_hdmi->ddc_bus = GMBUS_PORT_DPC; |
| 719 | intel_hdmi->ddi_port = PORT_C; |
| 720 | dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS; |
| 721 | } else if (sdvox_reg == DDI_BUF_CTL(PORT_D)) { |
| 722 | DRM_DEBUG_DRIVER("LPT: detected output on DDI D\n"); |
| 723 | intel_encoder->clone_mask = (1 << INTEL_HDMID_CLONE_BIT); |
| 724 | intel_hdmi->ddc_bus = GMBUS_PORT_DPD; |
| 725 | intel_hdmi->ddi_port = PORT_D; |
| 726 | dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS; |
Eugeni Dodonov | 6e4c167 | 2012-05-09 15:37:13 -0300 | [diff] [blame] | 727 | } else { |
| 728 | /* If we got an unknown sdvox_reg, things are pretty much broken |
| 729 | * in a way that we should let the kernel know about it */ |
| 730 | BUG(); |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 731 | } |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 732 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 733 | intel_hdmi->sdvox_reg = sdvox_reg; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 734 | |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 735 | if (!HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | a3da1df | 2012-05-08 15:19:06 +0200 | [diff] [blame] | 736 | intel_hdmi->write_infoframe = g4x_write_infoframe; |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 737 | I915_WRITE(VIDEO_DIP_CTL, 0); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 738 | } else if (IS_VALLEYVIEW(dev)) { |
| 739 | intel_hdmi->write_infoframe = vlv_write_infoframe; |
| 740 | for_each_pipe(i) |
| 741 | I915_WRITE(VLV_TVIDEO_DIP_CTL(i), 0); |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 742 | } else if (IS_HASWELL(dev)) { |
| 743 | /* FIXME: Haswell has a new set of DIP frame registers, but we are |
| 744 | * just doing the minimal required for HDMI to work at this stage. |
| 745 | */ |
| 746 | intel_hdmi->write_infoframe = hsw_write_infoframe; |
| 747 | for_each_pipe(i) |
| 748 | I915_WRITE(HSW_TVIDEO_DIP_CTL(i), 0); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 749 | } else if (HAS_PCH_IBX(dev)) { |
| 750 | intel_hdmi->write_infoframe = ibx_write_infoframe; |
| 751 | for_each_pipe(i) |
| 752 | I915_WRITE(TVIDEO_DIP_CTL(i), 0); |
| 753 | } else { |
| 754 | intel_hdmi->write_infoframe = cpt_write_infoframe; |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 755 | for_each_pipe(i) |
| 756 | I915_WRITE(TVIDEO_DIP_CTL(i), 0); |
| 757 | } |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 758 | |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 759 | if (IS_HASWELL(dev)) |
| 760 | drm_encoder_helper_add(&intel_encoder->base, &intel_hdmi_helper_funcs_hsw); |
| 761 | else |
| 762 | drm_encoder_helper_add(&intel_encoder->base, &intel_hdmi_helper_funcs); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 763 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 764 | intel_hdmi_add_properties(intel_hdmi, connector); |
| 765 | |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 766 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 767 | drm_sysfs_connector_add(connector); |
| 768 | |
| 769 | /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written |
| 770 | * 0xd. Failure to do so will result in spurious interrupts being |
| 771 | * generated on the port when a cable is not attached. |
| 772 | */ |
| 773 | if (IS_G4X(dev) && !IS_GM45(dev)) { |
| 774 | u32 temp = I915_READ(PEG_BAND_GAP_DATA); |
| 775 | I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); |
| 776 | } |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 777 | } |