This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BeagleBone Black - ALSA ADC register (no soundcard)

Hello TI community,

i'm trying to interface an audio adc (wolfson wm8782) with the Beagle Black (running Ubuntu 13.10 kernel, 3.8.13-bone39).

My problem is that i cant make the kernel register the "soundcard", i'm struggling with the files davinci-evm.c and with the codec driver wm8782.c (please see below for the code). I don't know if this is the right way or there is an easy way using device tree overlays...

I'll appreciate any help!

Thanks!

davinci-evm.c

/*
 * ASoC Driver.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */

#include <linux/module.h>
#include <linux/platform_device.h>

#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/jack.h>

static int evm_wm8782_init(struct snd_soc_pcm_runtime *rtd)
{
	return 0;
}

static int evm_wm8782_hw_params(struct snd_pcm_substream *substream,
				       struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
		struct snd_soc_dai *cpu_dai = rtd->cpu_dai;

		/*return snd_soc_dai_set_bclk_ratio(cpu_dai, 32*2);*/
		return 0;
}

/* machine stream operations */
static struct snd_soc_ops evm_wm8782_ops = {
	.hw_params = evm_wm8782_hw_params,
};

static struct snd_soc_dai_link evm_wm8782_dai[] = {
{
	.name		= "wm8782 board",
	.stream_name	= "wm8782 board",
	.cpu_dai_name	= "davinci-mcasp.0",
	.codec_dai_name	= "wm8782-hifi",
	.platform_name	= "davinci-pcm-audio",
	.codec_name	= "wm8782-codec.3-001b",
	.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
				SND_SOC_DAIFMT_CBS_CFS,
	.ops		= &evm_wm8782_ops,
	.init		= evm_wm8782_init,
},
};

/* audio machine driver */
static struct snd_soc_card snd_wm8782_adc = {
	.name         = "snd_wm8782_adc",
	.dai_link     = evm_wm8782_dai,
	.num_links    = ARRAY_SIZE(evm_wm8782_dai),
};

static int snd_wm8782_probe(struct platform_device *pdev)
{
	int ret = 0;

	snd_wm8782_adc.dev = &pdev->dev;
	ret = snd_soc_register_card(&snd_wm8782_adc);
	if (ret)
		dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);

	return ret;
}

static int snd_wm8782_remove(struct platform_device *pdev)
{
	return snd_soc_unregister_card(&snd_wm8782_adc);
}

static struct platform_driver snd_wm8782_driver = {
        .driver = {
                .name   = "snd-wm8782-adc",
                .owner  = THIS_MODULE,
        },
        .probe          = snd_wm8782_probe,
        .remove         = snd_wm8782_remove,
};

module_platform_driver(snd_wm8782_driver);

MODULE_AUTHOR("E.E.R");
MODULE_DESCRIPTION("ASoC Driver for pcm1803 ADC");
MODULE_LICENSE("GPL v2");