On 02/25/2013 01:53 AM, Kuninori Morimoto wrote:
ASoC sound driver requires CPU/CODEC drivers for probing, and each CPU/CODEC has some DAI on it. Then, "dai name matching" have been used to identify CPU-CODEC DAI pair on ASoC.
But, the "dai port number matching" is now required from DeviceTree. The solution of this issue is to replace the dai port number into dai name, and it needs some kind of .of_xlate function on each driver.
This patch adds .of_xlate_dai_name callback interface on each struct snd_soc_cpu/codec_driver, and snd_soc_of_get_cpu/codec_dai_name() which is using .of_xlate_dai_name.
Then, #sound-dai-cells which enables DAI specifier is required on CPU/CODEC device tree properties.
diff --git a/include/sound/soc.h b/include/sound/soc.h
struct snd_soc_cpu_driver {
- /* DT */
- int (*of_xlate_dai_name)(struct snd_soc_cpu *codec,
s/codec/cpu/
+int snd_soc_of_get_codec_dai_name(struct device_node *of_node,
const char **dai_name);
+int snd_soc_of_get_cpu_dai_name(struct device_node *of_node,
const char **dai_name);
I think you need to return the CODEC and CPU object or name here too. That'll be needed to fill in the machine driver's {codec,cpu}_of_node DAI link fields.
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
+#define SND_SOC_OF_GET_DAI_NAME(contents) \ +int snd_soc_of_get_ ## contents ## _dai_name(struct device_node *of_node,\
I would personally leave out the spaces around the ##; seems more readable to me, but maybe you'd disagree.
s/contents/type/?
...
- mutex_lock(&client_mutex); \
- list_for_each_entry(pos, &contents ## _list, list) { \
if (pos->dev->of_node != args.np) \
continue; \
\
if (!pos->driver->of_xlate_dai_name) { \
ret = -EIO; \
-ENOSYS seems more appropriate. Even if not, EIO doesn't seem right.
+EXPORT_SYMBOL_GPL(snd_soc_of_get_codec_dai_name);
I think you can put that macro call into SND_SOC_OF_GET_DAI_NAME().