Rev 5139 | Rev 6084 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5139 | Rev 5354 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright 2006 Dave Airlie |
2 | * Copyright 2006 Dave Airlie |
3 | * Copyright © 2006-2009 Intel Corporation |
3 | * Copyright © 2006-2009 Intel Corporation |
4 | * |
4 | * |
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
6 | * copy of this software and associated documentation files (the "Software"), |
6 | * copy of this software and associated documentation files (the "Software"), |
7 | * to deal in the Software without restriction, including without limitation |
7 | * to deal in the Software without restriction, including without limitation |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
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 |
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: |
10 | * Software is furnished to do so, subject to the following conditions: |
11 | * |
11 | * |
12 | * The above copyright notice and this permission notice (including the next |
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 |
13 | * paragraph) shall be included in all copies or substantial portions of the |
14 | * Software. |
14 | * Software. |
15 | * |
15 | * |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
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, |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
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 |
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 |
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 |
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | * DEALINGS IN THE SOFTWARE. |
22 | * DEALINGS IN THE SOFTWARE. |
23 | * |
23 | * |
24 | * Authors: |
24 | * Authors: |
25 | * Eric Anholt |
25 | * Eric Anholt |
26 | * Jesse Barnes |
26 | * Jesse Barnes |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include |
29 | #include |
30 | #include |
30 | #include |
31 | #include |
31 | #include |
32 | #include |
32 | #include |
33 | #include |
33 | #include |
34 | #include |
34 | #include |
35 | #include |
35 | #include |
36 | #include "intel_drv.h" |
36 | #include "intel_drv.h" |
37 | #include |
37 | #include |
38 | #include "i915_drv.h" |
38 | #include "i915_drv.h" |
39 | 39 | ||
40 | static struct drm_device *intel_hdmi_to_dev(struct intel_hdmi *intel_hdmi) |
40 | static struct drm_device *intel_hdmi_to_dev(struct intel_hdmi *intel_hdmi) |
41 | { |
41 | { |
42 | return hdmi_to_dig_port(intel_hdmi)->base.base.dev; |
42 | return hdmi_to_dig_port(intel_hdmi)->base.base.dev; |
43 | } |
43 | } |
44 | 44 | ||
45 | static void |
45 | static void |
46 | assert_hdmi_port_disabled(struct intel_hdmi *intel_hdmi) |
46 | assert_hdmi_port_disabled(struct intel_hdmi *intel_hdmi) |
47 | { |
47 | { |
48 | struct drm_device *dev = intel_hdmi_to_dev(intel_hdmi); |
48 | struct drm_device *dev = intel_hdmi_to_dev(intel_hdmi); |
49 | struct drm_i915_private *dev_priv = dev->dev_private; |
49 | struct drm_i915_private *dev_priv = dev->dev_private; |
50 | uint32_t enabled_bits; |
50 | uint32_t enabled_bits; |
51 | 51 | ||
52 | enabled_bits = HAS_DDI(dev) ? DDI_BUF_CTL_ENABLE : SDVO_ENABLE; |
52 | enabled_bits = HAS_DDI(dev) ? DDI_BUF_CTL_ENABLE : SDVO_ENABLE; |
53 | 53 | ||
54 | WARN(I915_READ(intel_hdmi->hdmi_reg) & enabled_bits, |
54 | WARN(I915_READ(intel_hdmi->hdmi_reg) & enabled_bits, |
55 | "HDMI port enabled, expecting disabled\n"); |
55 | "HDMI port enabled, expecting disabled\n"); |
56 | } |
56 | } |
57 | 57 | ||
58 | struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder) |
58 | struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder) |
59 | { |
59 | { |
60 | struct intel_digital_port *intel_dig_port = |
60 | struct intel_digital_port *intel_dig_port = |
61 | container_of(encoder, struct intel_digital_port, base.base); |
61 | container_of(encoder, struct intel_digital_port, base.base); |
62 | return &intel_dig_port->hdmi; |
62 | return &intel_dig_port->hdmi; |
63 | } |
63 | } |
64 | 64 | ||
65 | static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector) |
65 | static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector) |
66 | { |
66 | { |
67 | return enc_to_intel_hdmi(&intel_attached_encoder(connector)->base); |
67 | return enc_to_intel_hdmi(&intel_attached_encoder(connector)->base); |
68 | } |
68 | } |
69 | 69 | ||
70 | static u32 g4x_infoframe_index(enum hdmi_infoframe_type type) |
70 | static u32 g4x_infoframe_index(enum hdmi_infoframe_type type) |
71 | { |
71 | { |
72 | switch (type) { |
72 | switch (type) { |
73 | case HDMI_INFOFRAME_TYPE_AVI: |
73 | case HDMI_INFOFRAME_TYPE_AVI: |
74 | return VIDEO_DIP_SELECT_AVI; |
74 | return VIDEO_DIP_SELECT_AVI; |
75 | case HDMI_INFOFRAME_TYPE_SPD: |
75 | case HDMI_INFOFRAME_TYPE_SPD: |
76 | return VIDEO_DIP_SELECT_SPD; |
76 | return VIDEO_DIP_SELECT_SPD; |
77 | case HDMI_INFOFRAME_TYPE_VENDOR: |
77 | case HDMI_INFOFRAME_TYPE_VENDOR: |
78 | return VIDEO_DIP_SELECT_VENDOR; |
78 | return VIDEO_DIP_SELECT_VENDOR; |
79 | default: |
79 | default: |
80 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", type); |
80 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", type); |
81 | return 0; |
81 | return 0; |
82 | } |
82 | } |
83 | } |
83 | } |
84 | 84 | ||
85 | static u32 g4x_infoframe_enable(enum hdmi_infoframe_type type) |
85 | static u32 g4x_infoframe_enable(enum hdmi_infoframe_type type) |
86 | { |
86 | { |
87 | switch (type) { |
87 | switch (type) { |
88 | case HDMI_INFOFRAME_TYPE_AVI: |
88 | case HDMI_INFOFRAME_TYPE_AVI: |
89 | return VIDEO_DIP_ENABLE_AVI; |
89 | return VIDEO_DIP_ENABLE_AVI; |
90 | case HDMI_INFOFRAME_TYPE_SPD: |
90 | case HDMI_INFOFRAME_TYPE_SPD: |
91 | return VIDEO_DIP_ENABLE_SPD; |
91 | return VIDEO_DIP_ENABLE_SPD; |
92 | case HDMI_INFOFRAME_TYPE_VENDOR: |
92 | case HDMI_INFOFRAME_TYPE_VENDOR: |
93 | return VIDEO_DIP_ENABLE_VENDOR; |
93 | return VIDEO_DIP_ENABLE_VENDOR; |
94 | default: |
94 | default: |
95 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", type); |
95 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", type); |
96 | return 0; |
96 | return 0; |
97 | } |
97 | } |
98 | } |
98 | } |
99 | 99 | ||
100 | static u32 hsw_infoframe_enable(enum hdmi_infoframe_type type) |
100 | static u32 hsw_infoframe_enable(enum hdmi_infoframe_type type) |
101 | { |
101 | { |
102 | switch (type) { |
102 | switch (type) { |
103 | case HDMI_INFOFRAME_TYPE_AVI: |
103 | case HDMI_INFOFRAME_TYPE_AVI: |
104 | return VIDEO_DIP_ENABLE_AVI_HSW; |
104 | return VIDEO_DIP_ENABLE_AVI_HSW; |
105 | case HDMI_INFOFRAME_TYPE_SPD: |
105 | case HDMI_INFOFRAME_TYPE_SPD: |
106 | return VIDEO_DIP_ENABLE_SPD_HSW; |
106 | return VIDEO_DIP_ENABLE_SPD_HSW; |
107 | case HDMI_INFOFRAME_TYPE_VENDOR: |
107 | case HDMI_INFOFRAME_TYPE_VENDOR: |
108 | return VIDEO_DIP_ENABLE_VS_HSW; |
108 | return VIDEO_DIP_ENABLE_VS_HSW; |
109 | default: |
109 | default: |
110 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", type); |
110 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", type); |
111 | return 0; |
111 | return 0; |
112 | } |
112 | } |
113 | } |
113 | } |
114 | 114 | ||
115 | static u32 hsw_infoframe_data_reg(enum hdmi_infoframe_type type, |
115 | static u32 hsw_infoframe_data_reg(enum hdmi_infoframe_type type, |
116 | enum transcoder cpu_transcoder, |
116 | enum transcoder cpu_transcoder, |
117 | struct drm_i915_private *dev_priv) |
117 | struct drm_i915_private *dev_priv) |
118 | { |
118 | { |
119 | switch (type) { |
119 | switch (type) { |
120 | case HDMI_INFOFRAME_TYPE_AVI: |
120 | case HDMI_INFOFRAME_TYPE_AVI: |
121 | return HSW_TVIDEO_DIP_AVI_DATA(cpu_transcoder); |
121 | return HSW_TVIDEO_DIP_AVI_DATA(cpu_transcoder); |
122 | case HDMI_INFOFRAME_TYPE_SPD: |
122 | case HDMI_INFOFRAME_TYPE_SPD: |
123 | return HSW_TVIDEO_DIP_SPD_DATA(cpu_transcoder); |
123 | return HSW_TVIDEO_DIP_SPD_DATA(cpu_transcoder); |
124 | case HDMI_INFOFRAME_TYPE_VENDOR: |
124 | case HDMI_INFOFRAME_TYPE_VENDOR: |
125 | return HSW_TVIDEO_DIP_VS_DATA(cpu_transcoder); |
125 | return HSW_TVIDEO_DIP_VS_DATA(cpu_transcoder); |
126 | default: |
126 | default: |
127 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", type); |
127 | DRM_DEBUG_DRIVER("unknown info frame type %d\n", type); |
128 | return 0; |
128 | return 0; |
129 | } |
129 | } |
130 | } |
130 | } |
131 | 131 | ||
132 | static void g4x_write_infoframe(struct drm_encoder *encoder, |
132 | static void g4x_write_infoframe(struct drm_encoder *encoder, |
133 | enum hdmi_infoframe_type type, |
133 | enum hdmi_infoframe_type type, |
134 | const void *frame, ssize_t len) |
134 | const void *frame, ssize_t len) |
135 | { |
135 | { |
136 | const uint32_t *data = frame; |
136 | const uint32_t *data = frame; |
137 | struct drm_device *dev = encoder->dev; |
137 | struct drm_device *dev = encoder->dev; |
138 | struct drm_i915_private *dev_priv = dev->dev_private; |
138 | struct drm_i915_private *dev_priv = dev->dev_private; |
139 | u32 val = I915_READ(VIDEO_DIP_CTL); |
139 | u32 val = I915_READ(VIDEO_DIP_CTL); |
140 | int i; |
140 | int i; |
141 | 141 | ||
142 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
142 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
143 | 143 | ||
144 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
144 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
145 | val |= g4x_infoframe_index(type); |
145 | val |= g4x_infoframe_index(type); |
146 | 146 | ||
147 | val &= ~g4x_infoframe_enable(type); |
147 | val &= ~g4x_infoframe_enable(type); |
148 | 148 | ||
149 | I915_WRITE(VIDEO_DIP_CTL, val); |
149 | I915_WRITE(VIDEO_DIP_CTL, val); |
150 | 150 | ||
151 | mmiowb(); |
151 | mmiowb(); |
152 | for (i = 0; i < len; i += 4) { |
152 | for (i = 0; i < len; i += 4) { |
153 | I915_WRITE(VIDEO_DIP_DATA, *data); |
153 | I915_WRITE(VIDEO_DIP_DATA, *data); |
154 | data++; |
154 | data++; |
155 | } |
155 | } |
156 | /* Write every possible data byte to force correct ECC calculation. */ |
156 | /* Write every possible data byte to force correct ECC calculation. */ |
157 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
157 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
158 | I915_WRITE(VIDEO_DIP_DATA, 0); |
158 | I915_WRITE(VIDEO_DIP_DATA, 0); |
159 | mmiowb(); |
159 | mmiowb(); |
160 | 160 | ||
161 | val |= g4x_infoframe_enable(type); |
161 | val |= g4x_infoframe_enable(type); |
162 | val &= ~VIDEO_DIP_FREQ_MASK; |
162 | val &= ~VIDEO_DIP_FREQ_MASK; |
163 | val |= VIDEO_DIP_FREQ_VSYNC; |
163 | val |= VIDEO_DIP_FREQ_VSYNC; |
164 | 164 | ||
165 | I915_WRITE(VIDEO_DIP_CTL, val); |
165 | I915_WRITE(VIDEO_DIP_CTL, val); |
166 | POSTING_READ(VIDEO_DIP_CTL); |
166 | POSTING_READ(VIDEO_DIP_CTL); |
167 | } |
167 | } |
- | 168 | ||
- | 169 | static bool g4x_infoframe_enabled(struct drm_encoder *encoder) |
|
- | 170 | { |
|
- | 171 | struct drm_device *dev = encoder->dev; |
|
- | 172 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 173 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
|
- | 174 | u32 val = I915_READ(VIDEO_DIP_CTL); |
|
- | 175 | ||
- | 176 | if (VIDEO_DIP_PORT(intel_dig_port->port) == (val & VIDEO_DIP_PORT_MASK)) |
|
- | 177 | return val & VIDEO_DIP_ENABLE; |
|
- | 178 | ||
- | 179 | return false; |
|
- | 180 | } |
|
168 | 181 | ||
169 | static void ibx_write_infoframe(struct drm_encoder *encoder, |
182 | static void ibx_write_infoframe(struct drm_encoder *encoder, |
170 | enum hdmi_infoframe_type type, |
183 | enum hdmi_infoframe_type type, |
171 | const void *frame, ssize_t len) |
184 | const void *frame, ssize_t len) |
172 | { |
185 | { |
173 | const uint32_t *data = frame; |
186 | const uint32_t *data = frame; |
174 | struct drm_device *dev = encoder->dev; |
187 | struct drm_device *dev = encoder->dev; |
175 | struct drm_i915_private *dev_priv = dev->dev_private; |
188 | struct drm_i915_private *dev_priv = dev->dev_private; |
176 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
189 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
177 | int i, reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
190 | int i, reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
178 | u32 val = I915_READ(reg); |
191 | u32 val = I915_READ(reg); |
179 | 192 | ||
180 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
193 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
181 | 194 | ||
182 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
195 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
183 | val |= g4x_infoframe_index(type); |
196 | val |= g4x_infoframe_index(type); |
184 | 197 | ||
185 | val &= ~g4x_infoframe_enable(type); |
198 | val &= ~g4x_infoframe_enable(type); |
186 | 199 | ||
187 | I915_WRITE(reg, val); |
200 | I915_WRITE(reg, val); |
188 | 201 | ||
189 | mmiowb(); |
202 | mmiowb(); |
190 | for (i = 0; i < len; i += 4) { |
203 | for (i = 0; i < len; i += 4) { |
191 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
204 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
192 | data++; |
205 | data++; |
193 | } |
206 | } |
194 | /* Write every possible data byte to force correct ECC calculation. */ |
207 | /* Write every possible data byte to force correct ECC calculation. */ |
195 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
208 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
196 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
209 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
197 | mmiowb(); |
210 | mmiowb(); |
198 | 211 | ||
199 | val |= g4x_infoframe_enable(type); |
212 | val |= g4x_infoframe_enable(type); |
200 | val &= ~VIDEO_DIP_FREQ_MASK; |
213 | val &= ~VIDEO_DIP_FREQ_MASK; |
201 | val |= VIDEO_DIP_FREQ_VSYNC; |
214 | val |= VIDEO_DIP_FREQ_VSYNC; |
202 | 215 | ||
203 | I915_WRITE(reg, val); |
216 | I915_WRITE(reg, val); |
204 | POSTING_READ(reg); |
217 | POSTING_READ(reg); |
205 | } |
218 | } |
- | 219 | ||
- | 220 | static bool ibx_infoframe_enabled(struct drm_encoder *encoder) |
|
- | 221 | { |
|
- | 222 | struct drm_device *dev = encoder->dev; |
|
- | 223 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 224 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
|
- | 225 | int reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
|
- | 226 | u32 val = I915_READ(reg); |
|
- | 227 | ||
- | 228 | return val & VIDEO_DIP_ENABLE; |
|
- | 229 | } |
|
206 | 230 | ||
207 | static void cpt_write_infoframe(struct drm_encoder *encoder, |
231 | static void cpt_write_infoframe(struct drm_encoder *encoder, |
208 | enum hdmi_infoframe_type type, |
232 | enum hdmi_infoframe_type type, |
209 | const void *frame, ssize_t len) |
233 | const void *frame, ssize_t len) |
210 | { |
234 | { |
211 | const uint32_t *data = frame; |
235 | const uint32_t *data = frame; |
212 | struct drm_device *dev = encoder->dev; |
236 | struct drm_device *dev = encoder->dev; |
213 | struct drm_i915_private *dev_priv = dev->dev_private; |
237 | struct drm_i915_private *dev_priv = dev->dev_private; |
214 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
238 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
215 | int i, reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
239 | int i, reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
216 | u32 val = I915_READ(reg); |
240 | u32 val = I915_READ(reg); |
217 | 241 | ||
218 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
242 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
219 | 243 | ||
220 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
244 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
221 | val |= g4x_infoframe_index(type); |
245 | val |= g4x_infoframe_index(type); |
222 | 246 | ||
223 | /* The DIP control register spec says that we need to update the AVI |
247 | /* The DIP control register spec says that we need to update the AVI |
224 | * infoframe without clearing its enable bit */ |
248 | * infoframe without clearing its enable bit */ |
225 | if (type != HDMI_INFOFRAME_TYPE_AVI) |
249 | if (type != HDMI_INFOFRAME_TYPE_AVI) |
226 | val &= ~g4x_infoframe_enable(type); |
250 | val &= ~g4x_infoframe_enable(type); |
227 | 251 | ||
228 | I915_WRITE(reg, val); |
252 | I915_WRITE(reg, val); |
229 | 253 | ||
230 | mmiowb(); |
254 | mmiowb(); |
231 | for (i = 0; i < len; i += 4) { |
255 | for (i = 0; i < len; i += 4) { |
232 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
256 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
233 | data++; |
257 | data++; |
234 | } |
258 | } |
235 | /* Write every possible data byte to force correct ECC calculation. */ |
259 | /* Write every possible data byte to force correct ECC calculation. */ |
236 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
260 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
237 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
261 | I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
238 | mmiowb(); |
262 | mmiowb(); |
239 | 263 | ||
240 | val |= g4x_infoframe_enable(type); |
264 | val |= g4x_infoframe_enable(type); |
241 | val &= ~VIDEO_DIP_FREQ_MASK; |
265 | val &= ~VIDEO_DIP_FREQ_MASK; |
242 | val |= VIDEO_DIP_FREQ_VSYNC; |
266 | val |= VIDEO_DIP_FREQ_VSYNC; |
243 | 267 | ||
244 | I915_WRITE(reg, val); |
268 | I915_WRITE(reg, val); |
245 | POSTING_READ(reg); |
269 | POSTING_READ(reg); |
246 | } |
270 | } |
- | 271 | ||
- | 272 | static bool cpt_infoframe_enabled(struct drm_encoder *encoder) |
|
- | 273 | { |
|
- | 274 | struct drm_device *dev = encoder->dev; |
|
- | 275 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 276 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
|
- | 277 | int reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
|
- | 278 | u32 val = I915_READ(reg); |
|
- | 279 | ||
- | 280 | return val & VIDEO_DIP_ENABLE; |
|
- | 281 | } |
|
247 | 282 | ||
248 | static void vlv_write_infoframe(struct drm_encoder *encoder, |
283 | static void vlv_write_infoframe(struct drm_encoder *encoder, |
249 | enum hdmi_infoframe_type type, |
284 | enum hdmi_infoframe_type type, |
250 | const void *frame, ssize_t len) |
285 | const void *frame, ssize_t len) |
251 | { |
286 | { |
252 | const uint32_t *data = frame; |
287 | const uint32_t *data = frame; |
253 | struct drm_device *dev = encoder->dev; |
288 | struct drm_device *dev = encoder->dev; |
254 | struct drm_i915_private *dev_priv = dev->dev_private; |
289 | struct drm_i915_private *dev_priv = dev->dev_private; |
255 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
290 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
256 | int i, reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe); |
291 | int i, reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe); |
257 | u32 val = I915_READ(reg); |
292 | u32 val = I915_READ(reg); |
258 | 293 | ||
259 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
294 | WARN(!(val & VIDEO_DIP_ENABLE), "Writing DIP with CTL reg disabled\n"); |
260 | 295 | ||
261 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
296 | val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */ |
262 | val |= g4x_infoframe_index(type); |
297 | val |= g4x_infoframe_index(type); |
263 | 298 | ||
264 | val &= ~g4x_infoframe_enable(type); |
299 | val &= ~g4x_infoframe_enable(type); |
265 | 300 | ||
266 | I915_WRITE(reg, val); |
301 | I915_WRITE(reg, val); |
267 | 302 | ||
268 | mmiowb(); |
303 | mmiowb(); |
269 | for (i = 0; i < len; i += 4) { |
304 | for (i = 0; i < len; i += 4) { |
270 | I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
305 | I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), *data); |
271 | data++; |
306 | data++; |
272 | } |
307 | } |
273 | /* Write every possible data byte to force correct ECC calculation. */ |
308 | /* Write every possible data byte to force correct ECC calculation. */ |
274 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
309 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
275 | I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
310 | I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), 0); |
276 | mmiowb(); |
311 | mmiowb(); |
277 | 312 | ||
278 | val |= g4x_infoframe_enable(type); |
313 | val |= g4x_infoframe_enable(type); |
279 | val &= ~VIDEO_DIP_FREQ_MASK; |
314 | val &= ~VIDEO_DIP_FREQ_MASK; |
280 | val |= VIDEO_DIP_FREQ_VSYNC; |
315 | val |= VIDEO_DIP_FREQ_VSYNC; |
281 | 316 | ||
282 | I915_WRITE(reg, val); |
317 | I915_WRITE(reg, val); |
283 | POSTING_READ(reg); |
318 | POSTING_READ(reg); |
284 | } |
319 | } |
- | 320 | ||
- | 321 | static bool vlv_infoframe_enabled(struct drm_encoder *encoder) |
|
- | 322 | { |
|
- | 323 | struct drm_device *dev = encoder->dev; |
|
- | 324 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 325 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
|
- | 326 | int reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe); |
|
- | 327 | u32 val = I915_READ(reg); |
|
- | 328 | ||
- | 329 | return val & VIDEO_DIP_ENABLE; |
|
- | 330 | } |
|
285 | 331 | ||
286 | static void hsw_write_infoframe(struct drm_encoder *encoder, |
332 | static void hsw_write_infoframe(struct drm_encoder *encoder, |
287 | enum hdmi_infoframe_type type, |
333 | enum hdmi_infoframe_type type, |
288 | const void *frame, ssize_t len) |
334 | const void *frame, ssize_t len) |
289 | { |
335 | { |
290 | const uint32_t *data = frame; |
336 | const uint32_t *data = frame; |
291 | struct drm_device *dev = encoder->dev; |
337 | struct drm_device *dev = encoder->dev; |
292 | struct drm_i915_private *dev_priv = dev->dev_private; |
338 | struct drm_i915_private *dev_priv = dev->dev_private; |
293 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
339 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
294 | u32 ctl_reg = HSW_TVIDEO_DIP_CTL(intel_crtc->config.cpu_transcoder); |
340 | u32 ctl_reg = HSW_TVIDEO_DIP_CTL(intel_crtc->config.cpu_transcoder); |
295 | u32 data_reg; |
341 | u32 data_reg; |
296 | int i; |
342 | int i; |
297 | u32 val = I915_READ(ctl_reg); |
343 | u32 val = I915_READ(ctl_reg); |
298 | 344 | ||
299 | data_reg = hsw_infoframe_data_reg(type, |
345 | data_reg = hsw_infoframe_data_reg(type, |
300 | intel_crtc->config.cpu_transcoder, |
346 | intel_crtc->config.cpu_transcoder, |
301 | dev_priv); |
347 | dev_priv); |
302 | if (data_reg == 0) |
348 | if (data_reg == 0) |
303 | return; |
349 | return; |
304 | 350 | ||
305 | val &= ~hsw_infoframe_enable(type); |
351 | val &= ~hsw_infoframe_enable(type); |
306 | I915_WRITE(ctl_reg, val); |
352 | I915_WRITE(ctl_reg, val); |
307 | 353 | ||
308 | mmiowb(); |
354 | mmiowb(); |
309 | for (i = 0; i < len; i += 4) { |
355 | for (i = 0; i < len; i += 4) { |
310 | I915_WRITE(data_reg + i, *data); |
356 | I915_WRITE(data_reg + i, *data); |
311 | data++; |
357 | data++; |
312 | } |
358 | } |
313 | /* Write every possible data byte to force correct ECC calculation. */ |
359 | /* Write every possible data byte to force correct ECC calculation. */ |
314 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
360 | for (; i < VIDEO_DIP_DATA_SIZE; i += 4) |
315 | I915_WRITE(data_reg + i, 0); |
361 | I915_WRITE(data_reg + i, 0); |
316 | mmiowb(); |
362 | mmiowb(); |
317 | 363 | ||
318 | val |= hsw_infoframe_enable(type); |
364 | val |= hsw_infoframe_enable(type); |
319 | I915_WRITE(ctl_reg, val); |
365 | I915_WRITE(ctl_reg, val); |
320 | POSTING_READ(ctl_reg); |
366 | POSTING_READ(ctl_reg); |
321 | } |
367 | } |
- | 368 | ||
- | 369 | static bool hsw_infoframe_enabled(struct drm_encoder *encoder) |
|
- | 370 | { |
|
- | 371 | struct drm_device *dev = encoder->dev; |
|
- | 372 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 373 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
|
- | 374 | u32 ctl_reg = HSW_TVIDEO_DIP_CTL(intel_crtc->config.cpu_transcoder); |
|
- | 375 | u32 val = I915_READ(ctl_reg); |
|
- | 376 | ||
- | 377 | return val & (VIDEO_DIP_ENABLE_AVI_HSW | VIDEO_DIP_ENABLE_SPD_HSW | |
|
- | 378 | VIDEO_DIP_ENABLE_VS_HSW); |
|
- | 379 | } |
|
322 | 380 | ||
323 | /* |
381 | /* |
324 | * The data we write to the DIP data buffer registers is 1 byte bigger than the |
382 | * The data we write to the DIP data buffer registers is 1 byte bigger than the |
325 | * HDMI infoframe size because of an ECC/reserved byte at position 3 (starting |
383 | * HDMI infoframe size because of an ECC/reserved byte at position 3 (starting |
326 | * at 0). It's also a byte used by DisplayPort so the same DIP registers can be |
384 | * at 0). It's also a byte used by DisplayPort so the same DIP registers can be |
327 | * used for both technologies. |
385 | * used for both technologies. |
328 | * |
386 | * |
329 | * DW0: Reserved/ECC/DP | HB2 | HB1 | HB0 |
387 | * DW0: Reserved/ECC/DP | HB2 | HB1 | HB0 |
330 | * DW1: DB3 | DB2 | DB1 | DB0 |
388 | * DW1: DB3 | DB2 | DB1 | DB0 |
331 | * DW2: DB7 | DB6 | DB5 | DB4 |
389 | * DW2: DB7 | DB6 | DB5 | DB4 |
332 | * DW3: ... |
390 | * DW3: ... |
333 | * |
391 | * |
334 | * (HB is Header Byte, DB is Data Byte) |
392 | * (HB is Header Byte, DB is Data Byte) |
335 | * |
393 | * |
336 | * The hdmi pack() functions don't know about that hardware specific hole so we |
394 | * The hdmi pack() functions don't know about that hardware specific hole so we |
337 | * trick them by giving an offset into the buffer and moving back the header |
395 | * trick them by giving an offset into the buffer and moving back the header |
338 | * bytes by one. |
396 | * bytes by one. |
339 | */ |
397 | */ |
340 | static void intel_write_infoframe(struct drm_encoder *encoder, |
398 | static void intel_write_infoframe(struct drm_encoder *encoder, |
341 | union hdmi_infoframe *frame) |
399 | union hdmi_infoframe *frame) |
342 | { |
400 | { |
343 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
401 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
344 | uint8_t buffer[VIDEO_DIP_DATA_SIZE]; |
402 | uint8_t buffer[VIDEO_DIP_DATA_SIZE]; |
345 | ssize_t len; |
403 | ssize_t len; |
346 | 404 | ||
347 | /* see comment above for the reason for this offset */ |
405 | /* see comment above for the reason for this offset */ |
348 | len = hdmi_infoframe_pack(frame, buffer + 1, sizeof(buffer) - 1); |
406 | len = hdmi_infoframe_pack(frame, buffer + 1, sizeof(buffer) - 1); |
349 | if (len < 0) |
407 | if (len < 0) |
350 | return; |
408 | return; |
351 | 409 | ||
352 | /* Insert the 'hole' (see big comment above) at position 3 */ |
410 | /* Insert the 'hole' (see big comment above) at position 3 */ |
353 | buffer[0] = buffer[1]; |
411 | buffer[0] = buffer[1]; |
354 | buffer[1] = buffer[2]; |
412 | buffer[1] = buffer[2]; |
355 | buffer[2] = buffer[3]; |
413 | buffer[2] = buffer[3]; |
356 | buffer[3] = 0; |
414 | buffer[3] = 0; |
357 | len++; |
415 | len++; |
358 | 416 | ||
359 | intel_hdmi->write_infoframe(encoder, frame->any.type, buffer, len); |
417 | intel_hdmi->write_infoframe(encoder, frame->any.type, buffer, len); |
360 | } |
418 | } |
361 | 419 | ||
362 | static void intel_hdmi_set_avi_infoframe(struct drm_encoder *encoder, |
420 | static void intel_hdmi_set_avi_infoframe(struct drm_encoder *encoder, |
363 | struct drm_display_mode *adjusted_mode) |
421 | struct drm_display_mode *adjusted_mode) |
364 | { |
422 | { |
365 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
423 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
366 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
424 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
367 | union hdmi_infoframe frame; |
425 | union hdmi_infoframe frame; |
368 | int ret; |
426 | int ret; |
369 | 427 | ||
370 | /* Set user selected PAR to incoming mode's member */ |
428 | /* Set user selected PAR to incoming mode's member */ |
371 | adjusted_mode->picture_aspect_ratio = intel_hdmi->aspect_ratio; |
429 | adjusted_mode->picture_aspect_ratio = intel_hdmi->aspect_ratio; |
372 | 430 | ||
373 | ret = drm_hdmi_avi_infoframe_from_display_mode(&frame.avi, |
431 | ret = drm_hdmi_avi_infoframe_from_display_mode(&frame.avi, |
374 | adjusted_mode); |
432 | adjusted_mode); |
375 | if (ret < 0) { |
433 | if (ret < 0) { |
376 | DRM_ERROR("couldn't fill AVI infoframe\n"); |
434 | DRM_ERROR("couldn't fill AVI infoframe\n"); |
377 | return; |
435 | return; |
378 | } |
436 | } |
379 | 437 | ||
380 | if (intel_hdmi->rgb_quant_range_selectable) { |
438 | if (intel_hdmi->rgb_quant_range_selectable) { |
381 | if (intel_crtc->config.limited_color_range) |
439 | if (intel_crtc->config.limited_color_range) |
382 | frame.avi.quantization_range = |
440 | frame.avi.quantization_range = |
383 | HDMI_QUANTIZATION_RANGE_LIMITED; |
441 | HDMI_QUANTIZATION_RANGE_LIMITED; |
384 | else |
442 | else |
385 | frame.avi.quantization_range = |
443 | frame.avi.quantization_range = |
386 | HDMI_QUANTIZATION_RANGE_FULL; |
444 | HDMI_QUANTIZATION_RANGE_FULL; |
387 | } |
445 | } |
388 | 446 | ||
389 | intel_write_infoframe(encoder, &frame); |
447 | intel_write_infoframe(encoder, &frame); |
390 | } |
448 | } |
391 | 449 | ||
392 | static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder) |
450 | static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder) |
393 | { |
451 | { |
394 | union hdmi_infoframe frame; |
452 | union hdmi_infoframe frame; |
395 | int ret; |
453 | int ret; |
396 | 454 | ||
397 | ret = hdmi_spd_infoframe_init(&frame.spd, "Intel", "Integrated gfx"); |
455 | ret = hdmi_spd_infoframe_init(&frame.spd, "Intel", "Integrated gfx"); |
398 | if (ret < 0) { |
456 | if (ret < 0) { |
399 | DRM_ERROR("couldn't fill SPD infoframe\n"); |
457 | DRM_ERROR("couldn't fill SPD infoframe\n"); |
400 | return; |
458 | return; |
401 | } |
459 | } |
402 | 460 | ||
403 | frame.spd.sdi = HDMI_SPD_SDI_PC; |
461 | frame.spd.sdi = HDMI_SPD_SDI_PC; |
404 | 462 | ||
405 | intel_write_infoframe(encoder, &frame); |
463 | intel_write_infoframe(encoder, &frame); |
406 | } |
464 | } |
407 | 465 | ||
408 | static void |
466 | static void |
409 | intel_hdmi_set_hdmi_infoframe(struct drm_encoder *encoder, |
467 | intel_hdmi_set_hdmi_infoframe(struct drm_encoder *encoder, |
410 | struct drm_display_mode *adjusted_mode) |
468 | struct drm_display_mode *adjusted_mode) |
411 | { |
469 | { |
412 | union hdmi_infoframe frame; |
470 | union hdmi_infoframe frame; |
413 | int ret; |
471 | int ret; |
414 | 472 | ||
415 | ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi, |
473 | ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi, |
416 | adjusted_mode); |
474 | adjusted_mode); |
417 | if (ret < 0) |
475 | if (ret < 0) |
418 | return; |
476 | return; |
419 | 477 | ||
420 | intel_write_infoframe(encoder, &frame); |
478 | intel_write_infoframe(encoder, &frame); |
421 | } |
479 | } |
422 | 480 | ||
423 | static void g4x_set_infoframes(struct drm_encoder *encoder, |
481 | static void g4x_set_infoframes(struct drm_encoder *encoder, |
424 | bool enable, |
482 | bool enable, |
425 | struct drm_display_mode *adjusted_mode) |
483 | struct drm_display_mode *adjusted_mode) |
426 | { |
484 | { |
427 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
485 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
428 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
486 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
429 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
487 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
430 | u32 reg = VIDEO_DIP_CTL; |
488 | u32 reg = VIDEO_DIP_CTL; |
431 | u32 val = I915_READ(reg); |
489 | u32 val = I915_READ(reg); |
432 | u32 port = VIDEO_DIP_PORT(intel_dig_port->port); |
490 | u32 port = VIDEO_DIP_PORT(intel_dig_port->port); |
433 | 491 | ||
434 | assert_hdmi_port_disabled(intel_hdmi); |
492 | assert_hdmi_port_disabled(intel_hdmi); |
435 | 493 | ||
436 | /* If the registers were not initialized yet, they might be zeroes, |
494 | /* If the registers were not initialized yet, they might be zeroes, |
437 | * which means we're selecting the AVI DIP and we're setting its |
495 | * which means we're selecting the AVI DIP and we're setting its |
438 | * frequency to once. This seems to really confuse the HW and make |
496 | * frequency to once. This seems to really confuse the HW and make |
439 | * things stop working (the register spec says the AVI always needs to |
497 | * things stop working (the register spec says the AVI always needs to |
440 | * be sent every VSync). So here we avoid writing to the register more |
498 | * be sent every VSync). So here we avoid writing to the register more |
441 | * than we need and also explicitly select the AVI DIP and explicitly |
499 | * than we need and also explicitly select the AVI DIP and explicitly |
442 | * set its frequency to every VSync. Avoiding to write it twice seems to |
500 | * set its frequency to every VSync. Avoiding to write it twice seems to |
443 | * be enough to solve the problem, but being defensive shouldn't hurt us |
501 | * be enough to solve the problem, but being defensive shouldn't hurt us |
444 | * either. */ |
502 | * either. */ |
445 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
503 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
446 | 504 | ||
447 | if (!enable) { |
505 | if (!enable) { |
448 | if (!(val & VIDEO_DIP_ENABLE)) |
506 | if (!(val & VIDEO_DIP_ENABLE)) |
449 | return; |
507 | return; |
450 | val &= ~VIDEO_DIP_ENABLE; |
508 | val &= ~VIDEO_DIP_ENABLE; |
451 | I915_WRITE(reg, val); |
509 | I915_WRITE(reg, val); |
452 | POSTING_READ(reg); |
510 | POSTING_READ(reg); |
453 | return; |
511 | return; |
454 | } |
512 | } |
455 | 513 | ||
456 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
514 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
457 | if (val & VIDEO_DIP_ENABLE) { |
515 | if (val & VIDEO_DIP_ENABLE) { |
458 | val &= ~VIDEO_DIP_ENABLE; |
516 | val &= ~VIDEO_DIP_ENABLE; |
459 | I915_WRITE(reg, val); |
517 | I915_WRITE(reg, val); |
460 | POSTING_READ(reg); |
518 | POSTING_READ(reg); |
461 | } |
519 | } |
462 | val &= ~VIDEO_DIP_PORT_MASK; |
520 | val &= ~VIDEO_DIP_PORT_MASK; |
463 | val |= port; |
521 | val |= port; |
464 | } |
522 | } |
465 | 523 | ||
466 | val |= VIDEO_DIP_ENABLE; |
524 | val |= VIDEO_DIP_ENABLE; |
467 | val &= ~VIDEO_DIP_ENABLE_VENDOR; |
525 | val &= ~VIDEO_DIP_ENABLE_VENDOR; |
468 | 526 | ||
469 | I915_WRITE(reg, val); |
527 | I915_WRITE(reg, val); |
470 | POSTING_READ(reg); |
528 | POSTING_READ(reg); |
471 | 529 | ||
472 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
530 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
473 | intel_hdmi_set_spd_infoframe(encoder); |
531 | intel_hdmi_set_spd_infoframe(encoder); |
474 | intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode); |
532 | intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode); |
475 | } |
533 | } |
476 | 534 | ||
477 | static void ibx_set_infoframes(struct drm_encoder *encoder, |
535 | static void ibx_set_infoframes(struct drm_encoder *encoder, |
478 | bool enable, |
536 | bool enable, |
479 | struct drm_display_mode *adjusted_mode) |
537 | struct drm_display_mode *adjusted_mode) |
480 | { |
538 | { |
481 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
539 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
482 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
540 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
483 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
541 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
484 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
542 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
485 | u32 reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
543 | u32 reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
486 | u32 val = I915_READ(reg); |
544 | u32 val = I915_READ(reg); |
487 | u32 port = VIDEO_DIP_PORT(intel_dig_port->port); |
545 | u32 port = VIDEO_DIP_PORT(intel_dig_port->port); |
488 | 546 | ||
489 | assert_hdmi_port_disabled(intel_hdmi); |
547 | assert_hdmi_port_disabled(intel_hdmi); |
490 | 548 | ||
491 | /* See the big comment in g4x_set_infoframes() */ |
549 | /* See the big comment in g4x_set_infoframes() */ |
492 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
550 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
493 | 551 | ||
494 | if (!enable) { |
552 | if (!enable) { |
495 | if (!(val & VIDEO_DIP_ENABLE)) |
553 | if (!(val & VIDEO_DIP_ENABLE)) |
496 | return; |
554 | return; |
497 | val &= ~VIDEO_DIP_ENABLE; |
555 | val &= ~VIDEO_DIP_ENABLE; |
498 | I915_WRITE(reg, val); |
556 | I915_WRITE(reg, val); |
499 | POSTING_READ(reg); |
557 | POSTING_READ(reg); |
500 | return; |
558 | return; |
501 | } |
559 | } |
502 | 560 | ||
503 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
561 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
504 | if (val & VIDEO_DIP_ENABLE) { |
562 | if (val & VIDEO_DIP_ENABLE) { |
505 | val &= ~VIDEO_DIP_ENABLE; |
563 | val &= ~VIDEO_DIP_ENABLE; |
506 | I915_WRITE(reg, val); |
564 | I915_WRITE(reg, val); |
507 | POSTING_READ(reg); |
565 | POSTING_READ(reg); |
508 | } |
566 | } |
509 | val &= ~VIDEO_DIP_PORT_MASK; |
567 | val &= ~VIDEO_DIP_PORT_MASK; |
510 | val |= port; |
568 | val |= port; |
511 | } |
569 | } |
512 | 570 | ||
513 | val |= VIDEO_DIP_ENABLE; |
571 | val |= VIDEO_DIP_ENABLE; |
514 | val &= ~(VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
572 | val &= ~(VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
515 | VIDEO_DIP_ENABLE_GCP); |
573 | VIDEO_DIP_ENABLE_GCP); |
516 | 574 | ||
517 | I915_WRITE(reg, val); |
575 | I915_WRITE(reg, val); |
518 | POSTING_READ(reg); |
576 | POSTING_READ(reg); |
519 | 577 | ||
520 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
578 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
521 | intel_hdmi_set_spd_infoframe(encoder); |
579 | intel_hdmi_set_spd_infoframe(encoder); |
522 | intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode); |
580 | intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode); |
523 | } |
581 | } |
524 | 582 | ||
525 | static void cpt_set_infoframes(struct drm_encoder *encoder, |
583 | static void cpt_set_infoframes(struct drm_encoder *encoder, |
526 | bool enable, |
584 | bool enable, |
527 | struct drm_display_mode *adjusted_mode) |
585 | struct drm_display_mode *adjusted_mode) |
528 | { |
586 | { |
529 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
587 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
530 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
588 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
531 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
589 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
532 | u32 reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
590 | u32 reg = TVIDEO_DIP_CTL(intel_crtc->pipe); |
533 | u32 val = I915_READ(reg); |
591 | u32 val = I915_READ(reg); |
534 | 592 | ||
535 | assert_hdmi_port_disabled(intel_hdmi); |
593 | assert_hdmi_port_disabled(intel_hdmi); |
536 | 594 | ||
537 | /* See the big comment in g4x_set_infoframes() */ |
595 | /* See the big comment in g4x_set_infoframes() */ |
538 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
596 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
539 | 597 | ||
540 | if (!enable) { |
598 | if (!enable) { |
541 | if (!(val & VIDEO_DIP_ENABLE)) |
599 | if (!(val & VIDEO_DIP_ENABLE)) |
542 | return; |
600 | return; |
543 | val &= ~(VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI); |
601 | val &= ~(VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI); |
544 | I915_WRITE(reg, val); |
602 | I915_WRITE(reg, val); |
545 | POSTING_READ(reg); |
603 | POSTING_READ(reg); |
546 | return; |
604 | return; |
547 | } |
605 | } |
548 | 606 | ||
549 | /* Set both together, unset both together: see the spec. */ |
607 | /* Set both together, unset both together: see the spec. */ |
550 | val |= VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI; |
608 | val |= VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI; |
551 | val &= ~(VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
609 | val &= ~(VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT | |
552 | VIDEO_DIP_ENABLE_GCP); |
610 | VIDEO_DIP_ENABLE_GCP); |
553 | 611 | ||
554 | I915_WRITE(reg, val); |
612 | I915_WRITE(reg, val); |
555 | POSTING_READ(reg); |
613 | POSTING_READ(reg); |
556 | 614 | ||
557 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
615 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
558 | intel_hdmi_set_spd_infoframe(encoder); |
616 | intel_hdmi_set_spd_infoframe(encoder); |
559 | intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode); |
617 | intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode); |
560 | } |
618 | } |
561 | 619 | ||
562 | static void vlv_set_infoframes(struct drm_encoder *encoder, |
620 | static void vlv_set_infoframes(struct drm_encoder *encoder, |
563 | bool enable, |
621 | bool enable, |
564 | struct drm_display_mode *adjusted_mode) |
622 | struct drm_display_mode *adjusted_mode) |
565 | { |
623 | { |
566 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
624 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
567 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
625 | struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); |
568 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
626 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
569 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
627 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
570 | u32 reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe); |
628 | u32 reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe); |
571 | u32 val = I915_READ(reg); |
629 | u32 val = I915_READ(reg); |
572 | u32 port = VIDEO_DIP_PORT(intel_dig_port->port); |
630 | u32 port = VIDEO_DIP_PORT(intel_dig_port->port); |
573 | 631 | ||
574 | assert_hdmi_port_disabled(intel_hdmi); |
632 | assert_hdmi_port_disabled(intel_hdmi); |
575 | 633 | ||
576 | /* See the big comment in g4x_set_infoframes() */ |
634 | /* See the big comment in g4x_set_infoframes() */ |
577 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
635 | val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC; |
578 | 636 | ||
579 | if (!enable) { |
637 | if (!enable) { |
580 | if (!(val & VIDEO_DIP_ENABLE)) |
638 | if (!(val & VIDEO_DIP_ENABLE)) |
581 | return; |
639 | return; |
582 | val &= ~VIDEO_DIP_ENABLE; |
640 | val &= ~VIDEO_DIP_ENABLE; |
583 | I915_WRITE(reg, val); |
641 | I915_WRITE(reg, val); |
584 | POSTING_READ(reg); |
642 | POSTING_READ(reg); |
585 | return; |
643 | return; |
586 | } |
644 | } |
587 | 645 | ||
588 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
646 | if (port != (val & VIDEO_DIP_PORT_MASK)) { |
589 | if (val & VIDEO_DIP_ENABLE) { |
647 | if (val & VIDEO_DIP_ENABLE) { |
590 | val &= ~VIDEO_DIP_ENABLE; |
648 | val &= ~VIDEO_DIP_ENABLE; |
591 | I915_WRITE(reg, val); |
649 | I915_WRITE(reg, val); |
592 | POSTING_READ(reg); |
650 | POSTING_READ(reg); |
593 | } |
651 | } |
594 | val &= ~VIDEO_DIP_PORT_MASK; |
652 | val &= ~VIDEO_DIP_PORT_MASK; |
595 | val |= port; |
653 | val |= port; |
596 | } |
654 | } |
597 | 655 | ||
598 | val |= VIDEO_DIP_ENABLE; |
656 | val |= VIDEO_DIP_ENABLE; |
599 | val &= ~(VIDEO_DIP_ENABLE_AVI | VIDEO_DIP_ENABLE_VENDOR | |
657 | val &= ~(VIDEO_DIP_ENABLE_AVI | VIDEO_DIP_ENABLE_VENDOR | |
600 | VIDEO_DIP_ENABLE_GAMUT | VIDEO_DIP_ENABLE_GCP); |
658 | VIDEO_DIP_ENABLE_GAMUT | VIDEO_DIP_ENABLE_GCP); |
601 | 659 | ||
602 | I915_WRITE(reg, val); |
660 | I915_WRITE(reg, val); |
603 | POSTING_READ(reg); |
661 | POSTING_READ(reg); |
604 | 662 | ||
605 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
663 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
606 | intel_hdmi_set_spd_infoframe(encoder); |
664 | intel_hdmi_set_spd_infoframe(encoder); |
607 | intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode); |
665 | intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode); |
608 | } |
666 | } |
609 | 667 | ||
610 | static void hsw_set_infoframes(struct drm_encoder *encoder, |
668 | static void hsw_set_infoframes(struct drm_encoder *encoder, |
611 | bool enable, |
669 | bool enable, |
612 | struct drm_display_mode *adjusted_mode) |
670 | struct drm_display_mode *adjusted_mode) |
613 | { |
671 | { |
614 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
672 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
615 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
673 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
616 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
674 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); |
617 | u32 reg = HSW_TVIDEO_DIP_CTL(intel_crtc->config.cpu_transcoder); |
675 | u32 reg = HSW_TVIDEO_DIP_CTL(intel_crtc->config.cpu_transcoder); |
618 | u32 val = I915_READ(reg); |
676 | u32 val = I915_READ(reg); |
619 | 677 | ||
620 | assert_hdmi_port_disabled(intel_hdmi); |
678 | assert_hdmi_port_disabled(intel_hdmi); |
621 | 679 | ||
622 | if (!enable) { |
680 | if (!enable) { |
623 | I915_WRITE(reg, 0); |
681 | I915_WRITE(reg, 0); |
624 | POSTING_READ(reg); |
682 | POSTING_READ(reg); |
625 | return; |
683 | return; |
626 | } |
684 | } |
627 | 685 | ||
628 | val &= ~(VIDEO_DIP_ENABLE_VSC_HSW | VIDEO_DIP_ENABLE_GCP_HSW | |
686 | val &= ~(VIDEO_DIP_ENABLE_VSC_HSW | VIDEO_DIP_ENABLE_GCP_HSW | |
629 | VIDEO_DIP_ENABLE_VS_HSW | VIDEO_DIP_ENABLE_GMP_HSW); |
687 | VIDEO_DIP_ENABLE_VS_HSW | VIDEO_DIP_ENABLE_GMP_HSW); |
630 | 688 | ||
631 | I915_WRITE(reg, val); |
689 | I915_WRITE(reg, val); |
632 | POSTING_READ(reg); |
690 | POSTING_READ(reg); |
633 | 691 | ||
634 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
692 | intel_hdmi_set_avi_infoframe(encoder, adjusted_mode); |
635 | intel_hdmi_set_spd_infoframe(encoder); |
693 | intel_hdmi_set_spd_infoframe(encoder); |
636 | intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode); |
694 | intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode); |
637 | } |
695 | } |
638 | 696 | ||
639 | static void intel_hdmi_prepare(struct intel_encoder *encoder) |
697 | static void intel_hdmi_prepare(struct intel_encoder *encoder) |
640 | { |
698 | { |
641 | struct drm_device *dev = encoder->base.dev; |
699 | struct drm_device *dev = encoder->base.dev; |
642 | struct drm_i915_private *dev_priv = dev->dev_private; |
700 | struct drm_i915_private *dev_priv = dev->dev_private; |
643 | struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc); |
701 | struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc); |
644 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
702 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
645 | struct drm_display_mode *adjusted_mode = &crtc->config.adjusted_mode; |
703 | struct drm_display_mode *adjusted_mode = &crtc->config.adjusted_mode; |
646 | u32 hdmi_val; |
704 | u32 hdmi_val; |
647 | 705 | ||
648 | hdmi_val = SDVO_ENCODING_HDMI; |
706 | hdmi_val = SDVO_ENCODING_HDMI; |
649 | if (!HAS_PCH_SPLIT(dev)) |
707 | if (!HAS_PCH_SPLIT(dev)) |
650 | hdmi_val |= intel_hdmi->color_range; |
708 | hdmi_val |= intel_hdmi->color_range; |
651 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
709 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
652 | hdmi_val |= SDVO_VSYNC_ACTIVE_HIGH; |
710 | hdmi_val |= SDVO_VSYNC_ACTIVE_HIGH; |
653 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
711 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
654 | hdmi_val |= SDVO_HSYNC_ACTIVE_HIGH; |
712 | hdmi_val |= SDVO_HSYNC_ACTIVE_HIGH; |
655 | 713 | ||
656 | if (crtc->config.pipe_bpp > 24) |
714 | if (crtc->config.pipe_bpp > 24) |
657 | hdmi_val |= HDMI_COLOR_FORMAT_12bpc; |
715 | hdmi_val |= HDMI_COLOR_FORMAT_12bpc; |
658 | else |
716 | else |
659 | hdmi_val |= SDVO_COLOR_FORMAT_8bpc; |
717 | hdmi_val |= SDVO_COLOR_FORMAT_8bpc; |
660 | 718 | ||
661 | if (crtc->config.has_hdmi_sink) |
719 | if (crtc->config.has_hdmi_sink) |
662 | hdmi_val |= HDMI_MODE_SELECT_HDMI; |
720 | hdmi_val |= HDMI_MODE_SELECT_HDMI; |
663 | - | ||
664 | if (crtc->config.has_audio) { |
- | |
665 | WARN_ON(!crtc->config.has_hdmi_sink); |
- | |
666 | DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n", |
- | |
667 | pipe_name(crtc->pipe)); |
- | |
668 | hdmi_val |= SDVO_AUDIO_ENABLE; |
- | |
669 | intel_write_eld(&encoder->base, adjusted_mode); |
- | |
670 | } |
- | |
671 | 721 | ||
672 | if (HAS_PCH_CPT(dev)) |
722 | if (HAS_PCH_CPT(dev)) |
673 | hdmi_val |= SDVO_PIPE_SEL_CPT(crtc->pipe); |
723 | hdmi_val |= SDVO_PIPE_SEL_CPT(crtc->pipe); |
674 | else if (IS_CHERRYVIEW(dev)) |
724 | else if (IS_CHERRYVIEW(dev)) |
675 | hdmi_val |= SDVO_PIPE_SEL_CHV(crtc->pipe); |
725 | hdmi_val |= SDVO_PIPE_SEL_CHV(crtc->pipe); |
676 | else |
726 | else |
677 | hdmi_val |= SDVO_PIPE_SEL(crtc->pipe); |
727 | hdmi_val |= SDVO_PIPE_SEL(crtc->pipe); |
678 | 728 | ||
679 | I915_WRITE(intel_hdmi->hdmi_reg, hdmi_val); |
729 | I915_WRITE(intel_hdmi->hdmi_reg, hdmi_val); |
680 | POSTING_READ(intel_hdmi->hdmi_reg); |
730 | POSTING_READ(intel_hdmi->hdmi_reg); |
681 | } |
731 | } |
682 | 732 | ||
683 | static bool intel_hdmi_get_hw_state(struct intel_encoder *encoder, |
733 | static bool intel_hdmi_get_hw_state(struct intel_encoder *encoder, |
684 | enum pipe *pipe) |
734 | enum pipe *pipe) |
685 | { |
735 | { |
686 | struct drm_device *dev = encoder->base.dev; |
736 | struct drm_device *dev = encoder->base.dev; |
687 | struct drm_i915_private *dev_priv = dev->dev_private; |
737 | struct drm_i915_private *dev_priv = dev->dev_private; |
688 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
738 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
689 | enum intel_display_power_domain power_domain; |
739 | enum intel_display_power_domain power_domain; |
690 | u32 tmp; |
740 | u32 tmp; |
691 | 741 | ||
692 | power_domain = intel_display_port_power_domain(encoder); |
742 | power_domain = intel_display_port_power_domain(encoder); |
693 | if (!intel_display_power_enabled(dev_priv, power_domain)) |
743 | if (!intel_display_power_is_enabled(dev_priv, power_domain)) |
694 | return false; |
744 | return false; |
695 | 745 | ||
696 | tmp = I915_READ(intel_hdmi->hdmi_reg); |
746 | tmp = I915_READ(intel_hdmi->hdmi_reg); |
697 | 747 | ||
698 | if (!(tmp & SDVO_ENABLE)) |
748 | if (!(tmp & SDVO_ENABLE)) |
699 | return false; |
749 | return false; |
700 | 750 | ||
701 | if (HAS_PCH_CPT(dev)) |
751 | if (HAS_PCH_CPT(dev)) |
702 | *pipe = PORT_TO_PIPE_CPT(tmp); |
752 | *pipe = PORT_TO_PIPE_CPT(tmp); |
703 | else if (IS_CHERRYVIEW(dev)) |
753 | else if (IS_CHERRYVIEW(dev)) |
704 | *pipe = SDVO_PORT_TO_PIPE_CHV(tmp); |
754 | *pipe = SDVO_PORT_TO_PIPE_CHV(tmp); |
705 | else |
755 | else |
706 | *pipe = PORT_TO_PIPE(tmp); |
756 | *pipe = PORT_TO_PIPE(tmp); |
707 | 757 | ||
708 | return true; |
758 | return true; |
709 | } |
759 | } |
710 | 760 | ||
711 | static void intel_hdmi_get_config(struct intel_encoder *encoder, |
761 | static void intel_hdmi_get_config(struct intel_encoder *encoder, |
712 | struct intel_crtc_config *pipe_config) |
762 | struct intel_crtc_config *pipe_config) |
713 | { |
763 | { |
714 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
764 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
715 | struct drm_device *dev = encoder->base.dev; |
765 | struct drm_device *dev = encoder->base.dev; |
716 | struct drm_i915_private *dev_priv = dev->dev_private; |
766 | struct drm_i915_private *dev_priv = dev->dev_private; |
717 | u32 tmp, flags = 0; |
767 | u32 tmp, flags = 0; |
718 | int dotclock; |
768 | int dotclock; |
719 | 769 | ||
720 | tmp = I915_READ(intel_hdmi->hdmi_reg); |
770 | tmp = I915_READ(intel_hdmi->hdmi_reg); |
721 | 771 | ||
722 | if (tmp & SDVO_HSYNC_ACTIVE_HIGH) |
772 | if (tmp & SDVO_HSYNC_ACTIVE_HIGH) |
723 | flags |= DRM_MODE_FLAG_PHSYNC; |
773 | flags |= DRM_MODE_FLAG_PHSYNC; |
724 | else |
774 | else |
725 | flags |= DRM_MODE_FLAG_NHSYNC; |
775 | flags |= DRM_MODE_FLAG_NHSYNC; |
726 | 776 | ||
727 | if (tmp & SDVO_VSYNC_ACTIVE_HIGH) |
777 | if (tmp & SDVO_VSYNC_ACTIVE_HIGH) |
728 | flags |= DRM_MODE_FLAG_PVSYNC; |
778 | flags |= DRM_MODE_FLAG_PVSYNC; |
729 | else |
779 | else |
730 | flags |= DRM_MODE_FLAG_NVSYNC; |
780 | flags |= DRM_MODE_FLAG_NVSYNC; |
731 | 781 | ||
732 | if (tmp & HDMI_MODE_SELECT_HDMI) |
782 | if (tmp & HDMI_MODE_SELECT_HDMI) |
733 | pipe_config->has_hdmi_sink = true; |
783 | pipe_config->has_hdmi_sink = true; |
- | 784 | ||
- | 785 | if (intel_hdmi->infoframe_enabled(&encoder->base)) |
|
- | 786 | pipe_config->has_infoframe = true; |
|
734 | 787 | ||
735 | if (tmp & HDMI_MODE_SELECT_HDMI) |
788 | if (tmp & SDVO_AUDIO_ENABLE) |
736 | pipe_config->has_audio = true; |
789 | pipe_config->has_audio = true; |
737 | 790 | ||
738 | if (!HAS_PCH_SPLIT(dev) && |
791 | if (!HAS_PCH_SPLIT(dev) && |
739 | tmp & HDMI_COLOR_RANGE_16_235) |
792 | tmp & HDMI_COLOR_RANGE_16_235) |
740 | pipe_config->limited_color_range = true; |
793 | pipe_config->limited_color_range = true; |
741 | 794 | ||
742 | pipe_config->adjusted_mode.flags |= flags; |
795 | pipe_config->adjusted_mode.flags |= flags; |
743 | 796 | ||
744 | if ((tmp & SDVO_COLOR_FORMAT_MASK) == HDMI_COLOR_FORMAT_12bpc) |
797 | if ((tmp & SDVO_COLOR_FORMAT_MASK) == HDMI_COLOR_FORMAT_12bpc) |
745 | dotclock = pipe_config->port_clock * 2 / 3; |
798 | dotclock = pipe_config->port_clock * 2 / 3; |
746 | else |
799 | else |
747 | dotclock = pipe_config->port_clock; |
800 | dotclock = pipe_config->port_clock; |
748 | 801 | ||
749 | if (HAS_PCH_SPLIT(dev_priv->dev)) |
802 | if (HAS_PCH_SPLIT(dev_priv->dev)) |
750 | ironlake_check_encoder_dotclock(pipe_config, dotclock); |
803 | ironlake_check_encoder_dotclock(pipe_config, dotclock); |
751 | 804 | ||
752 | pipe_config->adjusted_mode.crtc_clock = dotclock; |
805 | pipe_config->adjusted_mode.crtc_clock = dotclock; |
753 | } |
806 | } |
754 | 807 | ||
755 | static void intel_enable_hdmi(struct intel_encoder *encoder) |
808 | static void intel_enable_hdmi(struct intel_encoder *encoder) |
756 | { |
809 | { |
757 | struct drm_device *dev = encoder->base.dev; |
810 | struct drm_device *dev = encoder->base.dev; |
758 | struct drm_i915_private *dev_priv = dev->dev_private; |
811 | struct drm_i915_private *dev_priv = dev->dev_private; |
759 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
812 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
760 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
813 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
761 | u32 temp; |
814 | u32 temp; |
762 | u32 enable_bits = SDVO_ENABLE; |
815 | u32 enable_bits = SDVO_ENABLE; |
763 | 816 | ||
764 | if (intel_crtc->config.has_audio) |
817 | if (intel_crtc->config.has_audio) |
765 | enable_bits |= SDVO_AUDIO_ENABLE; |
818 | enable_bits |= SDVO_AUDIO_ENABLE; |
766 | 819 | ||
767 | temp = I915_READ(intel_hdmi->hdmi_reg); |
820 | temp = I915_READ(intel_hdmi->hdmi_reg); |
768 | 821 | ||
769 | /* HW workaround for IBX, we need to move the port to transcoder A |
822 | /* HW workaround for IBX, we need to move the port to transcoder A |
770 | * before disabling it, so restore the transcoder select bit here. */ |
823 | * before disabling it, so restore the transcoder select bit here. */ |
771 | if (HAS_PCH_IBX(dev)) |
824 | if (HAS_PCH_IBX(dev)) |
772 | enable_bits |= SDVO_PIPE_SEL(intel_crtc->pipe); |
825 | enable_bits |= SDVO_PIPE_SEL(intel_crtc->pipe); |
773 | 826 | ||
774 | /* HW workaround, need to toggle enable bit off and on for 12bpc, but |
827 | /* HW workaround, need to toggle enable bit off and on for 12bpc, but |
775 | * we do this anyway which shows more stable in testing. |
828 | * we do this anyway which shows more stable in testing. |
776 | */ |
829 | */ |
777 | if (HAS_PCH_SPLIT(dev)) { |
830 | if (HAS_PCH_SPLIT(dev)) { |
778 | I915_WRITE(intel_hdmi->hdmi_reg, temp & ~SDVO_ENABLE); |
831 | I915_WRITE(intel_hdmi->hdmi_reg, temp & ~SDVO_ENABLE); |
779 | POSTING_READ(intel_hdmi->hdmi_reg); |
832 | POSTING_READ(intel_hdmi->hdmi_reg); |
780 | } |
833 | } |
781 | 834 | ||
782 | temp |= enable_bits; |
835 | temp |= enable_bits; |
783 | 836 | ||
784 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
837 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
785 | POSTING_READ(intel_hdmi->hdmi_reg); |
838 | POSTING_READ(intel_hdmi->hdmi_reg); |
786 | 839 | ||
787 | /* HW workaround, need to write this twice for issue that may result |
840 | /* HW workaround, need to write this twice for issue that may result |
788 | * in first write getting masked. |
841 | * in first write getting masked. |
789 | */ |
842 | */ |
790 | if (HAS_PCH_SPLIT(dev)) { |
843 | if (HAS_PCH_SPLIT(dev)) { |
791 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
844 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
792 | POSTING_READ(intel_hdmi->hdmi_reg); |
845 | POSTING_READ(intel_hdmi->hdmi_reg); |
793 | } |
846 | } |
- | 847 | ||
- | 848 | if (intel_crtc->config.has_audio) { |
|
- | 849 | WARN_ON(!intel_crtc->config.has_hdmi_sink); |
|
- | 850 | DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n", |
|
- | 851 | pipe_name(intel_crtc->pipe)); |
|
- | 852 | intel_audio_codec_enable(encoder); |
|
- | 853 | } |
|
794 | } |
854 | } |
795 | 855 | ||
796 | static void vlv_enable_hdmi(struct intel_encoder *encoder) |
856 | static void vlv_enable_hdmi(struct intel_encoder *encoder) |
797 | { |
857 | { |
798 | } |
858 | } |
799 | 859 | ||
800 | static void intel_disable_hdmi(struct intel_encoder *encoder) |
860 | static void intel_disable_hdmi(struct intel_encoder *encoder) |
801 | { |
861 | { |
802 | struct drm_device *dev = encoder->base.dev; |
862 | struct drm_device *dev = encoder->base.dev; |
803 | struct drm_i915_private *dev_priv = dev->dev_private; |
863 | struct drm_i915_private *dev_priv = dev->dev_private; |
804 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
864 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
- | 865 | struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc); |
|
805 | u32 temp; |
866 | u32 temp; |
806 | u32 enable_bits = SDVO_ENABLE | SDVO_AUDIO_ENABLE; |
867 | u32 enable_bits = SDVO_ENABLE | SDVO_AUDIO_ENABLE; |
- | 868 | ||
- | 869 | if (crtc->config.has_audio) |
|
- | 870 | intel_audio_codec_disable(encoder); |
|
807 | 871 | ||
808 | temp = I915_READ(intel_hdmi->hdmi_reg); |
872 | temp = I915_READ(intel_hdmi->hdmi_reg); |
809 | 873 | ||
810 | /* HW workaround for IBX, we need to move the port to transcoder A |
874 | /* HW workaround for IBX, we need to move the port to transcoder A |
811 | * before disabling it. */ |
875 | * before disabling it. */ |
812 | if (HAS_PCH_IBX(dev)) { |
876 | if (HAS_PCH_IBX(dev)) { |
813 | struct drm_crtc *crtc = encoder->base.crtc; |
877 | struct drm_crtc *crtc = encoder->base.crtc; |
814 | int pipe = crtc ? to_intel_crtc(crtc)->pipe : -1; |
878 | int pipe = crtc ? to_intel_crtc(crtc)->pipe : -1; |
815 | 879 | ||
816 | if (temp & SDVO_PIPE_B_SELECT) { |
880 | if (temp & SDVO_PIPE_B_SELECT) { |
817 | temp &= ~SDVO_PIPE_B_SELECT; |
881 | temp &= ~SDVO_PIPE_B_SELECT; |
818 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
882 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
819 | POSTING_READ(intel_hdmi->hdmi_reg); |
883 | POSTING_READ(intel_hdmi->hdmi_reg); |
820 | 884 | ||
821 | /* Again we need to write this twice. */ |
885 | /* Again we need to write this twice. */ |
822 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
886 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
823 | POSTING_READ(intel_hdmi->hdmi_reg); |
887 | POSTING_READ(intel_hdmi->hdmi_reg); |
824 | 888 | ||
825 | /* Transcoder selection bits only update |
889 | /* Transcoder selection bits only update |
826 | * effectively on vblank. */ |
890 | * effectively on vblank. */ |
827 | if (crtc) |
891 | if (crtc) |
828 | intel_wait_for_vblank(dev, pipe); |
892 | intel_wait_for_vblank(dev, pipe); |
829 | else |
893 | else |
830 | msleep(50); |
894 | msleep(50); |
831 | } |
895 | } |
832 | } |
896 | } |
833 | 897 | ||
834 | /* HW workaround, need to toggle enable bit off and on for 12bpc, but |
898 | /* HW workaround, need to toggle enable bit off and on for 12bpc, but |
835 | * we do this anyway which shows more stable in testing. |
899 | * we do this anyway which shows more stable in testing. |
836 | */ |
900 | */ |
837 | if (HAS_PCH_SPLIT(dev)) { |
901 | if (HAS_PCH_SPLIT(dev)) { |
838 | I915_WRITE(intel_hdmi->hdmi_reg, temp & ~SDVO_ENABLE); |
902 | I915_WRITE(intel_hdmi->hdmi_reg, temp & ~SDVO_ENABLE); |
839 | POSTING_READ(intel_hdmi->hdmi_reg); |
903 | POSTING_READ(intel_hdmi->hdmi_reg); |
840 | } |
904 | } |
841 | 905 | ||
842 | temp &= ~enable_bits; |
906 | temp &= ~enable_bits; |
843 | 907 | ||
844 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
908 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
845 | POSTING_READ(intel_hdmi->hdmi_reg); |
909 | POSTING_READ(intel_hdmi->hdmi_reg); |
846 | 910 | ||
847 | /* HW workaround, need to write this twice for issue that may result |
911 | /* HW workaround, need to write this twice for issue that may result |
848 | * in first write getting masked. |
912 | * in first write getting masked. |
849 | */ |
913 | */ |
850 | if (HAS_PCH_SPLIT(dev)) { |
914 | if (HAS_PCH_SPLIT(dev)) { |
851 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
915 | I915_WRITE(intel_hdmi->hdmi_reg, temp); |
852 | POSTING_READ(intel_hdmi->hdmi_reg); |
916 | POSTING_READ(intel_hdmi->hdmi_reg); |
853 | } |
917 | } |
854 | } |
918 | } |
855 | 919 | ||
856 | static int hdmi_portclock_limit(struct intel_hdmi *hdmi, bool respect_dvi_limit) |
920 | static int hdmi_portclock_limit(struct intel_hdmi *hdmi, bool respect_dvi_limit) |
857 | { |
921 | { |
858 | struct drm_device *dev = intel_hdmi_to_dev(hdmi); |
922 | struct drm_device *dev = intel_hdmi_to_dev(hdmi); |
859 | 923 | ||
860 | if ((respect_dvi_limit && !hdmi->has_hdmi_sink) || IS_G4X(dev)) |
924 | if ((respect_dvi_limit && !hdmi->has_hdmi_sink) || IS_G4X(dev)) |
861 | return 165000; |
925 | return 165000; |
862 | else if (IS_HASWELL(dev) || INTEL_INFO(dev)->gen >= 8) |
926 | else if (IS_HASWELL(dev) || INTEL_INFO(dev)->gen >= 8) |
863 | return 300000; |
927 | return 300000; |
864 | else |
928 | else |
865 | return 225000; |
929 | return 225000; |
866 | } |
930 | } |
867 | 931 | ||
868 | static enum drm_mode_status |
932 | static enum drm_mode_status |
869 | intel_hdmi_mode_valid(struct drm_connector *connector, |
933 | intel_hdmi_mode_valid(struct drm_connector *connector, |
870 | struct drm_display_mode *mode) |
934 | struct drm_display_mode *mode) |
871 | { |
935 | { |
- | 936 | int clock = mode->clock; |
|
- | 937 | ||
- | 938 | if (mode->flags & DRM_MODE_FLAG_DBLCLK) |
|
- | 939 | clock *= 2; |
|
- | 940 | ||
872 | if (mode->clock > hdmi_portclock_limit(intel_attached_hdmi(connector), |
941 | if (clock > hdmi_portclock_limit(intel_attached_hdmi(connector), |
873 | true)) |
942 | true)) |
874 | return MODE_CLOCK_HIGH; |
943 | return MODE_CLOCK_HIGH; |
875 | if (mode->clock < 20000) |
944 | if (clock < 20000) |
876 | return MODE_CLOCK_LOW; |
945 | return MODE_CLOCK_LOW; |
877 | 946 | ||
878 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
947 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
879 | return MODE_NO_DBLESCAN; |
948 | return MODE_NO_DBLESCAN; |
880 | 949 | ||
881 | return MODE_OK; |
950 | return MODE_OK; |
882 | } |
951 | } |
883 | 952 | ||
884 | static bool hdmi_12bpc_possible(struct intel_crtc *crtc) |
953 | static bool hdmi_12bpc_possible(struct intel_crtc *crtc) |
885 | { |
954 | { |
886 | struct drm_device *dev = crtc->base.dev; |
955 | struct drm_device *dev = crtc->base.dev; |
887 | struct intel_encoder *encoder; |
956 | struct intel_encoder *encoder; |
888 | int count = 0, count_hdmi = 0; |
957 | int count = 0, count_hdmi = 0; |
889 | 958 | ||
890 | if (HAS_GMCH_DISPLAY(dev)) |
959 | if (HAS_GMCH_DISPLAY(dev)) |
891 | return false; |
960 | return false; |
892 | 961 | ||
893 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) { |
962 | for_each_intel_encoder(dev, encoder) { |
894 | if (encoder->new_crtc != crtc) |
963 | if (encoder->new_crtc != crtc) |
895 | continue; |
964 | continue; |
896 | 965 | ||
897 | count_hdmi += encoder->type == INTEL_OUTPUT_HDMI; |
966 | count_hdmi += encoder->type == INTEL_OUTPUT_HDMI; |
898 | count++; |
967 | count++; |
899 | } |
968 | } |
900 | 969 | ||
901 | /* |
970 | /* |
902 | * HDMI 12bpc affects the clocks, so it's only possible |
971 | * HDMI 12bpc affects the clocks, so it's only possible |
903 | * when not cloning with other encoder types. |
972 | * when not cloning with other encoder types. |
904 | */ |
973 | */ |
905 | return count_hdmi > 0 && count_hdmi == count; |
974 | return count_hdmi > 0 && count_hdmi == count; |
906 | } |
975 | } |
907 | 976 | ||
908 | bool intel_hdmi_compute_config(struct intel_encoder *encoder, |
977 | bool intel_hdmi_compute_config(struct intel_encoder *encoder, |
909 | struct intel_crtc_config *pipe_config) |
978 | struct intel_crtc_config *pipe_config) |
910 | { |
979 | { |
911 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
980 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
912 | struct drm_device *dev = encoder->base.dev; |
981 | struct drm_device *dev = encoder->base.dev; |
913 | struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode; |
982 | struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode; |
914 | int clock_12bpc = pipe_config->adjusted_mode.crtc_clock * 3 / 2; |
983 | int clock_12bpc = pipe_config->adjusted_mode.crtc_clock * 3 / 2; |
915 | int portclock_limit = hdmi_portclock_limit(intel_hdmi, false); |
984 | int portclock_limit = hdmi_portclock_limit(intel_hdmi, false); |
916 | int desired_bpp; |
985 | int desired_bpp; |
917 | 986 | ||
918 | pipe_config->has_hdmi_sink = intel_hdmi->has_hdmi_sink; |
987 | pipe_config->has_hdmi_sink = intel_hdmi->has_hdmi_sink; |
- | 988 | ||
- | 989 | if (pipe_config->has_hdmi_sink) |
|
- | 990 | pipe_config->has_infoframe = true; |
|
919 | 991 | ||
920 | if (intel_hdmi->color_range_auto) { |
992 | if (intel_hdmi->color_range_auto) { |
921 | /* See CEA-861-E - 5.1 Default Encoding Parameters */ |
993 | /* See CEA-861-E - 5.1 Default Encoding Parameters */ |
922 | if (pipe_config->has_hdmi_sink && |
994 | if (pipe_config->has_hdmi_sink && |
923 | drm_match_cea_mode(adjusted_mode) > 1) |
995 | drm_match_cea_mode(adjusted_mode) > 1) |
924 | intel_hdmi->color_range = HDMI_COLOR_RANGE_16_235; |
996 | intel_hdmi->color_range = HDMI_COLOR_RANGE_16_235; |
925 | else |
997 | else |
926 | intel_hdmi->color_range = 0; |
998 | intel_hdmi->color_range = 0; |
927 | } |
999 | } |
- | 1000 | ||
- | 1001 | if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) { |
|
- | 1002 | pipe_config->pixel_multiplier = 2; |
|
- | 1003 | } |
|
928 | 1004 | ||
929 | if (intel_hdmi->color_range) |
1005 | if (intel_hdmi->color_range) |
930 | pipe_config->limited_color_range = true; |
1006 | pipe_config->limited_color_range = true; |
931 | 1007 | ||
932 | if (HAS_PCH_SPLIT(dev) && !HAS_DDI(dev)) |
1008 | if (HAS_PCH_SPLIT(dev) && !HAS_DDI(dev)) |
933 | pipe_config->has_pch_encoder = true; |
1009 | pipe_config->has_pch_encoder = true; |
934 | 1010 | ||
935 | if (pipe_config->has_hdmi_sink && intel_hdmi->has_audio) |
1011 | if (pipe_config->has_hdmi_sink && intel_hdmi->has_audio) |
936 | pipe_config->has_audio = true; |
1012 | pipe_config->has_audio = true; |
937 | 1013 | ||
938 | /* |
1014 | /* |
939 | * HDMI is either 12 or 8, so if the display lets 10bpc sneak |
1015 | * HDMI is either 12 or 8, so if the display lets 10bpc sneak |
940 | * through, clamp it down. Note that g4x/vlv don't support 12bpc hdmi |
1016 | * through, clamp it down. Note that g4x/vlv don't support 12bpc hdmi |
941 | * outputs. We also need to check that the higher clock still fits |
1017 | * outputs. We also need to check that the higher clock still fits |
942 | * within limits. |
1018 | * within limits. |
943 | */ |
1019 | */ |
944 | if (pipe_config->pipe_bpp > 8*3 && pipe_config->has_hdmi_sink && |
1020 | if (pipe_config->pipe_bpp > 8*3 && pipe_config->has_hdmi_sink && |
945 | clock_12bpc <= portclock_limit && |
1021 | clock_12bpc <= portclock_limit && |
946 | hdmi_12bpc_possible(encoder->new_crtc)) { |
1022 | hdmi_12bpc_possible(encoder->new_crtc)) { |
947 | DRM_DEBUG_KMS("picking bpc to 12 for HDMI output\n"); |
1023 | DRM_DEBUG_KMS("picking bpc to 12 for HDMI output\n"); |
948 | desired_bpp = 12*3; |
1024 | desired_bpp = 12*3; |
949 | 1025 | ||
950 | /* Need to adjust the port link by 1.5x for 12bpc. */ |
1026 | /* Need to adjust the port link by 1.5x for 12bpc. */ |
951 | pipe_config->port_clock = clock_12bpc; |
1027 | pipe_config->port_clock = clock_12bpc; |
952 | } else { |
1028 | } else { |
953 | DRM_DEBUG_KMS("picking bpc to 8 for HDMI output\n"); |
1029 | DRM_DEBUG_KMS("picking bpc to 8 for HDMI output\n"); |
954 | desired_bpp = 8*3; |
1030 | desired_bpp = 8*3; |
955 | } |
1031 | } |
956 | 1032 | ||
957 | if (!pipe_config->bw_constrained) { |
1033 | if (!pipe_config->bw_constrained) { |
958 | DRM_DEBUG_KMS("forcing pipe bpc to %i for HDMI\n", desired_bpp); |
1034 | DRM_DEBUG_KMS("forcing pipe bpc to %i for HDMI\n", desired_bpp); |
959 | pipe_config->pipe_bpp = desired_bpp; |
1035 | pipe_config->pipe_bpp = desired_bpp; |
960 | } |
1036 | } |
961 | 1037 | ||
962 | if (adjusted_mode->crtc_clock > portclock_limit) { |
1038 | if (adjusted_mode->crtc_clock > portclock_limit) { |
963 | DRM_DEBUG_KMS("too high HDMI clock, rejecting mode\n"); |
1039 | DRM_DEBUG_KMS("too high HDMI clock, rejecting mode\n"); |
964 | return false; |
1040 | return false; |
965 | } |
1041 | } |
966 | 1042 | ||
967 | return true; |
1043 | return true; |
968 | } |
1044 | } |
969 | 1045 | ||
970 | static enum drm_connector_status |
1046 | static void |
971 | intel_hdmi_detect(struct drm_connector *connector, bool force) |
1047 | intel_hdmi_unset_edid(struct drm_connector *connector) |
972 | { |
- | |
973 | struct drm_device *dev = connector->dev; |
1048 | { |
974 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
- | |
975 | struct intel_digital_port *intel_dig_port = |
- | |
976 | hdmi_to_dig_port(intel_hdmi); |
- | |
977 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
- | |
978 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
979 | struct edid *edid; |
- | |
980 | enum intel_display_power_domain power_domain; |
- | |
981 | enum drm_connector_status status = connector_status_disconnected; |
1049 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
- | 1050 | ||
- | 1051 | intel_hdmi->has_hdmi_sink = false; |
|
- | 1052 | intel_hdmi->has_audio = false; |
|
982 | 1053 | intel_hdmi->rgb_quant_range_selectable = false; |
|
- | 1054 | ||
- | 1055 | kfree(to_intel_connector(connector)->detect_edid); |
|
- | 1056 | to_intel_connector(connector)->detect_edid = NULL; |
|
- | 1057 | } |
|
- | 1058 | ||
- | 1059 | static bool |
|
- | 1060 | intel_hdmi_set_edid(struct drm_connector *connector) |
|
- | 1061 | { |
|
- | 1062 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
|
- | 1063 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
|
- | 1064 | struct intel_encoder *intel_encoder = |
|
- | 1065 | &hdmi_to_dig_port(intel_hdmi)->base; |
|
- | 1066 | enum intel_display_power_domain power_domain; |
|
983 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
1067 | struct edid *edid; |
984 | connector->base.id, connector->name); |
1068 | bool connected = false; |
985 | 1069 | ||
986 | power_domain = intel_display_port_power_domain(intel_encoder); |
1070 | power_domain = intel_display_port_power_domain(intel_encoder); |
987 | intel_display_power_get(dev_priv, power_domain); |
1071 | intel_display_power_get(dev_priv, power_domain); |
988 | - | ||
989 | intel_hdmi->has_hdmi_sink = false; |
- | |
990 | intel_hdmi->has_audio = false; |
- | |
991 | intel_hdmi->rgb_quant_range_selectable = false; |
1072 | |
992 | edid = drm_get_edid(connector, |
1073 | edid = drm_get_edid(connector, |
993 | intel_gmbus_get_adapter(dev_priv, |
1074 | intel_gmbus_get_adapter(dev_priv, |
994 | intel_hdmi->ddc_bus)); |
1075 | intel_hdmi->ddc_bus)); |
995 | - | ||
996 | if (edid) { |
1076 | |
- | 1077 | intel_display_power_put(dev_priv, power_domain); |
|
997 | if (edid->input & DRM_EDID_INPUT_DIGITAL) { |
1078 | |
998 | status = connector_status_connected; |
1079 | to_intel_connector(connector)->detect_edid = edid; |
999 | if (intel_hdmi->force_audio != HDMI_AUDIO_OFF_DVI) |
- | |
1000 | intel_hdmi->has_hdmi_sink = |
- | |
1001 | drm_detect_hdmi_monitor(edid); |
- | |
1002 | intel_hdmi->has_audio = drm_detect_monitor_audio(edid); |
1080 | if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) { |
1003 | intel_hdmi->rgb_quant_range_selectable = |
1081 | intel_hdmi->rgb_quant_range_selectable = |
1004 | drm_rgb_quant_range_selectable(edid); |
- | |
1005 | } |
- | |
1006 | kfree(edid); |
- | |
1007 | } |
1082 | drm_rgb_quant_range_selectable(edid); |
1008 | 1083 | ||
1009 | if (status == connector_status_connected) { |
1084 | intel_hdmi->has_audio = drm_detect_monitor_audio(edid); |
1010 | if (intel_hdmi->force_audio != HDMI_AUDIO_AUTO) |
1085 | if (intel_hdmi->force_audio != HDMI_AUDIO_AUTO) |
- | 1086 | intel_hdmi->has_audio = |
|
1011 | intel_hdmi->has_audio = |
1087 | intel_hdmi->force_audio == HDMI_AUDIO_ON; |
- | 1088 | ||
- | 1089 | if (intel_hdmi->force_audio != HDMI_AUDIO_OFF_DVI) |
|
- | 1090 | intel_hdmi->has_hdmi_sink = |
|
- | 1091 | drm_detect_hdmi_monitor(edid); |
|
1012 | (intel_hdmi->force_audio == HDMI_AUDIO_ON); |
1092 | |
- | 1093 | connected = true; |
|
- | 1094 | } |
|
- | 1095 | ||
- | 1096 | return connected; |
|
- | 1097 | } |
|
- | 1098 | ||
- | 1099 | static enum drm_connector_status |
|
- | 1100 | intel_hdmi_detect(struct drm_connector *connector, bool force) |
|
- | 1101 | { |
|
- | 1102 | enum drm_connector_status status; |
|
- | 1103 | ||
1013 | intel_encoder->type = INTEL_OUTPUT_HDMI; |
1104 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
- | 1105 | connector->base.id, connector->name); |
|
- | 1106 | ||
- | 1107 | intel_hdmi_unset_edid(connector); |
|
- | 1108 | ||
- | 1109 | if (intel_hdmi_set_edid(connector)) { |
|
- | 1110 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
|
- | 1111 | ||
- | 1112 | hdmi_to_dig_port(intel_hdmi)->base.type = INTEL_OUTPUT_HDMI; |
|
1014 | } |
1113 | status = connector_status_connected; |
1015 | 1114 | } else |
|
1016 | intel_display_power_put(dev_priv, power_domain); |
1115 | status = connector_status_disconnected; |
1017 | 1116 | ||
1018 | return status; |
1117 | return status; |
1019 | } |
1118 | } |
- | 1119 | ||
1020 | 1120 | static void |
|
1021 | static int intel_hdmi_get_modes(struct drm_connector *connector) |
1121 | intel_hdmi_force(struct drm_connector *connector) |
1022 | { |
1122 | { |
1023 | struct intel_encoder *intel_encoder = intel_attached_encoder(connector); |
- | |
1024 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
- | |
1025 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
- | |
1026 | enum intel_display_power_domain power_domain; |
- | |
1027 | int ret; |
1123 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
1028 | 1124 | ||
1029 | /* We should parse the EDID data and find out if it's an HDMI sink so |
- | |
1030 | * we can send audio to it. |
- | |
1031 | */ |
1125 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
1032 | 1126 | connector->base.id, connector->name); |
|
1033 | power_domain = intel_display_port_power_domain(intel_encoder); |
- | |
1034 | intel_display_power_get(dev_priv, power_domain); |
1127 | |
1035 | 1128 | intel_hdmi_unset_edid(connector); |
|
- | 1129 | ||
- | 1130 | if (connector->status != connector_status_connected) |
|
- | 1131 | return; |
|
- | 1132 | ||
- | 1133 | intel_hdmi_set_edid(connector); |
|
- | 1134 | hdmi_to_dig_port(intel_hdmi)->base.type = INTEL_OUTPUT_HDMI; |
|
- | 1135 | } |
|
- | 1136 | ||
1036 | ret = intel_ddc_get_modes(connector, |
1137 | static int intel_hdmi_get_modes(struct drm_connector *connector) |
- | 1138 | { |
|
- | 1139 | struct edid *edid; |
|
1037 | intel_gmbus_get_adapter(dev_priv, |
1140 | |
1038 | intel_hdmi->ddc_bus)); |
1141 | edid = to_intel_connector(connector)->detect_edid; |
1039 | 1142 | if (edid == NULL) |
|
1040 | intel_display_power_put(dev_priv, power_domain); |
1143 | return 0; |
1041 | 1144 | ||
1042 | return ret; |
1145 | return intel_connector_update_modes(connector, edid); |
1043 | } |
1146 | } |
1044 | 1147 | ||
1045 | static bool |
1148 | static bool |
1046 | intel_hdmi_detect_audio(struct drm_connector *connector) |
1149 | intel_hdmi_detect_audio(struct drm_connector *connector) |
1047 | { |
1150 | { |
1048 | struct intel_encoder *intel_encoder = intel_attached_encoder(connector); |
- | |
1049 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base); |
- | |
1050 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
- | |
1051 | enum intel_display_power_domain power_domain; |
- | |
1052 | struct edid *edid; |
- | |
1053 | bool has_audio = false; |
1151 | bool has_audio = false; |
- | 1152 | struct edid *edid; |
|
1054 | - | ||
1055 | power_domain = intel_display_port_power_domain(intel_encoder); |
- | |
1056 | intel_display_power_get(dev_priv, power_domain); |
- | |
1057 | 1153 | ||
1058 | edid = drm_get_edid(connector, |
- | |
1059 | intel_gmbus_get_adapter(dev_priv, |
- | |
1060 | intel_hdmi->ddc_bus)); |
- | |
1061 | if (edid) { |
1154 | edid = to_intel_connector(connector)->detect_edid; |
1062 | if (edid->input & DRM_EDID_INPUT_DIGITAL) |
1155 | if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) |
1063 | has_audio = drm_detect_monitor_audio(edid); |
- | |
1064 | kfree(edid); |
- | |
1065 | } |
- | |
1066 | - | ||
1067 | intel_display_power_put(dev_priv, power_domain); |
1156 | has_audio = drm_detect_monitor_audio(edid); |
1068 | 1157 | ||
1069 | return has_audio; |
1158 | return has_audio; |
1070 | } |
1159 | } |
1071 | 1160 | ||
1072 | static int |
1161 | static int |
1073 | intel_hdmi_set_property(struct drm_connector *connector, |
1162 | intel_hdmi_set_property(struct drm_connector *connector, |
1074 | struct drm_property *property, |
1163 | struct drm_property *property, |
1075 | uint64_t val) |
1164 | uint64_t val) |
1076 | { |
1165 | { |
1077 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
1166 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
1078 | struct intel_digital_port *intel_dig_port = |
1167 | struct intel_digital_port *intel_dig_port = |
1079 | hdmi_to_dig_port(intel_hdmi); |
1168 | hdmi_to_dig_port(intel_hdmi); |
1080 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
1169 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
1081 | int ret; |
1170 | int ret; |
1082 | 1171 | ||
1083 | ret = drm_object_property_set_value(&connector->base, property, val); |
1172 | ret = drm_object_property_set_value(&connector->base, property, val); |
1084 | if (ret) |
1173 | if (ret) |
1085 | return ret; |
1174 | return ret; |
1086 | 1175 | ||
1087 | if (property == dev_priv->force_audio_property) { |
1176 | if (property == dev_priv->force_audio_property) { |
1088 | enum hdmi_force_audio i = val; |
1177 | enum hdmi_force_audio i = val; |
1089 | bool has_audio; |
1178 | bool has_audio; |
1090 | 1179 | ||
1091 | if (i == intel_hdmi->force_audio) |
1180 | if (i == intel_hdmi->force_audio) |
1092 | return 0; |
1181 | return 0; |
1093 | 1182 | ||
1094 | intel_hdmi->force_audio = i; |
1183 | intel_hdmi->force_audio = i; |
1095 | 1184 | ||
1096 | if (i == HDMI_AUDIO_AUTO) |
1185 | if (i == HDMI_AUDIO_AUTO) |
1097 | has_audio = intel_hdmi_detect_audio(connector); |
1186 | has_audio = intel_hdmi_detect_audio(connector); |
1098 | else |
1187 | else |
1099 | has_audio = (i == HDMI_AUDIO_ON); |
1188 | has_audio = (i == HDMI_AUDIO_ON); |
1100 | 1189 | ||
1101 | if (i == HDMI_AUDIO_OFF_DVI) |
1190 | if (i == HDMI_AUDIO_OFF_DVI) |
1102 | intel_hdmi->has_hdmi_sink = 0; |
1191 | intel_hdmi->has_hdmi_sink = 0; |
1103 | 1192 | ||
1104 | intel_hdmi->has_audio = has_audio; |
1193 | intel_hdmi->has_audio = has_audio; |
1105 | goto done; |
1194 | goto done; |
1106 | } |
1195 | } |
1107 | 1196 | ||
1108 | if (property == dev_priv->broadcast_rgb_property) { |
1197 | if (property == dev_priv->broadcast_rgb_property) { |
1109 | bool old_auto = intel_hdmi->color_range_auto; |
1198 | bool old_auto = intel_hdmi->color_range_auto; |
1110 | uint32_t old_range = intel_hdmi->color_range; |
1199 | uint32_t old_range = intel_hdmi->color_range; |
1111 | 1200 | ||
1112 | switch (val) { |
1201 | switch (val) { |
1113 | case INTEL_BROADCAST_RGB_AUTO: |
1202 | case INTEL_BROADCAST_RGB_AUTO: |
1114 | intel_hdmi->color_range_auto = true; |
1203 | intel_hdmi->color_range_auto = true; |
1115 | break; |
1204 | break; |
1116 | case INTEL_BROADCAST_RGB_FULL: |
1205 | case INTEL_BROADCAST_RGB_FULL: |
1117 | intel_hdmi->color_range_auto = false; |
1206 | intel_hdmi->color_range_auto = false; |
1118 | intel_hdmi->color_range = 0; |
1207 | intel_hdmi->color_range = 0; |
1119 | break; |
1208 | break; |
1120 | case INTEL_BROADCAST_RGB_LIMITED: |
1209 | case INTEL_BROADCAST_RGB_LIMITED: |
1121 | intel_hdmi->color_range_auto = false; |
1210 | intel_hdmi->color_range_auto = false; |
1122 | intel_hdmi->color_range = HDMI_COLOR_RANGE_16_235; |
1211 | intel_hdmi->color_range = HDMI_COLOR_RANGE_16_235; |
1123 | break; |
1212 | break; |
1124 | default: |
1213 | default: |
1125 | return -EINVAL; |
1214 | return -EINVAL; |
1126 | } |
1215 | } |
1127 | 1216 | ||
1128 | if (old_auto == intel_hdmi->color_range_auto && |
1217 | if (old_auto == intel_hdmi->color_range_auto && |
1129 | old_range == intel_hdmi->color_range) |
1218 | old_range == intel_hdmi->color_range) |
1130 | return 0; |
1219 | return 0; |
1131 | 1220 | ||
1132 | goto done; |
1221 | goto done; |
1133 | } |
1222 | } |
1134 | 1223 | ||
1135 | if (property == connector->dev->mode_config.aspect_ratio_property) { |
1224 | if (property == connector->dev->mode_config.aspect_ratio_property) { |
1136 | switch (val) { |
1225 | switch (val) { |
1137 | case DRM_MODE_PICTURE_ASPECT_NONE: |
1226 | case DRM_MODE_PICTURE_ASPECT_NONE: |
1138 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_NONE; |
1227 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_NONE; |
1139 | break; |
1228 | break; |
1140 | case DRM_MODE_PICTURE_ASPECT_4_3: |
1229 | case DRM_MODE_PICTURE_ASPECT_4_3: |
1141 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_4_3; |
1230 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_4_3; |
1142 | break; |
1231 | break; |
1143 | case DRM_MODE_PICTURE_ASPECT_16_9: |
1232 | case DRM_MODE_PICTURE_ASPECT_16_9: |
1144 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_16_9; |
1233 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_16_9; |
1145 | break; |
1234 | break; |
1146 | default: |
1235 | default: |
1147 | return -EINVAL; |
1236 | return -EINVAL; |
1148 | } |
1237 | } |
1149 | goto done; |
1238 | goto done; |
1150 | } |
1239 | } |
1151 | 1240 | ||
1152 | return -EINVAL; |
1241 | return -EINVAL; |
1153 | 1242 | ||
1154 | done: |
1243 | done: |
1155 | if (intel_dig_port->base.base.crtc) |
1244 | if (intel_dig_port->base.base.crtc) |
1156 | intel_crtc_restore_mode(intel_dig_port->base.base.crtc); |
1245 | intel_crtc_restore_mode(intel_dig_port->base.base.crtc); |
1157 | 1246 | ||
1158 | return 0; |
1247 | return 0; |
1159 | } |
1248 | } |
1160 | 1249 | ||
1161 | static void intel_hdmi_pre_enable(struct intel_encoder *encoder) |
1250 | static void intel_hdmi_pre_enable(struct intel_encoder *encoder) |
1162 | { |
1251 | { |
1163 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
1252 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); |
1164 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
1253 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
1165 | struct drm_display_mode *adjusted_mode = |
1254 | struct drm_display_mode *adjusted_mode = |
1166 | &intel_crtc->config.adjusted_mode; |
1255 | &intel_crtc->config.adjusted_mode; |
1167 | 1256 | ||
1168 | intel_hdmi_prepare(encoder); |
1257 | intel_hdmi_prepare(encoder); |
1169 | 1258 | ||
1170 | intel_hdmi->set_infoframes(&encoder->base, |
1259 | intel_hdmi->set_infoframes(&encoder->base, |
1171 | intel_crtc->config.has_hdmi_sink, |
1260 | intel_crtc->config.has_hdmi_sink, |
1172 | adjusted_mode); |
1261 | adjusted_mode); |
1173 | } |
1262 | } |
1174 | 1263 | ||
1175 | static void vlv_hdmi_pre_enable(struct intel_encoder *encoder) |
1264 | static void vlv_hdmi_pre_enable(struct intel_encoder *encoder) |
1176 | { |
1265 | { |
1177 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1266 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1178 | struct intel_hdmi *intel_hdmi = &dport->hdmi; |
1267 | struct intel_hdmi *intel_hdmi = &dport->hdmi; |
1179 | struct drm_device *dev = encoder->base.dev; |
1268 | struct drm_device *dev = encoder->base.dev; |
1180 | struct drm_i915_private *dev_priv = dev->dev_private; |
1269 | struct drm_i915_private *dev_priv = dev->dev_private; |
1181 | struct intel_crtc *intel_crtc = |
1270 | struct intel_crtc *intel_crtc = |
1182 | to_intel_crtc(encoder->base.crtc); |
1271 | to_intel_crtc(encoder->base.crtc); |
1183 | struct drm_display_mode *adjusted_mode = |
1272 | struct drm_display_mode *adjusted_mode = |
1184 | &intel_crtc->config.adjusted_mode; |
1273 | &intel_crtc->config.adjusted_mode; |
1185 | enum dpio_channel port = vlv_dport_to_channel(dport); |
1274 | enum dpio_channel port = vlv_dport_to_channel(dport); |
1186 | int pipe = intel_crtc->pipe; |
1275 | int pipe = intel_crtc->pipe; |
1187 | u32 val; |
1276 | u32 val; |
1188 | 1277 | ||
1189 | /* Enable clock channels for this port */ |
1278 | /* Enable clock channels for this port */ |
1190 | mutex_lock(&dev_priv->dpio_lock); |
1279 | mutex_lock(&dev_priv->dpio_lock); |
1191 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW8(port)); |
1280 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW8(port)); |
1192 | val = 0; |
1281 | val = 0; |
1193 | if (pipe) |
1282 | if (pipe) |
1194 | val |= (1<<21); |
1283 | val |= (1<<21); |
1195 | else |
1284 | else |
1196 | val &= ~(1<<21); |
1285 | val &= ~(1<<21); |
1197 | val |= 0x001000c4; |
1286 | val |= 0x001000c4; |
1198 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW8(port), val); |
1287 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW8(port), val); |
1199 | 1288 | ||
1200 | /* HDMI 1.0V-2dB */ |
1289 | /* HDMI 1.0V-2dB */ |
1201 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), 0); |
1290 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), 0); |
1202 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW4(port), 0x2b245f5f); |
1291 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW4(port), 0x2b245f5f); |
1203 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW2(port), 0x5578b83a); |
1292 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW2(port), 0x5578b83a); |
1204 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW3(port), 0x0c782040); |
1293 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW3(port), 0x0c782040); |
1205 | vlv_dpio_write(dev_priv, pipe, VLV_TX3_DW4(port), 0x2b247878); |
1294 | vlv_dpio_write(dev_priv, pipe, VLV_TX3_DW4(port), 0x2b247878); |
1206 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW11(port), 0x00030000); |
1295 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW11(port), 0x00030000); |
1207 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW9(port), 0x00002000); |
1296 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW9(port), 0x00002000); |
1208 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), DPIO_TX_OCALINIT_EN); |
1297 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), DPIO_TX_OCALINIT_EN); |
1209 | 1298 | ||
1210 | /* Program lane clock */ |
1299 | /* Program lane clock */ |
1211 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW14(port), 0x00760018); |
1300 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW14(port), 0x00760018); |
1212 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW23(port), 0x00400888); |
1301 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW23(port), 0x00400888); |
1213 | mutex_unlock(&dev_priv->dpio_lock); |
1302 | mutex_unlock(&dev_priv->dpio_lock); |
1214 | 1303 | ||
1215 | intel_hdmi->set_infoframes(&encoder->base, |
1304 | intel_hdmi->set_infoframes(&encoder->base, |
1216 | intel_crtc->config.has_hdmi_sink, |
1305 | intel_crtc->config.has_hdmi_sink, |
1217 | adjusted_mode); |
1306 | adjusted_mode); |
1218 | 1307 | ||
1219 | intel_enable_hdmi(encoder); |
1308 | intel_enable_hdmi(encoder); |
1220 | 1309 | ||
1221 | vlv_wait_port_ready(dev_priv, dport); |
1310 | vlv_wait_port_ready(dev_priv, dport); |
1222 | } |
1311 | } |
1223 | 1312 | ||
1224 | static void vlv_hdmi_pre_pll_enable(struct intel_encoder *encoder) |
1313 | static void vlv_hdmi_pre_pll_enable(struct intel_encoder *encoder) |
1225 | { |
1314 | { |
1226 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1315 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1227 | struct drm_device *dev = encoder->base.dev; |
1316 | struct drm_device *dev = encoder->base.dev; |
1228 | struct drm_i915_private *dev_priv = dev->dev_private; |
1317 | struct drm_i915_private *dev_priv = dev->dev_private; |
1229 | struct intel_crtc *intel_crtc = |
1318 | struct intel_crtc *intel_crtc = |
1230 | to_intel_crtc(encoder->base.crtc); |
1319 | to_intel_crtc(encoder->base.crtc); |
1231 | enum dpio_channel port = vlv_dport_to_channel(dport); |
1320 | enum dpio_channel port = vlv_dport_to_channel(dport); |
1232 | int pipe = intel_crtc->pipe; |
1321 | int pipe = intel_crtc->pipe; |
1233 | 1322 | ||
1234 | intel_hdmi_prepare(encoder); |
1323 | intel_hdmi_prepare(encoder); |
1235 | 1324 | ||
1236 | /* Program Tx lane resets to default */ |
1325 | /* Program Tx lane resets to default */ |
1237 | mutex_lock(&dev_priv->dpio_lock); |
1326 | mutex_lock(&dev_priv->dpio_lock); |
1238 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW0(port), |
1327 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW0(port), |
1239 | DPIO_PCS_TX_LANE2_RESET | |
1328 | DPIO_PCS_TX_LANE2_RESET | |
1240 | DPIO_PCS_TX_LANE1_RESET); |
1329 | DPIO_PCS_TX_LANE1_RESET); |
1241 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW1(port), |
1330 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW1(port), |
1242 | DPIO_PCS_CLK_CRI_RXEB_EIOS_EN | |
1331 | DPIO_PCS_CLK_CRI_RXEB_EIOS_EN | |
1243 | DPIO_PCS_CLK_CRI_RXDIGFILTSG_EN | |
1332 | DPIO_PCS_CLK_CRI_RXDIGFILTSG_EN | |
1244 | (1< |
1333 | (1< |
1245 | DPIO_PCS_CLK_SOFT_RESET); |
1334 | DPIO_PCS_CLK_SOFT_RESET); |
1246 | 1335 | ||
1247 | /* Fix up inter-pair skew failure */ |
1336 | /* Fix up inter-pair skew failure */ |
1248 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW12(port), 0x00750f00); |
1337 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW12(port), 0x00750f00); |
1249 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW11(port), 0x00001500); |
1338 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW11(port), 0x00001500); |
1250 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW14(port), 0x40400000); |
1339 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW14(port), 0x40400000); |
1251 | 1340 | ||
1252 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW9(port), 0x00002000); |
1341 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW9(port), 0x00002000); |
1253 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), DPIO_TX_OCALINIT_EN); |
1342 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), DPIO_TX_OCALINIT_EN); |
1254 | mutex_unlock(&dev_priv->dpio_lock); |
1343 | mutex_unlock(&dev_priv->dpio_lock); |
1255 | } |
1344 | } |
1256 | 1345 | ||
1257 | static void chv_hdmi_pre_pll_enable(struct intel_encoder *encoder) |
1346 | static void chv_hdmi_pre_pll_enable(struct intel_encoder *encoder) |
1258 | { |
1347 | { |
1259 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1348 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1260 | struct drm_device *dev = encoder->base.dev; |
1349 | struct drm_device *dev = encoder->base.dev; |
1261 | struct drm_i915_private *dev_priv = dev->dev_private; |
1350 | struct drm_i915_private *dev_priv = dev->dev_private; |
1262 | struct intel_crtc *intel_crtc = |
1351 | struct intel_crtc *intel_crtc = |
1263 | to_intel_crtc(encoder->base.crtc); |
1352 | to_intel_crtc(encoder->base.crtc); |
1264 | enum dpio_channel ch = vlv_dport_to_channel(dport); |
1353 | enum dpio_channel ch = vlv_dport_to_channel(dport); |
1265 | enum pipe pipe = intel_crtc->pipe; |
1354 | enum pipe pipe = intel_crtc->pipe; |
1266 | u32 val; |
1355 | u32 val; |
- | 1356 | ||
- | 1357 | intel_hdmi_prepare(encoder); |
|
1267 | 1358 | ||
1268 | mutex_lock(&dev_priv->dpio_lock); |
1359 | mutex_lock(&dev_priv->dpio_lock); |
1269 | 1360 | ||
1270 | /* program left/right clock distribution */ |
1361 | /* program left/right clock distribution */ |
1271 | if (pipe != PIPE_B) { |
1362 | if (pipe != PIPE_B) { |
1272 | val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW5_CH0); |
1363 | val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW5_CH0); |
1273 | val &= ~(CHV_BUFLEFTENA1_MASK | CHV_BUFRIGHTENA1_MASK); |
1364 | val &= ~(CHV_BUFLEFTENA1_MASK | CHV_BUFRIGHTENA1_MASK); |
1274 | if (ch == DPIO_CH0) |
1365 | if (ch == DPIO_CH0) |
1275 | val |= CHV_BUFLEFTENA1_FORCE; |
1366 | val |= CHV_BUFLEFTENA1_FORCE; |
1276 | if (ch == DPIO_CH1) |
1367 | if (ch == DPIO_CH1) |
1277 | val |= CHV_BUFRIGHTENA1_FORCE; |
1368 | val |= CHV_BUFRIGHTENA1_FORCE; |
1278 | vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW5_CH0, val); |
1369 | vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW5_CH0, val); |
1279 | } else { |
1370 | } else { |
1280 | val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW1_CH1); |
1371 | val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW1_CH1); |
1281 | val &= ~(CHV_BUFLEFTENA2_MASK | CHV_BUFRIGHTENA2_MASK); |
1372 | val &= ~(CHV_BUFLEFTENA2_MASK | CHV_BUFRIGHTENA2_MASK); |
1282 | if (ch == DPIO_CH0) |
1373 | if (ch == DPIO_CH0) |
1283 | val |= CHV_BUFLEFTENA2_FORCE; |
1374 | val |= CHV_BUFLEFTENA2_FORCE; |
1284 | if (ch == DPIO_CH1) |
1375 | if (ch == DPIO_CH1) |
1285 | val |= CHV_BUFRIGHTENA2_FORCE; |
1376 | val |= CHV_BUFRIGHTENA2_FORCE; |
1286 | vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW1_CH1, val); |
1377 | vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW1_CH1, val); |
1287 | } |
1378 | } |
1288 | 1379 | ||
1289 | /* program clock channel usage */ |
1380 | /* program clock channel usage */ |
1290 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW8(ch)); |
1381 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW8(ch)); |
1291 | val |= CHV_PCS_USEDCLKCHANNEL_OVRRIDE; |
1382 | val |= CHV_PCS_USEDCLKCHANNEL_OVRRIDE; |
1292 | if (pipe != PIPE_B) |
1383 | if (pipe != PIPE_B) |
1293 | val &= ~CHV_PCS_USEDCLKCHANNEL; |
1384 | val &= ~CHV_PCS_USEDCLKCHANNEL; |
1294 | else |
1385 | else |
1295 | val |= CHV_PCS_USEDCLKCHANNEL; |
1386 | val |= CHV_PCS_USEDCLKCHANNEL; |
1296 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW8(ch), val); |
1387 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW8(ch), val); |
1297 | 1388 | ||
1298 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW8(ch)); |
1389 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW8(ch)); |
1299 | val |= CHV_PCS_USEDCLKCHANNEL_OVRRIDE; |
1390 | val |= CHV_PCS_USEDCLKCHANNEL_OVRRIDE; |
1300 | if (pipe != PIPE_B) |
1391 | if (pipe != PIPE_B) |
1301 | val &= ~CHV_PCS_USEDCLKCHANNEL; |
1392 | val &= ~CHV_PCS_USEDCLKCHANNEL; |
1302 | else |
1393 | else |
1303 | val |= CHV_PCS_USEDCLKCHANNEL; |
1394 | val |= CHV_PCS_USEDCLKCHANNEL; |
1304 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW8(ch), val); |
1395 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW8(ch), val); |
1305 | 1396 | ||
1306 | /* |
1397 | /* |
1307 | * This a a bit weird since generally CL |
1398 | * This a a bit weird since generally CL |
1308 | * matches the pipe, but here we need to |
1399 | * matches the pipe, but here we need to |
1309 | * pick the CL based on the port. |
1400 | * pick the CL based on the port. |
1310 | */ |
1401 | */ |
1311 | val = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW19(ch)); |
1402 | val = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW19(ch)); |
1312 | if (pipe != PIPE_B) |
1403 | if (pipe != PIPE_B) |
1313 | val &= ~CHV_CMN_USEDCLKCHANNEL; |
1404 | val &= ~CHV_CMN_USEDCLKCHANNEL; |
1314 | else |
1405 | else |
1315 | val |= CHV_CMN_USEDCLKCHANNEL; |
1406 | val |= CHV_CMN_USEDCLKCHANNEL; |
1316 | vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW19(ch), val); |
1407 | vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW19(ch), val); |
1317 | 1408 | ||
1318 | mutex_unlock(&dev_priv->dpio_lock); |
1409 | mutex_unlock(&dev_priv->dpio_lock); |
1319 | } |
1410 | } |
1320 | 1411 | ||
1321 | static void vlv_hdmi_post_disable(struct intel_encoder *encoder) |
1412 | static void vlv_hdmi_post_disable(struct intel_encoder *encoder) |
1322 | { |
1413 | { |
1323 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1414 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1324 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
1415 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
1325 | struct intel_crtc *intel_crtc = |
1416 | struct intel_crtc *intel_crtc = |
1326 | to_intel_crtc(encoder->base.crtc); |
1417 | to_intel_crtc(encoder->base.crtc); |
1327 | enum dpio_channel port = vlv_dport_to_channel(dport); |
1418 | enum dpio_channel port = vlv_dport_to_channel(dport); |
1328 | int pipe = intel_crtc->pipe; |
1419 | int pipe = intel_crtc->pipe; |
1329 | 1420 | ||
1330 | /* Reset lanes to avoid HDMI flicker (VLV w/a) */ |
1421 | /* Reset lanes to avoid HDMI flicker (VLV w/a) */ |
1331 | mutex_lock(&dev_priv->dpio_lock); |
1422 | mutex_lock(&dev_priv->dpio_lock); |
1332 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW0(port), 0x00000000); |
1423 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW0(port), 0x00000000); |
1333 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW1(port), 0x00e00060); |
1424 | vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW1(port), 0x00e00060); |
1334 | mutex_unlock(&dev_priv->dpio_lock); |
1425 | mutex_unlock(&dev_priv->dpio_lock); |
1335 | } |
1426 | } |
1336 | 1427 | ||
1337 | static void chv_hdmi_post_disable(struct intel_encoder *encoder) |
1428 | static void chv_hdmi_post_disable(struct intel_encoder *encoder) |
1338 | { |
1429 | { |
1339 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1430 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1340 | struct drm_device *dev = encoder->base.dev; |
1431 | struct drm_device *dev = encoder->base.dev; |
1341 | struct drm_i915_private *dev_priv = dev->dev_private; |
1432 | struct drm_i915_private *dev_priv = dev->dev_private; |
1342 | struct intel_crtc *intel_crtc = |
1433 | struct intel_crtc *intel_crtc = |
1343 | to_intel_crtc(encoder->base.crtc); |
1434 | to_intel_crtc(encoder->base.crtc); |
1344 | enum dpio_channel ch = vlv_dport_to_channel(dport); |
1435 | enum dpio_channel ch = vlv_dport_to_channel(dport); |
1345 | enum pipe pipe = intel_crtc->pipe; |
1436 | enum pipe pipe = intel_crtc->pipe; |
1346 | u32 val; |
1437 | u32 val; |
1347 | 1438 | ||
1348 | mutex_lock(&dev_priv->dpio_lock); |
1439 | mutex_lock(&dev_priv->dpio_lock); |
1349 | 1440 | ||
1350 | /* Propagate soft reset to data lane reset */ |
1441 | /* Propagate soft reset to data lane reset */ |
1351 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW1(ch)); |
1442 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW1(ch)); |
1352 | val |= CHV_PCS_REQ_SOFTRESET_EN; |
1443 | val |= CHV_PCS_REQ_SOFTRESET_EN; |
1353 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW1(ch), val); |
1444 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW1(ch), val); |
1354 | 1445 | ||
1355 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW1(ch)); |
1446 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW1(ch)); |
1356 | val |= CHV_PCS_REQ_SOFTRESET_EN; |
1447 | val |= CHV_PCS_REQ_SOFTRESET_EN; |
1357 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW1(ch), val); |
1448 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW1(ch), val); |
1358 | 1449 | ||
1359 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW0(ch)); |
1450 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW0(ch)); |
1360 | val &= ~(DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET); |
1451 | val &= ~(DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET); |
1361 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW0(ch), val); |
1452 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW0(ch), val); |
1362 | 1453 | ||
1363 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW0(ch)); |
1454 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW0(ch)); |
1364 | val &= ~(DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET); |
1455 | val &= ~(DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET); |
1365 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW0(ch), val); |
1456 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW0(ch), val); |
1366 | 1457 | ||
1367 | mutex_unlock(&dev_priv->dpio_lock); |
1458 | mutex_unlock(&dev_priv->dpio_lock); |
1368 | } |
1459 | } |
1369 | 1460 | ||
1370 | static void chv_hdmi_pre_enable(struct intel_encoder *encoder) |
1461 | static void chv_hdmi_pre_enable(struct intel_encoder *encoder) |
1371 | { |
1462 | { |
1372 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
1463 | struct intel_digital_port *dport = enc_to_dig_port(&encoder->base); |
- | 1464 | struct intel_hdmi *intel_hdmi = &dport->hdmi; |
|
1373 | struct drm_device *dev = encoder->base.dev; |
1465 | struct drm_device *dev = encoder->base.dev; |
1374 | struct drm_i915_private *dev_priv = dev->dev_private; |
1466 | struct drm_i915_private *dev_priv = dev->dev_private; |
1375 | struct intel_crtc *intel_crtc = |
1467 | struct intel_crtc *intel_crtc = |
1376 | to_intel_crtc(encoder->base.crtc); |
1468 | to_intel_crtc(encoder->base.crtc); |
- | 1469 | struct drm_display_mode *adjusted_mode = |
|
- | 1470 | &intel_crtc->config.adjusted_mode; |
|
1377 | enum dpio_channel ch = vlv_dport_to_channel(dport); |
1471 | enum dpio_channel ch = vlv_dport_to_channel(dport); |
1378 | int pipe = intel_crtc->pipe; |
1472 | int pipe = intel_crtc->pipe; |
1379 | int data, i; |
1473 | int data, i; |
1380 | u32 val; |
1474 | u32 val; |
1381 | 1475 | ||
1382 | mutex_lock(&dev_priv->dpio_lock); |
1476 | mutex_lock(&dev_priv->dpio_lock); |
- | 1477 | ||
- | 1478 | /* allow hardware to manage TX FIFO reset source */ |
|
- | 1479 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW11(ch)); |
|
- | 1480 | val &= ~DPIO_LANEDESKEW_STRAP_OVRD; |
|
- | 1481 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW11(ch), val); |
|
- | 1482 | ||
- | 1483 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW11(ch)); |
|
- | 1484 | val &= ~DPIO_LANEDESKEW_STRAP_OVRD; |
|
- | 1485 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW11(ch), val); |
|
1383 | 1486 | ||
1384 | /* Deassert soft data lane reset*/ |
1487 | /* Deassert soft data lane reset*/ |
1385 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW1(ch)); |
1488 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW1(ch)); |
1386 | val |= CHV_PCS_REQ_SOFTRESET_EN; |
1489 | val |= CHV_PCS_REQ_SOFTRESET_EN; |
1387 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW1(ch), val); |
1490 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW1(ch), val); |
1388 | 1491 | ||
1389 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW1(ch)); |
1492 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW1(ch)); |
1390 | val |= CHV_PCS_REQ_SOFTRESET_EN; |
1493 | val |= CHV_PCS_REQ_SOFTRESET_EN; |
1391 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW1(ch), val); |
1494 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW1(ch), val); |
1392 | 1495 | ||
1393 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW0(ch)); |
1496 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW0(ch)); |
1394 | val |= (DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET); |
1497 | val |= (DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET); |
1395 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW0(ch), val); |
1498 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW0(ch), val); |
1396 | 1499 | ||
1397 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW0(ch)); |
1500 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW0(ch)); |
1398 | val |= (DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET); |
1501 | val |= (DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET); |
1399 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW0(ch), val); |
1502 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW0(ch), val); |
1400 | 1503 | ||
1401 | /* Program Tx latency optimal setting */ |
1504 | /* Program Tx latency optimal setting */ |
1402 | for (i = 0; i < 4; i++) { |
1505 | for (i = 0; i < 4; i++) { |
1403 | /* Set the latency optimal bit */ |
1506 | /* Set the latency optimal bit */ |
1404 | data = (i == 1) ? 0x0 : 0x6; |
1507 | data = (i == 1) ? 0x0 : 0x6; |
1405 | vlv_dpio_write(dev_priv, pipe, CHV_TX_DW11(ch, i), |
1508 | vlv_dpio_write(dev_priv, pipe, CHV_TX_DW11(ch, i), |
1406 | data << DPIO_FRC_LATENCY_SHFIT); |
1509 | data << DPIO_FRC_LATENCY_SHFIT); |
1407 | 1510 | ||
1408 | /* Set the upar bit */ |
1511 | /* Set the upar bit */ |
1409 | data = (i == 1) ? 0x0 : 0x1; |
1512 | data = (i == 1) ? 0x0 : 0x1; |
1410 | vlv_dpio_write(dev_priv, pipe, CHV_TX_DW14(ch, i), |
1513 | vlv_dpio_write(dev_priv, pipe, CHV_TX_DW14(ch, i), |
1411 | data << DPIO_UPAR_SHIFT); |
1514 | data << DPIO_UPAR_SHIFT); |
1412 | } |
1515 | } |
1413 | 1516 | ||
1414 | /* Data lane stagger programming */ |
1517 | /* Data lane stagger programming */ |
1415 | /* FIXME: Fix up value only after power analysis */ |
1518 | /* FIXME: Fix up value only after power analysis */ |
1416 | 1519 | ||
1417 | /* Clear calc init */ |
1520 | /* Clear calc init */ |
1418 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW10(ch)); |
1521 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW10(ch)); |
1419 | val &= ~(DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3); |
1522 | val &= ~(DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3); |
- | 1523 | val &= ~(DPIO_PCS_TX1DEEMP_MASK | DPIO_PCS_TX2DEEMP_MASK); |
|
- | 1524 | val |= DPIO_PCS_TX1DEEMP_9P5 | DPIO_PCS_TX2DEEMP_9P5; |
|
1420 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW10(ch), val); |
1525 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW10(ch), val); |
1421 | 1526 | ||
1422 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW10(ch)); |
1527 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW10(ch)); |
1423 | val &= ~(DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3); |
1528 | val &= ~(DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3); |
- | 1529 | val &= ~(DPIO_PCS_TX1DEEMP_MASK | DPIO_PCS_TX2DEEMP_MASK); |
|
- | 1530 | val |= DPIO_PCS_TX1DEEMP_9P5 | DPIO_PCS_TX2DEEMP_9P5; |
|
1424 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW10(ch), val); |
1531 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW10(ch), val); |
- | 1532 | ||
- | 1533 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW9(ch)); |
|
- | 1534 | val &= ~(DPIO_PCS_TX1MARGIN_MASK | DPIO_PCS_TX2MARGIN_MASK); |
|
- | 1535 | val |= DPIO_PCS_TX1MARGIN_000 | DPIO_PCS_TX2MARGIN_000; |
|
- | 1536 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW9(ch), val); |
|
- | 1537 | ||
- | 1538 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW9(ch)); |
|
- | 1539 | val &= ~(DPIO_PCS_TX1MARGIN_MASK | DPIO_PCS_TX2MARGIN_MASK); |
|
- | 1540 | val |= DPIO_PCS_TX1MARGIN_000 | DPIO_PCS_TX2MARGIN_000; |
|
- | 1541 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW9(ch), val); |
|
1425 | 1542 | ||
1426 | /* FIXME: Program the support xxx V-dB */ |
1543 | /* FIXME: Program the support xxx V-dB */ |
1427 | /* Use 800mV-0dB */ |
1544 | /* Use 800mV-0dB */ |
1428 | for (i = 0; i < 4; i++) { |
1545 | for (i = 0; i < 4; i++) { |
1429 | val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW4(ch, i)); |
1546 | val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW4(ch, i)); |
1430 | val &= ~DPIO_SWING_DEEMPH9P5_MASK; |
1547 | val &= ~DPIO_SWING_DEEMPH9P5_MASK; |
1431 | val |= 128 << DPIO_SWING_DEEMPH9P5_SHIFT; |
1548 | val |= 128 << DPIO_SWING_DEEMPH9P5_SHIFT; |
1432 | vlv_dpio_write(dev_priv, pipe, CHV_TX_DW4(ch, i), val); |
1549 | vlv_dpio_write(dev_priv, pipe, CHV_TX_DW4(ch, i), val); |
1433 | } |
1550 | } |
1434 | 1551 | ||
1435 | for (i = 0; i < 4; i++) { |
1552 | for (i = 0; i < 4; i++) { |
1436 | val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW2(ch, i)); |
1553 | val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW2(ch, i)); |
1437 | val &= ~DPIO_SWING_MARGIN_MASK; |
1554 | val &= ~DPIO_SWING_MARGIN000_MASK; |
1438 | val |= 102 << DPIO_SWING_MARGIN_SHIFT; |
1555 | val |= 102 << DPIO_SWING_MARGIN000_SHIFT; |
1439 | vlv_dpio_write(dev_priv, pipe, CHV_TX_DW2(ch, i), val); |
1556 | vlv_dpio_write(dev_priv, pipe, CHV_TX_DW2(ch, i), val); |
1440 | } |
1557 | } |
1441 | 1558 | ||
1442 | /* Disable unique transition scale */ |
1559 | /* Disable unique transition scale */ |
1443 | for (i = 0; i < 4; i++) { |
1560 | for (i = 0; i < 4; i++) { |
1444 | val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW3(ch, i)); |
1561 | val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW3(ch, i)); |
1445 | val &= ~DPIO_TX_UNIQ_TRANS_SCALE_EN; |
1562 | val &= ~DPIO_TX_UNIQ_TRANS_SCALE_EN; |
1446 | vlv_dpio_write(dev_priv, pipe, CHV_TX_DW3(ch, i), val); |
1563 | vlv_dpio_write(dev_priv, pipe, CHV_TX_DW3(ch, i), val); |
1447 | } |
1564 | } |
1448 | 1565 | ||
1449 | /* Additional steps for 1200mV-0dB */ |
1566 | /* Additional steps for 1200mV-0dB */ |
1450 | #if 0 |
1567 | #if 0 |
1451 | val = vlv_dpio_read(dev_priv, pipe, VLV_TX_DW3(ch)); |
1568 | val = vlv_dpio_read(dev_priv, pipe, VLV_TX_DW3(ch)); |
1452 | if (ch) |
1569 | if (ch) |
1453 | val |= DPIO_TX_UNIQ_TRANS_SCALE_CH1; |
1570 | val |= DPIO_TX_UNIQ_TRANS_SCALE_CH1; |
1454 | else |
1571 | else |
1455 | val |= DPIO_TX_UNIQ_TRANS_SCALE_CH0; |
1572 | val |= DPIO_TX_UNIQ_TRANS_SCALE_CH0; |
1456 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW3(ch), val); |
1573 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW3(ch), val); |
1457 | 1574 | ||
1458 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW2(ch), |
1575 | vlv_dpio_write(dev_priv, pipe, VLV_TX_DW2(ch), |
1459 | vlv_dpio_read(dev_priv, pipe, VLV_TX_DW2(ch)) | |
1576 | vlv_dpio_read(dev_priv, pipe, VLV_TX_DW2(ch)) | |
1460 | (0x9a << DPIO_UNIQ_TRANS_SCALE_SHIFT)); |
1577 | (0x9a << DPIO_UNIQ_TRANS_SCALE_SHIFT)); |
1461 | #endif |
1578 | #endif |
1462 | /* Start swing calculation */ |
1579 | /* Start swing calculation */ |
1463 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW10(ch)); |
1580 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW10(ch)); |
1464 | val |= DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3; |
1581 | val |= DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3; |
1465 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW10(ch), val); |
1582 | vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW10(ch), val); |
1466 | 1583 | ||
1467 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW10(ch)); |
1584 | val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW10(ch)); |
1468 | val |= DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3; |
1585 | val |= DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3; |
1469 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW10(ch), val); |
1586 | vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW10(ch), val); |
1470 | 1587 | ||
1471 | /* LRC Bypass */ |
1588 | /* LRC Bypass */ |
1472 | val = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW30); |
1589 | val = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW30); |
1473 | val |= DPIO_LRC_BYPASS; |
1590 | val |= DPIO_LRC_BYPASS; |
1474 | vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW30, val); |
1591 | vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW30, val); |
1475 | 1592 | ||
1476 | mutex_unlock(&dev_priv->dpio_lock); |
1593 | mutex_unlock(&dev_priv->dpio_lock); |
- | 1594 | ||
- | 1595 | intel_hdmi->set_infoframes(&encoder->base, |
|
- | 1596 | intel_crtc->config.has_hdmi_sink, |
|
- | 1597 | adjusted_mode); |
|
1477 | 1598 | ||
1478 | intel_enable_hdmi(encoder); |
1599 | intel_enable_hdmi(encoder); |
1479 | 1600 | ||
1480 | vlv_wait_port_ready(dev_priv, dport); |
1601 | vlv_wait_port_ready(dev_priv, dport); |
1481 | } |
1602 | } |
1482 | 1603 | ||
1483 | static void intel_hdmi_destroy(struct drm_connector *connector) |
1604 | static void intel_hdmi_destroy(struct drm_connector *connector) |
1484 | { |
1605 | { |
- | 1606 | kfree(to_intel_connector(connector)->detect_edid); |
|
1485 | drm_connector_cleanup(connector); |
1607 | drm_connector_cleanup(connector); |
1486 | kfree(connector); |
1608 | kfree(connector); |
1487 | } |
1609 | } |
1488 | 1610 | ||
1489 | static const struct drm_connector_funcs intel_hdmi_connector_funcs = { |
1611 | static const struct drm_connector_funcs intel_hdmi_connector_funcs = { |
1490 | .dpms = intel_connector_dpms, |
1612 | .dpms = intel_connector_dpms, |
1491 | .detect = intel_hdmi_detect, |
1613 | .detect = intel_hdmi_detect, |
- | 1614 | .force = intel_hdmi_force, |
|
1492 | .fill_modes = drm_helper_probe_single_connector_modes, |
1615 | .fill_modes = drm_helper_probe_single_connector_modes, |
1493 | .set_property = intel_hdmi_set_property, |
1616 | .set_property = intel_hdmi_set_property, |
1494 | .destroy = intel_hdmi_destroy, |
1617 | .destroy = intel_hdmi_destroy, |
1495 | }; |
1618 | }; |
1496 | 1619 | ||
1497 | static const struct drm_connector_helper_funcs intel_hdmi_connector_helper_funcs = { |
1620 | static const struct drm_connector_helper_funcs intel_hdmi_connector_helper_funcs = { |
1498 | .get_modes = intel_hdmi_get_modes, |
1621 | .get_modes = intel_hdmi_get_modes, |
1499 | .mode_valid = intel_hdmi_mode_valid, |
1622 | .mode_valid = intel_hdmi_mode_valid, |
1500 | .best_encoder = intel_best_encoder, |
1623 | .best_encoder = intel_best_encoder, |
1501 | }; |
1624 | }; |
1502 | 1625 | ||
1503 | static const struct drm_encoder_funcs intel_hdmi_enc_funcs = { |
1626 | static const struct drm_encoder_funcs intel_hdmi_enc_funcs = { |
1504 | .destroy = intel_encoder_destroy, |
1627 | .destroy = intel_encoder_destroy, |
1505 | }; |
1628 | }; |
1506 | 1629 | ||
1507 | static void |
1630 | static void |
1508 | intel_attach_aspect_ratio_property(struct drm_connector *connector) |
1631 | intel_attach_aspect_ratio_property(struct drm_connector *connector) |
1509 | { |
1632 | { |
1510 | if (!drm_mode_create_aspect_ratio_property(connector->dev)) |
1633 | if (!drm_mode_create_aspect_ratio_property(connector->dev)) |
1511 | drm_object_attach_property(&connector->base, |
1634 | drm_object_attach_property(&connector->base, |
1512 | connector->dev->mode_config.aspect_ratio_property, |
1635 | connector->dev->mode_config.aspect_ratio_property, |
1513 | DRM_MODE_PICTURE_ASPECT_NONE); |
1636 | DRM_MODE_PICTURE_ASPECT_NONE); |
1514 | } |
1637 | } |
1515 | 1638 | ||
1516 | static void |
1639 | static void |
1517 | intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector) |
1640 | intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector) |
1518 | { |
1641 | { |
1519 | intel_attach_force_audio_property(connector); |
1642 | intel_attach_force_audio_property(connector); |
1520 | intel_attach_broadcast_rgb_property(connector); |
1643 | intel_attach_broadcast_rgb_property(connector); |
1521 | intel_hdmi->color_range_auto = true; |
1644 | intel_hdmi->color_range_auto = true; |
1522 | intel_attach_aspect_ratio_property(connector); |
1645 | intel_attach_aspect_ratio_property(connector); |
1523 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_NONE; |
1646 | intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_NONE; |
1524 | } |
1647 | } |
1525 | 1648 | ||
1526 | void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, |
1649 | void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, |
1527 | struct intel_connector *intel_connector) |
1650 | struct intel_connector *intel_connector) |
1528 | { |
1651 | { |
1529 | struct drm_connector *connector = &intel_connector->base; |
1652 | struct drm_connector *connector = &intel_connector->base; |
1530 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
1653 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
1531 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
1654 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
1532 | struct drm_device *dev = intel_encoder->base.dev; |
1655 | struct drm_device *dev = intel_encoder->base.dev; |
1533 | struct drm_i915_private *dev_priv = dev->dev_private; |
1656 | struct drm_i915_private *dev_priv = dev->dev_private; |
1534 | enum port port = intel_dig_port->port; |
1657 | enum port port = intel_dig_port->port; |
1535 | 1658 | ||
1536 | drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, |
1659 | drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, |
1537 | DRM_MODE_CONNECTOR_HDMIA); |
1660 | DRM_MODE_CONNECTOR_HDMIA); |
1538 | drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs); |
1661 | drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs); |
1539 | 1662 | ||
1540 | connector->interlace_allowed = 1; |
1663 | connector->interlace_allowed = 1; |
1541 | connector->doublescan_allowed = 0; |
1664 | connector->doublescan_allowed = 0; |
1542 | connector->stereo_allowed = 1; |
1665 | connector->stereo_allowed = 1; |
1543 | 1666 | ||
1544 | switch (port) { |
1667 | switch (port) { |
1545 | case PORT_B: |
1668 | case PORT_B: |
1546 | intel_hdmi->ddc_bus = GMBUS_PORT_DPB; |
1669 | intel_hdmi->ddc_bus = GMBUS_PORT_DPB; |
1547 | intel_encoder->hpd_pin = HPD_PORT_B; |
1670 | intel_encoder->hpd_pin = HPD_PORT_B; |
1548 | break; |
1671 | break; |
1549 | case PORT_C: |
1672 | case PORT_C: |
1550 | intel_hdmi->ddc_bus = GMBUS_PORT_DPC; |
1673 | intel_hdmi->ddc_bus = GMBUS_PORT_DPC; |
1551 | intel_encoder->hpd_pin = HPD_PORT_C; |
1674 | intel_encoder->hpd_pin = HPD_PORT_C; |
1552 | break; |
1675 | break; |
1553 | case PORT_D: |
1676 | case PORT_D: |
1554 | if (IS_CHERRYVIEW(dev)) |
1677 | if (IS_CHERRYVIEW(dev)) |
1555 | intel_hdmi->ddc_bus = GMBUS_PORT_DPD_CHV; |
1678 | intel_hdmi->ddc_bus = GMBUS_PORT_DPD_CHV; |
1556 | else |
1679 | else |
1557 | intel_hdmi->ddc_bus = GMBUS_PORT_DPD; |
1680 | intel_hdmi->ddc_bus = GMBUS_PORT_DPD; |
1558 | intel_encoder->hpd_pin = HPD_PORT_D; |
1681 | intel_encoder->hpd_pin = HPD_PORT_D; |
1559 | break; |
1682 | break; |
1560 | case PORT_A: |
1683 | case PORT_A: |
1561 | intel_encoder->hpd_pin = HPD_PORT_A; |
1684 | intel_encoder->hpd_pin = HPD_PORT_A; |
1562 | /* Internal port only for eDP. */ |
1685 | /* Internal port only for eDP. */ |
1563 | default: |
1686 | default: |
1564 | BUG(); |
1687 | BUG(); |
1565 | } |
1688 | } |
1566 | 1689 | ||
1567 | if (IS_VALLEYVIEW(dev)) { |
1690 | if (IS_VALLEYVIEW(dev)) { |
1568 | intel_hdmi->write_infoframe = vlv_write_infoframe; |
1691 | intel_hdmi->write_infoframe = vlv_write_infoframe; |
1569 | intel_hdmi->set_infoframes = vlv_set_infoframes; |
1692 | intel_hdmi->set_infoframes = vlv_set_infoframes; |
- | 1693 | intel_hdmi->infoframe_enabled = vlv_infoframe_enabled; |
|
1570 | } else if (IS_G4X(dev)) { |
1694 | } else if (IS_G4X(dev)) { |
1571 | intel_hdmi->write_infoframe = g4x_write_infoframe; |
1695 | intel_hdmi->write_infoframe = g4x_write_infoframe; |
1572 | intel_hdmi->set_infoframes = g4x_set_infoframes; |
1696 | intel_hdmi->set_infoframes = g4x_set_infoframes; |
- | 1697 | intel_hdmi->infoframe_enabled = g4x_infoframe_enabled; |
|
1573 | } else if (HAS_DDI(dev)) { |
1698 | } else if (HAS_DDI(dev)) { |
1574 | intel_hdmi->write_infoframe = hsw_write_infoframe; |
1699 | intel_hdmi->write_infoframe = hsw_write_infoframe; |
1575 | intel_hdmi->set_infoframes = hsw_set_infoframes; |
1700 | intel_hdmi->set_infoframes = hsw_set_infoframes; |
- | 1701 | intel_hdmi->infoframe_enabled = hsw_infoframe_enabled; |
|
1576 | } else if (HAS_PCH_IBX(dev)) { |
1702 | } else if (HAS_PCH_IBX(dev)) { |
1577 | intel_hdmi->write_infoframe = ibx_write_infoframe; |
1703 | intel_hdmi->write_infoframe = ibx_write_infoframe; |
1578 | intel_hdmi->set_infoframes = ibx_set_infoframes; |
1704 | intel_hdmi->set_infoframes = ibx_set_infoframes; |
- | 1705 | intel_hdmi->infoframe_enabled = ibx_infoframe_enabled; |
|
1579 | } else { |
1706 | } else { |
1580 | intel_hdmi->write_infoframe = cpt_write_infoframe; |
1707 | intel_hdmi->write_infoframe = cpt_write_infoframe; |
1581 | intel_hdmi->set_infoframes = cpt_set_infoframes; |
1708 | intel_hdmi->set_infoframes = cpt_set_infoframes; |
- | 1709 | intel_hdmi->infoframe_enabled = cpt_infoframe_enabled; |
|
1582 | } |
1710 | } |
1583 | 1711 | ||
1584 | if (HAS_DDI(dev)) |
1712 | if (HAS_DDI(dev)) |
1585 | intel_connector->get_hw_state = intel_ddi_connector_get_hw_state; |
1713 | intel_connector->get_hw_state = intel_ddi_connector_get_hw_state; |
1586 | else |
1714 | else |
1587 | intel_connector->get_hw_state = intel_connector_get_hw_state; |
1715 | intel_connector->get_hw_state = intel_connector_get_hw_state; |
1588 | intel_connector->unregister = intel_connector_unregister; |
1716 | intel_connector->unregister = intel_connector_unregister; |
1589 | 1717 | ||
1590 | intel_hdmi_add_properties(intel_hdmi, connector); |
1718 | intel_hdmi_add_properties(intel_hdmi, connector); |
1591 | 1719 | ||
1592 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
1720 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
1593 | drm_connector_register(connector); |
1721 | drm_connector_register(connector); |
1594 | 1722 | ||
1595 | /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written |
1723 | /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written |
1596 | * 0xd. Failure to do so will result in spurious interrupts being |
1724 | * 0xd. Failure to do so will result in spurious interrupts being |
1597 | * generated on the port when a cable is not attached. |
1725 | * generated on the port when a cable is not attached. |
1598 | */ |
1726 | */ |
1599 | if (IS_G4X(dev) && !IS_GM45(dev)) { |
1727 | if (IS_G4X(dev) && !IS_GM45(dev)) { |
1600 | u32 temp = I915_READ(PEG_BAND_GAP_DATA); |
1728 | u32 temp = I915_READ(PEG_BAND_GAP_DATA); |
1601 | I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); |
1729 | I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); |
1602 | } |
1730 | } |
1603 | } |
1731 | } |
1604 | 1732 | ||
1605 | void intel_hdmi_init(struct drm_device *dev, int hdmi_reg, enum port port) |
1733 | void intel_hdmi_init(struct drm_device *dev, int hdmi_reg, enum port port) |
1606 | { |
1734 | { |
1607 | struct intel_digital_port *intel_dig_port; |
1735 | struct intel_digital_port *intel_dig_port; |
1608 | struct intel_encoder *intel_encoder; |
1736 | struct intel_encoder *intel_encoder; |
1609 | struct intel_connector *intel_connector; |
1737 | struct intel_connector *intel_connector; |
1610 | 1738 | ||
1611 | intel_dig_port = kzalloc(sizeof(*intel_dig_port), GFP_KERNEL); |
1739 | intel_dig_port = kzalloc(sizeof(*intel_dig_port), GFP_KERNEL); |
1612 | if (!intel_dig_port) |
1740 | if (!intel_dig_port) |
1613 | return; |
1741 | return; |
1614 | 1742 | ||
1615 | intel_connector = kzalloc(sizeof(*intel_connector), GFP_KERNEL); |
1743 | intel_connector = kzalloc(sizeof(*intel_connector), GFP_KERNEL); |
1616 | if (!intel_connector) { |
1744 | if (!intel_connector) { |
1617 | kfree(intel_dig_port); |
1745 | kfree(intel_dig_port); |
1618 | return; |
1746 | return; |
1619 | } |
1747 | } |
1620 | 1748 | ||
1621 | intel_encoder = &intel_dig_port->base; |
1749 | intel_encoder = &intel_dig_port->base; |
1622 | 1750 | ||
1623 | drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs, |
1751 | drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs, |
1624 | DRM_MODE_ENCODER_TMDS); |
1752 | DRM_MODE_ENCODER_TMDS); |
1625 | 1753 | ||
1626 | intel_encoder->compute_config = intel_hdmi_compute_config; |
1754 | intel_encoder->compute_config = intel_hdmi_compute_config; |
1627 | intel_encoder->disable = intel_disable_hdmi; |
1755 | intel_encoder->disable = intel_disable_hdmi; |
1628 | intel_encoder->get_hw_state = intel_hdmi_get_hw_state; |
1756 | intel_encoder->get_hw_state = intel_hdmi_get_hw_state; |
1629 | intel_encoder->get_config = intel_hdmi_get_config; |
1757 | intel_encoder->get_config = intel_hdmi_get_config; |
1630 | if (IS_CHERRYVIEW(dev)) { |
1758 | if (IS_CHERRYVIEW(dev)) { |
1631 | intel_encoder->pre_pll_enable = chv_hdmi_pre_pll_enable; |
1759 | intel_encoder->pre_pll_enable = chv_hdmi_pre_pll_enable; |
1632 | intel_encoder->pre_enable = chv_hdmi_pre_enable; |
1760 | intel_encoder->pre_enable = chv_hdmi_pre_enable; |
1633 | intel_encoder->enable = vlv_enable_hdmi; |
1761 | intel_encoder->enable = vlv_enable_hdmi; |
1634 | intel_encoder->post_disable = chv_hdmi_post_disable; |
1762 | intel_encoder->post_disable = chv_hdmi_post_disable; |
1635 | } else if (IS_VALLEYVIEW(dev)) { |
1763 | } else if (IS_VALLEYVIEW(dev)) { |
1636 | intel_encoder->pre_pll_enable = vlv_hdmi_pre_pll_enable; |
1764 | intel_encoder->pre_pll_enable = vlv_hdmi_pre_pll_enable; |
1637 | intel_encoder->pre_enable = vlv_hdmi_pre_enable; |
1765 | intel_encoder->pre_enable = vlv_hdmi_pre_enable; |
1638 | intel_encoder->enable = vlv_enable_hdmi; |
1766 | intel_encoder->enable = vlv_enable_hdmi; |
1639 | intel_encoder->post_disable = vlv_hdmi_post_disable; |
1767 | intel_encoder->post_disable = vlv_hdmi_post_disable; |
1640 | } else { |
1768 | } else { |
1641 | intel_encoder->pre_enable = intel_hdmi_pre_enable; |
1769 | intel_encoder->pre_enable = intel_hdmi_pre_enable; |
1642 | intel_encoder->enable = intel_enable_hdmi; |
1770 | intel_encoder->enable = intel_enable_hdmi; |
1643 | } |
1771 | } |
1644 | 1772 | ||
1645 | intel_encoder->type = INTEL_OUTPUT_HDMI; |
1773 | intel_encoder->type = INTEL_OUTPUT_HDMI; |
1646 | if (IS_CHERRYVIEW(dev)) { |
1774 | if (IS_CHERRYVIEW(dev)) { |
1647 | if (port == PORT_D) |
1775 | if (port == PORT_D) |
1648 | intel_encoder->crtc_mask = 1 << 2; |
1776 | intel_encoder->crtc_mask = 1 << 2; |
1649 | else |
1777 | else |
1650 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1); |
1778 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1); |
1651 | } else { |
1779 | } else { |
1652 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
1780 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
1653 | } |
1781 | } |
1654 | intel_encoder->cloneable = 1 << INTEL_OUTPUT_ANALOG; |
1782 | intel_encoder->cloneable = 1 << INTEL_OUTPUT_ANALOG; |
1655 | /* |
1783 | /* |
1656 | * BSpec is unclear about HDMI+HDMI cloning on g4x, but it seems |
1784 | * BSpec is unclear about HDMI+HDMI cloning on g4x, but it seems |
1657 | * to work on real hardware. And since g4x can send infoframes to |
1785 | * to work on real hardware. And since g4x can send infoframes to |
1658 | * only one port anyway, nothing is lost by allowing it. |
1786 | * only one port anyway, nothing is lost by allowing it. |
1659 | */ |
1787 | */ |
1660 | if (IS_G4X(dev)) |
1788 | if (IS_G4X(dev)) |
1661 | intel_encoder->cloneable |= 1 << INTEL_OUTPUT_HDMI; |
1789 | intel_encoder->cloneable |= 1 << INTEL_OUTPUT_HDMI; |
1662 | 1790 | ||
1663 | intel_dig_port->port = port; |
1791 | intel_dig_port->port = port; |
1664 | intel_dig_port->hdmi.hdmi_reg = hdmi_reg; |
1792 | intel_dig_port->hdmi.hdmi_reg = hdmi_reg; |
1665 | intel_dig_port->dp.output_reg = 0; |
1793 | intel_dig_port->dp.output_reg = 0; |
1666 | 1794 | ||
1667 | intel_hdmi_init_connector(intel_dig_port, intel_connector); |
1795 | intel_hdmi_init_connector(intel_dig_port, intel_connector); |
1668 | }><>><>><>><>><>><>><>><>><>>><>>><>>><>><>> |
1796 | }><>><>><>><>><>><>><>><>><>>><>>><>>><>><>> |
1669 | ><21); |
1797 | ><21); |
1670 | >21); |
1798 | >21); |
1671 | ><21); |
1799 | ><21); |
1672 | >=>>>>>>>>>>>>>>>> |
1800 | >=>>>>>>>>>>>>>>>> |