Commit 8ec47de2 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Pass around crtc and connector states for audio

Explicitly pass the crtc and connector states into the audio
code enable/disable hooks, and plumb them all the way down.

This gets rid of almost all crtc->config and encoder->crtc
uses. The one place where we still use them is
i915_audio_component_sync_audio_rate() since that gets called from
the audio driver and we don't have explicit states around then.

Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171030184654.17429-1-ville.syrjala@linux.intel.comReviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 4ab09d0e
...@@ -726,10 +726,12 @@ struct drm_i915_display_funcs { ...@@ -726,10 +726,12 @@ struct drm_i915_display_funcs {
void (*crtc_disable)(struct intel_crtc_state *old_crtc_state, void (*crtc_disable)(struct intel_crtc_state *old_crtc_state,
struct drm_atomic_state *old_state); struct drm_atomic_state *old_state);
void (*update_crtcs)(struct drm_atomic_state *state); void (*update_crtcs)(struct drm_atomic_state *state);
void (*audio_codec_enable)(struct drm_connector *connector, void (*audio_codec_enable)(struct intel_encoder *encoder,
struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state,
const struct drm_display_mode *adjusted_mode); const struct drm_connector_state *conn_state);
void (*audio_codec_disable)(struct intel_encoder *encoder); void (*audio_codec_disable)(struct intel_encoder *encoder,
const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state);
void (*fdi_link_train)(struct intel_crtc *crtc, void (*fdi_link_train)(struct intel_crtc *crtc,
const struct intel_crtc_state *crtc_state); const struct intel_crtc_state *crtc_state);
void (*init_clock_gating)(struct drm_i915_private *dev_priv); void (*init_clock_gating)(struct drm_i915_private *dev_priv);
......
...@@ -102,13 +102,13 @@ static const struct dp_aud_n_m dp_aud_n_m[] = { ...@@ -102,13 +102,13 @@ static const struct dp_aud_n_m dp_aud_n_m[] = {
}; };
static const struct dp_aud_n_m * static const struct dp_aud_n_m *
audio_config_dp_get_n_m(struct intel_crtc *intel_crtc, int rate) audio_config_dp_get_n_m(const struct intel_crtc_state *crtc_state, int rate)
{ {
int i; int i;
for (i = 0; i < ARRAY_SIZE(dp_aud_n_m); i++) { for (i = 0; i < ARRAY_SIZE(dp_aud_n_m); i++) {
if (rate == dp_aud_n_m[i].sample_rate && if (rate == dp_aud_n_m[i].sample_rate &&
intel_crtc->config->port_clock == dp_aud_n_m[i].clock) crtc_state->port_clock == dp_aud_n_m[i].clock)
return &dp_aud_n_m[i]; return &dp_aud_n_m[i];
} }
...@@ -157,8 +157,10 @@ static const struct { ...@@ -157,8 +157,10 @@ static const struct {
}; };
/* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */
static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted_mode) static u32 audio_config_hdmi_pixel_clock(const struct intel_crtc_state *crtc_state)
{ {
const struct drm_display_mode *adjusted_mode =
&crtc_state->base.adjusted_mode;
int i; int i;
for (i = 0; i < ARRAY_SIZE(hdmi_audio_clock); i++) { 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,9 +181,11 @@ static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
return hdmi_audio_clock[i].config; return hdmi_audio_clock[i].config;
} }
static int audio_config_hdmi_get_n(const struct drm_display_mode *adjusted_mode, static int audio_config_hdmi_get_n(const struct intel_crtc_state *crtc_state,
int rate) int rate)
{ {
const struct drm_display_mode *adjusted_mode =
&crtc_state->base.adjusted_mode;
int i; int i;
for (i = 0; i < ARRAY_SIZE(hdmi_aud_ncts); i++) { for (i = 0; i < ARRAY_SIZE(hdmi_aud_ncts); i++) {
...@@ -220,7 +224,9 @@ static bool intel_eld_uptodate(struct drm_connector *connector, ...@@ -220,7 +224,9 @@ static bool intel_eld_uptodate(struct drm_connector *connector,
return true; return true;
} }
static void g4x_audio_codec_disable(struct intel_encoder *encoder) static void g4x_audio_codec_disable(struct intel_encoder *encoder,
const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state)
{ {
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
uint32_t eldv, tmp; uint32_t eldv, tmp;
...@@ -239,11 +245,12 @@ static void g4x_audio_codec_disable(struct intel_encoder *encoder) ...@@ -239,11 +245,12 @@ static void g4x_audio_codec_disable(struct intel_encoder *encoder)
I915_WRITE(G4X_AUD_CNTL_ST, tmp); I915_WRITE(G4X_AUD_CNTL_ST, tmp);
} }
static void g4x_audio_codec_enable(struct drm_connector *connector, static void g4x_audio_codec_enable(struct intel_encoder *encoder,
struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state,
const struct drm_display_mode *adjusted_mode) const struct drm_connector_state *conn_state)
{ {
struct drm_i915_private *dev_priv = to_i915(connector->dev); struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
struct drm_connector *connector = conn_state->connector;
uint8_t *eld = connector->eld; uint8_t *eld = connector->eld;
uint32_t eldv; uint32_t eldv;
uint32_t tmp; uint32_t tmp;
...@@ -279,16 +286,20 @@ static void g4x_audio_codec_enable(struct drm_connector *connector, ...@@ -279,16 +286,20 @@ static void g4x_audio_codec_enable(struct drm_connector *connector,
} }
static void static void
hsw_dp_audio_config_update(struct intel_crtc *intel_crtc, enum port port, hsw_dp_audio_config_update(struct intel_encoder *encoder,
const struct drm_display_mode *adjusted_mode) const struct intel_crtc_state *crtc_state)
{ {
struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
struct i915_audio_component *acomp = dev_priv->audio_component; struct i915_audio_component *acomp = dev_priv->audio_component;
int rate = acomp ? acomp->aud_sample_rate[port] : 0; struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
const struct dp_aud_n_m *nm = audio_config_dp_get_n_m(intel_crtc, rate); enum port port = encoder->port;
enum pipe pipe = intel_crtc->pipe; enum pipe pipe = crtc->pipe;
const struct dp_aud_n_m *nm;
int rate;
u32 tmp; u32 tmp;
rate = acomp ? acomp->aud_sample_rate[port] : 0;
nm = audio_config_dp_get_n_m(crtc_state, rate);
if (nm) if (nm)
DRM_DEBUG_KMS("using Maud %u, Naud %u\n", nm->m, nm->n); DRM_DEBUG_KMS("using Maud %u, Naud %u\n", nm->m, nm->n);
else else
...@@ -323,23 +334,26 @@ hsw_dp_audio_config_update(struct intel_crtc *intel_crtc, enum port port, ...@@ -323,23 +334,26 @@ hsw_dp_audio_config_update(struct intel_crtc *intel_crtc, enum port port,
} }
static void static void
hsw_hdmi_audio_config_update(struct intel_crtc *intel_crtc, enum port port, hsw_hdmi_audio_config_update(struct intel_encoder *encoder,
const struct drm_display_mode *adjusted_mode) const struct intel_crtc_state *crtc_state)
{ {
struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
struct i915_audio_component *acomp = dev_priv->audio_component; struct i915_audio_component *acomp = dev_priv->audio_component;
int rate = acomp ? acomp->aud_sample_rate[port] : 0; struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
enum pipe pipe = intel_crtc->pipe; enum port port = encoder->port;
int n; enum pipe pipe = crtc->pipe;
int n, rate;
u32 tmp; u32 tmp;
rate = acomp ? acomp->aud_sample_rate[port] : 0;
tmp = I915_READ(HSW_AUD_CFG(pipe)); tmp = I915_READ(HSW_AUD_CFG(pipe));
tmp &= ~AUD_CONFIG_N_VALUE_INDEX; tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK; tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
tmp &= ~AUD_CONFIG_N_PROG_ENABLE; tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
tmp |= audio_config_hdmi_pixel_clock(adjusted_mode); tmp |= audio_config_hdmi_pixel_clock(crtc_state);
n = audio_config_hdmi_get_n(adjusted_mode, rate); n = audio_config_hdmi_get_n(crtc_state, rate);
if (n != 0) { if (n != 0) {
DRM_DEBUG_KMS("using N %d\n", n); DRM_DEBUG_KMS("using N %d\n", n);
...@@ -363,20 +377,22 @@ hsw_hdmi_audio_config_update(struct intel_crtc *intel_crtc, enum port port, ...@@ -363,20 +377,22 @@ hsw_hdmi_audio_config_update(struct intel_crtc *intel_crtc, enum port port,
} }
static void static void
hsw_audio_config_update(struct intel_crtc *intel_crtc, enum port port, hsw_audio_config_update(struct intel_encoder *encoder,
const struct drm_display_mode *adjusted_mode) const struct intel_crtc_state *crtc_state)
{ {
if (intel_crtc_has_dp_encoder(intel_crtc->config)) if (intel_crtc_has_dp_encoder(crtc_state))
hsw_dp_audio_config_update(intel_crtc, port, adjusted_mode); hsw_dp_audio_config_update(encoder, crtc_state);
else else
hsw_hdmi_audio_config_update(intel_crtc, port, adjusted_mode); hsw_hdmi_audio_config_update(encoder, crtc_state);
} }
static void hsw_audio_codec_disable(struct intel_encoder *encoder) static void hsw_audio_codec_disable(struct intel_encoder *encoder,
const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state)
{ {
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc);
enum pipe pipe = intel_crtc->pipe; enum pipe pipe = crtc->pipe;
uint32_t tmp; uint32_t tmp;
DRM_DEBUG_KMS("Disable audio codec on pipe %c\n", pipe_name(pipe)); 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,7 +405,7 @@ static void hsw_audio_codec_disable(struct intel_encoder *encoder)
tmp |= AUD_CONFIG_N_PROG_ENABLE; tmp |= AUD_CONFIG_N_PROG_ENABLE;
tmp &= ~AUD_CONFIG_UPPER_N_MASK; tmp &= ~AUD_CONFIG_UPPER_N_MASK;
tmp &= ~AUD_CONFIG_LOWER_N_MASK; tmp &= ~AUD_CONFIG_LOWER_N_MASK;
if (intel_crtc_has_dp_encoder(intel_crtc->config)) if (intel_crtc_has_dp_encoder(old_crtc_state))
tmp |= AUD_CONFIG_N_VALUE_INDEX; tmp |= AUD_CONFIG_N_VALUE_INDEX;
I915_WRITE(HSW_AUD_CFG(pipe), tmp); I915_WRITE(HSW_AUD_CFG(pipe), tmp);
...@@ -402,14 +418,14 @@ static void hsw_audio_codec_disable(struct intel_encoder *encoder) ...@@ -402,14 +418,14 @@ static void hsw_audio_codec_disable(struct intel_encoder *encoder)
mutex_unlock(&dev_priv->av_mutex); mutex_unlock(&dev_priv->av_mutex);
} }
static void hsw_audio_codec_enable(struct drm_connector *connector, static void hsw_audio_codec_enable(struct intel_encoder *encoder,
struct intel_encoder *intel_encoder, const struct intel_crtc_state *crtc_state,
const struct drm_display_mode *adjusted_mode) const struct drm_connector_state *conn_state)
{ {
struct drm_i915_private *dev_priv = to_i915(connector->dev); struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
struct intel_crtc *intel_crtc = to_intel_crtc(intel_encoder->base.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
enum pipe pipe = intel_crtc->pipe; struct drm_connector *connector = conn_state->connector;
enum port port = intel_encoder->port; enum pipe pipe = crtc->pipe;
const uint8_t *eld = connector->eld; const uint8_t *eld = connector->eld;
uint32_t tmp; uint32_t tmp;
int len, i; int len, i;
...@@ -448,17 +464,19 @@ static void hsw_audio_codec_enable(struct drm_connector *connector, ...@@ -448,17 +464,19 @@ static void hsw_audio_codec_enable(struct drm_connector *connector,
I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp); I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
/* Enable timestamps */ /* Enable timestamps */
hsw_audio_config_update(intel_crtc, port, adjusted_mode); hsw_audio_config_update(encoder, crtc_state);
mutex_unlock(&dev_priv->av_mutex); mutex_unlock(&dev_priv->av_mutex);
} }
static void ilk_audio_codec_disable(struct intel_encoder *intel_encoder) static void ilk_audio_codec_disable(struct intel_encoder *encoder,
const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state)
{ {
struct drm_i915_private *dev_priv = to_i915(intel_encoder->base.dev); struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
struct intel_crtc *intel_crtc = to_intel_crtc(intel_encoder->base.crtc); struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc);
enum pipe pipe = intel_crtc->pipe; enum pipe pipe = crtc->pipe;
enum port port = intel_encoder->port; enum port port = encoder->port;
uint32_t tmp, eldv; uint32_t tmp, eldv;
i915_reg_t aud_config, aud_cntrl_st2; i915_reg_t aud_config, aud_cntrl_st2;
...@@ -485,7 +503,7 @@ static void ilk_audio_codec_disable(struct intel_encoder *intel_encoder) ...@@ -485,7 +503,7 @@ static void ilk_audio_codec_disable(struct intel_encoder *intel_encoder)
tmp |= AUD_CONFIG_N_PROG_ENABLE; tmp |= AUD_CONFIG_N_PROG_ENABLE;
tmp &= ~AUD_CONFIG_UPPER_N_MASK; tmp &= ~AUD_CONFIG_UPPER_N_MASK;
tmp &= ~AUD_CONFIG_LOWER_N_MASK; tmp &= ~AUD_CONFIG_LOWER_N_MASK;
if (intel_crtc_has_dp_encoder(intel_crtc->config)) if (intel_crtc_has_dp_encoder(old_crtc_state))
tmp |= AUD_CONFIG_N_VALUE_INDEX; tmp |= AUD_CONFIG_N_VALUE_INDEX;
I915_WRITE(aud_config, tmp); I915_WRITE(aud_config, tmp);
...@@ -497,14 +515,15 @@ static void ilk_audio_codec_disable(struct intel_encoder *intel_encoder) ...@@ -497,14 +515,15 @@ static void ilk_audio_codec_disable(struct intel_encoder *intel_encoder)
I915_WRITE(aud_cntrl_st2, tmp); I915_WRITE(aud_cntrl_st2, tmp);
} }
static void ilk_audio_codec_enable(struct drm_connector *connector, static void ilk_audio_codec_enable(struct intel_encoder *encoder,
struct intel_encoder *intel_encoder, const struct intel_crtc_state *crtc_state,
const struct drm_display_mode *adjusted_mode) const struct drm_connector_state *conn_state)
{ {
struct drm_i915_private *dev_priv = to_i915(connector->dev); struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
struct intel_crtc *intel_crtc = to_intel_crtc(intel_encoder->base.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
enum pipe pipe = intel_crtc->pipe; struct drm_connector *connector = conn_state->connector;
enum port port = intel_encoder->port; enum pipe pipe = crtc->pipe;
enum port port = encoder->port;
uint8_t *eld = connector->eld; uint8_t *eld = connector->eld;
uint32_t tmp, eldv; uint32_t tmp, eldv;
int len, i; int len, i;
...@@ -568,36 +587,36 @@ static void ilk_audio_codec_enable(struct drm_connector *connector, ...@@ -568,36 +587,36 @@ static void ilk_audio_codec_enable(struct drm_connector *connector,
tmp &= ~AUD_CONFIG_N_VALUE_INDEX; tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
tmp &= ~AUD_CONFIG_N_PROG_ENABLE; tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK; tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
if (intel_crtc_has_dp_encoder(intel_crtc->config)) if (intel_crtc_has_dp_encoder(crtc_state))
tmp |= AUD_CONFIG_N_VALUE_INDEX; tmp |= AUD_CONFIG_N_VALUE_INDEX;
else else
tmp |= audio_config_hdmi_pixel_clock(adjusted_mode); tmp |= audio_config_hdmi_pixel_clock(crtc_state);
I915_WRITE(aud_config, tmp); I915_WRITE(aud_config, tmp);
} }
/** /**
* intel_audio_codec_enable - Enable the audio codec for HD audio * intel_audio_codec_enable - Enable the audio codec for HD audio
* @intel_encoder: encoder on which to enable audio * @encoder: encoder on which to enable audio
* @crtc_state: pointer to the current crtc state. * @crtc_state: pointer to the current crtc state.
* @conn_state: pointer to the current connector state. * @conn_state: pointer to the current connector state.
* *
* The enable sequences may only be performed after enabling the transcoder and * The enable sequences may only be performed after enabling the transcoder and
* port, and after completed link training. * port, and after completed link training.
*/ */
void intel_audio_codec_enable(struct intel_encoder *intel_encoder, void intel_audio_codec_enable(struct intel_encoder *encoder,
const struct intel_crtc_state *crtc_state, const struct intel_crtc_state *crtc_state,
const struct drm_connector_state *conn_state) const struct drm_connector_state *conn_state)
{ {
struct drm_encoder *encoder = &intel_encoder->base; struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
const struct drm_display_mode *adjusted_mode = &crtc_state->base.adjusted_mode;
struct drm_connector *connector;
struct drm_i915_private *dev_priv = to_i915(encoder->dev);
struct i915_audio_component *acomp = dev_priv->audio_component; struct i915_audio_component *acomp = dev_priv->audio_component;
enum port port = intel_encoder->port; struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
enum pipe pipe = to_intel_crtc(crtc_state->base.crtc)->pipe; struct drm_connector *connector = conn_state->connector;
const struct drm_display_mode *adjusted_mode =
&crtc_state->base.adjusted_mode;
enum port port = encoder->port;
enum pipe pipe = crtc->pipe;
connector = conn_state->connector; if (!connector->eld[0])
if (!connector || !connector->eld[0])
return; return;
DRM_DEBUG_DRIVER("ELD on [CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", 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,19 +628,20 @@ void intel_audio_codec_enable(struct intel_encoder *intel_encoder,
connector->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2; connector->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2;
if (dev_priv->display.audio_codec_enable) if (dev_priv->display.audio_codec_enable)
dev_priv->display.audio_codec_enable(connector, intel_encoder, dev_priv->display.audio_codec_enable(encoder,
adjusted_mode); crtc_state,
conn_state);
mutex_lock(&dev_priv->av_mutex); mutex_lock(&dev_priv->av_mutex);
intel_encoder->audio_connector = connector; encoder->audio_connector = connector;
/* referred in audio callbacks */ /* referred in audio callbacks */
dev_priv->av_enc_map[pipe] = intel_encoder; dev_priv->av_enc_map[pipe] = encoder;
mutex_unlock(&dev_priv->av_mutex); mutex_unlock(&dev_priv->av_mutex);
if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify) { if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify) {
/* audio drivers expect pipe = -1 to indicate Non-MST cases */ /* audio drivers expect pipe = -1 to indicate Non-MST cases */
if (intel_encoder->type != INTEL_OUTPUT_DP_MST) if (encoder->type != INTEL_OUTPUT_DP_MST)
pipe = -1; pipe = -1;
acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr, acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr,
(int) port, (int) pipe); (int) port, (int) pipe);
...@@ -629,36 +649,41 @@ void intel_audio_codec_enable(struct intel_encoder *intel_encoder, ...@@ -629,36 +649,41 @@ void intel_audio_codec_enable(struct intel_encoder *intel_encoder,
intel_lpe_audio_notify(dev_priv, pipe, port, connector->eld, intel_lpe_audio_notify(dev_priv, pipe, port, connector->eld,
crtc_state->port_clock, crtc_state->port_clock,
intel_encoder->type == INTEL_OUTPUT_DP); encoder->type == INTEL_OUTPUT_DP);
} }
/** /**
* intel_audio_codec_disable - Disable the audio codec for HD audio * intel_audio_codec_disable - Disable the audio codec for HD audio
* @intel_encoder: encoder on which to disable audio * @encoder: encoder on which to disable audio
* @crtc_state: pointer to the old crtc state.
* @conn_state: pointer to the old connector state.
* *
* The disable sequences must be performed before disabling the transcoder or * The disable sequences must be performed before disabling the transcoder or
* port. * port.
*/ */
void intel_audio_codec_disable(struct intel_encoder *intel_encoder) void intel_audio_codec_disable(struct intel_encoder *encoder,
const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state)
{ {
struct drm_encoder *encoder = &intel_encoder->base; struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
struct drm_i915_private *dev_priv = to_i915(encoder->dev);
struct i915_audio_component *acomp = dev_priv->audio_component; struct i915_audio_component *acomp = dev_priv->audio_component;
enum port port = intel_encoder->port; struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc);
struct intel_crtc *crtc = to_intel_crtc(encoder->crtc); enum port port = encoder->port;
enum pipe pipe = crtc->pipe; enum pipe pipe = crtc->pipe;
if (dev_priv->display.audio_codec_disable) if (dev_priv->display.audio_codec_disable)
dev_priv->display.audio_codec_disable(intel_encoder); dev_priv->display.audio_codec_disable(encoder,
old_crtc_state,
old_conn_state);
mutex_lock(&dev_priv->av_mutex); mutex_lock(&dev_priv->av_mutex);
intel_encoder->audio_connector = NULL; encoder->audio_connector = NULL;
dev_priv->av_enc_map[pipe] = NULL; dev_priv->av_enc_map[pipe] = NULL;
mutex_unlock(&dev_priv->av_mutex); mutex_unlock(&dev_priv->av_mutex);
if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify) { if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify) {
/* audio drivers expect pipe = -1 to indicate Non-MST cases */ /* audio drivers expect pipe = -1 to indicate Non-MST cases */
if (intel_encoder->type != INTEL_OUTPUT_DP_MST) if (encoder->type != INTEL_OUTPUT_DP_MST)
pipe = -1; pipe = -1;
acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr, acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr,
(int) port, (int) pipe); (int) port, (int) pipe);
...@@ -793,10 +818,9 @@ static int i915_audio_component_sync_audio_rate(struct device *kdev, int port, ...@@ -793,10 +818,9 @@ static int i915_audio_component_sync_audio_rate(struct device *kdev, int port,
int pipe, int rate) int pipe, int rate)
{ {
struct drm_i915_private *dev_priv = kdev_to_i915(kdev); struct drm_i915_private *dev_priv = kdev_to_i915(kdev);
struct intel_encoder *intel_encoder;
struct intel_crtc *crtc;
struct drm_display_mode *adjusted_mode;
struct i915_audio_component *acomp = dev_priv->audio_component; struct i915_audio_component *acomp = dev_priv->audio_component;
struct intel_encoder *encoder;
struct intel_crtc *crtc;
int err = 0; int err = 0;
if (!HAS_DDI(dev_priv)) if (!HAS_DDI(dev_priv))
...@@ -806,23 +830,19 @@ static int i915_audio_component_sync_audio_rate(struct device *kdev, int port, ...@@ -806,23 +830,19 @@ static int i915_audio_component_sync_audio_rate(struct device *kdev, int port,
mutex_lock(&dev_priv->av_mutex); mutex_lock(&dev_priv->av_mutex);
/* 1. get the pipe */ /* 1. get the pipe */
intel_encoder = get_saved_enc(dev_priv, port, pipe); encoder = get_saved_enc(dev_priv, port, pipe);
if (!intel_encoder || !intel_encoder->base.crtc) { if (!encoder || !encoder->base.crtc) {
DRM_DEBUG_KMS("Not valid for port %c\n", port_name(port)); DRM_DEBUG_KMS("Not valid for port %c\n", port_name(port));
err = -ENODEV; err = -ENODEV;
goto unlock; goto unlock;
} }
/* pipe passed from the audio driver will be -1 for Non-MST case */ crtc = to_intel_crtc(encoder->base.crtc);
crtc = to_intel_crtc(intel_encoder->base.crtc);
pipe = crtc->pipe;
adjusted_mode = &crtc->config->base.adjusted_mode;
/* port must be valid now, otherwise the pipe will be invalid */ /* port must be valid now, otherwise the pipe will be invalid */
acomp->aud_sample_rate[port] = rate; acomp->aud_sample_rate[port] = rate;
hsw_audio_config_update(crtc, port, adjusted_mode); hsw_audio_config_update(encoder, crtc->config);
unlock: unlock:
mutex_unlock(&dev_priv->av_mutex); mutex_unlock(&dev_priv->av_mutex);
......
...@@ -2425,7 +2425,8 @@ static void intel_disable_ddi_dp(struct intel_encoder *encoder, ...@@ -2425,7 +2425,8 @@ static void intel_disable_ddi_dp(struct intel_encoder *encoder,
struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
if (old_crtc_state->has_audio) if (old_crtc_state->has_audio)
intel_audio_codec_disable(encoder); intel_audio_codec_disable(encoder,
old_crtc_state, old_conn_state);
intel_edp_drrs_disable(intel_dp, old_crtc_state); intel_edp_drrs_disable(intel_dp, old_crtc_state);
intel_psr_disable(intel_dp, old_crtc_state); intel_psr_disable(intel_dp, old_crtc_state);
...@@ -2437,7 +2438,8 @@ static void intel_disable_ddi_hdmi(struct intel_encoder *encoder, ...@@ -2437,7 +2438,8 @@ static void intel_disable_ddi_hdmi(struct intel_encoder *encoder,
const struct drm_connector_state *old_conn_state) const struct drm_connector_state *old_conn_state)
{ {
if (old_crtc_state->has_audio) if (old_crtc_state->has_audio)
intel_audio_codec_disable(encoder); intel_audio_codec_disable(encoder,
old_crtc_state, old_conn_state);
intel_hdmi_handle_sink_scrambling(encoder, intel_hdmi_handle_sink_scrambling(encoder,
old_conn_state->connector, old_conn_state->connector,
......
...@@ -2708,7 +2708,8 @@ static void intel_disable_dp(struct intel_encoder *encoder, ...@@ -2708,7 +2708,8 @@ static void intel_disable_dp(struct intel_encoder *encoder,
struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
if (old_crtc_state->has_audio) if (old_crtc_state->has_audio)
intel_audio_codec_disable(encoder); intel_audio_codec_disable(encoder,
old_crtc_state, old_conn_state);
/* Make sure the panel is off before trying to change the mode. But also /* Make sure the panel is off before trying to change the mode. But also
* ensure that we have vdd while we switch off the panel. */ * ensure that we have vdd while we switch off the panel. */
......
...@@ -149,7 +149,8 @@ static void intel_mst_disable_dp(struct intel_encoder *encoder, ...@@ -149,7 +149,8 @@ static void intel_mst_disable_dp(struct intel_encoder *encoder,
DRM_ERROR("failed to update payload %d\n", ret); DRM_ERROR("failed to update payload %d\n", ret);
} }
if (old_crtc_state->has_audio) if (old_crtc_state->has_audio)
intel_audio_codec_disable(encoder); intel_audio_codec_disable(encoder,
old_crtc_state, old_conn_state);
} }
static void intel_mst_post_disable_dp(struct intel_encoder *encoder, static void intel_mst_post_disable_dp(struct intel_encoder *encoder,
......
...@@ -1311,7 +1311,9 @@ void intel_init_audio_hooks(struct drm_i915_private *dev_priv); ...@@ -1311,7 +1311,9 @@ void intel_init_audio_hooks(struct drm_i915_private *dev_priv);
void intel_audio_codec_enable(struct intel_encoder *encoder, void intel_audio_codec_enable(struct intel_encoder *encoder,
const struct intel_crtc_state *crtc_state, const struct intel_crtc_state *crtc_state,
const struct drm_connector_state *conn_state); const struct drm_connector_state *conn_state);
void intel_audio_codec_disable(struct intel_encoder *encoder); void intel_audio_codec_disable(struct intel_encoder *encoder,
const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state);
void i915_audio_component_init(struct drm_i915_private *dev_priv); void i915_audio_component_init(struct drm_i915_private *dev_priv);
void i915_audio_component_cleanup(struct drm_i915_private *dev_priv); void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
void intel_audio_init(struct drm_i915_private *dev_priv); void intel_audio_init(struct drm_i915_private *dev_priv);
......
...@@ -1206,7 +1206,8 @@ static void g4x_disable_hdmi(struct intel_encoder *encoder, ...@@ -1206,7 +1206,8 @@ static void g4x_disable_hdmi(struct intel_encoder *encoder,
const struct drm_connector_state *old_conn_state) const struct drm_connector_state *old_conn_state)
{ {
if (old_crtc_state->has_audio) if (old_crtc_state->has_audio)
intel_audio_codec_disable(encoder); intel_audio_codec_disable(encoder,
old_crtc_state, old_conn_state);
intel_disable_hdmi(encoder, old_crtc_state, old_conn_state); intel_disable_hdmi(encoder, old_crtc_state, old_conn_state);
} }
...@@ -1216,7 +1217,8 @@ static void pch_disable_hdmi(struct intel_encoder *encoder, ...@@ -1216,7 +1217,8 @@ static void pch_disable_hdmi(struct intel_encoder *encoder,
const struct drm_connector_state *old_conn_state) const struct drm_connector_state *old_conn_state)
{ {
if (old_crtc_state->has_audio) if (old_crtc_state->has_audio)
intel_audio_codec_disable(encoder); intel_audio_codec_disable(encoder,
old_crtc_state, old_conn_state);
} }
static void pch_post_disable_hdmi(struct intel_encoder *encoder, static void pch_post_disable_hdmi(struct intel_encoder *encoder,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment