diff options
author | Nikita Yushchenko <nikita.yoush@cogentembedded.com> | 2016-09-26 05:56:51 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-09-26 12:04:14 -0400 |
commit | 899a247cf6d5bbb9eb799261791441d7d5ea2099 (patch) | |
tree | 90641000368d883f44b6a43aa4d59f43275845db | |
parent | b0133d9c4d7600fa43499c12897136fb4f38fd57 (diff) |
ASoC: simple-card: add support for aux devices
Add device tree property to define auxiliary devices to be added to
simle-audio-card.
Together with proper audio routing definition, this allows to use
simple-card in setups where separate amplifier chip is connected to
codec's output.
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | Documentation/devicetree/bindings/sound/simple-card.txt | 37 | ||||
-rw-r--r-- | sound/soc/generic/simple-card.c | 34 |
2 files changed, 71 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index cf3979eb3578..5ecdde6d9f63 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt | |||
@@ -22,6 +22,8 @@ Optional properties: | |||
22 | headphones are attached. | 22 | headphones are attached. |
23 | - simple-audio-card,mic-det-gpio : Reference to GPIO that signals when | 23 | - simple-audio-card,mic-det-gpio : Reference to GPIO that signals when |
24 | a microphone is attached. | 24 | a microphone is attached. |
25 | - simple-audio-card,aux-devs : List of phandles pointing to auxiliary devices, such | ||
26 | as amplifiers, to be added to the sound card. | ||
25 | 27 | ||
26 | Optional subnodes: | 28 | Optional subnodes: |
27 | 29 | ||
@@ -162,3 +164,38 @@ sound { | |||
162 | }; | 164 | }; |
163 | }; | 165 | }; |
164 | }; | 166 | }; |
167 | |||
168 | Example 3 - route audio from IMX6 SSI2 through TLV320DAC3100 codec | ||
169 | through TPA6130A2 amplifier to headphones: | ||
170 | |||
171 | &i2c0 { | ||
172 | codec: tlv320dac3100@18 { | ||
173 | compatible = "ti,tlv320dac3100"; | ||
174 | ... | ||
175 | } | ||
176 | |||
177 | amp: tpa6130a2@60 { | ||
178 | compatible = "ti,tpa6130a2"; | ||
179 | ... | ||
180 | } | ||
181 | } | ||
182 | |||
183 | sound { | ||
184 | compatible = "simple-audio-card"; | ||
185 | ... | ||
186 | simple-audio-card,widgets = | ||
187 | "Headphone", "Headphone Jack"; | ||
188 | simple-audio-card,routing = | ||
189 | "Headphone Jack", "HPLEFT", | ||
190 | "Headphone Jack", "HPRIGHT", | ||
191 | "LEFTIN", "HPL", | ||
192 | "RIGHTIN", "HPR"; | ||
193 | simple-audio-card,aux-devs = <&>; | ||
194 | simple-audio-card,cpu { | ||
195 | sound-dai = <&ssi2>; | ||
196 | }; | ||
197 | simple-audio-card,codec { | ||
198 | sound-dai = <&codec>; | ||
199 | clocks = ... | ||
200 | }; | ||
201 | }; | ||
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index fe0bc5c469e2..f608f8d23f3d 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
@@ -318,6 +318,36 @@ dai_link_of_err: | |||
318 | return ret; | 318 | return ret; |
319 | } | 319 | } |
320 | 320 | ||
321 | static int asoc_simple_card_parse_aux_devs(struct device_node *node, | ||
322 | struct simple_card_data *priv) | ||
323 | { | ||
324 | struct device *dev = simple_priv_to_dev(priv); | ||
325 | struct device_node *aux_node; | ||
326 | int i, n, len; | ||
327 | |||
328 | if (!of_find_property(node, PREFIX "aux-devs", &len)) | ||
329 | return 0; /* Ok to have no aux-devs */ | ||
330 | |||
331 | n = len / sizeof(__be32); | ||
332 | if (n <= 0) | ||
333 | return -EINVAL; | ||
334 | |||
335 | priv->snd_card.aux_dev = devm_kzalloc(dev, | ||
336 | n * sizeof(*priv->snd_card.aux_dev), GFP_KERNEL); | ||
337 | if (!priv->snd_card.aux_dev) | ||
338 | return -ENOMEM; | ||
339 | |||
340 | for (i = 0; i < n; i++) { | ||
341 | aux_node = of_parse_phandle(node, PREFIX "aux-devs", i); | ||
342 | if (!aux_node) | ||
343 | return -EINVAL; | ||
344 | priv->snd_card.aux_dev[i].codec_of_node = aux_node; | ||
345 | } | ||
346 | |||
347 | priv->snd_card.num_aux_devs = n; | ||
348 | return 0; | ||
349 | } | ||
350 | |||
321 | static int asoc_simple_card_parse_of(struct device_node *node, | 351 | static int asoc_simple_card_parse_of(struct device_node *node, |
322 | struct simple_card_data *priv) | 352 | struct simple_card_data *priv) |
323 | { | 353 | { |
@@ -372,6 +402,10 @@ static int asoc_simple_card_parse_of(struct device_node *node, | |||
372 | } | 402 | } |
373 | 403 | ||
374 | ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX); | 404 | ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX); |
405 | if (ret < 0) | ||
406 | goto card_parse_end; | ||
407 | |||
408 | ret = asoc_simple_card_parse_aux_devs(node, priv); | ||
375 | 409 | ||
376 | card_parse_end: | 410 | card_parse_end: |
377 | of_node_put(dai_link); | 411 | of_node_put(dai_link); |