ASoC: tlv320aic31xx: Optimize the master mode I2S clock handling
Subsystems (3)
cover ASoC: tlv320aic31xx: Optimize the master mode I2S clock handling
Hi,
Instead of forcing DAC/ADC to be turned on, we can use P0 R29, Bit2 to let the I2S clocks running, but we do not want it to run all the time and we do not want I2S clocks when it is not needed (analog loopback mode).
Use DAPM_SUPPLY for the bit and connect it to the in/out AIF.
The DAPM routes can be modify to not include the DAC/ADC.
Regards,
Peter
---
Peter Ujfalusi (2):
ASoC: tlv320aic31xx: Rename AIF_IN from 'DAC IN' to 'AIF IN'
ASoC: tlv320aic31xx: Do not force power on the DAC/ADC in clock master
mode
sound/soc/codecs/tlv320aic31xx.c | 46 +++++++++++++++++++++++++--------------- sound/soc/codecs/tlv320aic31xx.h | 1 + 2 files changed, 30 insertions(+), 17 deletions(-)
Signature · 4 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 1/2 ASoC: tlv320aic31xx: Rename AIF_IN from 'DAC IN' to 'AIF IN'
The audio interface is not really the DAC input. Use more generic name for it.
--- sound/soc/codecs/tlv320aic31xx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
sound/soc/codecs/tlv320aic31xx.c +9 -9
@@ -468,7 +468,7 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w, }static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = { -SND_SOC_DAPM_AIF_IN ("DAC IN" ,"DAC Playback" ,0 ,SND_SOC_NOPM ,0 ,0 ), +SND_SOC_DAPM_AIF_IN ("AIF IN" ,"Playback" ,0 ,SND_SOC_NOPM ,0 ,0 ),SND_SOC_DAPM_MUX ("DAC Left Input" ,SND_SOC_NOPM ,0 ,0 , &ldac_in_control),
@@ -584,12 +584,12 @@ static const struct snd_soc_dapm_widget aic310x_dapm_widgets[] = {static const struct snd_soc_dapm_route common31xx_audio_map[] = {/* DAC Input Routing */ - {"DAC Left Input" ,"Left Data" ,"DAC IN" }, - {"DAC Left Input" ,"Right Data" ,"DAC IN" }, - {"DAC Left Input" ,"Mono" ,"DAC IN" }, - {"DAC Right Input" ,"Left Data" ,"DAC IN" }, - {"DAC Right Input" ,"Right Data" ,"DAC IN" }, - {"DAC Right Input" ,"Mono" ,"DAC IN" }, + {"DAC Left Input" ,"Left Data" ,"AIF IN" }, + {"DAC Left Input" ,"Right Data" ,"AIF IN" }, + {"DAC Left Input" ,"Mono" ,"AIF IN" }, + {"DAC Right Input" ,"Left Data" ,"AIF IN" }, + {"DAC Right Input" ,"Right Data" ,"AIF IN" }, + {"DAC Right Input" ,"Mono" ,"AIF IN" }, {"DAC Left" ,NULL ,"DAC Left Input" }, {"DAC Right" ,NULL ,"DAC Right Input" },
@@ -679,8 +679,8 @@ aic310x_audio_map[] = {*/ static const struct snd_soc_dapm_route common31xx_cm_audio_map[] = { - {"DAC Left Input" ,"Off" ,"DAC IN" }, - {"DAC Right Input" ,"Off" ,"DAC IN" }, + {"DAC Left Input" ,"Off" ,"AIF IN" }, + {"DAC Right Input" ,"Off" ,"AIF IN" }, {"HPL" ,NULL ,"DAC Left" }, {"HPR" ,NULL ,"DAC Right" },
Signature · 4 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Mark Brown
maintainerApplied "ASoC: tlv320aic31xx: Rename AIF_IN from 'DAC IN' to 'AIF IN'" to the asoc tree
The patch
ASoC: tlv320aic31xx: Rename AIF_IN from 'DAC IN' to 'AIF IN'
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
7d41bc28e9fa3fed28691019ca0fe36ed68d7b86Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <[email protected]>
Date: Mon, 19 Feb 2018 11:45:07 +0200
Subject: [PATCH] ASoC: tlv320aic31xx: Rename AIF_IN from 'DAC IN' to 'AIF IN'
The audio interface is not really the DAC input. Use more generic name for it.
--- sound/soc/codecs/tlv320aic31xx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
sound/soc/codecs/tlv320aic31xx.c +9 -9
@@ -468,7 +468,7 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w, }static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = { -SND_SOC_DAPM_AIF_IN ("DAC IN" ,"DAC Playback" ,0 ,SND_SOC_NOPM ,0 ,0 ), +SND_SOC_DAPM_AIF_IN ("AIF IN" ,"Playback" ,0 ,SND_SOC_NOPM ,0 ,0 ),SND_SOC_DAPM_MUX ("DAC Left Input" ,SND_SOC_NOPM ,0 ,0 , &ldac_in_control),
@@ -584,12 +584,12 @@ static const struct snd_soc_dapm_widget aic310x_dapm_widgets[] = {static const struct snd_soc_dapm_route common31xx_audio_map[] = {/* DAC Input Routing */ - {"DAC Left Input" ,"Left Data" ,"DAC IN" }, - {"DAC Left Input" ,"Right Data" ,"DAC IN" }, - {"DAC Left Input" ,"Mono" ,"DAC IN" }, - {"DAC Right Input" ,"Left Data" ,"DAC IN" }, - {"DAC Right Input" ,"Right Data" ,"DAC IN" }, - {"DAC Right Input" ,"Mono" ,"DAC IN" }, + {"DAC Left Input" ,"Left Data" ,"AIF IN" }, + {"DAC Left Input" ,"Right Data" ,"AIF IN" }, + {"DAC Left Input" ,"Mono" ,"AIF IN" }, + {"DAC Right Input" ,"Left Data" ,"AIF IN" }, + {"DAC Right Input" ,"Right Data" ,"AIF IN" }, + {"DAC Right Input" ,"Mono" ,"AIF IN" }, {"DAC Left" ,NULL ,"DAC Left Input" }, {"DAC Right" ,NULL ,"DAC Right Input" },
@@ -679,8 +679,8 @@ aic310x_audio_map[] = {*/ static const struct snd_soc_dapm_route common31xx_cm_audio_map[] = { - {"DAC Left Input" ,"Off" ,"DAC IN" }, - {"DAC Right Input" ,"Off" ,"DAC IN" }, + {"DAC Left Input" ,"Off" ,"AIF IN" }, + {"DAC Right Input" ,"Off" ,"AIF IN" }, {"HPL" ,NULL ,"DAC Left" }, {"HPR" ,NULL ,"DAC Right" },
Signature · 1 line
2.16.1
PATCH 2/2 ASoC: tlv320aic31xx: Do not force power on the DAC/ADC in clock master mode
In reply to Peter UjfalusiWith P0 R29, Bit2 set the I2S clocks will be running when the DAC/ADC is powered down, but still the codec need to be powered up by needing at least one complete DAPM path for the stream.
If the AIF is not needed (analog loopback for example) the I2S clocks will not run as they are not needed.
--- sound/soc/codecs/tlv320aic31xx.c | 32 ++++++++++++++++++++++---------- sound/soc/codecs/tlv320aic31xx.h | 1 + 2 files changed, 23 insertions(+), 10 deletions(-)
sound/soc/codecs/tlv320aic31xx.c +22 -10
@@ -501,6 +501,10 @@ static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("MICBIAS" ,SND_SOC_NOPM ,0 ,0 , mic_bias_event,SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD ), +/* Keep BCLK/WCLK enabled even if DAC/ADC is powered down */ +SND_SOC_DAPM_SUPPLY ("Activate I2S clocks" ,AIC31XX_IFACE2 ,2 ,0 , +NULL ,0 ), +/* Outputs */ SND_SOC_DAPM_OUTPUT ("HPL" ), SND_SOC_DAPM_OUTPUT("HPR"),
@@ -553,6 +557,8 @@ static const struct snd_soc_dapm_widget aic31xx_dapm_widgets[] = {SND_SOC_DAPM_MIXER ("Output Right" ,SND_SOC_NOPM ,0 ,0 , aic31xx_right_output_switches,ARRAY_SIZE (aic31xx_right_output_switches)), + + SND_SOC_DAPM_AIF_OUT("AIF OUT", "Capture", 0, SND_SOC_NOPM, 0, 0), }; static const struct snd_soc_dapm_widget aic311x_dapm_widgets[] = {
@@ -640,6 +646,8 @@ aic31xx_audio_map[] = { {"ADC", NULL, "MIC_GAIN_CTL"}, + {"AIF OUT", NULL, "ADC"}, +/* Left Output */ {"Output Left", "From Left DAC", "DAC Left"}, {"Output Left", "From MIC1LP", "MIC1LP"},
@@ -673,25 +681,29 @@ aic310x_audio_map[] = {/* * Always connected DAPM routes for codec clock master modes. -* If the codec is the master on the I2S bus, we need to power on components -* to have valid DAC_CLK and also the DACs and ADC for playback/capture. +* If the codec is the master on the I2S bus, we need to power up components +* to have valid DAC_CLK. +* +* In order to have the I2S clocks on the bus either the DACs/ADC need to be +* enabled, or the P0/R29/D2 (Keep bclk/wclk in power down) need to be set. +* * Otherwise the codec will not generate clocks on the bus. */ static const struct snd_soc_dapm_route common31xx_cm_audio_map[] = { - {"DAC Left Input" ,"Off" ,"AIF IN" }, - {"DAC Right Input" ,"Off" ,"AIF IN" }, + {"HPL" ,NULL ,"AIF IN" }, + {"HPR" ,NULL ,"AIF IN" }, - {"HPL" ,NULL ,"DAC Left" }, - {"HPR" ,NULL ,"DAC Right" }, + {"AIF IN" ,NULL ,"Activate I2S clocks" }, };static const struct snd_soc_dapm_route aic31xx_cm_audio_map[] = { - {"MIC1LP P-Terminal" ,"Off" ,"MIC1LP" }, - {"MIC1RP P-Terminal" ,"Off" ,"MIC1RP" }, - {"MIC1LM P-Terminal" ,"Off" ,"MIC1LM" }, - {"MIC1LM M-Terminal" ,"Off" ,"MIC1LM" }, + {"AIF OUT" ,NULL ,"MIC1LP" }, + {"AIF OUT" ,NULL ,"MIC1RP" }, + {"AIF OUT" ,NULL ,"MIC1LM" }, + + {"AIF OUT" ,NULL ,"Activate I2S clocks" }, };static int aic31xx_add_controls (struct snd_soc_component *component)
sound/soc/codecs/tlv320aic31xx.h +1 -0
@@ -160,6 +160,7 @@ struct aic31xx_pdata {#define AIC31XX_DACMOD2BCLK 0x01#define AIC31XX_ADC2BCLK 0x02#define AIC31XX_ADCMOD2BCLK 0x03 +#define AIC31XX_KEEP_I2SCLK BIT(2)/* AIC31XX_ADCFLAG */ #define AIC31XX_ADCPWRSTATUS_MASK BIT(6)
Signature · 9 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
maintainerApplied "ASoC: tlv320aic31xx: Do not force power on the DAC/ADC in clock master mode" to the asoc tree
The patch
ASoC: tlv320aic31xx: Do not force power on the DAC/ADC in clock master mode
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
a16be2a6e2ffa8ad5e24e96289f317e1b5b8c17aMon Sep 17 00:00:00 2001
From: Peter Ujfalusi <[email protected]>
Date: Mon, 19 Feb 2018 11:45:08 +0200
Subject: [PATCH] ASoC: tlv320aic31xx: Do not force power on the DAC/ADC in
clock master mode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
With P0 R29, Bit2 set the I2S clocks will be running when the DAC/ADC is powered down, but still the codec need to be powered up by needing at least one complete DAPM path for the stream.
If the AIF is not needed (analog loopback for example) the I2S clocks will not run as they are not needed.
--- sound/soc/codecs/tlv320aic31xx.c | 32 ++++++++++++++++++++++---------- sound/soc/codecs/tlv320aic31xx.h | 1 + 2 files changed, 23 insertions(+), 10 deletions(-)
sound/soc/codecs/tlv320aic31xx.c +22 -10
@@ -501,6 +501,10 @@ static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("MICBIAS" ,SND_SOC_NOPM ,0 ,0 , mic_bias_event,SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD ), +/* Keep BCLK/WCLK enabled even if DAC/ADC is powered down */ +SND_SOC_DAPM_SUPPLY ("Activate I2S clocks" ,AIC31XX_IFACE2 ,2 ,0 , +NULL ,0 ), +/* Outputs */ SND_SOC_DAPM_OUTPUT ("HPL" ), SND_SOC_DAPM_OUTPUT("HPR"),
@@ -553,6 +557,8 @@ static const struct snd_soc_dapm_widget aic31xx_dapm_widgets[] = {SND_SOC_DAPM_MIXER ("Output Right" ,SND_SOC_NOPM ,0 ,0 , aic31xx_right_output_switches,ARRAY_SIZE (aic31xx_right_output_switches)), + + SND_SOC_DAPM_AIF_OUT("AIF OUT", "Capture", 0, SND_SOC_NOPM, 0, 0), }; static const struct snd_soc_dapm_widget aic311x_dapm_widgets[] = {
@@ -640,6 +646,8 @@ aic31xx_audio_map[] = { {"ADC", NULL, "MIC_GAIN_CTL"}, + {"AIF OUT", NULL, "ADC"}, +/* Left Output */ {"Output Left", "From Left DAC", "DAC Left"}, {"Output Left", "From MIC1LP", "MIC1LP"},
@@ -673,25 +681,29 @@ aic310x_audio_map[] = {/* * Always connected DAPM routes for codec clock master modes. -* If the codec is the master on the I2S bus, we need to power on components -* to have valid DAC_CLK and also the DACs and ADC for playback/capture. +* If the codec is the master on the I2S bus, we need to power up components +* to have valid DAC_CLK. +* +* In order to have the I2S clocks on the bus either the DACs/ADC need to be +* enabled, or the P0/R29/D2 (Keep bclk/wclk in power down) need to be set. +* * Otherwise the codec will not generate clocks on the bus. */ static const struct snd_soc_dapm_route common31xx_cm_audio_map[] = { - {"DAC Left Input" ,"Off" ,"AIF IN" }, - {"DAC Right Input" ,"Off" ,"AIF IN" }, + {"HPL" ,NULL ,"AIF IN" }, + {"HPR" ,NULL ,"AIF IN" }, - {"HPL" ,NULL ,"DAC Left" }, - {"HPR" ,NULL ,"DAC Right" }, + {"AIF IN" ,NULL ,"Activate I2S clocks" }, };static const struct snd_soc_dapm_route aic31xx_cm_audio_map[] = { - {"MIC1LP P-Terminal" ,"Off" ,"MIC1LP" }, - {"MIC1RP P-Terminal" ,"Off" ,"MIC1RP" }, - {"MIC1LM P-Terminal" ,"Off" ,"MIC1LM" }, - {"MIC1LM M-Terminal" ,"Off" ,"MIC1LM" }, + {"AIF OUT" ,NULL ,"MIC1LP" }, + {"AIF OUT" ,NULL ,"MIC1RP" }, + {"AIF OUT" ,NULL ,"MIC1LM" }, + + {"AIF OUT" ,NULL ,"Activate I2S clocks" }, };static int aic31xx_add_controls (struct snd_soc_component *component)
sound/soc/codecs/tlv320aic31xx.h +1 -0
@@ -160,6 +160,7 @@ struct aic31xx_pdata {#define AIC31XX_DACMOD2BCLK 0x01#define AIC31XX_ADC2BCLK 0x02#define AIC31XX_ADCMOD2BCLK 0x03 +#define AIC31XX_KEEP_I2SCLK BIT(2)/* AIC31XX_ADCFLAG */ #define AIC31XX_ADCPWRSTATUS_MASK BIT(6)
Signature · 1 line
2.16.1
Re: [PATCH 2/2] ASoC: tlv320aic31xx: Do not force power on the DAC/ADC in clock master mode
In reply to Peter UjfalusiHi Peter,
Quoted 6 lines · Peter Ujfalusi
With P0 R29, Bit2 set the I2S clocks will be running when the DAC/ADC is powered down, but still the codec need to be powered up by needing at least one complete DAPM path for the stream.
If the AIF is not needed (analog loopback for example) the I2S clocks will not run as they are not needed.
Thanks for the work! This looks good. Sadly, I don't have an aic31 hardware for testing at hand.
Stefan
Quoted 87 lines
Signed-off-by Peter Ujfalusi <[email protected]>Suggested-by Stefan Müller-Klieser <[email protected]>--- sound/soc/codecs/tlv320aic31xx.c | 32 ++++++++++++++++++++++---------- sound/soc/codecs/tlv320aic31xx.h | 1 + 2 files changed, 23 insertions(+), 10 deletions(-)sound/soc/codecs/tlv320aic31xx.c +22
-10@@ -501,6 +501,10 @@ static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("MICBIAS" ,SND_SOC_NOPM ,0 ,0 , mic_bias_event,SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD ), +/* Keep BCLK/WCLK enabled even if DAC/ADC is powered down */ +SND_SOC_DAPM_SUPPLY ("Activate I2S clocks" ,AIC31XX_IFACE2 ,2 ,0 , +NULL ,0 ), +/* Outputs */ SND_SOC_DAPM_OUTPUT ("HPL" ), SND_SOC_DAPM_OUTPUT("HPR"),@@ -553,6 +557,8 @@ static const struct snd_soc_dapm_widget aic31xx_dapm_widgets[] = {SND_SOC_DAPM_MIXER ("Output Right" ,SND_SOC_NOPM ,0 ,0 , aic31xx_right_output_switches,ARRAY_SIZE (aic31xx_right_output_switches)), + + SND_SOC_DAPM_AIF_OUT("AIF OUT", "Capture", 0, SND_SOC_NOPM, 0, 0), }; static const struct snd_soc_dapm_widget aic311x_dapm_widgets[] = {@@ -640,6 +646,8 @@ aic31xx_audio_map[] = { {"ADC", NULL, "MIC_GAIN_CTL"}, + {"AIF OUT", NULL, "ADC"}, +/* Left Output */ {"Output Left", "From Left DAC", "DAC Left"}, {"Output Left", "From MIC1LP", "MIC1LP"},@@ -673,25 +681,29 @@ aic310x_audio_map[] = {/* * Always connected DAPM routes for codec clock master modes. -* If the codec is the master on the I2S bus, we need to power on components -* to have valid DAC_CLK and also the DACs and ADC for playback/capture. +* If the codec is the master on the I2S bus, we need to power up components +* to have valid DAC_CLK. +* +* In order to have the I2S clocks on the bus either the DACs/ADC need to be +* enabled, or the P0/R29/D2 (Keep bclk/wclk in power down) need to be set. +* * Otherwise the codec will not generate clocks on the bus. */ static const struct snd_soc_dapm_route common31xx_cm_audio_map[] = { - {"DAC Left Input" ,"Off" ,"AIF IN" }, - {"DAC Right Input" ,"Off" ,"AIF IN" }, + {"HPL" ,NULL ,"AIF IN" }, + {"HPR" ,NULL ,"AIF IN" }, - {"HPL" ,NULL ,"DAC Left" }, - {"HPR" ,NULL ,"DAC Right" }, + {"AIF IN" ,NULL ,"Activate I2S clocks" }, };static const struct snd_soc_dapm_route aic31xx_cm_audio_map[] = { - {"MIC1LP P-Terminal" ,"Off" ,"MIC1LP" }, - {"MIC1RP P-Terminal" ,"Off" ,"MIC1RP" }, - {"MIC1LM P-Terminal" ,"Off" ,"MIC1LM" }, - {"MIC1LM M-Terminal" ,"Off" ,"MIC1LM" }, + {"AIF OUT" ,NULL ,"MIC1LP" }, + {"AIF OUT" ,NULL ,"MIC1RP" }, + {"AIF OUT" ,NULL ,"MIC1LM" }, + + {"AIF OUT" ,NULL ,"Activate I2S clocks" }, };static int aic31xx_add_controls (struct snd_soc_component *component)sound/soc/codecs/tlv320aic31xx.h +0
-0
sound/soc/codecs/tlv320aic31xx.h struct aic31xx_pdata { · line 166
Quoted 7 lines
sound/soc/codecs/tlv320aic31xx.h +1
-0@@ -160,6 +160,7 @@ struct aic31xx_pdata {#define AIC31XX_DACMOD2BCLK 0x01#define AIC31XX_ADC2BCLK 0x02#define AIC31XX_ADCMOD2BCLK 0x03 +#define AIC31XX_KEEP_I2SCLK BIT(2)/* AIC31XX_ADCFLAG */ #define AIC31XX_ADCPWRSTATUS_MASK BIT(6)
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel