i'm trying to interface an audio ADC (wm8782/pcm1803a) with the Beagle Black. I already did some changes in the files davinci-evm , wm8782.c and BB-BONE-AUDI-01 device tree overlay file (see code below).
My problem is that when loading the dtbo file dmesg returns:
"...Codec DAI wm8782-hifi not found"
I'm assuming that my codec (wm8782) is not being registered by alsa core, but where I have to do that??
I'm running Ubuntu 13.10, kernel: 3.8.13-bone39
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 = "PCM1803 board",
.stream_name = "PCM1803 board",
.cpu_dai_name = "davinci-mcasp.0",
.codec_dai_name = "wm8782-hifi",
.platform_name = "davinci-pcm-audio",
.codec_name = "wm8782-codec",
.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");
wm8782.c
/*
* sound/soc/codecs/wm8782.c
* simple, strap-pin configured 24bit 2ch ADC
*
* Copyright: 2011 Raumfeld GmbH
* Author: Johannes Stezenbach <js@sig21.net>
*
* based on ad73311.c
* Copyright: Analog Device Inc.
* Author: Cliff Cai <cliff.cai@analog.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/ac97_codec.h>
#include <sound/initval.h>
#include <sound/soc.h>
static struct snd_soc_dai_driver wm8782_dai = {
.name = "wm8782-hifi",
.capture = {
.stream_name = "Capture",
.channels_min = 1,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_8000_192000,
.formats = SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_S24_LE,
},
};
static struct snd_soc_codec_driver soc_codec_dev_wm8782;
static int wm8782_probe(struct platform_device *pdev)
{
return snd_soc_register_codec(&pdev->dev,
&soc_codec_dev_wm8782, &wm8782_dai, 1);
}
static int wm8782_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
}
static struct platform_driver wm8782_codec_driver = {
.driver = {
.name = "wm8782",
.owner = THIS_MODULE,
},
.probe = wm8782_probe,
.remove = wm8782_remove,
};
module_platform_driver(wm8782_codec_driver);
MODULE_DESCRIPTION("ASoC WM8782 driver");
MODULE_AUTHOR("Johannes Stezenbach <js@sig21.net>");
MODULE_LICENSE("GPL");
BB-BONE-AUDI-01-00A0.dts
/*
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
* 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.
*/
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";
/* identification */
part-number = "BB-BONE-AUDI-01";
version = "00A0", "A0";
/* state the resources this cape uses */
exclusive-use =
/* the pin header uses */
"P9.14", /* leds: gpio1_18 */
"P9.16", /* leds: gpio1_19 */
"P9.31", /* mcasp0: mcasp0_aclkx */
"P9.29", /* mcasp0: mcasp0_fsx */
"P9.28", /* mcasp0: mcasp0_axr2 */
"P9.25", /* mcasp0: mcasp0_ahclkx */
/* the hardware ip uses */
"gpio1_18", "gpio1_19",
"mcasp0";
fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
bone_audio_cape_led_pins: pinmux_bone_audio_cape_led_pins {
pinctrl-single,pins = <
0x48 0x07 /* gpmc_a2.gpio1_18, OUTPUT | MODE7 */
0x4c 0x07 /* gpmc_a3.gpio1_19, OUTPUT | MODE7 */
>;
};
bone_audio_cape_audio_pins: pinmux_bone_audio_cape_audio_pins {
pinctrl-single,pins = <
0x190 0x20 /* mcasp0_aclkx.mcasp0_aclkx, INPUT | MODE0 */
0x194 0x20 /* mcasp0_fsx.mcasp0_fsx, INPUT | MODE0 */
0x19c 0x22 /* mcasp0_ahclkr.mcasp0_axr2, INPUT | MODE2 */
0x1ac 0x22 /* mcasp0_ahclkx.mcasp0_axr3, INPUT | MODE2 */
>;
};
};
};
fragment@1 {
target = <&ocp>;
__overlay__ {
/* avoid stupid warning */
#address-cells = <1>;
#size-cells = <1>;
gpio-leds-cape-audio {
compatible = "gpio-leds";
pinctrl-names = "default";
pinctrl-0 = <&bone_audio_cape_led_pins>;
audio-led0 {
label = "audio:green:usr0";
gpios = <&gpio2 18 0>;
linux,default-trigger = "heartbeat";
default-state = "off";
};
audio-led1 {
label = "audio:green:usr1";
gpios = <&gpio2 19 0>;
linux,default-trigger = "mmc0";
default-state = "off";
};
};
};
};
fragment@2 {
target = <&mcasp0>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&bone_audio_cape_audio_pins>;
status = "okay";
op-mode = <0>; /* MCASP_IIS_MODE */
tdm-slots = <2>;
num-serializer = <16>;
serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */
0 0 2 1
0 0 0 0
0 0 0 0
0 0 0 0
>;
tx-num-evt = <1>;
rx-num-evt = <1>;
};
};
};