Combining snd_soc_*_volsw/volsw_2r
Subsystems (4)
v2 cover Combining snd_soc_*_volsw/volsw_2r
Hello Mark,
Changes since v1 (RFC series):
- rebased on git://opensource.wolfsonmicro.com/linux-2.6-asoc, for-3.2 branch
- twl6040: warning added for the custom volsw calls in case of unexpected parameter
- snd_soc_volsw_is_stereo returns type changed to bool
- patch 06: optimized the if() cases in order to reduce the number of comparison in certain cases
- patch 06: Use the (reg == reg2) comparison instead of (shift != rshitf) to differentiate between single or 2r type of stereo controls
- patch 07: Use the (reg == reg2) comparison instead of (shift != rshitf) to differentiate between single or 2r type of stereo controls
Intro mail from v1:
This series will combine the snd_soc_*_volsw, and snd_soc_*_volsw_2r callbacks.
We are going to drop the volsw_r2 callbacks, and merge the support to the _volsw functions.
In order to achieve this, the macros need to be adjusted, and also the drivers, which were not using the macros to construct the soc_mixer_control needed to be changed, so I'm not going to introduce any breakage, inconsistency.
This has been suggested in this thread:
http://mailman.alsa-project.org/pipermail/alsa-devel/2011-September/044287.html
By Mark in this mail (I hope I did not misunderstood it):
http://mailman.alsa-project.org/pipermail/alsa-devel/2011-September/044343.html
The use of the existing macros will not change, but underneath we are not going to have two sets of functions for single, or double mixer controls.
I think the last 3 patch can be squashed, I did not wanted to touch the core, and a codec driver in a same patch.
Regards,
Peter
---
Peter Ujfalusi (10):
ASoC: Consolidate use of controls with custom get/put function
ASoC: twl6040: Simplify custom get_volsw callback
ASoC: twl6040: Prepare for core put_volsw/volsw_2r merger
ASoC: core: Change SOC_SINGLE/DOUBLE_VALUE representation
ASoC: core: Combine snd_soc_info_volsw/info_volsw_2r functions
ASoC: core: Combine snd_soc_get_volsw/get_volsw_2r functions
ASoC: core: Combine snd_soc_put_volsw/put_volsw_2r functions
ASoC: twl6040: Simply call snd_soc_put_volsw form the custom code
ASoC: core: Remove snd_soc_put_volsw_2r definition
ASoC: twl6040: Warn user in twl6040_put_volsw for error case
include/sound/soc.h | 33 +++++--- sound/soc/codecs/tlv320aic23.c | 14 +--- sound/soc/codecs/twl4030.c | 48 +++--------- sound/soc/codecs/twl6040.c | 64 ++++------------ sound/soc/codecs/wm8350.c | 39 ++++------ sound/soc/codecs/wm8580.c | 36 +++------ sound/soc/codecs/wm_hubs.c | 18 +--- sound/soc/soc-core.c | 162 +++++++++------------------------------- 8 files changed, 117 insertions(+), 297 deletions(-)
Signature · 1 line
1.7.7
PATCH v2 1/10 ASoC: Consolidate use of controls with custom get/put function
Use the macros for controls require custom get/put function. This is to make sure that the soc_mixer_control is used consistently among the drivers.
--- sound/soc/codecs/tlv320aic23.c | 14 ++--------- sound/soc/codecs/twl4030.c | 48 ++++++++++------------------------------ sound/soc/codecs/twl6040.c | 37 +++++------------------------- sound/soc/codecs/wm8350.c | 39 ++++++++++++-------------------- sound/soc/codecs/wm8580.c | 36 ++++++++++-------------------- sound/soc/codecs/wm_hubs.c | 18 ++++---------- 6 files changed, 53 insertions(+), 139 deletions(-)
sound/soc/codecs/tlv320aic23.c +3 -11
@@ -159,15 +159,6 @@ static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol, } -#define SOC_TLV320AIC23_SINGLE_TLV (xname, reg, shift, max, invert, tlv_array) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ - SNDRV_CTL_ELEM_ACCESS_READWRITE,\ - .tlv.p = (tlv_array), \ - .info = snd_soc_info_volsw, .get = snd_soc_tlv320aic23_get_volsw,\ - .put = snd_soc_tlv320aic23_put_volsw, \ - .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } -static const struct snd_kcontrol_new tlv320aic23_snd_controls[] = {SOC_DOUBLE_R_TLV ("Digital Playback Volume" ,TLV320AIC23_LCHNVOL ,TLV320AIC23_RCHNVOL ,0 ,127 ,0 , out_gain_tlv),
@@ -178,8 +169,9 @@ static const struct snd_kcontrol_new tlv320aic23_snd_controls[] = { TLV320AIC23_RINVOL, 0, 31, 0, input_gain_tlv),SOC_SINGLE ("Mic Input Switch" ,TLV320AIC23_ANLG ,1 ,1 ,1 ),SOC_SINGLE ("Mic Booster Switch" ,TLV320AIC23_ANLG ,0 ,1 ,0 ), -SOC_TLV320AIC23_SINGLE_TLV ("Sidetone Volume" ,TLV320AIC23_ANLG , -6 ,4 ,0 , sidetone_vol_tlv), +SOC_SINGLE_EXT_TLV ("Sidetone Volume" ,TLV320AIC23_ANLG ,6 ,4 ,0 , + snd_soc_tlv320aic23_get_volsw, + snd_soc_tlv320aic23_put_volsw, sidetone_vol_tlv), SOC_ENUM("Playback De-emphasis", tlv320aic23_deemph), };
sound/soc/codecs/twl4030.c +12 -36
65 lines not on this page · raw message
sound/soc/codecs/twl6040.c +6 -31
@@ -812,33 +812,6 @@ static int twl6040_get_volsw(struct snd_kcontrol *kcontrol,return snd_soc_get_volsw (kcontrol, ucontrol); } -/* double control with volume update */ -#define SOC_TWL6040_DOUBLE_TLV (xname, xreg, shift_left, shift_right, xmax,\ - xinvert, tlv_array)\ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ - SNDRV_CTL_ELEM_ACCESS_READWRITE,\ - .tlv.p = (tlv_array), \ - .info = snd_soc_info_volsw, .get = twl6040_get_volsw, \ - .put = twl6040_put_volsw, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = xreg, .shift = shift_left, .rshift = shift_right,\ - .max = xmax, .platform_max = xmax, .invert = xinvert} } - -/* double control with volume update */ -#define SOC_TWL6040_DOUBLE_R_TLV (xname, reg_left, reg_right, xshift, xmax,\ - xinvert, tlv_array)\ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ - SNDRV_CTL_ELEM_ACCESS_READWRITE | \ - SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ - .tlv.p = (tlv_array), \ - .info = snd_soc_info_volsw_2r, \ - .get = twl6040_get_volsw, .put = twl6040_put_volsw, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ - .rshift = xshift, .max = xmax, .invert = xinvert}, } -/* * MICATT volume control: * from -6 to 0 dB in 6 dB steps
@@ -1027,10 +1000,12 @@ static const struct snd_kcontrol_new twl6040_snd_controls[] = { TWL6040_REG_LINEGAIN, 0, 3, 7, 0, afm_amp_tlv),/* Playback gains */ -SOC_TWL6040_DOUBLE_TLV ("Headset Playback Volume" , -TWL6040_REG_HSGAIN ,0 ,4 ,0xF ,1 , hs_tlv), -SOC_TWL6040_DOUBLE_R_TLV ("Handsfree Playback Volume" , -TWL6040_REG_HFLGAIN ,TWL6040_REG_HFRGAIN ,0 ,0x1D ,1 , hf_tlv), +SOC_DOUBLE_EXT_TLV ("Headset Playback Volume" , +TWL6040_REG_HSGAIN ,0 ,4 ,0xF ,1 , twl6040_get_volsw, + twl6040_put_volsw, hs_tlv), +SOC_DOUBLE_R_EXT_TLV ("Handsfree Playback Volume" , +TWL6040_REG_HFLGAIN ,TWL6040_REG_HFRGAIN ,0 ,0x1D ,1 , + twl6040_get_volsw, twl6040_put_volsw, hf_tlv),SOC_SINGLE_TLV ("Earphone Playback Volume" , TWL6040_REG_EARCTL, 1, 0xF, 1, ep_tlv),
sound/soc/codecs/wm8350.c +15 -24
@@ -395,20 +395,6 @@ static int wm8350_get_volsw_2r(struct snd_kcontrol *kcontrol,return snd_soc_get_volsw_2r (kcontrol, ucontrol); } -/* double control with volume update */ -#define SOC_WM8350_DOUBLE_R_TLV (xname, reg_left, reg_right, xshift, xmax, \ - xinvert, tlv_array) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ - SNDRV_CTL_ELEM_ACCESS_READWRITE | \ - SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ - .tlv.p = (tlv_array), \ - .info = snd_soc_info_volsw_2r, \ - .get = wm8350_get_volsw_2r, .put = wm8350_put_volsw_2r_vu, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ - .rshift = xshift, .max = xmax, .invert = xinvert}, } -static const char *wm8350_deemp[] = {"None" ,"32kHz" ,"44.1kHz" ,"48kHz" };static const char *wm8350_pol[] = {"Normal" ,"Inv R" ,"Inv L" ,"Inv L & R" };static const char *wm8350_dacmutem[] = {"Normal" ,"Soft" };
@@ -443,26 +429,29 @@ static const unsigned int capture_sd_tlv[] = {static const struct snd_kcontrol_new wm8350_snd_controls[] = {SOC_ENUM ("Playback Deemphasis" , wm8350_enum[0 ]),SOC_ENUM ("Playback DAC Inversion" , wm8350_enum[1 ]), -SOC_WM8350_DOUBLE_R_TLV ("Playback PCM Volume" , +SOC_DOUBLE_R_EXT_TLV ("Playback PCM Volume" ,WM8350_DAC_DIGITAL_VOLUME_L ,WM8350_DAC_DIGITAL_VOLUME_R , -0 ,255 ,0 , dac_pcm_tlv), +0 ,255 ,0 , wm8350_get_volsw_2r, + wm8350_put_volsw_2r_vu, dac_pcm_tlv),SOC_ENUM ("Playback PCM Mute Function" , wm8350_enum[2 ]),SOC_ENUM ("Playback PCM Mute Speed" , wm8350_enum[3 ]),SOC_ENUM ("Capture PCM Filter" , wm8350_enum[4 ]),SOC_ENUM ("Capture PCM HP Filter" , wm8350_enum[5 ]),SOC_ENUM ("Capture ADC Inversion" , wm8350_enum[6 ]), -SOC_WM8350_DOUBLE_R_TLV ("Capture PCM Volume" , +SOC_DOUBLE_R_EXT_TLV ("Capture PCM Volume" ,WM8350_ADC_DIGITAL_VOLUME_L ,WM8350_ADC_DIGITAL_VOLUME_R , -0 ,255 ,0 , adc_pcm_tlv), +0 ,255 ,0 , wm8350_get_volsw_2r, + wm8350_put_volsw_2r_vu, adc_pcm_tlv),SOC_DOUBLE_TLV ("Capture Sidetone Volume" ,WM8350_ADC_DIVIDER ,8 ,4 ,15 ,1 , capture_sd_tlv), -SOC_WM8350_DOUBLE_R_TLV ("Capture Volume" , +SOC_DOUBLE_R_EXT_TLV ("Capture Volume" ,WM8350_LEFT_INPUT_VOLUME ,WM8350_RIGHT_INPUT_VOLUME , -2 ,63 ,0 , pre_amp_tlv), +2 ,63 ,0 , wm8350_get_volsw_2r, + wm8350_put_volsw_2r_vu, pre_amp_tlv),SOC_DOUBLE_R ("Capture ZC Switch" ,WM8350_LEFT_INPUT_VOLUME ,WM8350_RIGHT_INPUT_VOLUME ,13 ,1 ,0 ),
@@ -490,17 +479,19 @@ static const struct snd_kcontrol_new wm8350_snd_controls[] = {SOC_SINGLE_TLV ("Out4 Capture Volume" ,WM8350_INPUT_MIXER_VOLUME ,1 ,7 ,0 , out_mix_tlv), -SOC_WM8350_DOUBLE_R_TLV ("Out1 Playback Volume" , +SOC_DOUBLE_R_EXT_TLV ("Out1 Playback Volume" ,WM8350_LOUT1_VOLUME ,WM8350_ROUT1_VOLUME , -2 ,63 ,0 , out_pga_tlv), +2 ,63 ,0 , wm8350_get_volsw_2r, + wm8350_put_volsw_2r_vu, out_pga_tlv),SOC_DOUBLE_R ("Out1 Playback ZC Switch" ,WM8350_LOUT1_VOLUME ,WM8350_ROUT1_VOLUME ,13 ,1 ,0 ), -SOC_WM8350_DOUBLE_R_TLV ("Out2 Playback Volume" , +SOC_DOUBLE_R_EXT_TLV ("Out2 Playback Volume" ,WM8350_LOUT2_VOLUME ,WM8350_ROUT2_VOLUME , -2 ,63 ,0 , out_pga_tlv), +2 ,63 ,0 , wm8350_get_volsw_2r, + wm8350_put_volsw_2r_vu, out_pga_tlv),SOC_DOUBLE_R ("Out2 Playback ZC Switch" ,WM8350_LOUT2_VOLUME ,WM8350_ROUT2_VOLUME ,13 ,1 ,0 ), SOC_SINGLE("Out2 Right Invert Switch", WM8350_ROUT2_VOLUME, 10, 1, 0),
sound/soc/codecs/wm8580.c +12 -24
@@ -224,31 +224,19 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol,return 0 ; } -#define SOC_WM8580_OUT_DOUBLE_R_TLV (xname, reg_left, reg_right, xshift, xmax, \ - xinvert, tlv_array) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ - SNDRV_CTL_ELEM_ACCESS_READWRITE, \ - .tlv.p = (tlv_array), \ - .info = snd_soc_info_volsw_2r, \ - .get = snd_soc_get_volsw_2r, .put = wm8580_out_vu, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ - .max = xmax, .invert = xinvert} } -static const struct snd_kcontrol_new wm8580_snd_controls[] = { -SOC_WM8580_OUT_DOUBLE_R_TLV ("DAC1 Playback Volume" , -WM8580_DIGITAL_ATTENUATION_DACL1 , -WM8580_DIGITAL_ATTENUATION_DACR1 , -0 ,0xff ,0 , dac_tlv), -SOC_WM8580_OUT_DOUBLE_R_TLV ("DAC2 Playback Volume" , -WM8580_DIGITAL_ATTENUATION_DACL2 , -WM8580_DIGITAL_ATTENUATION_DACR2 , -0 ,0xff ,0 , dac_tlv), -SOC_WM8580_OUT_DOUBLE_R_TLV ("DAC3 Playback Volume" , -WM8580_DIGITAL_ATTENUATION_DACL3 , -WM8580_DIGITAL_ATTENUATION_DACR3 , -0 ,0xff ,0 , dac_tlv), +SOC_DOUBLE_R_EXT_TLV ("DAC1 Playback Volume" , +WM8580_DIGITAL_ATTENUATION_DACL1 , +WM8580_DIGITAL_ATTENUATION_DACR1 , +0 ,0xff ,0 , snd_soc_get_volsw_2r, wm8580_out_vu, dac_tlv), +SOC_DOUBLE_R_EXT_TLV ("DAC2 Playback Volume" , +WM8580_DIGITAL_ATTENUATION_DACL2 , +WM8580_DIGITAL_ATTENUATION_DACR2 , +0 ,0xff ,0 , snd_soc_get_volsw_2r, wm8580_out_vu, dac_tlv), +SOC_DOUBLE_R_EXT_TLV ("DAC3 Playback Volume" , +WM8580_DIGITAL_ATTENUATION_DACL3 , +WM8580_DIGITAL_ATTENUATION_DACR3 , +0 ,0xff ,0 , snd_soc_get_volsw_2r, wm8580_out_vu, dac_tlv),SOC_SINGLE ("DAC1 Deemphasis Switch" ,WM8580_DAC_CONTROL3 ,0 ,1 ,0 ),SOC_SINGLE ("DAC2 Deemphasis Switch" ,WM8580_DAC_CONTROL3 ,1 ,1 ,0 ),
sound/soc/codecs/wm_hubs.c +5 -13
@@ -362,19 +362,11 @@ SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST, 3, 0, 7, 0,SOC_ENUM ("Speaker Reference" , speaker_ref),SOC_ENUM ("Speaker Mode" , speaker_mode), -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Headphone Volume", - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | -SNDRV_CTL_ELEM_ACCESS_READWRITE , - .tlv.p = outpga_tlv, - .info = snd_soc_info_volsw_2r, - .get = snd_soc_get_volsw_2r, .put = wm8993_put_dc_servo, - .private_value = (unsigned long)&(struct soc_mixer_control) { - .reg =WM8993_LEFT_OUTPUT_VOLUME , - .rreg =WM8993_RIGHT_OUTPUT_VOLUME , - .shift =0 , .max =63 - }, -}, +SOC_DOUBLE_R_EXT_TLV ("Headphone Volume" , +WM8993_LEFT_OUTPUT_VOLUME ,WM8993_RIGHT_OUTPUT_VOLUME , +0 ,63 ,0 , snd_soc_get_volsw_2r, wm8993_put_dc_servo, + outpga_tlv), +SOC_DOUBLE_R ("Headphone Switch" ,WM8993_LEFT_OUTPUT_VOLUME ,WM8993_RIGHT_OUTPUT_VOLUME ,6 ,1 ,0 ), SOC_DOUBLE_R("Headphone ZC Switch", WM8993_LEFT_OUTPUT_VOLUME,
Signature · 1 line
1.7.7
PATCH v2 2/10 ASoC: twl6040: Simplify custom get_volsw callback
In reply to Peter UjfalusiThe custom get_volsw does not need to call any core get_volsw calls, since we are returning the shadow values for the gains. Return -EINVAL in the unlikely event, if the function has been called for unhandled control. This way we can remove one check in the code.
--- sound/soc/codecs/twl6040.c | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-)
sound/soc/codecs/twl6040.c +6 -12
@@ -796,20 +796,14 @@ static int twl6040_get_volsw(struct snd_kcontrol *kcontrol, out = &twl6040_priv->handsfree;break ;default : -break ; - } - -if (out) { - ucontrol->value.integer.value[0 ] = out->left_vol; - ucontrol->value.integer.value[1 ] = out->right_vol; -return 0 ; +dev_warn (codec->dev,"%s: Unexpected register: 0x%02x\n" , + __func__, mc->reg); +return -EINVAL ; } -/* call the appropriate handler depending on the rreg */ -if (mc->rreg) -return snd_soc_get_volsw_2r (kcontrol, ucontrol); -else -return snd_soc_get_volsw (kcontrol, ucontrol); + ucontrol->value.integer.value[0 ] = out->left_vol; + ucontrol->value.integer.value[1 ] = out->right_vol; +return 0 ; }/*
Signature · 1 line
1.7.7
PATCH v2 3/10 ASoC: twl6040: Prepare for core put_volsw/volsw_2r merger
In reply to Peter UjfalusiAvoid using the mc->rreg to identify the 2r type of gain control. Introduce a variable to track this.
This change is needed to avoid breakage with the upcoming volsw volsw_2r merger.
--- sound/soc/codecs/twl6040.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
sound/soc/codecs/twl6040.c +4 -2
@@ -746,7 +746,7 @@ static int twl6040_put_volsw(struct snd_kcontrol *kcontrol,struct twl6040_output *out =NULL ;struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; -int ret; +int ret, type_2r;/* For HS and HF we shadow the values and only actually write * them out when active in order to ensure the amplifier comes on
@@ -754,9 +754,11 @@ static int twl6040_put_volsw(struct snd_kcontrol *kcontrol,switch (mc->reg) {case TWL6040_REG_HSGAIN : out = &twl6040_priv->headset; + type_2r =0 ;break ;case TWL6040_REG_HFLGAIN : out = &twl6040_priv->handsfree; + type_2r =1 ;break ;default :return -EINVAL ;
@@ -768,7 +770,7 @@ static int twl6040_put_volsw(struct snd_kcontrol *kcontrol,return 1 ;/* call the appropriate handler depending on the rreg */ -if (mc->rreg) +if (type_2r) ret =snd_soc_put_volsw_2r (kcontrol, ucontrol);else ret =snd_soc_put_volsw (kcontrol, ucontrol);
Signature · 1 line
1.7.7
PATCH v2 4/10 ASoC: core: Change SOC_SINGLE/DOUBLE_VALUE representation
In reply to Peter UjfalusiSOC_SINGLE/DOUBLE_VALUE is used for mixer controls, where the bits are within one register.
Assign .rreg to be the same as .reg for these types.
With this change we can tell if the mixer in question:
is mono:mc->reg == mc->rreg && mc->shift == mc->rshift
is stereo, within single register:mc->reg == mc->rreg && mc->shift != mc->rshift
is stereo, in two registers:mc->reg != mc->rreg
The patch provide a small inline function to query, if the mixer is stereo, or mono.
--- include/sound/soc.h | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-)
include/sound/soc.h +15 -2
@@ -30,8 +30,9 @@*/ #define SOC_DOUBLE_VALUE (xreg, shift_left, shift_right, xmax, xinvert) \ ((unsigned long)&(struct soc_mixer_control) \ - {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ - .max = xmax, .platform_max = xmax, .invert = xinvert}) + {.reg = xreg, .rreg = xreg, .shift = shift_left, \ + .rshift = shift_right, .max = xmax, .platform_max = xmax, \ + .invert = xinvert})#define SOC_SINGLE_VALUE (xreg, xshift, xmax, xinvert) \ SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert)#define SOC_SINGLE_VALUE_EXT (xreg, xmax, xinvert) \
@@ -946,6 +947,18 @@ static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)INIT_LIST_HEAD (&card->dapm_list); } +static inline bool snd_soc_volsw_is_stereo (struct soc_mixer_control *mc) +{ +if (mc->reg == mc->rreg && mc->shift == mc->rshift) +return 0 ; +/* +* mc->reg == mc->rreg && mc->shift != mc->rshift, or +* mc->reg != mc->rreg means that the control is +* stereo (bits in one register or in two registers) +*/ +return 1 ; +} +int snd_soc_util_init (void );void snd_soc_util_exit (void );
Signature · 1 line
1.7.7
PATCH v2 5/10 ASoC: core: Combine snd_soc_info_volsw/info_volsw_2r functions
In reply to Peter UjfalusiHandle the info_volsw/info_volsw_2r in one function.
--- include/sound/soc.h | 8 +++----- sound/soc/soc-core.c | 40 +++------------------------------------- 2 files changed, 6 insertions(+), 42 deletions(-)
include/sound/soc.h +3 -5
@@ -63,7 +63,7 @@ max, invert) }#define SOC_DOUBLE_R (xname, reg_left, reg_right, xshift, xmax, xinvert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ - .info = snd_soc_info_volsw_2r, \ + .info = snd_soc_info_volsw, \ .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ xmax, xinvert) }
@@ -81,7 +81,7 @@ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ SNDRV_CTL_ELEM_ACCESS_READWRITE,\ .tlv.p = (tlv_array), \ - .info = snd_soc_info_volsw_2r, \ + .info = snd_soc_info_volsw, \ .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ .private_value =SOC_DOUBLE_R_VALUE (reg_left, reg_right, xshift, \ xmax, xinvert) }
@@ -156,7 +156,7 @@ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ SNDRV_CTL_ELEM_ACCESS_READWRITE, \ .tlv.p = (tlv_array), \ - .info = snd_soc_info_volsw_2r, \ + .info = snd_soc_info_volsw, \ .get = xhandler_get, .put = xhandler_put, \ .private_value =SOC_DOUBLE_R_VALUE (reg_left, reg_right, xshift, \ xmax, xinvert) }
@@ -393,8 +393,6 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);int snd_soc_put_volsw (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); -int snd_soc_info_volsw_2r (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_info *uinfo);int snd_soc_get_volsw_2r (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
sound/soc/soc-core.c +3 -37
@@ -2248,7 +2248,8 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext);* @kcontrol: mixer control * @uinfo: control element information * -* Callback to provide information about a single mixer control. +* Callback to provide information about a single mixer control, or a double +* mixer control that spans 2 registers. * * Returns 0 for success. */
@@ -2258,8 +2259,6 @@ int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;int platform_max; -unsigned int shift = mc->shift; -unsigned int rshift = mc->rshift;if (!mc->platform_max) mc->platform_max = mc->max;
@@ -2270,7 +2269,7 @@ int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,else uinfo->type =SNDRV_CTL_ELEM_TYPE_INTEGER ; - uinfo->count = shift == rshift ?1 :2 ; + uinfo->count =snd_soc_volsw_is_stereo (mc) ?2 :1 ; uinfo->value.integer.min =0 ; uinfo->value.integer.max = platform_max;return 0 ;
@@ -2356,39 +2355,6 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,EXPORT_SYMBOL_GPL (snd_soc_put_volsw);/** -* snd_soc_info_volsw_2r - double mixer info callback -* @kcontrol: mixer control -* @uinfo: control element information -* -* Callback to provide information about a double mixer control that -* spans 2 codec registers. -* -* Returns 0 for success. -*/ -int snd_soc_info_volsw_2r (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_info *uinfo) -{ -struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; -int platform_max; - -if (!mc->platform_max) - mc->platform_max = mc->max; - platform_max = mc->platform_max; - -if (platform_max ==1 && !strstr (kcontrol->id.name," Volume" )) - uinfo->type =SNDRV_CTL_ELEM_TYPE_BOOLEAN ; -else - uinfo->type =SNDRV_CTL_ELEM_TYPE_INTEGER ; - - uinfo->count =2 ; - uinfo->value.integer.min =0 ; - uinfo->value.integer.max = platform_max; -return 0 ; -} -EXPORT_SYMBOL_GPL (snd_soc_info_volsw_2r); - -/** * snd_soc_get_volsw_2r - double mixer get callback * @kcontrol: mixer control * @ucontrol: control element information
Signature · 1 line
1.7.7
PATCH v2 6/10 ASoC: core: Combine snd_soc_get_volsw/get_volsw_2r functions
In reply to Peter UjfalusiHandle the get_volsw/get_volsw_2r in one function.
--- include/sound/soc.h | 6 +--- sound/soc/soc-core.c | 56 +++++++++++-------------------------------------- 2 files changed, 15 insertions(+), 47 deletions(-)
include/sound/soc.h +2 -4
@@ -64,7 +64,7 @@#define SOC_DOUBLE_R (xname, reg_left, reg_right, xshift, xmax, xinvert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ .info = snd_soc_info_volsw, \ - .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ + .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_2r, \ .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ xmax, xinvert) }#define SOC_DOUBLE_TLV (xname, reg, shift_left, shift_right, max, invert, tlv_array) \
@@ -82,7 +82,7 @@ SNDRV_CTL_ELEM_ACCESS_READWRITE,\ .tlv.p = (tlv_array), \ .info = snd_soc_info_volsw, \ - .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ + .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_2r, \ .private_value =SOC_DOUBLE_R_VALUE (reg_left, reg_right, xshift, \ xmax, xinvert) }#define SOC_DOUBLE_S8_TLV (xname, xreg, xmin, xmax, tlv_array) \
@@ -393,8 +393,6 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);int snd_soc_put_volsw (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); -int snd_soc_get_volsw_2r (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol);int snd_soc_put_volsw_2r (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
sound/soc/soc-core.c +13 -43
82 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH v2 7/10 ASoC: core: Combine snd_soc_put_volsw/put_volsw_2r functions
In reply to Peter UjfalusiHandle the put_volsw/put_volsw_2r in one function.
To avoid build breakage in twl6040 keep the snd_soc_put_volsw_2r as define, and map it snd_soc_put_volsw.
--- include/sound/soc.h | 7 ++--- sound/soc/soc-core.c | 66 ++++++++++++++----------------------------------- 2 files changed, 22 insertions(+), 51 deletions(-)
include/sound/soc.h +3 -4
@@ -64,7 +64,7 @@#define SOC_DOUBLE_R (xname, reg_left, reg_right, xshift, xmax, xinvert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ .info = snd_soc_info_volsw, \ - .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_2r, \ + .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ xmax, xinvert) }#define SOC_DOUBLE_TLV (xname, reg, shift_left, shift_right, max, invert, tlv_array) \
@@ -82,7 +82,7 @@ SNDRV_CTL_ELEM_ACCESS_READWRITE,\ .tlv.p = (tlv_array), \ .info = snd_soc_info_volsw, \ - .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_2r, \ + .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ .private_value =SOC_DOUBLE_R_VALUE (reg_left, reg_right, xshift, \ xmax, xinvert) }#define SOC_DOUBLE_S8_TLV (xname, xreg, xmin, xmax, tlv_array) \
@@ -393,8 +393,7 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);int snd_soc_put_volsw (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); -int snd_soc_put_volsw_2r (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol); +#define snd_soc_put_volsw_2r snd_soc_put_volswint snd_soc_info_volsw_s8 (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo); int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
sound/soc/soc-core.c +19 -47
99 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH v2 8/10 ASoC: twl6040: Simply call snd_soc_put_volsw form the custom code
In reply to Peter UjfalusiThe ASoC core now have one callback function, which can handle single, and double register mixer controls.
--- sound/soc/codecs/twl6040.c | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-)
sound/soc/codecs/twl6040.c +2 -9
@@ -746,7 +746,7 @@ static int twl6040_put_volsw(struct snd_kcontrol *kcontrol,struct twl6040_output *out =NULL ;struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; -int ret, type_2r; +int ret;/* For HS and HF we shadow the values and only actually write * them out when active in order to ensure the amplifier comes on
@@ -754,11 +754,9 @@ static int twl6040_put_volsw(struct snd_kcontrol *kcontrol,switch (mc->reg) {case TWL6040_REG_HSGAIN : out = &twl6040_priv->headset; - type_2r =0 ;break ;case TWL6040_REG_HFLGAIN : out = &twl6040_priv->handsfree; - type_2r =1 ;break ;default :return -EINVAL ;
@@ -769,12 +767,7 @@ static int twl6040_put_volsw(struct snd_kcontrol *kcontrol,if (!out->active)return 1 ; -/* call the appropriate handler depending on the rreg */ -if (type_2r) - ret =snd_soc_put_volsw_2r (kcontrol, ucontrol); -else - ret =snd_soc_put_volsw (kcontrol, ucontrol); - + ret =snd_soc_put_volsw (kcontrol, ucontrol);if (ret <0 )return ret;
Signature · 1 line
1.7.7
PATCH v2 9/10 ASoC: core: Remove snd_soc_put_volsw_2r definition
In reply to Peter UjfalusiWe do not have users for snd_soc_put_volsw_2r anymore. It can be removed.
--- include/sound/soc.h | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
include/sound/soc.h +0 -1
@@ -393,7 +393,6 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);int snd_soc_put_volsw (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); -#define snd_soc_put_volsw_2r snd_soc_put_volswint snd_soc_info_volsw_s8 (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo); int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
Signature · 1 line
1.7.7
PATCH v2 10/10 ASoC: twl6040: Warn user in twl6040_put_volsw for error case
In reply to Peter UjfalusiLet the user know, that the callback has been called with unexpected register parameter.
--- sound/soc/codecs/twl6040.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
sound/soc/codecs/twl6040.c +2 -0
@@ -759,6 +759,8 @@ static int twl6040_put_volsw(struct snd_kcontrol *kcontrol, out = &twl6040_priv->handsfree;break ;default : +dev_warn (codec->dev,"%s: Unexpected register: 0x%02x\n" , + __func__, mc->reg);return -EINVAL ; }
Signature · 1 line
1.7.7
Mark Brown
AppliedQuoted 1 line · Peter Ujfalusi
This series will combine the snd_soc_*_volsw, and snd_soc_*_volsw_2r callbacks.
Applied all, thanks.