drm/i2c: tda998x: store audio port enable in settings

Store the audio port enable register in the audio settings structure,
which can never be zero for a valid audio configuration.  Use this to
signal whether we have audio configured, rather than AFMT_UNUSED.

Tested-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
This commit is contained in:
Russell King 2019-03-01 19:12:28 +00:00
parent a03a915b83
commit 82642ab734

View File

@ -42,6 +42,7 @@ struct tda998x_audio_port {
struct tda998x_audio_settings { struct tda998x_audio_settings {
struct tda998x_audio_params params; struct tda998x_audio_params params;
u8 ena_ap;
u8 i2s_format; u8 i2s_format;
u8 cts_n; u8 cts_n;
}; };
@ -961,10 +962,14 @@ static int tda998x_configure_audio(struct tda998x_priv *priv,
u8 buf[6], clksel_aip, clksel_fs, adiv; u8 buf[6], clksel_aip, clksel_fs, adiv;
u32 n; u32 n;
/* If audio is not configured, there is nothing to do. */
if (settings->ena_ap == 0)
return 0;
adiv = tda998x_get_adiv(priv, settings->params.sample_rate); adiv = tda998x_get_adiv(priv, settings->params.sample_rate);
/* Enable audio ports */ /* Enable audio ports */
reg_write(priv, REG_ENA_AP, settings->params.config); reg_write(priv, REG_ENA_AP, settings->ena_ap);
/* Set audio input source */ /* Set audio input source */
switch (settings->params.format) { switch (settings->params.format) {
@ -1074,9 +1079,9 @@ static int tda998x_audio_hw_params(struct device *dev, void *data,
for (i = 0; i < ARRAY_SIZE(priv->audio_port); i++) for (i = 0; i < ARRAY_SIZE(priv->audio_port); i++)
if (priv->audio_port[i].format == audio.params.format) if (priv->audio_port[i].format == audio.params.format)
audio.params.config = priv->audio_port[i].config; audio.ena_ap = priv->audio_port[i].config;
if (audio.params.config == 0) { if (audio.ena_ap == 0) {
dev_err(dev, "%s: No audio configuration found\n", __func__); dev_err(dev, "%s: No audio configuration found\n", __func__);
return -EINVAL; return -EINVAL;
} }
@ -1116,8 +1121,7 @@ static void tda998x_audio_shutdown(struct device *dev, void *data)
mutex_lock(&priv->audio_mutex); mutex_lock(&priv->audio_mutex);
reg_write(priv, REG_ENA_AP, 0); reg_write(priv, REG_ENA_AP, 0);
priv->audio.ena_ap = 0;
priv->audio.params.format = AFMT_UNUSED;
mutex_unlock(&priv->audio_mutex); mutex_unlock(&priv->audio_mutex);
} }
@ -1623,8 +1627,7 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
tda998x_write_avi(priv, adjusted_mode); tda998x_write_avi(priv, adjusted_mode);
if (priv->audio.params.format != AFMT_UNUSED && if (priv->sink_has_audio)
priv->sink_has_audio)
tda998x_configure_audio(priv, &priv->audio); tda998x_configure_audio(priv, &priv->audio);
} }
@ -1705,6 +1708,7 @@ static int tda998x_set_config(struct tda998x_priv *priv,
bool spdif = p->audio_params.format == AFMT_SPDIF; bool spdif = p->audio_params.format == AFMT_SPDIF;
priv->audio.params = p->audio_params; priv->audio.params = p->audio_params;
priv->audio.ena_ap = p->audio_params.config;
priv->audio.i2s_format = I2S_FORMAT_PHILIPS; priv->audio.i2s_format = I2S_FORMAT_PHILIPS;
ratio = spdif ? 64 : p->audio_params.sample_width * 2; ratio = spdif ? 64 : p->audio_params.sample_width * 2;