static int max98925_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); switch (event) { case SND_SOC_DAPM_PRE_PMU: regmap_update_bits(max98925->regmap, MAX98925_BLOCK_ENABLE, M98925_BST_EN_MASK | M98925_ADC_IMON_EN_MASK | M98925_ADC_VMON_EN_MASK, M98925_BST_EN_MASK | M98925_ADC_IMON_EN_MASK | M98925_ADC_VMON_EN_MASK); break; case SND_SOC_DAPM_POST_PMD: regmap_update_bits(max98925->regmap, MAX98925_BLOCK_ENABLE, M98925_BST_EN_MASK | M98925_ADC_IMON_EN_MASK | M98925_ADC_VMON_EN_MASK, 0); break; default: return 0; } return 0; }
static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; unsigned int cfud; int i; /* preserve reserved bits in STA32X_CFUD */ cfud = snd_soc_read(codec, STA32X_CFUD) & 0xf0; /* chip documentation does not say if the bits are self clearing, * so do it explicitly */ snd_soc_write(codec, STA32X_CFUD, cfud); snd_soc_write(codec, STA32X_CFADDR2, index); if (numcoef == 1) snd_soc_write(codec, STA32X_CFUD, cfud | 0x04); else if (numcoef == 5) snd_soc_write(codec, STA32X_CFUD, cfud | 0x08); else return -EINVAL; for (i = 0; i < 3 * numcoef; i++) ucontrol->value.bytes.data[i] = snd_soc_read(codec, STA32X_B1CF1 + i); return 0; }
/* * Stop any attempts to change speaker mode while the speaker is enabled. * * We also have some special anti-pop controls dependent on speaker * mode which must be changed along with the mode. */ static int speaker_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg_pwr = snd_soc_read(codec, WM9081_POWER_MANAGEMENT); unsigned int reg2 = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); /* Are we changing anything? */ if (ucontrol->value.integer.value[0] == ((reg2 & WM9081_SPK_MODE) != 0)) return 0; /* Don't try to change modes while enabled */ if (reg_pwr & WM9081_SPK_ENA) return -EINVAL; if (ucontrol->value.integer.value[0]) { /* Class AB */ reg2 &= ~(WM9081_SPK_INV_MUTE | WM9081_OUT_SPK_CTRL); reg2 |= WM9081_SPK_MODE; } else { /* Class D */ reg2 |= WM9081_SPK_INV_MUTE | WM9081_OUT_SPK_CTRL; reg2 &= ~WM9081_SPK_MODE; } snd_soc_write(codec, WM9081_ANALOGUE_SPEAKER_2, reg2); return 0; }
static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; unsigned int cfud; int i; /* preserve reserved bits in STA32X_CFUD */ cfud = snd_soc_read(codec, STA32X_CFUD) & 0xf0; /* chip documentation does not say if the bits are self clearing, * so do it explicitly */ snd_soc_write(codec, STA32X_CFUD, cfud); snd_soc_write(codec, STA32X_CFADDR2, index); for (i = 0; i < numcoef && (index + i < STA32X_COEF_COUNT); i++) sta32x->coef_shadow[index + i] = (ucontrol->value.bytes.data[3 * i] << 16) | (ucontrol->value.bytes.data[3 * i + 1] << 8) | (ucontrol->value.bytes.data[3 * i + 2]); for (i = 0; i < 3 * numcoef; i++) snd_soc_write(codec, STA32X_B1CF1 + i, ucontrol->value.bytes.data[i]); if (numcoef == 1) snd_soc_write(codec, STA32X_CFUD, cfud | 0x01); else if (numcoef == 5) snd_soc_write(codec, STA32X_CFUD, cfud | 0x02); else return -EINVAL; return 0; }
static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = cs4271->deemph; return 0; }
static int pcm512x_overclock_dac_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = pcm512x->overclock_dac; return 0; }
static int es8328_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = es8328->deemph; return 0; }
static int cs4271_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); cs4271->deemph = ucontrol->value.integer.value[0]; return cs4271_set_deemph(codec); }
static int adav80x_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = adav80x->deemph; return 0; };
static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = ak4641->deemph; return 0; };
static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = wm8904->deemph; return 0; }
static int lm4857_get_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct lm4857 *lm4857 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = lm4857->mode; return 0; }
static int snd_wl1273_get_audio_route(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wl1273->mode; return 0; }
static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); ucontrol->value.integer.value[0] = wm2000->spk_ena; return 0; }
static int tas5086_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); priv->deemph = ucontrol->value.integer.value[0]; return tas5086_set_deemph(codec); }
static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = priv->deemph; return 0; }
static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; return 0; }
static int max9768_set_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]); return 0; }
static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); ucontrol->value.enumerated.item[0] = wm2000->anc_active; return 0; }
static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); dev_dbg(codec->dev, "%s: enter.\n", __func__); ucontrol->value.integer.value[0] = wl1273->core->volume; return 0; }
/** * cs4270_soc_put_mute - put callback for the 'Master Playback switch' * alsa control. * @kcontrol: mixer control * @ucontrol: control element information * * This function basically passes the arguments on to the generic * snd_soc_put_volsw() function and saves the mute information in * our private data structure. This is because we want to prevent * cs4270_dai_mute() neglecting the user's decision to manually * mute the codec's output. * * Returns 0 for success. */ static int cs4270_soc_put_mute(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); int left = !ucontrol->value.integer.value[0]; int right = !ucontrol->value.integer.value[1]; cs4270->manual_mute = (left ? CS4270_MUTE_DAC_A : 0) | (right ? CS4270_MUTE_DAC_B : 0); return snd_soc_put_volsw(kcontrol, ucontrol); }
static int lm4857_set_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct lm4857 *lm4857 = snd_soc_codec_get_drvdata(codec); uint8_t value = ucontrol->value.integer.value[0]; lm4857->mode = value; if (codec->dapm.bias_level == SND_SOC_BIAS_ON) regmap_update_bits(lm4857->regmap, LM4857_CTRL, 0x0F, value + 6); return 1; }
static int speaker_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg; reg = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); if (reg & WM9081_SPK_MODE) ucontrol->value.integer.value[0] = 1; else ucontrol->value.integer.value[0] = 0; return 0; }
static int eqmode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg; reg = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF); if (reg & WM8985_EQ3DMODE) ucontrol->value.integer.value[0] = 1; else ucontrol->value.integer.value[0] = 0; return 0; }
static int adav80x_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); unsigned int deemph = ucontrol->value.enumerated.item[0]; if (deemph > 1) return -EINVAL; adav80x->deemph = deemph; return adav80x_set_deemph(codec); }
static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); int deemph = ucontrol->value.integer.value[0]; if (deemph > 1) return -EINVAL; ak4641->deemph = deemph; return ak4641_set_deemph(codec); }
static int txsrc_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec; unsigned int src; codec = snd_soc_kcontrol_codec(kcontrol); src = snd_soc_read(codec, WM8804_SPDTX4); if (src & 0x40) ucontrol->value.integer.value[0] = 1; else ucontrol->value.integer.value[0] = 0; return 0; }
static int txsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec; unsigned int src, txpwr; codec = snd_soc_kcontrol_codec(kcontrol); if (ucontrol->value.integer.value[0] != 0 && ucontrol->value.integer.value[0] != 1) return -EINVAL; src = snd_soc_read(codec, WM8804_SPDTX4); switch ((src & 0x40) >> 6) { case 0: if (!ucontrol->value.integer.value[0]) return 0; break; case 1: if (ucontrol->value.integer.value[1]) return 0; break; } /* save the current power state of the transmitter */ txpwr = snd_soc_read(codec, WM8804_PWRDN) & 0x4; /* power down the transmitter */ snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x4); /* set the tx source */ snd_soc_update_bits(codec, WM8804_SPDTX4, 0x40, ucontrol->value.integer.value[0] << 6); if (ucontrol->value.integer.value[0]) { /* power down the receiver */ snd_soc_update_bits(codec, WM8804_PWRDN, 0x2, 0x2); /* power up the AIF */ snd_soc_update_bits(codec, WM8804_PWRDN, 0x10, 0); } else { /* don't power down the AIF -- may be used as an output */ /* power up the receiver */ snd_soc_update_bits(codec, WM8804_PWRDN, 0x2, 0); } /* restore the transmitter's configuration */ snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, txpwr); return 0; }
static int snd_wl1273_fm_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); int r; dev_dbg(codec->dev, "%s: enter.\n", __func__); r = wl1273->core->set_volume(wl1273->core, ucontrol->value.integer.value[0]); if (r) return r; return 1; }
static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); int reg = kcontrol->private_value & 0xff; int ret; u16 val; ret = snd_soc_put_volsw(kcontrol, ucontrol); if (ret < 0) return ret; /* now hit the volume update bits (always bit 8) */ val = snd_soc_read(codec, reg); return snd_soc_write(codec, reg, val | 0x0100); }