.prepare = seeed_voice_card_prepare,
};
+static int asoc_card_parse_dai(struct device_node *node,
+ struct snd_soc_dai_link_component *dlc,
+ int *is_single_link)
+{
+ struct of_phandle_args args;
+ int ret;
+
+ if (!node)
+ return 0;
+
+ ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args);
+ if (ret)
+ return ret;
+
+ ret = snd_soc_of_get_dai_name(node, &dlc->dai_name);
+ if (ret < 0)
+ return ret;
+
+ dlc->of_node = args.np;
+
+ if (is_single_link)
+ *is_single_link = !args.args_count;
+
+ return 0;
+}
+
+static int asoc_card_init_dai(struct snd_soc_dai *dai,
+ struct asoc_simple_dai *simple_dai)
+{
+ int ret;
+
+ if (!simple_dai)
+ return 0;
+
+ if (simple_dai->sysclk) {
+ ret = snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk,
+ simple_dai->clk_direction);
+ if (ret && ret != -ENOTSUPP) {
+ dev_err(dai->dev, "simple-card: set_sysclk error\n");
+ return ret;
+ }
+ }
+
+ if (simple_dai->slots) {
+ ret = snd_soc_dai_set_tdm_slot(dai,
+ simple_dai->tx_slot_mask,
+ simple_dai->rx_slot_mask,
+ simple_dai->slots,
+ simple_dai->slot_width);
+ if (ret && ret != -ENOTSUPP) {
+ dev_err(dai->dev, "simple-card: set_tdm_slot error\n");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
static int seeed_voice_card_dai_init(struct snd_soc_pcm_runtime *rtd)
{
struct seeed_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
seeed_priv_to_props(priv, rtd->num);
int ret;
- ret = asoc_simple_card_init_dai(codec, &dai_props->codec_dai);
+ ret = asoc_card_init_dai(codec, &dai_props->codec_dai);
if (ret < 0)
return ret;
- ret = asoc_simple_card_init_dai(cpu, &dai_props->cpu_dai);
+ ret = asoc_card_init_dai(cpu, &dai_props->cpu_dai);
if (ret < 0)
return ret;
goto dai_link_of_err;
}
- ret = asoc_simple_card_parse_daifmt(dev, node, codec,
+ ret = asoc_simple_parse_daifmt(dev, node, codec,
prefix, &dai_link->dai_fmt);
if (ret < 0)
goto dai_link_of_err;
of_property_read_u32(node, "mclk-fs", &dai_props->mclk_fs);
- ret = asoc_simple_card_parse_cpu(cpu, dai_link,
- DAI, CELL, &single_cpu);
+ ret = asoc_card_parse_dai(cpu, dai_link->cpus, &single_cpu);
if (ret < 0)
goto dai_link_of_err;
#if _SINGLE_CODEC
- ret = asoc_simple_card_parse_codec(codec, dai_link, DAI, CELL);
+ ret = asoc_card_parse_dai(codec, dai_link->codecs, NULL);
if (ret < 0)
goto dai_link_of_err;
#else
dev_dbg(dev, "dai_link num_codecs = %d\n", dai_link->num_codecs);
#endif
- ret = asoc_simple_card_parse_platform(plat, dai_link, DAI, CELL);
+ ret = asoc_card_parse_dai(plat, dai_link->platforms, NULL);
if (ret < 0)
goto dai_link_of_err;
&cpu_dai->rx_slot_mask,
&cpu_dai->slots,
&cpu_dai->slot_width);
- dev_dbg(dev, "cpu_dai : slot,width,tx,rx = %d,%d,%d,%d\n",
+ dev_dbg(dev, "cpu_dai : slot,width,tx,rx = %d,%d,%d,%d\n",
cpu_dai->slots, cpu_dai->slot_width,
cpu_dai->tx_slot_mask, cpu_dai->rx_slot_mask
);
goto dai_link_of_err;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,10,0)
- ret = asoc_simple_card_parse_clk_cpu(cpu, dai_link, cpu_dai);
+ ret = asoc_simple_parse_clk_cpu(cpu, dai_link, cpu_dai);
#else
- ret = asoc_simple_card_parse_clk_cpu(dev, cpu, dai_link, cpu_dai);
+ ret = asoc_simple_parse_clk_cpu(dev, cpu, dai_link, cpu_dai);
#endif
if (ret < 0)
goto dai_link_of_err;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,10,0)
- ret = asoc_simple_card_parse_clk_codec(codec, dai_link, codec_dai);
+ ret = asoc_simple_parse_clk_codec(codec, dai_link, codec_dai);
#else
- ret = asoc_simple_card_parse_clk_codec(dev, codec, dai_link, codec_dai);
+ ret = asoc_simple_parse_clk_codec(dev, codec, dai_link, codec_dai);
#endif
if (ret < 0)
goto dai_link_of_err;
#if _SINGLE_CODEC
- ret = asoc_simple_card_canonicalize_dailink(dai_link);
- if (ret < 0)
- goto dai_link_of_err;
+ asoc_simple_canonicalize_platform(dai_link);
#endif
- ret = asoc_simple_card_set_dailink_name(dev, dai_link,
+ ret = asoc_simple_set_dailink_name(dev, dai_link,
"%s-%s",
- dai_link->cpu_dai_name,
+ dai_link->cpus->dai_name,
#if _SINGLE_CODEC
- dai_link->codec_dai_name
+ dai_link->codecs->dai_name
#else
dai_link->codecs[0].dai_name
#endif
dev_dbg(dev, "\tname : %s\n", dai_link->stream_name);
dev_dbg(dev, "\tformat : %04x\n", dai_link->dai_fmt);
dev_dbg(dev, "\tcpu : %s / %d\n",
- dai_link->cpu_dai_name,
+ dai_link->cpus->dai_name,
dai_props->cpu_dai.sysclk);
dev_dbg(dev, "\tcodec : %s / %d\n",
#if _SINGLE_CODEC
- dai_link->codec_dai_name,
+ dai_link->codecs->dai_name,
#else
dai_link->codecs[0].dai_name,
#endif
dai_props->codec_dai.sysclk);
- asoc_simple_card_canonicalize_cpu(dai_link, single_cpu);
+ asoc_simple_canonicalize_cpu(dai_link, single_cpu);
dai_link_of_err:
of_node_put(cpu);
aux_node = of_parse_phandle(node, PREFIX "aux-devs", i);
if (!aux_node)
return -EINVAL;
- priv->snd_card.aux_dev[i].codec_of_node = aux_node;
+ priv->snd_card.aux_dev[i].dlc.of_node = aux_node;
}
priv->snd_card.num_aux_devs = n;
goto card_parse_end;
}
- ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX);
+ ret = asoc_simple_parse_card_name(&priv->snd_card, PREFIX);
if (ret < 0)
goto card_parse_end;
{
struct seeed_card_data *priv;
struct snd_soc_dai_link *dai_link;
+ struct snd_soc_dai_link_component *compnent;
struct seeed_dai_props *dai_props;
struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
if (!dai_props || !dai_link)
return -ENOMEM;
+ compnent = devm_kzalloc(dev, 3 * sizeof(*compnent), GFP_KERNEL);
+ if (!compnent)
+ return -ENOMEM;
+
+ dai_link->cpus = &compnent[0];
+ dai_link->num_cpus = 1;
+ dai_link->codecs = &compnent[1];
+ dai_link->num_codecs = 1;
+ dai_link->platforms = &compnent[2];
+ dai_link->num_platforms = 1;
+
priv->dai_props = dai_props;
priv->dai_link = dai_link;
priv->snd_card.name = (cinfo->card) ? cinfo->card : cinfo->name;
dai_link->name = cinfo->name;
dai_link->stream_name = cinfo->name;
- dai_link->platform_name = cinfo->platform;
- dai_link->codec_name = cinfo->codec;
- dai_link->cpu_dai_name = cinfo->cpu_dai.name;
- dai_link->codec_dai_name = cinfo->codec_dai.name;
+ dai_link->platforms->name = cinfo->platform;
+ dai_link->codecs->dai_name = cinfo->codec;
+ dai_link->cpus->dai_name = cinfo->cpu_dai.name;
+ dai_link->codecs->dai_name = cinfo->codec_dai.name;
dai_link->dai_fmt = cinfo->daifmt;
dai_link->init = seeed_voice_card_dai_init;
memcpy(&priv->dai_props->cpu_dai, &cinfo->cpu_dai,
return ret;
err:
- asoc_simple_card_clean_reference(&priv->snd_card);
+ asoc_simple_clean_reference(&priv->snd_card);
return ret;
}
if (cancel_work_sync(&priv->work_codec_clk) != 0) {
}
- return asoc_simple_card_clean_reference(card);
+ return asoc_simple_clean_reference(card);
}
static const struct of_device_id seeed_voice_of_match[] = {