.. | .. |
---|
20 | 20 | #include <linux/string.h> |
---|
21 | 21 | #include <sound/simple_card_utils.h> |
---|
22 | 22 | |
---|
23 | | -struct graph_card_data { |
---|
24 | | - struct snd_soc_card snd_card; |
---|
25 | | - struct graph_dai_props { |
---|
26 | | - struct asoc_simple_dai cpu_dai; |
---|
27 | | - struct asoc_simple_dai codec_dai; |
---|
28 | | - unsigned int mclk_fs; |
---|
29 | | - } *dai_props; |
---|
30 | | - unsigned int mclk_fs; |
---|
31 | | - struct asoc_simple_jack hp_jack; |
---|
32 | | - struct asoc_simple_jack mic_jack; |
---|
33 | | - struct snd_soc_dai_link *dai_link; |
---|
34 | | - struct gpio_desc *pa_gpio; |
---|
35 | | -}; |
---|
| 23 | +#define DPCM_SELECTABLE 1 |
---|
36 | 24 | |
---|
37 | | -static int asoc_graph_card_outdrv_event(struct snd_soc_dapm_widget *w, |
---|
38 | | - struct snd_kcontrol *kcontrol, |
---|
39 | | - int event) |
---|
| 25 | +#define PREFIX "audio-graph-card," |
---|
| 26 | + |
---|
| 27 | +static int graph_outdrv_event(struct snd_soc_dapm_widget *w, |
---|
| 28 | + struct snd_kcontrol *kcontrol, |
---|
| 29 | + int event) |
---|
40 | 30 | { |
---|
41 | 31 | struct snd_soc_dapm_context *dapm = w->dapm; |
---|
42 | | - struct graph_card_data *priv = snd_soc_card_get_drvdata(dapm->card); |
---|
| 32 | + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(dapm->card); |
---|
43 | 33 | |
---|
44 | 34 | switch (event) { |
---|
45 | 35 | case SND_SOC_DAPM_POST_PMU: |
---|
.. | .. |
---|
55 | 45 | return 0; |
---|
56 | 46 | } |
---|
57 | 47 | |
---|
58 | | -static const struct snd_soc_dapm_widget asoc_graph_card_dapm_widgets[] = { |
---|
| 48 | +static const struct snd_soc_dapm_widget graph_dapm_widgets[] = { |
---|
59 | 49 | SND_SOC_DAPM_OUT_DRV_E("Amplifier", SND_SOC_NOPM, |
---|
60 | | - 0, 0, NULL, 0, asoc_graph_card_outdrv_event, |
---|
| 50 | + 0, 0, NULL, 0, graph_outdrv_event, |
---|
61 | 51 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
---|
62 | 52 | }; |
---|
63 | 53 | |
---|
64 | | -#define graph_priv_to_card(priv) (&(priv)->snd_card) |
---|
65 | | -#define graph_priv_to_props(priv, i) ((priv)->dai_props + (i)) |
---|
66 | | -#define graph_priv_to_dev(priv) (graph_priv_to_card(priv)->dev) |
---|
67 | | -#define graph_priv_to_link(priv, i) (graph_priv_to_card(priv)->dai_link + (i)) |
---|
68 | | - |
---|
69 | | -static int asoc_graph_card_startup(struct snd_pcm_substream *substream) |
---|
70 | | -{ |
---|
71 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
72 | | - struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); |
---|
73 | | - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); |
---|
74 | | - int ret; |
---|
75 | | - |
---|
76 | | - ret = asoc_simple_card_clk_enable(&dai_props->cpu_dai); |
---|
77 | | - if (ret) |
---|
78 | | - return ret; |
---|
79 | | - |
---|
80 | | - ret = asoc_simple_card_clk_enable(&dai_props->codec_dai); |
---|
81 | | - if (ret) |
---|
82 | | - asoc_simple_card_clk_disable(&dai_props->cpu_dai); |
---|
83 | | - |
---|
84 | | - return ret; |
---|
85 | | -} |
---|
86 | | - |
---|
87 | | -static void asoc_graph_card_shutdown(struct snd_pcm_substream *substream) |
---|
88 | | -{ |
---|
89 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
90 | | - struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); |
---|
91 | | - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); |
---|
92 | | - |
---|
93 | | - asoc_simple_card_clk_disable(&dai_props->cpu_dai); |
---|
94 | | - |
---|
95 | | - asoc_simple_card_clk_disable(&dai_props->codec_dai); |
---|
96 | | -} |
---|
97 | | - |
---|
98 | | -static int asoc_graph_card_hw_params(struct snd_pcm_substream *substream, |
---|
99 | | - struct snd_pcm_hw_params *params) |
---|
100 | | -{ |
---|
101 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
102 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
---|
103 | | - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
---|
104 | | - struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); |
---|
105 | | - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); |
---|
106 | | - unsigned int mclk, mclk_fs = 0; |
---|
107 | | - int ret = 0; |
---|
108 | | - |
---|
109 | | - if (priv->mclk_fs) |
---|
110 | | - mclk_fs = priv->mclk_fs; |
---|
111 | | - else if (dai_props->mclk_fs) |
---|
112 | | - mclk_fs = dai_props->mclk_fs; |
---|
113 | | - |
---|
114 | | - if (mclk_fs) { |
---|
115 | | - mclk = params_rate(params) * mclk_fs; |
---|
116 | | - ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, |
---|
117 | | - SND_SOC_CLOCK_IN); |
---|
118 | | - if (ret && ret != -ENOTSUPP) |
---|
119 | | - goto err; |
---|
120 | | - |
---|
121 | | - ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, |
---|
122 | | - SND_SOC_CLOCK_OUT); |
---|
123 | | - if (ret && ret != -ENOTSUPP) |
---|
124 | | - goto err; |
---|
125 | | - } |
---|
126 | | - return 0; |
---|
127 | | -err: |
---|
128 | | - return ret; |
---|
129 | | -} |
---|
130 | | - |
---|
131 | | -static const struct snd_soc_ops asoc_graph_card_ops = { |
---|
132 | | - .startup = asoc_graph_card_startup, |
---|
133 | | - .shutdown = asoc_graph_card_shutdown, |
---|
134 | | - .hw_params = asoc_graph_card_hw_params, |
---|
| 54 | +static const struct snd_soc_ops graph_ops = { |
---|
| 55 | + .startup = asoc_simple_startup, |
---|
| 56 | + .shutdown = asoc_simple_shutdown, |
---|
| 57 | + .hw_params = asoc_simple_hw_params, |
---|
135 | 58 | }; |
---|
136 | 59 | |
---|
137 | | -static int asoc_graph_card_dai_init(struct snd_soc_pcm_runtime *rtd) |
---|
| 60 | +static int graph_get_dai_id(struct device_node *ep) |
---|
138 | 61 | { |
---|
139 | | - struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); |
---|
140 | | - struct snd_soc_dai *codec = rtd->codec_dai; |
---|
141 | | - struct snd_soc_dai *cpu = rtd->cpu_dai; |
---|
142 | | - struct graph_dai_props *dai_props = |
---|
143 | | - graph_priv_to_props(priv, rtd->num); |
---|
| 62 | + struct device_node *node; |
---|
| 63 | + struct device_node *endpoint; |
---|
| 64 | + struct of_endpoint info; |
---|
| 65 | + int i, id; |
---|
| 66 | + const u32 *reg; |
---|
144 | 67 | int ret; |
---|
145 | 68 | |
---|
146 | | - ret = asoc_simple_card_init_dai(codec, &dai_props->codec_dai); |
---|
147 | | - if (ret < 0) |
---|
| 69 | + /* use driver specified DAI ID if exist */ |
---|
| 70 | + ret = snd_soc_get_dai_id(ep); |
---|
| 71 | + if (ret != -ENOTSUPP) |
---|
148 | 72 | return ret; |
---|
149 | 73 | |
---|
150 | | - ret = asoc_simple_card_init_dai(cpu, &dai_props->cpu_dai); |
---|
151 | | - if (ret < 0) |
---|
| 74 | + /* use endpoint/port reg if exist */ |
---|
| 75 | + ret = of_graph_parse_endpoint(ep, &info); |
---|
| 76 | + if (ret == 0) { |
---|
| 77 | + /* |
---|
| 78 | + * Because it will count port/endpoint if it doesn't have "reg". |
---|
| 79 | + * But, we can't judge whether it has "no reg", or "reg = <0>" |
---|
| 80 | + * only of_graph_parse_endpoint(). |
---|
| 81 | + * We need to check "reg" property |
---|
| 82 | + */ |
---|
| 83 | + if (of_get_property(ep, "reg", NULL)) |
---|
| 84 | + return info.id; |
---|
| 85 | + |
---|
| 86 | + node = of_get_parent(ep); |
---|
| 87 | + reg = of_get_property(node, "reg", NULL); |
---|
| 88 | + of_node_put(node); |
---|
| 89 | + if (reg) |
---|
| 90 | + return info.port; |
---|
| 91 | + } |
---|
| 92 | + node = of_graph_get_port_parent(ep); |
---|
| 93 | + |
---|
| 94 | + /* |
---|
| 95 | + * Non HDMI sound case, counting port/endpoint on its DT |
---|
| 96 | + * is enough. Let's count it. |
---|
| 97 | + */ |
---|
| 98 | + i = 0; |
---|
| 99 | + id = -1; |
---|
| 100 | + for_each_endpoint_of_node(node, endpoint) { |
---|
| 101 | + if (endpoint == ep) |
---|
| 102 | + id = i; |
---|
| 103 | + i++; |
---|
| 104 | + } |
---|
| 105 | + |
---|
| 106 | + of_node_put(node); |
---|
| 107 | + |
---|
| 108 | + if (id < 0) |
---|
| 109 | + return -ENODEV; |
---|
| 110 | + |
---|
| 111 | + return id; |
---|
| 112 | +} |
---|
| 113 | + |
---|
| 114 | +static int asoc_simple_parse_dai(struct device_node *ep, |
---|
| 115 | + struct snd_soc_dai_link_component *dlc, |
---|
| 116 | + int *is_single_link) |
---|
| 117 | +{ |
---|
| 118 | + struct device_node *node; |
---|
| 119 | + struct of_phandle_args args; |
---|
| 120 | + int ret; |
---|
| 121 | + |
---|
| 122 | + if (!ep) |
---|
| 123 | + return 0; |
---|
| 124 | + |
---|
| 125 | + node = of_graph_get_port_parent(ep); |
---|
| 126 | + |
---|
| 127 | + /* Get dai->name */ |
---|
| 128 | + args.np = node; |
---|
| 129 | + args.args[0] = graph_get_dai_id(ep); |
---|
| 130 | + args.args_count = (of_graph_get_endpoint_count(node) > 1); |
---|
| 131 | + |
---|
| 132 | + /* |
---|
| 133 | + * FIXME |
---|
| 134 | + * |
---|
| 135 | + * Here, dlc->dai_name is pointer to CPU/Codec DAI name. |
---|
| 136 | + * If user unbinded CPU or Codec driver, but not for Sound Card, |
---|
| 137 | + * dlc->dai_name is keeping unbinded CPU or Codec |
---|
| 138 | + * driver's pointer. |
---|
| 139 | + * |
---|
| 140 | + * If user re-bind CPU or Codec driver again, ALSA SoC will try |
---|
| 141 | + * to rebind Card via snd_soc_try_rebind_card(), but because of |
---|
| 142 | + * above reason, it might can't bind Sound Card. |
---|
| 143 | + * Because Sound Card is pointing to released dai_name pointer. |
---|
| 144 | + * |
---|
| 145 | + * To avoid this rebind Card issue, |
---|
| 146 | + * 1) It needs to alloc memory to keep dai_name eventhough |
---|
| 147 | + * CPU or Codec driver was unbinded, or |
---|
| 148 | + * 2) user need to rebind Sound Card everytime |
---|
| 149 | + * if he unbinded CPU or Codec. |
---|
| 150 | + */ |
---|
| 151 | + ret = snd_soc_get_dai_name(&args, &dlc->dai_name); |
---|
| 152 | + if (ret < 0) { |
---|
| 153 | + of_node_put(node); |
---|
152 | 154 | return ret; |
---|
| 155 | + } |
---|
| 156 | + |
---|
| 157 | + dlc->of_node = node; |
---|
| 158 | + |
---|
| 159 | + if (is_single_link) |
---|
| 160 | + *is_single_link = of_graph_get_endpoint_count(node) == 1; |
---|
153 | 161 | |
---|
154 | 162 | return 0; |
---|
155 | 163 | } |
---|
156 | 164 | |
---|
157 | | -static int asoc_graph_card_dai_link_of(struct device_node *cpu_port, |
---|
158 | | - struct graph_card_data *priv, |
---|
159 | | - int idx) |
---|
| 165 | +static void graph_parse_convert(struct device *dev, |
---|
| 166 | + struct device_node *ep, |
---|
| 167 | + struct asoc_simple_data *adata) |
---|
160 | 168 | { |
---|
161 | | - struct device *dev = graph_priv_to_dev(priv); |
---|
162 | | - struct snd_soc_dai_link *dai_link = graph_priv_to_link(priv, idx); |
---|
163 | | - struct graph_dai_props *dai_props = graph_priv_to_props(priv, idx); |
---|
164 | | - struct asoc_simple_dai *cpu_dai = &dai_props->cpu_dai; |
---|
165 | | - struct asoc_simple_dai *codec_dai = &dai_props->codec_dai; |
---|
166 | | - struct device_node *cpu_ep = of_get_next_child(cpu_port, NULL); |
---|
167 | | - struct device_node *codec_ep = of_graph_get_remote_endpoint(cpu_ep); |
---|
168 | | - struct device_node *rcpu_ep = of_graph_get_remote_endpoint(codec_ep); |
---|
| 169 | + struct device_node *top = dev->of_node; |
---|
| 170 | + struct device_node *port = of_get_parent(ep); |
---|
| 171 | + struct device_node *ports = of_get_parent(port); |
---|
| 172 | + struct device_node *node = of_graph_get_port_parent(ep); |
---|
| 173 | + |
---|
| 174 | + asoc_simple_parse_convert(dev, top, NULL, adata); |
---|
| 175 | + asoc_simple_parse_convert(dev, node, PREFIX, adata); |
---|
| 176 | + asoc_simple_parse_convert(dev, ports, NULL, adata); |
---|
| 177 | + asoc_simple_parse_convert(dev, port, NULL, adata); |
---|
| 178 | + asoc_simple_parse_convert(dev, ep, NULL, adata); |
---|
| 179 | + |
---|
| 180 | + of_node_put(port); |
---|
| 181 | + of_node_put(ports); |
---|
| 182 | + of_node_put(node); |
---|
| 183 | +} |
---|
| 184 | + |
---|
| 185 | +static void graph_parse_mclk_fs(struct device_node *top, |
---|
| 186 | + struct device_node *ep, |
---|
| 187 | + struct simple_dai_props *props) |
---|
| 188 | +{ |
---|
| 189 | + struct device_node *port = of_get_parent(ep); |
---|
| 190 | + struct device_node *ports = of_get_parent(port); |
---|
| 191 | + struct device_node *node = of_graph_get_port_parent(ep); |
---|
| 192 | + |
---|
| 193 | + of_property_read_u32(top, "mclk-fs", &props->mclk_fs); |
---|
| 194 | + of_property_read_u32(ports, "mclk-fs", &props->mclk_fs); |
---|
| 195 | + of_property_read_u32(port, "mclk-fs", &props->mclk_fs); |
---|
| 196 | + of_property_read_u32(ep, "mclk-fs", &props->mclk_fs); |
---|
| 197 | + |
---|
| 198 | + of_node_put(port); |
---|
| 199 | + of_node_put(ports); |
---|
| 200 | + of_node_put(node); |
---|
| 201 | +} |
---|
| 202 | + |
---|
| 203 | +static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, |
---|
| 204 | + struct device_node *cpu_ep, |
---|
| 205 | + struct device_node *codec_ep, |
---|
| 206 | + struct link_info *li, |
---|
| 207 | + int dup_codec) |
---|
| 208 | +{ |
---|
| 209 | + struct device *dev = simple_priv_to_dev(priv); |
---|
| 210 | + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); |
---|
| 211 | + struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); |
---|
| 212 | + struct device_node *top = dev->of_node; |
---|
| 213 | + struct device_node *ep = li->cpu ? cpu_ep : codec_ep; |
---|
| 214 | + struct device_node *port; |
---|
| 215 | + struct device_node *ports; |
---|
| 216 | + struct device_node *node; |
---|
| 217 | + struct asoc_simple_dai *dai; |
---|
| 218 | + struct snd_soc_dai_link_component *cpus = dai_link->cpus; |
---|
| 219 | + struct snd_soc_dai_link_component *codecs = dai_link->codecs; |
---|
169 | 220 | int ret; |
---|
170 | 221 | |
---|
171 | | - if (rcpu_ep != cpu_ep) { |
---|
172 | | - dev_err(dev, "remote-endpoint mismatch (%s/%s/%s)\n", |
---|
173 | | - cpu_ep->name, codec_ep->name, rcpu_ep->name); |
---|
174 | | - ret = -EINVAL; |
---|
175 | | - goto dai_link_of_err; |
---|
| 222 | + /* Do it all CPU endpoint, and 1st Codec endpoint */ |
---|
| 223 | + if (!li->cpu && dup_codec) |
---|
| 224 | + return 0; |
---|
| 225 | + |
---|
| 226 | + port = of_get_parent(ep); |
---|
| 227 | + ports = of_get_parent(port); |
---|
| 228 | + node = of_graph_get_port_parent(ep); |
---|
| 229 | + |
---|
| 230 | + li->link++; |
---|
| 231 | + |
---|
| 232 | + dev_dbg(dev, "link_of DPCM (%pOF)\n", ep); |
---|
| 233 | + |
---|
| 234 | + if (li->cpu) { |
---|
| 235 | + int is_single_links = 0; |
---|
| 236 | + |
---|
| 237 | + /* Codec is dummy */ |
---|
| 238 | + codecs->of_node = NULL; |
---|
| 239 | + codecs->dai_name = "snd-soc-dummy-dai"; |
---|
| 240 | + codecs->name = "snd-soc-dummy"; |
---|
| 241 | + |
---|
| 242 | + /* FE settings */ |
---|
| 243 | + dai_link->dynamic = 1; |
---|
| 244 | + dai_link->dpcm_merged_format = 1; |
---|
| 245 | + |
---|
| 246 | + dai = |
---|
| 247 | + dai_props->cpu_dai = &priv->dais[li->dais++]; |
---|
| 248 | + |
---|
| 249 | + ret = asoc_simple_parse_cpu(ep, dai_link, &is_single_links); |
---|
| 250 | + if (ret) |
---|
| 251 | + goto out_put_node; |
---|
| 252 | + |
---|
| 253 | + ret = asoc_simple_parse_clk_cpu(dev, ep, dai_link, dai); |
---|
| 254 | + if (ret < 0) |
---|
| 255 | + goto out_put_node; |
---|
| 256 | + |
---|
| 257 | + ret = asoc_simple_set_dailink_name(dev, dai_link, |
---|
| 258 | + "fe.%s", |
---|
| 259 | + cpus->dai_name); |
---|
| 260 | + if (ret < 0) |
---|
| 261 | + goto out_put_node; |
---|
| 262 | + |
---|
| 263 | + /* card->num_links includes Codec */ |
---|
| 264 | + asoc_simple_canonicalize_cpu(dai_link, is_single_links); |
---|
| 265 | + } else { |
---|
| 266 | + struct snd_soc_codec_conf *cconf; |
---|
| 267 | + |
---|
| 268 | + /* CPU is dummy */ |
---|
| 269 | + cpus->of_node = NULL; |
---|
| 270 | + cpus->dai_name = "snd-soc-dummy-dai"; |
---|
| 271 | + cpus->name = "snd-soc-dummy"; |
---|
| 272 | + |
---|
| 273 | + /* BE settings */ |
---|
| 274 | + dai_link->no_pcm = 1; |
---|
| 275 | + dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; |
---|
| 276 | + |
---|
| 277 | + dai = |
---|
| 278 | + dai_props->codec_dai = &priv->dais[li->dais++]; |
---|
| 279 | + |
---|
| 280 | + cconf = |
---|
| 281 | + dai_props->codec_conf = &priv->codec_conf[li->conf++]; |
---|
| 282 | + |
---|
| 283 | + ret = asoc_simple_parse_codec(ep, dai_link); |
---|
| 284 | + if (ret < 0) |
---|
| 285 | + goto out_put_node; |
---|
| 286 | + |
---|
| 287 | + ret = asoc_simple_parse_clk_codec(dev, ep, dai_link, dai); |
---|
| 288 | + if (ret < 0) |
---|
| 289 | + goto out_put_node; |
---|
| 290 | + |
---|
| 291 | + ret = asoc_simple_set_dailink_name(dev, dai_link, |
---|
| 292 | + "be.%s", |
---|
| 293 | + codecs->dai_name); |
---|
| 294 | + if (ret < 0) |
---|
| 295 | + goto out_put_node; |
---|
| 296 | + |
---|
| 297 | + /* check "prefix" from top node */ |
---|
| 298 | + snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, |
---|
| 299 | + "prefix"); |
---|
| 300 | + snd_soc_of_parse_node_prefix(node, cconf, codecs->of_node, |
---|
| 301 | + PREFIX "prefix"); |
---|
| 302 | + snd_soc_of_parse_node_prefix(ports, cconf, codecs->of_node, |
---|
| 303 | + "prefix"); |
---|
| 304 | + snd_soc_of_parse_node_prefix(port, cconf, codecs->of_node, |
---|
| 305 | + "prefix"); |
---|
176 | 306 | } |
---|
177 | 307 | |
---|
178 | | - ret = asoc_simple_card_parse_daifmt(dev, cpu_ep, codec_ep, |
---|
179 | | - NULL, &dai_link->dai_fmt); |
---|
| 308 | + graph_parse_convert(dev, ep, &dai_props->adata); |
---|
| 309 | + graph_parse_mclk_fs(top, ep, dai_props); |
---|
| 310 | + |
---|
| 311 | + asoc_simple_canonicalize_platform(dai_link); |
---|
| 312 | + |
---|
| 313 | + ret = asoc_simple_parse_tdm(ep, dai); |
---|
| 314 | + if (ret) |
---|
| 315 | + goto out_put_node; |
---|
| 316 | + |
---|
| 317 | + ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep, |
---|
| 318 | + NULL, &dai_link->dai_fmt); |
---|
180 | 319 | if (ret < 0) |
---|
181 | | - goto dai_link_of_err; |
---|
| 320 | + goto out_put_node; |
---|
182 | 321 | |
---|
183 | | - of_property_read_u32(rcpu_ep, "mclk-fs", &dai_props->mclk_fs); |
---|
| 322 | + snd_soc_dai_link_set_capabilities(dai_link); |
---|
184 | 323 | |
---|
185 | | - ret = asoc_simple_card_parse_graph_cpu(cpu_ep, dai_link); |
---|
186 | | - if (ret < 0) |
---|
187 | | - goto dai_link_of_err; |
---|
| 324 | + dai_link->ops = &graph_ops; |
---|
| 325 | + dai_link->init = asoc_simple_dai_init; |
---|
188 | 326 | |
---|
189 | | - ret = asoc_simple_card_parse_graph_codec(codec_ep, dai_link); |
---|
190 | | - if (ret < 0) |
---|
191 | | - goto dai_link_of_err; |
---|
192 | | - |
---|
193 | | - ret = asoc_simple_card_of_parse_tdm(cpu_ep, cpu_dai); |
---|
194 | | - if (ret < 0) |
---|
195 | | - goto dai_link_of_err; |
---|
196 | | - |
---|
197 | | - ret = asoc_simple_card_of_parse_tdm(codec_ep, codec_dai); |
---|
198 | | - if (ret < 0) |
---|
199 | | - goto dai_link_of_err; |
---|
200 | | - |
---|
201 | | - ret = asoc_simple_card_parse_clk_cpu(dev, cpu_ep, dai_link, cpu_dai); |
---|
202 | | - if (ret < 0) |
---|
203 | | - goto dai_link_of_err; |
---|
204 | | - |
---|
205 | | - ret = asoc_simple_card_parse_clk_codec(dev, codec_ep, dai_link, codec_dai); |
---|
206 | | - if (ret < 0) |
---|
207 | | - goto dai_link_of_err; |
---|
208 | | - |
---|
209 | | - ret = asoc_simple_card_canonicalize_dailink(dai_link); |
---|
210 | | - if (ret < 0) |
---|
211 | | - goto dai_link_of_err; |
---|
212 | | - |
---|
213 | | - ret = asoc_simple_card_set_dailink_name(dev, dai_link, |
---|
214 | | - "%s-%s", |
---|
215 | | - dai_link->cpu_dai_name, |
---|
216 | | - dai_link->codec_dai_name); |
---|
217 | | - if (ret < 0) |
---|
218 | | - goto dai_link_of_err; |
---|
219 | | - |
---|
220 | | - dai_link->ops = &asoc_graph_card_ops; |
---|
221 | | - dai_link->init = asoc_graph_card_dai_init; |
---|
222 | | - |
---|
223 | | - asoc_simple_card_canonicalize_cpu(dai_link, |
---|
224 | | - of_graph_get_endpoint_count(dai_link->cpu_of_node) == 1); |
---|
225 | | - |
---|
226 | | -dai_link_of_err: |
---|
227 | | - of_node_put(cpu_ep); |
---|
228 | | - of_node_put(rcpu_ep); |
---|
229 | | - of_node_put(codec_ep); |
---|
230 | | - |
---|
| 327 | +out_put_node: |
---|
| 328 | + of_node_put(ports); |
---|
| 329 | + of_node_put(port); |
---|
| 330 | + of_node_put(node); |
---|
231 | 331 | return ret; |
---|
232 | 332 | } |
---|
233 | 333 | |
---|
234 | | -static int asoc_graph_card_parse_of(struct graph_card_data *priv) |
---|
| 334 | +static int graph_dai_link_of(struct asoc_simple_priv *priv, |
---|
| 335 | + struct device_node *cpu_ep, |
---|
| 336 | + struct device_node *codec_ep, |
---|
| 337 | + struct link_info *li) |
---|
235 | 338 | { |
---|
236 | | - struct of_phandle_iterator it; |
---|
237 | | - struct device *dev = graph_priv_to_dev(priv); |
---|
238 | | - struct snd_soc_card *card = graph_priv_to_card(priv); |
---|
239 | | - struct device_node *node = dev->of_node; |
---|
240 | | - int rc, idx = 0; |
---|
241 | | - int ret; |
---|
| 339 | + struct device *dev = simple_priv_to_dev(priv); |
---|
| 340 | + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); |
---|
| 341 | + struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); |
---|
| 342 | + struct device_node *top = dev->of_node; |
---|
| 343 | + struct asoc_simple_dai *cpu_dai; |
---|
| 344 | + struct asoc_simple_dai *codec_dai; |
---|
| 345 | + int ret, single_cpu = 0; |
---|
242 | 346 | |
---|
243 | | - ret = asoc_simple_card_of_parse_widgets(card, NULL); |
---|
244 | | - if (ret < 0) |
---|
245 | | - return ret; |
---|
| 347 | + /* Do it only CPU turn */ |
---|
| 348 | + if (!li->cpu) |
---|
| 349 | + return 0; |
---|
246 | 350 | |
---|
247 | | - ret = asoc_simple_card_of_parse_routing(card, NULL, 1); |
---|
248 | | - if (ret < 0) |
---|
249 | | - return ret; |
---|
| 351 | + dev_dbg(dev, "link_of (%pOF)\n", cpu_ep); |
---|
| 352 | + |
---|
| 353 | + li->link++; |
---|
| 354 | + |
---|
| 355 | + cpu_dai = |
---|
| 356 | + dai_props->cpu_dai = &priv->dais[li->dais++]; |
---|
| 357 | + codec_dai = |
---|
| 358 | + dai_props->codec_dai = &priv->dais[li->dais++]; |
---|
250 | 359 | |
---|
251 | 360 | /* Factor to mclk, used in hw_params() */ |
---|
252 | | - of_property_read_u32(node, "mclk-fs", &priv->mclk_fs); |
---|
| 361 | + graph_parse_mclk_fs(top, cpu_ep, dai_props); |
---|
| 362 | + graph_parse_mclk_fs(top, codec_ep, dai_props); |
---|
253 | 363 | |
---|
| 364 | + ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep, |
---|
| 365 | + NULL, &dai_link->dai_fmt); |
---|
| 366 | + if (ret < 0) |
---|
| 367 | + return ret; |
---|
| 368 | + |
---|
| 369 | + ret = asoc_simple_parse_cpu(cpu_ep, dai_link, &single_cpu); |
---|
| 370 | + if (ret < 0) |
---|
| 371 | + return ret; |
---|
| 372 | + |
---|
| 373 | + ret = asoc_simple_parse_codec(codec_ep, dai_link); |
---|
| 374 | + if (ret < 0) |
---|
| 375 | + return ret; |
---|
| 376 | + |
---|
| 377 | + ret = asoc_simple_parse_tdm(cpu_ep, cpu_dai); |
---|
| 378 | + if (ret < 0) |
---|
| 379 | + return ret; |
---|
| 380 | + |
---|
| 381 | + ret = asoc_simple_parse_tdm(codec_ep, codec_dai); |
---|
| 382 | + if (ret < 0) |
---|
| 383 | + return ret; |
---|
| 384 | + |
---|
| 385 | + ret = asoc_simple_parse_clk_cpu(dev, cpu_ep, dai_link, cpu_dai); |
---|
| 386 | + if (ret < 0) |
---|
| 387 | + return ret; |
---|
| 388 | + |
---|
| 389 | + ret = asoc_simple_parse_clk_codec(dev, codec_ep, dai_link, codec_dai); |
---|
| 390 | + if (ret < 0) |
---|
| 391 | + return ret; |
---|
| 392 | + |
---|
| 393 | + ret = asoc_simple_set_dailink_name(dev, dai_link, |
---|
| 394 | + "%s-%s", |
---|
| 395 | + dai_link->cpus->dai_name, |
---|
| 396 | + dai_link->codecs->dai_name); |
---|
| 397 | + if (ret < 0) |
---|
| 398 | + return ret; |
---|
| 399 | + |
---|
| 400 | + dai_link->ops = &graph_ops; |
---|
| 401 | + dai_link->init = asoc_simple_dai_init; |
---|
| 402 | + |
---|
| 403 | + asoc_simple_canonicalize_cpu(dai_link, single_cpu); |
---|
| 404 | + asoc_simple_canonicalize_platform(dai_link); |
---|
| 405 | + |
---|
| 406 | + return 0; |
---|
| 407 | +} |
---|
| 408 | + |
---|
| 409 | +static int graph_for_each_link(struct asoc_simple_priv *priv, |
---|
| 410 | + struct link_info *li, |
---|
| 411 | + int (*func_noml)(struct asoc_simple_priv *priv, |
---|
| 412 | + struct device_node *cpu_ep, |
---|
| 413 | + struct device_node *codec_ep, |
---|
| 414 | + struct link_info *li), |
---|
| 415 | + int (*func_dpcm)(struct asoc_simple_priv *priv, |
---|
| 416 | + struct device_node *cpu_ep, |
---|
| 417 | + struct device_node *codec_ep, |
---|
| 418 | + struct link_info *li, int dup_codec)) |
---|
| 419 | +{ |
---|
| 420 | + struct of_phandle_iterator it; |
---|
| 421 | + struct device *dev = simple_priv_to_dev(priv); |
---|
| 422 | + struct device_node *node = dev->of_node; |
---|
| 423 | + struct device_node *cpu_port; |
---|
| 424 | + struct device_node *cpu_ep; |
---|
| 425 | + struct device_node *codec_ep; |
---|
| 426 | + struct device_node *codec_port; |
---|
| 427 | + struct device_node *codec_port_old = NULL; |
---|
| 428 | + struct asoc_simple_data adata; |
---|
| 429 | + uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev); |
---|
| 430 | + int rc, ret; |
---|
| 431 | + |
---|
| 432 | + /* loop for all listed CPU port */ |
---|
254 | 433 | of_for_each_phandle(&it, rc, node, "dais", NULL, 0) { |
---|
255 | | - ret = asoc_graph_card_dai_link_of(it.node, priv, idx++); |
---|
256 | | - if (ret < 0) { |
---|
257 | | - of_node_put(it.node); |
---|
| 434 | + cpu_port = it.node; |
---|
| 435 | + cpu_ep = NULL; |
---|
258 | 436 | |
---|
259 | | - return ret; |
---|
| 437 | + /* loop for all CPU endpoint */ |
---|
| 438 | + while (1) { |
---|
| 439 | + cpu_ep = of_get_next_child(cpu_port, cpu_ep); |
---|
| 440 | + if (!cpu_ep) |
---|
| 441 | + break; |
---|
| 442 | + |
---|
| 443 | + /* get codec */ |
---|
| 444 | + codec_ep = of_graph_get_remote_endpoint(cpu_ep); |
---|
| 445 | + codec_port = of_get_parent(codec_ep); |
---|
| 446 | + |
---|
| 447 | + /* get convert-xxx property */ |
---|
| 448 | + memset(&adata, 0, sizeof(adata)); |
---|
| 449 | + graph_parse_convert(dev, codec_ep, &adata); |
---|
| 450 | + graph_parse_convert(dev, cpu_ep, &adata); |
---|
| 451 | + |
---|
| 452 | + /* |
---|
| 453 | + * It is DPCM |
---|
| 454 | + * if Codec port has many endpoints, |
---|
| 455 | + * or has convert-xxx property |
---|
| 456 | + */ |
---|
| 457 | + if (dpcm_selectable && |
---|
| 458 | + ((of_get_child_count(codec_port) > 1) || |
---|
| 459 | + adata.convert_rate || adata.convert_channels)) |
---|
| 460 | + ret = func_dpcm(priv, cpu_ep, codec_ep, li, |
---|
| 461 | + (codec_port_old == codec_port)); |
---|
| 462 | + /* else normal sound */ |
---|
| 463 | + else |
---|
| 464 | + ret = func_noml(priv, cpu_ep, codec_ep, li); |
---|
| 465 | + |
---|
| 466 | + of_node_put(codec_ep); |
---|
| 467 | + of_node_put(codec_port); |
---|
| 468 | + |
---|
| 469 | + if (ret < 0) { |
---|
| 470 | + of_node_put(cpu_ep); |
---|
| 471 | + return ret; |
---|
| 472 | + } |
---|
| 473 | + |
---|
| 474 | + codec_port_old = codec_port; |
---|
260 | 475 | } |
---|
261 | 476 | } |
---|
262 | 477 | |
---|
263 | | - return asoc_simple_card_parse_card_name(card, NULL); |
---|
| 478 | + return 0; |
---|
264 | 479 | } |
---|
265 | 480 | |
---|
266 | | -static int asoc_graph_get_dais_count(struct device *dev) |
---|
| 481 | +static int graph_parse_of(struct asoc_simple_priv *priv) |
---|
267 | 482 | { |
---|
268 | | - struct of_phandle_iterator it; |
---|
269 | | - struct device_node *node = dev->of_node; |
---|
270 | | - int count = 0; |
---|
271 | | - int rc; |
---|
272 | | - |
---|
273 | | - of_for_each_phandle(&it, rc, node, "dais", NULL, 0) |
---|
274 | | - count++; |
---|
275 | | - |
---|
276 | | - return count; |
---|
277 | | -} |
---|
278 | | - |
---|
279 | | -static int asoc_graph_soc_card_probe(struct snd_soc_card *card) |
---|
280 | | -{ |
---|
281 | | - struct graph_card_data *priv = snd_soc_card_get_drvdata(card); |
---|
| 483 | + struct snd_soc_card *card = simple_priv_to_card(priv); |
---|
| 484 | + struct link_info li; |
---|
282 | 485 | int ret; |
---|
283 | 486 | |
---|
284 | | - ret = asoc_simple_card_init_hp(card, &priv->hp_jack, NULL); |
---|
| 487 | + ret = asoc_simple_parse_widgets(card, NULL); |
---|
285 | 488 | if (ret < 0) |
---|
286 | 489 | return ret; |
---|
287 | 490 | |
---|
288 | | - ret = asoc_simple_card_init_mic(card, &priv->mic_jack, NULL); |
---|
| 491 | + ret = asoc_simple_parse_routing(card, NULL); |
---|
| 492 | + if (ret < 0) |
---|
| 493 | + return ret; |
---|
| 494 | + |
---|
| 495 | + memset(&li, 0, sizeof(li)); |
---|
| 496 | + for (li.cpu = 1; li.cpu >= 0; li.cpu--) { |
---|
| 497 | + /* |
---|
| 498 | + * Detect all CPU first, and Detect all Codec 2nd. |
---|
| 499 | + * |
---|
| 500 | + * In Normal sound case, all DAIs are detected |
---|
| 501 | + * as "CPU-Codec". |
---|
| 502 | + * |
---|
| 503 | + * In DPCM sound case, |
---|
| 504 | + * all CPUs are detected as "CPU-dummy", and |
---|
| 505 | + * all Codecs are detected as "dummy-Codec". |
---|
| 506 | + * To avoid random sub-device numbering, |
---|
| 507 | + * detect "dummy-Codec" in last; |
---|
| 508 | + */ |
---|
| 509 | + ret = graph_for_each_link(priv, &li, |
---|
| 510 | + graph_dai_link_of, |
---|
| 511 | + graph_dai_link_of_dpcm); |
---|
| 512 | + if (ret < 0) |
---|
| 513 | + return ret; |
---|
| 514 | + } |
---|
| 515 | + |
---|
| 516 | + return asoc_simple_parse_card_name(card, NULL); |
---|
| 517 | +} |
---|
| 518 | + |
---|
| 519 | +static int graph_count_noml(struct asoc_simple_priv *priv, |
---|
| 520 | + struct device_node *cpu_ep, |
---|
| 521 | + struct device_node *codec_ep, |
---|
| 522 | + struct link_info *li) |
---|
| 523 | +{ |
---|
| 524 | + struct device *dev = simple_priv_to_dev(priv); |
---|
| 525 | + |
---|
| 526 | + li->link += 1; /* 1xCPU-Codec */ |
---|
| 527 | + li->dais += 2; /* 1xCPU + 1xCodec */ |
---|
| 528 | + |
---|
| 529 | + dev_dbg(dev, "Count As Normal\n"); |
---|
| 530 | + |
---|
| 531 | + return 0; |
---|
| 532 | +} |
---|
| 533 | + |
---|
| 534 | +static int graph_count_dpcm(struct asoc_simple_priv *priv, |
---|
| 535 | + struct device_node *cpu_ep, |
---|
| 536 | + struct device_node *codec_ep, |
---|
| 537 | + struct link_info *li, |
---|
| 538 | + int dup_codec) |
---|
| 539 | +{ |
---|
| 540 | + struct device *dev = simple_priv_to_dev(priv); |
---|
| 541 | + |
---|
| 542 | + li->link++; /* 1xCPU-dummy */ |
---|
| 543 | + li->dais++; /* 1xCPU */ |
---|
| 544 | + |
---|
| 545 | + if (!dup_codec) { |
---|
| 546 | + li->link++; /* 1xdummy-Codec */ |
---|
| 547 | + li->conf++; /* 1xdummy-Codec */ |
---|
| 548 | + li->dais++; /* 1xCodec */ |
---|
| 549 | + } |
---|
| 550 | + |
---|
| 551 | + dev_dbg(dev, "Count As DPCM\n"); |
---|
| 552 | + |
---|
| 553 | + return 0; |
---|
| 554 | +} |
---|
| 555 | + |
---|
| 556 | +static void graph_get_dais_count(struct asoc_simple_priv *priv, |
---|
| 557 | + struct link_info *li) |
---|
| 558 | +{ |
---|
| 559 | + struct device *dev = simple_priv_to_dev(priv); |
---|
| 560 | + |
---|
| 561 | + /* |
---|
| 562 | + * link_num : number of links. |
---|
| 563 | + * CPU-Codec / CPU-dummy / dummy-Codec |
---|
| 564 | + * dais_num : number of DAIs |
---|
| 565 | + * ccnf_num : number of codec_conf |
---|
| 566 | + * same number for "dummy-Codec" |
---|
| 567 | + * |
---|
| 568 | + * ex1) |
---|
| 569 | + * CPU0 --- Codec0 link : 5 |
---|
| 570 | + * CPU1 --- Codec1 dais : 7 |
---|
| 571 | + * CPU2 -/ ccnf : 1 |
---|
| 572 | + * CPU3 --- Codec2 |
---|
| 573 | + * |
---|
| 574 | + * => 5 links = 2xCPU-Codec + 2xCPU-dummy + 1xdummy-Codec |
---|
| 575 | + * => 7 DAIs = 4xCPU + 3xCodec |
---|
| 576 | + * => 1 ccnf = 1xdummy-Codec |
---|
| 577 | + * |
---|
| 578 | + * ex2) |
---|
| 579 | + * CPU0 --- Codec0 link : 5 |
---|
| 580 | + * CPU1 --- Codec1 dais : 6 |
---|
| 581 | + * CPU2 -/ ccnf : 1 |
---|
| 582 | + * CPU3 -/ |
---|
| 583 | + * |
---|
| 584 | + * => 5 links = 1xCPU-Codec + 3xCPU-dummy + 1xdummy-Codec |
---|
| 585 | + * => 6 DAIs = 4xCPU + 2xCodec |
---|
| 586 | + * => 1 ccnf = 1xdummy-Codec |
---|
| 587 | + * |
---|
| 588 | + * ex3) |
---|
| 589 | + * CPU0 --- Codec0 link : 6 |
---|
| 590 | + * CPU1 -/ dais : 6 |
---|
| 591 | + * CPU2 --- Codec1 ccnf : 2 |
---|
| 592 | + * CPU3 -/ |
---|
| 593 | + * |
---|
| 594 | + * => 6 links = 0xCPU-Codec + 4xCPU-dummy + 2xdummy-Codec |
---|
| 595 | + * => 6 DAIs = 4xCPU + 2xCodec |
---|
| 596 | + * => 2 ccnf = 2xdummy-Codec |
---|
| 597 | + * |
---|
| 598 | + * ex4) |
---|
| 599 | + * CPU0 --- Codec0 (convert-rate) link : 3 |
---|
| 600 | + * CPU1 --- Codec1 dais : 4 |
---|
| 601 | + * ccnf : 1 |
---|
| 602 | + * |
---|
| 603 | + * => 3 links = 1xCPU-Codec + 1xCPU-dummy + 1xdummy-Codec |
---|
| 604 | + * => 4 DAIs = 2xCPU + 2xCodec |
---|
| 605 | + * => 1 ccnf = 1xdummy-Codec |
---|
| 606 | + */ |
---|
| 607 | + graph_for_each_link(priv, li, |
---|
| 608 | + graph_count_noml, |
---|
| 609 | + graph_count_dpcm); |
---|
| 610 | + dev_dbg(dev, "link %d, dais %d, ccnf %d\n", |
---|
| 611 | + li->link, li->dais, li->conf); |
---|
| 612 | +} |
---|
| 613 | + |
---|
| 614 | +static int graph_card_probe(struct snd_soc_card *card) |
---|
| 615 | +{ |
---|
| 616 | + struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card); |
---|
| 617 | + int ret; |
---|
| 618 | + |
---|
| 619 | + ret = asoc_simple_init_hp(card, &priv->hp_jack, NULL); |
---|
| 620 | + if (ret < 0) |
---|
| 621 | + return ret; |
---|
| 622 | + |
---|
| 623 | + ret = asoc_simple_init_mic(card, &priv->mic_jack, NULL); |
---|
289 | 624 | if (ret < 0) |
---|
290 | 625 | return ret; |
---|
291 | 626 | |
---|
292 | 627 | return 0; |
---|
293 | 628 | } |
---|
294 | 629 | |
---|
295 | | -static int asoc_graph_card_probe(struct platform_device *pdev) |
---|
| 630 | +static int graph_probe(struct platform_device *pdev) |
---|
296 | 631 | { |
---|
297 | | - struct graph_card_data *priv; |
---|
298 | | - struct snd_soc_dai_link *dai_link; |
---|
299 | | - struct graph_dai_props *dai_props; |
---|
| 632 | + struct asoc_simple_priv *priv; |
---|
300 | 633 | struct device *dev = &pdev->dev; |
---|
301 | 634 | struct snd_soc_card *card; |
---|
302 | | - int num, ret; |
---|
| 635 | + struct link_info li; |
---|
| 636 | + int ret; |
---|
303 | 637 | |
---|
304 | 638 | /* Allocate the private data and the DAI link array */ |
---|
305 | 639 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
---|
306 | 640 | if (!priv) |
---|
307 | 641 | return -ENOMEM; |
---|
308 | 642 | |
---|
309 | | - num = asoc_graph_get_dais_count(dev); |
---|
310 | | - if (num == 0) |
---|
| 643 | + card = simple_priv_to_card(priv); |
---|
| 644 | + card->owner = THIS_MODULE; |
---|
| 645 | + card->dev = dev; |
---|
| 646 | + card->dapm_widgets = graph_dapm_widgets; |
---|
| 647 | + card->num_dapm_widgets = ARRAY_SIZE(graph_dapm_widgets); |
---|
| 648 | + card->probe = graph_card_probe; |
---|
| 649 | + |
---|
| 650 | + memset(&li, 0, sizeof(li)); |
---|
| 651 | + graph_get_dais_count(priv, &li); |
---|
| 652 | + if (!li.link || !li.dais) |
---|
311 | 653 | return -EINVAL; |
---|
312 | 654 | |
---|
313 | | - dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL); |
---|
314 | | - dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL); |
---|
315 | | - if (!dai_props || !dai_link) |
---|
316 | | - return -ENOMEM; |
---|
| 655 | + ret = asoc_simple_init_priv(priv, &li); |
---|
| 656 | + if (ret < 0) |
---|
| 657 | + return ret; |
---|
317 | 658 | |
---|
318 | 659 | priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); |
---|
319 | 660 | if (IS_ERR(priv->pa_gpio)) { |
---|
.. | .. |
---|
322 | 663 | return ret; |
---|
323 | 664 | } |
---|
324 | 665 | |
---|
325 | | - priv->dai_props = dai_props; |
---|
326 | | - priv->dai_link = dai_link; |
---|
327 | | - |
---|
328 | | - /* Init snd_soc_card */ |
---|
329 | | - card = graph_priv_to_card(priv); |
---|
330 | | - card->owner = THIS_MODULE; |
---|
331 | | - card->dev = dev; |
---|
332 | | - card->dai_link = dai_link; |
---|
333 | | - card->num_links = num; |
---|
334 | | - card->dapm_widgets = asoc_graph_card_dapm_widgets; |
---|
335 | | - card->num_dapm_widgets = ARRAY_SIZE(asoc_graph_card_dapm_widgets); |
---|
336 | | - card->probe = asoc_graph_soc_card_probe; |
---|
337 | | - |
---|
338 | | - ret = asoc_graph_card_parse_of(priv); |
---|
| 666 | + ret = graph_parse_of(priv); |
---|
339 | 667 | if (ret < 0) { |
---|
340 | 668 | if (ret != -EPROBE_DEFER) |
---|
341 | 669 | dev_err(dev, "parse error %d\n", ret); |
---|
.. | .. |
---|
344 | 672 | |
---|
345 | 673 | snd_soc_card_set_drvdata(card, priv); |
---|
346 | 674 | |
---|
| 675 | + asoc_simple_debug_info(priv); |
---|
| 676 | + |
---|
347 | 677 | ret = devm_snd_soc_register_card(dev, card); |
---|
348 | 678 | if (ret < 0) |
---|
349 | 679 | goto err; |
---|
350 | 680 | |
---|
351 | 681 | return 0; |
---|
352 | 682 | err: |
---|
353 | | - asoc_simple_card_clean_reference(card); |
---|
| 683 | + asoc_simple_clean_reference(card); |
---|
354 | 684 | |
---|
355 | 685 | return ret; |
---|
356 | 686 | } |
---|
357 | 687 | |
---|
358 | | -static int asoc_graph_card_remove(struct platform_device *pdev) |
---|
| 688 | +static int graph_remove(struct platform_device *pdev) |
---|
359 | 689 | { |
---|
360 | 690 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
---|
361 | 691 | |
---|
362 | | - return asoc_simple_card_clean_reference(card); |
---|
| 692 | + return asoc_simple_clean_reference(card); |
---|
363 | 693 | } |
---|
364 | 694 | |
---|
365 | | -static const struct of_device_id asoc_graph_of_match[] = { |
---|
| 695 | +static const struct of_device_id graph_of_match[] = { |
---|
366 | 696 | { .compatible = "audio-graph-card", }, |
---|
| 697 | + { .compatible = "audio-graph-scu-card", |
---|
| 698 | + .data = (void *)DPCM_SELECTABLE }, |
---|
367 | 699 | {}, |
---|
368 | 700 | }; |
---|
369 | | -MODULE_DEVICE_TABLE(of, asoc_graph_of_match); |
---|
| 701 | +MODULE_DEVICE_TABLE(of, graph_of_match); |
---|
370 | 702 | |
---|
371 | | -static struct platform_driver asoc_graph_card = { |
---|
| 703 | +static struct platform_driver graph_card = { |
---|
372 | 704 | .driver = { |
---|
373 | 705 | .name = "asoc-audio-graph-card", |
---|
374 | 706 | .pm = &snd_soc_pm_ops, |
---|
375 | | - .of_match_table = asoc_graph_of_match, |
---|
| 707 | + .of_match_table = graph_of_match, |
---|
376 | 708 | }, |
---|
377 | | - .probe = asoc_graph_card_probe, |
---|
378 | | - .remove = asoc_graph_card_remove, |
---|
| 709 | + .probe = graph_probe, |
---|
| 710 | + .remove = graph_remove, |
---|
379 | 711 | }; |
---|
380 | | -module_platform_driver(asoc_graph_card); |
---|
| 712 | +module_platform_driver(graph_card); |
---|
381 | 713 | |
---|
382 | 714 | MODULE_ALIAS("platform:asoc-audio-graph-card"); |
---|
383 | 715 | MODULE_LICENSE("GPL v2"); |
---|