[alsa-devel] [PATCH] asoc: add dummy codec
Lars-Peter Clausen
lars at metafoo.de
Thu Apr 11 20:02:33 CEST 2013
On 04/11/2013 05:48 PM, Gabriel M. Beddingfield wrote:
> On 04/11/2013 08:11 AM, Stas Sergeev wrote:
>>> There is already a dummy codec driver.
>>>
>>> Please take a look at sound/soc/soc-utils.c
>>>
>>> - Lars
>> Lars, indeed, this codec is present in a git kernel and
>> it wasn't in mine android kernel.
>> But, that driver is too dummy to even work at all.
>>
>> The attached patch adds a playback stream for the dummy
>> codec. Would it be possible to apply this?
>
> No... not like that.
>
> Instead, wouldn't it be better to extend it by defining some platform data? Maybe something like:
Either you want a dummy or you want one with specific requirements. For the
former case use the dummy codec, for the later case add a proper driver.
Putting these kinds of things in your board file is in my opinion a bad habit.
- Lars
>
> diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c
> index fe4541d..9d22718 100644
> --- a/sound/soc/soc-utils.c
> +++ b/sound/soc/soc-utils.c
> @@ -96,9 +96,14 @@ static struct snd_soc_dai_driver dummy_dai = {
>
> static int snd_soc_dummy_probe(struct platform_device *pdev)
> {
> + struct snd_soc_dummy_dai_pdata *pdata = dev_get_platdata(&pdev->dev);
> int ret;
>
> - ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1);
> + if (pdata->n_dai > 0)
> + ret = snd_soc_register_codec(&pdev->dev, &dummy_codec,
> + &pdata->dai, &pdata->n_dai);
> + else
> + ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1);
> if (ret < 0)
> return ret;
>
>
> ...then you can define whatever kind of DAI you want in the machine driver.
>
> -gabriel
>
More information about the Alsa-devel
mailing list