Commit 6ff62eedce4f7756b092d276165d8e11edab9f28

Authored by Xiubo Li
Committed by Mark Brown
1 parent ff2878644e

ASoC: simple-card: add slot information parsing supports

For some CPU/CODEC DAI devices the slot information maybe needed. This
patch adds the slot information parsing for simple-card driver.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>

Showing 3 changed files with 25 additions and 0 deletions Side-by-side Diff

Documentation/devicetree/bindings/sound/simple-card.txt
... ... @@ -18,6 +18,8 @@
18 18 Each entry is a pair of strings, the first being the
19 19 connection's sink, the second being the connection's
20 20 source.
  21 +- dai-tdm-slot-num : Please refer to tdm-slot.txt.
  22 +- dai-tdm-slot-width : Please refer to tdm-slot.txt.
21 23  
22 24 Required subnodes:
23 25  
... ... @@ -55,6 +57,9 @@
55 57 "MIC_IN", "Microphone Jack",
56 58 "Headphone Jack", "HP_OUT",
57 59 "External Speaker", "LINE_OUT";
  60 +
  61 + dai-tdm-slot-num = <2>;
  62 + dai-tdm-slot-width = <8>;
58 63  
59 64 simple-audio-card,cpu {
60 65 sound-dai = <&sh_fsi2 0>;
include/sound/simple_card.h
... ... @@ -18,6 +18,8 @@
18 18 const char *name;
19 19 unsigned int fmt;
20 20 unsigned int sysclk;
  21 + int slots;
  22 + int slot_width;
21 23 };
22 24  
23 25 struct asoc_simple_card_info {
sound/soc/generic/simple-card.c
... ... @@ -9,11 +9,14 @@
9 9 * published by the Free Software Foundation.
10 10 */
11 11 #include <linux/clk.h>
  12 +#include <linux/device.h>
12 13 #include <linux/module.h>
13 14 #include <linux/of.h>
14 15 #include <linux/platform_device.h>
15 16 #include <linux/string.h>
16 17 #include <sound/simple_card.h>
  18 +#include <sound/soc-dai.h>
  19 +#include <sound/soc.h>
17 20  
18 21 struct simple_card_data {
19 22 struct snd_soc_card snd_card;
... ... @@ -44,6 +47,16 @@
44 47 }
45 48 }
46 49  
  50 + if (set->slots) {
  51 + ret = snd_soc_dai_set_tdm_slot(dai, 0, 0,
  52 + set->slots,
  53 + set->slot_width);
  54 + if (ret && ret != -ENOTSUPP) {
  55 + dev_err(dai->dev, "simple-card: set_tdm_slot error\n");
  56 + goto err;
  57 + }
  58 + }
  59 +
47 60 ret = 0;
48 61  
49 62 err:
... ... @@ -92,6 +105,11 @@
92 105 /* get dai->name */
93 106 ret = snd_soc_of_get_dai_name(np, name);
94 107 if (ret < 0)
  108 + goto parse_error;
  109 +
  110 + /* parse TDM slot */
  111 + ret = snd_soc_of_parse_tdm_slot(np, &dai->slots, &dai->slot_width);
  112 + if (ret)
95 113 goto parse_error;
96 114  
97 115 /*