|
@@ -101,7 +101,7 @@ static int asoc_simple_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int asoc_simple_card_parse_links(struct device_node *np,
|
|
|
+static int asoc_simple_card_dai_link_of(struct device_node *np,
|
|
|
struct asoc_simple_card_priv *priv,
|
|
|
unsigned int daifmt,
|
|
|
int idx, bool is_fe)
|
|
@@ -195,22 +195,35 @@ static int asoc_simple_card_parse_links(struct device_node *np,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int asoc_simple_card_dai_link_of(struct device_node *node,
|
|
|
- struct asoc_simple_card_priv *priv)
|
|
|
+static int asoc_simple_card_parse_of(struct device_node *node,
|
|
|
+ struct asoc_simple_card_priv *priv)
|
|
|
+
|
|
|
{
|
|
|
struct device *dev = simple_priv_to_dev(priv);
|
|
|
struct device_node *np;
|
|
|
unsigned int daifmt = 0;
|
|
|
- int ret, i;
|
|
|
bool is_fe;
|
|
|
+ int ret, i;
|
|
|
+
|
|
|
+ if (!node)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ ret = snd_soc_of_parse_audio_routing(&priv->snd_card, PREFIX "routing");
|
|
|
+ if (ret < 0)
|
|
|
+ return ret;
|
|
|
+
|
|
|
+ /* sampling rate convert */
|
|
|
+ of_property_read_u32(node, PREFIX "convert-rate", &priv->convert_rate);
|
|
|
+
|
|
|
+ /* channels transfer */
|
|
|
+ of_property_read_u32(node, PREFIX "convert-channels", &priv->convert_channels);
|
|
|
|
|
|
/* 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);
|
|
|
+ ret = asoc_simple_card_parse_daifmt(dev, node, np, PREFIX, &daifmt);
|
|
|
if (ret < 0)
|
|
|
return ret;
|
|
|
|
|
@@ -220,58 +233,12 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
|
|
|
if (strcmp(np->name, PREFIX "cpu") == 0)
|
|
|
is_fe = true;
|
|
|
|
|
|
- ret = asoc_simple_card_parse_links(np, priv, daifmt, i, is_fe);
|
|
|
+ ret = asoc_simple_card_dai_link_of(np, priv, daifmt, i, is_fe);
|
|
|
if (ret < 0)
|
|
|
return ret;
|
|
|
i++;
|
|
|
}
|
|
|
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-static int asoc_simple_card_parse_of(struct device_node *node,
|
|
|
- struct asoc_simple_card_priv *priv,
|
|
|
- struct device *dev)
|
|
|
-{
|
|
|
- struct asoc_simple_dai *props;
|
|
|
- struct snd_soc_dai_link *links;
|
|
|
- int ret;
|
|
|
- int num;
|
|
|
-
|
|
|
- if (!node)
|
|
|
- return -EINVAL;
|
|
|
-
|
|
|
- num = of_get_child_count(node);
|
|
|
- props = devm_kzalloc(dev, sizeof(*props) * num, GFP_KERNEL);
|
|
|
- links = devm_kzalloc(dev, sizeof(*links) * num, GFP_KERNEL);
|
|
|
- if (!props || !links)
|
|
|
- return -ENOMEM;
|
|
|
-
|
|
|
- priv->dai_props = props;
|
|
|
- priv->dai_link = links;
|
|
|
-
|
|
|
- /* Init snd_soc_card */
|
|
|
- priv->snd_card.owner = THIS_MODULE;
|
|
|
- priv->snd_card.dev = dev;
|
|
|
- priv->snd_card.dai_link = priv->dai_link;
|
|
|
- priv->snd_card.num_links = num;
|
|
|
- priv->snd_card.codec_conf = &priv->codec_conf;
|
|
|
- priv->snd_card.num_configs = 1;
|
|
|
-
|
|
|
- ret = snd_soc_of_parse_audio_routing(&priv->snd_card, PREFIX "routing");
|
|
|
- if (ret < 0)
|
|
|
- return ret;
|
|
|
-
|
|
|
- /* sampling rate convert */
|
|
|
- of_property_read_u32(node, PREFIX "convert-rate", &priv->convert_rate);
|
|
|
-
|
|
|
- /* channels transfer */
|
|
|
- of_property_read_u32(node, PREFIX "convert-channels", &priv->convert_channels);
|
|
|
-
|
|
|
- ret = asoc_simple_card_dai_link_of(node, priv);
|
|
|
- if (ret < 0)
|
|
|
- return ret;
|
|
|
-
|
|
|
ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX);
|
|
|
if (ret < 0)
|
|
|
return ret;
|
|
@@ -287,16 +254,36 @@ static int asoc_simple_card_parse_of(struct device_node *node,
|
|
|
static int asoc_simple_card_probe(struct platform_device *pdev)
|
|
|
{
|
|
|
struct asoc_simple_card_priv *priv;
|
|
|
- struct device_node *np = pdev->dev.of_node;
|
|
|
+ struct snd_soc_dai_link *links;
|
|
|
+ struct asoc_simple_dai *props;
|
|
|
struct device *dev = &pdev->dev;
|
|
|
- int ret;
|
|
|
+ struct device_node *np = pdev->dev.of_node;
|
|
|
+ int num, ret;
|
|
|
|
|
|
/* Allocate the private data */
|
|
|
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
|
|
if (!priv)
|
|
|
return -ENOMEM;
|
|
|
|
|
|
- ret = asoc_simple_card_parse_of(np, priv, dev);
|
|
|
+ num = of_get_child_count(np);
|
|
|
+
|
|
|
+ props = devm_kzalloc(dev, sizeof(*props) * num, GFP_KERNEL);
|
|
|
+ links = devm_kzalloc(dev, sizeof(*links) * num, GFP_KERNEL);
|
|
|
+ if (!props || !links)
|
|
|
+ return -ENOMEM;
|
|
|
+
|
|
|
+ priv->dai_props = props;
|
|
|
+ priv->dai_link = links;
|
|
|
+
|
|
|
+ /* Init snd_soc_card */
|
|
|
+ priv->snd_card.owner = THIS_MODULE;
|
|
|
+ priv->snd_card.dev = dev;
|
|
|
+ priv->snd_card.dai_link = priv->dai_link;
|
|
|
+ priv->snd_card.num_links = num;
|
|
|
+ priv->snd_card.codec_conf = &priv->codec_conf;
|
|
|
+ priv->snd_card.num_configs = 1;
|
|
|
+
|
|
|
+ ret = asoc_simple_card_parse_of(np, priv);
|
|
|
if (ret < 0) {
|
|
|
if (ret != -EPROBE_DEFER)
|
|
|
dev_err(dev, "parse error %d\n", ret);
|