Re: [PATCH 2/2] ASoC: Do DAPM control updates in the middle of DAPM sequences

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 14 December 2010 19:53:22 ext Mark Brown wrote:
> @@ -1634,13 +1671,12 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol
> *kcontrol, (struct soc_mixer_control *)kcontrol->private_value; unsigned
> int reg = mc->reg;
>         unsigned int shift = mc->shift;
> -       unsigned int rshift = mc->rshift;
>         int max = mc->max;
>         unsigned int mask = (1 << fls(max)) - 1;
>         unsigned int invert = mc->invert;
> -       unsigned int val, val2, val_mask;
> -       int connect;
> -       int ret;
> +       unsigned int val, val_mask;
> +       int connect, change;

You do not need the change variable, since

> +       struct snd_soc_dapm_update update;
> 
>         val = (ucontrol->value.integer.value[0] & mask);
> 
> @@ -1648,18 +1684,12 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol
> *kcontrol, val = max - val;
>         val_mask = mask << shift;
>         val = val << shift;
> -       if (shift != rshift) {
> -               val2 = (ucontrol->value.integer.value[1] & mask);
> -               if (invert)
> -                       val2 = max - val2;
> -               val_mask |= mask << rshift;
> -               val |= val2 << rshift;
> -       }
> 
>         mutex_lock(&widget->codec->mutex);
>         widget->value = val;
> 
> -       if (snd_soc_test_bits(widget->codec, reg, val_mask, val)) {
> +       change = snd_soc_test_bits(widget->codec, reg, val_mask, val);
> +       if (change) {

it is used only here, so you could just keep the old if () way.

>                 if (val)
>                         /* new connection */
>                         connect = invert ? 0:1;
> @@ -1667,28 +1697,20 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol
> *kcontrol, /* old connection must be powered down */
>                         connect = invert ? 1:0;
> 
> +               update.kcontrol = kcontrol;
> +               update.widget = widget;
> +               update.reg = reg;
> +               update.mask = mask;
> +               update.val = val;
> +               widget->dapm->update = &update;
> +
>                 dapm_mixer_update_power(widget, kcontrol, connect);
> +
> +               widget->dapm->update = NULL;
>         }
> 
> -       if (widget->event) {
> -               if (widget->event_flags & SND_SOC_DAPM_PRE_REG) {
> -                       ret = widget->event(widget, kcontrol,
> -                                               SND_SOC_DAPM_PRE_REG);
> -                       if (ret < 0) {
> -                               ret = 1;
> -                               goto out;
> -                       }
> -               }
> -               ret = snd_soc_update_bits(widget->codec, reg, val_mask,
> val); -               if (widget->event_flags & SND_SOC_DAPM_POST_REG)
> -                       ret = widget->event(widget, kcontrol,
> -                                               SND_SOC_DAPM_POST_REG);
> -       } else
> -               ret = snd_soc_update_bits(widget->codec, reg, val_mask,
> val); -
> -out:
>         mutex_unlock(&widget->codec->mutex);
> -       return ret;
> +       return 0;
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);

-- 
Péter
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux