Skip to contentSkip to conversation

ASoC: fsl_micfil: Set default quality and channel range control

PATCH In review Chancel Liu 3 participants 6 messages Nov 27, 2025 – Nov 29, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover ASoC: fsl_micfil: Set default quality and channel range control

Add default quality for different platforms.
Set channel range control.

changes in v2
- use snd_kcontrol_chip() instead of snd_soc_kcontrol_component()

Chancel Liu (2):
ASoC: fsl_micfil: Add default quality for different platforms
ASoC: fsl_micfil: Set channel range control

 sound/soc/fsl/fsl_micfil.c | 132 ++++++++++++++++++++++++++++++-------
 1 file changed, 109 insertions(+), 23 deletions(-)
Signature · 1 line
2.50.1
#1 lore raw

PATCH v2 1/2 ASoC: fsl_micfil: Add default quality for different platforms

Add a default quality flag in soc data. For i.MX8MP/93/943 platforms on which range control is constrained, set medium quality by default to achieve better audio performance and wider adjustable range control.

---
 sound/soc/fsl/fsl_micfil.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/fsl/fsl_micfil.c +6 -1
index 1ea543863101..86678fee7a57 100644
@@ -92,6 +92,7 @@ struct fsl_micfil_soc_data {
 	bool volume_sx;
 	u64  formats;
 	int  fifo_offset;
+	enum quality default_quality;
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx8mm = {
@@ -102,6 +103,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx8mm = {
 	.formats = SNDRV_PCM_FMTBIT_S16_LE,
 	.volume_sx = true,
 	.fifo_offset = 0,
+	.default_quality = QUALITY_VLOW0,
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx8mp = {
@@ -112,6 +114,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx8mp = {
 	.formats = SNDRV_PCM_FMTBIT_S32_LE,
 	.volume_sx = false,
 	.fifo_offset = 0,
+	.default_quality = QUALITY_MEDIUM,
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx93 = {
@@ -124,6 +127,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx93 = {
 	.use_verid = true,
 	.volume_sx = false,
 	.fifo_offset = 0,
+	.default_quality = QUALITY_MEDIUM,
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx943 = {
@@ -136,6 +140,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx943 = {
 	.use_verid = true,
 	.volume_sx = false,
 	.fifo_offset = -4,
+	.default_quality = QUALITY_MEDIUM,
 };
 
 static const struct of_device_id fsl_micfil_dt_ids[] = {
@@ -892,7 +897,7 @@ static int fsl_micfil_dai_probe(struct snd_soc_dai *cpu_dai)
 	unsigned int val = 0;
 	int ret, i;
 
-	micfil->quality = QUALITY_VLOW0;
+	micfil->quality = micfil->soc->default_quality;
 	micfil->card = cpu_dai->component->card;
 
 	/* set default gain to 2 */
Signature · 1 line
2.50.1
maintainer Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] ASoC: fsl_micfil: Add default quality for different platforms

Quoted 6 lines · Chancel Liu

Add a default quality flag in soc data. For i.MX8MP/93/943 platforms on which range control is constrained, set medium quality by default to achieve better audio performance and wider adjustable range control.

Best regards
Shengjiu wang

Quoted 60 lines
---
 sound/soc/fsl/fsl_micfil.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/fsl/fsl_micfil.c +6 -2
index 1ea543863101..86678fee7a57 100644
@@ -92,6 +92,7 @@ struct fsl_micfil_soc_data {
        bool volume_sx;
        u64  formats;
        int  fifo_offset;
+       enum quality default_quality;
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx8mm = {
@@ -102,6 +103,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx8mm = {
        .formats = SNDRV_PCM_FMTBIT_S16_LE,
        .volume_sx = true,
        .fifo_offset = 0,
+       .default_quality = QUALITY_VLOW0,
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx8mp = {
@@ -112,6 +114,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx8mp = {
        .formats = SNDRV_PCM_FMTBIT_S32_LE,
        .volume_sx = false,
        .fifo_offset = 0,
+       .default_quality = QUALITY_MEDIUM,
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx93 = {
@@ -124,6 +127,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx93 = {
        .use_verid = true,
        .volume_sx = false,
        .fifo_offset = 0,
+       .default_quality = QUALITY_MEDIUM,
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx943 = {
@@ -136,6 +140,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx943 = {
        .use_verid = true,
        .volume_sx = false,
        .fifo_offset = -4,
+       .default_quality = QUALITY_MEDIUM,
 };
 
 static const struct of_device_id fsl_micfil_dt_ids[] = {
@@ -892,7 +897,7 @@ static int fsl_micfil_dai_probe(struct snd_soc_dai *cpu_dai)
        unsigned int val = 0;
        int ret, i;
 
-       micfil->quality = QUALITY_VLOW0;
+       micfil->quality = micfil->soc->default_quality;
        micfil->card = cpu_dai->component->card;
 
        /* set default gain to 2 */
--

2.50.1

#3 lore raw

PATCH v2 2/2 ASoC: fsl_micfil: Set channel range control

In reply to Chancel Liu

The range control register can't directly adjust volume gain according to specification. It's the dynamic range of the CIC filter. The range value should meet some conditions otherwise the channel data is not reliable. Add an array in soc data to store const value in formula with which range with all quality on different platforms can be calculated. If the value set to range control exceeds the max range there'll be warning logs.

---
 sound/soc/fsl/fsl_micfil.c | 125 ++++++++++++++++++++++++++++++-------
 1 file changed, 103 insertions(+), 22 deletions(-)
sound/soc/fsl/fsl_micfil.c +103 -22
index 86678fee7a57..d6cde2757c6d 100644
@@ -17,6 +17,7 @@
 #include <linux/sysfs.h>
 #include <linux/types.h>
 #include <linux/dma/imx-dma.h>
+#include <linux/log2.h>
 #include <sound/dmaengine_pcm.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -93,6 +94,8 @@ struct fsl_micfil_soc_data {
 	u64  formats;
 	int  fifo_offset;
 	enum quality default_quality;
+	/* stores const value in formula to calculate range */
+	int rangeadj_const[3][2];
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx8mm = {
@@ -115,6 +118,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx8mp = {
 	.volume_sx = false,
 	.fifo_offset = 0,
 	.default_quality = QUALITY_MEDIUM,
+	.rangeadj_const = {{27, 7}, {27, 7}, {26, 7}},
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx93 = {
@@ -128,6 +132,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx93 = {
 	.volume_sx = false,
 	.fifo_offset = 0,
 	.default_quality = QUALITY_MEDIUM,
+	.rangeadj_const = {{30, 6}, {30, 6}, {29, 6}},
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx943 = {
@@ -141,6 +146,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx943 = {
 	.volume_sx = false,
 	.fifo_offset = -4,
 	.default_quality = QUALITY_MEDIUM,
+	.rangeadj_const = {{34, 6}, {34, 6}, {33, 6}},
 };
 
 static const struct of_device_id fsl_micfil_dt_ids[] = {
@@ -167,9 +173,69 @@ static const struct soc_enum fsl_micfil_quality_enum =
 
 static DECLARE_TLV_DB_SCALE(gain_tlv, 0, 100, 0);
 
+static int micfil_get_max_range(struct fsl_micfil *micfil)
+{
+	int max_range;
+
+	switch (micfil->quality) {
+	case QUALITY_HIGH:
+	case QUALITY_VLOW0:
+		max_range = micfil->soc->rangeadj_const[0][0] - micfil->soc->rangeadj_const[0][1] *
+			    ilog2(2 * MICFIL_OSR_DEFAULT);
+		break;
+	case QUALITY_MEDIUM:
+	case QUALITY_VLOW1:
+		max_range = micfil->soc->rangeadj_const[1][0] - micfil->soc->rangeadj_const[1][1] *
+			    ilog2(MICFIL_OSR_DEFAULT);
+		break;
+	case QUALITY_LOW:
+	case QUALITY_VLOW2:
+		max_range = micfil->soc->rangeadj_const[2][0] - micfil->soc->rangeadj_const[2][1] *
+			    ilog2(MICFIL_OSR_DEFAULT);
+		break;
+	default:
+		return 0;
+	}
+	max_range = max_range < 0 ? 0 : max_range;
+
+	return max_range;
+}
+
+static int micfil_range_set(struct snd_kcontrol *kcontrol,
+			    struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol);
+	struct fsl_micfil *micfil = snd_soc_component_get_drvdata(cmpnt);
+	struct soc_mixer_control *mc =
+		(struct soc_mixer_control *)kcontrol->private_value;
+	unsigned int shift = mc->shift;
+	int max_range, new_range;
+
+	new_range = ucontrol->value.integer.value[0];
+	max_range = micfil_get_max_range(micfil);
+	if (new_range > max_range)
+		dev_warn(&micfil->pdev->dev, "range makes channel %d data unreliable\n", shift / 4);
+
+	regmap_update_bits(micfil->regmap, REG_MICFIL_OUT_CTRL, 0xF << shift, new_range << shift);
+
+	return 0;
+}
+
 static int micfil_set_quality(struct fsl_micfil *micfil)
 {
-	u32 qsel;
+	int range, max_range;
+	u32 qsel, val;
+	int i;
+
+	if (!micfil->soc->volume_sx) {
+		regmap_read(micfil->regmap, REG_MICFIL_OUT_CTRL, &val);
+		max_range = micfil_get_max_range(micfil);
+		for (i = 0; i < micfil->soc->fifos; i++) {
+			range = (val >> MICFIL_OUTGAIN_CHX_SHIFT(i)) & 0xF;
+			if (range > max_range)
+				dev_warn(&micfil->pdev->dev, "please reset channel %d range\n", i);
+		}
+	}
 
 	switch (micfil->quality) {
 	case QUALITY_HIGH:
@@ -367,23 +433,31 @@ static int hwvad_detected(struct snd_kcontrol *kcontrol,
 	return 0;
 }
 
-static const struct snd_kcontrol_new fsl_micfil_volume_controls[] = {
-	SOC_SINGLE_TLV("CH0 Volume", REG_MICFIL_OUT_CTRL,
-		       MICFIL_OUTGAIN_CHX_SHIFT(0), 0xF, 0, gain_tlv),
-	SOC_SINGLE_TLV("CH1 Volume", REG_MICFIL_OUT_CTRL,
-		       MICFIL_OUTGAIN_CHX_SHIFT(1), 0xF, 0, gain_tlv),
-	SOC_SINGLE_TLV("CH2 Volume", REG_MICFIL_OUT_CTRL,
-		       MICFIL_OUTGAIN_CHX_SHIFT(2), 0xF, 0, gain_tlv),
-	SOC_SINGLE_TLV("CH3 Volume", REG_MICFIL_OUT_CTRL,
-		       MICFIL_OUTGAIN_CHX_SHIFT(3), 0xF, 0, gain_tlv),
-	SOC_SINGLE_TLV("CH4 Volume", REG_MICFIL_OUT_CTRL,
-		       MICFIL_OUTGAIN_CHX_SHIFT(4), 0xF, 0, gain_tlv),
-	SOC_SINGLE_TLV("CH5 Volume", REG_MICFIL_OUT_CTRL,
-		       MICFIL_OUTGAIN_CHX_SHIFT(5), 0xF, 0, gain_tlv),
-	SOC_SINGLE_TLV("CH6 Volume", REG_MICFIL_OUT_CTRL,
-		       MICFIL_OUTGAIN_CHX_SHIFT(6), 0xF, 0, gain_tlv),
-	SOC_SINGLE_TLV("CH7 Volume", REG_MICFIL_OUT_CTRL,
-		       MICFIL_OUTGAIN_CHX_SHIFT(7), 0xF, 0, gain_tlv),
+static const struct snd_kcontrol_new fsl_micfil_range_controls[] = {
+	SOC_SINGLE_EXT("CH0 Range", REG_MICFIL_OUT_CTRL,
+		       MICFIL_OUTGAIN_CHX_SHIFT(0), 0xF, 0,
+		       snd_soc_get_volsw, micfil_range_set),
+	SOC_SINGLE_EXT("CH1 Range", REG_MICFIL_OUT_CTRL,
+		       MICFIL_OUTGAIN_CHX_SHIFT(1), 0xF, 0,
+		       snd_soc_get_volsw, micfil_range_set),
+	SOC_SINGLE_EXT("CH2 Range", REG_MICFIL_OUT_CTRL,
+		       MICFIL_OUTGAIN_CHX_SHIFT(2), 0xF, 0,
+		       snd_soc_get_volsw, micfil_range_set),
+	SOC_SINGLE_EXT("CH3 Range", REG_MICFIL_OUT_CTRL,
+		       MICFIL_OUTGAIN_CHX_SHIFT(3), 0xF, 0,
+		       snd_soc_get_volsw, micfil_range_set),
+	SOC_SINGLE_EXT("CH4 Range", REG_MICFIL_OUT_CTRL,
+		       MICFIL_OUTGAIN_CHX_SHIFT(4), 0xF, 0,
+		       snd_soc_get_volsw, micfil_range_set),
+	SOC_SINGLE_EXT("CH5 Range", REG_MICFIL_OUT_CTRL,
+		       MICFIL_OUTGAIN_CHX_SHIFT(5), 0xF, 0,
+		       snd_soc_get_volsw, micfil_range_set),
+	SOC_SINGLE_EXT("CH6 Range", REG_MICFIL_OUT_CTRL,
+		       MICFIL_OUTGAIN_CHX_SHIFT(6), 0xF, 0,
+		       snd_soc_get_volsw, micfil_range_set),
+	SOC_SINGLE_EXT("CH7 Range", REG_MICFIL_OUT_CTRL,
+		       MICFIL_OUTGAIN_CHX_SHIFT(7), 0xF, 0,
+		       snd_soc_get_volsw, micfil_range_set),
 };
 
 static const struct snd_kcontrol_new fsl_micfil_volume_sx_controls[] = {
@@ -895,13 +969,20 @@ static int fsl_micfil_dai_probe(struct snd_soc_dai *cpu_dai)
 	struct fsl_micfil *micfil = dev_get_drvdata(cpu_dai->dev);
 	struct device *dev = cpu_dai->dev;
 	unsigned int val = 0;
-	int ret, i;
+	int ret, i, max_range;
 
 	micfil->quality = micfil->soc->default_quality;
 	micfil->card = cpu_dai->component->card;
 
 	/* set default gain to 2 */
-	regmap_write(micfil->regmap, REG_MICFIL_OUT_CTRL, 0x22222222);
+	if (micfil->soc->volume_sx) {
+		regmap_write(micfil->regmap, REG_MICFIL_OUT_CTRL, 0x22222222);
+	} else {
+		max_range = micfil_get_max_range(micfil);
+		for (i = 1; i < micfil->soc->fifos; i++)
+			max_range |= max_range << 4;
+		regmap_write(micfil->regmap, REG_MICFIL_OUT_CTRL, max_range);
+	}
 
 	/* set DC Remover in bypass mode*/
 	for (i = 0; i < MICFIL_OUTPUT_CHANNELS; i++)
@@ -935,8 +1016,8 @@ static int fsl_micfil_component_probe(struct snd_soc_component *component)
 		snd_soc_add_component_controls(component, fsl_micfil_volume_sx_controls,
 					       ARRAY_SIZE(fsl_micfil_volume_sx_controls));
 	else
-		snd_soc_add_component_controls(component, fsl_micfil_volume_controls,
-					       ARRAY_SIZE(fsl_micfil_volume_controls));
+		snd_soc_add_component_controls(component, fsl_micfil_range_controls,
+					       ARRAY_SIZE(fsl_micfil_range_controls));
 
 	return 0;
 }
Signature · 1 line
2.50.1
maintainer Acked-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] ASoC: fsl_micfil: Set channel range control

Quoted 10 lines · Chancel Liu

The range control register can't directly adjust volume gain according to specification. It's the dynamic range of the CIC filter. The range value should meet some conditions otherwise the channel data is not reliable. Add an array in soc data to store const value in formula with which range with all quality on different platforms can be calculated. If the value set to range control exceeds the max range there'll be warning logs.

Best regards
Shengjiu wang

Quoted 206 lines
---
 sound/soc/fsl/fsl_micfil.c | 125 ++++++++++++++++++++++++++++++-------
 1 file changed, 103 insertions(+), 22 deletions(-)
sound/soc/fsl/fsl_micfil.c +103 -23
index 86678fee7a57..d6cde2757c6d 100644
@@ -17,6 +17,7 @@
 #include <linux/sysfs.h>
 #include <linux/types.h>
 #include <linux/dma/imx-dma.h>
+#include <linux/log2.h>
 #include <sound/dmaengine_pcm.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -93,6 +94,8 @@ struct fsl_micfil_soc_data {
        u64  formats;
        int  fifo_offset;
        enum quality default_quality;
+       /* stores const value in formula to calculate range */
+       int rangeadj_const[3][2];
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx8mm = {
@@ -115,6 +118,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx8mp = {
        .volume_sx = false,
        .fifo_offset = 0,
        .default_quality = QUALITY_MEDIUM,
+       .rangeadj_const = {{27, 7}, {27, 7}, {26, 7}},
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx93 = {
@@ -128,6 +132,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx93 = {
        .volume_sx = false,
        .fifo_offset = 0,
        .default_quality = QUALITY_MEDIUM,
+       .rangeadj_const = {{30, 6}, {30, 6}, {29, 6}},
 };
 
 static struct fsl_micfil_soc_data fsl_micfil_imx943 = {
@@ -141,6 +146,7 @@ static struct fsl_micfil_soc_data fsl_micfil_imx943 = {
        .volume_sx = false,
        .fifo_offset = -4,
        .default_quality = QUALITY_MEDIUM,
+       .rangeadj_const = {{34, 6}, {34, 6}, {33, 6}},
 };
 
 static const struct of_device_id fsl_micfil_dt_ids[] = {
@@ -167,9 +173,69 @@ static const struct soc_enum fsl_micfil_quality_enum =
 
 static DECLARE_TLV_DB_SCALE(gain_tlv, 0, 100, 0);
 
+static int micfil_get_max_range(struct fsl_micfil *micfil)
+{
+       int max_range;
+
+       switch (micfil->quality) {
+       case QUALITY_HIGH:
+       case QUALITY_VLOW0:
+               max_range = micfil->soc->rangeadj_const[0][0] - micfil->soc->rangeadj_const[0][1] *
+                           ilog2(2 * MICFIL_OSR_DEFAULT);
+               break;
+       case QUALITY_MEDIUM:
+       case QUALITY_VLOW1:
+               max_range = micfil->soc->rangeadj_const[1][0] - micfil->soc->rangeadj_const[1][1] *
+                           ilog2(MICFIL_OSR_DEFAULT);
+               break;
+       case QUALITY_LOW:
+       case QUALITY_VLOW2:
+               max_range = micfil->soc->rangeadj_const[2][0] - micfil->soc->rangeadj_const[2][1] *
+                           ilog2(MICFIL_OSR_DEFAULT);
+               break;
+       default:
+               return 0;
+       }
+       max_range = max_range < 0 ? 0 : max_range;
+
+       return max_range;
+}
+
+static int micfil_range_set(struct snd_kcontrol *kcontrol,
+                           struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol);
+       struct fsl_micfil *micfil = snd_soc_component_get_drvdata(cmpnt);
+       struct soc_mixer_control *mc =
+               (struct soc_mixer_control *)kcontrol->private_value;
+       unsigned int shift = mc->shift;
+       int max_range, new_range;
+
+       new_range = ucontrol->value.integer.value[0];
+       max_range = micfil_get_max_range(micfil);
+       if (new_range > max_range)
+               dev_warn(&micfil->pdev->dev, "range makes channel %d data unreliable\n", shift / 4);
+
+       regmap_update_bits(micfil->regmap, REG_MICFIL_OUT_CTRL, 0xF << shift, new_range << shift);
+
+       return 0;
+}
+
 static int micfil_set_quality(struct fsl_micfil *micfil)
 {
-       u32 qsel;
+       int range, max_range;
+       u32 qsel, val;
+       int i;
+
+       if (!micfil->soc->volume_sx) {
+               regmap_read(micfil->regmap, REG_MICFIL_OUT_CTRL, &val);
+               max_range = micfil_get_max_range(micfil);
+               for (i = 0; i < micfil->soc->fifos; i++) {
+                       range = (val >> MICFIL_OUTGAIN_CHX_SHIFT(i)) & 0xF;
+                       if (range > max_range)
+                               dev_warn(&micfil->pdev->dev, "please reset channel %d range\n", i);
+               }
+       }
 
        switch (micfil->quality) {
        case QUALITY_HIGH:
@@ -367,23 +433,31 @@ static int hwvad_detected(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static const struct snd_kcontrol_new fsl_micfil_volume_controls[] = {
-       SOC_SINGLE_TLV("CH0 Volume", REG_MICFIL_OUT_CTRL,
-                      MICFIL_OUTGAIN_CHX_SHIFT(0), 0xF, 0, gain_tlv),
-       SOC_SINGLE_TLV("CH1 Volume", REG_MICFIL_OUT_CTRL,
-                      MICFIL_OUTGAIN_CHX_SHIFT(1), 0xF, 0, gain_tlv),
-       SOC_SINGLE_TLV("CH2 Volume", REG_MICFIL_OUT_CTRL,
-                      MICFIL_OUTGAIN_CHX_SHIFT(2), 0xF, 0, gain_tlv),
-       SOC_SINGLE_TLV("CH3 Volume", REG_MICFIL_OUT_CTRL,
-                      MICFIL_OUTGAIN_CHX_SHIFT(3), 0xF, 0, gain_tlv),
-       SOC_SINGLE_TLV("CH4 Volume", REG_MICFIL_OUT_CTRL,
-                      MICFIL_OUTGAIN_CHX_SHIFT(4), 0xF, 0, gain_tlv),
-       SOC_SINGLE_TLV("CH5 Volume", REG_MICFIL_OUT_CTRL,
-                      MICFIL_OUTGAIN_CHX_SHIFT(5), 0xF, 0, gain_tlv),
-       SOC_SINGLE_TLV("CH6 Volume", REG_MICFIL_OUT_CTRL,
-                      MICFIL_OUTGAIN_CHX_SHIFT(6), 0xF, 0, gain_tlv),
-       SOC_SINGLE_TLV("CH7 Volume", REG_MICFIL_OUT_CTRL,
-                      MICFIL_OUTGAIN_CHX_SHIFT(7), 0xF, 0, gain_tlv),
+static const struct snd_kcontrol_new fsl_micfil_range_controls[] = {
+       SOC_SINGLE_EXT("CH0 Range", REG_MICFIL_OUT_CTRL,
+                      MICFIL_OUTGAIN_CHX_SHIFT(0), 0xF, 0,
+                      snd_soc_get_volsw, micfil_range_set),
+       SOC_SINGLE_EXT("CH1 Range", REG_MICFIL_OUT_CTRL,
+                      MICFIL_OUTGAIN_CHX_SHIFT(1), 0xF, 0,
+                      snd_soc_get_volsw, micfil_range_set),
+       SOC_SINGLE_EXT("CH2 Range", REG_MICFIL_OUT_CTRL,
+                      MICFIL_OUTGAIN_CHX_SHIFT(2), 0xF, 0,
+                      snd_soc_get_volsw, micfil_range_set),
+       SOC_SINGLE_EXT("CH3 Range", REG_MICFIL_OUT_CTRL,
+                      MICFIL_OUTGAIN_CHX_SHIFT(3), 0xF, 0,
+                      snd_soc_get_volsw, micfil_range_set),
+       SOC_SINGLE_EXT("CH4 Range", REG_MICFIL_OUT_CTRL,
+                      MICFIL_OUTGAIN_CHX_SHIFT(4), 0xF, 0,
+                      snd_soc_get_volsw, micfil_range_set),
+       SOC_SINGLE_EXT("CH5 Range", REG_MICFIL_OUT_CTRL,
+                      MICFIL_OUTGAIN_CHX_SHIFT(5), 0xF, 0,
+                      snd_soc_get_volsw, micfil_range_set),
+       SOC_SINGLE_EXT("CH6 Range", REG_MICFIL_OUT_CTRL,
+                      MICFIL_OUTGAIN_CHX_SHIFT(6), 0xF, 0,
+                      snd_soc_get_volsw, micfil_range_set),
+       SOC_SINGLE_EXT("CH7 Range", REG_MICFIL_OUT_CTRL,
+                      MICFIL_OUTGAIN_CHX_SHIFT(7), 0xF, 0,
+                      snd_soc_get_volsw, micfil_range_set),
 };
 
 static const struct snd_kcontrol_new fsl_micfil_volume_sx_controls[] = {
@@ -895,13 +969,20 @@ static int fsl_micfil_dai_probe(struct snd_soc_dai *cpu_dai)
        struct fsl_micfil *micfil = dev_get_drvdata(cpu_dai->dev);
        struct device *dev = cpu_dai->dev;
        unsigned int val = 0;
-       int ret, i;
+       int ret, i, max_range;
 
        micfil->quality = micfil->soc->default_quality;
        micfil->card = cpu_dai->component->card;
 
        /* set default gain to 2 */
-       regmap_write(micfil->regmap, REG_MICFIL_OUT_CTRL, 0x22222222);
+       if (micfil->soc->volume_sx) {
+               regmap_write(micfil->regmap, REG_MICFIL_OUT_CTRL, 0x22222222);
+       } else {
+               max_range = micfil_get_max_range(micfil);
+               for (i = 1; i < micfil->soc->fifos; i++)
+                       max_range |= max_range << 4;
+               regmap_write(micfil->regmap, REG_MICFIL_OUT_CTRL, max_range);
+       }
 
        /* set DC Remover in bypass mode*/
        for (i = 0; i < MICFIL_OUTPUT_CHANNELS; i++)
@@ -935,8 +1016,8 @@ static int fsl_micfil_component_probe(struct snd_soc_component *component)
                snd_soc_add_component_controls(component, fsl_micfil_volume_sx_controls,
                                               ARRAY_SIZE(fsl_micfil_volume_sx_controls));
        else
-               snd_soc_add_component_controls(component, fsl_micfil_volume_controls,
-                                              ARRAY_SIZE(fsl_micfil_volume_controls));
+               snd_soc_add_component_controls(component, fsl_micfil_range_controls,
+                                              ARRAY_SIZE(fsl_micfil_range_controls));
 
        return 0;
 }
--

2.50.1

maintainer
#5 lore raw
In reply to Chancel Liu
Quoted 11 lines · Chancel Liu

Add default quality for different platforms.
Set channel range control.

changes in v2
- use snd_kcontrol_chip() instead of snd_soc_kcontrol_component()

Chancel Liu (2):
ASoC: fsl_micfil: Add default quality for different platforms
ASoC: fsl_micfil: Set channel range control

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: fsl_micfil: Add default quality for different platforms

      commit: e04aab96b3776634ab37ddce6d50a431126edec3
[2/2] ASoC: fsl_micfil: Set channel range control
      commit: ef1a7e02fdb7526e8d7c75e744f1f5b2acd7100b

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark