[alsa-devel] [PATCH 2/3] ASoC: add snd_soc_of_get_port_dai_name()

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Thu Feb 14 02:16:55 CET 2013


Hi Stephen

Thank you for your explain.
I think I could understand, but not 100%.

> Well, any driver that could be used with it will need to implement the
> .of_xlate() callback. The simple-audio code would still be 100%
> independent from any CPU or CODEC, since of_xlate would be a standard
> interface/API that any CPU or CODEC driver could implement, and any ASoC
> machine driver could call.
(snip)
> Yes, .of_xlate() wouldn't have to be implemented by the WM8903 CODEC
> driver for the tegra-wm8903 machine driver to use the WM8903 CODEC.
> However, if it /was/ implemented, it wouldn't stop tegra-wm8903 from
> working. And later, it may help unify all the simple Tegra machine
> drivers into one, since they could also become CODEC-independent, and
> hence become unified (or at least mostly unified) code.

I guess, this .of_xlate should has "public" interface for all drivers,
not simple-card special.
Now, simple-card needs "dai name" from struct of_phandle_args.
This .of_xlate can be used from other driver if there is such kind of driver.
Now, as example, I assumed this "other driver" needs something other data pointer from .of_xlate here.

Then can .of_xlate has *void pointer for return ?
In my check, the parameter of .of_xlate in gpio_chip and pmw has "driver specific" parameter.


My pseudo code now is below.
But is this correct ??

simple-card  OF has <&device port>  : of_phandle_args will be used as "port" spec
other driver OF has <xxxx yyy zzz>  : of_phandle_args will be used as "something" spec

-- asoc --
struct snd_soc_dai_driver {
       ...
       int (*of_xlate)(struct snd_soc_dai_driver    *driver,
                       const struct of_phandle_args *spec,  // driver specific spec
                       void                         *data); // for return data
       ...
}

-- MULTI .of_xlate support codec driver ---

#ifdef CONFIG_ASOC_SIMPLE_AUDIO_OF
int codec_of_xlate(struct snd_soc_dai_driver    *driver,
                   const struct of_phandle_args *portspec,
                   void                         *data);
{
        /*
         * for simple-card which needs "dai name"
         *
         * of_phandle_args is used as "port" spec
         */
        *data = port_to_dai_name(portspec);
        return 0;
}
#elif  CONFIG_OTHER_DIRVER_IT_NEEDS_xxx_POINTER_OF
int codec_of_xlate(struct snd_soc_dai_driver    *driver,
                   const struct of_phandle_args *something_spec,
                   void                         *data);
{
        /*
         * for "other" driver which needs something pointer
         *
         * of_phandle_args is used as "something" spec
         */
        *data = something_necessary_pointer(something_spec);
        return 0;
}
#else
#define codec_of_xlate() NULL
#endif

struct snd_soc_dai_driver  codec_driver = {
       ...
       .of_xlate = codec_of_xlate,
       ...
}



Best regards
---
Kuninori Morimoto


More information about the Alsa-devel mailing list