From: Stuart Henderson Date: Wed, 26 Apr 2017 16:45:45 +0000 (+0100) Subject: ASoC: madera: Add Rate ALSA controls X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6cf4f6e1cae44d66dc826fdc5742876883372eec;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git ASoC: madera: Add Rate ALSA controls Change-Id: I9536b12cc4f12505aeab8819917f17efd579cb66 Signed-off-by: Stuart Henderson --- diff --git a/sound/soc/codecs/cs47l35.c b/sound/soc/codecs/cs47l35.c index 1e2ccc57273a..159a1768e9f8 100644 --- a/sound/soc/codecs/cs47l35.c +++ b/sound/soc/codecs/cs47l35.c @@ -193,6 +193,14 @@ static int cs47l35_hp_ev(struct snd_soc_dapm_widget *w, } } +static const struct soc_enum cs47l35_input_rate = + SOC_VALUE_ENUM_SINGLE(MADERA_INPUT_RATE, + MADERA_IN_RATE_SHIFT, + 0x0f, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val); + static const struct snd_kcontrol_new cs47l35_snd_controls[] = { SOC_ENUM("IN1 OSR", madera_in_dmic_osr[0]), SOC_ENUM("IN2 OSR", madera_in_dmic_osr[1]), @@ -310,6 +318,8 @@ SOC_ENUM("LHPF4 Mode", madera_lhpf4_mode), SOC_ENUM("Sample Rate 2", madera_sample_rate[0]), SOC_ENUM("Sample Rate 3", madera_sample_rate[1]), +MADERA_RATE_ENUM("FX Rate", madera_fx_rate), + MADERA_RATE_ENUM("ISRC1 FSL", madera_isrc_fsl[0]), MADERA_RATE_ENUM("ISRC2 FSL", madera_isrc_fsl[1]), MADERA_RATE_ENUM("ISRC1 FSH", madera_isrc_fsh[0]), @@ -371,12 +381,17 @@ SOC_SINGLE("Speaker THR1 EDRE Switch", MADERA_EDRE_ENABLE, SOC_ENUM("Output Ramp Up", madera_out_vi_ramp), SOC_ENUM("Output Ramp Down", madera_out_vd_ramp), +MADERA_RATE_ENUM("SPDIF1 Rate", madera_spdif_rate), + SOC_SINGLE("Noise Gate Switch", MADERA_NOISE_GATE_CONTROL, MADERA_NGATE_ENA_SHIFT, 1, 0), SOC_SINGLE_TLV("Noise Gate Threshold Volume", MADERA_NOISE_GATE_CONTROL, MADERA_NGATE_THR_SHIFT, 7, 1, madera_ng_tlv), SOC_ENUM("Noise Gate Hold", madera_ng_hold), +MADERA_RATE_ENUM("Output Rate 1", madera_output_rate), +SOC_ENUM("In Rate", cs47l35_input_rate), + CS47L35_NG_SRC("HPOUT1L", MADERA_NOISE_GATE_SELECT_1L), CS47L35_NG_SRC("HPOUT1R", MADERA_NOISE_GATE_SELECT_1R), CS47L35_NG_SRC("SPKOUT", MADERA_NOISE_GATE_SELECT_4L), diff --git a/sound/soc/codecs/cs47l85.c b/sound/soc/codecs/cs47l85.c index 35f19caaa65b..c32e21b3aacc 100644 --- a/sound/soc/codecs/cs47l85.c +++ b/sound/soc/codecs/cs47l85.c @@ -254,6 +254,14 @@ static int cs47l85_hp_ev(struct snd_soc_dapm_widget *w, } } +static const struct soc_enum cs47l85_input_rate = + SOC_VALUE_ENUM_SINGLE(MADERA_INPUT_RATE, + MADERA_IN_RATE_SHIFT, + 0x0f, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val); + static const struct snd_kcontrol_new cs47l85_snd_controls[] = { SOC_ENUM("IN1 OSR", madera_in_dmic_osr[0]), SOC_ENUM("IN2 OSR", madera_in_dmic_osr[1]), @@ -421,6 +429,8 @@ SOC_ENUM("Sample Rate 2", madera_sample_rate[0]), SOC_ENUM("Sample Rate 3", madera_sample_rate[1]), SOC_ENUM("ASYNC Sample Rate 2", madera_sample_rate[2]), +MADERA_RATE_ENUM("FX Rate", madera_fx_rate), + MADERA_RATE_ENUM("ISRC1 FSL", madera_isrc_fsl[0]), MADERA_RATE_ENUM("ISRC2 FSL", madera_isrc_fsl[1]), MADERA_RATE_ENUM("ISRC3 FSL", madera_isrc_fsl[2]), @@ -532,12 +542,17 @@ SOC_DOUBLE("HPOUT3 EDRE Switch", MADERA_EDRE_ENABLE, SOC_ENUM("Output Ramp Up", madera_out_vi_ramp), SOC_ENUM("Output Ramp Down", madera_out_vd_ramp), +MADERA_RATE_ENUM("SPDIF1 Rate", madera_spdif_rate), + SOC_SINGLE("Noise Gate Switch", MADERA_NOISE_GATE_CONTROL, MADERA_NGATE_ENA_SHIFT, 1, 0), SOC_SINGLE_TLV("Noise Gate Threshold Volume", MADERA_NOISE_GATE_CONTROL, MADERA_NGATE_THR_SHIFT, 7, 1, madera_ng_tlv), SOC_ENUM("Noise Gate Hold", madera_ng_hold), +MADERA_RATE_ENUM("Output Rate 1", madera_output_rate), +SOC_ENUM("In Rate", cs47l85_input_rate), + CS47L85_NG_SRC("HPOUT1L", MADERA_NOISE_GATE_SELECT_1L), CS47L85_NG_SRC("HPOUT1R", MADERA_NOISE_GATE_SELECT_1R), CS47L85_NG_SRC("HPOUT2L", MADERA_NOISE_GATE_SELECT_2L), diff --git a/sound/soc/codecs/cs47l90.c b/sound/soc/codecs/cs47l90.c index 18a5dce7675c..04441dd38bf6 100644 --- a/sound/soc/codecs/cs47l90.c +++ b/sound/soc/codecs/cs47l90.c @@ -344,6 +344,8 @@ SOC_ENUM("Sample Rate 2", madera_sample_rate[0]), SOC_ENUM("Sample Rate 3", madera_sample_rate[1]), SOC_ENUM("ASYNC Sample Rate 2", madera_sample_rate[2]), +MADERA_RATE_ENUM("FX Rate", madera_fx_rate), + MADERA_RATE_ENUM("ISRC1 FSL", madera_isrc_fsl[0]), MADERA_RATE_ENUM("ISRC2 FSL", madera_isrc_fsl[1]), MADERA_RATE_ENUM("ISRC3 FSL", madera_isrc_fsl[2]), @@ -432,12 +434,37 @@ SOC_DOUBLE("HPOUT3 EDRE Switch", MADERA_EDRE_ENABLE, SOC_ENUM("Output Ramp Up", madera_out_vi_ramp), SOC_ENUM("Output Ramp Down", madera_out_vd_ramp), +MADERA_RATE_ENUM("SPDIF1 Rate", madera_spdif_rate), + SOC_SINGLE("Noise Gate Switch", MADERA_NOISE_GATE_CONTROL, MADERA_NGATE_ENA_SHIFT, 1, 0), SOC_SINGLE_TLV("Noise Gate Threshold Volume", MADERA_NOISE_GATE_CONTROL, MADERA_NGATE_THR_SHIFT, 7, 1, madera_ng_tlv), SOC_ENUM("Noise Gate Hold", madera_ng_hold), +MADERA_RATE_ENUM("Output Rate 1", madera_output_rate), + +SOC_ENUM_EXT("IN1L Rate", madera_input_rate[0], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN1R Rate", madera_input_rate[1], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN2L Rate", madera_input_rate[2], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN2R Rate", madera_input_rate[3], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN3L Rate", madera_input_rate[4], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN3R Rate", madera_input_rate[5], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN4L Rate", madera_input_rate[6], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN4R Rate", madera_input_rate[7], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN5L Rate", madera_input_rate[8], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN5R Rate", madera_input_rate[9], + snd_soc_get_enum_double, madera_in_rate_put), + SOC_ENUM_EXT("DFC1RX Width", madera_dfc_width[0], snd_soc_get_enum_double, madera_dfc_put), SOC_ENUM_EXT("DFC1RX Type", madera_dfc_type[0], diff --git a/sound/soc/codecs/cs47l92.c b/sound/soc/codecs/cs47l92.c index 269a1036a92f..ea956ab3c54b 100644 --- a/sound/soc/codecs/cs47l92.c +++ b/sound/soc/codecs/cs47l92.c @@ -364,6 +364,8 @@ SOC_ENUM("Sample Rate 2", madera_sample_rate[0]), SOC_ENUM("Sample Rate 3", madera_sample_rate[1]), SOC_ENUM("ASYNC Sample Rate 2", madera_sample_rate[2]), +MADERA_RATE_ENUM("FX Rate", madera_fx_rate), + MADERA_RATE_ENUM("ISRC1 FSL", madera_isrc_fsl[0]), MADERA_RATE_ENUM("ISRC2 FSL", madera_isrc_fsl[1]), MADERA_RATE_ENUM("ISRC1 FSH", madera_isrc_fsh[0]), @@ -438,12 +440,33 @@ SOC_DOUBLE("HPOUT3 EDRE Switch", MADERA_EDRE_ENABLE, SOC_ENUM("Output Ramp Up", madera_out_vi_ramp), SOC_ENUM("Output Ramp Down", madera_out_vd_ramp), +MADERA_RATE_ENUM("SPDIF1 Rate", madera_spdif_rate), + SOC_SINGLE("Noise Gate Switch", MADERA_NOISE_GATE_CONTROL, MADERA_NGATE_ENA_SHIFT, 1, 0), SOC_SINGLE_TLV("Noise Gate Threshold Volume", MADERA_NOISE_GATE_CONTROL, MADERA_NGATE_THR_SHIFT, 7, 1, madera_ng_tlv), SOC_ENUM("Noise Gate Hold", madera_ng_hold), +MADERA_RATE_ENUM("Output Rate 1", madera_output_ext_rate), + +SOC_ENUM_EXT("IN1L Rate", madera_input_rate[0], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN1R Rate", madera_input_rate[1], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN2L Rate", madera_input_rate[2], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN2R Rate", madera_input_rate[3], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN3L Rate", madera_input_rate[4], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN3R Rate", madera_input_rate[5], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN4L Rate", madera_input_rate[6], + snd_soc_get_enum_double, madera_in_rate_put), +SOC_ENUM_EXT("IN4R Rate", madera_input_rate[7], + snd_soc_get_enum_double, madera_in_rate_put), + SOC_ENUM_EXT("DFC1RX Width", madera_dfc_width[0], snd_soc_get_enum_double, madera_dfc_put), SOC_ENUM_EXT("DFC1RX Type", madera_dfc_type[0], diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c index cdbcb0858154..4866a9836f77 100644 --- a/sound/soc/codecs/madera.c +++ b/sound/soc/codecs/madera.c @@ -1731,6 +1731,88 @@ const unsigned int madera_rate_val[MADERA_RATE_ENUM_SIZE] = { }; EXPORT_SYMBOL_GPL(madera_rate_val); +const struct soc_enum madera_output_rate = + SOC_VALUE_ENUM_SINGLE(MADERA_OUTPUT_RATE_1, + MADERA_OUT_RATE_SHIFT, + MADERA_OUT_RATE_MASK >> MADERA_OUT_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val); +EXPORT_SYMBOL_GPL(madera_output_rate); + +const struct soc_enum madera_output_ext_rate = + SOC_VALUE_ENUM_SINGLE(MADERA_OUTPUT_RATE_1, + MADERA_OUT_RATE_SHIFT, + MADERA_OUT_RATE_MASK >> MADERA_OUT_RATE_SHIFT, + MADERA_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val); +EXPORT_SYMBOL_GPL(madera_output_ext_rate); + +const struct soc_enum madera_input_rate[] = { + SOC_VALUE_ENUM_SINGLE(MADERA_IN1L_RATE_CONTROL, + MADERA_IN1L_RATE_SHIFT, + MADERA_IN1L_RATE_MASK >> MADERA_IN1L_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val), + SOC_VALUE_ENUM_SINGLE(MADERA_IN1R_RATE_CONTROL, + MADERA_IN1R_RATE_SHIFT, + MADERA_IN1R_RATE_MASK >> MADERA_IN1R_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val), + SOC_VALUE_ENUM_SINGLE(MADERA_IN2L_RATE_CONTROL, + MADERA_IN2L_RATE_SHIFT, + MADERA_IN2L_RATE_MASK >> MADERA_IN2L_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val), + SOC_VALUE_ENUM_SINGLE(MADERA_IN2R_RATE_CONTROL, + MADERA_IN2R_RATE_SHIFT, + MADERA_IN2R_RATE_MASK >> MADERA_IN2R_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val), + SOC_VALUE_ENUM_SINGLE(MADERA_IN3L_RATE_CONTROL, + MADERA_IN3L_RATE_SHIFT, + MADERA_IN3L_RATE_MASK >> MADERA_IN3L_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val), + SOC_VALUE_ENUM_SINGLE(MADERA_IN3R_RATE_CONTROL, + MADERA_IN3R_RATE_SHIFT, + MADERA_IN3R_RATE_MASK >> MADERA_IN3R_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val), + SOC_VALUE_ENUM_SINGLE(MADERA_IN4L_RATE_CONTROL, + MADERA_IN4L_RATE_SHIFT, + MADERA_IN4L_RATE_MASK >> MADERA_IN4L_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val), + SOC_VALUE_ENUM_SINGLE(MADERA_IN4R_RATE_CONTROL, + MADERA_IN4R_RATE_SHIFT, + MADERA_IN4R_RATE_MASK >> MADERA_IN4R_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val), + SOC_VALUE_ENUM_SINGLE(MADERA_IN5L_RATE_CONTROL, + MADERA_IN5L_RATE_SHIFT, + MADERA_IN5L_RATE_MASK >> MADERA_IN5L_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val), + SOC_VALUE_ENUM_SINGLE(MADERA_IN5R_RATE_CONTROL, + MADERA_IN5R_RATE_SHIFT, + MADERA_IN5R_RATE_MASK >> MADERA_IN5R_RATE_SHIFT, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val), +}; +EXPORT_SYMBOL_GPL(madera_input_rate); + const char * const madera_dfc_width_text[MADERA_DFC_WIDTH_ENUM_SIZE] = { "8bit", "16bit", "20bit", "24bit", "32bit", }; @@ -1984,6 +2066,22 @@ const struct soc_enum madera_dfc_type[] = { }; EXPORT_SYMBOL_GPL(madera_dfc_type); +const struct soc_enum madera_fx_rate = + SOC_VALUE_ENUM_SINGLE(MADERA_FX_CTRL1, + MADERA_FX_RATE_SHIFT, 0xf, + MADERA_RATE_ENUM_SIZE, + madera_rate_text, madera_rate_val); +EXPORT_SYMBOL_GPL(madera_fx_rate); + +const struct soc_enum madera_spdif_rate = + SOC_VALUE_ENUM_SINGLE(MADERA_SPD1_TX_CONTROL, + MADERA_SPD1_RATE_SHIFT, + 0x0f, + MADERA_SYNC_RATE_ENUM_SIZE, + madera_rate_text, + madera_rate_val); +EXPORT_SYMBOL_GPL(madera_spdif_rate); + const struct soc_enum madera_isrc_fsh[] = { SOC_VALUE_ENUM_SINGLE(MADERA_ISRC_1_CTRL_1, MADERA_ISRC1_FSH_SHIFT, 0xf, @@ -2264,6 +2362,34 @@ const struct soc_enum madera_output_anc_src[] = { }; EXPORT_SYMBOL_GPL(madera_output_anc_src); +int madera_in_rate_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int reg, mask; + int ret = 0; + + snd_soc_dapm_mutex_lock(dapm); + + /* Cannot change rate on an active input */ + reg = snd_soc_read(codec, MADERA_INPUT_ENABLES); + mask = (e->reg - MADERA_IN1L_CONTROL) / 4; + mask ^= 0x1; /* Flip bottom bit for channel order */ + + if ((reg) & (1 << mask)) { + ret = -EBUSY; + goto exit; + } + + ret = snd_soc_put_enum_double(kcontrol, ucontrol); +exit: + snd_soc_dapm_mutex_unlock(dapm); + return ret; +} +EXPORT_SYMBOL_GPL(madera_in_rate_put); + int madera_dfc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { diff --git a/sound/soc/codecs/madera.h b/sound/soc/codecs/madera.h index 7cb0c1ef60c8..e550ce77e13d 100644 --- a/sound/soc/codecs/madera.h +++ b/sound/soc/codecs/madera.h @@ -351,8 +351,12 @@ extern const struct soc_enum madera_isrc_fsh[]; extern const struct soc_enum madera_asrc1_rate[]; extern const struct soc_enum madera_asrc1_bidir_rate[]; extern const struct soc_enum madera_asrc2_rate[]; +extern const struct soc_enum madera_output_rate; +extern const struct soc_enum madera_output_ext_rate; +extern const struct soc_enum madera_input_rate[]; extern const struct soc_enum madera_dfc_width[]; extern const struct soc_enum madera_dfc_type[]; +extern const struct soc_enum madera_fx_rate; extern const struct soc_enum madera_spdif_rate; extern const struct soc_enum madera_in_vi_ramp; @@ -386,6 +390,8 @@ int madera_dfc_put(struct snd_kcontrol *kcontrol, int madera_lp_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int madera_in_rate_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); int madera_out1_demux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);