Loading sound/soc/codecs/wcd9335.c +65 −7 Original line number Diff line number Diff line Loading @@ -79,6 +79,8 @@ #define TASHA_SLIM_PGD_PORT_INT_TX_EN0 (TASHA_SLIM_PGD_PORT_INT_EN0 + 2) #define TASHA_NUM_INTERPOLATORS 9 #define TASHA_NUM_DECIMATORS 9 #define BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE)) #define TASHA_MAD_AUDIO_FIRMWARE_PATH "wcd9335/wcd9335_mad_audio.bin" #define TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS (1 << 0) Loading Loading @@ -621,6 +623,13 @@ struct wcd_vbat { u16 dcp2; }; struct hpf_work { struct tasha_priv *tasha; u8 decimator; u8 hpf_cut_off_freq; struct delayed_work dwork; }; struct tasha_priv { struct device *dev; struct wcd9xxx *wcd9xxx; Loading Loading @@ -731,6 +740,7 @@ struct tasha_priv { int (*machine_codec_event_cb)(struct snd_soc_codec *codec, enum wcd9335_codec_event); int spkr_mode; struct hpf_work tx_hpf_work[TASHA_NUM_DECIMATORS]; }; static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec, Loading Loading @@ -4554,6 +4564,36 @@ static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic) #define CF_MIN_3DB_75HZ 0x1 #define CF_MIN_3DB_150HZ 0x2 static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work) { struct delayed_work *hpf_delayed_work; struct hpf_work *hpf_work; struct tasha_priv *tasha; struct snd_soc_codec *codec; u16 dec_cfg_reg, amic_reg; u8 hpf_cut_off_freq; int amic_n; hpf_delayed_work = to_delayed_work(work); hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); tasha = hpf_work->tasha; codec = tasha->codec; hpf_cut_off_freq = hpf_work->hpf_cut_off_freq; dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator; dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", __func__, hpf_work->decimator, hpf_cut_off_freq); amic_n = tasha_codec_find_amic_input(codec, hpf_work->decimator); if (amic_n) { amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1; tasha_codec_set_tx_hold(codec, amic_reg, false); } snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, hpf_cut_off_freq << 5); } static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { Loading @@ -4563,8 +4603,10 @@ static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, char *widget_name = NULL; char *wname; int ret = 0, amic_n; u16 tx_vol_ctl_reg, amic_reg, pwr_level_reg = 0, dec_cfg_reg; u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg; char *dec; u8 hpf_cut_off_freq; struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); dev_dbg(codec->dev, "%s %d\n", __func__, event); Loading Loading @@ -4635,21 +4677,30 @@ static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, break; } } hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) & TX_HPF_CUT_OFF_FREQ_MASK) >> 5; tasha->tx_hpf_work[decimator].hpf_cut_off_freq = hpf_cut_off_freq; if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, CF_MIN_3DB_150HZ << 5); /* Enable TX PGA Mute */ snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMU: /* Remove Mute */ snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); amic_n = tasha_codec_find_amic_input(codec, decimator); if (amic_n) { amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1; tasha_codec_set_tx_hold(codec, amic_reg, false); } if (tasha->tx_hpf_work[decimator].hpf_cut_off_freq != CF_MIN_3DB_150HZ) schedule_delayed_work( &tasha->tx_hpf_work[decimator].dwork, msecs_to_jiffies(300)); break; case SND_SOC_DAPM_PRE_PMD: snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); cancel_delayed_work_sync(&tasha->tx_hpf_work[decimator].dwork); break; case SND_SOC_DAPM_POST_PMD: snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); Loading Loading @@ -11504,6 +11555,13 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) ret = 0; } for (i = 0; i < TASHA_NUM_DECIMATORS; i++) { tasha->tx_hpf_work[i].tasha = tasha; tasha->tx_hpf_work[i].decimator = i; INIT_DELAYED_WORK(&tasha->tx_hpf_work[i].dwork, tasha_tx_hpf_corner_freq_callback); } mutex_lock(&codec->mutex); snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1"); snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2"); Loading Loading
sound/soc/codecs/wcd9335.c +65 −7 Original line number Diff line number Diff line Loading @@ -79,6 +79,8 @@ #define TASHA_SLIM_PGD_PORT_INT_TX_EN0 (TASHA_SLIM_PGD_PORT_INT_EN0 + 2) #define TASHA_NUM_INTERPOLATORS 9 #define TASHA_NUM_DECIMATORS 9 #define BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE)) #define TASHA_MAD_AUDIO_FIRMWARE_PATH "wcd9335/wcd9335_mad_audio.bin" #define TASHA_CPE_SS_ERR_STATUS_MEM_ACCESS (1 << 0) Loading Loading @@ -621,6 +623,13 @@ struct wcd_vbat { u16 dcp2; }; struct hpf_work { struct tasha_priv *tasha; u8 decimator; u8 hpf_cut_off_freq; struct delayed_work dwork; }; struct tasha_priv { struct device *dev; struct wcd9xxx *wcd9xxx; Loading Loading @@ -731,6 +740,7 @@ struct tasha_priv { int (*machine_codec_event_cb)(struct snd_soc_codec *codec, enum wcd9335_codec_event); int spkr_mode; struct hpf_work tx_hpf_work[TASHA_NUM_DECIMATORS]; }; static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec, Loading Loading @@ -4554,6 +4564,36 @@ static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic) #define CF_MIN_3DB_75HZ 0x1 #define CF_MIN_3DB_150HZ 0x2 static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work) { struct delayed_work *hpf_delayed_work; struct hpf_work *hpf_work; struct tasha_priv *tasha; struct snd_soc_codec *codec; u16 dec_cfg_reg, amic_reg; u8 hpf_cut_off_freq; int amic_n; hpf_delayed_work = to_delayed_work(work); hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); tasha = hpf_work->tasha; codec = tasha->codec; hpf_cut_off_freq = hpf_work->hpf_cut_off_freq; dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator; dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", __func__, hpf_work->decimator, hpf_cut_off_freq); amic_n = tasha_codec_find_amic_input(codec, hpf_work->decimator); if (amic_n) { amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1; tasha_codec_set_tx_hold(codec, amic_reg, false); } snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, hpf_cut_off_freq << 5); } static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { Loading @@ -4563,8 +4603,10 @@ static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, char *widget_name = NULL; char *wname; int ret = 0, amic_n; u16 tx_vol_ctl_reg, amic_reg, pwr_level_reg = 0, dec_cfg_reg; u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg; char *dec; u8 hpf_cut_off_freq; struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); dev_dbg(codec->dev, "%s %d\n", __func__, event); Loading Loading @@ -4635,21 +4677,30 @@ static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, break; } } hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) & TX_HPF_CUT_OFF_FREQ_MASK) >> 5; tasha->tx_hpf_work[decimator].hpf_cut_off_freq = hpf_cut_off_freq; if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, CF_MIN_3DB_150HZ << 5); /* Enable TX PGA Mute */ snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMU: /* Remove Mute */ snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); amic_n = tasha_codec_find_amic_input(codec, decimator); if (amic_n) { amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1; tasha_codec_set_tx_hold(codec, amic_reg, false); } if (tasha->tx_hpf_work[decimator].hpf_cut_off_freq != CF_MIN_3DB_150HZ) schedule_delayed_work( &tasha->tx_hpf_work[decimator].dwork, msecs_to_jiffies(300)); break; case SND_SOC_DAPM_PRE_PMD: snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); cancel_delayed_work_sync(&tasha->tx_hpf_work[decimator].dwork); break; case SND_SOC_DAPM_POST_PMD: snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); Loading Loading @@ -11504,6 +11555,13 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) ret = 0; } for (i = 0; i < TASHA_NUM_DECIMATORS; i++) { tasha->tx_hpf_work[i].tasha = tasha; tasha->tx_hpf_work[i].decimator = i; INIT_DELAYED_WORK(&tasha->tx_hpf_work[i].dwork, tasha_tx_hpf_corner_freq_callback); } mutex_lock(&codec->mutex); snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT1"); snd_soc_dapm_disable_pin(dapm, "ANC LINEOUT2"); Loading