2014-02-06 17 views
1

我試圖用Beagle Black接口音頻ADC(wm8782/pcm1803a)。我已在文件davinci-evm,wm8782.c和BB-BONE-AUDI-01設備樹覆蓋文件(請參閱下面的代碼)中做了一些更改。 我的問題是,加載dtbo文件的dmesg返回時:BeagleBoneBlack - 在ALSA上註冊I2S ADC

「......編解碼器DAI wm8782,音響找不到」

我假設我的編解碼器(wm8782)是不是被由alsa核心註冊,但我必須這樣做? 我正在運行Ubuntu 13.10,內核:3.8.13-bone39

謝謝!

達芬奇-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 <[email protected]> 
* 
* based on ad73311.c 
* Copyright: Analog Device Inc. 
* Author: Cliff Cai <[email protected]> 
* 
* 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 <[email protected]>"); 
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"; 

    [email protected] { 
     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 */ 

       >; 
      }; 
     }; 
    }; 

    [email protected] { 
     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"; 
       }; 
      }; 
     }; 
    }; 


    [email protected] { 
     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>; 
     }; 
    }; 


}; 
+0

我已經做了一些改變和dtbo文件獲取加載,但從dmesg我得到:「davinci_evm sound.11:ASoC:CODEC DAI wm8782-hifi未註冊」。有什麼建議? – EzeEst

回答

1

您可以使您的編解碼器驅動程序變爲設備樹兼容並加載,只需在您的dts文件中添加編解碼器的節點即可。

在你的情況,這部分添加到您的編解碼器驅動程序:

. 
. 
. 
#ifdef CONFIG_OF 
static const struct of_device_id wm8782_dt_ids[] = { 
    { .compatible = "ti,wm8782", }, 
    { } 
}; 
MODULE_DEVICE_TABLE(of, wm8782_dt_ids); 
#endif 

static struct platform_driver wm8782_codec_driver = { 
    .driver = { 
     .name = "wm8782", 
     .owner = THIS_MODULE, 
     .of_match_table = of_match_ptr(wm8782_dt_ids), 
    }, 
. 
. 
. 

然後,這個節點添加到您的DTS文件:

wm8782: wm8782 { 
     wm8782 = "ti,wm8782"; 
    };