- if (kcontrol->private_value)
- idx = WM_DAC_MASTER_ATTEN;
- else
- idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + WM_DAC_ATTEN;
- nvol = ucontrol->value.integer.value[0] + 0x1a;
- ovol = wm_get(ice, idx) & 0x7f;
- change = (ovol != nvol);
- if (change) {
- if (nvol <= 0x1a && ovol <= 0x1a)
- change = 0;
- else
- wm_put(ice, idx, nvol | 0x180); /* update on zero detect */
+ for (i = 0; i < voices; i++) {
+ idx = WM_DAC_ATTEN + ofs + i;
+ nvol = ucontrol->value.integer.value[i] + 0x1a;
+ ovol = wm_get(ice, idx) & 0x7f;
+ if (ovol != nvol) {
+ if (nvol <= 0x1a && ovol <= 0x1a)
+ continue;
+ wm_put(ice, idx, nvol | 0x80); /* zero-detect, prelatch */
+ wm_put_nocache(ice, idx, nvol | 0x180); /* update */
+ change = 1;
+ }
+ }
+ snd_ice1712_restore_gpio_status(ice);
+ return change;
+}
+
+/* digital master volume */
+#define MASTER_0dB 0xff
+#define MASTER_RES 128 /* -64dB */
+#define MASTER_MIN (MASTER_0dB - MASTER_RES)
+static int wm_master_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 1;
+ uinfo->value.integer.min = 0; /* mute (-64dB) */
+ uinfo->value.integer.max = MASTER_RES; /* 0dB */
+ return 0;
+}
+
+static int wm_master_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+ ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+ unsigned short val;
+
+ down(&ice->gpio_mutex);
+ val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
+ val = val > MASTER_MIN ? (val - MASTER_MIN) : 0;
+ ucontrol->value.integer.value[0] = val;
+ up(&ice->gpio_mutex);
+ return 0;
+}
+
+static int wm_master_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+ ice1712_t *ice = snd_kcontrol_chip(kcontrol);
+ unsigned short ovol, nvol;
+ int change = 0;
+
+ snd_ice1712_save_gpio_status(ice);
+ nvol = ucontrol->value.integer.value[0];
+ nvol = (nvol ? (nvol + MASTER_MIN) : 0) & 0xff;
+ ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
+ if (ovol != nvol) {
+ wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */
+ wm_put_nocache(ice, WM_DAC_DIG_MASTER_ATTEN, nvol | 0x100); /* update */
+ change = 1;