ASoC: omap-mcbsp: Prepare for init time DAI format setting
PATCH 1/3 ASoC: omap-mcbsp: Prepare for init time DAI format setting
Before commit 75d9ac4 ("ASoC: Allow DAI formats to be specified in the dai_link") expectation for omap-mcbsp was that snd_soc_dai_set_fmt is to be called first in machine hw_params callback before other CPU DAI functions. Thus it was enough that only omap_mcbsp_dai_set_dai_fmt cleared the mcbsp->regs structure.
Now this doesn't hold anymore since machine drivers can set the DAI format only once on init time and thus mcbsp->regs may get out of sync when other CPU DAI functions are modifying them dynamically with different values between the calls. Therefore clear the accessed mcbsp->regs bits and bitfields in other functions too.
--- sound/soc/omap/omap-mcbsp.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
sound/soc/omap/omap-mcbsp.c +9 -0
@@ -317,6 +317,10 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,return 0 ; } + regs->rcr2 &= ~(RPHASE |RFRLEN2 (0x7f ) |RWDLEN2 (7 )); + regs->xcr2 &= ~(RPHASE |XFRLEN2 (0x7f ) |XWDLEN2 (7 )); + regs->rcr1 &= ~(RFRLEN1 (0x7f ) |RWDLEN1 (7 )); + regs->xcr1 &= ~(XFRLEN1 (0x7f ) |XWDLEN1 (7 )); format = mcbsp_data->fmt &SND_SOC_DAIFMT_FORMAT_MASK ; wpf = channels =params_channels (params); if (channels == 2 && (format == SND_SOC_DAIFMT_I2S ||
@@ -369,6 +373,8 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, framesize = wlen * channels;/* Set FS period and length in terms of bit clock periods */ + regs->srgr2 &= ~FPER (0xfff ); + regs->srgr1 &= ~FWID (0xff );switch (format) {case SND_SOC_DAIFMT_I2S :case SND_SOC_DAIFMT_LEFT_J :
@@ -505,6 +511,7 @@ static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai,return -ENODEV ; mcbsp_data->clk_div = div; + regs->srgr1 &= ~CLKGDV (0xff ); regs->srgr1 |=CLKGDV (div -1 );return 0 ;
@@ -534,6 +541,8 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,return -EINVAL ; mcbsp_data->in_freq = freq; + regs->srgr2 &= ~CLKSM ; + regs->pcr0 &= ~SCLKME ;switch (clk_id) {case OMAP_MCBSP_SYSCLK_CLK :
Signature · 1 line
1.7.6.3
PATCH 2/3 ASoC: omap: Convert bunch of machine drivers to use init time DAI format
---omap3beagle.c and ams-delta.c are left out as thet use either dynamic DAI format or configure just the CPU DAI.
--- sound/soc/omap/am3517evm.c | 22 +----------------- sound/soc/omap/igep0020.c | 23 +------------------ sound/soc/omap/n810.c | 19 +--------------- sound/soc/omap/omap3evm.c | 23 +------------------ sound/soc/omap/omap3pandora.c | 20 +++-------------- sound/soc/omap/osk5912.c | 23 +------------------ sound/soc/omap/overo.c | 23 +------------------ sound/soc/omap/rx51.c | 20 +---------------- sound/soc/omap/sdp3430.c | 46 +++------------------------------------- sound/soc/omap/zoom2.c | 46 +++------------------------------------- 10 files changed, 26 insertions(+), 239 deletions(-)
sound/soc/omap/am3517evm.c +2 -20
@@ -43,26 +43,6 @@ static int am3517evm_hw_params(struct snd_pcm_substream *substream,struct snd_soc_dai *cpu_dai = rtd->cpu_dai;int ret; -/* Set codec DAI configuration */ - ret =snd_soc_dai_set_fmt (codec_dai, -SND_SOC_DAIFMT_DSP_B | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (ret <0 ) { -printk (KERN_ERR "can't set codec DAI configuration\n" ); -return ret; - } - -/* Set cpu DAI configuration */ - ret =snd_soc_dai_set_fmt (cpu_dai, -SND_SOC_DAIFMT_DSP_B | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (ret <0 ) { -printk (KERN_ERR "can't set cpu DAI configuration\n" ); -return ret; - } -/* Set the codec system clock for DAC and ADC */ ret =snd_soc_dai_set_sysclk (codec_dai,0 ,CODEC_CLOCK ,SND_SOC_CLOCK_IN );
@@ -140,6 +120,8 @@ static struct snd_soc_dai_link am3517evm_dai = { .codec_dai_name = "tlv320aic23-hifi", .platform_name = "omap-pcm-audio", .codec_name = "tlv320aic23-codec.2-001a", + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .init = am3517evm_aic23_init, .ops = &am3517evm_ops, };
sound/soc/omap/igep0020.c +2 -21
@@ -38,29 +38,8 @@ static int igep2_hw_params(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *codec_dai = rtd->codec_dai; -struct snd_soc_dai *cpu_dai = rtd->cpu_dai;int ret; -/* Set codec DAI configuration */ - ret =snd_soc_dai_set_fmt (codec_dai, -SND_SOC_DAIFMT_I2S | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (ret <0 ) { -printk (KERN_ERR "can't set codec DAI configuration\n" ); -return ret; - } - -/* Set cpu DAI configuration */ - ret =snd_soc_dai_set_fmt (cpu_dai, -SND_SOC_DAIFMT_I2S | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (ret <0 ) { -printk (KERN_ERR "can't set cpu DAI configuration\n" ); -return ret; - } -/* Set the codec system clock for DAC and ADC */ ret =snd_soc_dai_set_sysclk (codec_dai,0 ,26000000 ,SND_SOC_CLOCK_IN );
@@ -84,6 +63,8 @@ static struct snd_soc_dai_link igep2_dai = { .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .ops = &igep2_ops, };
sound/soc/omap/n810.c +2 -17
@@ -115,25 +115,8 @@ static int n810_hw_params(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *codec_dai = rtd->codec_dai; -struct snd_soc_dai *cpu_dai = rtd->cpu_dai;int err; -/* Set codec DAI configuration */ - err =snd_soc_dai_set_fmt (codec_dai, -SND_SOC_DAIFMT_I2S | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (err <0 ) -return err; - -/* Set cpu DAI configuration */ - err =snd_soc_dai_set_fmt (cpu_dai, -SND_SOC_DAIFMT_I2S | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (err <0 ) -return err; -/* Set the codec system clock for DAC and ADC */ err =snd_soc_dai_set_sysclk (codec_dai,0 ,12000000 ,SND_SOC_CLOCK_IN );
@@ -312,6 +295,8 @@ static struct snd_soc_dai_link n810_dai = { .platform_name = "omap-pcm-audio", .codec_name = "tlv320aic3x-codec.2-0018", .codec_dai_name = "tlv320aic3x-hifi", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .init = n810_aic33_init, .ops = &n810_ops, };
sound/soc/omap/omap3evm.c +2 -21
@@ -36,29 +36,8 @@ static int omap3evm_hw_params(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *codec_dai = rtd->codec_dai; -struct snd_soc_dai *cpu_dai = rtd->cpu_dai;int ret; -/* Set codec DAI configuration */ - ret =snd_soc_dai_set_fmt (codec_dai, -SND_SOC_DAIFMT_I2S | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (ret <0 ) { -printk (KERN_ERR "Can't set codec DAI configuration\n" ); -return ret; - } - -/* Set cpu DAI configuration */ - ret =snd_soc_dai_set_fmt (cpu_dai, -SND_SOC_DAIFMT_I2S | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (ret <0 ) { -printk (KERN_ERR "Can't set cpu DAI configuration\n" ); -return ret; - } -/* Set the codec system clock for DAC and ADC */ ret =snd_soc_dai_set_sysclk (codec_dai,0 ,26000000 ,SND_SOC_CLOCK_IN );
@@ -82,6 +61,8 @@ static struct snd_soc_dai_link omap3evm_dai = { .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .ops = &omap3evm_ops, };
sound/soc/omap/omap3pandora.c +4 -16
@@ -48,24 +48,8 @@ static int omap3pandora_hw_params(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *codec_dai = rtd->codec_dai;struct snd_soc_dai *cpu_dai = rtd->cpu_dai; -int fmt =SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBS_CFS ;int ret; -/* Set codec DAI configuration */ - ret =snd_soc_dai_set_fmt (codec_dai, fmt); -if (ret <0 ) { -pr_err (PREFIX "can't set codec DAI configuration\n" ); -return ret; - } - -/* Set cpu DAI configuration */ - ret =snd_soc_dai_set_fmt (cpu_dai, fmt); -if (ret <0 ) { -pr_err (PREFIX "can't set cpu DAI configuration\n" ); -return ret; - } -/* Set the codec system clock for DAC and ADC */ ret =snd_soc_dai_set_sysclk (codec_dai,0 ,26000000 ,SND_SOC_CLOCK_IN );
@@ -231,6 +215,8 @@ static struct snd_soc_dai_link omap3pandora_dai[] = { .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", + .dai_fmt =SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &omap3pandora_ops, .init = omap3pandora_out_init, }, {
@@ -240,6 +226,8 @@ static struct snd_soc_dai_link omap3pandora_dai[] = { .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &omap3pandora_ops, .init = omap3pandora_in_init, }
sound/soc/omap/osk5912.c +2 -21
@@ -55,29 +55,8 @@ static int osk_hw_params(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *codec_dai = rtd->codec_dai; -struct snd_soc_dai *cpu_dai = rtd->cpu_dai;int err; -/* Set codec DAI configuration */ - err =snd_soc_dai_set_fmt (codec_dai, -SND_SOC_DAIFMT_DSP_B | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (err <0 ) { -printk (KERN_ERR "can't set codec DAI configuration\n" ); -return err; - } - -/* Set cpu DAI configuration */ - err =snd_soc_dai_set_fmt (cpu_dai, -SND_SOC_DAIFMT_DSP_B | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (err <0 ) { -printk (KERN_ERR "can't set cpu DAI configuration\n" ); -return err; - } -/* Set the codec system clock for DAC and ADC */ err =snd_soc_dai_set_sysclk (codec_dai,0 ,CODEC_CLOCK ,SND_SOC_CLOCK_IN );
@@ -141,6 +120,8 @@ static struct snd_soc_dai_link osk_dai = { .codec_dai_name = "tlv320aic23-hifi", .platform_name = "omap-pcm-audio", .codec_name = "tlv320aic23-codec", + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .init = osk_tlv320aic23_init, .ops = &osk_ops, };
sound/soc/omap/overo.c +2 -21
@@ -38,29 +38,8 @@ static int overo_hw_params(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *codec_dai = rtd->codec_dai; -struct snd_soc_dai *cpu_dai = rtd->cpu_dai;int ret; -/* Set codec DAI configuration */ - ret =snd_soc_dai_set_fmt (codec_dai, -SND_SOC_DAIFMT_I2S | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (ret <0 ) { -printk (KERN_ERR "can't set codec DAI configuration\n" ); -return ret; - } - -/* Set cpu DAI configuration */ - ret =snd_soc_dai_set_fmt (cpu_dai, -SND_SOC_DAIFMT_I2S | -SND_SOC_DAIFMT_NB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (ret <0 ) { -printk (KERN_ERR "can't set cpu DAI configuration\n" ); -return ret; - } -/* Set the codec system clock for DAC and ADC */ ret =snd_soc_dai_set_sysclk (codec_dai,0 ,26000000 ,SND_SOC_CLOCK_IN );
@@ -84,6 +63,8 @@ static struct snd_soc_dai_link overo_dai = { .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .ops = &overo_ops, };
sound/soc/omap/rx51.c +2 -18
@@ -115,24 +115,6 @@ static int rx51_hw_params(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *codec_dai = rtd->codec_dai; -struct snd_soc_dai *cpu_dai = rtd->cpu_dai; -int err; - -/* Set codec DAI configuration */ - err =snd_soc_dai_set_fmt (codec_dai, -SND_SOC_DAIFMT_DSP_A | -SND_SOC_DAIFMT_IB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (err <0 ) -return err; - -/* Set cpu DAI configuration */ - err =snd_soc_dai_set_fmt (cpu_dai, -SND_SOC_DAIFMT_DSP_A | -SND_SOC_DAIFMT_IB_NF | -SND_SOC_DAIFMT_CBM_CFM ); -if (err <0 ) -return err;/* Set the codec system clock for DAC and ADC */ return snd_soc_dai_set_sysclk(codec_dai, 0, 19200000,
@@ -377,6 +359,8 @@ static struct snd_soc_dai_link rx51_dai[] = { .codec_dai_name = "tlv320aic3x-hifi", .platform_name = "omap-pcm-audio", .codec_name = "tlv320aic3x-codec.2-0018", + .dai_fmt =SND_SOC_DAIFMT_DSP_A |SND_SOC_DAIFMT_IB_NF | + SND_SOC_DAIFMT_CBM_CFM, .init = rx51_aic34_init, .ops = &rx51_ops, },
sound/soc/omap/sdp3430.c +4 -42
74 lines not on this page · raw message
sound/soc/omap/zoom2.c +4 -42
74 lines not on this page · raw message
Signature · 1 line
1.7.6.3
PATCH 3/3 ASoC: omap: Use single hw_params callback in sdp3430 and zoom2
In reply to Jarkko NikulaThere is no need to use two hw_params callbacks in sdp3430 and zoom2 as thet are now identical. Use instead the same snd_soc_ops structure and hw_params callback for both DAI links.
--- sound/soc/omap/sdp3430.c | 24 +----------------------- sound/soc/omap/zoom2.c | 24 +----------------------- 2 files changed, 2 insertions(+), 46 deletions(-)
sound/soc/omap/sdp3430.c +1 -23
@@ -70,28 +70,6 @@ static struct snd_soc_ops sdp3430_ops = { .hw_params = sdp3430_hw_params, }; -static int sdp3430_hw_voice_params (struct snd_pcm_substream *substream, -struct snd_pcm_hw_params *params) -{ -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct snd_soc_dai *codec_dai = rtd->codec_dai; -int ret; - -/* Set the codec system clock for DAC and ADC */ - ret =snd_soc_dai_set_sysclk (codec_dai,0 ,26000000 , -SND_SOC_CLOCK_IN ); -if (ret <0 ) { -printk (KERN_ERR "can't set codec system clock\n" ); -return ret; - } - -return 0 ; -} - -static struct snd_soc_ops sdp3430_voice_ops = { - .hw_params = sdp3430_hw_voice_params, -}; -/* Headset jack */ static struct snd_soc_jack hs_jack;
@@ -240,7 +218,7 @@ static struct snd_soc_dai_link sdp3430_dai[] = { .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBM_CFM, .init = sdp3430_twl4030_voice_init, - .ops = &sdp3430_voice_ops, + .ops = &sdp3430_ops, }, };
sound/soc/omap/zoom2.c +1 -23
@@ -61,28 +61,6 @@ static struct snd_soc_ops zoom2_ops = { .hw_params = zoom2_hw_params, }; -static int zoom2_hw_voice_params (struct snd_pcm_substream *substream, -struct snd_pcm_hw_params *params) -{ -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct snd_soc_dai *codec_dai = rtd->codec_dai; -int ret; - -/* Set the codec system clock for DAC and ADC */ - ret =snd_soc_dai_set_sysclk (codec_dai,0 ,26000000 , -SND_SOC_CLOCK_IN ); -if (ret <0 ) { -printk (KERN_ERR "can't set codec system clock\n" ); -return ret; - } - -return 0 ; -} - -static struct snd_soc_ops zoom2_voice_ops = { - .hw_params = zoom2_hw_voice_params, -}; -/* Zoom2 machine DAPM */ static const struct snd_soc_dapm_widget zoom2_twl4030_dapm_widgets[] = {SND_SOC_DAPM_MIC ("Ext Mic" ,NULL ),
@@ -190,7 +168,7 @@ static struct snd_soc_dai_link zoom2_dai[] = { .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBM_CFM, .init = zoom2_twl4030_voice_init, - .ops = &zoom2_voice_ops, + .ops = &zoom2_ops, }, };
Signature · 1 line
1.7.6.3
Quoted 8 lines · Jarkko Nikula
Before commit 75d9ac4 ("ASoC: Allow DAI formats to be specified in the
dai_link") expectation for omap-mcbsp was thatsnd_soc_dai_set_fmtis to be called first in machinehw_paramscallback before other CPU DAI functions. Thus it was enough that onlyomap_mcbsp_dai_set_dai_fmtcleared themcbsp->regsstructure.Now this doesn't hold anymore since machine drivers can set the DAI format only once on init time and thus
mcbsp->regsmay get out of sync when other
Note that it's only been convention that stopped this happening in the past, there's never been anything stopping drivers doing this in the link init function.
Quoted 5 lines · Jarkko Nikula
Before commit 75d9ac4 ("ASoC: Allow DAI formats to be specified in the
dai_link") expectation for omap-mcbsp was thatsnd_soc_dai_set_fmtis to be called first in machinehw_paramscallback before other CPU DAI functions. Thus it was enough that onlyomap_mcbsp_dai_set_dai_fmtcleared themcbsp->regsstructure.
Applied all with a note here about the fact that this was always a limitation in the OMAP drivers.