aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHelen Koike <helen.koike@collabora.co.uk>2016-06-20 13:12:31 -0400
committerMark Brown <broonie@kernel.org>2016-06-23 10:36:05 -0400
commite01d700c399d8d899850a1e5fad5227a9d976304 (patch)
tree4ef278e6c518aaae59404ea309b1a84679f6aefc
parenta0d5ff4496dca6e435ae3adb286d6583cf785aca (diff)
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 <lars@metafoo.de> [koike: port for upstream] Signed-off-by: Helen Koike <helen.koike@collabora.co.uk> [On N900] Tested-By: Sebastian Reichel <sre@kernel.org> Reviewed-By: Sebastian Reichel <sre@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/tpa6130a2.c64
1 files changed, 2 insertions, 62 deletions
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index d90388a38903..81bf5848b743 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -114,64 +114,6 @@ exit:
114 return ret; 114 return ret;
115} 115}
116 116
117static 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
146static 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
175/* 117/*
176 * TPA6130 volume. From -59.5 to 4 dB with increasing step size when going 118 * TPA6130 volume. From -59.5 to 4 dB with increasing step size when going
177 * down in gain. 119 * down in gain.
@@ -190,9 +132,8 @@ static const DECLARE_TLV_DB_RANGE(tpa6130_tlv,
190); 132);
191 133
192static const struct snd_kcontrol_new tpa6130a2_controls[] = { 134static const struct snd_kcontrol_new tpa6130a2_controls[] = {
193 SOC_SINGLE_EXT_TLV("Headphone Playback Volume", 135 SOC_SINGLE_TLV("Headphone Playback Volume",
194 TPA6130A2_REG_VOL_MUTE, 0, 0x3f, 0, 136 TPA6130A2_REG_VOL_MUTE, 0, 0x3f, 0,
195 tpa6130a2_get_volsw, tpa6130a2_put_volsw,
196 tpa6130_tlv), 137 tpa6130_tlv),
197}; 138};
198 139
@@ -203,9 +144,8 @@ static const DECLARE_TLV_DB_RANGE(tpa6140_tlv,
203); 144);
204 145
205static const struct snd_kcontrol_new tpa6140a2_controls[] = { 146static const struct snd_kcontrol_new tpa6140a2_controls[] = {
206 SOC_SINGLE_EXT_TLV("Headphone Playback Volume", 147 SOC_SINGLE_TLV("Headphone Playback Volume",
207 TPA6130A2_REG_VOL_MUTE, 1, 0x1f, 0, 148 TPA6130A2_REG_VOL_MUTE, 1, 0x1f, 0,
208 tpa6130a2_get_volsw, tpa6130a2_put_volsw,
209 tpa6140_tlv), 149 tpa6140_tlv),
210}; 150};
211 151