static int simple_parse_of(struct simple_priv *priv) { struct device *dev = simple_priv_to_dev(priv); struct device_node *top = dev->of_node; struct snd_soc_card *card = simple_priv_to_card(priv); struct link_info li; int ret; if (!top) return -EINVAL; ret = asoc_simple_card_of_parse_widgets(card, PREFIX); if (ret < 0) return ret; ret = asoc_simple_card_of_parse_routing(card, PREFIX); if (ret < 0) return ret; /* Single/Muti DAI link(s) & New style of DT node */ memset(&li, 0, sizeof(li)); for (li.cpu = 1; li.cpu >= 0; li.cpu--) { /* * Detect all CPU first, and Detect all Codec 2nd. * * In Normal sound case, all DAIs are detected * as "CPU-Codec". * * In DPCM sound case, * all CPUs are detected as "CPU-dummy", and * all Codecs are detected as "dummy-Codec". * To avoid random sub-device numbering, * detect "dummy-Codec" in last; */ ret = simple_for_each_link(priv, &li, simple_dai_link_of, simple_dai_link_of_dpcm); if (ret < 0) return ret; } ret = asoc_simple_card_parse_card_name(card, PREFIX); if (ret < 0) return ret; ret = simple_parse_aux_devs(top, priv); return ret; }
static int asoc_simple_card_parse_of(struct simple_card_data *priv) { struct device *dev = simple_priv_to_dev(priv); struct device_node *np; struct snd_soc_card *card = simple_priv_to_card(priv); struct device_node *node = dev->of_node; unsigned int daifmt = 0; bool is_fe; int ret, i; if (!node) return -EINVAL; ret = asoc_simple_card_of_parse_widgets(card, PREFIX); if (ret < 0) return ret; ret = asoc_simple_card_of_parse_routing(card, PREFIX, 0); if (ret < 0) return ret; asoc_simple_card_parse_convert(dev, PREFIX, &priv->adata); /* find 1st codec */ np = of_get_child_by_name(node, PREFIX "codec"); if (!np) return -ENODEV; ret = asoc_simple_card_parse_daifmt(dev, node, np, PREFIX, &daifmt); if (ret < 0) return ret; i = 0; for_each_child_of_node(node, np) { is_fe = false; if (strcmp(np->name, PREFIX "cpu") == 0) is_fe = true; ret = asoc_simple_card_dai_link_of(np, priv, daifmt, i, is_fe); if (ret < 0) return ret; i++; }
static int asoc_simple_card_parse_of(struct simple_card_data *priv) { struct device *dev = simple_priv_to_dev(priv); struct snd_soc_card *card = simple_priv_to_card(priv); struct device_node *dai_link; struct device_node *node = dev->of_node; int ret; if (!node) return -EINVAL; dai_link = of_get_child_by_name(node, PREFIX "dai-link"); ret = asoc_simple_card_of_parse_widgets(card, PREFIX); if (ret < 0) goto card_parse_end; ret = asoc_simple_card_of_parse_routing(card, PREFIX, 1); if (ret < 0) goto card_parse_end; /* Factor to mclk, used in hw_params() */ of_property_read_u32(node, PREFIX "mclk-fs", &priv->mclk_fs); /* Single/Muti DAI link(s) & New style of DT node */ if (dai_link) { struct device_node *np = NULL; int i = 0; for_each_child_of_node(node, np) { dev_dbg(dev, "\tlink %d:\n", i); ret = asoc_simple_card_dai_link_of(np, priv, i, false); if (ret < 0) { of_node_put(np); goto card_parse_end; } i++; } } else {