Skip to content

Commit da95e89

Browse files
Chancel Liubroonie
authored andcommitted
ASoC: fsl_micfil: Add a flag to distinguish with different volume control types
On i.MX8MM the register of volume control has positive and negative values. It is different from other platforms like i.MX8MP and i.MX93 which only have positive values. Add a volume_sx flag to use SX_TLV volume control for this kind of platform. Use common TLV volume control for other platforms. Fixes: cdfa92e ("ASoC: fsl_micfil: Correct the number of steps on SX controls") Signed-off-by: Chancel Liu <[email protected]> Reviewed-by: Daniel Baluta <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 9fc9ef0 commit da95e89

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

sound/soc/fsl/fsl_micfil.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct fsl_micfil_soc_data {
6767
bool imx;
6868
bool use_edma;
6969
bool use_verid;
70+
bool volume_sx;
7071
u64 formats;
7172
};
7273

@@ -76,6 +77,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx8mm = {
7677
.fifo_depth = 8,
7778
.dataline = 0xf,
7879
.formats = SNDRV_PCM_FMTBIT_S16_LE,
80+
.volume_sx = true,
7981
};
8082

8183
static struct fsl_micfil_soc_data fsl_micfil_imx8mp = {
@@ -84,6 +86,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx8mp = {
8486
.fifo_depth = 32,
8587
.dataline = 0xf,
8688
.formats = SNDRV_PCM_FMTBIT_S32_LE,
89+
.volume_sx = false,
8790
};
8891

8992
static struct fsl_micfil_soc_data fsl_micfil_imx93 = {
@@ -94,6 +97,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx93 = {
9497
.formats = SNDRV_PCM_FMTBIT_S32_LE,
9598
.use_edma = true,
9699
.use_verid = true,
100+
.volume_sx = false,
97101
};
98102

99103
static const struct of_device_id fsl_micfil_dt_ids[] = {
@@ -317,7 +321,26 @@ static int hwvad_detected(struct snd_kcontrol *kcontrol,
317321
return 0;
318322
}
319323

320-
static const struct snd_kcontrol_new fsl_micfil_snd_controls[] = {
324+
static const struct snd_kcontrol_new fsl_micfil_volume_controls[] = {
325+
SOC_SINGLE_TLV("CH0 Volume", REG_MICFIL_OUT_CTRL,
326+
MICFIL_OUTGAIN_CHX_SHIFT(0), 0xF, 0, gain_tlv),
327+
SOC_SINGLE_TLV("CH1 Volume", REG_MICFIL_OUT_CTRL,
328+
MICFIL_OUTGAIN_CHX_SHIFT(1), 0xF, 0, gain_tlv),
329+
SOC_SINGLE_TLV("CH2 Volume", REG_MICFIL_OUT_CTRL,
330+
MICFIL_OUTGAIN_CHX_SHIFT(2), 0xF, 0, gain_tlv),
331+
SOC_SINGLE_TLV("CH3 Volume", REG_MICFIL_OUT_CTRL,
332+
MICFIL_OUTGAIN_CHX_SHIFT(3), 0xF, 0, gain_tlv),
333+
SOC_SINGLE_TLV("CH4 Volume", REG_MICFIL_OUT_CTRL,
334+
MICFIL_OUTGAIN_CHX_SHIFT(4), 0xF, 0, gain_tlv),
335+
SOC_SINGLE_TLV("CH5 Volume", REG_MICFIL_OUT_CTRL,
336+
MICFIL_OUTGAIN_CHX_SHIFT(5), 0xF, 0, gain_tlv),
337+
SOC_SINGLE_TLV("CH6 Volume", REG_MICFIL_OUT_CTRL,
338+
MICFIL_OUTGAIN_CHX_SHIFT(6), 0xF, 0, gain_tlv),
339+
SOC_SINGLE_TLV("CH7 Volume", REG_MICFIL_OUT_CTRL,
340+
MICFIL_OUTGAIN_CHX_SHIFT(7), 0xF, 0, gain_tlv),
341+
};
342+
343+
static const struct snd_kcontrol_new fsl_micfil_volume_sx_controls[] = {
321344
SOC_SINGLE_SX_TLV("CH0 Volume", REG_MICFIL_OUT_CTRL,
322345
MICFIL_OUTGAIN_CHX_SHIFT(0), 0x8, 0xF, gain_tlv),
323346
SOC_SINGLE_SX_TLV("CH1 Volume", REG_MICFIL_OUT_CTRL,
@@ -334,6 +357,9 @@ static const struct snd_kcontrol_new fsl_micfil_snd_controls[] = {
334357
MICFIL_OUTGAIN_CHX_SHIFT(6), 0x8, 0xF, gain_tlv),
335358
SOC_SINGLE_SX_TLV("CH7 Volume", REG_MICFIL_OUT_CTRL,
336359
MICFIL_OUTGAIN_CHX_SHIFT(7), 0x8, 0xF, gain_tlv),
360+
};
361+
362+
static const struct snd_kcontrol_new fsl_micfil_snd_controls[] = {
337363
SOC_ENUM_EXT("MICFIL Quality Select",
338364
fsl_micfil_quality_enum,
339365
micfil_quality_get, micfil_quality_set),
@@ -801,6 +827,20 @@ static int fsl_micfil_dai_probe(struct snd_soc_dai *cpu_dai)
801827
return 0;
802828
}
803829

830+
static int fsl_micfil_component_probe(struct snd_soc_component *component)
831+
{
832+
struct fsl_micfil *micfil = snd_soc_component_get_drvdata(component);
833+
834+
if (micfil->soc->volume_sx)
835+
snd_soc_add_component_controls(component, fsl_micfil_volume_sx_controls,
836+
ARRAY_SIZE(fsl_micfil_volume_sx_controls));
837+
else
838+
snd_soc_add_component_controls(component, fsl_micfil_volume_controls,
839+
ARRAY_SIZE(fsl_micfil_volume_controls));
840+
841+
return 0;
842+
}
843+
804844
static const struct snd_soc_dai_ops fsl_micfil_dai_ops = {
805845
.probe = fsl_micfil_dai_probe,
806846
.startup = fsl_micfil_startup,
@@ -821,6 +861,7 @@ static struct snd_soc_dai_driver fsl_micfil_dai = {
821861

822862
static const struct snd_soc_component_driver fsl_micfil_component = {
823863
.name = "fsl-micfil-dai",
864+
.probe = fsl_micfil_component_probe,
824865
.controls = fsl_micfil_snd_controls,
825866
.num_controls = ARRAY_SIZE(fsl_micfil_snd_controls),
826867
.legacy_dai_naming = 1,

0 commit comments

Comments
 (0)