This patchset adds some mixer controls to sun4i-codec.
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.
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 (12):
sun4i-codec: Add inputs: Mic2, Line Right, Line Left, FM Right, FM
Left.
sun4i-codec: Add Differential Line Capture Switch and its routes
sun4i-codec: Add Line Playback Volume, FM Playback Volume, Mic
Playback Volume, Capture Volume, Line Capture Volume.
sun4i-codec: Add Mic1 Capture Volume, Mic2 Capture Volume.
sun4i-codec: Move struct sun4i_codec_quirks further up.
sun4i-codec: Add support for extra controls to struct
sun4i_codec_quirks and use them.
sun4i-codec: Add extra controls to sun4i_codec_quirks,
sun7i_codec_quirks.
sun4i-codec: Merge sun4i_codec_left_mixer_controls and
sun4i_codec_right_mixer_controls into sun4i_codec_mixer_controls.
sun4i-codec: Add Line Playback Switch, FM Playback Switch, Mic1
Playback Switch, Mic2 Playback Switch.
sun4i-codec: Add Left Capture Select, Right Capture Select.
sun4i-codec: Add MIC2 Pre-Amplifier.
sun4i-codec: Add routes for playback switches, Mic2, Capture Select.
sound/soc/sunxi/sun4i-codec.c | 283 ++++++++++++++++++++++++++++++++++++++----
1 file changed, 259 insertions(+), 24 deletions(-)
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index 15006998..2f65aa72 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -720,8 +720,15 @@ 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),
+ /* Inputs */
SND_SOC_DAPM_INPUT("Mic1"),
+ SND_SOC_DAPM_INPUT("Mic2"),
+ SND_SOC_DAPM_INPUT("Line Right"),
+ SND_SOC_DAPM_INPUT("Line Left"),
+ SND_SOC_DAPM_INPUT("FM Right"),
+ SND_SOC_DAPM_INPUT("FM Left"),
+ /* Outputs */
SND_SOC_DAPM_OUTPUT("HP Right"),
SND_SOC_DAPM_OUTPUT("HP Left"),
};
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index 25870a64..f56a59ad 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -889,6 +889,16 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = {
};
+struct sun4i_codec_quirks {
+ const struct regmap_config *regmap_config;
+ const struct snd_soc_codec_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 struct snd_soc_codec_driver sun4i_codec_codec = {
.component_driver = {
.controls = sun4i_codec_controls,
@@ -1546,16 +1556,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_codec_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,
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 55 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index a2435c6e..b5a3b5b3 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -64,6 +64,9 @@
#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_LDACLMIXS (15)
#define SUN4I_CODEC_DAC_ACTL_RDACRMIXS (14)
#define SUN4I_CODEC_DAC_ACTL_LDACRMIXS (13)
@@ -94,9 +97,10 @@
#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_VADCG (20)
+#define SUN4I_CODEC_ADC_ACTL_ADCG (20)
#define SUN4I_CODEC_ADC_ACTL_ADCIS (17)
#define SUN4I_CODEC_ADC_ACTL_LNRDF (16)
+#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)
@@ -644,6 +648,23 @@ 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,
+ 0);
+static DECLARE_TLV_DB_SCALE(sun4i_codec_adc_gain_scale, -450, 150, 0);
static const char * const sun4i_codec_difflinein_capture_source[] = {
"Stereo",
@@ -663,6 +684,38 @@ 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),
+ /* Line, FM, Mic1, Mic2 */
+ 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 Capture 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),
+ SOC_SINGLE_TLV("Mic Playback Volume",
+ SUN4I_CODEC_DAC_ACTL,
+ SUN4I_CODEC_DAC_ACTL_MICG,
+ 7,
+ 0,
+ sun4i_codec_micin_loopback_gain_scale),
+ /* ADC */
+ SOC_SINGLE_TLV("Capture Volume",
+ SUN4I_CODEC_ADC_ACTL,
+ SUN4I_CODEC_ADC_ACTL_ADCG,
+ 4,
+ 0,
+ sun4i_codec_adc_gain_scale),
};
static const struct snd_kcontrol_new sun4i_codec_left_mixer_controls[] = {
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index 21ece880..730f6151 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -685,6 +685,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_capture_source[] = {
"Stereo",
"Differential",
@@ -851,6 +870,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 Capture Switch", SND_SOC_NOPM,
0,
0,
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 51 ++++++++++++++++++++++++++++++++++++++++---
1 file changed, 48 insertions(+), 3 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index a9e10dce..315d79a3 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -905,12 +905,20 @@ 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", "DAC Playback Switch", "Right DAC" },
+ { "Right Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" },
+ { "Right Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
+ { "Right Mixer", "Line Playback Switch", "Line Right" },
+ { "Right Mixer", "FM Playback Switch", "FM Right" },
/* Left Mixer Routes */
{ "Left Mixer", NULL, "Mixer Enable" },
- { "Left Mixer", "Left DAC Playback Switch", "Left DAC" },
+ { "Left Mixer", "DAC Playback Switch", "Left DAC" },
+ { "Left Mixer", "Mic1 Playback Switch", "MIC1 Pre-Amplifier" },
+ { "Left Mixer", "Mic2 Playback Switch", "MIC2 Pre-Amplifier" },
+ { "Left Mixer", "Line Playback Switch", "Line Left" },
+ { "Left Mixer", "FM Playback Switch", "FM Left" },
/* Power Amplifier Routes */
{ "Power Amplifier", "Mixer Playback Switch", "Left Mixer" },
@@ -928,11 +936,48 @@ 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" },
+ /* see also Left Mixer Routes, Right Mixer Routes */
+
+ /* Mic2 Routes */
+ { "Left ADC", NULL, "MIC2 Pre-Amplifier" },
+ { "Right ADC", NULL, "MIC2 Pre-Amplifier" },
+ { "MIC2 Pre-Amplifier", NULL, "Mic2"},
+ { "Mic2", NULL, "VMIC" },
+ /* see also Left Mixer Routes, Right Mixer Routes */
+
+ /* Line, FM Routes */
+ /* see also Left Mixer Routes, Right Mixer Routes */
/* LNRDF Routes */
{ "Differential Line Capture Switch", "Differential", "Line Left" },
{ "Differential Line Capture Switch", "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 {
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index b1da14d1..d453af65 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -1576,6 +1576,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 = {
@@ -1595,6 +1597,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 = {
Signed-off-by: Danny Milosavljevic <[email protected]>
---
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 07ed4fd4..21ece880 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -67,9 +67,17 @@
#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)
#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)
@@ -764,6 +772,22 @@ static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] = {
SUN4I_CODEC_DAC_ACTL,
SUN4I_CODEC_DAC_ACTL_LDACLMIXS,
SUN4I_CODEC_DAC_ACTL_RDACRMIXS, 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),
+ 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),
SOC_DAPM_SINGLE("Right Mixer Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
SUN4I_CODEC_DAC_ACTL_LDACRMIXS, 1, 0),
};
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index 730f6151..a9e10dce 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -860,6 +860,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,
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index f56a59ad..b1da14d1 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -897,9 +897,22 @@ struct sun4i_codec_quirks {
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_codec_probe(struct snd_soc_codec *scodec)
+{
+ const struct sun4i_codec_quirks *quirks;
+
+ quirks = of_device_get_match_data(scodec->dev);
+ return snd_soc_add_codec_controls(scodec,
+ quirks->controls,
+ quirks->num_controls);
+}
+
static struct snd_soc_codec_driver sun4i_codec_codec = {
+ .probe = sun4i_codec_codec_probe,
.component_driver = {
.controls = sun4i_codec_controls,
.num_controls = ARRAY_SIZE(sun4i_codec_controls),
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index d453af65..07ed4fd4 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -759,15 +759,12 @@ 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,
+static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] = {
+ SOC_DAPM_DOUBLE("DAC Playback Switch",
+ SUN4I_CODEC_DAC_ACTL,
+ SUN4I_CODEC_DAC_ACTL_LDACLMIXS,
SUN4I_CODEC_DAC_ACTL_RDACRMIXS, 1, 0),
- SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
+ SOC_DAPM_SINGLE("Right Mixer Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
SUN4I_CODEC_DAC_ACTL_LDACRMIXS, 1, 0),
};
@@ -803,11 +800,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,
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index b5a3b5b3..25870a64 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -97,6 +97,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_ADCG (20)
#define SUN4I_CODEC_ADC_ACTL_ADCIS (17)
#define SUN4I_CODEC_ADC_ACTL_LNRDF (16)
@@ -115,6 +117,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
*
@@ -665,6 +670,12 @@ static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale,
150,
0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_adc_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 char * const sun4i_codec_difflinein_capture_source[] = {
"Stereo",
@@ -718,6 +729,36 @@ static const struct snd_kcontrol_new sun4i_codec_controls[] = {
sun4i_codec_adc_gain_scale),
};
+static const struct snd_kcontrol_new sun4i_codec_extra_controls[] = {
+ SOC_SINGLE_TLV("Mic1 Capture Volume",
+ SUN4I_CODEC_ADC_ACTL,
+ SUN4I_CODEC_ADC_ACTL_PREG1,
+ 3,
+ 0,
+ sun4i_codec_micin_preamp_gain_scale),
+ SOC_SINGLE_TLV("Mic2 Capture 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 Capture 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 Capture 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),
Signed-off-by: Danny Milosavljevic <[email protected]>
---
sound/soc/sunxi/sun4i-codec.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index 2f65aa72..a2435c6e 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -96,6 +96,7 @@
#define SUN4I_CODEC_ADC_ACTL_VMICEN (27)
#define SUN4I_CODEC_ADC_ACTL_VADCG (20)
#define SUN4I_CODEC_ADC_ACTL_ADCIS (17)
+#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)
@@ -644,6 +645,20 @@ static const struct snd_kcontrol_new sun4i_codec_pa_mute =
static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1);
+static const char * const sun4i_codec_difflinein_capture_source[] = {
+ "Stereo",
+ "Differential",
+};
+
+static SOC_ENUM_SINGLE_DECL(sun4i_codec_enum_difflinein_capture_source,
+ SUN4I_CODEC_ADC_ACTL,
+ SUN4I_CODEC_ADC_ACTL_LNRDF,
+ sun4i_codec_difflinein_capture_source);
+
+static const struct snd_kcontrol_new sun4i_codec_difflinein_capture_source_controls =
+ SOC_DAPM_ENUM("Differential Line Capture Switch",
+ sun4i_codec_enum_difflinein_capture_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,
@@ -720,6 +735,12 @@ 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 Capture Switch", SND_SOC_NOPM,
+ 0,
+ 0,
+ &sun4i_codec_difflinein_capture_source_controls),
+
/* Inputs */
SND_SOC_DAPM_INPUT("Mic1"),
SND_SOC_DAPM_INPUT("Mic2"),
@@ -767,6 +788,11 @@ 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" },
+
+ /* LNRDF Routes */
+ { "Differential Line Capture Switch", "Differential", "Line Left" },
+ { "Differential Line Capture Switch", "Differential", "Line Right" },
+
};
static struct snd_soc_codec_driver sun4i_codec_codec = {
Hi,
On Fri, Jun 9, 2017 at 2:22 PM, Danny Milosavljevic
<[email protected]> wrote:
> This patchset adds some mixer controls to sun4i-codec.
>
> 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.
>
> 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 (12):
> sun4i-codec: Add inputs: Mic2, Line Right, Line Left, FM Right, FM
> Left.
> sun4i-codec: Add Differential Line Capture Switch and its routes
> sun4i-codec: Add Line Playback Volume, FM Playback Volume, Mic
> Playback Volume, Capture Volume, Line Capture Volume.
> sun4i-codec: Add Mic1 Capture Volume, Mic2 Capture Volume.
> sun4i-codec: Move struct sun4i_codec_quirks further up.
> sun4i-codec: Add support for extra controls to struct
> sun4i_codec_quirks and use them.
> sun4i-codec: Add extra controls to sun4i_codec_quirks,
> sun7i_codec_quirks.
> sun4i-codec: Merge sun4i_codec_left_mixer_controls and
> sun4i_codec_right_mixer_controls into sun4i_codec_mixer_controls.
> sun4i-codec: Add Line Playback Switch, FM Playback Switch, Mic1
> Playback Switch, Mic2 Playback Switch.
> sun4i-codec: Add Left Capture Select, Right Capture Select.
> sun4i-codec: Add MIC2 Pre-Amplifier.
> sun4i-codec: Add routes for playback switches, Mic2, Capture Select.
This is not really what I meant by splitting up the patches.
First of all, in some patches, you are adding pieces that don't have
any meaningful use without following patches. Then you neglect to mention
this (or anything meaningful) in your commit messages. Your commit message
should detail what you are doing, and why you're doing it. The latter is
even more important the the former. You are supposed to justify your
changes.
Instead, try doing one meaningful change at a time. One example would be:
add the Mic2 input, including the widget, mixer kcontrols, mic gain
kcontrols, and routes. That way, one can test each individual patch.
Check out the git history of sound/soc/sunxi/sun4i-codec.c and see what
I did for the A31.
ChenYu
>
> sound/soc/sunxi/sun4i-codec.c | 283 ++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 259 insertions(+), 24 deletions(-)
>
On Fri, Jun 9, 2017 at 2:22 PM, Danny Milosavljevic
<[email protected]> wrote:
> Signed-off-by: Danny Milosavljevic <[email protected]>
> ---
> sound/soc/sunxi/sun4i-codec.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
> index 2f65aa72..a2435c6e 100644
> --- a/sound/soc/sunxi/sun4i-codec.c
> +++ b/sound/soc/sunxi/sun4i-codec.c
> @@ -96,6 +96,7 @@
> #define SUN4I_CODEC_ADC_ACTL_VMICEN (27)
> #define SUN4I_CODEC_ADC_ACTL_VADCG (20)
> #define SUN4I_CODEC_ADC_ACTL_ADCIS (17)
> +#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)
> @@ -644,6 +645,20 @@ static const struct snd_kcontrol_new sun4i_codec_pa_mute =
>
> static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1);
>
> +static const char * const sun4i_codec_difflinein_capture_source[] = {
> + "Stereo",
> + "Differential",
> +};
> +
> +static SOC_ENUM_SINGLE_DECL(sun4i_codec_enum_difflinein_capture_source,
> + SUN4I_CODEC_ADC_ACTL,
> + SUN4I_CODEC_ADC_ACTL_LNRDF,
> + sun4i_codec_difflinein_capture_source);
> +
> +static const struct snd_kcontrol_new sun4i_codec_difflinein_capture_source_controls =
> + SOC_DAPM_ENUM("Differential Line Capture Switch",
A mux control or widget should not be named "XXX Switch". Please use
"XXX Route" or "XXX Source Route". Second, this control is not limited
to capture. Please drop the "Capture" suffix. Just call it "Line Source"
or "Line In Source".
> + sun4i_codec_enum_difflinein_capture_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,
> @@ -720,6 +735,12 @@ 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 Capture Switch", SND_SOC_NOPM,
Same here.
> + 0,
> + 0,
> + &sun4i_codec_difflinein_capture_source_controls),
There is not much benefit in putting every value on a separate line,
except increasing line count and taking up screen real estate.
ChenYu
> +
> /* Inputs */
> SND_SOC_DAPM_INPUT("Mic1"),
> SND_SOC_DAPM_INPUT("Mic2"),
> @@ -767,6 +788,11 @@ 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" },
> +
> + /* LNRDF Routes */
> + { "Differential Line Capture Switch", "Differential", "Line Left" },
> + { "Differential Line Capture Switch", "Differential", "Line Right" },
> +
> };
>
> static struct snd_soc_codec_driver sun4i_codec_codec = {
On Fri, Jun 9, 2017 at 2:22 PM, Danny Milosavljevic
<[email protected]> wrote:
> Signed-off-by: Danny Milosavljevic <[email protected]>
> ---
> sound/soc/sunxi/sun4i-codec.c | 41 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
> index b5a3b5b3..25870a64 100644
> --- a/sound/soc/sunxi/sun4i-codec.c
> +++ b/sound/soc/sunxi/sun4i-codec.c
> @@ -97,6 +97,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_ADCG (20)
> #define SUN4I_CODEC_ADC_ACTL_ADCIS (17)
> #define SUN4I_CODEC_ADC_ACTL_LNRDF (16)
> @@ -115,6 +117,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)
> +
These aren't used.
> /*
> * sun6i specific registers
> *
> @@ -665,6 +670,12 @@ static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale,
> 150,
> 0);
> static DECLARE_TLV_DB_SCALE(sun4i_codec_adc_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 char * const sun4i_codec_difflinein_capture_source[] = {
> "Stereo",
> @@ -718,6 +729,36 @@ static const struct snd_kcontrol_new sun4i_codec_controls[] = {
> sun4i_codec_adc_gain_scale),
> };
>
> +static const struct snd_kcontrol_new sun4i_codec_extra_controls[] = {
> + SOC_SINGLE_TLV("Mic1 Capture Volume",
> + SUN4I_CODEC_ADC_ACTL,
> + SUN4I_CODEC_ADC_ACTL_PREG1,
> + 3,
> + 0,
> + sun4i_codec_micin_preamp_gain_scale),
You correctly name them preamp gain here.
> + SOC_SINGLE_TLV("Mic2 Capture Volume",
But incorrect name the controls. They do not just affect capture.
Call them "Mic1/Mic2 Boost Volume".
ChenYu
> + 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 Capture 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 Capture 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),
On Fri, Jun 9, 2017 at 2:22 PM, Danny Milosavljevic
<[email protected]> wrote:
Why?
> Signed-off-by: Danny Milosavljevic <[email protected]>
> ---
> sound/soc/sunxi/sun4i-codec.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
> index 25870a64..f56a59ad 100644
> --- a/sound/soc/sunxi/sun4i-codec.c
> +++ b/sound/soc/sunxi/sun4i-codec.c
> @@ -889,6 +889,16 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = {
>
> };
>
> +struct sun4i_codec_quirks {
> + const struct regmap_config *regmap_config;
> + const struct snd_soc_codec_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 struct snd_soc_codec_driver sun4i_codec_codec = {
> .component_driver = {
> .controls = sun4i_codec_controls,
> @@ -1546,16 +1556,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_codec_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,
On Fri, Jun 9, 2017 at 2:22 PM, Danny Milosavljevic
<[email protected]> wrote:
Again, why?
> Signed-off-by: Danny Milosavljevic <[email protected]>
> ---
> sound/soc/sunxi/sun4i-codec.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
> index f56a59ad..b1da14d1 100644
> --- a/sound/soc/sunxi/sun4i-codec.c
> +++ b/sound/soc/sunxi/sun4i-codec.c
> @@ -897,9 +897,22 @@ struct sun4i_codec_quirks {
> 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_codec_probe(struct snd_soc_codec *scodec)
> +{
> + const struct sun4i_codec_quirks *quirks;
> +
> + quirks = of_device_get_match_data(scodec->dev);
> + return snd_soc_add_codec_controls(scodec,
> + quirks->controls,
> + quirks->num_controls);
> +}
> +
> static struct snd_soc_codec_driver sun4i_codec_codec = {
> + .probe = sun4i_codec_codec_probe,
> .component_driver = {
> .controls = sun4i_codec_controls,
> .num_controls = ARRAY_SIZE(sun4i_codec_controls),
On Fri, Jun 9, 2017 at 2:22 PM, Danny Milosavljevic
<[email protected]> wrote:
> Signed-off-by: Danny Milosavljevic <[email protected]>
> ---
> sound/soc/sunxi/sun4i-codec.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
> index b1da14d1..d453af65 100644
> --- a/sound/soc/sunxi/sun4i-codec.c
> +++ b/sound/soc/sunxi/sun4i-codec.c
> @@ -1576,6 +1576,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),
Where did these come from?
> };
>
> static const struct sun4i_codec_quirks sun6i_a31_codec_quirks = {
> @@ -1595,6 +1597,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 = {