static int inmixer_event (struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { u16 reg, fakepower; reg = wm8400_read(w->codec, WM8400_POWER_MANAGEMENT_2); fakepower = wm8400_read(w->codec, WM8400_INTDRIVBITS); if (fakepower & ((1 << WM8400_INMIXL_PWR) | (1 << WM8400_AINLMUX_PWR))) { reg |= WM8400_AINL_ENA; } else { reg &= ~WM8400_AINL_ENA; } if (fakepower & ((1 << WM8400_INMIXR_PWR) | (1 << WM8400_AINRMUX_PWR))) { reg |= WM8400_AINR_ENA; } else { reg &= ~WM8400_AINR_ENA; } wm8400_write(w->codec, WM8400_POWER_MANAGEMENT_2, reg); return 0; }
/** * wm8400_set_bits - Bitmask write * * @wm8400: Pointer to wm8400 control structure * @reg: Register to access * @mask: Mask of bits to change * @val: Value to set for masked bits */ int wm8400_set_bits(struct wm8400 *wm8400, u8 reg, u16 mask, u16 val) { u16 tmp; int ret; mutex_lock(&wm8400->io_lock); ret = wm8400_read(wm8400, reg, 1, &tmp); tmp = (tmp & ~mask) | val; if (ret == 0) ret = wm8400_write(wm8400, reg, 1, &tmp); mutex_unlock(&wm8400->io_lock); return ret; }
/** * wm8400_stop_codec - Place the codec subsystem in reset */ void wm8400_stop_codec(struct wm8400 *wm8400) { u16 val; int i; mutex_lock(&wm8400->io_lock); val = wm8400->reg_cache[WM8400_POWER_MANAGEMENT_1] & ~WM8400_CODEC_ENA; wm8400_write(wm8400, WM8400_POWER_MANAGEMENT_1, 1, &val); /* Reset all codec registers to their initial value */ for (i = 0; i < ARRAY_SIZE(wm8400->reg_cache); i++) if (reg_data[i].is_codec) wm8400->reg_cache[i] = reg_data[i].default_val; mutex_unlock(&wm8400->io_lock); }
static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int reg = mc->reg; int ret; u16 val; ret = snd_soc_put_volsw(kcontrol, ucontrol); if (ret < 0) return ret; /* */ val = wm8400_read(codec, reg); return wm8400_write(codec, reg, val | 0x0100); }