From: Vasily Khoruzhick <anarsoul@gmail.com>
To: "Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Maxime Ripard" <maxime.ripard@free-electrons.com>,
"Chen-Yu Tsai" <wens@csie.org>,
"Marcus Cooper" <codekipper@gmail.com>,
"Mylène Josserand" <mylene.josserand@free-electrons.com>,
alsa-devel@alsa-project.org,
linux-arm-kernel@lists.infradead.org
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Subject: [PATCH 5/9] ASoC: sun8i-codec-analog: Use callbacks to add headphones and lineout outputs
Date: Sun, 3 Dec 2017 12:41:53 -0800 [thread overview]
Message-ID: <20171203204157.20829-6-anarsoul@gmail.com> (raw)
In-Reply-To: <20171203204157.20829-1-anarsoul@gmail.com>
From: Marcus Cooper <codekipper@gmail.com>
Widgets for headphones and lineout outputs on A64 are different enough
and use different regs, so move addition of these outputs into callback to
simplify upcoming A64 support.
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Marcus Cooper <codekipper@gmail.com>
---
sound/soc/sunxi/sun8i-codec-analog.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/sound/soc/sunxi/sun8i-codec-analog.c b/sound/soc/sunxi/sun8i-codec-analog.c
index 485e79f292c4..384f582b6f69 100644
--- a/sound/soc/sunxi/sun8i-codec-analog.c
+++ b/sound/soc/sunxi/sun8i-codec-analog.c
@@ -397,7 +397,7 @@ static const struct snd_soc_dapm_route sun8i_codec_mixer_routes[] = {
/* headphone specific controls, widgets, and routes */
static const DECLARE_TLV_DB_SCALE(sun8i_codec_hp_vol_scale, -6300, 100, 1);
-static const struct snd_kcontrol_new sun8i_codec_headphone_controls[] = {
+static const struct snd_kcontrol_new sun8i_a23_codec_hp_ctrls[] = {
SOC_SINGLE_TLV("Headphone Playback Volume",
SUN8I_ADDA_HP_VOLC,
SUN8I_ADDA_HP_VOLC_HP_VOL, 0x3f, 0,
@@ -447,7 +447,7 @@ static int sun8i_headphone_amp_event(struct snd_soc_dapm_widget *w,
return 0;
}
-static const struct snd_soc_dapm_widget sun8i_codec_headphone_widgets[] = {
+static const struct snd_soc_dapm_widget sun8i_a23_codec_hp_widgets[] = {
SND_SOC_DAPM_MUX("Headphone Source Playback Route",
SND_SOC_NOPM, 0, 0, sun8i_codec_hp_src),
SND_SOC_DAPM_OUT_DRV_E("Headphone Amp", SUN8I_ADDA_PAEN_HP_CTRL,
@@ -471,22 +471,24 @@ static const struct snd_soc_dapm_route sun8i_codec_headphone_routes[] = {
{ "HP", NULL, "Headphone Amp" },
};
-static int sun8i_codec_add_headphone(struct snd_soc_component *cmpnt)
+static int sun8i_a23_codec_add_headphone(struct snd_soc_component *cmpnt)
{
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
struct device *dev = cmpnt->dev;
int ret;
ret = snd_soc_add_component_controls(cmpnt,
- sun8i_codec_headphone_controls,
- ARRAY_SIZE(sun8i_codec_headphone_controls));
+ sun8i_a23_codec_hp_ctrls,
+ ARRAY_SIZE(
+ sun8i_a23_codec_hp_ctrls));
if (ret) {
dev_err(dev, "Failed to add Headphone controls: %d\n", ret);
return ret;
}
- ret = snd_soc_dapm_new_controls(dapm, sun8i_codec_headphone_widgets,
- ARRAY_SIZE(sun8i_codec_headphone_widgets));
+ ret = snd_soc_dapm_new_controls(dapm,
+ sun8i_a23_codec_hp_widgets,
+ ARRAY_SIZE(sun8i_a23_codec_hp_widgets));
if (ret) {
dev_err(dev, "Failed to add Headphone DAPM widgets: %d\n", ret);
return ret;
@@ -604,6 +606,7 @@ static const DECLARE_TLV_DB_RANGE(sun8i_codec_lineout_vol_scale,
0, 1, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0),
);
+
static const struct snd_kcontrol_new sun8i_codec_lineout_controls[] = {
SOC_SINGLE_TLV("Line Out Playback Volume",
SUN8I_ADDA_PHONE_GAIN_CTRL,
@@ -648,7 +651,7 @@ static const struct snd_soc_dapm_route sun8i_codec_lineout_routes[] = {
{ "LINEOUT", NULL, "Line Out Enable", },
};
-static int sun8i_codec_add_lineout(struct snd_soc_component *cmpnt)
+static int sun8i_h3_codec_add_lineout(struct snd_soc_component *cmpnt)
{
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
struct device *dev = cmpnt->dev;
@@ -751,6 +754,9 @@ struct sun8i_codec_analog_quirks {
bool has_lineout;
bool has_mbias;
bool has_mic2;
+ const struct snd_soc_component_driver *cmpnt_drv;
+ int (*add_headphone)(struct snd_soc_component *cmpnt);
+ int (*add_lineout)(struct snd_soc_component *cmpnt);
};
static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = {
@@ -759,6 +765,7 @@ static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = {
.has_linein = true,
.has_mbias = true,
.has_mic2 = true,
+ .add_headphone = sun8i_a23_codec_add_headphone,
};
static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = {
@@ -766,8 +773,10 @@ static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = {
.has_lineout = true,
.has_mbias = true,
.has_mic2 = true,
+ .add_lineout = sun8i_h3_codec_add_lineout,
};
+
static int sun8i_codec_analog_add_mixer(struct snd_soc_component *cmpnt,
const struct sun8i_codec_analog_quirks *quirks)
{
@@ -834,7 +843,7 @@ static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt)
return ret;
if (quirks->has_headphone) {
- ret = sun8i_codec_add_headphone(cmpnt);
+ ret = quirks->add_headphone(cmpnt);
if (ret)
return ret;
}
@@ -852,7 +861,7 @@ static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt)
}
if (quirks->has_lineout) {
- ret = sun8i_codec_add_lineout(cmpnt);
+ ret = quirks->add_lineout(cmpnt);
if (ret)
return ret;
}
--
2.15.0
next prev parent reply other threads:[~2017-12-03 20:42 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-03 20:41 [PATCH 0/9] Add audiocodec support for A64 SoC Vasily Khoruzhick
2017-12-03 20:41 ` [PATCH 1/9] ASoC: sun4i-i2s: Add quirk to handle fixed WSS Vasily Khoruzhick
2017-12-04 0:43 ` Chen-Yu Tsai
2017-12-03 20:41 ` [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S Vasily Khoruzhick
2017-12-04 6:42 ` Code Kipper
2017-12-04 7:34 ` Vasily Khoruzhick
2017-12-05 8:01 ` Maxime Ripard
2017-12-05 23:04 ` Vasily Khoruzhick
2017-12-06 15:27 ` Maxime Ripard
2017-12-07 9:21 ` Code Kipper
2017-12-07 9:30 ` Chen-Yu Tsai
2017-12-07 22:48 ` Vasily Khoruzhick
2017-12-08 6:40 ` Code Kipper
2017-12-08 22:16 ` Vasily Khoruzhick
2017-12-03 20:41 ` [PATCH 3/9] ASoC: sun8i-codec: Add quirk to specify aif1_lrck_div value Vasily Khoruzhick
2017-12-04 7:23 ` Code Kipper
2017-12-04 7:38 ` Chen-Yu Tsai
2017-12-04 8:26 ` Chen-Yu Tsai
2017-12-03 20:41 ` [PATCH 4/9] ASoC: sun8i-codec: Add support for A64 SoC Vasily Khoruzhick
2017-12-05 8:04 ` Maxime Ripard
2017-12-05 23:17 ` Vasily Khoruzhick
2017-12-06 15:32 ` Maxime Ripard
2017-12-06 15:48 ` Mark Brown
2017-12-06 18:53 ` Maxime Ripard
2017-12-06 19:13 ` Mark Brown
2017-12-03 20:41 ` Vasily Khoruzhick [this message]
2017-12-03 20:41 ` [PATCH 6/9] ASoC: sun8i-codec-analog: Add component driver field to quirks structure Vasily Khoruzhick
2017-12-03 20:41 ` [PATCH 7/9] ASoC: sun8i-codec-analog: Add support for A64 SoC Vasily Khoruzhick
2017-12-03 20:41 ` [PATCH 8/9] arm64: dts: allwinner: a64: Add nodes necessary for analog sound support Vasily Khoruzhick
2017-12-03 20:41 ` [PATCH 9/9] arm64: dts: allwinner: a64: Enable sound on Pine64 and SoPine Vasily Khoruzhick
2017-12-05 3:24 ` Chen-Yu Tsai
2017-12-09 19:54 ` Vasily Khoruzhick
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171203204157.20829-6-anarsoul@gmail.com \
--to=anarsoul@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=codekipper@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maxime.ripard@free-electrons.com \
--cc=mylene.josserand@free-electrons.com \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox