Register snd-soc-dummy in a device tree

会有一股神秘感。 提交于 2020-02-20 10:26:27

问题


I'm trying to register the ALSA dummy codec provided in soc-utils in my device tree source file, to use it with an i2s device driver (sun8i-i2s).
I've tried to set the sound-dai field in my i2s configuration as explained here : https://patchwork.kernel.org/patch/7679391/, but the device driver fails to find the dai name when reading the device tree.
I've found two workarounds, which consists in either writing my own dummy codec and giving it to the device tree :

/ {
    stupid-codec {
        #sound-dai-cells = <0x00000000>;
        compatible = "linux,snd-soc-stupid";
        status = "okay";
        linux,phandle = <0x0000dead>;
        phandle = <0x0000dead>;
    };
...
};

...    

&i2s0 {
    #sound-dai-cells = <0x00000000>;
    compatible = "allwinner,sun8i-h3-i2s"; 
    sound-dai = <0x0000dead>; 
    status = "okay";
};

Or force-link the codec in the device driver and have no sound-dai field in the device :

device tree :
&i2s0 {
    // No sound-dai
    status = "okay";
};

i2s driver :
static int sun8i_card_create(struct device *dev, struct priv *priv)
{
    struct snd_soc_card *card;

...

    // Skip the part where it's reading the device tree
    #if 0
        codec->of_node = sun8i_get_codec(dev);
        if (!codec->of_node) {
            dev_err(dev, "no port node\n");
            return -ENXIO;
        }
        DBGOUT("%s: codec_name=\"%s\"\n", __func__, codec->of_node->name);

        if(snd_soc_of_get_dai_name(dev->of_node, &codec->dai_name) < 0)
        {
            dev_err(dev, "%s: failed to find dai name, use codec's name as dai name.\n", __func__);
            codec->dai_name = codec->of_node->name;
        }
        DBGOUT("%s: dai_name=\"%s\"\n", __func__, codec->dai_name);
    #endif

    // Force codec and dai name
    codec->name = "snd-soc-dummy";
    codec->dai_name = "snd-soc-dummy-dai";

Both kind of work, but it is still a dirty hack, so it would be great if someone had the correct syntax for the dummy in the device tree.

EDIT 2019/10/10

We ended up using a different codec (pcm5102a), which gets implemented separately in the dts :

 (in sun8i-h3-nanopi-neo-air.dts) 
 &i2s0 {
    /* sound-dai = <&pcm5102a>; */
    status = "okay";
 };

 (in sun8i-h3-nanopi.dtsi)  
 pcm5102a: pcm5102a-codec {
    #sound-dai-cells = <0>;                                                                                                                              
    compatible = "ti,pcm5102a";
    status = "disabled";
 };

As for the use of snd-soc-dummy, I couldn't make it work properly, but I noticed that the generic linux driver seems to use a hardcoded string to register it : https://github.com/torvalds/linux/blob/master/sound/soc/generic/simple-card.c

来源:https://stackoverflow.com/questions/47398505/register-snd-soc-dummy-in-a-device-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!