Skip to content

Commit 244ac15

Browse files
Dan Murphybroonie
authored andcommitted
ASoC: tlv320adcx140: Fix BCLK inversion for DSP modes
Fix the BCLK inversion for DSP modes This is how it is defined by ASoC: * BCLK: * - "normal" polarity means signal is available at rising edge of BCLK * - "inverted" polarity means signal is available at falling edge of BCLK The adcx140 defines the BCLK edge based on coding type. The PCM (DSP_A/B) should drive on rising and sample on falling edge, so from ASoC pov, it is IB_NF. But from the codec pov if it is configured in DSP mode, then the BCLK should not be inverted, defaults to the coding standard. For i2s, it is NB_NF from ASoC pov (drive on falling, sample on rising). >From the codec's pov BCLK should not invert either, as this is the default for the coding. So, inversion must take the format into account: IB_NF + DSP_A/B == the codec bclk inversion should be disabled NB_NF + DSP_A/B == the codec bclk inversion should be enabled NB_NF + I2S == the codec bclk inversion should be disabled Signed-off-by: Dan Murphy <dmurphy@ti.com> Link: https://lore.kernel.org/r/20200915190606.1744-2-dmurphy@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent df16e22 commit 244ac15

1 file changed

Lines changed: 23 additions & 21 deletions

File tree

sound/soc/codecs/tlv320adcx140.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ static int adcx140_set_dai_fmt(struct snd_soc_dai *codec_dai,
673673
u8 iface_reg1 = 0;
674674
u8 iface_reg2 = 0;
675675
int offset = 0;
676-
int width = adcx140->slot_width;
676+
bool inverted_bclk = false;
677677

678678
/* set master/slave audio interface */
679679
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -689,24 +689,6 @@ static int adcx140_set_dai_fmt(struct snd_soc_dai *codec_dai,
689689
return -EINVAL;
690690
}
691691

692-
/* signal polarity */
693-
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
694-
case SND_SOC_DAIFMT_NB_IF:
695-
iface_reg1 |= ADCX140_FSYNCINV_BIT;
696-
break;
697-
case SND_SOC_DAIFMT_IB_IF:
698-
iface_reg1 |= ADCX140_BCLKINV_BIT | ADCX140_FSYNCINV_BIT;
699-
break;
700-
case SND_SOC_DAIFMT_IB_NF:
701-
iface_reg1 |= ADCX140_BCLKINV_BIT;
702-
break;
703-
case SND_SOC_DAIFMT_NB_NF:
704-
break;
705-
default:
706-
dev_err(component->dev, "Invalid DAI clock signal polarity\n");
707-
return -EINVAL;
708-
}
709-
710692
/* interface format */
711693
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
712694
case SND_SOC_DAIFMT_I2S:
@@ -716,16 +698,36 @@ static int adcx140_set_dai_fmt(struct snd_soc_dai *codec_dai,
716698
iface_reg1 |= ADCX140_LEFT_JUST_BIT;
717699
break;
718700
case SND_SOC_DAIFMT_DSP_A:
719-
offset += (adcx140->tdm_delay * width + 1);
701+
offset = 1;
702+
inverted_bclk = true;
720703
break;
721704
case SND_SOC_DAIFMT_DSP_B:
722-
offset += adcx140->tdm_delay * width;
705+
inverted_bclk = true;
723706
break;
724707
default:
725708
dev_err(component->dev, "Invalid DAI interface format\n");
726709
return -EINVAL;
727710
}
728711

712+
/* signal polarity */
713+
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
714+
case SND_SOC_DAIFMT_IB_NF:
715+
case SND_SOC_DAIFMT_IB_IF:
716+
inverted_bclk = !inverted_bclk;
717+
break;
718+
case SND_SOC_DAIFMT_NB_IF:
719+
iface_reg1 |= ADCX140_FSYNCINV_BIT;
720+
break;
721+
case SND_SOC_DAIFMT_NB_NF:
722+
break;
723+
default:
724+
dev_err(component->dev, "Invalid DAI clock signal polarity\n");
725+
return -EINVAL;
726+
}
727+
728+
if (inverted_bclk)
729+
iface_reg1 |= ADCX140_BCLKINV_BIT;
730+
729731
adcx140->dai_fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
730732

731733
adcx140_pwr_ctrl(adcx140, false);

0 commit comments

Comments
 (0)