Lines Matching defs:wm

18 static void snd_wm8766_write(struct snd_wm8766 *wm, u16 addr, u16 data)
21 wm->regs[addr] = data;
22 wm->ops.write(wm, addr, data);
137 void snd_wm8766_init(struct snd_wm8766 *wm)
147 memcpy(wm->ctl, snd_wm8766_default_ctl, sizeof(wm->ctl));
149 snd_wm8766_write(wm, WM8766_REG_RESET, 0x00); /* reset */
153 snd_wm8766_write(wm, i, default_values[i]);
156 void snd_wm8766_resume(struct snd_wm8766 *wm)
161 snd_wm8766_write(wm, i, wm->regs[i]);
164 void snd_wm8766_set_if(struct snd_wm8766 *wm, u16 dac)
166 u16 val = wm->regs[WM8766_REG_IFCTRL] & ~WM8766_IF_MASK;
169 snd_wm8766_write(wm, WM8766_REG_IFCTRL, val | dac);
172 void snd_wm8766_volume_restore(struct snd_wm8766 *wm)
174 u16 val = wm->regs[WM8766_REG_DACR1];
176 snd_wm8766_write(wm, WM8766_REG_DACR1, val | WM8766_VOL_UPDATE);
184 struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
188 uinfo->count = (wm->ctl[n].flags & WM8766_FLAG_STEREO) ? 2 : 1;
189 uinfo->value.integer.min = wm->ctl[n].min;
190 uinfo->value.integer.max = wm->ctl[n].max;
198 struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
201 return snd_ctl_enum_info(uinfo, 1, wm->ctl[n].max,
202 wm->ctl[n].enum_names);
208 struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
212 if (wm->ctl[n].get)
213 wm->ctl[n].get(wm, &val1, &val2);
215 val1 = wm->regs[wm->ctl[n].reg1] & wm->ctl[n].mask1;
216 val1 >>= __ffs(wm->ctl[n].mask1);
217 if (wm->ctl[n].flags & WM8766_FLAG_STEREO) {
218 val2 = wm->regs[wm->ctl[n].reg2] & wm->ctl[n].mask2;
219 val2 >>= __ffs(wm->ctl[n].mask2);
220 if (wm->ctl[n].flags & WM8766_FLAG_VOL_UPDATE)
224 if (wm->ctl[n].flags & WM8766_FLAG_INVERT) {
225 val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min);
226 if (wm->ctl[n].flags & WM8766_FLAG_STEREO)
227 val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min);
230 if (wm->ctl[n].flags & WM8766_FLAG_STEREO)
239 struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
246 if (wm->ctl[n].flags & WM8766_FLAG_INVERT) {
247 regval1 = wm->ctl[n].max - (regval1 - wm->ctl[n].min);
248 regval2 = wm->ctl[n].max - (regval2 - wm->ctl[n].min);
250 if (wm->ctl[n].set)
251 wm->ctl[n].set(wm, regval1, regval2);
253 val = wm->regs[wm->ctl[n].reg1] & ~wm->ctl[n].mask1;
254 val |= regval1 << __ffs(wm->ctl[n].mask1);
256 if (wm->ctl[n].flags & WM8766_FLAG_STEREO &&
257 wm->ctl[n].reg1 == wm->ctl[n].reg2) {
258 val &= ~wm->ctl[n].mask2;
259 val |= regval2 << __ffs(wm->ctl[n].mask2);
261 snd_wm8766_write(wm, wm->ctl[n].reg1, val);
263 if (wm->ctl[n].flags & WM8766_FLAG_STEREO &&
264 wm->ctl[n].reg1 != wm->ctl[n].reg2) {
265 val = wm->regs[wm->ctl[n].reg2] & ~wm->ctl[n].mask2;
266 val |= regval2 << __ffs(wm->ctl[n].mask2);
267 if (wm->ctl[n].flags & WM8766_FLAG_VOL_UPDATE)
269 snd_wm8766_write(wm, wm->ctl[n].reg2, val);
276 static int snd_wm8766_add_control(struct snd_wm8766 *wm, int num)
284 cont.name = wm->ctl[num].name;
286 if (wm->ctl[num].flags & WM8766_FLAG_LIM ||
287 wm->ctl[num].flags & WM8766_FLAG_ALC)
293 switch (wm->ctl[num].type) {
297 cont.tlv.p = wm->ctl[num].tlv;
300 wm->ctl[num].max = 1;
301 if (wm->ctl[num].flags & WM8766_FLAG_STEREO)
312 ctl = snd_ctl_new1(&cont, wm);
315 wm->ctl[num].kctl = ctl;
317 return snd_ctl_add(wm->card, ctl);
320 int snd_wm8766_build_controls(struct snd_wm8766 *wm)
325 if (wm->ctl[i].name) {
326 err = snd_wm8766_add_control(wm, i);