Skip to content

Commit e01d700

Browse files
Helen Koikebroonie
authored andcommitted
ASoC: tpa6130a2: Use snd soc volsw functions
Use snd_soc_{info,get,put}_volsw instead of custom volume functions Signed-off-by: Lars-Peter Clausen <[email protected]> [koike: port for upstream] Signed-off-by: Helen Koike <[email protected]> [On N900] Tested-By: Sebastian Reichel <[email protected]> Reviewed-By: Sebastian Reichel <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent a0d5ff4 commit e01d700

File tree

1 file changed

+2
-62
lines changed

1 file changed

+2
-62
lines changed

sound/soc/codecs/tpa6130a2.c

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -114,64 +114,6 @@ static int tpa6130a2_power(u8 power)
114114
return ret;
115115
}
116116

117-
static int tpa6130a2_get_volsw(struct snd_kcontrol *kcontrol,
118-
struct snd_ctl_elem_value *ucontrol)
119-
{
120-
struct soc_mixer_control *mc =
121-
(struct soc_mixer_control *)kcontrol->private_value;
122-
struct tpa6130a2_data *data;
123-
unsigned int reg = mc->reg;
124-
unsigned int shift = mc->shift;
125-
int max = mc->max, val;
126-
unsigned int mask = (1 << fls(max)) - 1;
127-
unsigned int invert = mc->invert;
128-
129-
if (WARN_ON(!tpa6130a2_client))
130-
return -EINVAL;
131-
data = i2c_get_clientdata(tpa6130a2_client);
132-
133-
mutex_lock(&data->mutex);
134-
135-
regmap_read(data->regmap, reg, &val);
136-
ucontrol->value.integer.value[0] = (val >> shift) & mask;
137-
138-
if (invert)
139-
ucontrol->value.integer.value[0] =
140-
max - ucontrol->value.integer.value[0];
141-
142-
mutex_unlock(&data->mutex);
143-
return 0;
144-
}
145-
146-
static int tpa6130a2_put_volsw(struct snd_kcontrol *kcontrol,
147-
struct snd_ctl_elem_value *ucontrol)
148-
{
149-
struct soc_mixer_control *mc =
150-
(struct soc_mixer_control *)kcontrol->private_value;
151-
struct tpa6130a2_data *data;
152-
unsigned int reg = mc->reg;
153-
unsigned int shift = mc->shift;
154-
int max = mc->max;
155-
unsigned int mask = (1 << fls(max)) - 1;
156-
unsigned int invert = mc->invert;
157-
unsigned int val = (ucontrol->value.integer.value[0] & mask);
158-
bool change;
159-
160-
if (WARN_ON(!tpa6130a2_client))
161-
return -EINVAL;
162-
data = i2c_get_clientdata(tpa6130a2_client);
163-
164-
if (invert)
165-
val = max - val;
166-
167-
mutex_lock(&data->mutex);
168-
regmap_update_bits_check(data->regmap, reg, mask << shift, val << shift,
169-
&change);
170-
mutex_unlock(&data->mutex);
171-
172-
return change;
173-
}
174-
175117
/*
176118
* TPA6130 volume. From -59.5 to 4 dB with increasing step size when going
177119
* down in gain.
@@ -190,9 +132,8 @@ static const DECLARE_TLV_DB_RANGE(tpa6130_tlv,
190132
);
191133

192134
static const struct snd_kcontrol_new tpa6130a2_controls[] = {
193-
SOC_SINGLE_EXT_TLV("Headphone Playback Volume",
135+
SOC_SINGLE_TLV("Headphone Playback Volume",
194136
TPA6130A2_REG_VOL_MUTE, 0, 0x3f, 0,
195-
tpa6130a2_get_volsw, tpa6130a2_put_volsw,
196137
tpa6130_tlv),
197138
};
198139

@@ -203,9 +144,8 @@ static const DECLARE_TLV_DB_RANGE(tpa6140_tlv,
203144
);
204145

205146
static const struct snd_kcontrol_new tpa6140a2_controls[] = {
206-
SOC_SINGLE_EXT_TLV("Headphone Playback Volume",
147+
SOC_SINGLE_TLV("Headphone Playback Volume",
207148
TPA6130A2_REG_VOL_MUTE, 1, 0x1f, 0,
208-
tpa6130a2_get_volsw, tpa6130a2_put_volsw,
209149
tpa6140_tlv),
210150
};
211151

0 commit comments

Comments
 (0)