- return snd_ac97_update_bits(ac97, reg, mask << shift, val << shift);
-}
-
-#define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .info = snd_ac97_info_double, \
- .get = snd_ac97_get_double, .put = snd_ac97_put_double, \
- .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
-
-static int snd_ac97_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
-{
- int mask = (kcontrol->private_value >> 16) & 0xff;
-
- uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
- uinfo->count = 2;
- uinfo->value.integer.min = 0;
- uinfo->value.integer.max = mask;
- return 0;
-}
-
-static int snd_ac97_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
-{
- ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
- int reg = kcontrol->private_value & 0xff;
- int shift_left = (kcontrol->private_value >> 8) & 0x0f;
- int shift_right = (kcontrol->private_value >> 12) & 0x0f;
- int mask = (kcontrol->private_value >> 16) & 0xff;
- int invert = (kcontrol->private_value >> 24) & 0xff;
-
- spin_lock(&ac97->reg_lock);
- ucontrol->value.integer.value[0] = (snd_ac97_read_cache(ac97, reg) >> shift_left) & mask;
- ucontrol->value.integer.value[1] = (snd_ac97_read_cache(ac97, reg) >> shift_right) & mask;
- spin_unlock(&ac97->reg_lock);
- if (invert) {
- ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
- ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1];
- }
- return 0;
-}
-
-static int snd_ac97_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
-{
- ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
- int reg = kcontrol->private_value & 0xff;
- int shift_left = (kcontrol->private_value >> 8) & 0x0f;
- int shift_right = (kcontrol->private_value >> 12) & 0x0f;
- int mask = (kcontrol->private_value >> 16) & 0xff;
- int invert = (kcontrol->private_value >> 24) & 0xff;
- unsigned short val1, val2;
-
- val1 = ucontrol->value.integer.value[0] & mask;
- val2 = ucontrol->value.integer.value[1] & mask;
- if (invert) {
- val1 = mask - val1;
- val2 = mask - val2;
- }
- return snd_ac97_update_bits(ac97, reg,
- (mask << shift_left) | (mask << shift_right),
- (val1 << shift_left) | (val2 << shift_right));
-}
-
-int snd_ac97_getput_page(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol,
- int (*func)(snd_kcontrol_t *, snd_ctl_elem_value_t *))
-{
- ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
- int reg = kcontrol->private_value & 0xff;
- int err;
-
- if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23 &&
- (reg >= 0x60 && reg < 0x70)) {
- unsigned short page_save;
- unsigned short page = (kcontrol->private_value >> 25) & 0x0f;
- down(&ac97->mutex); /* lock paging */
- page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK;
- snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page);
- err = func(kcontrol, ucontrol);
- snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save);
- up(&ac97->mutex); /* unlock paging */
- } else
- err = func(kcontrol, ucontrol);