simple-card.c (9eac361877b3c96c8f68dffd7a7a3e92a2b85d0b) simple-card.c (cecdef3656956b0978bf86ecd1ce0542d2c61e97)
1/*
2 * ASoC simple sound card support
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 294 unchanged lines hidden (view full) ---

303 clk = of_clk_get(args.np, 0);
304 if (!IS_ERR(clk))
305 dai->sysclk = clk_get_rate(clk);
306 }
307
308 return 0;
309}
310
1/*
2 * ASoC simple sound card support
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 294 unchanged lines hidden (view full) ---

303 clk = of_clk_get(args.np, 0);
304 if (!IS_ERR(clk))
305 dai->sysclk = clk_get_rate(clk);
306 }
307
308 return 0;
309}
310
311static int asoc_simple_card_parse_daifmt(struct device_node *node,
312 struct simple_card_data *priv,
313 struct device_node *codec,
314 char *prefix, int idx)
315{
316 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx);
317 struct device *dev = simple_priv_to_dev(priv);
318 struct device_node *bitclkmaster = NULL;
319 struct device_node *framemaster = NULL;
320 unsigned int daifmt;
321
322 daifmt = snd_soc_of_parse_daifmt(node, prefix,
323 &bitclkmaster, &framemaster);
324 daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
325
326 if (strlen(prefix) && !bitclkmaster && !framemaster) {
327 /*
328 * No dai-link level and master setting was not found from
329 * sound node level, revert back to legacy DT parsing and
330 * take the settings from codec node.
331 */
332 dev_dbg(dev, "Revert to legacy daifmt parsing\n");
333
334 daifmt = snd_soc_of_parse_daifmt(codec, NULL, NULL, NULL) |
335 (daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK);
336 } else {
337 if (codec == bitclkmaster)
338 daifmt |= (codec == framemaster) ?
339 SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS;
340 else
341 daifmt |= (codec == framemaster) ?
342 SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS;
343 }
344
345 dai_link->dai_fmt = daifmt;
346
347 of_node_put(bitclkmaster);
348 of_node_put(framemaster);
349
350 return 0;
351}
352
353static int asoc_simple_card_dai_link_of(struct device_node *node,
354 struct simple_card_data *priv,
355 int idx,
356 bool is_top_level_node)
357{
358 struct device *dev = simple_priv_to_dev(priv);
359 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx);
360 struct simple_dai_props *dai_props = simple_priv_to_props(priv, idx);

--- 20 unchanged lines hidden (view full) ---

381 codec = of_get_child_by_name(node, prop);
382
383 if (!cpu || !codec) {
384 ret = -EINVAL;
385 dev_err(dev, "%s: Can't find %s DT node\n", __func__, prop);
386 goto dai_link_of_err;
387 }
388
311static int asoc_simple_card_dai_link_of(struct device_node *node,
312 struct simple_card_data *priv,
313 int idx,
314 bool is_top_level_node)
315{
316 struct device *dev = simple_priv_to_dev(priv);
317 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx);
318 struct simple_dai_props *dai_props = simple_priv_to_props(priv, idx);

--- 20 unchanged lines hidden (view full) ---

339 codec = of_get_child_by_name(node, prop);
340
341 if (!cpu || !codec) {
342 ret = -EINVAL;
343 dev_err(dev, "%s: Can't find %s DT node\n", __func__, prop);
344 goto dai_link_of_err;
345 }
346
389 ret = asoc_simple_card_parse_daifmt(node, priv,
390 codec, prefix, idx);
347 ret = asoc_simple_card_parse_daifmt(dev, node, codec,
348 prefix, &dai_link->dai_fmt);
391 if (ret < 0)
392 goto dai_link_of_err;
393
394 if (!of_property_read_u32(node, "mclk-fs", &val))
395 dai_props->mclk_fs = val;
396
397 ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai,
398 &dai_link->cpu_of_node,

--- 272 unchanged lines hidden ---
349 if (ret < 0)
350 goto dai_link_of_err;
351
352 if (!of_property_read_u32(node, "mclk-fs", &val))
353 dai_props->mclk_fs = val;
354
355 ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai,
356 &dai_link->cpu_of_node,

--- 272 unchanged lines hidden ---