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 /sound/soc/generic | |
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>
Diffstat (limited to 'sound/soc/generic')
-rw-r--r-- | sound/soc/generic/simple-card.c | 34 |
1 files changed, 34 insertions, 0 deletions
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); |