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