diff options
Diffstat (limited to 'sound/soc/codecs/lpass-rx-macro.c')
| -rw-r--r-- | sound/soc/codecs/lpass-rx-macro.c | 116 |
1 files changed, 56 insertions, 60 deletions
diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index a8fc842cc94e..0a8de5620e72 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -1682,7 +1682,7 @@ static const struct regmap_config rx_regmap_config = { static int rx_macro_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct rx_macro *rx = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; @@ -1905,52 +1905,48 @@ static int rx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream) { struct snd_soc_component *component = dai->component; struct rx_macro *rx = snd_soc_component_get_drvdata(component); - uint16_t j, reg, mix_reg, dsm_reg; - u16 int_mux_cfg0, int_mux_cfg1; + u32 port, j, reg, mix_reg, int_mux_cfg0, int_mux_cfg1; + u32 mask, val; u8 int_mux_cfg0_val, int_mux_cfg1_val; - switch (dai->id) { - case RX_MACRO_AIF1_PB: - case RX_MACRO_AIF2_PB: - case RX_MACRO_AIF3_PB: - case RX_MACRO_AIF4_PB: - for (j = 0; j < INTERP_MAX; j++) { - reg = CDC_RX_RXn_RX_PATH_CTL(rx, j); - mix_reg = CDC_RX_RXn_RX_PATH_MIX_CTL(rx, j); - dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(rx, j); - - if (mute) { - snd_soc_component_update_bits(component, reg, - CDC_RX_PATH_PGA_MUTE_MASK, - CDC_RX_PATH_PGA_MUTE_ENABLE); - snd_soc_component_update_bits(component, mix_reg, - CDC_RX_PATH_PGA_MUTE_MASK, - CDC_RX_PATH_PGA_MUTE_ENABLE); - } else { - snd_soc_component_update_bits(component, reg, - CDC_RX_PATH_PGA_MUTE_MASK, 0x0); - snd_soc_component_update_bits(component, mix_reg, - CDC_RX_PATH_PGA_MUTE_MASK, 0x0); + if (stream != SNDRV_PCM_STREAM_PLAYBACK) + return 0; + + for (j = 0; j < INTERP_MAX; j++) { + reg = CDC_RX_RXn_RX_PATH_CTL(rx, j); + mix_reg = CDC_RX_RXn_RX_PATH_MIX_CTL(rx, j); + + mask = CDC_RX_PATH_PGA_MUTE_MASK; + val = 0; + if (mute) + val |= CDC_RX_PATH_PGA_MUTE_ENABLE; + if (rx->main_clk_users[j] > 0) { + mask |= CDC_RX_PATH_CLK_EN_MASK; + val |= CDC_RX_PATH_CLK_ENABLE; + } + + int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0 + j * 8; + int_mux_cfg1 = int_mux_cfg0 + 4; + int_mux_cfg0_val = snd_soc_component_read(component, int_mux_cfg0); + int_mux_cfg1_val = snd_soc_component_read(component, int_mux_cfg1); + + for_each_set_bit(port, &rx->active_ch_mask[dai->id], RX_MACRO_PORTS_MAX) { + if (((int_mux_cfg0_val & 0x0f) == port + INTn_1_INP_SEL_RX0) || + ((int_mux_cfg0_val >> 4) == port + INTn_1_INP_SEL_RX0) || + ((int_mux_cfg1_val >> 4) == port + INTn_1_INP_SEL_RX0)) { + snd_soc_component_update_bits(component, reg, mask, val); } - int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0 + j * 8; - int_mux_cfg1 = int_mux_cfg0 + 4; - int_mux_cfg0_val = snd_soc_component_read(component, int_mux_cfg0); - int_mux_cfg1_val = snd_soc_component_read(component, int_mux_cfg1); - - if (snd_soc_component_read(component, dsm_reg) & 0x01) { - if (int_mux_cfg0_val || (int_mux_cfg1_val & 0xF0)) - snd_soc_component_update_bits(component, reg, 0x20, 0x20); - if (int_mux_cfg1_val & 0x0F) { - snd_soc_component_update_bits(component, reg, 0x20, 0x20); - snd_soc_component_update_bits(component, mix_reg, 0x20, - 0x20); + if ((int_mux_cfg1_val & 0x0f) == port + INTn_2_INP_SEL_RX0) { + snd_soc_component_update_bits(component, mix_reg, mask, val); + /* main clock needs to be enabled for mix to be useful: */ + if (rx->main_clk_users[j] > 0) { + snd_soc_component_update_bits(component, reg, + CDC_RX_PATH_CLK_EN_MASK, + CDC_RX_PATH_CLK_ENABLE); } } } - break; - default: - break; } return 0; } @@ -2434,8 +2430,7 @@ static void rx_macro_hd2_control(struct snd_soc_component *component, static int rx_macro_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; struct rx_macro *rx = snd_soc_component_get_drvdata(component); @@ -2446,7 +2441,7 @@ static int rx_macro_get_compander(struct snd_kcontrol *kcontrol, static int rx_macro_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; struct rx_macro *rx = snd_soc_component_get_drvdata(component); @@ -2459,7 +2454,7 @@ static int rx_macro_set_compander(struct snd_kcontrol *kcontrol, static int rx_macro_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct rx_macro *rx = snd_soc_component_get_drvdata(component); @@ -2471,7 +2466,7 @@ static int rx_macro_mux_get(struct snd_kcontrol *kcontrol, static int rx_macro_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update *update = NULL; @@ -2548,7 +2543,7 @@ static const struct snd_kcontrol_new rx_macro_rx5_mux = static int rx_macro_get_ear_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rx->is_ear_mode_on; @@ -2558,7 +2553,7 @@ static int rx_macro_get_ear_mode(struct snd_kcontrol *kcontrol, static int rx_macro_put_ear_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); rx->is_ear_mode_on = (!ucontrol->value.integer.value[0] ? false : true); @@ -2568,7 +2563,7 @@ static int rx_macro_put_ear_mode(struct snd_kcontrol *kcontrol, static int rx_macro_get_hph_hd2_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rx->hph_hd2_mode; @@ -2578,7 +2573,7 @@ static int rx_macro_get_hph_hd2_mode(struct snd_kcontrol *kcontrol, static int rx_macro_put_hph_hd2_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); rx->hph_hd2_mode = ucontrol->value.integer.value[0]; @@ -2588,7 +2583,7 @@ static int rx_macro_put_hph_hd2_mode(struct snd_kcontrol *kcontrol, static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = rx->hph_pwr_mode; @@ -2598,7 +2593,7 @@ static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol, static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); rx->hph_pwr_mode = ucontrol->value.enumerated.item[0]; @@ -2608,7 +2603,7 @@ static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol, static int rx_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rx->is_softclip_on; @@ -2619,7 +2614,7 @@ static int rx_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, static int rx_macro_soft_clip_enable_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); rx->is_softclip_on = ucontrol->value.integer.value[0]; @@ -2630,7 +2625,7 @@ static int rx_macro_soft_clip_enable_put(struct snd_kcontrol *kcontrol, static int rx_macro_aux_hpf_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rx->is_aux_hpf_on; @@ -2641,7 +2636,7 @@ static int rx_macro_aux_hpf_mode_get(struct snd_kcontrol *kcontrol, static int rx_macro_aux_hpf_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); rx->is_aux_hpf_on = ucontrol->value.integer.value[0]; @@ -2930,8 +2925,7 @@ static int rx_macro_put_iir_band_audio_mixer( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd_iir_filter_ctl *ctl = (struct wcd_iir_filter_ctl *)kcontrol->private_value; struct soc_bytes_ext *params = &ctl->bytes_ext; @@ -2959,8 +2953,7 @@ static int rx_macro_put_iir_band_audio_mixer( static int rx_macro_get_iir_band_audio_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd_iir_filter_ctl *ctl = (struct wcd_iir_filter_ctl *)kcontrol->private_value; struct soc_bytes_ext *params = &ctl->bytes_ext; @@ -3612,7 +3605,7 @@ static const struct snd_soc_dapm_route rx_audio_map[] = { static int rx_macro_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rx_macro *rx = snd_soc_component_get_drvdata(component); const struct snd_soc_dapm_widget *widgets; const struct snd_kcontrol_new *controls; @@ -3955,6 +3948,9 @@ static const struct of_device_id rx_macro_dt_match[] = { .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, }, { + .compatible = "qcom,sm6115-lpass-rx-macro", + .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, + }, { .compatible = "qcom,sm8250-lpass-rx-macro", .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, }, { |
