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