blob: fa0eecf6a792db0e236ec126f17f0d52169ccf37 [file] [log] [blame]
Jani Nikula7c10a2b2014-10-27 16:26:43 +02001/*
2 * Copyright © 2014 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include <linux/kernel.h>
25
26#include <drm/drmP.h>
27#include <drm/drm_edid.h>
28#include "intel_drv.h"
29#include "i915_drv.h"
30
Jani Nikula87fcb2a2014-10-27 16:26:44 +020031static const struct {
Jani Nikula7c10a2b2014-10-27 16:26:43 +020032 int clock;
33 u32 config;
34} hdmi_audio_clock[] = {
35 { DIV_ROUND_UP(25200 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_25175 },
36 { 25200, AUD_CONFIG_PIXEL_CLOCK_HDMI_25200 }, /* default per bspec */
37 { 27000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27000 },
38 { 27000 * 1001 / 1000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27027 },
39 { 54000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54000 },
40 { 54000 * 1001 / 1000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54054 },
41 { DIV_ROUND_UP(74250 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_74176 },
42 { 74250, AUD_CONFIG_PIXEL_CLOCK_HDMI_74250 },
43 { DIV_ROUND_UP(148500 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_148352 },
44 { 148500, AUD_CONFIG_PIXEL_CLOCK_HDMI_148500 },
45};
46
47/* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */
48static u32 audio_config_hdmi_pixel_clock(struct drm_display_mode *mode)
49{
50 int i;
51
52 for (i = 0; i < ARRAY_SIZE(hdmi_audio_clock); i++) {
53 if (mode->clock == hdmi_audio_clock[i].clock)
54 break;
55 }
56
57 if (i == ARRAY_SIZE(hdmi_audio_clock)) {
58 DRM_DEBUG_KMS("HDMI audio pixel clock setting for %d not found, falling back to defaults\n", mode->clock);
59 i = 1;
60 }
61
62 DRM_DEBUG_KMS("Configuring HDMI audio for pixel clock %d (0x%08x)\n",
63 hdmi_audio_clock[i].clock,
64 hdmi_audio_clock[i].config);
65
66 return hdmi_audio_clock[i].config;
67}
68
69static bool intel_eld_uptodate(struct drm_connector *connector,
70 int reg_eldv, uint32_t bits_eldv,
71 int reg_elda, uint32_t bits_elda,
72 int reg_edid)
73{
74 struct drm_i915_private *dev_priv = connector->dev->dev_private;
75 uint8_t *eld = connector->eld;
Jani Nikulaf9f682a2014-10-27 16:26:45 +020076 uint32_t tmp;
77 int i;
Jani Nikula7c10a2b2014-10-27 16:26:43 +020078
Jani Nikulaf9f682a2014-10-27 16:26:45 +020079 tmp = I915_READ(reg_eldv);
80 tmp &= bits_eldv;
Jani Nikula7c10a2b2014-10-27 16:26:43 +020081
Jani Nikulaf9f682a2014-10-27 16:26:45 +020082 if (!tmp)
Jani Nikula7c10a2b2014-10-27 16:26:43 +020083 return false;
84
Jani Nikulaf9f682a2014-10-27 16:26:45 +020085 tmp = I915_READ(reg_elda);
86 tmp &= ~bits_elda;
87 I915_WRITE(reg_elda, tmp);
Jani Nikula7c10a2b2014-10-27 16:26:43 +020088
89 for (i = 0; i < eld[2]; i++)
90 if (I915_READ(reg_edid) != *((uint32_t *)eld + i))
91 return false;
92
93 return true;
94}
95
Jani Nikula76d8d3e2014-10-27 16:26:57 +020096static void g4x_audio_codec_disable(struct intel_encoder *encoder)
97{
98 struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
99 uint32_t eldv, tmp;
100
101 DRM_DEBUG_KMS("Disable audio codec\n");
102
103 tmp = I915_READ(G4X_AUD_VID_DID);
104 if (tmp == INTEL_AUDIO_DEVBLC || tmp == INTEL_AUDIO_DEVCL)
105 eldv = G4X_ELDV_DEVCL_DEVBLC;
106 else
107 eldv = G4X_ELDV_DEVCTG;
108
109 /* Invalidate ELD */
110 tmp = I915_READ(G4X_AUD_CNTL_ST);
111 tmp &= ~eldv;
112 I915_WRITE(G4X_AUD_CNTL_ST, tmp);
113}
114
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200115static void g4x_audio_codec_enable(struct drm_connector *connector,
116 struct intel_encoder *encoder,
117 struct drm_display_mode *mode)
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200118{
119 struct drm_i915_private *dev_priv = connector->dev->dev_private;
120 uint8_t *eld = connector->eld;
121 uint32_t eldv;
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200122 uint32_t tmp;
123 int len, i;
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200124
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200125 tmp = I915_READ(G4X_AUD_VID_DID);
126 if (tmp == INTEL_AUDIO_DEVBLC || tmp == INTEL_AUDIO_DEVCL)
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200127 eldv = G4X_ELDV_DEVCL_DEVBLC;
128 else
129 eldv = G4X_ELDV_DEVCTG;
130
131 if (intel_eld_uptodate(connector,
132 G4X_AUD_CNTL_ST, eldv,
Jani Nikulac46f1112014-10-27 16:26:52 +0200133 G4X_AUD_CNTL_ST, G4X_ELD_ADDR_MASK,
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200134 G4X_HDMIW_HDMIEDID))
135 return;
136
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200137 tmp = I915_READ(G4X_AUD_CNTL_ST);
Jani Nikulac46f1112014-10-27 16:26:52 +0200138 tmp &= ~(eldv | G4X_ELD_ADDR_MASK);
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200139 len = (tmp >> 9) & 0x1f; /* ELD buffer size */
140 I915_WRITE(G4X_AUD_CNTL_ST, tmp);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200141
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200142 len = min_t(int, eld[2], len);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200143 DRM_DEBUG_DRIVER("ELD size %d\n", len);
144 for (i = 0; i < len; i++)
145 I915_WRITE(G4X_HDMIW_HDMIEDID, *((uint32_t *)eld + i));
146
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200147 tmp = I915_READ(G4X_AUD_CNTL_ST);
148 tmp |= eldv;
149 I915_WRITE(G4X_AUD_CNTL_ST, tmp);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200150}
151
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200152static void hsw_audio_codec_disable(struct intel_encoder *encoder)
153{
Jani Nikula5fad84a2014-11-04 10:30:23 +0200154 struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
155 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
156 enum pipe pipe = intel_crtc->pipe;
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200157 uint32_t tmp;
158
Jani Nikula5fad84a2014-11-04 10:30:23 +0200159 DRM_DEBUG_KMS("Disable audio codec on pipe %c\n", pipe_name(pipe));
160
161 /* Disable timestamps */
162 tmp = I915_READ(HSW_AUD_CFG(pipe));
163 tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
164 tmp |= AUD_CONFIG_N_PROG_ENABLE;
165 tmp &= ~AUD_CONFIG_UPPER_N_MASK;
166 tmp &= ~AUD_CONFIG_LOWER_N_MASK;
167 if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
168 tmp |= AUD_CONFIG_N_VALUE_INDEX;
169 I915_WRITE(HSW_AUD_CFG(pipe), tmp);
170
171 /* Invalidate ELD */
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200172 tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
Jani Nikula5fad84a2014-11-04 10:30:23 +0200173 tmp &= ~(AUDIO_ELD_VALID_A << (pipe * 4));
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200174 I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
175}
176
177static void hsw_audio_codec_enable(struct drm_connector *connector,
178 struct intel_encoder *encoder,
179 struct drm_display_mode *mode)
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200180{
181 struct drm_i915_private *dev_priv = connector->dev->dev_private;
Jani Nikula820d2d72014-10-27 16:26:47 +0200182 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
Jani Nikula5fad84a2014-11-04 10:30:23 +0200183 enum pipe pipe = intel_crtc->pipe;
184 const uint8_t *eld = connector->eld;
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200185 uint32_t tmp;
186 int len, i;
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200187
Jani Nikula5fad84a2014-11-04 10:30:23 +0200188 DRM_DEBUG_KMS("Enable audio codec on pipe %c, %u bytes ELD\n",
189 pipe_name(pipe), eld[2]);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200190
Jani Nikula5fad84a2014-11-04 10:30:23 +0200191 /* Enable audio presence detect, invalidate ELD */
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200192 tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
Jani Nikula5fad84a2014-11-04 10:30:23 +0200193 tmp |= AUDIO_OUTPUT_ENABLE_A << (pipe * 4);
194 tmp &= ~(AUDIO_ELD_VALID_A << (pipe * 4));
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200195 I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
Jani Nikula5fad84a2014-11-04 10:30:23 +0200196
197 /*
198 * FIXME: We're supposed to wait for vblank here, but we have vblanks
199 * disabled during the mode set. The proper fix would be to push the
200 * rest of the setup into a vblank work item, queued here, but the
201 * infrastructure is not there yet.
202 */
203
204 /* Reset ELD write address */
205 tmp = I915_READ(HSW_AUD_DIP_ELD_CTRL(pipe));
206 tmp &= ~IBX_ELD_ADDRESS_MASK;
207 I915_WRITE(HSW_AUD_DIP_ELD_CTRL(pipe), tmp);
208
209 /* Up to 84 bytes of hw ELD buffer */
210 len = min_t(int, eld[2], 21);
211 for (i = 0; i < len; i++)
212 I915_WRITE(HSW_AUD_EDID_DATA(pipe), *((uint32_t *)eld + i));
213
214 /* ELD valid */
215 tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
216 tmp |= AUDIO_ELD_VALID_A << (pipe * 4);
217 I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
218
219 /* Enable timestamps */
220 tmp = I915_READ(HSW_AUD_CFG(pipe));
221 tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
222 tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
223 tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
224 if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
225 tmp |= AUD_CONFIG_N_VALUE_INDEX;
226 else
227 tmp |= audio_config_hdmi_pixel_clock(mode);
228 I915_WRITE(HSW_AUD_CFG(pipe), tmp);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200229}
230
Jani Nikula495a5bb2014-10-27 16:26:55 +0200231static void ilk_audio_codec_disable(struct intel_encoder *encoder)
232{
233 struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
234 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
235 struct intel_digital_port *intel_dig_port =
236 enc_to_dig_port(&encoder->base);
237 enum port port = intel_dig_port->port;
238 enum pipe pipe = intel_crtc->pipe;
239 uint32_t tmp, eldv;
240 int aud_config;
241 int aud_cntrl_st2;
242
243 DRM_DEBUG_KMS("Disable audio codec on port %c, pipe %c\n",
244 port_name(port), pipe_name(pipe));
245
246 if (HAS_PCH_IBX(dev_priv->dev)) {
247 aud_config = IBX_AUD_CFG(pipe);
248 aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
249 } else if (IS_VALLEYVIEW(dev_priv)) {
250 aud_config = VLV_AUD_CFG(pipe);
251 aud_cntrl_st2 = VLV_AUD_CNTL_ST2;
252 } else {
253 aud_config = CPT_AUD_CFG(pipe);
254 aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
255 }
256
257 /* Disable timestamps */
258 tmp = I915_READ(aud_config);
259 tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
260 tmp |= AUD_CONFIG_N_PROG_ENABLE;
261 tmp &= ~AUD_CONFIG_UPPER_N_MASK;
262 tmp &= ~AUD_CONFIG_LOWER_N_MASK;
263 if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
264 tmp |= AUD_CONFIG_N_VALUE_INDEX;
265 I915_WRITE(aud_config, tmp);
266
267 if (WARN_ON(!port)) {
268 eldv = IBX_ELD_VALIDB;
269 eldv |= IBX_ELD_VALIDB << 4;
270 eldv |= IBX_ELD_VALIDB << 8;
271 } else {
272 eldv = IBX_ELD_VALIDB << ((port - 1) * 4);
273 }
274
275 /* Invalidate ELD */
276 tmp = I915_READ(aud_cntrl_st2);
277 tmp &= ~eldv;
278 I915_WRITE(aud_cntrl_st2, tmp);
279}
280
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200281static void ilk_audio_codec_enable(struct drm_connector *connector,
282 struct intel_encoder *encoder,
283 struct drm_display_mode *mode)
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200284{
285 struct drm_i915_private *dev_priv = connector->dev->dev_private;
Jani Nikula820d2d72014-10-27 16:26:47 +0200286 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
Jani Nikulac6bde932014-11-04 10:31:28 +0200287 struct intel_digital_port *intel_dig_port =
288 enc_to_dig_port(&encoder->base);
289 enum port port = intel_dig_port->port;
290 enum pipe pipe = intel_crtc->pipe;
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200291 uint8_t *eld = connector->eld;
292 uint32_t eldv;
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200293 uint32_t tmp;
294 int len, i;
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200295 int hdmiw_hdmiedid;
296 int aud_config;
297 int aud_cntl_st;
298 int aud_cntrl_st2;
Jani Nikulac6bde932014-11-04 10:31:28 +0200299
300 DRM_DEBUG_KMS("Enable audio codec on port %c, pipe %c, %u bytes ELD\n",
301 port_name(port), pipe_name(pipe), eld[2]);
302
303 /*
304 * FIXME: We're supposed to wait for vblank here, but we have vblanks
305 * disabled during the mode set. The proper fix would be to push the
306 * rest of the setup into a vblank work item, queued here, but the
307 * infrastructure is not there yet.
308 */
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200309
310 if (HAS_PCH_IBX(connector->dev)) {
311 hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID(pipe);
312 aud_config = IBX_AUD_CFG(pipe);
313 aud_cntl_st = IBX_AUD_CNTL_ST(pipe);
314 aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
315 } else if (IS_VALLEYVIEW(connector->dev)) {
316 hdmiw_hdmiedid = VLV_HDMIW_HDMIEDID(pipe);
317 aud_config = VLV_AUD_CFG(pipe);
318 aud_cntl_st = VLV_AUD_CNTL_ST(pipe);
319 aud_cntrl_st2 = VLV_AUD_CNTL_ST2;
320 } else {
321 hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID(pipe);
322 aud_config = CPT_AUD_CFG(pipe);
323 aud_cntl_st = CPT_AUD_CNTL_ST(pipe);
324 aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
325 }
326
Jani Nikulac6bde932014-11-04 10:31:28 +0200327 if (WARN_ON(!port)) {
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200328 eldv = IBX_ELD_VALIDB;
329 eldv |= IBX_ELD_VALIDB << 4;
330 eldv |= IBX_ELD_VALIDB << 8;
331 } else {
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200332 eldv = IBX_ELD_VALIDB << ((port - 1) * 4);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200333 }
334
Jani Nikulac6bde932014-11-04 10:31:28 +0200335 /* Invalidate ELD */
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200336 tmp = I915_READ(aud_cntrl_st2);
337 tmp &= ~eldv;
338 I915_WRITE(aud_cntrl_st2, tmp);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200339
Jani Nikulac6bde932014-11-04 10:31:28 +0200340 /* Reset ELD write address */
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200341 tmp = I915_READ(aud_cntl_st);
Jani Nikulac46f1112014-10-27 16:26:52 +0200342 tmp &= ~IBX_ELD_ADDRESS_MASK;
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200343 I915_WRITE(aud_cntl_st, tmp);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200344
Jani Nikulac6bde932014-11-04 10:31:28 +0200345 /* Up to 84 bytes of hw ELD buffer */
346 len = min_t(int, eld[2], 21);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200347 for (i = 0; i < len; i++)
348 I915_WRITE(hdmiw_hdmiedid, *((uint32_t *)eld + i));
349
Jani Nikulac6bde932014-11-04 10:31:28 +0200350 /* ELD valid */
Jani Nikulaf9f682a2014-10-27 16:26:45 +0200351 tmp = I915_READ(aud_cntrl_st2);
352 tmp |= eldv;
353 I915_WRITE(aud_cntrl_st2, tmp);
Jani Nikulac6bde932014-11-04 10:31:28 +0200354
355 /* Enable timestamps */
356 tmp = I915_READ(aud_config);
357 tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
358 tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
359 tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
360 if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
361 tmp |= AUD_CONFIG_N_VALUE_INDEX;
362 else
363 tmp |= audio_config_hdmi_pixel_clock(mode);
364 I915_WRITE(aud_config, tmp);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200365}
366
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200367/**
368 * intel_audio_codec_enable - Enable the audio codec for HD audio
369 * @intel_encoder: encoder on which to enable audio
370 *
371 * The enable sequences may only be performed after enabling the transcoder and
372 * port, and after completed link training.
373 */
374void intel_audio_codec_enable(struct intel_encoder *intel_encoder)
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200375{
Jani Nikula33d1e7c62014-10-27 16:26:46 +0200376 struct drm_encoder *encoder = &intel_encoder->base;
377 struct intel_crtc *crtc = to_intel_crtc(encoder->crtc);
378 struct drm_display_mode *mode = &crtc->config.adjusted_mode;
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200379 struct drm_connector *connector;
380 struct drm_device *dev = encoder->dev;
381 struct drm_i915_private *dev_priv = dev->dev_private;
382
383 connector = drm_select_eld(encoder, mode);
384 if (!connector)
385 return;
386
387 DRM_DEBUG_DRIVER("ELD on [CONNECTOR:%d:%s], [ENCODER:%d:%s]\n",
388 connector->base.id,
389 connector->name,
390 connector->encoder->base.id,
391 connector->encoder->name);
392
Jani Nikula6189b032014-10-28 13:53:01 +0200393 /* ELD Conn_Type */
394 connector->eld[5] &= ~(3 << 2);
395 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT))
396 connector->eld[5] |= (1 << 2);
397
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200398 connector->eld[6] = drm_av_sync_delay(connector, mode) / 2;
399
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200400 if (dev_priv->display.audio_codec_enable)
401 dev_priv->display.audio_codec_enable(connector, intel_encoder, mode);
402}
403
404/**
405 * intel_audio_codec_disable - Disable the audio codec for HD audio
406 * @encoder: encoder on which to disable audio
407 *
408 * The disable sequences must be performed before disabling the transcoder or
409 * port.
410 */
411void intel_audio_codec_disable(struct intel_encoder *encoder)
412{
413 struct drm_device *dev = encoder->base.dev;
414 struct drm_i915_private *dev_priv = dev->dev_private;
415
416 if (dev_priv->display.audio_codec_disable)
417 dev_priv->display.audio_codec_disable(encoder);
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200418}
419
420/**
421 * intel_init_audio - Set up chip specific audio functions
422 * @dev: drm device
423 */
424void intel_init_audio(struct drm_device *dev)
425{
426 struct drm_i915_private *dev_priv = dev->dev_private;
427
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200428 if (IS_G4X(dev)) {
429 dev_priv->display.audio_codec_enable = g4x_audio_codec_enable;
Jani Nikula76d8d3e2014-10-27 16:26:57 +0200430 dev_priv->display.audio_codec_disable = g4x_audio_codec_disable;
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200431 } else if (IS_VALLEYVIEW(dev)) {
432 dev_priv->display.audio_codec_enable = ilk_audio_codec_enable;
Jani Nikula495a5bb2014-10-27 16:26:55 +0200433 dev_priv->display.audio_codec_disable = ilk_audio_codec_disable;
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200434 } else if (IS_HASWELL(dev) || INTEL_INFO(dev)->gen >= 8) {
435 dev_priv->display.audio_codec_enable = hsw_audio_codec_enable;
436 dev_priv->display.audio_codec_disable = hsw_audio_codec_disable;
437 } else if (HAS_PCH_SPLIT(dev)) {
438 dev_priv->display.audio_codec_enable = ilk_audio_codec_enable;
Jani Nikula495a5bb2014-10-27 16:26:55 +0200439 dev_priv->display.audio_codec_disable = ilk_audio_codec_disable;
Jani Nikula69bfe1a2014-10-27 16:26:50 +0200440 }
Jani Nikula7c10a2b2014-10-27 16:26:43 +0200441}