aboutsummaryrefslogtreecommitdiff
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorJon Smirl <jonsmirl@gmail.com>2008-07-29 11:42:26 +0100
committerJaroslav Kysela <perex@perex.cz>2008-07-29 21:32:16 +0200
commit4eaa9819dc08d7bfd1065ce530e31b18a119dcaf (patch)
tree022aa2195b94f0d886851c3cbcad818a13967644 /sound/soc/soc-dapm.c
parent58cd33c0f375578cfda25a52ed280caa888b6254 (diff)
ALSA: ASoC: Convert bitfields in ASoC into full int width
Convert bitfields in ASoC into full int width. This is a simple mechanical conversion. Two places in the DAPM code were fixed to properly use mask. Signed-off-by: Jon Smirl <jonsmirl@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index f9d100bc847..bbdca0dacba 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -104,10 +104,13 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
case snd_soc_dapm_switch:
case snd_soc_dapm_mixer: {
int val;
- int reg = w->kcontrols[i].private_value & 0xff;
- int shift = (w->kcontrols[i].private_value >> 8) & 0x0f;
- int mask = (w->kcontrols[i].private_value >> 16) & 0xff;
- int invert = (w->kcontrols[i].private_value >> 24) & 0x01;
+ struct soc_mixer_control *mc = (struct soc_mixer_control *)
+ w->kcontrols[i].private_value;
+ uint reg = mc->reg;
+ uint shift = mc->shift;
+ int max = mc->max;
+ uint mask = (1 << fls(max)) - 1;
+ uint invert = mc->invert;
val = snd_soc_read(w->codec, reg);
val = (val >> shift) & mask;
@@ -247,16 +250,19 @@ static int dapm_set_pga(struct snd_soc_dapm_widget *widget, int power)
return 0;
if (widget->num_kcontrols && k) {
- int reg = k->private_value & 0xff;
- int shift = (k->private_value >> 8) & 0x0f;
- int mask = (k->private_value >> 16) & 0xff;
- int invert = (k->private_value >> 24) & 0x01;
+ struct soc_mixer_control *mc =
+ (struct soc_mixer_control *)k->private_value;
+ uint reg = mc->reg;
+ uint shift = mc->shift;
+ int max = mc->max;
+ uint mask = (1 << fls(max)) - 1;
+ uint invert = mc->invert;
if (power) {
int i;
/* power up has happended, increase volume to last level */
if (invert) {
- for (i = mask; i > widget->saved_value; i--)
+ for (i = max; i > widget->saved_value; i--)
snd_soc_update_bits(widget->codec, reg, mask, i);
} else {
for (i = 0; i < widget->saved_value; i++)
@@ -1133,12 +1139,14 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
- int reg = kcontrol->private_value & 0xff;
- int shift = (kcontrol->private_value >> 8) & 0x0f;
- int rshift = (kcontrol->private_value >> 12) & 0x0f;
- int max = (kcontrol->private_value >> 16) & 0xff;
- int invert = (kcontrol->private_value >> 24) & 0x01;
- int mask = (1 << fls(max)) - 1;
+ struct soc_mixer_control *mc =
+ (struct soc_mixer_control *)kcontrol->private_value;
+ uint reg = mc->reg;
+ uint shift = mc->shift;
+ uint rshift = mc->rshift;
+ int max = mc->max;
+ uint invert = mc->invert;
+ uint mask = (1 << fls(max)) - 1;
/* return the saved value if we are powered down */
if (widget->id == snd_soc_dapm_pga && !widget->power) {
@@ -1176,12 +1184,14 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
- int reg = kcontrol->private_value & 0xff;
- int shift = (kcontrol->private_value >> 8) & 0x0f;
- int rshift = (kcontrol->private_value >> 12) & 0x0f;
- int max = (kcontrol->private_value >> 16) & 0xff;
- int mask = (1 << fls(max)) - 1;
- int invert = (kcontrol->private_value >> 24) & 0x01;
+ struct soc_mixer_control *mc =
+ (struct soc_mixer_control *)kcontrol->private_value;
+ uint reg = mc->reg;
+ uint shift = mc->shift;
+ uint rshift = mc->rshift;
+ int max = mc->max;
+ uint mask = (1 << fls(max)) - 1;
+ uint invert = mc->invert;
unsigned short val, val2, val_mask;
int ret;