ASoC: TWL4030: Enable/disable voice digital filters
PATCH 1/5 ASoC: TWL4030: Enable/disable voice digital filters
From: Misael Lopez Cruz <[email protected]>
Enable TWL4030 VTXL/VTXR and VRX digital filters for uplink and downlink paths, respectively.
This patch also corrects voice 8/16kHz mode selection bit (SEL_16K) of CODEC_MODE register.
--- sound/soc/codecs/twl4030.c | 37 +++++++++++++++++++++++++++++++++++++ sound/soc/codecs/twl4030.h | 2 +- 2 files changed, 38 insertions(+), 1 deletions(-)
sound/soc/codecs/twl4030.c +37 -0
@@ -1629,6 +1629,28 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai,return 0 ; } +/* In case of voice mode, the RX1 L(VRX) for downlink and the TX2 L/R +* (VTXL, VTXR) for uplink has to be enabled/disabled. */ +static void twl4030_voice_enable (struct snd_soc_codec *codec,int direction, +int enable) +{ +u8 reg, mask; + + reg =twl4030_read_reg_cache (codec,TWL4030_REG_OPTION ); + +if (direction ==SNDRV_PCM_STREAM_PLAYBACK ) + mask =TWL4030_ARXL1_VRX_EN ; +else + mask =TWL4030_ATXL2_VTXL_EN |TWL4030_ATXR2_VTXR_EN ; + +if (enable) + reg |= mask; +else + reg &= ~mask; + +twl4030_write (codec,TWL4030_REG_OPTION , reg); +} +static int twl4030_voice_startup (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {
@@ -1665,6 +1687,17 @@ static int twl4030_voice_startup(struct snd_pcm_substream *substream,return 0 ; } +static void twl4030_voice_shutdown (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_device *socdev = rtd->socdev; +struct snd_soc_codec *codec = socdev->card->codec; + +/* Enable voice digital filters */ +twl4030_voice_enable (codec, substream->stream,0 ); +} +static int twl4030_voice_hw_params (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params,struct snd_soc_dai *dai) {
@@ -1673,6 +1706,9 @@ static int twl4030_voice_hw_params(struct snd_pcm_substream *substream,struct snd_soc_codec *codec = socdev->card->codec;u8 old_mode, mode; +/* Enable voice digital filters */ +twl4030_voice_enable (codec, substream->stream,1 ); +/* bit rate */ old_mode =twl4030_read_reg_cache (codec,TWL4030_REG_CODEC_MODE ) & ~(TWL4030_CODECPDZ );
@@ -1780,6 +1816,7 @@ static struct snd_soc_dai_ops twl4030_dai_ops = {static struct snd_soc_dai_ops twl4030_dai_voice_ops = { .startup = twl4030_voice_startup, + .shutdown = twl4030_voice_shutdown, .hw_params = twl4030_voice_hw_params, .set_sysclk = twl4030_voice_set_dai_sysclk, .set_fmt = twl4030_voice_set_dai_fmt,
sound/soc/codecs/twl4030.h +1 -1
@@ -110,7 +110,7 @@#define TWL4030_APLL_RATE_44100 0x90#define TWL4030_APLL_RATE_48000 0xA0#define TWL4030_APLL_RATE_96000 0xE0 -#define TWL4030_SEL_16K 0x04 +#define TWL4030_SEL_16K 0x08#define TWL4030_CODECPDZ 0x02#define TWL4030_OPT_MODE 0x01#define TWL4030_OPTION_1 (1 << 0)
Signature · 1 line
1.6.3.1
PATCH 2/5 ASoC: Split DAPM power checks from sequencing of power changes
DAPM has always applied any changes to the power state of widgets as soon as it has determined that they are required. Instead of doing this store all the changes that are required on lists of widgets to power up and down, then iterate over those lists and apply the changes. This changes the sequence in which changes are implemented, doing all power downs before power ups and always using the up/down sequences (previously they were only used when changes were due to DAC/ADC power events). The error handling is also changed so that we continue attempting to power widgets if some changes fail.
The main benefit of this is to allow future changes to do optimisations over the whole power sequence and to reduce the number of walks of the widget graph required to check the power status of widgets.
--- include/sound/soc-dapm.h | 3 ++ include/sound/soc.h | 2 + sound/soc/soc-dapm.c | 81 +++++++++++++++++++++++++++++++-------------- 3 files changed, 61 insertions(+), 25 deletions(-)
include/sound/soc-dapm.h +3 -0
@@ -385,6 +385,9 @@ struct snd_soc_dapm_widget {/* widget input and outputs */ struct list_head sources;struct list_head sinks; + +/* used during DAPM updates */ + struct list_head power_list; };#endif
include/sound/soc.h +2 -0
@@ -372,6 +372,8 @@ struct snd_soc_codec {enum snd_soc_bias_level bias_level;enum snd_soc_bias_level suspend_bias_level;struct delayed_work delayed_work; +struct list_head up_list; +struct list_head down_list;/* codec DAI's */ struct snd_soc_dai *dai;
sound/soc/soc-dapm.c +56 -25
108 lines not on this page · raw message
Signature · 1 line
1.6.3.1
PATCH 3/5 ASoC: Make DAPM sysfs entries non-optional
In reply to Mark Brownsysfs is so standard these days there's no point.
--- sound/soc/soc-dapm.c | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-)
sound/soc/soc-dapm.c +1 -9
@@ -67,10 +67,6 @@ static int dapm_down_seq[] = { snd_soc_dapm_post }; -static int dapm_status =1 ; -module_param (dapm_status, int,0 ); -MODULE_PARM_DESC (dapm_status,"enable DPM sysfs entries" ); -static void pop_wait (u32 pop_time) {if (pop_time)
@@ -974,16 +970,12 @@ static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);int snd_soc_dapm_sys_add (struct device *dev) { -if (!dapm_status) -return 0 ;return device_create_file (dev, &dev_attr_dapm_widget); }static void snd_soc_dapm_sys_remove (struct device *dev) { -if (dapm_status) { -device_remove_file (dev, &dev_attr_dapm_widget); - } +device_remove_file (dev, &dev_attr_dapm_widget); }/* free all dapm widgets and resources */
Signature · 1 line
1.6.3.1
PATCH 4/5 ASoC: Integrate bias management with DAPM power management
In reply to Mark BrownRather than managing the bias level of the system based on if there is an active audio stream manage it based on there being an active DAPM widget. This simplifies the code a little, moving the power handling into one place, and improves audio performance for bypass paths when no playbacks or captures are active.
--- include/sound/soc-dapm.h | 2 - include/sound/soc.h | 1 + sound/soc/soc-core.c | 61 ++++++------------------------------ sound/soc/soc-dapm.c | 78 +++++++++++++++++++++++++++++++-------------- 4 files changed, 65 insertions(+), 77 deletions(-)
include/sound/soc-dapm.h +0 -2
@@ -279,8 +279,6 @@ int snd_soc_dapm_add_routes(struct snd_soc_codec *codec,/* dapm events */ int snd_soc_dapm_stream_event (struct snd_soc_codec *codec,char *stream,int event); -int snd_soc_dapm_set_bias_level (struct snd_soc_device *socdev, -enum snd_soc_bias_level level);/* dapm sys fs - used by the core */ int snd_soc_dapm_sys_add (struct device *dev);
include/sound/soc.h +1 -0
@@ -339,6 +339,7 @@ struct snd_soc_codec {struct module *owner;struct mutex mutex;struct device *dev; +struct snd_soc_device *socdev;struct list_head list;
sound/soc/soc-core.c +10 -51
96 lines not on this page · raw message
sound/soc/soc-dapm.c +54 -24
117 lines not on this page · raw message
Signature · 1 line
1.6.3.1
PATCH 5/5 ASoC: Add debug trace for bias level transitions
In reply to Mark BrownA standard way of making sure we know when the bias level changes.
--- sound/soc/soc-dapm.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
sound/soc/soc-dapm.c +18 -0
@@ -110,6 +110,24 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,struct snd_soc_codec *codec = socdev->card->codec;int ret =0 ; +switch (level) { +case SND_SOC_BIAS_ON : +dev_dbg (socdev->dev,"Setting full bias\n" ); +break ; +case SND_SOC_BIAS_PREPARE : +dev_dbg (socdev->dev,"Setting bias prepare\n" ); +break ; +case SND_SOC_BIAS_STANDBY : +dev_dbg (socdev->dev,"Setting standby bias\n" ); +break ; +case SND_SOC_BIAS_OFF : +dev_dbg (socdev->dev,"Setting bias off\n" ); +break ; +default : +dev_err (socdev->dev,"Setting invalid bias %d\n" , level); +return -EINVAL ; + } +if (card->set_bias_level) ret = card->set_bias_level (card, level);if (ret ==0 && codec->set_bias_level)
Signature · 1 line
1.6.3.1