1 // SPDX-License-Identifier: GPL-2.0
5 // Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
8 #include <linux/gpio.h>
9 #include <linux/gpio/consumer.h>
10 #include <linux/module.h>
12 #include <linux/of_gpio.h>
13 #include <linux/of_graph.h>
14 #include <sound/jack.h>
15 #include <sound/pcm_params.h>
16 #include <sound/simple_card_utils.h>
18 void asoc_simple_convert_fixup(struct asoc_simple_data *data,
19 struct snd_pcm_hw_params *params)
21 struct snd_interval *rate = hw_param_interval(params,
22 SNDRV_PCM_HW_PARAM_RATE);
23 struct snd_interval *channels = hw_param_interval(params,
24 SNDRV_PCM_HW_PARAM_CHANNELS);
26 if (data->convert_rate)
28 rate->max = data->convert_rate;
30 if (data->convert_channels)
32 channels->max = data->convert_channels;
34 EXPORT_SYMBOL_GPL(asoc_simple_convert_fixup);
36 void asoc_simple_parse_convert(struct device_node *np,
38 struct asoc_simple_data *data)
45 /* sampling rate convert */
46 snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-rate");
47 of_property_read_u32(np, prop, &data->convert_rate);
49 /* channels transfer */
50 snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-channels");
51 of_property_read_u32(np, prop, &data->convert_channels);
53 EXPORT_SYMBOL_GPL(asoc_simple_parse_convert);
55 int asoc_simple_parse_daifmt(struct device *dev,
56 struct device_node *node,
57 struct device_node *codec,
61 struct device_node *bitclkmaster = NULL;
62 struct device_node *framemaster = NULL;
65 daifmt = snd_soc_daifmt_parse_format(node, prefix);
67 snd_soc_daifmt_parse_clock_provider_as_phandle(node, prefix, &bitclkmaster, &framemaster);
68 if (!bitclkmaster && !framemaster) {
70 * No dai-link level and master setting was not found from
71 * sound node level, revert back to legacy DT parsing and
72 * take the settings from codec node.
74 dev_dbg(dev, "Revert to legacy daifmt parsing\n");
76 daifmt |= snd_soc_daifmt_parse_clock_provider_as_flag(codec, NULL);
78 daifmt |= snd_soc_daifmt_clock_provider_from_bitmap(
79 ((codec == bitclkmaster) << 4) | (codec == framemaster));
82 of_node_put(bitclkmaster);
83 of_node_put(framemaster);
89 EXPORT_SYMBOL_GPL(asoc_simple_parse_daifmt);
91 int asoc_simple_parse_tdm_width_map(struct device *dev, struct device_node *np,
92 struct asoc_simple_dai *dai)
94 u32 *array_values, *p;
97 if (!of_property_read_bool(np, "dai-tdm-slot-width-map"))
100 n = of_property_count_elems_of_size(np, "dai-tdm-slot-width-map", sizeof(u32));
102 dev_err(dev, "Invalid number of cells for dai-tdm-slot-width-map\n");
106 dai->tdm_width_map = devm_kcalloc(dev, n, sizeof(*dai->tdm_width_map), GFP_KERNEL);
107 if (!dai->tdm_width_map)
110 array_values = kcalloc(n, sizeof(*array_values), GFP_KERNEL);
114 ret = of_property_read_u32_array(np, "dai-tdm-slot-width-map", array_values, n);
116 dev_err(dev, "Could not read dai-tdm-slot-width-map: %d\n", ret);
121 for (i = 0; i < n / 3; ++i) {
122 dai->tdm_width_map[i].sample_bits = *p++;
123 dai->tdm_width_map[i].slot_width = *p++;
124 dai->tdm_width_map[i].slot_count = *p++;
127 dai->n_tdm_widths = i;
134 EXPORT_SYMBOL_GPL(asoc_simple_parse_tdm_width_map);
136 int asoc_simple_set_dailink_name(struct device *dev,
137 struct snd_soc_dai_link *dai_link,
138 const char *fmt, ...)
145 name = devm_kvasprintf(dev, GFP_KERNEL, fmt, ap);
151 dai_link->name = name;
152 dai_link->stream_name = name;
157 EXPORT_SYMBOL_GPL(asoc_simple_set_dailink_name);
159 int asoc_simple_parse_card_name(struct snd_soc_card *card,
167 /* Parse the card name from DT */
168 ret = snd_soc_of_parse_card_name(card, "label");
169 if (ret < 0 || !card->name) {
172 snprintf(prop, sizeof(prop), "%sname", prefix);
173 ret = snd_soc_of_parse_card_name(card, prop);
178 if (!card->name && card->dai_link)
179 card->name = card->dai_link->name;
183 EXPORT_SYMBOL_GPL(asoc_simple_parse_card_name);
185 static int asoc_simple_clk_enable(struct asoc_simple_dai *dai)
188 return clk_prepare_enable(dai->clk);
193 static void asoc_simple_clk_disable(struct asoc_simple_dai *dai)
196 clk_disable_unprepare(dai->clk);
199 int asoc_simple_parse_clk(struct device *dev,
200 struct device_node *node,
201 struct asoc_simple_dai *simple_dai,
202 struct snd_soc_dai_link_component *dlc)
208 * Parse dai->sysclk come from "clocks = <&xxx>"
209 * (if system has common clock)
210 * or "system-clock-frequency = <xxx>"
211 * or device's module clock.
213 clk = devm_get_clk_from_child(dev, node, NULL);
214 simple_dai->clk_fixed = of_property_read_bool(
215 node, "system-clock-fixed");
217 simple_dai->sysclk = clk_get_rate(clk);
219 simple_dai->clk = clk;
220 } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) {
221 simple_dai->sysclk = val;
222 simple_dai->clk_fixed = true;
224 clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
226 simple_dai->sysclk = clk_get_rate(clk);
229 if (of_property_read_bool(node, "system-clock-direction-out"))
230 simple_dai->clk_direction = SND_SOC_CLOCK_OUT;
234 EXPORT_SYMBOL_GPL(asoc_simple_parse_clk);
236 static int asoc_simple_check_fixed_sysclk(struct device *dev,
237 struct asoc_simple_dai *dai,
238 unsigned int *fixed_sysclk)
240 if (dai->clk_fixed) {
241 if (*fixed_sysclk && *fixed_sysclk != dai->sysclk) {
242 dev_err(dev, "inconsistent fixed sysclk rates (%u vs %u)\n",
243 *fixed_sysclk, dai->sysclk);
246 *fixed_sysclk = dai->sysclk;
252 int asoc_simple_startup(struct snd_pcm_substream *substream)
254 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
255 struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
256 struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num);
257 struct asoc_simple_dai *dai;
258 unsigned int fixed_sysclk = 0;
262 for_each_prop_dai_cpu(props, i1, dai) {
263 ret = asoc_simple_clk_enable(dai);
266 ret = asoc_simple_check_fixed_sysclk(rtd->dev, dai, &fixed_sysclk);
271 for_each_prop_dai_codec(props, i2, dai) {
272 ret = asoc_simple_clk_enable(dai);
275 ret = asoc_simple_check_fixed_sysclk(rtd->dev, dai, &fixed_sysclk);
280 if (fixed_sysclk && props->mclk_fs) {
281 unsigned int fixed_rate = fixed_sysclk / props->mclk_fs;
283 if (fixed_sysclk % props->mclk_fs) {
284 dev_err(rtd->dev, "fixed sysclk %u not divisible by mclk_fs %u\n",
285 fixed_sysclk, props->mclk_fs);
288 ret = snd_pcm_hw_constraint_minmax(substream->runtime, SNDRV_PCM_HW_PARAM_RATE,
289 fixed_rate, fixed_rate);
297 for_each_prop_dai_codec(props, i, dai) {
300 asoc_simple_clk_disable(dai);
303 for_each_prop_dai_cpu(props, i, dai) {
306 asoc_simple_clk_disable(dai);
310 EXPORT_SYMBOL_GPL(asoc_simple_startup);
312 void asoc_simple_shutdown(struct snd_pcm_substream *substream)
314 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
315 struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
316 struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num);
317 struct asoc_simple_dai *dai;
320 for_each_prop_dai_cpu(props, i, dai) {
321 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, i);
323 if (props->mclk_fs && !dai->clk_fixed && !snd_soc_dai_active(cpu_dai))
324 snd_soc_dai_set_sysclk(cpu_dai,
325 0, 0, SND_SOC_CLOCK_OUT);
327 asoc_simple_clk_disable(dai);
329 for_each_prop_dai_codec(props, i, dai) {
330 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, i);
332 if (props->mclk_fs && !dai->clk_fixed && !snd_soc_dai_active(codec_dai))
333 snd_soc_dai_set_sysclk(codec_dai,
334 0, 0, SND_SOC_CLOCK_IN);
336 asoc_simple_clk_disable(dai);
339 EXPORT_SYMBOL_GPL(asoc_simple_shutdown);
341 static int asoc_simple_set_clk_rate(struct device *dev,
342 struct asoc_simple_dai *simple_dai,
348 if (simple_dai->clk_fixed && rate != simple_dai->sysclk) {
349 dev_err(dev, "dai %s invalid clock rate %lu\n", simple_dai->name, rate);
353 if (!simple_dai->clk)
356 if (clk_get_rate(simple_dai->clk) == rate)
359 return clk_set_rate(simple_dai->clk, rate);
362 static int asoc_simple_set_tdm(struct snd_soc_dai *dai,
363 struct asoc_simple_dai *simple_dai,
364 struct snd_pcm_hw_params *params)
366 int sample_bits = params_width(params);
367 int slot_width, slot_count;
370 if (!simple_dai || !simple_dai->tdm_width_map)
373 slot_width = simple_dai->slot_width;
374 slot_count = simple_dai->slots;
377 slot_width = sample_bits;
379 for (i = 0; i < simple_dai->n_tdm_widths; ++i) {
380 if (simple_dai->tdm_width_map[i].sample_bits == sample_bits) {
381 slot_width = simple_dai->tdm_width_map[i].slot_width;
382 slot_count = simple_dai->tdm_width_map[i].slot_count;
387 ret = snd_soc_dai_set_tdm_slot(dai,
388 simple_dai->tx_slot_mask,
389 simple_dai->rx_slot_mask,
392 if (ret && ret != -ENOTSUPP) {
393 dev_err(dai->dev, "simple-card: set_tdm_slot error: %d\n", ret);
400 int asoc_simple_hw_params(struct snd_pcm_substream *substream,
401 struct snd_pcm_hw_params *params)
403 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
404 struct asoc_simple_dai *pdai;
405 struct snd_soc_dai *sdai;
406 struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
407 struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num);
408 unsigned int mclk, mclk_fs = 0;
412 mclk_fs = props->mclk_fs;
415 struct snd_soc_component *component;
416 mclk = params_rate(params) * mclk_fs;
418 for_each_prop_dai_codec(props, i, pdai) {
419 ret = asoc_simple_set_clk_rate(rtd->dev, pdai, mclk);
424 for_each_prop_dai_cpu(props, i, pdai) {
425 ret = asoc_simple_set_clk_rate(rtd->dev, pdai, mclk);
430 /* Ensure sysclk is set on all components in case any
431 * (such as platform components) are missed by calls to
432 * snd_soc_dai_set_sysclk.
434 for_each_rtd_components(rtd, i, component) {
435 ret = snd_soc_component_set_sysclk(component, 0, 0,
436 mclk, SND_SOC_CLOCK_IN);
437 if (ret && ret != -ENOTSUPP)
441 for_each_rtd_codec_dais(rtd, i, sdai) {
442 ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_IN);
443 if (ret && ret != -ENOTSUPP)
447 for_each_rtd_cpu_dais(rtd, i, sdai) {
448 ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_OUT);
449 if (ret && ret != -ENOTSUPP)
454 for_each_prop_dai_codec(props, i, pdai) {
455 sdai = asoc_rtd_to_codec(rtd, i);
456 ret = asoc_simple_set_tdm(sdai, pdai, params);
461 for_each_prop_dai_cpu(props, i, pdai) {
462 sdai = asoc_rtd_to_cpu(rtd, i);
463 ret = asoc_simple_set_tdm(sdai, pdai, params);
470 EXPORT_SYMBOL_GPL(asoc_simple_hw_params);
472 int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
473 struct snd_pcm_hw_params *params)
475 struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
476 struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
478 asoc_simple_convert_fixup(&dai_props->adata, params);
482 EXPORT_SYMBOL_GPL(asoc_simple_be_hw_params_fixup);
484 static int asoc_simple_init_dai(struct snd_soc_dai *dai,
485 struct asoc_simple_dai *simple_dai)
492 if (simple_dai->sysclk) {
493 ret = snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk,
494 simple_dai->clk_direction);
495 if (ret && ret != -ENOTSUPP) {
496 dev_err(dai->dev, "simple-card: set_sysclk error\n");
501 if (simple_dai->slots) {
502 ret = snd_soc_dai_set_tdm_slot(dai,
503 simple_dai->tx_slot_mask,
504 simple_dai->rx_slot_mask,
506 simple_dai->slot_width);
507 if (ret && ret != -ENOTSUPP) {
508 dev_err(dai->dev, "simple-card: set_tdm_slot error\n");
516 static int asoc_simple_init_dai_link_params(struct snd_soc_pcm_runtime *rtd,
517 struct simple_dai_props *dai_props)
519 struct snd_soc_dai_link *dai_link = rtd->dai_link;
520 struct snd_soc_component *component;
521 struct snd_soc_pcm_stream *params;
522 struct snd_pcm_hardware hw;
526 for_each_rtd_components(rtd, i, component) {
527 if (!snd_soc_component_is_codec(component))
531 /* Assumes the capabilities are the same for all supported streams */
532 for_each_pcm_streams(stream) {
533 ret = snd_soc_runtime_calc_hw(rtd, &hw, stream);
539 dev_err(rtd->dev, "simple-card: no valid dai_link params\n");
543 params = devm_kzalloc(rtd->dev, sizeof(*params), GFP_KERNEL);
547 params->formats = hw.formats;
548 params->rates = hw.rates;
549 params->rate_min = hw.rate_min;
550 params->rate_max = hw.rate_max;
551 params->channels_min = hw.channels_min;
552 params->channels_max = hw.channels_max;
554 dai_link->params = params;
555 dai_link->num_params = 1;
560 int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd)
562 struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
563 struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num);
564 struct asoc_simple_dai *dai;
567 for_each_prop_dai_codec(props, i, dai) {
568 ret = asoc_simple_init_dai(asoc_rtd_to_codec(rtd, i), dai);
572 for_each_prop_dai_cpu(props, i, dai) {
573 ret = asoc_simple_init_dai(asoc_rtd_to_cpu(rtd, i), dai);
578 ret = asoc_simple_init_dai_link_params(rtd, props);
584 EXPORT_SYMBOL_GPL(asoc_simple_dai_init);
586 void asoc_simple_canonicalize_platform(struct snd_soc_dai_link_component *platforms,
587 struct snd_soc_dai_link_component *cpus)
589 /* Assumes platform == cpu */
590 if (!platforms->of_node)
591 platforms->of_node = cpus->of_node;
593 EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_platform);
595 void asoc_simple_canonicalize_cpu(struct snd_soc_dai_link_component *cpus,
599 * In soc_bind_dai_link() will check cpu name after
600 * of_node matching if dai_link has cpu_dai_name.
601 * but, it will never match if name was created by
602 * fmt_single_name() remove cpu_dai_name if cpu_args
605 * fmt_multiple_name()
608 cpus->dai_name = NULL;
610 EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_cpu);
612 int asoc_simple_clean_reference(struct snd_soc_card *card)
614 struct snd_soc_dai_link *dai_link;
615 struct snd_soc_dai_link_component *cpu;
616 struct snd_soc_dai_link_component *codec;
619 for_each_card_prelinks(card, i, dai_link) {
620 for_each_link_cpus(dai_link, j, cpu)
621 of_node_put(cpu->of_node);
622 for_each_link_codecs(dai_link, j, codec)
623 of_node_put(codec->of_node);
627 EXPORT_SYMBOL_GPL(asoc_simple_clean_reference);
629 int asoc_simple_parse_routing(struct snd_soc_card *card,
632 struct device_node *node = card->dev->of_node;
638 snprintf(prop, sizeof(prop), "%s%s", prefix, "routing");
640 if (!of_property_read_bool(node, prop))
643 return snd_soc_of_parse_audio_routing(card, prop);
645 EXPORT_SYMBOL_GPL(asoc_simple_parse_routing);
647 int asoc_simple_parse_widgets(struct snd_soc_card *card,
650 struct device_node *node = card->dev->of_node;
656 snprintf(prop, sizeof(prop), "%s%s", prefix, "widgets");
658 if (of_property_read_bool(node, prop))
659 return snd_soc_of_parse_audio_simple_widgets(card, prop);
661 /* no widgets is not error */
664 EXPORT_SYMBOL_GPL(asoc_simple_parse_widgets);
666 int asoc_simple_parse_pin_switches(struct snd_soc_card *card,
674 snprintf(prop, sizeof(prop), "%s%s", prefix, "pin-switches");
676 return snd_soc_of_parse_pin_switches(card, prop);
678 EXPORT_SYMBOL_GPL(asoc_simple_parse_pin_switches);
680 int asoc_simple_init_jack(struct snd_soc_card *card,
681 struct asoc_simple_jack *sjack,
682 int is_hp, char *prefix,
685 struct device *dev = card->dev;
686 enum of_gpio_flags flags;
696 sjack->gpio.gpio = -ENOENT;
699 snprintf(prop, sizeof(prop), "%shp-det-gpio", prefix);
700 pin_name = pin ? pin : "Headphones";
701 gpio_name = "Headphone detection";
702 mask = SND_JACK_HEADPHONE;
704 snprintf(prop, sizeof(prop), "%smic-det-gpio", prefix);
705 pin_name = pin ? pin : "Mic Jack";
706 gpio_name = "Mic detection";
707 mask = SND_JACK_MICROPHONE;
710 det = of_get_named_gpio_flags(dev->of_node, prop, 0, &flags);
711 if (det == -EPROBE_DEFER)
712 return -EPROBE_DEFER;
714 if (gpio_is_valid(det)) {
715 sjack->pin.pin = pin_name;
716 sjack->pin.mask = mask;
718 sjack->gpio.name = gpio_name;
719 sjack->gpio.report = mask;
720 sjack->gpio.gpio = det;
721 sjack->gpio.invert = !!(flags & OF_GPIO_ACTIVE_LOW);
722 sjack->gpio.debounce_time = 150;
724 snd_soc_card_jack_new_pins(card, pin_name, mask, &sjack->jack,
727 snd_soc_jack_add_gpios(&sjack->jack, 1,
733 EXPORT_SYMBOL_GPL(asoc_simple_init_jack);
735 int asoc_simple_init_priv(struct asoc_simple_priv *priv,
736 struct link_info *li)
738 struct snd_soc_card *card = simple_priv_to_card(priv);
739 struct device *dev = simple_priv_to_dev(priv);
740 struct snd_soc_dai_link *dai_link;
741 struct simple_dai_props *dai_props;
742 struct asoc_simple_dai *dais;
743 struct snd_soc_dai_link_component *dlcs;
744 struct snd_soc_codec_conf *cconf = NULL;
745 struct snd_soc_pcm_stream *c2c_conf = NULL;
746 int i, dai_num = 0, dlc_num = 0, cnf_num = 0, c2c_num = 0;
748 dai_props = devm_kcalloc(dev, li->link, sizeof(*dai_props), GFP_KERNEL);
749 dai_link = devm_kcalloc(dev, li->link, sizeof(*dai_link), GFP_KERNEL);
750 if (!dai_props || !dai_link)
755 * dlcs (= CPU+Codec+Platform)
757 for (i = 0; i < li->link; i++) {
758 int cc = li->num[i].cpus + li->num[i].codecs;
761 dlc_num += cc + li->num[i].platforms;
763 if (!li->num[i].cpus)
764 cnf_num += li->num[i].codecs;
766 c2c_num += li->num[i].c2c;
769 dais = devm_kcalloc(dev, dai_num, sizeof(*dais), GFP_KERNEL);
770 dlcs = devm_kcalloc(dev, dlc_num, sizeof(*dlcs), GFP_KERNEL);
775 cconf = devm_kcalloc(dev, cnf_num, sizeof(*cconf), GFP_KERNEL);
781 c2c_conf = devm_kcalloc(dev, c2c_num, sizeof(*c2c_conf), GFP_KERNEL);
786 dev_dbg(dev, "link %d, dais %d, ccnf %d\n",
787 li->link, dai_num, cnf_num);
789 /* dummy CPU/Codec */
790 priv->dummy.of_node = NULL;
791 priv->dummy.dai_name = "snd-soc-dummy-dai";
792 priv->dummy.name = "snd-soc-dummy";
794 priv->dai_props = dai_props;
795 priv->dai_link = dai_link;
798 priv->codec_conf = cconf;
799 priv->c2c_conf = c2c_conf;
801 card->dai_link = priv->dai_link;
802 card->num_links = li->link;
803 card->codec_conf = cconf;
804 card->num_configs = cnf_num;
806 for (i = 0; i < li->link; i++) {
807 if (li->num[i].cpus) {
810 dai_link[i].cpus = dlcs;
811 dai_props[i].num.cpus =
812 dai_link[i].num_cpus = li->num[i].cpus;
813 dai_props[i].cpu_dai = dais;
815 dlcs += li->num[i].cpus;
816 dais += li->num[i].cpus;
818 if (li->num[i].c2c) {
820 dai_props[i].c2c_conf = c2c_conf;
821 c2c_conf += li->num[i].c2c;
824 /* DPCM Be's CPU = dummy */
826 dai_link[i].cpus = &priv->dummy;
827 dai_props[i].num.cpus =
828 dai_link[i].num_cpus = 1;
831 if (li->num[i].codecs) {
833 dai_props[i].codecs =
834 dai_link[i].codecs = dlcs;
835 dai_props[i].num.codecs =
836 dai_link[i].num_codecs = li->num[i].codecs;
837 dai_props[i].codec_dai = dais;
839 dlcs += li->num[i].codecs;
840 dais += li->num[i].codecs;
842 if (!li->num[i].cpus) {
843 /* DPCM Be's Codec */
844 dai_props[i].codec_conf = cconf;
845 cconf += li->num[i].codecs;
848 /* DPCM Fe's Codec = dummy */
849 dai_props[i].codecs =
850 dai_link[i].codecs = &priv->dummy;
851 dai_props[i].num.codecs =
852 dai_link[i].num_codecs = 1;
855 if (li->num[i].platforms) {
857 dai_props[i].platforms =
858 dai_link[i].platforms = dlcs;
859 dai_props[i].num.platforms =
860 dai_link[i].num_platforms = li->num[i].platforms;
862 dlcs += li->num[i].platforms;
864 /* Doesn't have Platform */
865 dai_props[i].platforms =
866 dai_link[i].platforms = NULL;
867 dai_props[i].num.platforms =
868 dai_link[i].num_platforms = 0;
874 EXPORT_SYMBOL_GPL(asoc_simple_init_priv);
876 int asoc_simple_remove(struct platform_device *pdev)
878 struct snd_soc_card *card = platform_get_drvdata(pdev);
880 return asoc_simple_clean_reference(card);
882 EXPORT_SYMBOL_GPL(asoc_simple_remove);
884 int asoc_graph_card_probe(struct snd_soc_card *card)
886 struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card);
889 ret = asoc_simple_init_hp(card, &priv->hp_jack, NULL);
893 ret = asoc_simple_init_mic(card, &priv->mic_jack, NULL);
899 EXPORT_SYMBOL_GPL(asoc_graph_card_probe);
901 int asoc_graph_is_ports0(struct device_node *np)
903 struct device_node *port, *ports, *ports0, *top;
906 /* np is "endpoint" or "port" */
907 if (of_node_name_eq(np, "endpoint")) {
908 port = of_get_parent(np);
914 ports = of_get_parent(port);
915 top = of_get_parent(ports);
916 ports0 = of_get_child_by_name(top, "ports");
918 ret = ports0 == ports;
927 EXPORT_SYMBOL_GPL(asoc_graph_is_ports0);
929 /* Module information */
930 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
931 MODULE_DESCRIPTION("ALSA SoC Simple Card Utils");
932 MODULE_LICENSE("GPL v2");