aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2016-11-03 03:55:53 -0400
committerMark Brown <broonie@kernel.org>2016-11-04 16:38:35 -0400
commit300a18d13f7eaec789e79dc45bce026e098b45da (patch)
tree2e7fd1c3da4b7b6eb139ca89132660b70cfe64be
parentecd5cdb4fd818b1cec55863d5de3683dad1c2f53 (diff)
ASoC: sun4i-codec: Add support for A31 board level audio routing
The A31 SoC's codec has various inputs, outputs and microphone bias supplies. These can be routed on the board in different ways, such as: - HPCOM may be connected to have the headphone DC coupled. - Microphones all use the MBIAS main microphone supply or one mic may use the HBIAS supply, which supports headset detection and buttons. - Line Out may be routed to an audio jack, or an onboard speaker amp with power controls. Add support for specifying the audio routes in the device tree. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/sound/sun4i-codec.txt33
-rw-r--r--sound/soc/sunxi/sun4i-codec.c21
2 files changed, 52 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/sound/sun4i-codec.txt b/Documentation/devicetree/bindings/sound/sun4i-codec.txt
index bf480e9683a3..d91a95377f49 100644
--- a/Documentation/devicetree/bindings/sound/sun4i-codec.txt
+++ b/Documentation/devicetree/bindings/sound/sun4i-codec.txt
@@ -22,6 +22,31 @@ Optional properties:
22Required properties for the following compatibles: 22Required properties for the following compatibles:
23 - "allwinner,sun6i-a31-codec" 23 - "allwinner,sun6i-a31-codec"
24- resets: phandle to the reset control for this device 24- resets: phandle to the reset control for this device
25- allwinner,audio-routing: A list of the connections between audio components.
26 Each entry is a pair of strings, the first being the
27 connection's sink, the second being the connection's
28 source. Valid names include:
29
30 Audio pins on the SoC:
31 "HP"
32 "HPCOM"
33 "LINEIN"
34 "LINEOUT"
35 "MIC1"
36 "MIC2"
37 "MIC3"
38
39 Microphone biases from the SoC:
40 "HBIAS"
41 "MBIAS"
42
43 Board connectors:
44 "Headphone"
45 "Headset Mic"
46 "Line In"
47 "Line Out"
48 "Mic"
49 "Speaker"
25 50
26Example: 51Example:
27codec: codec@01c22c00 { 52codec: codec@01c22c00 {
@@ -45,4 +70,12 @@ codec: codec@01c22c00 {
45 resets = <&ccu RST_APB1_CODEC>; 70 resets = <&ccu RST_APB1_CODEC>;
46 dmas = <&dma 15>, <&dma 15>; 71 dmas = <&dma 15>, <&dma 15>;
47 dma-names = "rx", "tx"; 72 dma-names = "rx", "tx";
73 allwinner,audio-routing =
74 "Headphone", "HP",
75 "Speaker", "LINEOUT",
76 "LINEIN", "Line In",
77 "MIC1", "MBIAS",
78 "MIC1", "Mic",
79 "MIC2", "HBIAS",
80 "MIC2", "Headset Mic";
48}; 81};
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index f55718fe7c5b..1934db29b2b5 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -1104,9 +1104,19 @@ static struct snd_soc_card *sun4i_codec_create_card(struct device *dev)
1104 return card; 1104 return card;
1105}; 1105};
1106 1106
1107static const struct snd_soc_dapm_widget sun6i_codec_card_dapm_widgets[] = {
1108 SND_SOC_DAPM_HP("Headphone", NULL),
1109 SND_SOC_DAPM_LINE("Line In", NULL),
1110 SND_SOC_DAPM_LINE("Line Out", NULL),
1111 SND_SOC_DAPM_MIC("Headset Mic", NULL),
1112 SND_SOC_DAPM_MIC("Mic", NULL),
1113 SND_SOC_DAPM_SPK("Speaker", sun4i_codec_spk_event),
1114};
1115
1107static struct snd_soc_card *sun6i_codec_create_card(struct device *dev) 1116static struct snd_soc_card *sun6i_codec_create_card(struct device *dev)
1108{ 1117{
1109 struct snd_soc_card *card; 1118 struct snd_soc_card *card;
1119 int ret;
1110 1120
1111 card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); 1121 card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
1112 if (!card) 1122 if (!card)
@@ -1116,8 +1126,15 @@ static struct snd_soc_card *sun6i_codec_create_card(struct device *dev)
1116 if (!card->dai_link) 1126 if (!card->dai_link)
1117 return ERR_PTR(-ENOMEM); 1127 return ERR_PTR(-ENOMEM);
1118 1128
1119 card->dev = dev; 1129 card->dev = dev;
1120 card->name = "A31 Audio Codec"; 1130 card->name = "A31 Audio Codec";
1131 card->dapm_widgets = sun6i_codec_card_dapm_widgets;
1132 card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets);
1133 card->fully_routed = true;
1134
1135 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing");
1136 if (ret)
1137 dev_warn(dev, "failed to parse audio-routing: %d\n", ret);
1121 1138
1122 return card; 1139 return card;
1123}; 1140};