Commit 336c1291 authored by Dan Murphy's avatar Dan Murphy Committed by Mark Brown

ASoC: tlv320adcx140: Add tx offset slot programming

Add the TX offset slot programming.  There is no RX offset slot
register.

Since there is no RX offset the check for slot symmetry can be removed.
Signed-off-by: default avatarDan Murphy <dmurphy@ti.com>
Link: https://lore.kernel.org/r/20200709185129.10505-2-dmurphy@ti.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 91cb940c
...@@ -646,6 +646,8 @@ static int adcx140_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -646,6 +646,8 @@ static int adcx140_set_dai_fmt(struct snd_soc_dai *codec_dai,
struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component); struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component);
u8 iface_reg1 = 0; u8 iface_reg1 = 0;
u8 iface_reg2 = 0; u8 iface_reg2 = 0;
int offset = 0;
int width = adcx140->slot_width;
/* set master/slave audio interface */ /* set master/slave audio interface */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
...@@ -688,7 +690,10 @@ static int adcx140_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -688,7 +690,10 @@ static int adcx140_set_dai_fmt(struct snd_soc_dai *codec_dai,
iface_reg1 |= ADCX140_LEFT_JUST_BIT; iface_reg1 |= ADCX140_LEFT_JUST_BIT;
break; break;
case SND_SOC_DAIFMT_DSP_A: case SND_SOC_DAIFMT_DSP_A:
offset += (adcx140->tdm_delay * width + 1);
break;
case SND_SOC_DAIFMT_DSP_B: case SND_SOC_DAIFMT_DSP_B:
offset += adcx140->tdm_delay * width;
break; break;
default: default:
dev_err(component->dev, "Invalid DAI interface format\n"); dev_err(component->dev, "Invalid DAI interface format\n");
...@@ -705,6 +710,11 @@ static int adcx140_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -705,6 +710,11 @@ static int adcx140_set_dai_fmt(struct snd_soc_dai *codec_dai,
snd_soc_component_update_bits(component, ADCX140_MST_CFG0, snd_soc_component_update_bits(component, ADCX140_MST_CFG0,
ADCX140_BCLK_FSYNC_MASTER, iface_reg2); ADCX140_BCLK_FSYNC_MASTER, iface_reg2);
/* Configure data offset */
snd_soc_component_update_bits(component, ADCX140_ASI_CFG1,
ADCX140_TX_OFFSET_MASK, offset);
return 0; return 0;
} }
...@@ -716,11 +726,6 @@ static int adcx140_set_dai_tdm_slot(struct snd_soc_dai *codec_dai, ...@@ -716,11 +726,6 @@ static int adcx140_set_dai_tdm_slot(struct snd_soc_dai *codec_dai,
struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component); struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component);
unsigned int lsb; unsigned int lsb;
if (tx_mask != rx_mask) {
dev_err(component->dev, "tx and rx masks must be symmetric\n");
return -EINVAL;
}
/* TDM based on DSP mode requires slots to be adjacent */ /* TDM based on DSP mode requires slots to be adjacent */
lsb = __ffs(tx_mask); lsb = __ffs(tx_mask);
if ((lsb + 1) != __fls(tx_mask)) { if ((lsb + 1) != __fls(tx_mask)) {
...@@ -745,34 +750,9 @@ static int adcx140_set_dai_tdm_slot(struct snd_soc_dai *codec_dai, ...@@ -745,34 +750,9 @@ static int adcx140_set_dai_tdm_slot(struct snd_soc_dai *codec_dai,
return 0; return 0;
} }
static int adcx140_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component);
int offset = 0;
int width = adcx140->slot_width;
if (!width)
width = substream->runtime->sample_bits;
/* TDM slot selection only valid in DSP_A/_B mode */
if (adcx140->dai_fmt == SND_SOC_DAIFMT_DSP_A)
offset += (adcx140->tdm_delay * width + 1);
else if (adcx140->dai_fmt == SND_SOC_DAIFMT_DSP_B)
offset += adcx140->tdm_delay * width;
/* Configure data offset */
snd_soc_component_update_bits(component, ADCX140_ASI_CFG1,
ADCX140_TX_OFFSET_MASK, offset);
return 0;
}
static const struct snd_soc_dai_ops adcx140_dai_ops = { static const struct snd_soc_dai_ops adcx140_dai_ops = {
.hw_params = adcx140_hw_params, .hw_params = adcx140_hw_params,
.set_fmt = adcx140_set_dai_fmt, .set_fmt = adcx140_set_dai_fmt,
.prepare = adcx140_prepare,
.set_tdm_slot = adcx140_set_dai_tdm_slot, .set_tdm_slot = adcx140_set_dai_tdm_slot,
}; };
......
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