diff options
Diffstat (limited to 'drivers/gpu/drm/i915/intel_audio.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_audio.c | 202 |
1 files changed, 111 insertions, 91 deletions
diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c index 0ddba16fde1b..f1502a0188eb 100644 --- a/drivers/gpu/drm/i915/intel_audio.c +++ b/drivers/gpu/drm/i915/intel_audio.c | |||
@@ -102,13 +102,13 @@ static const struct dp_aud_n_m dp_aud_n_m[] = { | |||
102 | }; | 102 | }; |
103 | 103 | ||
104 | static const struct dp_aud_n_m * | 104 | static const struct dp_aud_n_m * |
105 | audio_config_dp_get_n_m(struct intel_crtc *intel_crtc, int rate) | 105 | audio_config_dp_get_n_m(const struct intel_crtc_state *crtc_state, int rate) |
106 | { | 106 | { |
107 | int i; | 107 | int i; |
108 | 108 | ||
109 | for (i = 0; i < ARRAY_SIZE(dp_aud_n_m); i++) { | 109 | for (i = 0; i < ARRAY_SIZE(dp_aud_n_m); i++) { |
110 | if (rate == dp_aud_n_m[i].sample_rate && | 110 | if (rate == dp_aud_n_m[i].sample_rate && |
111 | intel_crtc->config->port_clock == dp_aud_n_m[i].clock) | 111 | crtc_state->port_clock == dp_aud_n_m[i].clock) |
112 | return &dp_aud_n_m[i]; | 112 | return &dp_aud_n_m[i]; |
113 | } | 113 | } |
114 | 114 | ||
@@ -157,8 +157,10 @@ static const struct { | |||
157 | }; | 157 | }; |
158 | 158 | ||
159 | /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ | 159 | /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ |
160 | static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted_mode) | 160 | static u32 audio_config_hdmi_pixel_clock(const struct intel_crtc_state *crtc_state) |
161 | { | 161 | { |
162 | const struct drm_display_mode *adjusted_mode = | ||
163 | &crtc_state->base.adjusted_mode; | ||
162 | int i; | 164 | int i; |
163 | 165 | ||
164 | for (i = 0; i < ARRAY_SIZE(hdmi_audio_clock); i++) { | 166 | for (i = 0; i < ARRAY_SIZE(hdmi_audio_clock); i++) { |
@@ -179,9 +181,11 @@ static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted | |||
179 | return hdmi_audio_clock[i].config; | 181 | return hdmi_audio_clock[i].config; |
180 | } | 182 | } |
181 | 183 | ||
182 | static int audio_config_hdmi_get_n(const struct drm_display_mode *adjusted_mode, | 184 | static int audio_config_hdmi_get_n(const struct intel_crtc_state *crtc_state, |
183 | int rate) | 185 | int rate) |
184 | { | 186 | { |
187 | const struct drm_display_mode *adjusted_mode = | ||
188 | &crtc_state->base.adjusted_mode; | ||
185 | int i; | 189 | int i; |
186 | 190 | ||
187 | for (i = 0; i < ARRAY_SIZE(hdmi_aud_ncts); i++) { | 191 | for (i = 0; i < ARRAY_SIZE(hdmi_aud_ncts); i++) { |
@@ -220,7 +224,9 @@ static bool intel_eld_uptodate(struct drm_connector *connector, | |||
220 | return true; | 224 | return true; |
221 | } | 225 | } |
222 | 226 | ||
223 | static void g4x_audio_codec_disable(struct intel_encoder *encoder) | 227 | static void g4x_audio_codec_disable(struct intel_encoder *encoder, |
228 | const struct intel_crtc_state *old_crtc_state, | ||
229 | const struct drm_connector_state *old_conn_state) | ||
224 | { | 230 | { |
225 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); | 231 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
226 | uint32_t eldv, tmp; | 232 | uint32_t eldv, tmp; |
@@ -239,11 +245,12 @@ static void g4x_audio_codec_disable(struct intel_encoder *encoder) | |||
239 | I915_WRITE(G4X_AUD_CNTL_ST, tmp); | 245 | I915_WRITE(G4X_AUD_CNTL_ST, tmp); |
240 | } | 246 | } |
241 | 247 | ||
242 | static void g4x_audio_codec_enable(struct drm_connector *connector, | 248 | static void g4x_audio_codec_enable(struct intel_encoder *encoder, |
243 | struct intel_encoder *encoder, | 249 | const struct intel_crtc_state *crtc_state, |
244 | const struct drm_display_mode *adjusted_mode) | 250 | const struct drm_connector_state *conn_state) |
245 | { | 251 | { |
246 | struct drm_i915_private *dev_priv = to_i915(connector->dev); | 252 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
253 | struct drm_connector *connector = conn_state->connector; | ||
247 | uint8_t *eld = connector->eld; | 254 | uint8_t *eld = connector->eld; |
248 | uint32_t eldv; | 255 | uint32_t eldv; |
249 | uint32_t tmp; | 256 | uint32_t tmp; |
@@ -279,16 +286,20 @@ static void g4x_audio_codec_enable(struct drm_connector *connector, | |||
279 | } | 286 | } |
280 | 287 | ||
281 | static void | 288 | static void |
282 | hsw_dp_audio_config_update(struct intel_crtc *intel_crtc, enum port port, | 289 | hsw_dp_audio_config_update(struct intel_encoder *encoder, |
283 | const struct drm_display_mode *adjusted_mode) | 290 | const struct intel_crtc_state *crtc_state) |
284 | { | 291 | { |
285 | struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev); | 292 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
286 | struct i915_audio_component *acomp = dev_priv->audio_component; | 293 | struct i915_audio_component *acomp = dev_priv->audio_component; |
287 | int rate = acomp ? acomp->aud_sample_rate[port] : 0; | 294 | struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); |
288 | const struct dp_aud_n_m *nm = audio_config_dp_get_n_m(intel_crtc, rate); | 295 | enum port port = encoder->port; |
289 | enum pipe pipe = intel_crtc->pipe; | 296 | enum pipe pipe = crtc->pipe; |
297 | const struct dp_aud_n_m *nm; | ||
298 | int rate; | ||
290 | u32 tmp; | 299 | u32 tmp; |
291 | 300 | ||
301 | rate = acomp ? acomp->aud_sample_rate[port] : 0; | ||
302 | nm = audio_config_dp_get_n_m(crtc_state, rate); | ||
292 | if (nm) | 303 | if (nm) |
293 | DRM_DEBUG_KMS("using Maud %u, Naud %u\n", nm->m, nm->n); | 304 | DRM_DEBUG_KMS("using Maud %u, Naud %u\n", nm->m, nm->n); |
294 | else | 305 | else |
@@ -323,23 +334,26 @@ hsw_dp_audio_config_update(struct intel_crtc *intel_crtc, enum port port, | |||
323 | } | 334 | } |
324 | 335 | ||
325 | static void | 336 | static void |
326 | hsw_hdmi_audio_config_update(struct intel_crtc *intel_crtc, enum port port, | 337 | hsw_hdmi_audio_config_update(struct intel_encoder *encoder, |
327 | const struct drm_display_mode *adjusted_mode) | 338 | const struct intel_crtc_state *crtc_state) |
328 | { | 339 | { |
329 | struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev); | 340 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
330 | struct i915_audio_component *acomp = dev_priv->audio_component; | 341 | struct i915_audio_component *acomp = dev_priv->audio_component; |
331 | int rate = acomp ? acomp->aud_sample_rate[port] : 0; | 342 | struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); |
332 | enum pipe pipe = intel_crtc->pipe; | 343 | enum port port = encoder->port; |
333 | int n; | 344 | enum pipe pipe = crtc->pipe; |
345 | int n, rate; | ||
334 | u32 tmp; | 346 | u32 tmp; |
335 | 347 | ||
348 | rate = acomp ? acomp->aud_sample_rate[port] : 0; | ||
349 | |||
336 | tmp = I915_READ(HSW_AUD_CFG(pipe)); | 350 | tmp = I915_READ(HSW_AUD_CFG(pipe)); |
337 | tmp &= ~AUD_CONFIG_N_VALUE_INDEX; | 351 | tmp &= ~AUD_CONFIG_N_VALUE_INDEX; |
338 | tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK; | 352 | tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK; |
339 | tmp &= ~AUD_CONFIG_N_PROG_ENABLE; | 353 | tmp &= ~AUD_CONFIG_N_PROG_ENABLE; |
340 | tmp |= audio_config_hdmi_pixel_clock(adjusted_mode); | 354 | tmp |= audio_config_hdmi_pixel_clock(crtc_state); |
341 | 355 | ||
342 | n = audio_config_hdmi_get_n(adjusted_mode, rate); | 356 | n = audio_config_hdmi_get_n(crtc_state, rate); |
343 | if (n != 0) { | 357 | if (n != 0) { |
344 | DRM_DEBUG_KMS("using N %d\n", n); | 358 | DRM_DEBUG_KMS("using N %d\n", n); |
345 | 359 | ||
@@ -363,20 +377,22 @@ hsw_hdmi_audio_config_update(struct intel_crtc *intel_crtc, enum port port, | |||
363 | } | 377 | } |
364 | 378 | ||
365 | static void | 379 | static void |
366 | hsw_audio_config_update(struct intel_crtc *intel_crtc, enum port port, | 380 | hsw_audio_config_update(struct intel_encoder *encoder, |
367 | const struct drm_display_mode *adjusted_mode) | 381 | const struct intel_crtc_state *crtc_state) |
368 | { | 382 | { |
369 | if (intel_crtc_has_dp_encoder(intel_crtc->config)) | 383 | if (intel_crtc_has_dp_encoder(crtc_state)) |
370 | hsw_dp_audio_config_update(intel_crtc, port, adjusted_mode); | 384 | hsw_dp_audio_config_update(encoder, crtc_state); |
371 | else | 385 | else |
372 | hsw_hdmi_audio_config_update(intel_crtc, port, adjusted_mode); | 386 | hsw_hdmi_audio_config_update(encoder, crtc_state); |
373 | } | 387 | } |
374 | 388 | ||
375 | static void hsw_audio_codec_disable(struct intel_encoder *encoder) | 389 | static void hsw_audio_codec_disable(struct intel_encoder *encoder, |
390 | const struct intel_crtc_state *old_crtc_state, | ||
391 | const struct drm_connector_state *old_conn_state) | ||
376 | { | 392 | { |
377 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); | 393 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
378 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); | 394 | struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc); |
379 | enum pipe pipe = intel_crtc->pipe; | 395 | enum pipe pipe = crtc->pipe; |
380 | uint32_t tmp; | 396 | uint32_t tmp; |
381 | 397 | ||
382 | DRM_DEBUG_KMS("Disable audio codec on pipe %c\n", pipe_name(pipe)); | 398 | DRM_DEBUG_KMS("Disable audio codec on pipe %c\n", pipe_name(pipe)); |
@@ -389,7 +405,7 @@ static void hsw_audio_codec_disable(struct intel_encoder *encoder) | |||
389 | tmp |= AUD_CONFIG_N_PROG_ENABLE; | 405 | tmp |= AUD_CONFIG_N_PROG_ENABLE; |
390 | tmp &= ~AUD_CONFIG_UPPER_N_MASK; | 406 | tmp &= ~AUD_CONFIG_UPPER_N_MASK; |
391 | tmp &= ~AUD_CONFIG_LOWER_N_MASK; | 407 | tmp &= ~AUD_CONFIG_LOWER_N_MASK; |
392 | if (intel_crtc_has_dp_encoder(intel_crtc->config)) | 408 | if (intel_crtc_has_dp_encoder(old_crtc_state)) |
393 | tmp |= AUD_CONFIG_N_VALUE_INDEX; | 409 | tmp |= AUD_CONFIG_N_VALUE_INDEX; |
394 | I915_WRITE(HSW_AUD_CFG(pipe), tmp); | 410 | I915_WRITE(HSW_AUD_CFG(pipe), tmp); |
395 | 411 | ||
@@ -402,14 +418,14 @@ static void hsw_audio_codec_disable(struct intel_encoder *encoder) | |||
402 | mutex_unlock(&dev_priv->av_mutex); | 418 | mutex_unlock(&dev_priv->av_mutex); |
403 | } | 419 | } |
404 | 420 | ||
405 | static void hsw_audio_codec_enable(struct drm_connector *connector, | 421 | static void hsw_audio_codec_enable(struct intel_encoder *encoder, |
406 | struct intel_encoder *intel_encoder, | 422 | const struct intel_crtc_state *crtc_state, |
407 | const struct drm_display_mode *adjusted_mode) | 423 | const struct drm_connector_state *conn_state) |
408 | { | 424 | { |
409 | struct drm_i915_private *dev_priv = to_i915(connector->dev); | 425 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
410 | struct intel_crtc *intel_crtc = to_intel_crtc(intel_encoder->base.crtc); | 426 | struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); |
411 | enum pipe pipe = intel_crtc->pipe; | 427 | struct drm_connector *connector = conn_state->connector; |
412 | enum port port = intel_encoder->port; | 428 | enum pipe pipe = crtc->pipe; |
413 | const uint8_t *eld = connector->eld; | 429 | const uint8_t *eld = connector->eld; |
414 | uint32_t tmp; | 430 | uint32_t tmp; |
415 | int len, i; | 431 | int len, i; |
@@ -448,17 +464,19 @@ static void hsw_audio_codec_enable(struct drm_connector *connector, | |||
448 | I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp); | 464 | I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp); |
449 | 465 | ||
450 | /* Enable timestamps */ | 466 | /* Enable timestamps */ |
451 | hsw_audio_config_update(intel_crtc, port, adjusted_mode); | 467 | hsw_audio_config_update(encoder, crtc_state); |
452 | 468 | ||
453 | mutex_unlock(&dev_priv->av_mutex); | 469 | mutex_unlock(&dev_priv->av_mutex); |
454 | } | 470 | } |
455 | 471 | ||
456 | static void ilk_audio_codec_disable(struct intel_encoder *intel_encoder) | 472 | static void ilk_audio_codec_disable(struct intel_encoder *encoder, |
473 | const struct intel_crtc_state *old_crtc_state, | ||
474 | const struct drm_connector_state *old_conn_state) | ||
457 | { | 475 | { |
458 | struct drm_i915_private *dev_priv = to_i915(intel_encoder->base.dev); | 476 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
459 | struct intel_crtc *intel_crtc = to_intel_crtc(intel_encoder->base.crtc); | 477 | struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc); |
460 | enum pipe pipe = intel_crtc->pipe; | 478 | enum pipe pipe = crtc->pipe; |
461 | enum port port = intel_encoder->port; | 479 | enum port port = encoder->port; |
462 | uint32_t tmp, eldv; | 480 | uint32_t tmp, eldv; |
463 | i915_reg_t aud_config, aud_cntrl_st2; | 481 | i915_reg_t aud_config, aud_cntrl_st2; |
464 | 482 | ||
@@ -485,7 +503,7 @@ static void ilk_audio_codec_disable(struct intel_encoder *intel_encoder) | |||
485 | tmp |= AUD_CONFIG_N_PROG_ENABLE; | 503 | tmp |= AUD_CONFIG_N_PROG_ENABLE; |
486 | tmp &= ~AUD_CONFIG_UPPER_N_MASK; | 504 | tmp &= ~AUD_CONFIG_UPPER_N_MASK; |
487 | tmp &= ~AUD_CONFIG_LOWER_N_MASK; | 505 | tmp &= ~AUD_CONFIG_LOWER_N_MASK; |
488 | if (intel_crtc_has_dp_encoder(intel_crtc->config)) | 506 | if (intel_crtc_has_dp_encoder(old_crtc_state)) |
489 | tmp |= AUD_CONFIG_N_VALUE_INDEX; | 507 | tmp |= AUD_CONFIG_N_VALUE_INDEX; |
490 | I915_WRITE(aud_config, tmp); | 508 | I915_WRITE(aud_config, tmp); |
491 | 509 | ||
@@ -497,14 +515,15 @@ static void ilk_audio_codec_disable(struct intel_encoder *intel_encoder) | |||
497 | I915_WRITE(aud_cntrl_st2, tmp); | 515 | I915_WRITE(aud_cntrl_st2, tmp); |
498 | } | 516 | } |
499 | 517 | ||
500 | static void ilk_audio_codec_enable(struct drm_connector *connector, | 518 | static void ilk_audio_codec_enable(struct intel_encoder *encoder, |
501 | struct intel_encoder *intel_encoder, | 519 | const struct intel_crtc_state *crtc_state, |
502 | const struct drm_display_mode *adjusted_mode) | 520 | const struct drm_connector_state *conn_state) |
503 | { | 521 | { |
504 | struct drm_i915_private *dev_priv = to_i915(connector->dev); | 522 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
505 | struct intel_crtc *intel_crtc = to_intel_crtc(intel_encoder->base.crtc); | 523 | struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); |
506 | enum pipe pipe = intel_crtc->pipe; | 524 | struct drm_connector *connector = conn_state->connector; |
507 | enum port port = intel_encoder->port; | 525 | enum pipe pipe = crtc->pipe; |
526 | enum port port = encoder->port; | ||
508 | uint8_t *eld = connector->eld; | 527 | uint8_t *eld = connector->eld; |
509 | uint32_t tmp, eldv; | 528 | uint32_t tmp, eldv; |
510 | int len, i; | 529 | int len, i; |
@@ -568,36 +587,36 @@ static void ilk_audio_codec_enable(struct drm_connector *connector, | |||
568 | tmp &= ~AUD_CONFIG_N_VALUE_INDEX; | 587 | tmp &= ~AUD_CONFIG_N_VALUE_INDEX; |
569 | tmp &= ~AUD_CONFIG_N_PROG_ENABLE; | 588 | tmp &= ~AUD_CONFIG_N_PROG_ENABLE; |
570 | tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK; | 589 | tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK; |
571 | if (intel_crtc_has_dp_encoder(intel_crtc->config)) | 590 | if (intel_crtc_has_dp_encoder(crtc_state)) |
572 | tmp |= AUD_CONFIG_N_VALUE_INDEX; | 591 | tmp |= AUD_CONFIG_N_VALUE_INDEX; |
573 | else | 592 | else |
574 | tmp |= audio_config_hdmi_pixel_clock(adjusted_mode); | 593 | tmp |= audio_config_hdmi_pixel_clock(crtc_state); |
575 | I915_WRITE(aud_config, tmp); | 594 | I915_WRITE(aud_config, tmp); |
576 | } | 595 | } |
577 | 596 | ||
578 | /** | 597 | /** |
579 | * intel_audio_codec_enable - Enable the audio codec for HD audio | 598 | * intel_audio_codec_enable - Enable the audio codec for HD audio |
580 | * @intel_encoder: encoder on which to enable audio | 599 | * @encoder: encoder on which to enable audio |
581 | * @crtc_state: pointer to the current crtc state. | 600 | * @crtc_state: pointer to the current crtc state. |
582 | * @conn_state: pointer to the current connector state. | 601 | * @conn_state: pointer to the current connector state. |
583 | * | 602 | * |
584 | * The enable sequences may only be performed after enabling the transcoder and | 603 | * The enable sequences may only be performed after enabling the transcoder and |
585 | * port, and after completed link training. | 604 | * port, and after completed link training. |
586 | */ | 605 | */ |
587 | void intel_audio_codec_enable(struct intel_encoder *intel_encoder, | 606 | void intel_audio_codec_enable(struct intel_encoder *encoder, |
588 | const struct intel_crtc_state *crtc_state, | 607 | const struct intel_crtc_state *crtc_state, |
589 | const struct drm_connector_state *conn_state) | 608 | const struct drm_connector_state *conn_state) |
590 | { | 609 | { |
591 | struct drm_encoder *encoder = &intel_encoder->base; | 610 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
592 | const struct drm_display_mode *adjusted_mode = &crtc_state->base.adjusted_mode; | ||
593 | struct drm_connector *connector; | ||
594 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); | ||
595 | struct i915_audio_component *acomp = dev_priv->audio_component; | 611 | struct i915_audio_component *acomp = dev_priv->audio_component; |
596 | enum port port = intel_encoder->port; | 612 | struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); |
597 | enum pipe pipe = to_intel_crtc(crtc_state->base.crtc)->pipe; | 613 | struct drm_connector *connector = conn_state->connector; |
614 | const struct drm_display_mode *adjusted_mode = | ||
615 | &crtc_state->base.adjusted_mode; | ||
616 | enum port port = encoder->port; | ||
617 | enum pipe pipe = crtc->pipe; | ||
598 | 618 | ||
599 | connector = conn_state->connector; | 619 | if (!connector->eld[0]) |
600 | if (!connector || !connector->eld[0]) | ||
601 | return; | 620 | return; |
602 | 621 | ||
603 | DRM_DEBUG_DRIVER("ELD on [CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", | 622 | DRM_DEBUG_DRIVER("ELD on [CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", |
@@ -609,19 +628,20 @@ void intel_audio_codec_enable(struct intel_encoder *intel_encoder, | |||
609 | connector->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2; | 628 | connector->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2; |
610 | 629 | ||
611 | if (dev_priv->display.audio_codec_enable) | 630 | if (dev_priv->display.audio_codec_enable) |
612 | dev_priv->display.audio_codec_enable(connector, intel_encoder, | 631 | dev_priv->display.audio_codec_enable(encoder, |
613 | adjusted_mode); | 632 | crtc_state, |
633 | conn_state); | ||
614 | 634 | ||
615 | mutex_lock(&dev_priv->av_mutex); | 635 | mutex_lock(&dev_priv->av_mutex); |
616 | intel_encoder->audio_connector = connector; | 636 | encoder->audio_connector = connector; |
617 | 637 | ||
618 | /* referred in audio callbacks */ | 638 | /* referred in audio callbacks */ |
619 | dev_priv->av_enc_map[pipe] = intel_encoder; | 639 | dev_priv->av_enc_map[pipe] = encoder; |
620 | mutex_unlock(&dev_priv->av_mutex); | 640 | mutex_unlock(&dev_priv->av_mutex); |
621 | 641 | ||
622 | if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify) { | 642 | if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify) { |
623 | /* audio drivers expect pipe = -1 to indicate Non-MST cases */ | 643 | /* audio drivers expect pipe = -1 to indicate Non-MST cases */ |
624 | if (intel_encoder->type != INTEL_OUTPUT_DP_MST) | 644 | if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)) |
625 | pipe = -1; | 645 | pipe = -1; |
626 | acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr, | 646 | acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr, |
627 | (int) port, (int) pipe); | 647 | (int) port, (int) pipe); |
@@ -629,36 +649,41 @@ void intel_audio_codec_enable(struct intel_encoder *intel_encoder, | |||
629 | 649 | ||
630 | intel_lpe_audio_notify(dev_priv, pipe, port, connector->eld, | 650 | intel_lpe_audio_notify(dev_priv, pipe, port, connector->eld, |
631 | crtc_state->port_clock, | 651 | crtc_state->port_clock, |
632 | intel_encoder->type == INTEL_OUTPUT_DP); | 652 | intel_crtc_has_dp_encoder(crtc_state)); |
633 | } | 653 | } |
634 | 654 | ||
635 | /** | 655 | /** |
636 | * intel_audio_codec_disable - Disable the audio codec for HD audio | 656 | * intel_audio_codec_disable - Disable the audio codec for HD audio |
637 | * @intel_encoder: encoder on which to disable audio | 657 | * @encoder: encoder on which to disable audio |
658 | * @old_crtc_state: pointer to the old crtc state. | ||
659 | * @old_conn_state: pointer to the old connector state. | ||
638 | * | 660 | * |
639 | * The disable sequences must be performed before disabling the transcoder or | 661 | * The disable sequences must be performed before disabling the transcoder or |
640 | * port. | 662 | * port. |
641 | */ | 663 | */ |
642 | void intel_audio_codec_disable(struct intel_encoder *intel_encoder) | 664 | void intel_audio_codec_disable(struct intel_encoder *encoder, |
665 | const struct intel_crtc_state *old_crtc_state, | ||
666 | const struct drm_connector_state *old_conn_state) | ||
643 | { | 667 | { |
644 | struct drm_encoder *encoder = &intel_encoder->base; | 668 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
645 | struct drm_i915_private *dev_priv = to_i915(encoder->dev); | ||
646 | struct i915_audio_component *acomp = dev_priv->audio_component; | 669 | struct i915_audio_component *acomp = dev_priv->audio_component; |
647 | enum port port = intel_encoder->port; | 670 | struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc); |
648 | struct intel_crtc *crtc = to_intel_crtc(encoder->crtc); | 671 | enum port port = encoder->port; |
649 | enum pipe pipe = crtc->pipe; | 672 | enum pipe pipe = crtc->pipe; |
650 | 673 | ||
651 | if (dev_priv->display.audio_codec_disable) | 674 | if (dev_priv->display.audio_codec_disable) |
652 | dev_priv->display.audio_codec_disable(intel_encoder); | 675 | dev_priv->display.audio_codec_disable(encoder, |
676 | old_crtc_state, | ||
677 | old_conn_state); | ||
653 | 678 | ||
654 | mutex_lock(&dev_priv->av_mutex); | 679 | mutex_lock(&dev_priv->av_mutex); |
655 | intel_encoder->audio_connector = NULL; | 680 | encoder->audio_connector = NULL; |
656 | dev_priv->av_enc_map[pipe] = NULL; | 681 | dev_priv->av_enc_map[pipe] = NULL; |
657 | mutex_unlock(&dev_priv->av_mutex); | 682 | mutex_unlock(&dev_priv->av_mutex); |
658 | 683 | ||
659 | if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify) { | 684 | if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify) { |
660 | /* audio drivers expect pipe = -1 to indicate Non-MST cases */ | 685 | /* audio drivers expect pipe = -1 to indicate Non-MST cases */ |
661 | if (intel_encoder->type != INTEL_OUTPUT_DP_MST) | 686 | if (!intel_crtc_has_type(old_crtc_state, INTEL_OUTPUT_DP_MST)) |
662 | pipe = -1; | 687 | pipe = -1; |
663 | acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr, | 688 | acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr, |
664 | (int) port, (int) pipe); | 689 | (int) port, (int) pipe); |
@@ -793,10 +818,9 @@ static int i915_audio_component_sync_audio_rate(struct device *kdev, int port, | |||
793 | int pipe, int rate) | 818 | int pipe, int rate) |
794 | { | 819 | { |
795 | struct drm_i915_private *dev_priv = kdev_to_i915(kdev); | 820 | struct drm_i915_private *dev_priv = kdev_to_i915(kdev); |
796 | struct intel_encoder *intel_encoder; | ||
797 | struct intel_crtc *crtc; | ||
798 | struct drm_display_mode *adjusted_mode; | ||
799 | struct i915_audio_component *acomp = dev_priv->audio_component; | 821 | struct i915_audio_component *acomp = dev_priv->audio_component; |
822 | struct intel_encoder *encoder; | ||
823 | struct intel_crtc *crtc; | ||
800 | int err = 0; | 824 | int err = 0; |
801 | 825 | ||
802 | if (!HAS_DDI(dev_priv)) | 826 | if (!HAS_DDI(dev_priv)) |
@@ -806,23 +830,19 @@ static int i915_audio_component_sync_audio_rate(struct device *kdev, int port, | |||
806 | mutex_lock(&dev_priv->av_mutex); | 830 | mutex_lock(&dev_priv->av_mutex); |
807 | 831 | ||
808 | /* 1. get the pipe */ | 832 | /* 1. get the pipe */ |
809 | intel_encoder = get_saved_enc(dev_priv, port, pipe); | 833 | encoder = get_saved_enc(dev_priv, port, pipe); |
810 | if (!intel_encoder || !intel_encoder->base.crtc) { | 834 | if (!encoder || !encoder->base.crtc) { |
811 | DRM_DEBUG_KMS("Not valid for port %c\n", port_name(port)); | 835 | DRM_DEBUG_KMS("Not valid for port %c\n", port_name(port)); |
812 | err = -ENODEV; | 836 | err = -ENODEV; |
813 | goto unlock; | 837 | goto unlock; |
814 | } | 838 | } |
815 | 839 | ||
816 | /* pipe passed from the audio driver will be -1 for Non-MST case */ | 840 | crtc = to_intel_crtc(encoder->base.crtc); |
817 | crtc = to_intel_crtc(intel_encoder->base.crtc); | ||
818 | pipe = crtc->pipe; | ||
819 | |||
820 | adjusted_mode = &crtc->config->base.adjusted_mode; | ||
821 | 841 | ||
822 | /* port must be valid now, otherwise the pipe will be invalid */ | 842 | /* port must be valid now, otherwise the pipe will be invalid */ |
823 | acomp->aud_sample_rate[port] = rate; | 843 | acomp->aud_sample_rate[port] = rate; |
824 | 844 | ||
825 | hsw_audio_config_update(crtc, port, adjusted_mode); | 845 | hsw_audio_config_update(encoder, crtc->config); |
826 | 846 | ||
827 | unlock: | 847 | unlock: |
828 | mutex_unlock(&dev_priv->av_mutex); | 848 | mutex_unlock(&dev_priv->av_mutex); |