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> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 32 | #include <drm/drmP.h> |
| 33 | #include <drm/drm_crtc.h> |
| 34 | #include <drm/drm_edid.h> |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 35 | #include "intel_drv.h" |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 36 | #include <drm/i915_drm.h> |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 37 | #include "i915_drv.h" |
| 38 | |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 39 | static struct drm_device *intel_hdmi_to_dev(struct intel_hdmi *intel_hdmi) |
| 40 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 41 | return hdmi_to_dig_port(intel_hdmi)->base.base.dev; |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 42 | } |
| 43 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 44 | static void |
| 45 | assert_hdmi_port_disabled(struct intel_hdmi *intel_hdmi) |
| 46 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 47 | struct drm_device *dev = intel_hdmi_to_dev(intel_hdmi); |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 48 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 49 | uint32_t enabled_bits; |
| 50 | |
| 51 | enabled_bits = IS_HASWELL(dev) ? DDI_BUF_CTL_ENABLE : SDVO_ENABLE; |
| 52 | |
| 53 | WARN(I915_READ(intel_hdmi->sdvox_reg) & enabled_bits, |
| 54 | "HDMI port enabled, expecting disabled\n"); |
| 55 | } |
| 56 | |
Eugeni Dodonov | f5bbfca | 2012-05-09 15:37:30 -0300 | [diff] [blame] | 57 | struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder) |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 58 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 59 | struct intel_digital_port *intel_dig_port = |
| 60 | container_of(encoder, struct intel_digital_port, base.base); |
| 61 | return &intel_dig_port->hdmi; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 62 | } |
| 63 | |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 64 | static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector) |
| 65 | { |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 66 | return enc_to_intel_hdmi(&intel_attached_encoder(connector)->base); |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 67 | } |
| 68 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 69 | void intel_dip_infoframe_csum(struct dip_infoframe *frame) |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 70 | { |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 71 | uint8_t *data = (uint8_t *)frame; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 72 | uint8_t sum = 0; |
| 73 | unsigned i; |
| 74 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 75 | frame->checksum = 0; |
| 76 | frame->ecc = 0; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 77 | |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 78 | for (i = 0; i < frame->len + DIP_HEADER_SIZE; i++) |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 79 | sum += data[i]; |
| 80 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 81 | frame->checksum = 0x100 - sum; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 82 | } |
| 83 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 84 | static u32 g4x_infoframe_index(struct dip_infoframe *frame) |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 85 | { |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 86 | switch (frame->type) { |
| 87 | case DIP_TYPE_AVI: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 88 | return VIDEO_DIP_SELECT_AVI; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 89 | case DIP_TYPE_SPD: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 90 | return VIDEO_DIP_SELECT_SPD; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 91 | default: |
| 92 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type); |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 93 | return 0; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 94 | } |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 97 | static u32 g4x_infoframe_enable(struct dip_infoframe *frame) |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 98 | { |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 99 | switch (frame->type) { |
| 100 | case DIP_TYPE_AVI: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 101 | return VIDEO_DIP_ENABLE_AVI; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 102 | case DIP_TYPE_SPD: |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 103 | return VIDEO_DIP_ENABLE_SPD; |
Paulo Zanoni | fa193ff | 2012-05-04 17:18:20 -0300 | [diff] [blame] | 104 | default: |
| 105 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type); |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 106 | return 0; |
Paulo Zanoni | fa193ff | 2012-05-04 17:18:20 -0300 | [diff] [blame] | 107 | } |
Paulo Zanoni | fa193ff | 2012-05-04 17:18:20 -0300 | [diff] [blame] | 108 | } |
| 109 | |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 110 | static u32 hsw_infoframe_enable(struct dip_infoframe *frame) |
| 111 | { |
| 112 | switch (frame->type) { |
| 113 | case DIP_TYPE_AVI: |
| 114 | return VIDEO_DIP_ENABLE_AVI_HSW; |
| 115 | case DIP_TYPE_SPD: |
| 116 | return VIDEO_DIP_ENABLE_SPD_HSW; |
| 117 | default: |
| 118 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type); |
| 119 | return 0; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | static u32 hsw_infoframe_data_reg(struct dip_infoframe *frame, enum pipe pipe) |
| 124 | { |
| 125 | switch (frame->type) { |
| 126 | case DIP_TYPE_AVI: |
| 127 | return HSW_TVIDEO_DIP_AVI_DATA(pipe); |
| 128 | case DIP_TYPE_SPD: |
| 129 | return HSW_TVIDEO_DIP_SPD_DATA(pipe); |
| 130 | default: |
| 131 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type); |
| 132 | return 0; |
| 133 | } |
| 134 | } |
| 135 | |
Daniel Vetter | a3da1df | 2012-05-08 15:19:06 +0200 | [diff] [blame] | 136 | static void g4x_write_infoframe(struct drm_encoder *encoder, |
| 137 | struct dip_infoframe *frame) |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 138 | { |
| 139 | uint32_t *data = (uint32_t *)frame; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 140 | struct drm_device *dev = encoder->dev; |
| 141 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 142 | u32 val = I915_READ(VIDEO_DIP_CTL); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 143 | unsigned i, len = DIP_HEADER_SIZE + frame->len; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 144 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 145 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
| 146 | |
Paulo Zanoni | 1d4f85a | 2012-05-04 17:18:18 -0300 | [diff] [blame] | 147 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 148 | val |= g4x_infoframe_index(frame); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 149 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 150 | val &= ~g4x_infoframe_enable(frame); |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 151 | |
| 152 | I915_WRITE(VIDEO_DIP_CTL, val); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 153 | |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 154 | mmiowb(); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 155 | for (i = 0; i < len; i += 4) { |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 156 | I915_WRITE(VIDEO_DIP_DATA, *data); |
| 157 | data++; |
| 158 | } |
Paulo Zanoni | adf00b2 | 2012-09-25 13:23:34 -0300 | [diff] [blame] | 159 | /* Write every possible data byte to force correct ECC calculation. */ |
| 160 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
| 161 | I915_WRITE(VIDEO_DIP_DATA, 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 162 | mmiowb(); |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 163 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 164 | val |= g4x_infoframe_enable(frame); |
Paulo Zanoni | 60c5ea2 | 2012-05-04 17:18:22 -0300 | [diff] [blame] | 165 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 166 | val |= VIDEO_DIP_FREQ_VSYNC; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 167 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 168 | I915_WRITE(VIDEO_DIP_CTL, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 169 | POSTING_READ(VIDEO_DIP_CTL); |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 170 | } |
| 171 | |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 172 | static void ibx_write_infoframe(struct drm_encoder *encoder, |
| 173 | struct dip_infoframe *frame) |
| 174 | { |
| 175 | uint32_t *data = (uint32_t *)frame; |
| 176 | struct drm_device *dev = encoder->dev; |
| 177 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 178 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 179 | int reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 180 | unsigned i, len = DIP_HEADER_SIZE + frame->len; |
| 181 | u32 val = I915_READ(reg); |
| 182 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 183 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
| 184 | |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 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 | |
| 190 | I915_WRITE(reg, val); |
| 191 | |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 192 | mmiowb(); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 193 | for (i = 0; i < len; i += 4) { |
| 194 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
| 195 | data++; |
| 196 | } |
Paulo Zanoni | adf00b2 | 2012-09-25 13:23:34 -0300 | [diff] [blame] | 197 | /* Write every possible data byte to force correct ECC calculation. */ |
| 198 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
| 199 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 200 | mmiowb(); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 201 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 202 | val |= g4x_infoframe_enable(frame); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 203 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 204 | val |= VIDEO_DIP_FREQ_VSYNC; |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 205 | |
| 206 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 207 | POSTING_READ(reg); |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | static void cpt_write_infoframe(struct drm_encoder *encoder, |
| 211 | struct dip_infoframe *frame) |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 212 | { |
| 213 | uint32_t *data = (uint32_t *)frame; |
| 214 | struct drm_device *dev = encoder->dev; |
| 215 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 216 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 217 | int reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 218 | unsigned i, len = DIP_HEADER_SIZE + frame->len; |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 219 | u32 val = I915_READ(reg); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 220 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 221 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
| 222 | |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 223 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 224 | val |= g4x_infoframe_index(frame); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 225 | |
Paulo Zanoni | ecb9785 | 2012-05-04 17:18:21 -0300 | [diff] [blame] | 226 | /* The DIP control register spec says that we need to update the AVI |
| 227 | * infoframe without clearing its enable bit */ |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 228 | if (frame->type != DIP_TYPE_AVI) |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 229 | val &= ~g4x_infoframe_enable(frame); |
Paulo Zanoni | ecb9785 | 2012-05-04 17:18:21 -0300 | [diff] [blame] | 230 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 231 | I915_WRITE(reg, val); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 232 | |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 233 | mmiowb(); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 234 | for (i = 0; i < len; i += 4) { |
| 235 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
| 236 | data++; |
| 237 | } |
Paulo Zanoni | adf00b2 | 2012-09-25 13:23:34 -0300 | [diff] [blame] | 238 | /* Write every possible data byte to force correct ECC calculation. */ |
| 239 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
| 240 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 241 | mmiowb(); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 242 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 243 | val |= g4x_infoframe_enable(frame); |
Paulo Zanoni | 60c5ea2 | 2012-05-04 17:18:22 -0300 | [diff] [blame] | 244 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 245 | val |= VIDEO_DIP_FREQ_VSYNC; |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 246 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 247 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 248 | POSTING_READ(reg); |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 249 | } |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 250 | |
| 251 | static void vlv_write_infoframe(struct drm_encoder *encoder, |
| 252 | struct dip_infoframe *frame) |
| 253 | { |
| 254 | uint32_t *data = (uint32_t *)frame; |
| 255 | struct drm_device *dev = encoder->dev; |
| 256 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 257 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 258 | int reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 259 | unsigned i, len = DIP_HEADER_SIZE + frame->len; |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 260 | u32 val = I915_READ(reg); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 261 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 262 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
| 263 | |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 264 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 265 | val |= g4x_infoframe_index(frame); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 266 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 267 | val &= ~g4x_infoframe_enable(frame); |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 268 | |
| 269 | I915_WRITE(reg, val); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 270 | |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 271 | mmiowb(); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 272 | for (i = 0; i < len; i += 4) { |
| 273 | I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
| 274 | data++; |
| 275 | } |
Paulo Zanoni | adf00b2 | 2012-09-25 13:23:34 -0300 | [diff] [blame] | 276 | /* Write every possible data byte to force correct ECC calculation. */ |
| 277 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
| 278 | I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 279 | mmiowb(); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 280 | |
Daniel Vetter | bc2481f | 2012-05-08 15:18:32 +0200 | [diff] [blame] | 281 | val |= g4x_infoframe_enable(frame); |
Paulo Zanoni | 60c5ea2 | 2012-05-04 17:18:22 -0300 | [diff] [blame] | 282 | val &= ~VIDEO_DIP_FREQ_MASK; |
Daniel Vetter | 4b24c93 | 2012-05-08 14:41:00 +0200 | [diff] [blame] | 283 | val |= VIDEO_DIP_FREQ_VSYNC; |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 284 | |
Paulo Zanoni | 22509ec | 2012-05-04 17:18:17 -0300 | [diff] [blame] | 285 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 286 | POSTING_READ(reg); |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 287 | } |
| 288 | |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 289 | static void hsw_write_infoframe(struct drm_encoder *encoder, |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 290 | struct dip_infoframe *frame) |
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 | uint32_t *data = (uint32_t *)frame; |
| 293 | struct drm_device *dev = encoder->dev; |
| 294 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 295 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
| 296 | u32 ctl_reg = HSW_TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 297 | u32 data_reg = hsw_infoframe_data_reg(frame, intel_crtc->pipe); |
| 298 | unsigned int i, len = DIP_HEADER_SIZE + frame->len; |
| 299 | u32 val = I915_READ(ctl_reg); |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 300 | |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 301 | if (data_reg == 0) |
| 302 | return; |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 303 | |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 304 | val &= ~hsw_infoframe_enable(frame); |
| 305 | I915_WRITE(ctl_reg, val); |
| 306 | |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 307 | mmiowb(); |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 308 | for (i = 0; i < len; i += 4) { |
| 309 | I915_WRITE(data_reg + i, *data); |
| 310 | data++; |
| 311 | } |
Paulo Zanoni | adf00b2 | 2012-09-25 13:23:34 -0300 | [diff] [blame] | 312 | /* Write every possible data byte to force correct ECC calculation. */ |
| 313 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
| 314 | I915_WRITE(data_reg + i, 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 315 | mmiowb(); |
Paulo Zanoni | 2da8af5 | 2012-05-14 17:12:51 -0300 | [diff] [blame] | 316 | |
| 317 | val |= hsw_infoframe_enable(frame); |
| 318 | I915_WRITE(ctl_reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 319 | POSTING_READ(ctl_reg); |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 320 | } |
| 321 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 322 | static void intel_set_infoframe(struct drm_encoder *encoder, |
| 323 | struct dip_infoframe *frame) |
| 324 | { |
| 325 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
| 326 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 327 | intel_dip_infoframe_csum(frame); |
| 328 | intel_hdmi->write_infoframe(encoder, frame); |
| 329 | } |
| 330 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 331 | static void intel_hdmi_set_avi_infoframe(struct drm_encoder *encoder, |
Paulo Zanoni | c846b61 | 2012-04-13 16:31:41 -0300 | [diff] [blame] | 332 | struct drm_display_mode *adjusted_mode) |
Jesse Barnes | b055c8f | 2011-07-08 11:31:57 -0700 | [diff] [blame] | 333 | { |
| 334 | struct dip_infoframe avi_if = { |
| 335 | .type = DIP_TYPE_AVI, |
| 336 | .ver = DIP_VERSION_AVI, |
| 337 | .len = DIP_LEN_AVI, |
| 338 | }; |
Jesse Barnes | b055c8f | 2011-07-08 11:31:57 -0700 | [diff] [blame] | 339 | |
Paulo Zanoni | c846b61 | 2012-04-13 16:31:41 -0300 | [diff] [blame] | 340 | if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) |
| 341 | avi_if.body.avi.YQ_CN_PR |= DIP_AVI_PR_2; |
| 342 | |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 343 | intel_set_infoframe(encoder, &avi_if); |
Jesse Barnes | b055c8f | 2011-07-08 11:31:57 -0700 | [diff] [blame] | 344 | } |
| 345 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 346 | static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder) |
Jesse Barnes | c0864cb | 2011-08-03 09:22:56 -0700 | [diff] [blame] | 347 | { |
| 348 | struct dip_infoframe spd_if; |
| 349 | |
| 350 | memset(&spd_if, 0, sizeof(spd_if)); |
| 351 | spd_if.type = DIP_TYPE_SPD; |
| 352 | spd_if.ver = DIP_VERSION_SPD; |
| 353 | spd_if.len = DIP_LEN_SPD; |
| 354 | strcpy(spd_if.body.spd.vn, "Intel"); |
| 355 | strcpy(spd_if.body.spd.pd, "Integrated gfx"); |
| 356 | spd_if.body.spd.sdi = DIP_SPD_PC; |
| 357 | |
| 358 | intel_set_infoframe(encoder, &spd_if); |
| 359 | } |
| 360 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 361 | static void g4x_set_infoframes(struct drm_encoder *encoder, |
| 362 | struct drm_display_mode *adjusted_mode) |
| 363 | { |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 364 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
| 365 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
| 366 | u32 reg = VIDEO_DIP_CTL; |
| 367 | u32 val = I915_READ(reg); |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 368 | u32 port; |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 369 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 370 | assert_hdmi_port_disabled(intel_hdmi); |
| 371 | |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 372 | /* If the registers were not initialized yet, they might be zeroes, |
| 373 | * which means we're selecting the AVI DIP and we're setting its |
| 374 | * frequency to once. This seems to really confuse the HW and make |
| 375 | * things stop working (the register spec says the AVI always needs to |
| 376 | * be sent every VSync). So here we avoid writing to the register more |
| 377 | * than we need and also explicitly select the AVI DIP and explicitly |
| 378 | * set its frequency to every VSync. Avoiding to write it twice seems to |
| 379 | * be enough to solve the problem, but being defensive shouldn't hurt us |
| 380 | * either. */ |
| 381 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
| 382 | |
| 383 | if (!intel_hdmi->has_hdmi_sink) { |
| 384 | if (!(val & VIDEO_DIP_ENABLE)) |
| 385 | return; |
| 386 | val &= ~VIDEO_DIP_ENABLE; |
| 387 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 388 | POSTING_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 389 | return; |
| 390 | } |
| 391 | |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 392 | switch (intel_hdmi->sdvox_reg) { |
| 393 | case SDVOB: |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 394 | port = VIDEO_DIP_PORT_B; |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 395 | break; |
| 396 | case SDVOC: |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 397 | port = VIDEO_DIP_PORT_C; |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 398 | break; |
| 399 | default: |
Paulo Zanoni | 57df2ae | 2012-09-24 10:32:54 -0300 | [diff] [blame] | 400 | BUG(); |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 401 | return; |
| 402 | } |
| 403 | |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 404 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
| 405 | if (val & VIDEO_DIP_ENABLE) { |
| 406 | val &= ~VIDEO_DIP_ENABLE; |
| 407 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 408 | POSTING_READ(reg); |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 409 | } |
| 410 | val &= ~VIDEO_DIP_PORT_MASK; |
| 411 | val |= port; |
| 412 | } |
| 413 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 414 | val |= VIDEO_DIP_ENABLE; |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 415 | val &= ~VIDEO_DIP_ENABLE_VENDOR; |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 416 | |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 417 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 418 | POSTING_READ(reg); |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 419 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 420 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
| 421 | intel_hdmi_set_spd_infoframe(encoder); |
| 422 | } |
| 423 | |
| 424 | static void ibx_set_infoframes(struct drm_encoder *encoder, |
| 425 | struct drm_display_mode *adjusted_mode) |
| 426 | { |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 427 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
| 428 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
| 429 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
| 430 | u32 reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 431 | u32 val = I915_READ(reg); |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 432 | u32 port; |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 433 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 434 | assert_hdmi_port_disabled(intel_hdmi); |
| 435 | |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 436 | /* See the big comment in g4x_set_infoframes() */ |
| 437 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
| 438 | |
| 439 | if (!intel_hdmi->has_hdmi_sink) { |
| 440 | if (!(val & VIDEO_DIP_ENABLE)) |
| 441 | return; |
| 442 | val &= ~VIDEO_DIP_ENABLE; |
| 443 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 444 | POSTING_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 445 | return; |
| 446 | } |
| 447 | |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 448 | switch (intel_hdmi->sdvox_reg) { |
| 449 | case HDMIB: |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 450 | port = VIDEO_DIP_PORT_B; |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 451 | break; |
| 452 | case HDMIC: |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 453 | port = VIDEO_DIP_PORT_C; |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 454 | break; |
| 455 | case HDMID: |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 456 | port = VIDEO_DIP_PORT_D; |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 457 | break; |
| 458 | default: |
Paulo Zanoni | 57df2ae | 2012-09-24 10:32:54 -0300 | [diff] [blame] | 459 | BUG(); |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 460 | return; |
| 461 | } |
| 462 | |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 463 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
| 464 | if (val & VIDEO_DIP_ENABLE) { |
| 465 | val &= ~VIDEO_DIP_ENABLE; |
| 466 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 467 | POSTING_READ(reg); |
Paulo Zanoni | 72b78c9 | 2012-05-28 16:42:54 -0300 | [diff] [blame] | 468 | } |
| 469 | val &= ~VIDEO_DIP_PORT_MASK; |
| 470 | val |= port; |
| 471 | } |
| 472 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 473 | val |= VIDEO_DIP_ENABLE; |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 474 | val &= ~(VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 475 | VIDEO_DIP_ENABLE_GCP); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 476 | |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 477 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 478 | POSTING_READ(reg); |
Paulo Zanoni | f278d97 | 2012-05-28 16:42:50 -0300 | [diff] [blame] | 479 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 480 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
| 481 | intel_hdmi_set_spd_infoframe(encoder); |
| 482 | } |
| 483 | |
| 484 | static void cpt_set_infoframes(struct drm_encoder *encoder, |
| 485 | struct drm_display_mode *adjusted_mode) |
| 486 | { |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 487 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
| 488 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
| 489 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
| 490 | u32 reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 491 | u32 val = I915_READ(reg); |
| 492 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 493 | assert_hdmi_port_disabled(intel_hdmi); |
| 494 | |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 495 | /* See the big comment in g4x_set_infoframes() */ |
| 496 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
| 497 | |
| 498 | if (!intel_hdmi->has_hdmi_sink) { |
| 499 | if (!(val & VIDEO_DIP_ENABLE)) |
| 500 | return; |
| 501 | val &= ~(VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI); |
| 502 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 503 | POSTING_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 504 | return; |
| 505 | } |
| 506 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 507 | /* Set both together, unset both together: see the spec. */ |
| 508 | val |= VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI; |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 509 | val &= ~(VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 510 | VIDEO_DIP_ENABLE_GCP); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 511 | |
| 512 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 513 | POSTING_READ(reg); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 514 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 515 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
| 516 | intel_hdmi_set_spd_infoframe(encoder); |
| 517 | } |
| 518 | |
| 519 | static void vlv_set_infoframes(struct drm_encoder *encoder, |
| 520 | struct drm_display_mode *adjusted_mode) |
| 521 | { |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 522 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
| 523 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
| 524 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
| 525 | u32 reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe); |
| 526 | u32 val = I915_READ(reg); |
| 527 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 528 | assert_hdmi_port_disabled(intel_hdmi); |
| 529 | |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 530 | /* See the big comment in g4x_set_infoframes() */ |
| 531 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
| 532 | |
| 533 | if (!intel_hdmi->has_hdmi_sink) { |
| 534 | if (!(val & VIDEO_DIP_ENABLE)) |
| 535 | return; |
| 536 | val &= ~VIDEO_DIP_ENABLE; |
| 537 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 538 | POSTING_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 539 | return; |
| 540 | } |
| 541 | |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 542 | val |= VIDEO_DIP_ENABLE; |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 543 | val &= ~(VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
| 544 | VIDEO_DIP_ENABLE_GCP); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 545 | |
| 546 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 547 | POSTING_READ(reg); |
Paulo Zanoni | 822974a | 2012-05-28 16:42:51 -0300 | [diff] [blame] | 548 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 549 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
| 550 | intel_hdmi_set_spd_infoframe(encoder); |
| 551 | } |
| 552 | |
| 553 | static void hsw_set_infoframes(struct drm_encoder *encoder, |
| 554 | struct drm_display_mode *adjusted_mode) |
| 555 | { |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 556 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
| 557 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
| 558 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
| 559 | u32 reg = HSW_TVIDEO_DIP_CTL(intel_crtc->pipe); |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 560 | u32 val = I915_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 561 | |
Daniel Vetter | afba018 | 2012-06-12 16:36:45 +0200 | [diff] [blame] | 562 | assert_hdmi_port_disabled(intel_hdmi); |
| 563 | |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 564 | if (!intel_hdmi->has_hdmi_sink) { |
| 565 | I915_WRITE(reg, 0); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 566 | POSTING_READ(reg); |
Paulo Zanoni | 0c14c7f | 2012-05-28 16:42:49 -0300 | [diff] [blame] | 567 | return; |
| 568 | } |
| 569 | |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 570 | val &= ~(VIDEO_DIP_ENABLE_VSC_HSW | VIDEO_DIP_ENABLE_GCP_HSW | |
| 571 | VIDEO_DIP_ENABLE_VS_HSW | VIDEO_DIP_ENABLE_GMP_HSW); |
| 572 | |
| 573 | I915_WRITE(reg, val); |
Paulo Zanoni | 9d9740f | 2012-05-28 16:43:00 -0300 | [diff] [blame] | 574 | POSTING_READ(reg); |
Paulo Zanoni | 0dd87d2 | 2012-05-28 16:42:53 -0300 | [diff] [blame] | 575 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 576 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
| 577 | intel_hdmi_set_spd_infoframe(encoder); |
| 578 | } |
| 579 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 580 | static void intel_hdmi_mode_set(struct drm_encoder *encoder, |
| 581 | struct drm_display_mode *mode, |
| 582 | struct drm_display_mode *adjusted_mode) |
| 583 | { |
| 584 | struct drm_device *dev = encoder->dev; |
| 585 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 586 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 587 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 588 | u32 sdvox; |
| 589 | |
Paulo Zanoni | b659c3d | 2012-05-28 16:42:56 -0300 | [diff] [blame] | 590 | sdvox = SDVO_ENCODING_HDMI; |
Jesse Barnes | 5d4fac9 | 2011-06-24 12:19:19 -0700 | [diff] [blame] | 591 | if (!HAS_PCH_SPLIT(dev)) |
| 592 | sdvox |= intel_hdmi->color_range; |
Adam Jackson | b599c0b | 2010-07-16 14:46:31 -0400 | [diff] [blame] | 593 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
| 594 | sdvox |= SDVO_VSYNC_ACTIVE_HIGH; |
| 595 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
| 596 | sdvox |= SDVO_HSYNC_ACTIVE_HIGH; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 597 | |
Jesse Barnes | 020f670 | 2011-06-24 12:19:25 -0700 | [diff] [blame] | 598 | if (intel_crtc->bpp > 24) |
| 599 | sdvox |= COLOR_FORMAT_12bpc; |
| 600 | else |
| 601 | sdvox |= COLOR_FORMAT_8bpc; |
| 602 | |
Zhenyu Wang | 2e3d600 | 2010-09-10 10:39:40 +0800 | [diff] [blame] | 603 | /* Required on CPT */ |
| 604 | if (intel_hdmi->has_hdmi_sink && HAS_PCH_CPT(dev)) |
| 605 | sdvox |= HDMI_MODE_SELECT; |
| 606 | |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 607 | if (intel_hdmi->has_audio) { |
Wu Fengguang | e0dac65 | 2011-09-05 14:25:34 +0800 | [diff] [blame] | 608 | DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n", |
| 609 | pipe_name(intel_crtc->pipe)); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 610 | sdvox |= SDVO_AUDIO_ENABLE; |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 611 | sdvox |= SDVO_NULL_PACKETS_DURING_VSYNC; |
Wu Fengguang | e0dac65 | 2011-09-05 14:25:34 +0800 | [diff] [blame] | 612 | intel_write_eld(encoder, adjusted_mode); |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 613 | } |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 614 | |
Jesse Barnes | 7577056 | 2011-10-12 09:01:58 -0700 | [diff] [blame] | 615 | if (HAS_PCH_CPT(dev)) |
| 616 | sdvox |= PORT_TRANS_SEL_CPT(intel_crtc->pipe); |
Daniel Vetter | 7a87c28 | 2012-06-05 11:03:39 +0200 | [diff] [blame] | 617 | else if (intel_crtc->pipe == PIPE_B) |
Jesse Barnes | 7577056 | 2011-10-12 09:01:58 -0700 | [diff] [blame] | 618 | sdvox |= SDVO_PIPE_B_SELECT; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 619 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 620 | I915_WRITE(intel_hdmi->sdvox_reg, sdvox); |
| 621 | POSTING_READ(intel_hdmi->sdvox_reg); |
David Härdeman | 3c17fe4 | 2010-09-24 21:44:32 +0200 | [diff] [blame] | 622 | |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 623 | intel_hdmi->set_infoframes(encoder, adjusted_mode); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 624 | } |
| 625 | |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 626 | static bool intel_hdmi_get_hw_state(struct intel_encoder *encoder, |
| 627 | enum pipe *pipe) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 628 | { |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 629 | struct drm_device *dev = encoder->base.dev; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 630 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 631 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
| 632 | u32 tmp; |
| 633 | |
| 634 | tmp = I915_READ(intel_hdmi->sdvox_reg); |
| 635 | |
| 636 | if (!(tmp & SDVO_ENABLE)) |
| 637 | return false; |
| 638 | |
| 639 | if (HAS_PCH_CPT(dev)) |
| 640 | *pipe = PORT_TO_PIPE_CPT(tmp); |
| 641 | else |
| 642 | *pipe = PORT_TO_PIPE(tmp); |
| 643 | |
| 644 | return true; |
| 645 | } |
| 646 | |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 647 | static void intel_enable_hdmi(struct intel_encoder *encoder) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 648 | { |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 649 | struct drm_device *dev = encoder->base.dev; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 650 | struct drm_i915_private *dev_priv = dev->dev_private; |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 651 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 652 | u32 temp; |
Wu Fengguang | 2deed76 | 2011-12-09 20:42:20 +0800 | [diff] [blame] | 653 | u32 enable_bits = SDVO_ENABLE; |
| 654 | |
| 655 | if (intel_hdmi->has_audio) |
| 656 | enable_bits |= SDVO_AUDIO_ENABLE; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 657 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 658 | temp = I915_READ(intel_hdmi->sdvox_reg); |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 659 | |
Daniel Vetter | 7a87c28 | 2012-06-05 11:03:39 +0200 | [diff] [blame] | 660 | /* HW workaround for IBX, we need to move the port to transcoder A |
| 661 | * before disabling it. */ |
| 662 | if (HAS_PCH_IBX(dev)) { |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 663 | struct drm_crtc *crtc = encoder->base.crtc; |
Daniel Vetter | 7a87c28 | 2012-06-05 11:03:39 +0200 | [diff] [blame] | 664 | int pipe = crtc ? to_intel_crtc(crtc)->pipe : -1; |
| 665 | |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 666 | /* Restore the transcoder select bit. */ |
| 667 | if (pipe == PIPE_B) |
| 668 | enable_bits |= SDVO_PIPE_B_SELECT; |
| 669 | } |
Daniel Vetter | 7a87c28 | 2012-06-05 11:03:39 +0200 | [diff] [blame] | 670 | |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 671 | /* HW workaround, need to toggle enable bit off and on for 12bpc, but |
| 672 | * we do this anyway which shows more stable in testing. |
| 673 | */ |
| 674 | if (HAS_PCH_SPLIT(dev)) { |
| 675 | I915_WRITE(intel_hdmi->sdvox_reg, temp & ~SDVO_ENABLE); |
| 676 | POSTING_READ(intel_hdmi->sdvox_reg); |
| 677 | } |
Daniel Vetter | 7a87c28 | 2012-06-05 11:03:39 +0200 | [diff] [blame] | 678 | |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 679 | temp |= enable_bits; |
| 680 | |
| 681 | I915_WRITE(intel_hdmi->sdvox_reg, temp); |
| 682 | POSTING_READ(intel_hdmi->sdvox_reg); |
| 683 | |
| 684 | /* HW workaround, need to write this twice for issue that may result |
| 685 | * in first write getting masked. |
| 686 | */ |
| 687 | if (HAS_PCH_SPLIT(dev)) { |
| 688 | I915_WRITE(intel_hdmi->sdvox_reg, temp); |
| 689 | POSTING_READ(intel_hdmi->sdvox_reg); |
| 690 | } |
| 691 | } |
| 692 | |
| 693 | static void intel_disable_hdmi(struct intel_encoder *encoder) |
| 694 | { |
| 695 | struct drm_device *dev = encoder->base.dev; |
| 696 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 697 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
| 698 | u32 temp; |
Wang Xingchao | 3cce574 | 2012-09-13 11:19:00 +0800 | [diff] [blame] | 699 | u32 enable_bits = SDVO_ENABLE | SDVO_AUDIO_ENABLE; |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 700 | |
| 701 | temp = I915_READ(intel_hdmi->sdvox_reg); |
| 702 | |
| 703 | /* HW workaround for IBX, we need to move the port to transcoder A |
| 704 | * before disabling it. */ |
| 705 | if (HAS_PCH_IBX(dev)) { |
| 706 | struct drm_crtc *crtc = encoder->base.crtc; |
| 707 | int pipe = crtc ? to_intel_crtc(crtc)->pipe : -1; |
| 708 | |
| 709 | if (temp & SDVO_PIPE_B_SELECT) { |
| 710 | temp &= ~SDVO_PIPE_B_SELECT; |
| 711 | I915_WRITE(intel_hdmi->sdvox_reg, temp); |
| 712 | POSTING_READ(intel_hdmi->sdvox_reg); |
| 713 | |
| 714 | /* Again we need to write this twice. */ |
| 715 | I915_WRITE(intel_hdmi->sdvox_reg, temp); |
| 716 | POSTING_READ(intel_hdmi->sdvox_reg); |
| 717 | |
| 718 | /* Transcoder selection bits only update |
| 719 | * effectively on vblank. */ |
| 720 | if (crtc) |
| 721 | intel_wait_for_vblank(dev, pipe); |
| 722 | else |
| 723 | msleep(50); |
Daniel Vetter | 7a87c28 | 2012-06-05 11:03:39 +0200 | [diff] [blame] | 724 | } |
| 725 | } |
| 726 | |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 727 | /* HW workaround, need to toggle enable bit off and on for 12bpc, but |
| 728 | * we do this anyway which shows more stable in testing. |
| 729 | */ |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 730 | if (HAS_PCH_SPLIT(dev)) { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 731 | I915_WRITE(intel_hdmi->sdvox_reg, temp & ~SDVO_ENABLE); |
| 732 | POSTING_READ(intel_hdmi->sdvox_reg); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 733 | } |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 734 | |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 735 | temp &= ~enable_bits; |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 736 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 737 | I915_WRITE(intel_hdmi->sdvox_reg, temp); |
| 738 | POSTING_READ(intel_hdmi->sdvox_reg); |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 739 | |
| 740 | /* HW workaround, need to write this twice for issue that may result |
| 741 | * in first write getting masked. |
| 742 | */ |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 743 | if (HAS_PCH_SPLIT(dev)) { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 744 | I915_WRITE(intel_hdmi->sdvox_reg, temp); |
| 745 | POSTING_READ(intel_hdmi->sdvox_reg); |
Zhenyu Wang | d8a2d0e | 2009-11-02 07:52:30 +0000 | [diff] [blame] | 746 | } |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 747 | } |
| 748 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 749 | static int intel_hdmi_mode_valid(struct drm_connector *connector, |
| 750 | struct drm_display_mode *mode) |
| 751 | { |
| 752 | if (mode->clock > 165000) |
| 753 | return MODE_CLOCK_HIGH; |
| 754 | if (mode->clock < 20000) |
Nicolas Kaiser | 5cbba41 | 2011-05-30 12:48:26 +0200 | [diff] [blame] | 755 | return MODE_CLOCK_LOW; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 756 | |
| 757 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
| 758 | return MODE_NO_DBLESCAN; |
| 759 | |
| 760 | return MODE_OK; |
| 761 | } |
| 762 | |
| 763 | static bool intel_hdmi_mode_fixup(struct drm_encoder *encoder, |
Laurent Pinchart | e811f5a | 2012-07-17 17:56:50 +0200 | [diff] [blame] | 764 | const struct drm_display_mode *mode, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 765 | struct drm_display_mode *adjusted_mode) |
| 766 | { |
| 767 | return true; |
| 768 | } |
| 769 | |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 770 | static bool g4x_hdmi_connected(struct intel_hdmi *intel_hdmi) |
| 771 | { |
Paulo Zanoni | 30add22 | 2012-10-26 19:05:45 -0200 | [diff] [blame] | 772 | struct drm_device *dev = intel_hdmi_to_dev(intel_hdmi); |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 773 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 774 | uint32_t bit; |
| 775 | |
| 776 | switch (intel_hdmi->sdvox_reg) { |
Chris Wilson | eeafaac | 2012-05-25 10:23:37 +0100 | [diff] [blame] | 777 | case SDVOB: |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 778 | bit = HDMIB_HOTPLUG_LIVE_STATUS; |
| 779 | break; |
Chris Wilson | eeafaac | 2012-05-25 10:23:37 +0100 | [diff] [blame] | 780 | case SDVOC: |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 781 | bit = HDMIC_HOTPLUG_LIVE_STATUS; |
| 782 | break; |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 783 | default: |
| 784 | bit = 0; |
| 785 | break; |
| 786 | } |
| 787 | |
| 788 | return I915_READ(PORT_HOTPLUG_STAT) & bit; |
| 789 | } |
| 790 | |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 791 | static enum drm_connector_status |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 792 | intel_hdmi_detect(struct drm_connector *connector, bool force) |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 793 | { |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 794 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 795 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
| 796 | struct edid *edid; |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 797 | enum drm_connector_status status = connector_status_disconnected; |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 798 | |
Chris Wilson | 8ec22b2 | 2012-05-11 18:01:34 +0100 | [diff] [blame] | 799 | if (IS_G4X(connector->dev) && !g4x_hdmi_connected(intel_hdmi)) |
| 800 | return status; |
| 801 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 802 | intel_hdmi->has_hdmi_sink = false; |
Zhenyu Wang | 2e3d600 | 2010-09-10 10:39:40 +0800 | [diff] [blame] | 803 | intel_hdmi->has_audio = false; |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 804 | edid = drm_get_edid(connector, |
Daniel Kurtz | 3bd7d90 | 2012-03-28 02:36:14 +0800 | [diff] [blame] | 805 | intel_gmbus_get_adapter(dev_priv, |
| 806 | intel_hdmi->ddc_bus)); |
ling.ma@intel.com | 2ded9e274 | 2009-07-16 17:23:09 +0800 | [diff] [blame] | 807 | |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 808 | if (edid) { |
Eric Anholt | be9f1c4 | 2009-06-21 22:14:55 -0700 | [diff] [blame] | 809 | if (edid->input & DRM_EDID_INPUT_DIGITAL) { |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 810 | status = connector_status_connected; |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 811 | if (intel_hdmi->force_audio != HDMI_AUDIO_OFF_DVI) |
| 812 | intel_hdmi->has_hdmi_sink = |
| 813 | drm_detect_hdmi_monitor(edid); |
Zhenyu Wang | 2e3d600 | 2010-09-10 10:39:40 +0800 | [diff] [blame] | 814 | intel_hdmi->has_audio = drm_detect_monitor_audio(edid); |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 815 | } |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 816 | kfree(edid); |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 817 | } |
ling.ma@intel.com | 2ded9e274 | 2009-07-16 17:23:09 +0800 | [diff] [blame] | 818 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 819 | if (status == connector_status_connected) { |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 820 | if (intel_hdmi->force_audio != HDMI_AUDIO_AUTO) |
| 821 | intel_hdmi->has_audio = |
| 822 | (intel_hdmi->force_audio == HDMI_AUDIO_ON); |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 823 | } |
| 824 | |
Keith Packard | aa93d63 | 2009-05-05 09:52:46 -0700 | [diff] [blame] | 825 | return status; |
Ma Ling | 9dff6af | 2009-04-02 13:13:26 +0800 | [diff] [blame] | 826 | } |
| 827 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 828 | static int intel_hdmi_get_modes(struct drm_connector *connector) |
| 829 | { |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 830 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 831 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 832 | |
| 833 | /* We should parse the EDID data and find out if it's an HDMI sink so |
| 834 | * we can send audio to it. |
| 835 | */ |
| 836 | |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 837 | return intel_ddc_get_modes(connector, |
Daniel Kurtz | 3bd7d90 | 2012-03-28 02:36:14 +0800 | [diff] [blame] | 838 | intel_gmbus_get_adapter(dev_priv, |
| 839 | intel_hdmi->ddc_bus)); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 840 | } |
| 841 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 842 | static bool |
| 843 | intel_hdmi_detect_audio(struct drm_connector *connector) |
| 844 | { |
| 845 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
| 846 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
| 847 | struct edid *edid; |
| 848 | bool has_audio = false; |
| 849 | |
| 850 | edid = drm_get_edid(connector, |
Daniel Kurtz | 3bd7d90 | 2012-03-28 02:36:14 +0800 | [diff] [blame] | 851 | intel_gmbus_get_adapter(dev_priv, |
| 852 | intel_hdmi->ddc_bus)); |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 853 | if (edid) { |
| 854 | if (edid->input & DRM_EDID_INPUT_DIGITAL) |
| 855 | has_audio = drm_detect_monitor_audio(edid); |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 856 | kfree(edid); |
| 857 | } |
| 858 | |
| 859 | return has_audio; |
| 860 | } |
| 861 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 862 | static int |
| 863 | intel_hdmi_set_property(struct drm_connector *connector, |
Paulo Zanoni | ed517fb | 2012-05-14 17:12:50 -0300 | [diff] [blame] | 864 | struct drm_property *property, |
| 865 | uint64_t val) |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 866 | { |
| 867 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 868 | struct intel_digital_port *intel_dig_port = |
| 869 | hdmi_to_dig_port(intel_hdmi); |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 870 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 871 | int ret; |
| 872 | |
| 873 | ret = drm_connector_property_set_value(connector, property, val); |
| 874 | if (ret) |
| 875 | return ret; |
| 876 | |
Chris Wilson | 3f43c48 | 2011-05-12 22:17:24 +0100 | [diff] [blame] | 877 | if (property == dev_priv->force_audio_property) { |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 878 | enum hdmi_force_audio i = val; |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 879 | bool has_audio; |
| 880 | |
| 881 | if (i == intel_hdmi->force_audio) |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 882 | return 0; |
| 883 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 884 | intel_hdmi->force_audio = i; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 885 | |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 886 | if (i == HDMI_AUDIO_AUTO) |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 887 | has_audio = intel_hdmi_detect_audio(connector); |
| 888 | else |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 889 | has_audio = (i == HDMI_AUDIO_ON); |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 890 | |
Wu Fengguang | b1d7e4b | 2012-02-14 11:45:36 +0800 | [diff] [blame] | 891 | if (i == HDMI_AUDIO_OFF_DVI) |
| 892 | intel_hdmi->has_hdmi_sink = 0; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 893 | |
Chris Wilson | 1aad7ac | 2011-02-09 18:46:58 +0000 | [diff] [blame] | 894 | intel_hdmi->has_audio = has_audio; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 895 | goto done; |
| 896 | } |
| 897 | |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 898 | if (property == dev_priv->broadcast_rgb_property) { |
| 899 | if (val == !!intel_hdmi->color_range) |
| 900 | return 0; |
| 901 | |
| 902 | intel_hdmi->color_range = val ? SDVO_COLOR_RANGE_16_235 : 0; |
| 903 | goto done; |
| 904 | } |
| 905 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 906 | return -EINVAL; |
| 907 | |
| 908 | done: |
Paulo Zanoni | da63a9f | 2012-10-26 19:05:46 -0200 | [diff] [blame] | 909 | if (intel_dig_port->base.base.crtc) { |
| 910 | struct drm_crtc *crtc = intel_dig_port->base.base.crtc; |
Daniel Vetter | a6778b3 | 2012-07-02 09:56:42 +0200 | [diff] [blame] | 911 | intel_set_mode(crtc, &crtc->mode, |
| 912 | crtc->x, crtc->y, crtc->fb); |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 913 | } |
| 914 | |
| 915 | return 0; |
| 916 | } |
| 917 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 918 | static void intel_hdmi_destroy(struct drm_connector *connector) |
| 919 | { |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 920 | drm_sysfs_connector_remove(connector); |
| 921 | drm_connector_cleanup(connector); |
Zhenyu Wang | 674e2d0 | 2010-03-29 15:57:42 +0800 | [diff] [blame] | 922 | kfree(connector); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 923 | } |
| 924 | |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 925 | static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs_hsw = { |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 926 | .mode_fixup = intel_hdmi_mode_fixup, |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 927 | .mode_set = intel_ddi_mode_set, |
Daniel Vetter | 1f70385 | 2012-07-11 16:51:39 +0200 | [diff] [blame] | 928 | .disable = intel_encoder_noop, |
Eugeni Dodonov | 72662e1 | 2012-05-09 15:37:31 -0300 | [diff] [blame] | 929 | }; |
| 930 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 931 | static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs = { |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 932 | .mode_fixup = intel_hdmi_mode_fixup, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 933 | .mode_set = intel_hdmi_mode_set, |
Daniel Vetter | 1f70385 | 2012-07-11 16:51:39 +0200 | [diff] [blame] | 934 | .disable = intel_encoder_noop, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 935 | }; |
| 936 | |
| 937 | static const struct drm_connector_funcs intel_hdmi_connector_funcs = { |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 938 | .dpms = intel_connector_dpms, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 939 | .detect = intel_hdmi_detect, |
| 940 | .fill_modes = drm_helper_probe_single_connector_modes, |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 941 | .set_property = intel_hdmi_set_property, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 942 | .destroy = intel_hdmi_destroy, |
| 943 | }; |
| 944 | |
| 945 | static const struct drm_connector_helper_funcs intel_hdmi_connector_helper_funcs = { |
| 946 | .get_modes = intel_hdmi_get_modes, |
| 947 | .mode_valid = intel_hdmi_mode_valid, |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 948 | .best_encoder = intel_best_encoder, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 949 | }; |
| 950 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 951 | static const struct drm_encoder_funcs intel_hdmi_enc_funcs = { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 952 | .destroy = intel_encoder_destroy, |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 953 | }; |
| 954 | |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 955 | static void |
| 956 | intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector) |
| 957 | { |
Chris Wilson | 3f43c48 | 2011-05-12 22:17:24 +0100 | [diff] [blame] | 958 | intel_attach_force_audio_property(connector); |
Chris Wilson | e953fd7 | 2011-02-21 22:23:52 +0000 | [diff] [blame] | 959 | intel_attach_broadcast_rgb_property(connector); |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 960 | } |
| 961 | |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame^] | 962 | static void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, |
| 963 | struct intel_connector *intel_connector) |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 964 | { |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame^] | 965 | struct drm_connector *connector = &intel_connector->base; |
| 966 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
| 967 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
| 968 | struct drm_device *dev = intel_encoder->base.dev; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 969 | struct drm_i915_private *dev_priv = dev->dev_private; |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame^] | 970 | enum port port = intel_hdmi->ddi_port; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 971 | |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 972 | drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, |
Adam Jackson | 8d91104 | 2009-09-23 15:08:29 -0400 | [diff] [blame] | 973 | DRM_MODE_CONNECTOR_HDMIA); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 974 | drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs); |
| 975 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 976 | connector->polled = DRM_CONNECTOR_POLL_HPD; |
Peter Ross | c3febcc | 2012-01-28 14:49:26 +0100 | [diff] [blame] | 977 | connector->interlace_allowed = 1; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 978 | connector->doublescan_allowed = 0; |
| 979 | |
Daniel Vetter | 08d644a | 2012-07-12 20:19:59 +0200 | [diff] [blame] | 980 | switch (port) { |
| 981 | case PORT_B: |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 982 | intel_hdmi->ddc_bus = GMBUS_PORT_DPB; |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 983 | dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS; |
Daniel Vetter | 08d644a | 2012-07-12 20:19:59 +0200 | [diff] [blame] | 984 | break; |
| 985 | case PORT_C: |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 986 | intel_hdmi->ddc_bus = GMBUS_PORT_DPC; |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 987 | dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS; |
Daniel Vetter | 08d644a | 2012-07-12 20:19:59 +0200 | [diff] [blame] | 988 | break; |
| 989 | case PORT_D: |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 990 | intel_hdmi->ddc_bus = GMBUS_PORT_DPD; |
Jesse Barnes | b01f2c3 | 2009-12-11 11:07:17 -0800 | [diff] [blame] | 991 | dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS; |
Daniel Vetter | 08d644a | 2012-07-12 20:19:59 +0200 | [diff] [blame] | 992 | break; |
| 993 | case PORT_A: |
| 994 | /* Internal port only for eDP. */ |
| 995 | default: |
Eugeni Dodonov | 6e4c167 | 2012-05-09 15:37:13 -0300 | [diff] [blame] | 996 | BUG(); |
Ma Ling | f8aed70 | 2009-08-24 13:50:24 +0800 | [diff] [blame] | 997 | } |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 998 | |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 999 | if (!HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | a3da1df | 2012-05-08 15:19:06 +0200 | [diff] [blame] | 1000 | intel_hdmi->write_infoframe = g4x_write_infoframe; |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 1001 | intel_hdmi->set_infoframes = g4x_set_infoframes; |
Shobhit Kumar | 90b107c | 2012-03-28 13:39:32 -0700 | [diff] [blame] | 1002 | } else if (IS_VALLEYVIEW(dev)) { |
| 1003 | intel_hdmi->write_infoframe = vlv_write_infoframe; |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 1004 | intel_hdmi->set_infoframes = vlv_set_infoframes; |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 1005 | } else if (IS_HASWELL(dev)) { |
Eugeni Dodonov | 8c5f5f7 | 2012-05-10 10:18:02 -0300 | [diff] [blame] | 1006 | intel_hdmi->write_infoframe = hsw_write_infoframe; |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 1007 | intel_hdmi->set_infoframes = hsw_set_infoframes; |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 1008 | } else if (HAS_PCH_IBX(dev)) { |
| 1009 | intel_hdmi->write_infoframe = ibx_write_infoframe; |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 1010 | intel_hdmi->set_infoframes = ibx_set_infoframes; |
Paulo Zanoni | fdf1250 | 2012-05-04 17:18:24 -0300 | [diff] [blame] | 1011 | } else { |
| 1012 | intel_hdmi->write_infoframe = cpt_write_infoframe; |
Paulo Zanoni | 687f4d0 | 2012-05-28 16:42:48 -0300 | [diff] [blame] | 1013 | intel_hdmi->set_infoframes = cpt_set_infoframes; |
Jesse Barnes | 64a8fc0 | 2011-09-22 11:16:00 +0530 | [diff] [blame] | 1014 | } |
Jesse Barnes | 45187ac | 2011-08-03 09:22:55 -0700 | [diff] [blame] | 1015 | |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame^] | 1016 | intel_connector->get_hw_state = intel_connector_get_hw_state; |
| 1017 | |
| 1018 | intel_hdmi_add_properties(intel_hdmi, connector); |
| 1019 | |
| 1020 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
| 1021 | drm_sysfs_connector_add(connector); |
| 1022 | |
| 1023 | /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written |
| 1024 | * 0xd. Failure to do so will result in spurious interrupts being |
| 1025 | * generated on the port when a cable is not attached. |
| 1026 | */ |
| 1027 | if (IS_G4X(dev) && !IS_GM45(dev)) { |
| 1028 | u32 temp = I915_READ(PEG_BAND_GAP_DATA); |
| 1029 | I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | void intel_hdmi_init(struct drm_device *dev, int sdvox_reg, enum port port) |
| 1034 | { |
| 1035 | struct intel_digital_port *intel_dig_port; |
| 1036 | struct intel_encoder *intel_encoder; |
| 1037 | struct drm_encoder *encoder; |
| 1038 | struct intel_connector *intel_connector; |
| 1039 | |
| 1040 | intel_dig_port = kzalloc(sizeof(struct intel_digital_port), GFP_KERNEL); |
| 1041 | if (!intel_dig_port) |
| 1042 | return; |
| 1043 | |
| 1044 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
| 1045 | if (!intel_connector) { |
| 1046 | kfree(intel_dig_port); |
| 1047 | return; |
| 1048 | } |
| 1049 | |
| 1050 | intel_encoder = &intel_dig_port->base; |
| 1051 | encoder = &intel_encoder->base; |
| 1052 | |
| 1053 | drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs, |
| 1054 | DRM_MODE_ENCODER_TMDS); |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1055 | if (IS_HASWELL(dev)) { |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1056 | intel_encoder->pre_enable = intel_ddi_pre_enable; |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1057 | intel_encoder->enable = intel_enable_ddi; |
| 1058 | intel_encoder->disable = intel_disable_ddi; |
Paulo Zanoni | 6441ab5 | 2012-10-05 12:05:58 -0300 | [diff] [blame] | 1059 | intel_encoder->post_disable = intel_ddi_post_disable; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1060 | intel_encoder->get_hw_state = intel_ddi_get_hw_state; |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1061 | drm_encoder_helper_add(&intel_encoder->base, |
| 1062 | &intel_hdmi_helper_funcs_hsw); |
| 1063 | } else { |
| 1064 | intel_encoder->enable = intel_enable_hdmi; |
| 1065 | intel_encoder->disable = intel_disable_hdmi; |
Daniel Vetter | 85234cd | 2012-07-02 13:27:29 +0200 | [diff] [blame] | 1066 | intel_encoder->get_hw_state = intel_hdmi_get_hw_state; |
Daniel Vetter | 5ab432e | 2012-06-30 08:59:56 +0200 | [diff] [blame] | 1067 | drm_encoder_helper_add(&intel_encoder->base, |
| 1068 | &intel_hdmi_helper_funcs); |
| 1069 | } |
| 1070 | |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame^] | 1071 | intel_encoder->type = INTEL_OUTPUT_HDMI; |
| 1072 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
| 1073 | intel_encoder->cloneable = false; |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1074 | |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame^] | 1075 | intel_dig_port->hdmi.ddi_port = port; |
| 1076 | intel_dig_port->hdmi.sdvox_reg = sdvox_reg; |
| 1077 | intel_dig_port->dp.output_reg = 0; |
Chris Wilson | 55b7d6e8 | 2010-09-19 09:29:33 +0100 | [diff] [blame] | 1078 | |
Paulo Zanoni | b9cb234 | 2012-10-26 19:05:47 -0200 | [diff] [blame^] | 1079 | intel_hdmi_init_connector(intel_dig_port, intel_connector); |
Eric Anholt | 7d57382 | 2009-01-02 13:33:00 -0800 | [diff] [blame] | 1080 | } |