aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2011-10-05 03:29:24 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-10-05 12:10:09 -0400
commitf7915d997554d4e2ce123c7a4ddd28e12c2e034c (patch)
tree9c676e63eab1afe14bfa94632a2ed28a6df44f9b /sound/soc/soc-core.c
parente8f5a10307f7d224df91776033a0b8559a559844 (diff)
ASoC: core: Combine snd_soc_get_volsw/get_volsw_2r functions
Handle the get_volsw/get_volsw_2r in one function. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c56
1 files changed, 13 insertions, 43 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 34e85506782e..1a13d530f053 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2281,7 +2281,8 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
2281 * @kcontrol: mixer control 2281 * @kcontrol: mixer control
2282 * @ucontrol: control element information 2282 * @ucontrol: control element information
2283 * 2283 *
2284 * Callback to get the value of a single mixer control. 2284 * Callback to get the value of a single mixer control, or a double mixer
2285 * control that spans 2 registers.
2285 * 2286 *
2286 * Returns 0 for success. 2287 * Returns 0 for success.
2287 */ 2288 */
@@ -2292,6 +2293,7 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
2292 (struct soc_mixer_control *)kcontrol->private_value; 2293 (struct soc_mixer_control *)kcontrol->private_value;
2293 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 2294 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2294 unsigned int reg = mc->reg; 2295 unsigned int reg = mc->reg;
2296 unsigned int reg2 = mc->rreg;
2295 unsigned int shift = mc->shift; 2297 unsigned int shift = mc->shift;
2296 unsigned int rshift = mc->rshift; 2298 unsigned int rshift = mc->rshift;
2297 int max = mc->max; 2299 int max = mc->max;
@@ -2300,13 +2302,18 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
2300 2302
2301 ucontrol->value.integer.value[0] = 2303 ucontrol->value.integer.value[0] =
2302 (snd_soc_read(codec, reg) >> shift) & mask; 2304 (snd_soc_read(codec, reg) >> shift) & mask;
2303 if (shift != rshift) 2305 if (invert)
2304 ucontrol->value.integer.value[1] =
2305 (snd_soc_read(codec, reg) >> rshift) & mask;
2306 if (invert) {
2307 ucontrol->value.integer.value[0] = 2306 ucontrol->value.integer.value[0] =
2308 max - ucontrol->value.integer.value[0]; 2307 max - ucontrol->value.integer.value[0];
2309 if (shift != rshift) 2308
2309 if (snd_soc_volsw_is_stereo(mc)) {
2310 if (reg == reg2)
2311 ucontrol->value.integer.value[1] =
2312 (snd_soc_read(codec, reg) >> rshift) & mask;
2313 else
2314 ucontrol->value.integer.value[1] =
2315 (snd_soc_read(codec, reg2) >> shift) & mask;
2316 if (invert)
2310 ucontrol->value.integer.value[1] = 2317 ucontrol->value.integer.value[1] =
2311 max - ucontrol->value.integer.value[1]; 2318 max - ucontrol->value.integer.value[1];
2312 } 2319 }
@@ -2355,43 +2362,6 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
2355EXPORT_SYMBOL_GPL(snd_soc_put_volsw); 2362EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
2356 2363
2357/** 2364/**
2358 * snd_soc_get_volsw_2r - double mixer get callback
2359 * @kcontrol: mixer control
2360 * @ucontrol: control element information
2361 *
2362 * Callback to get the value of a double mixer control that spans 2 registers.
2363 *
2364 * Returns 0 for success.
2365 */
2366int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
2367 struct snd_ctl_elem_value *ucontrol)
2368{
2369 struct soc_mixer_control *mc =
2370 (struct soc_mixer_control *)kcontrol->private_value;
2371 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2372 unsigned int reg = mc->reg;
2373 unsigned int reg2 = mc->rreg;
2374 unsigned int shift = mc->shift;
2375 int max = mc->max;
2376 unsigned int mask = (1 << fls(max)) - 1;
2377 unsigned int invert = mc->invert;
2378
2379 ucontrol->value.integer.value[0] =
2380 (snd_soc_read(codec, reg) >> shift) & mask;
2381 ucontrol->value.integer.value[1] =
2382 (snd_soc_read(codec, reg2) >> shift) & mask;
2383 if (invert) {
2384 ucontrol->value.integer.value[0] =
2385 max - ucontrol->value.integer.value[0];
2386 ucontrol->value.integer.value[1] =
2387 max - ucontrol->value.integer.value[1];
2388 }
2389
2390 return 0;
2391}
2392EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r);
2393
2394/**
2395 * snd_soc_put_volsw_2r - double mixer set callback 2365 * snd_soc_put_volsw_2r - double mixer set callback
2396 * @kcontrol: mixer control 2366 * @kcontrol: mixer control
2397 * @ucontrol: control element information 2367 * @ucontrol: control element information