Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: core: add optional pcm_new callback for DAI driver

During probe, DAIs can need to perform some actions that requests
the knowledge of the pcm runtime handle.
The callback is called during DAIs linking, after PCM device creation.
For instance this can be used to add relationship between a DAI pcm
control and the pcm device.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Arnaud Pouliquen and committed by
Mark Brown
25f7b701 c82dbe5c

+31
+3
include/sound/soc-dai.h
··· 256 256 int (*resume)(struct snd_soc_dai *dai); 257 257 /* compress dai */ 258 258 int (*compress_new)(struct snd_soc_pcm_runtime *rtd, int num); 259 + /* Optional Callback used at pcm creation*/ 260 + int (*pcm_new)(struct snd_soc_pcm_runtime *rtd, 261 + struct snd_soc_dai *dai); 259 262 /* DAI is also used for the control bus */ 260 263 bool bus_control; 261 264
+28
sound/soc/soc-core.c
··· 1593 1593 return 0; 1594 1594 } 1595 1595 1596 + static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, 1597 + struct snd_soc_pcm_runtime *rtd) 1598 + { 1599 + int i, ret = 0; 1600 + 1601 + for (i = 0; i < num_dais; ++i) { 1602 + struct snd_soc_dai_driver *drv = dais[i]->driver; 1603 + 1604 + if (!rtd->dai_link->no_pcm && drv->pcm_new) 1605 + ret = drv->pcm_new(rtd, dais[i]); 1606 + if (ret < 0) { 1607 + dev_err(dais[i]->dev, 1608 + "ASoC: Failed to bind %s with pcm device\n", 1609 + dais[i]->name); 1610 + return ret; 1611 + } 1612 + } 1613 + 1614 + return 0; 1615 + } 1616 + 1596 1617 static int soc_link_dai_widgets(struct snd_soc_card *card, 1597 1618 struct snd_soc_dai_link *dai_link, 1598 1619 struct snd_soc_pcm_runtime *rtd) ··· 1725 1704 dai_link->stream_name, ret); 1726 1705 return ret; 1727 1706 } 1707 + ret = soc_link_dai_pcm_new(&cpu_dai, 1, rtd); 1708 + if (ret < 0) 1709 + return ret; 1710 + ret = soc_link_dai_pcm_new(rtd->codec_dais, 1711 + rtd->num_codecs, rtd); 1712 + if (ret < 0) 1713 + return ret; 1728 1714 } else { 1729 1715 INIT_DELAYED_WORK(&rtd->delayed_work, 1730 1716 codec2codec_close_delayed_work);