ASoC: core: Add initial support for DAI multicodec

DAI link assumes a one to one mapping between CPU DAI and CODEC. In
some cases, the same CPU DAI can be connected to several codecs.
This is the case for example, if you connect two mono codecs to the
same I2S link in order to have a stereo card.
The current ASoC implementation does not allow such setup.

Add support for DAI links composed of a single CPU DAI and multiple
CODECs. Sound cards have to pass the CODECs array in the corresponding
DAI link through a new 'snd_soc_dai_link_component' struct. Each CODEC in
this array is described in the same manner single CODEC DAIs are
(either DT/OF node or codec_name).

Multi-codec links are not supported in the case of CODEC to CODEC links.
Just print a warning if it happens.

Based on an original code done by Misael.

Signed-off-by: Benoit Cousson <[email protected]>
Signed-off-by: Misael Lopez Cruz <[email protected]>
Signed-off-by: Fabien Parent <[email protected]>
Tested-by: Lars-Peter Clausen <[email protected]>
Reviewed-by: Lars-Peter Clausen <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
This commit is contained in:
Benoit Cousson 2014-07-08 23:19:34 +02:00 • committed by Mark Brown
commit 88bd870f02
3 changed files with 220 additions and 90 deletions

View file

@ -272,6 +272,10 @@ struct snd_soc_dai {
struct snd_soc_codec *codec;
struct snd_soc_component *component;
/* CODEC TDM slot masks and params (for fixup) */
unsigned int tx_mask;
unsigned int rx_mask;
struct snd_soc_card *card;
struct list_head list;

View file

@ -846,6 +846,12 @@ struct snd_soc_platform_driver {
int (*bespoke_trigger)(struct snd_pcm_substream *, int);
};
struct snd_soc_dai_link_component {
const char *name;
const struct device_node *of_node;
const char *dai_name;
};
struct snd_soc_platform {
struct device *dev;
const struct snd_soc_platform_driver *driver;
@ -891,6 +897,10 @@ struct snd_soc_dai_link {
const struct device_node *codec_of_node;
/* You MUST specify the DAI name within the codec */
const char *codec_dai_name;
struct snd_soc_dai_link_component *codecs;
unsigned int num_codecs;
/*
* You MAY specify the link's platform/PCM/DMA driver, either by
* device name, or by DT/OF node, but not both. Some forms of link
@ -1089,6 +1099,9 @@ struct snd_soc_pcm_runtime {
struct snd_soc_dai *codec_dai;
struct snd_soc_dai *cpu_dai;
struct snd_soc_dai **codec_dais;
unsigned int num_codecs;
struct delayed_work delayed_work;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_dpcm_root;