[alsa-devel] [PATCH v14 0/8] ASoC: sun4i-codec: Add Line-In, FM-In, Mic 2, Capture Source, Differential Line-In
This patchset adds some mixer controls to sun4i-codec for the Allwinner A10 and the Allwinner A20.
It also adds a mux for the capture source and the PGA for the MIC2 preamp.
Where possible, it uses SOC_DAPM_DOUBLE in order to cut down on the number of distinct controls in alsamixer.
v14 changes compared to v13 are: - Merged some of the patches together if it made sense to test them together. - Use snd_soc_component_driver. - Moved SUN4I_CODEC_DAC_ACTL_LFMS, SUN4I_CODEC_DAC_ACTL_RFMS to the correct patch in the series. - Kept "Left Mixer Left DAC Playback Switch", "Right Mixer Left DAC Playback Switch" and "Right Mixer Right DAC Playback Switch" unchanged compared to the released version - for backward compatibility.
v13 changes compared to v12 are: - Added my "Signed-off-by". - Clarified some commit message text.
v12 changes compared to v11 are: - Split up patchset in another way. - Renamed "Mic1 Capture Volume" to "Mic1 Boost Volume". - Renamed "Mic2 Capture Volume" to "Mic2 Boost Volume". - Renamed "Line Capture Volume" to "Line Boost Volume". - Renamed "Differential Line Capture Switch" to "Differential Line Source".
v11 changes compared to v10 are: - Split up patchset. - Fixed typo in Differential Line Capture Switch. - Renamed "Non-Differential" value to "Stereo". - Removed duplicate PA Volume mixer control.
v10 changes compared to v9 are: - Use SOC_DAPM_DOUBLE where possible and it makes sense in order to cut down on the number of controls.
v9 changes compared to v8 are: - added Line Differential Capture Switch. - split Capture Source into Left Capture Select, Right Capture Select. - added Line Capture Volume. - rename "sun4i_codec_widgets" to "sun4i_codec_controls" for consistency with the struct field it's used in. - rename "Line-In" to "Line". - rename "Power Amplifier Playback Volume" to "Headphone Playback Volume".
v8 changes compared to v7 are: - fixed the routes for line and mic capturing.
v7 changes compared to v6 are: - preparation for different A20, A10 controls is now in an extra patch. - all register definitions are now at the top. - sun7i-specific things (A20-specific things) are now less grouped-together. - rename "Power Amplifier Volume" to "Power Amplifier Playback Volume".
v6 changes compared to v5 are: - Mic preamplifier special cases for A20 and A10 now are now not icky: There are two different _widget arrays and the probe() function now selects the right one to pass to snd_soc_register_codec() unmodified. - sun7i-specific things (A20-specific things) are now grouped together.
v5 changes compared to v4 are: - Mic preamplifier controls have more common names now. - Mic preamplifier scale has a 0 dB entry as well now, as documented in the A20 user manual. - Mic preamplifier has special cases for A20 and A10 now. - Gain controls have "Gain" in the name now.
v4 changes compared to v3 are: - names of the input are not uppercase anymore. - bit index constants are now named as in the A20 user manual v1.4. - added Mic1-In, Mac2-In. - added Mic1 and Mic2 Pre-Amplifiers.
v3 changes compared to v2 are: - added DAPM routes.
v2 changes compared to v1 are: - moved Line-In and FM-In playback switches to their respective sun4i_codec_*_mixer_controls.
v1 changes: - added linein, fmin output volumes and switches.
Danny Milosavljevic (8): ASoC: sun4i-codec: Add MIC2 Pre-Amplifier, Mic2, Mic Playback Volume ASoC: sun4i-codec: Add Mic1 Boost Volume, Mic2 Boost Volume ASoC: sun4i-codec: Merge sun4i_codec_left_mixer_controls and sun4i_codec_right_mixer_controls into sun4i_codec_mixer_controls. ASoC: sun4i-codec: Add Mic1 Playback Switch, Mic2 Playback Switch. ASoC: sun4i-codec: Add FM Playback Volume, FM Left, FM Right, FM Playback Switch ASoC: sun4i-codec: Add Line Playback Volume, Line Boost Volume, Line Right, Line Left, Line Playback Switch ASoC: sun4i-codec: Add Differential Line Source. ASoC: sun4i-codec: Add Left Capture Select, Right Capture Select.
sound/soc/sunxi/sun4i-codec.c | 233 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 209 insertions(+), 24 deletions(-)
Add MIC2 Pre-Amplifier, Mic2 input and Mic Playback Volume for Allwinner A10 and Allwinner A20.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org --- sound/soc/sunxi/sun4i-codec.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 9a3cb7704810..060a40b45ab0 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -64,6 +64,7 @@ #define SUN4I_CODEC_DAC_ACTL_DACAENR (31) #define SUN4I_CODEC_DAC_ACTL_DACAENL (30) #define SUN4I_CODEC_DAC_ACTL_MIXEN (29) +#define SUN4I_CODEC_DAC_ACTL_MICG (20) #define SUN4I_CODEC_DAC_ACTL_LDACLMIXS (15) #define SUN4I_CODEC_DAC_ACTL_RDACRMIXS (14) #define SUN4I_CODEC_DAC_ACTL_LDACRMIXS (13) @@ -673,11 +674,16 @@ static const struct snd_kcontrol_new sun4i_codec_pa_mute = SUN4I_CODEC_DAC_ACTL_PA_MUTE, 1, 0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1); +static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale, -450, 150, + 0);
static const struct snd_kcontrol_new sun4i_codec_controls[] = { SOC_SINGLE_TLV("Power Amplifier Volume", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_PA_VOL, 0x3F, 0, sun4i_codec_pa_volume_scale), + SOC_SINGLE_TLV("Mic Playback Volume", SUN4I_CODEC_DAC_ACTL, + SUN4I_CODEC_DAC_ACTL_MICG, 7, 0, + sun4i_codec_micin_loopback_gain_scale), };
static const struct snd_kcontrol_new sun4i_codec_left_mixer_controls[] = { @@ -741,6 +747,8 @@ static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = { /* Mic Pre-Amplifiers */ SND_SOC_DAPM_PGA("MIC1 Pre-Amplifier", SUN4I_CODEC_ADC_ACTL, SUN4I_CODEC_ADC_ACTL_PREG1EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("MIC2 Pre-Amplifier", SUN4I_CODEC_ADC_ACTL, + SUN4I_CODEC_ADC_ACTL_PREG2EN, 0, NULL, 0),
/* Power Amplifier */ SND_SOC_DAPM_MIXER("Power Amplifier", SUN4I_CODEC_ADC_ACTL, @@ -751,6 +759,7 @@ static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = { &sun4i_codec_pa_mute),
SND_SOC_DAPM_INPUT("Mic1"), + SND_SOC_DAPM_INPUT("Mic2"),
SND_SOC_DAPM_OUTPUT("HP Right"), SND_SOC_DAPM_OUTPUT("HP Left"), @@ -790,6 +799,12 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { { "Right ADC", NULL, "MIC1 Pre-Amplifier" }, { "MIC1 Pre-Amplifier", NULL, "Mic1"}, { "Mic1", NULL, "VMIC" }, + + /* Mic2 Routes */ + { "Left ADC", NULL, "MIC2 Pre-Amplifier" }, + { "Right ADC", NULL, "MIC2 Pre-Amplifier" }, + { "MIC2 Pre-Amplifier", NULL, "Mic2"}, + { "Mic2", NULL, "VMIC" }, };
static const struct snd_soc_component_driver sun4i_codec_codec = {
On Wed, May 02, 2018 at 11:07:53PM +0200, Danny Milosavljevic wrote:
Add MIC2 Pre-Amplifier, Mic2 input and Mic Playback Volume for Allwinner A10 and Allwinner A20.
That's a general remark for all your commits here, but you should have more context in your commit logs, for example to define what is the usual use case for these microphones, if the playback volume applies to all mic at once, or just a fraction of them, etc.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org
sound/soc/sunxi/sun4i-codec.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 9a3cb7704810..060a40b45ab0 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -64,6 +64,7 @@ #define SUN4I_CODEC_DAC_ACTL_DACAENR (31) #define SUN4I_CODEC_DAC_ACTL_DACAENL (30) #define SUN4I_CODEC_DAC_ACTL_MIXEN (29) +#define SUN4I_CODEC_DAC_ACTL_MICG (20) #define SUN4I_CODEC_DAC_ACTL_LDACLMIXS (15) #define SUN4I_CODEC_DAC_ACTL_RDACRMIXS (14) #define SUN4I_CODEC_DAC_ACTL_LDACRMIXS (13) @@ -673,11 +674,16 @@ static const struct snd_kcontrol_new sun4i_codec_pa_mute = SUN4I_CODEC_DAC_ACTL_PA_MUTE, 1, 0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1); +static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale, -450, 150,
0);
static const struct snd_kcontrol_new sun4i_codec_controls[] = { SOC_SINGLE_TLV("Power Amplifier Volume", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_PA_VOL, 0x3F, 0, sun4i_codec_pa_volume_scale),
- SOC_SINGLE_TLV("Mic Playback Volume", SUN4I_CODEC_DAC_ACTL,
SUN4I_CODEC_DAC_ACTL_MICG, 7, 0,
sun4i_codec_micin_loopback_gain_scale),
This should probably go in a separate patch, it isn't directly related to the rest of the patch.
Looks good otherwise, thanks! Maxime
Add Mic1 Boost Volume and Mic2 Boost Volume for Allwinner A10 and Allwinner A20. Also add support for extra controls to the sun4i_codec_quirks because the A10 and A20 have Mic1 Boost Volume at different places (likewise for Mic2 Boost Volume).
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org --- sound/soc/sunxi/sun4i-codec.c | 66 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 10 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 060a40b45ab0..4af286f44a67 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -95,6 +95,8 @@ #define SUN4I_CODEC_ADC_ACTL_PREG1EN (29) #define SUN4I_CODEC_ADC_ACTL_PREG2EN (28) #define SUN4I_CODEC_ADC_ACTL_VMICEN (27) +#define SUN4I_CODEC_ADC_ACTL_PREG1 (25) +#define SUN4I_CODEC_ADC_ACTL_PREG2 (23) #define SUN4I_CODEC_ADC_ACTL_VADCG (20) #define SUN4I_CODEC_ADC_ACTL_ADCIS (17) #define SUN4I_CODEC_ADC_ACTL_PA_EN (4) @@ -111,6 +113,9 @@ /* Microphone controls (sun7i only) */ #define SUN7I_CODEC_AC_MIC_PHONE_CAL (0x3c)
+#define SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG1 (29) +#define SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG2 (26) + /* * sun6i specific registers * @@ -676,6 +681,12 @@ static const struct snd_kcontrol_new sun4i_codec_pa_mute = static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1); static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale, -450, 150, 0); +static DECLARE_TLV_DB_RANGE(sun4i_codec_micin_preamp_gain_scale, + 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), + 1, 7, TLV_DB_SCALE_ITEM(3500, 300, 0)); +static DECLARE_TLV_DB_RANGE(sun7i_codec_micin_preamp_gain_scale, + 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), + 1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0));
static const struct snd_kcontrol_new sun4i_codec_controls[] = { SOC_SINGLE_TLV("Power Amplifier Volume", SUN4I_CODEC_DAC_ACTL, @@ -686,6 +697,24 @@ static const struct snd_kcontrol_new sun4i_codec_controls[] = { sun4i_codec_micin_loopback_gain_scale), };
+static const struct snd_kcontrol_new sun4i_codec_extra_controls[] = { + SOC_SINGLE_TLV("Mic1 Boost Volume", SUN4I_CODEC_ADC_ACTL, + SUN4I_CODEC_ADC_ACTL_PREG1, 3, 0, + sun4i_codec_micin_preamp_gain_scale), + SOC_SINGLE_TLV("Mic2 Boost Volume", SUN4I_CODEC_ADC_ACTL, + SUN4I_CODEC_ADC_ACTL_PREG2, 3, 0, + sun4i_codec_micin_preamp_gain_scale), +}; + +static const struct snd_kcontrol_new sun7i_codec_extra_controls[] = { + SOC_SINGLE_TLV("Mic1 Boost Volume", SUN7I_CODEC_AC_MIC_PHONE_CAL, + SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG1, 7, 0, + sun7i_codec_micin_preamp_gain_scale), + SOC_SINGLE_TLV("Mic2 Boost Volume", SUN7I_CODEC_AC_MIC_PHONE_CAL, + SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG2, 7, 0, + sun7i_codec_micin_preamp_gain_scale), +}; + static const struct snd_kcontrol_new sun4i_codec_left_mixer_controls[] = { SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACLMIXS, 1, 0), @@ -807,7 +836,30 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { { "Mic2", NULL, "VMIC" }, };
+struct sun4i_codec_quirks { + const struct regmap_config *regmap_config; + const struct snd_soc_component_driver *codec; + struct snd_soc_card * (*create_card)(struct device *dev); + struct reg_field reg_adc_fifoc; /* used for regmap_field */ + unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */ + unsigned int reg_adc_rxdata; /* RX FIFO offset for DMA config */ + bool has_reset; + const struct snd_kcontrol_new *controls; + unsigned int num_controls; +}; + +static int sun4i_codec_component_driver_probe(struct snd_soc_component *codec) +{ + const struct sun4i_codec_quirks *quirks; + + quirks = of_device_get_match_data(codec->dev); + return snd_soc_add_component_controls(codec, + quirks->controls, + quirks->num_controls); +} + static const struct snd_soc_component_driver sun4i_codec_codec = { + .probe = sun4i_codec_component_driver_probe, .controls = sun4i_codec_controls, .num_controls = ARRAY_SIZE(sun4i_codec_controls), .dapm_widgets = sun4i_codec_codec_dapm_widgets, @@ -1469,16 +1521,6 @@ static const struct regmap_config sun8i_v3s_codec_regmap_config = { .max_register = SUN8I_H3_CODEC_ADC_DBG, };
-struct sun4i_codec_quirks { - const struct regmap_config *regmap_config; - const struct snd_soc_component_driver *codec; - struct snd_soc_card * (*create_card)(struct device *dev); - struct reg_field reg_adc_fifoc; /* used for regmap_field */ - unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */ - unsigned int reg_adc_rxdata; /* RX FIFO offset for DMA config */ - bool has_reset; -}; - static const struct sun4i_codec_quirks sun4i_codec_quirks = { .regmap_config = &sun4i_codec_regmap_config, .codec = &sun4i_codec_codec, @@ -1486,6 +1528,8 @@ static const struct sun4i_codec_quirks sun4i_codec_quirks = { .reg_adc_fifoc = REG_FIELD(SUN4I_CODEC_ADC_FIFOC, 0, 31), .reg_dac_txdata = SUN4I_CODEC_DAC_TXDATA, .reg_adc_rxdata = SUN4I_CODEC_ADC_RXDATA, + .controls = sun4i_codec_extra_controls, + .num_controls = ARRAY_SIZE(sun4i_codec_extra_controls), };
static const struct sun4i_codec_quirks sun6i_a31_codec_quirks = { @@ -1505,6 +1549,8 @@ static const struct sun4i_codec_quirks sun7i_codec_quirks = { .reg_adc_fifoc = REG_FIELD(SUN4I_CODEC_ADC_FIFOC, 0, 31), .reg_dac_txdata = SUN4I_CODEC_DAC_TXDATA, .reg_adc_rxdata = SUN4I_CODEC_ADC_RXDATA, + .controls = sun7i_codec_extra_controls, + .num_controls = ARRAY_SIZE(sun7i_codec_extra_controls), };
static const struct sun4i_codec_quirks sun8i_a23_codec_quirks = {
On Wed, May 02, 2018 at 11:07:54PM +0200, Danny Milosavljevic wrote:
Add Mic1 Boost Volume and Mic2 Boost Volume for Allwinner A10 and Allwinner A20. Also add support for extra controls to the sun4i_codec_quirks because the A10 and A20 have Mic1 Boost Volume at different places (likewise for Mic2 Boost Volume).
A good rule of thumb is that when you have "also" in your commit log, you should do another patch instead doing that instead.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org
sound/soc/sunxi/sun4i-codec.c | 66 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 10 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 060a40b45ab0..4af286f44a67 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -95,6 +95,8 @@ #define SUN4I_CODEC_ADC_ACTL_PREG1EN (29) #define SUN4I_CODEC_ADC_ACTL_PREG2EN (28) #define SUN4I_CODEC_ADC_ACTL_VMICEN (27) +#define SUN4I_CODEC_ADC_ACTL_PREG1 (25) +#define SUN4I_CODEC_ADC_ACTL_PREG2 (23) #define SUN4I_CODEC_ADC_ACTL_VADCG (20) #define SUN4I_CODEC_ADC_ACTL_ADCIS (17) #define SUN4I_CODEC_ADC_ACTL_PA_EN (4) @@ -111,6 +113,9 @@ /* Microphone controls (sun7i only) */ #define SUN7I_CODEC_AC_MIC_PHONE_CAL (0x3c)
+#define SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG1 (29) +#define SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG2 (26)
/*
- sun6i specific registers
@@ -676,6 +681,12 @@ static const struct snd_kcontrol_new sun4i_codec_pa_mute = static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1); static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale, -450, 150, 0); +static DECLARE_TLV_DB_RANGE(sun4i_codec_micin_preamp_gain_scale,
0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
1, 7, TLV_DB_SCALE_ITEM(3500, 300, 0));
+static DECLARE_TLV_DB_RANGE(sun7i_codec_micin_preamp_gain_scale,
0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0));
static const struct snd_kcontrol_new sun4i_codec_controls[] = { SOC_SINGLE_TLV("Power Amplifier Volume", SUN4I_CODEC_DAC_ACTL, @@ -686,6 +697,24 @@ static const struct snd_kcontrol_new sun4i_codec_controls[] = { sun4i_codec_micin_loopback_gain_scale), };
+static const struct snd_kcontrol_new sun4i_codec_extra_controls[] = {
- SOC_SINGLE_TLV("Mic1 Boost Volume", SUN4I_CODEC_ADC_ACTL,
SUN4I_CODEC_ADC_ACTL_PREG1, 3, 0,
sun4i_codec_micin_preamp_gain_scale),
- SOC_SINGLE_TLV("Mic2 Boost Volume", SUN4I_CODEC_ADC_ACTL,
SUN4I_CODEC_ADC_ACTL_PREG2, 3, 0,
sun4i_codec_micin_preamp_gain_scale),
+};
+static const struct snd_kcontrol_new sun7i_codec_extra_controls[] = {
- SOC_SINGLE_TLV("Mic1 Boost Volume", SUN7I_CODEC_AC_MIC_PHONE_CAL,
SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG1, 7, 0,
sun7i_codec_micin_preamp_gain_scale),
- SOC_SINGLE_TLV("Mic2 Boost Volume", SUN7I_CODEC_AC_MIC_PHONE_CAL,
SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG2, 7, 0,
sun7i_codec_micin_preamp_gain_scale),
+};
static const struct snd_kcontrol_new sun4i_codec_left_mixer_controls[] = { SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACLMIXS, 1, 0), @@ -807,7 +836,30 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { { "Mic2", NULL, "VMIC" }, };
+struct sun4i_codec_quirks {
- const struct regmap_config *regmap_config;
- const struct snd_soc_component_driver *codec;
- struct snd_soc_card * (*create_card)(struct device *dev);
- struct reg_field reg_adc_fifoc; /* used for regmap_field */
- unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */
- unsigned int reg_adc_rxdata; /* RX FIFO offset for DMA config */
- bool has_reset;
- const struct snd_kcontrol_new *controls;
- unsigned int num_controls;
+};
+static int sun4i_codec_component_driver_probe(struct snd_soc_component *codec) +{
- const struct sun4i_codec_quirks *quirks;
- quirks = of_device_get_match_data(codec->dev);
- return snd_soc_add_component_controls(codec,
quirks->controls,
quirks->num_controls);
Why not just extending the sun4i_codec_controls to add it, and create a duplicate one for the A20?
Hi Maxime,
On Thu, 3 May 2018 16:33:19 +0200 Maxime Ripard maxime.ripard@bootlin.com wrote:
+struct sun4i_codec_quirks {
- const struct regmap_config *regmap_config;
- const struct snd_soc_component_driver *codec;
- struct snd_soc_card * (*create_card)(struct device *dev);
- struct reg_field reg_adc_fifoc; /* used for regmap_field */
- unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */
- unsigned int reg_adc_rxdata; /* RX FIFO offset for DMA config */
- bool has_reset;
- const struct snd_kcontrol_new *controls;
- unsigned int num_controls;
+};
+static int sun4i_codec_component_driver_probe(struct snd_soc_component *codec) +{
- const struct sun4i_codec_quirks *quirks;
- quirks = of_device_get_match_data(codec->dev);
- return snd_soc_add_component_controls(codec,
quirks->controls,
quirks->num_controls);
Why not just extending the sun4i_codec_controls to add it, and create a duplicate one for the A20?
Because sun4i_codec_controls has five controls shared between A10 and A20, and only two not shared.
And if we extended sun4i_codec_controls, we'd also have to duplicate sun4i_codec_codec in order to use sun4i_codec_controls vs. sun7i_codec_controls, which really contains exactly the same data otherwise.
The quirks here are just for two controls, Mic1 Boost Volume and Mic2 Boost Volume, and there not even for the names or anything - just for some reason the register moved away.
The simplest way was to add it to the quirks - which already have a variant selection etc.
On Sat, May 05, 2018 at 09:05:13AM +0200, Danny Milosavljevic wrote:
Hi Maxime,
On Thu, 3 May 2018 16:33:19 +0200 Maxime Ripard maxime.ripard@bootlin.com wrote:
+struct sun4i_codec_quirks {
- const struct regmap_config *regmap_config;
- const struct snd_soc_component_driver *codec;
- struct snd_soc_card * (*create_card)(struct device *dev);
- struct reg_field reg_adc_fifoc; /* used for regmap_field */
- unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */
- unsigned int reg_adc_rxdata; /* RX FIFO offset for DMA config */
- bool has_reset;
- const struct snd_kcontrol_new *controls;
- unsigned int num_controls;
+};
+static int sun4i_codec_component_driver_probe(struct snd_soc_component *codec) +{
- const struct sun4i_codec_quirks *quirks;
- quirks = of_device_get_match_data(codec->dev);
- return snd_soc_add_component_controls(codec,
quirks->controls,
quirks->num_controls);
Why not just extending the sun4i_codec_controls to add it, and create a duplicate one for the A20?
Because sun4i_codec_controls has five controls shared between A10 and A20, and only two not shared.
And if we extended sun4i_codec_controls, we'd also have to duplicate sun4i_codec_codec in order to use sun4i_codec_controls vs. sun7i_codec_controls, which really contains exactly the same data otherwise.
What I don't really like is that with this patch we have two variants of the same mechanism: one to add the controls that are mostly shared, and one to add the controls that are not shared, without any clear definition of when you should add a new control to one list or the other.
So far, we had one mechanism, it was easy to understand and to know what to do about it. And the code was simple as well.
The quirks here are just for two controls, Mic1 Boost Volume and Mic2 Boost Volume, and there not even for the names or anything - just for some reason the register moved away.
The simplest way was to add it to the quirks - which already have a variant selection etc.
Actually, I think that having to do add a new control explicitly to an A10 and an A20 list is a feature if the two controls set aren't exactly the same. It makes you explicitly think about what you're doing, and hopefully double check if it is actually shared or not, instead of exposing a control because one didn't pay attention that it was shared.
Chen-Yu, any opinion on this?
Maxime
Since it's now possible to have a DAPM mixer control with multiple channels, use it to cut down the total number of controls.
Keep "Left Mixer Left DAC Playback Switch" and "Right Mixer Right DAC Playback Switch" name & layout the same as before for compatibility.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org --- sound/soc/sunxi/sun4i-codec.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 4af286f44a67..b62af407967f 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -715,15 +715,15 @@ static const struct snd_kcontrol_new sun7i_codec_extra_controls[] = { sun7i_codec_micin_preamp_gain_scale), };
-static const struct snd_kcontrol_new sun4i_codec_left_mixer_controls[] = { - SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL, - SUN4I_CODEC_DAC_ACTL_LDACLMIXS, 1, 0), -}; - -static const struct snd_kcontrol_new sun4i_codec_right_mixer_controls[] = { - SOC_DAPM_SINGLE("Right DAC Playback Switch", SUN4I_CODEC_DAC_ACTL, - SUN4I_CODEC_DAC_ACTL_RDACRMIXS, 1, 0), - SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL, +static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] = { + SOC_DAPM_SINGLE("Left Mixer Left DAC Playback Switch", + SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACLMIXS, + 1, 0), + SOC_DAPM_SINGLE("Right Mixer Right DAC Playback Switch", + SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_RDACRMIXS, + 1, 0), + SOC_DAPM_SINGLE("Right Mixer Left DAC Playback Switch", + SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACRMIXS, 1, 0), };
@@ -759,11 +759,11 @@ static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = {
/* Mixers */ SND_SOC_DAPM_MIXER("Left Mixer", SND_SOC_NOPM, 0, 0, - sun4i_codec_left_mixer_controls, - ARRAY_SIZE(sun4i_codec_left_mixer_controls)), + sun4i_codec_mixer_controls, + ARRAY_SIZE(sun4i_codec_mixer_controls)), SND_SOC_DAPM_MIXER("Right Mixer", SND_SOC_NOPM, 0, 0, - sun4i_codec_right_mixer_controls, - ARRAY_SIZE(sun4i_codec_right_mixer_controls)), + sun4i_codec_mixer_controls, + ARRAY_SIZE(sun4i_codec_mixer_controls)),
/* Global Mixer Enable */ SND_SOC_DAPM_SUPPLY("Mixer Enable", SUN4I_CODEC_DAC_ACTL, @@ -805,12 +805,12 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = {
/* Right Mixer Routes */ { "Right Mixer", NULL, "Mixer Enable" }, - { "Right Mixer", "Left DAC Playback Switch", "Left DAC" }, - { "Right Mixer", "Right DAC Playback Switch", "Right DAC" }, + { "Right Mixer", "Right Mixer Left DAC Playback Switch", "Left DAC" }, + { "Right Mixer", "Right Mixer Right DAC Playback Switch", "Right DAC" },
/* Left Mixer Routes */ { "Left Mixer", NULL, "Mixer Enable" }, - { "Left Mixer", "Left DAC Playback Switch", "Left DAC" }, + { "Left Mixer", "Left Mixer Left DAC Playback Switch", "Left DAC" },
/* Power Amplifier Routes */ { "Power Amplifier", "Mixer Playback Switch", "Left Mixer" },
On Wed, May 02, 2018 at 11:07:55PM +0200, Danny Milosavljevic wrote:
Since it's now possible to have a DAPM mixer control with multiple channels, use it to cut down the total number of controls.
Keep "Left Mixer Left DAC Playback Switch" and "Right Mixer Right DAC Playback Switch" name & layout the same as before for compatibility.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org
sound/soc/sunxi/sun4i-codec.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 4af286f44a67..b62af407967f 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -715,15 +715,15 @@ static const struct snd_kcontrol_new sun7i_codec_extra_controls[] = { sun7i_codec_micin_preamp_gain_scale), };
-static const struct snd_kcontrol_new sun4i_codec_left_mixer_controls[] = {
- SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
SUN4I_CODEC_DAC_ACTL_LDACLMIXS, 1, 0),
-};
-static const struct snd_kcontrol_new sun4i_codec_right_mixer_controls[] = {
- SOC_DAPM_SINGLE("Right DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
SUN4I_CODEC_DAC_ACTL_RDACRMIXS, 1, 0),
- SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
+static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] = {
- SOC_DAPM_SINGLE("Left Mixer Left DAC Playback Switch",
SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACLMIXS,
1, 0),
- SOC_DAPM_SINGLE("Right Mixer Right DAC Playback Switch",
SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_RDACRMIXS,
1, 0),
- SOC_DAPM_SINGLE("Right Mixer Left DAC Playback Switch",
SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACRMIXS, 1, 0),
};
@@ -759,11 +759,11 @@ static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = {
/* Mixers */ SND_SOC_DAPM_MIXER("Left Mixer", SND_SOC_NOPM, 0, 0,
sun4i_codec_left_mixer_controls,
ARRAY_SIZE(sun4i_codec_left_mixer_controls)),
sun4i_codec_mixer_controls,
SND_SOC_DAPM_MIXER("Right Mixer", SND_SOC_NOPM, 0, 0,ARRAY_SIZE(sun4i_codec_mixer_controls)),
sun4i_codec_right_mixer_controls,
ARRAY_SIZE(sun4i_codec_right_mixer_controls)),
sun4i_codec_mixer_controls,
ARRAY_SIZE(sun4i_codec_mixer_controls)),
Doesn't that mean that the controls will be shared between the right and left mixers now, which wasn't the case before? And also, wouldn't the controls be called "Left Mixer Left Mixer Left DAC Playback Switch" (for the first one) now?
Hi Maxime,
On Thu, 3 May 2018 16:46:19 +0200 Maxime Ripard maxime.ripard@bootlin.com wrote:
Doesn't that mean that the controls will be shared between the right and left mixers now, which wasn't the case before?
Yes. However Chen-Yu said that except for debugfs that cannot be observed by user space anyway.
It's nice to have the NEW controls have multiple channels, which is what this does.
And also, wouldn't the controls be called "Left Mixer Left Mixer Left DAC Playback Switch" (for the first one) now?
No. I checked using "amixer" - the names look fine, "Left Mixer Left DAC Playback Switch".
With the patch series, amixer says:
numid=10,iface=MIXER,name='FM Playback Switch' numid=6,iface=MIXER,name='FM Playback Volume' numid=5,iface=MIXER,name='Line Boost Volume' numid=9,iface=MIXER,name='Line Playback Switch' numid=4,iface=MIXER,name='Line Playback Volume' numid=1,iface=MIXER,name='Mic1 Boost Volume' numid=11,iface=MIXER,name='Mic1 Playback Switch' numid=2,iface=MIXER,name='Mic2 Boost Volume' numid=12,iface=MIXER,name='Mic2 Playback Switch' numid=7,iface=MIXER,name='Mic Playback Volume' numid=18,iface=MIXER,name='Capture Source' numid=19,iface=MIXER,name='Differential Line Source' numid=8,iface=MIXER,name='Left Mixer Left DAC Playback Switch' numid=15,iface=MIXER,name='Power Amplifier DAC Playback Switch' numid=16,iface=MIXER,name='Power Amplifier Mixer Playback Switch' numid=17,iface=MIXER,name='Power Amplifier Mute Switch' numid=3,iface=MIXER,name='Power Amplifier Volume' numid=14,iface=MIXER,name='Right Mixer Left DAC Playback Switch' numid=13,iface=MIXER,name='Right Mixer Right DAC Playback Switch'
On Sat, May 05, 2018 at 08:51:43AM +0200, Danny Milosavljevic wrote:
Hi Maxime,
On Thu, 3 May 2018 16:46:19 +0200 Maxime Ripard maxime.ripard@bootlin.com wrote:
Doesn't that mean that the controls will be shared between the right and left mixers now, which wasn't the case before?
Yes. However Chen-Yu said that except for debugfs that cannot be observed by user space anyway.
It's nice to have the NEW controls have multiple channels, which is what this does.
And also, wouldn't the controls be called "Left Mixer Left Mixer Left DAC Playback Switch" (for the first one) now?
No. I checked using "amixer" - the names look fine, "Left Mixer Left DAC Playback Switch".
With the patch series, amixer says:
numid=10,iface=MIXER,name='FM Playback Switch' numid=6,iface=MIXER,name='FM Playback Volume' numid=5,iface=MIXER,name='Line Boost Volume' numid=9,iface=MIXER,name='Line Playback Switch' numid=4,iface=MIXER,name='Line Playback Volume' numid=1,iface=MIXER,name='Mic1 Boost Volume' numid=11,iface=MIXER,name='Mic1 Playback Switch' numid=2,iface=MIXER,name='Mic2 Boost Volume' numid=12,iface=MIXER,name='Mic2 Playback Switch' numid=7,iface=MIXER,name='Mic Playback Volume' numid=18,iface=MIXER,name='Capture Source' numid=19,iface=MIXER,name='Differential Line Source' numid=8,iface=MIXER,name='Left Mixer Left DAC Playback Switch' numid=15,iface=MIXER,name='Power Amplifier DAC Playback Switch' numid=16,iface=MIXER,name='Power Amplifier Mixer Playback Switch' numid=17,iface=MIXER,name='Power Amplifier Mute Switch' numid=3,iface=MIXER,name='Power Amplifier Volume' numid=14,iface=MIXER,name='Right Mixer Left DAC Playback Switch' numid=13,iface=MIXER,name='Right Mixer Right DAC Playback Switch'
Great then :)
Maxime
Add Mic1 Playback Switch and Mic2 Playback Switch for Allwinner A10 and Allwinner A20.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org --- sound/soc/sunxi/sun4i-codec.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index b62af407967f..0add2c44115c 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -68,6 +68,10 @@ #define SUN4I_CODEC_DAC_ACTL_LDACLMIXS (15) #define SUN4I_CODEC_DAC_ACTL_RDACRMIXS (14) #define SUN4I_CODEC_DAC_ACTL_LDACRMIXS (13) +#define SUN4I_CODEC_DAC_ACTL_MIC1LS (12) +#define SUN4I_CODEC_DAC_ACTL_MIC1RS (11) +#define SUN4I_CODEC_DAC_ACTL_MIC2LS (10) +#define SUN4I_CODEC_DAC_ACTL_MIC2RS (9) #define SUN4I_CODEC_DAC_ACTL_DACPAS (8) #define SUN4I_CODEC_DAC_ACTL_MIXPAS (7) #define SUN4I_CODEC_DAC_ACTL_PA_MUTE (6) @@ -725,6 +729,12 @@ static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] = { SOC_DAPM_SINGLE("Right Mixer Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACRMIXS, 1, 0), + SOC_DAPM_DOUBLE("Mic1 Playback Switch", SUN4I_CODEC_DAC_ACTL, + SUN4I_CODEC_DAC_ACTL_MIC1LS, + SUN4I_CODEC_DAC_ACTL_MIC1RS, 1, 0), + SOC_DAPM_DOUBLE("Mic2 Playback Switch", SUN4I_CODEC_DAC_ACTL, + SUN4I_CODEC_DAC_ACTL_MIC2LS, + SUN4I_CODEC_DAC_ACTL_MIC2RS, 1, 0), };
static const struct snd_kcontrol_new sun4i_codec_pa_mixer_controls[] = { @@ -807,10 +817,14 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { { "Right Mixer", NULL, "Mixer Enable" }, { "Right Mixer", "Right Mixer Left DAC Playback Switch", "Left DAC" }, { "Right Mixer", "Right Mixer Right DAC Playback Switch", "Right DAC" }, + { "Right Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" }, + { "Right Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
/* Left Mixer Routes */ { "Left Mixer", NULL, "Mixer Enable" }, { "Left Mixer", "Left Mixer Left DAC Playback Switch", "Left DAC" }, + { "Left Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" }, + { "Left Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
/* Power Amplifier Routes */ { "Power Amplifier", "Mixer Playback Switch", "Left Mixer" },
Add FM Playback Volume for Allwinner A10 and Allwinner A20. Add FM Left, FM Right, FM Playback Switch for Allwinner A10 and Allwinner A20.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org --- sound/soc/sunxi/sun4i-codec.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 0add2c44115c..3bc3f2012bc6 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -64,7 +64,10 @@ #define SUN4I_CODEC_DAC_ACTL_DACAENR (31) #define SUN4I_CODEC_DAC_ACTL_DACAENL (30) #define SUN4I_CODEC_DAC_ACTL_MIXEN (29) +#define SUN4I_CODEC_DAC_ACTL_FMG (23) #define SUN4I_CODEC_DAC_ACTL_MICG (20) +#define SUN4I_CODEC_DAC_ACTL_LFMS (17) +#define SUN4I_CODEC_DAC_ACTL_RFMS (16) #define SUN4I_CODEC_DAC_ACTL_LDACLMIXS (15) #define SUN4I_CODEC_DAC_ACTL_RDACRMIXS (14) #define SUN4I_CODEC_DAC_ACTL_LDACRMIXS (13) @@ -683,6 +686,8 @@ static const struct snd_kcontrol_new sun4i_codec_pa_mute = SUN4I_CODEC_DAC_ACTL_PA_MUTE, 1, 0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1); +static DECLARE_TLV_DB_SCALE(sun4i_codec_fmin_loopback_gain_scale, -450, 150, + 0); static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale, -450, 150, 0); static DECLARE_TLV_DB_RANGE(sun4i_codec_micin_preamp_gain_scale, @@ -696,6 +701,9 @@ static const struct snd_kcontrol_new sun4i_codec_controls[] = { SOC_SINGLE_TLV("Power Amplifier Volume", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_PA_VOL, 0x3F, 0, sun4i_codec_pa_volume_scale), + SOC_SINGLE_TLV("FM Playback Volume", SUN4I_CODEC_DAC_ACTL, + SUN4I_CODEC_DAC_ACTL_FMG, 3, 0, + sun4i_codec_fmin_loopback_gain_scale), SOC_SINGLE_TLV("Mic Playback Volume", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_MICG, 7, 0, sun4i_codec_micin_loopback_gain_scale), @@ -729,6 +737,9 @@ static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] = { SOC_DAPM_SINGLE("Right Mixer Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACRMIXS, 1, 0), + SOC_DAPM_DOUBLE("FM Playback Switch", SUN4I_CODEC_DAC_ACTL, + SUN4I_CODEC_DAC_ACTL_LFMS, + SUN4I_CODEC_DAC_ACTL_RFMS, 1, 0), SOC_DAPM_DOUBLE("Mic1 Playback Switch", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_MIC1LS, SUN4I_CODEC_DAC_ACTL_MIC1RS, 1, 0), @@ -797,6 +808,8 @@ static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = { SND_SOC_DAPM_SWITCH("Power Amplifier Mute", SND_SOC_NOPM, 0, 0, &sun4i_codec_pa_mute),
+ SND_SOC_DAPM_INPUT("FM Right"), + SND_SOC_DAPM_INPUT("FM Left"), SND_SOC_DAPM_INPUT("Mic1"), SND_SOC_DAPM_INPUT("Mic2"),
@@ -817,12 +830,14 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { { "Right Mixer", NULL, "Mixer Enable" }, { "Right Mixer", "Right Mixer Left DAC Playback Switch", "Left DAC" }, { "Right Mixer", "Right Mixer Right DAC Playback Switch", "Right DAC" }, + { "Right Mixer", "FM Playback Switch", "FM Right" }, { "Right Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" }, { "Right Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
/* Left Mixer Routes */ { "Left Mixer", NULL, "Mixer Enable" }, { "Left Mixer", "Left Mixer Left DAC Playback Switch", "Left DAC" }, + { "Left Mixer", "FM Playback Switch", "FM Left" }, { "Left Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" }, { "Left Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
Add Line Playback Volume for Allwinner A10 and Allwinner A20. Add Line Boost Volume for Allwinner A10 and Allwinner A20. Add Line Right, Line Left, Line Playback Switch for Allwinner A10 and Allwinner A20.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org --- sound/soc/sunxi/sun4i-codec.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 3bc3f2012bc6..4125d9ef0eb6 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -64,8 +64,11 @@ #define SUN4I_CODEC_DAC_ACTL_DACAENR (31) #define SUN4I_CODEC_DAC_ACTL_DACAENL (30) #define SUN4I_CODEC_DAC_ACTL_MIXEN (29) +#define SUN4I_CODEC_DAC_ACTL_LNG (26) #define SUN4I_CODEC_DAC_ACTL_FMG (23) #define SUN4I_CODEC_DAC_ACTL_MICG (20) +#define SUN4I_CODEC_DAC_ACTL_LLNS (19) +#define SUN4I_CODEC_DAC_ACTL_RLNS (18) #define SUN4I_CODEC_DAC_ACTL_LFMS (17) #define SUN4I_CODEC_DAC_ACTL_RFMS (16) #define SUN4I_CODEC_DAC_ACTL_LDACLMIXS (15) @@ -106,6 +109,7 @@ #define SUN4I_CODEC_ADC_ACTL_PREG2 (23) #define SUN4I_CODEC_ADC_ACTL_VADCG (20) #define SUN4I_CODEC_ADC_ACTL_ADCIS (17) +#define SUN4I_CODEC_ADC_ACTL_LNPREG (13) #define SUN4I_CODEC_ADC_ACTL_PA_EN (4) #define SUN4I_CODEC_ADC_ACTL_DDE (3) #define SUN4I_CODEC_ADC_DEBUG (0x2c) @@ -686,6 +690,10 @@ static const struct snd_kcontrol_new sun4i_codec_pa_mute = SUN4I_CODEC_DAC_ACTL_PA_MUTE, 1, 0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1); +static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_loopback_gain_scale, -150, 150, + 0); +static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_preamp_gain_scale, -1200, 300, + 0); static DECLARE_TLV_DB_SCALE(sun4i_codec_fmin_loopback_gain_scale, -450, 150, 0); static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale, -450, 150, @@ -701,6 +709,12 @@ static const struct snd_kcontrol_new sun4i_codec_controls[] = { SOC_SINGLE_TLV("Power Amplifier Volume", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_PA_VOL, 0x3F, 0, sun4i_codec_pa_volume_scale), + SOC_SINGLE_TLV("Line Playback Volume", SUN4I_CODEC_DAC_ACTL, + SUN4I_CODEC_DAC_ACTL_LNG, 1, 0, + sun4i_codec_linein_loopback_gain_scale), + SOC_SINGLE_TLV("Line Boost Volume", SUN4I_CODEC_ADC_ACTL, + SUN4I_CODEC_ADC_ACTL_LNPREG, 7, 0, + sun4i_codec_linein_preamp_gain_scale), SOC_SINGLE_TLV("FM Playback Volume", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_FMG, 3, 0, sun4i_codec_fmin_loopback_gain_scale), @@ -737,6 +751,9 @@ static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] = { SOC_DAPM_SINGLE("Right Mixer Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACRMIXS, 1, 0), + SOC_DAPM_DOUBLE("Line Playback Switch", SUN4I_CODEC_DAC_ACTL, + SUN4I_CODEC_DAC_ACTL_LLNS, + SUN4I_CODEC_DAC_ACTL_RLNS, 1, 0), SOC_DAPM_DOUBLE("FM Playback Switch", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LFMS, SUN4I_CODEC_DAC_ACTL_RFMS, 1, 0), @@ -808,6 +825,8 @@ static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = { SND_SOC_DAPM_SWITCH("Power Amplifier Mute", SND_SOC_NOPM, 0, 0, &sun4i_codec_pa_mute),
+ SND_SOC_DAPM_INPUT("Line Right"), + SND_SOC_DAPM_INPUT("Line Left"), SND_SOC_DAPM_INPUT("FM Right"), SND_SOC_DAPM_INPUT("FM Left"), SND_SOC_DAPM_INPUT("Mic1"), @@ -830,6 +849,7 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { { "Right Mixer", NULL, "Mixer Enable" }, { "Right Mixer", "Right Mixer Left DAC Playback Switch", "Left DAC" }, { "Right Mixer", "Right Mixer Right DAC Playback Switch", "Right DAC" }, + { "Right Mixer", "Line Playback Switch", "Line Right" }, { "Right Mixer", "FM Playback Switch", "FM Right" }, { "Right Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" }, { "Right Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" }, @@ -837,6 +857,7 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { /* Left Mixer Routes */ { "Left Mixer", NULL, "Mixer Enable" }, { "Left Mixer", "Left Mixer Left DAC Playback Switch", "Left DAC" }, + { "Left Mixer", "Line Playback Switch", "Line Left" }, { "Left Mixer", "FM Playback Switch", "FM Left" }, { "Left Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" }, { "Left Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
Add Differential Line Source for Allwinner A10 and Allwinner A20.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org --- sound/soc/sunxi/sun4i-codec.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 4125d9ef0eb6..45dcb80a1da9 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -110,6 +110,7 @@ #define SUN4I_CODEC_ADC_ACTL_VADCG (20) #define SUN4I_CODEC_ADC_ACTL_ADCIS (17) #define SUN4I_CODEC_ADC_ACTL_LNPREG (13) +#define SUN4I_CODEC_ADC_ACTL_LNRDF (16) #define SUN4I_CODEC_ADC_ACTL_PA_EN (4) #define SUN4I_CODEC_ADC_ACTL_DDE (3) #define SUN4I_CODEC_ADC_DEBUG (0x2c) @@ -705,6 +706,20 @@ static DECLARE_TLV_DB_RANGE(sun7i_codec_micin_preamp_gain_scale, 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0));
+static const char * const sun4i_codec_difflinein_source[] = { + "Stereo", + "Differential", +}; + +static SOC_ENUM_SINGLE_DECL(sun4i_codec_enum_difflinein_source, + SUN4I_CODEC_ADC_ACTL, + SUN4I_CODEC_ADC_ACTL_LNRDF, + sun4i_codec_difflinein_source); + +static const struct snd_kcontrol_new sun4i_codec_difflinein_source_controls = + SOC_DAPM_ENUM("Differential Line Source", + sun4i_codec_enum_difflinein_source); + static const struct snd_kcontrol_new sun4i_codec_controls[] = { SOC_SINGLE_TLV("Power Amplifier Volume", SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_PA_VOL, 0x3F, 0, @@ -825,6 +840,11 @@ static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = { SND_SOC_DAPM_SWITCH("Power Amplifier Mute", SND_SOC_NOPM, 0, 0, &sun4i_codec_pa_mute),
+ /* MUX */ + SND_SOC_DAPM_MUX("Differential Line Source", SND_SOC_NOPM, + 0, 0, + &sun4i_codec_difflinein_source_controls), + SND_SOC_DAPM_INPUT("Line Right"), SND_SOC_DAPM_INPUT("Line Left"), SND_SOC_DAPM_INPUT("FM Right"), @@ -884,6 +904,10 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { { "Right ADC", NULL, "MIC2 Pre-Amplifier" }, { "MIC2 Pre-Amplifier", NULL, "Mic2"}, { "Mic2", NULL, "VMIC" }, + + /* LNRDF Routes */ + { "Differential Line Source", "Differential", "Line Left" }, + { "Differential Line Source", "Differential", "Line Right" }, };
struct sun4i_codec_quirks {
Add Left Capture Select and Right Capture Select for Allwinner A10 and Allwinner A20.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org --- sound/soc/sunxi/sun4i-codec.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 45dcb80a1da9..1a4ba3bae5da 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -706,6 +706,25 @@ static DECLARE_TLV_DB_RANGE(sun7i_codec_micin_preamp_gain_scale, 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0));
+static const char * const sun4i_codec_capture_source[] = { + "Line", + "FM", + "Mic1", + "Mic2", + "Mic1,Mic2", + "Mic1+Mic2", + "Output Mixer", + "Line,Mic1", +}; + +static SOC_ENUM_SINGLE_DECL(sun4i_codec_enum_capture_source, + SUN4I_CODEC_ADC_ACTL, + SUN4I_CODEC_ADC_ACTL_ADCIS, + sun4i_codec_capture_source); + +static const struct snd_kcontrol_new sun4i_codec_capture_source_controls = + SOC_DAPM_ENUM("Capture Source", sun4i_codec_enum_capture_source); + static const char * const sun4i_codec_difflinein_source[] = { "Stereo", "Differential", @@ -841,6 +860,10 @@ static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = { &sun4i_codec_pa_mute),
/* MUX */ + SND_SOC_DAPM_MUX("Left Capture Select", SND_SOC_NOPM, 0, 0, + &sun4i_codec_capture_source_controls), + SND_SOC_DAPM_MUX("Right Capture Select", SND_SOC_NOPM, 0, 0, + &sun4i_codec_capture_source_controls), SND_SOC_DAPM_MUX("Differential Line Source", SND_SOC_NOPM, 0, 0, &sun4i_codec_difflinein_source_controls), @@ -908,6 +931,33 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { /* LNRDF Routes */ { "Differential Line Source", "Differential", "Line Left" }, { "Differential Line Source", "Differential", "Line Right" }, + + /* Right ADC Input Routes */ + { "Right Capture Select", "Line", "Line Right" }, + { "Right Capture Select", "Line", "Differential Line Capture Switch" }, + { "Right Capture Select", "FM", "FM Right" }, + { "Right Capture Select", "Mic1", "MIC1 Pre-Amplifier" }, + { "Right Capture Select", "Mic2", "MIC2 Pre-Amplifier" }, + { "Right Capture Select", "Mic1,Mic2", "MIC2 Pre-Amplifier" }, + { "Right Capture Select", "Mic1+Mic2", "MIC2 Pre-Amplifier" }, + { "Right Capture Select", "Mic1+Mic2", "MIC1 Pre-Amplifier" }, + { "Right Capture Select", "Output Mixer", "Right Mixer" }, + { "Right Capture Select", "Line,Mic1", "MIC1 Pre-Amplifier" }, + { "Right ADC", NULL, "Right Capture Select" }, + + /* Left ADC Input Routes */ + { "Left Capture Select", "Line", "Line Left" }, + { "Left Capture Select", "Line", "Differential Line Capture Switch" }, + { "Left Capture Select", "FM", "FM Left" }, + { "Left Capture Select", "Mic1", "MIC1 Pre-Amplifier" }, + { "Left Capture Select", "Mic2", "MIC2 Pre-Amplifier" }, + { "Left Capture Select", "Mic1,Mic2", "MIC1 Pre-Amplifier" }, + { "Left Capture Select", "Mic1+Mic2", "MIC1 Pre-Amplifier" }, + { "Left Capture Select", "Mic1+Mic2", "MIC2 Pre-Amplifier" }, + { "Left Capture Select", "Output Mixer", "Left Mixer" }, + { "Left Capture Select", "Line,Mic1", "Line Left" }, + { "Left Capture Select", "Line,Mic1", "Differential Line Capture Switch" }, + { "Left ADC", NULL, "Left Capture Select" }, };
struct sun4i_codec_quirks {
Hi,
On Wed, May 02, 2018 at 11:08:00PM +0200, Danny Milosavljevic wrote:
Add Left Capture Select and Right Capture Select for Allwinner A10 and Allwinner A20.
Signed-off-by: Danny Milosavljevic dannym@scratchpost.org
sound/soc/sunxi/sun4i-codec.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 45dcb80a1da9..1a4ba3bae5da 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -706,6 +706,25 @@ static DECLARE_TLV_DB_RANGE(sun7i_codec_micin_preamp_gain_scale, 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0));
+static const char * const sun4i_codec_capture_source[] = {
- "Line",
- "FM",
- "Mic1",
- "Mic2",
- "Mic1,Mic2",
- "Mic1+Mic2",
- "Output Mixer",
- "Line,Mic1",
+};
Shouldn't that be defined in a more generic way? As far as I know, there's no way to tell what the difference between "Mic1,Mic2" and "Mic1+Mic2" would be from the userspace.
I guess the larger issue is that you'd need to have controls that are common to both channels (ie that would change the routing of both mixers), but aren't sharing the same controls structure since the label would be different.
Maxime
Hi Maxime,
On Thu, 3 May 2018 16:54:08 +0200 Maxime Ripard maxime.ripard@bootlin.com wrote:
+static const char * const sun4i_codec_capture_source[] = {
- "Line",
- "FM",
- "Mic1",
- "Mic2",
- "Mic1,Mic2",
- "Mic1+Mic2",
- "Output Mixer",
- "Line,Mic1",
+};
Shouldn't that be defined in a more generic way? As far as I know, there's no way to tell what the difference between "Mic1,Mic2" and "Mic1+Mic2" would be from the userspace.
Sounds good - but how?
Here, "Mic1,Mic2" means the left channel captured is Mic1 and the right channel captured is Mic2.
On the other hand, "Mic1+Mic2" means that the signals from Mic1 and Mic2 are added together and that is captured (both as left and as right).
"Mic1" means both the left channel and the right channel captured is from Mic1. Likewise "Mic2".
On Sat, May 05, 2018 at 12:40:50PM +0200, Danny Milosavljevic wrote:
Hi Maxime,
On Thu, 3 May 2018 16:54:08 +0200 Maxime Ripard maxime.ripard@bootlin.com wrote:
+static const char * const sun4i_codec_capture_source[] = {
- "Line",
- "FM",
- "Mic1",
- "Mic2",
- "Mic1,Mic2",
- "Mic1+Mic2",
- "Output Mixer",
- "Line,Mic1",
+};
Shouldn't that be defined in a more generic way? As far as I know, there's no way to tell what the difference between "Mic1,Mic2" and "Mic1+Mic2" would be from the userspace.
Sounds good - but how?
Here, "Mic1,Mic2" means the left channel captured is Mic1 and the right channel captured is Mic2.
On the other hand, "Mic1+Mic2" means that the signals from Mic1 and Mic2 are added together and that is captured (both as left and as right).
"Mic1" means both the left channel and the right channel captured is from Mic1. Likewise "Mic2".
Right, and my point isn't that it is difficult to understand or remember once you get it, but that it's difficult to get it in the first place, and that this convention is solely based on the one used in the datasheet, which is an abstraction violation in itself.
I guess that's really up to Mark here, but one solution would be to allow to couple the controls explicitly instead of relying solely on the fact that they share the same controls array pointer.
Maxime
participants (2)
-
Danny Milosavljevic
-
Maxime Ripard