ASoC: Add SND_SOC_BYTES_EXT control type
Subsystems (4)
PATCH 1/3 ASoC: Add SND_SOC_BYTES_EXT control type
--- include/sound/soc.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
include/sound/soc.h +7 -0
@@ -256,6 +256,13 @@ ((unsigned long )&(struct soc_bytes ) \ {.base = xbase, .num_regs = xregs }) } +#define SND_SOC_BYTES_EXT (xname, xbase, xregs, xhandler_get, xhandler_put) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_bytes_info, .get = xhandler_get, \ + .put = xhandler_put, .private_value = \ + ((unsigned long)&(struct soc_bytes) \ + {.base = xbase, .num_regs = xregs }) } +#define SND_SOC_BYTES_MASK (xname, xbase, xregs, xmask) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
Signature · 1 line
1.7.2.5
PATCH 2/3 mfd: wm5102: Mark additional registers as volatile
Mark some additional registers as volatile. The write sequencer control registers should not be cached, as we don't ever want their value synchronised as this might cause a write sequence to be accidentally initiated.
Additionally, the DAC_COMP registers require special preconditions to write so there values wouldn't be updated accurately during a register sync.
--- drivers/mfd/wm5102-tables.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/mfd/wm5102-tables.c +7 -3
@@ -245,9 +245,6 @@ const struct regmap_irq_chip wm5102_irq = {static const struct reg_default wm5102_reg_default[] = { {0x00000008 ,0x0019 },/* R8 - Ctrl IF SPI CFG 1 */ {0x00000009 ,0x0001 },/* R9 - Ctrl IF I2C1 CFG 1 */ - {0x00000016 ,0x0000 },/* R22 - Write Sequencer Ctrl 0 */ - {0x00000017 ,0x0000 },/* R23 - Write Sequencer Ctrl 1 */ - {0x00000018 ,0x0000 },/* R24 - Write Sequencer Ctrl 2 */ {0x00000020 ,0x0000 },/* R32 - Tone Generator 1 */ {0x00000021 ,0x1000 },/* R33 - Tone Generator 2 */ {0x00000022 ,0x0000 },/* R34 - Tone Generator 3 */
@@ -1878,6 +1875,9 @@ static bool wm5102_volatile_register(struct device *dev, unsigned int reg)switch (reg) {case ARIZONA_SOFTWARE_RESET :case ARIZONA_DEVICE_REVISION : +case ARIZONA_WRITE_SEQUENCER_CTRL_0 : +case ARIZONA_WRITE_SEQUENCER_CTRL_1 : +case ARIZONA_WRITE_SEQUENCER_CTRL_2 :case ARIZONA_OUTPUT_STATUS_1 :case ARIZONA_RAW_OUTPUT_STATUS_1 :case ARIZONA_SLIMBUS_RX_PORT_STATUS :
@@ -1889,6 +1889,10 @@ static bool wm5102_volatile_register(struct device *dev, unsigned int reg)case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS :case ARIZONA_FLL1_NCO_TEST_0 :case ARIZONA_FLL2_NCO_TEST_0 : +case ARIZONA_DAC_COMP_1 : +case ARIZONA_DAC_COMP_2 : +case ARIZONA_DAC_COMP_3 : +case ARIZONA_DAC_COMP_4 :case ARIZONA_FX_CTRL2 :case ARIZONA_INTERRUPT_STATUS_1 :case ARIZONA_INTERRUPT_STATUS_2 :
Signature · 1 line
1.7.2.5
Re: [PATCH 2/3] mfd: wm5102: Mark additional registers as volatile
drivers/mfd/wm5102-tables.c static bool wm5102_volatile_register(struct device *dev, unsigned int reg) · line 1881
Quoted 8 lines · Charles Keepax
drivers/mfd/wm5102-tables.c +3
-0@@ -1878,6 +1875,9 @@ static bool wm5102_volatile_register(struct device *dev, unsigned int reg)switch (reg) {case ARIZONA_SOFTWARE_RESET :case ARIZONA_DEVICE_REVISION : +case ARIZONA_WRITE_SEQUENCER_CTRL_0 : +case ARIZONA_WRITE_SEQUENCER_CTRL_1 : +case ARIZONA_WRITE_SEQUENCER_CTRL_2 :case ARIZONA_OUTPUT_STATUS_1 :
Just noticed that we are missing WRITE_SEQUENCER_CTRL_3 here, I might hold off with this patch until:
mfd: wm5102: Mark register write sequencer control 3 readable
Has made it to a public MFD branch I can rebase onto, then I can add that in too.
Thanks,
Charles
PATCH 3/3 ASoC: wm5102: Add controls to allow shaping of ultrasonic response
In reply to Charles KeepaxAdd controls to allow custom shaping of the ultrasonic response. This custom shaping can be turned on/off at runtime, although, it should be noted that settings will not affect a currently open audio stream, they will be applied when the next audio stream is started.
--- include/linux/mfd/arizona/core.h | 3 ++ sound/soc/codecs/arizona.c | 34 +++++++++++++++++++++ sound/soc/codecs/wm5102.c | 62 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 0 deletions(-)
include/linux/mfd/arizona/core.h +3 -0
@@ -113,6 +113,9 @@ struct arizona {int tdm_width[ARIZONA_MAX_AIF ];int tdm_slots[ARIZONA_MAX_AIF ]; + +uint16_t dac_comp_coeff; +uint8_t dac_comp_enabled; };int arizona_clk32k_enable (struct arizona *arizona);
sound/soc/codecs/arizona.c +34 -0
@@ -1127,6 +1127,31 @@ static int arizona_startup(struct snd_pcm_substream *substream, constraint); } +static void arizona_wm5102_set_dac_comp (struct snd_soc_codec *codec, +unsigned int rate) +{ +struct arizona_priv *priv =snd_soc_codec_get_drvdata (codec); +struct arizona *arizona = priv->arizona; +struct reg_default dac_comp[] = { + {0x80 ,0x3 }, + {ARIZONA_DAC_COMP_1 ,0 }, + {ARIZONA_DAC_COMP_2 ,0 }, + {0x80 ,0x0 }, + }; + +mutex_lock (&codec->mutex); + + dac_comp[1 ].def = arizona->dac_comp_coeff; +if (rate >=176400 ) + dac_comp[2 ].def = arizona->dac_comp_enabled; + +mutex_unlock (&codec->mutex); + +regmap_multi_reg_write (arizona->regmap, + dac_comp, +ARRAY_SIZE (dac_comp)); +} +static int arizona_hw_params_rate (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params,struct snd_soc_dai *dai)
@@ -1153,6 +1178,15 @@ static int arizona_hw_params_rate(struct snd_pcm_substream *substream,switch (dai_priv->clk) {case ARIZONA_CLK_SYSCLK : +switch (priv->arizona->type) { +case WM5102 : +arizona_wm5102_set_dac_comp (codec, +params_rate (params)); +break ; +default : +break ; + } +snd_soc_update_bits (codec,ARIZONA_SAMPLE_RATE_1 ,ARIZONA_SAMPLE_RATE_1_MASK , sr_val);if (base)
sound/soc/codecs/wm5102.c +62 -0
74 lines not on this page · raw message
Signature · 1 line
1.7.2.5
Re: [PATCH 3/3] ASoC: wm5102: Add controls to allow shaping of ultrasonic response
Quoted 8 lines · Charles Keepax
Add controls to allow custom shaping of the ultrasonic response. This custom shaping can be turned on/off at runtime, although, it should be noted that settings will not affect a currently open audio stream, they will be applied when the next audio stream is started.
Signed-off-by Charles Keepax <[email protected]>--- include/linux/mfd/arizona/core.h | 3 ++
For the MFD changes:
Quoted 150 lines
sound/soc/codecs/arizona.c | 34 +++++++++++++++++++++ sound/soc/codecs/wm5102.c | 62 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 0 deletions(-)include/linux/mfd/arizona/core.h +3
-0@@ -113,6 +113,9 @@ struct arizona {int tdm_width[ARIZONA_MAX_AIF ];int tdm_slots[ARIZONA_MAX_AIF ]; + +uint16_t dac_comp_coeff; +uint8_t dac_comp_enabled; };int arizona_clk32k_enable (struct arizona *arizona);sound/soc/codecs/arizona.c +34
-0@@ -1127,6 +1127,31 @@ static int arizona_startup(struct snd_pcm_substream *substream, constraint); } +static void arizona_wm5102_set_dac_comp (struct snd_soc_codec *codec, +unsigned int rate) +{ +struct arizona_priv *priv =snd_soc_codec_get_drvdata (codec); +struct arizona *arizona = priv->arizona; +struct reg_default dac_comp[] = { + {0x80 ,0x3 }, + {ARIZONA_DAC_COMP_1 ,0 }, + {ARIZONA_DAC_COMP_2 ,0 }, + {0x80 ,0x0 }, + }; + +mutex_lock (&codec->mutex); + + dac_comp[1 ].def = arizona->dac_comp_coeff; +if (rate >=176400 ) + dac_comp[2 ].def = arizona->dac_comp_enabled; + +mutex_unlock (&codec->mutex); + +regmap_multi_reg_write (arizona->regmap, + dac_comp, +ARRAY_SIZE (dac_comp)); +} +static int arizona_hw_params_rate (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params,struct snd_soc_dai *dai)@@ -1153,6 +1178,15 @@ static int arizona_hw_params_rate(struct snd_pcm_substream *substream,switch (dai_priv->clk) {case ARIZONA_CLK_SYSCLK : +switch (priv->arizona->type) { +case WM5102 : +arizona_wm5102_set_dac_comp (codec, +params_rate (params)); +break ; +default : +break ; + } +snd_soc_update_bits (codec,ARIZONA_SAMPLE_RATE_1 ,ARIZONA_SAMPLE_RATE_1_MASK , sr_val);if (base)sound/soc/codecs/wm5102.c +62
-0@@ -612,6 +612,62 @@ static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w,return 0 ; } +static int wm5102_out_comp_coeff_get (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_codec *codec =snd_kcontrol_chip (kcontrol); +struct arizona *arizona =dev_get_drvdata (codec->dev->parent); +uint16_t data; + +mutex_lock (&codec->mutex); + data =cpu_to_be16 (arizona->dac_comp_coeff); +memcpy (ucontrol->value.bytes.data, &data,sizeof (data)); +mutex_unlock (&codec->mutex); + +return 0 ; +} + +static int wm5102_out_comp_coeff_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_codec *codec =snd_kcontrol_chip (kcontrol); +struct arizona *arizona =dev_get_drvdata (codec->dev->parent); + +mutex_lock (&codec->mutex); +memcpy (&arizona->dac_comp_coeff, ucontrol->value.bytes.data, +sizeof (arizona->dac_comp_coeff)); + arizona->dac_comp_coeff =be16_to_cpu (arizona->dac_comp_coeff); +mutex_unlock (&codec->mutex); + +return 0 ; +} + +static int wm5102_out_comp_switch_get (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_codec *codec =snd_kcontrol_chip (kcontrol); +struct arizona *arizona =dev_get_drvdata (codec->dev->parent); + +mutex_lock (&codec->mutex); + ucontrol->value.integer.value[0 ] = arizona->dac_comp_enabled; +mutex_unlock (&codec->mutex); + +return 0 ; +} + +static int wm5102_out_comp_switch_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_codec *codec =snd_kcontrol_chip (kcontrol); +struct arizona *arizona =dev_get_drvdata (codec->dev->parent); + +mutex_lock (&codec->mutex); + arizona->dac_comp_enabled = ucontrol->value.integer.value[0 ]; +mutex_unlock (&codec->mutex); + +return 0 ; +} +static const char *wm5102_osr_text[] = {"Low power" ,"Normal" ,"High performance" , };@@ -843,6 +899,12 @@ SOC_SINGLE_TLV("Noise Gate Threshold Volume", ARIZONA_NOISE_GATE_CONTROL, ARIZONA_NGATE_THR_SHIFT, 7, 1, ng_tlv),SOC_ENUM ("Noise Gate Hold" , arizona_ng_hold), +SND_SOC_BYTES_EXT ("Output Compensation Coefficient" ,0 ,1 , + wm5102_out_comp_coeff_get, wm5102_out_comp_coeff_put), + +SOC_SINGLE_EXT ("Output Compensation Switch" ,0 ,0 ,1 ,0 , + wm5102_out_comp_switch_get, wm5102_out_comp_switch_put), +WM5102_NG_SRC ("HPOUT1L" ,ARIZONA_NOISE_GATE_SELECT_1L ),WM5102_NG_SRC ("HPOUT1R" ,ARIZONA_NOISE_GATE_SELECT_1R ), WM5102_NG_SRC("HPOUT2L", ARIZONA_NOISE_GATE_SELECT_2L),
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 1 line · Charles Keepax
Signed-off-by Charles Keepax <[email protected]>
Vinod did beat you on this one:
http://mailman.alsa-project.org/pipermail/alsa-devel/2014-May/076155.html
Although that version of the macro looks slightly different.
Quoted 23 lines
--- include/sound/soc.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)include/sound/soc.h +7
-0@@ -256,6 +256,13 @@ ((unsigned long )&(struct soc_bytes ) \ {.base = xbase, .num_regs = xregs }) } +#define SND_SOC_BYTES_EXT (xname, xbase, xregs, xhandler_get, xhandler_put) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_bytes_info, .get = xhandler_get, \ + .put = xhandler_put, .private_value = \ + ((unsigned long)&(struct soc_bytes) \ + {.base = xbase, .num_regs = xregs }) } +#define SND_SOC_BYTES_MASK (xname, xbase, xregs, xmask) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
Quoted 8 lines · Lars-Peter Clausen
Quoted 1 line · Charles Keepax
Signed-off-by Charles Keepax <[email protected]>Vinod did beat you on this one:
http://mailman.alsa-project.org/pipermail/alsa-devel/2014-May/076155.html
Although that version of the macro looks slightly different.
Ooops.. not sure how I missed that, will rebase my stuff on top of that.
Thanks,
Charles