Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
resources:tools-software:linux-drivers:sound:ad1835a [06 May 2011 16:25] – resources_tools-software_linux-drivers_sound_ad1835a renamed to resources:tools-software:linux-drivers:sound:ad1835a andyrresources:tools-software:linux-drivers:sound:ad1835a [04 Feb 2021 15:36] (current) – [Driver testing] Michael Hennerich
Line 1: Line 1:
-====== Adding Audio to the Kernel ======+====== AD1836 Sound CODEC Linux Driver ====== 
 + 
 +===== Supported devices ===== 
 + 
 +  * [[adi>AD1835A]] 
 +  * [[adi>AD1836A]] 
 +  * [[adi>AD1838A]] 
 +  * [[adi>AD1837A]] 
 +  * [[adi>AD1839A]] 
 + 
 +===== Evaluation Boards ===== 
 + 
 +  * [[adi>AD1836AZ-DBRD]] 
 + 
 +====== Source Code ====== 
 + 
 +==== Status ==== 
 + 
 +^ Source ^ Mainline? ^ 
 +| [[git.linux.org>sound/soc/codecs/ad1836.c|git]] | [[git.linux.org>sound/soc/codecs/ad1836.c|Yes]] | 
 + 
 +==== Files ==== 
 + 
 +^ Function ^ File ^ 
 +| driver  | [[git.linux.org>sound/soc/codecs/ad1836.c]] | 
 +| include | [[git.linux.org>sound/soc/codecs/ad1836.h]] | 
 + 
 +====== Example device initialization ====== 
 + 
 +{{page>software/linux/docs/platform_and_bus_model#Declaring SPI slave devices&firstseconly&noeditbtn}} 
 + 
 +You need to set the modalias of your SPI info according to your codec. Valid values are "ad1835", "ad1836", "ad1837", "ad1838" and "ad1839". You'll also have to adjust bus_num and chip_select according to your board setup. 
 + 
 +<code c> 
 +static struct spi_board_info board_spi_board_info[] __initdata = { 
 + [--snip--] 
 +
 + .modalias = "ad1836", 
 + .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */ 
 + .bus_num = 0, 
 + .chip_select = 4, /* CS, change it for your board */ 
 + .mode = SPI_MODE_3, 
 + }, 
 + [--snip--] 
 +}; 
 +</code> 
 + 
 +<code c> 
 +static int __init board_init(void) 
 +
 + [--snip--] 
 + 
 + spi_register_board_info(board_spi_board_info, ARRAY_SIZE(board_spi_board_info)); 
 + 
 + [--snip--] 
 + 
 + return 0; 
 +
 +arch_initcall(board_init); 
 +</code> 
 + 
 +===== ASoC DAPM Widgets ===== 
 + 
 +^ Name ^ Description ^ Model ^ 
 +| DAC1OUT | DAC Channel1 Output | AD1835A, AD1836A, AD1838A | 
 +| DAC2OUT | DAC Channel2 Output | AD1835A, AD1836A, AD1838A | 
 +| DAC3OUT | DAC Channel3 Output | AD1835A, AD1836A, AD1838A | 
 +| DAC4OUT | DAC Channel4 Output | AD1835A | 
 +| ADC1IN | ADC Channel1 Input | AD1835A, AD1836A, AD1838A | 
 +| ADC2IN | ADC Channel2 Input | AD1836A | 
 + 
 +===== ALSA Controls ===== 
 + 
 +^ Name ^ Description ^ Model ^ 
 +| ADC High Pass Filter Switch | Enable/Disable ADC high-pass filter | AD1835A, AD1836A, AD1838A | 
 +| Playback Deemphasis | Select playback de-emphasis. Possible Values: "None", "44.1kHz", "32kHz", "48kHz" | AD1835A, AD1836A, AD1838A | 
 +| DAC1 Playback Volume | DAC Channel 1 volume | AD1835A, AD1836A, AD1838A | 
 +| DAC2 Playback Volume | DAC Channel 2 volume | AD1835A, AD1836A, AD1838A | 
 +| DAC3 Playback Volume | DAC Channel 3 volume | AD1835A, AD1836A, AD1838A | 
 +| DAC4 Playback Volume | DAC Channel 4 volume | AD1835A | 
 +| DAC1 Playback Switch | Mute/Unmute DAC Channel 1 | AD1835A, AD1836A, AD1838A | 
 +| DAC2 Playback Switch | Mute/Unmute DAC Channel 2 | AD1835A, AD1836A, AD1838A | 
 +| DAC3 Playback Switch | Mute/Unmute DAC Channel 3 | AD1835A, AD1836A, AD1838A | 
 +| DAC4 Playback Switch | Mute/Unmute DAC Channel 4 | AD1835A | 
 +| ADC1 Capture Switch | Mute/Unmute ADC Channel1 | AD1835A, AD1836A, AD1838A | 
 +| ADC2 Capture Switch | Mute/Unmute ADC Channel2 | AD1836A | 
 +| ADC2 Capture Volume | Gain for ADC Channel 2 | AD1836A | 
 + 
 +===== DAI Configuration ===== 
 + 
 +The CODEC driver registers one DAI named depending on the chip model used. 
 + 
 +^ DAI name ^ Model ^ 
 +| "ad1835-hifi" | AD1835, AD1837 | 
 +| "ad1836-hifi" | AD1836 | 
 +| "ad1838-hifi" | AD1838, AD1839 | 
 + 
 +==== Supported DAI formats ==== 
 + 
 +^ Name ^ Supported by driver ^ Description ^ 
 +| SND_SOC_DAIFMT_I2S     | no  | I2S mode | 
 +| SND_SOC_DAIFMT_RIGHT_J | no  | Right Justified mode | 
 +| SND_SOC_DAIFMT_LEFT_J  | no  | Left Justified mode  | 
 +| SND_SOC_DAIFMT_DSP_A   | yes | data MSB after FRM LRC | 
 +| SND_SOC_DAIFMT_DSP_B   | no  | data MSB during FRM LRC  | 
 +| SND_SOC_DAIFMT_AC97    | no  | AC97 mode | 
 +| SND_SOC_DAIFMT_PDM     | no  | Pulse density modulation | 
 +| | | 
 +| SND_SOC_DAIFMT_NB_NF | no | Normal bit- and frameclock | 
 +| SND_SOC_DAIFMT_NB_IF | no  | Normal bitclock, inverted frameclock | 
 +| SND_SOC_DAIFMT_IB_NF | no  | Inverted frameclock, normal bitclock | 
 +| SND_SOC_DAIFMT_IB_IF | yes  | Inverted bit- and frameclock | 
 +| | | 
 +| SND_SOC_DAIFMT_CBM_CFM | yes | Codec bit- and frameclock master | 
 +| SND_SOC_DAIFMT_CBS_CFM | no  | Codec bitclock slave, frameclock master | 
 +| SND_SOC_DAIFMT_CBM_CFS | no  | Codec bitclock master, frameclock slave | 
 +| SND_SOC_DAIFMT_CBS_CFS | no  | Codec bit- and frameclock slave | 
 + 
 +==== Example DAI Configuration ==== 
 + 
 +<code c> 
 +static int bf5xx_ad1836_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; 
 + struct snd_soc_dai *codec_dai = rtd->codec_dai; 
 + int ret; 
 + 
 + /* set cpu DAI configuration */ 
 + ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A | 
 + SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM); 
 + if (ret < 0) 
 + return ret; 
 + 
 + /* set codec DAI configuration */ 
 + ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | 
 + SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM); 
 + if (ret < 0) 
 + return ret; 
 + 
 + return 0; 
 +
 + 
 +static struct snd_soc_ops bf5xx_ad1836_ops = { 
 + .hw_params = bf5xx_ad1836_hw_params, 
 +}; 
 + 
 +static struct snd_soc_dai_link bf5xx_ad1836_dai = { 
 + .name = "ad1836", 
 + .stream_name = "AD1836", 
 + .cpu_dai_name = "bfin-tdm.0", 
 + .codec_dai_name = "ad1836-hifi", 
 + .platform_name = "bfin-tdm-pcm-audio", 
 + .codec_name = "spi0.4", 
 + .ops = &bf5xx_ad1836_ops, 
 +}; 
 +</code> 
 +====== AD1836 evaluation board driver ====== 
 ===== Adding Kernel Support - As a module ===== ===== Adding Kernel Support - As a module =====
  
Line 20: Line 179:
  
 Doing this will create modules (outside the kernel). The modules will be inserted automatically when it is needed. You can also build sound driver into kernel. Doing this will create modules (outside the kernel). The modules will be inserted automatically when it is needed. You can also build sound driver into kernel.
 +
 ==== Testing the built in kernel driver ==== ==== Testing the built in kernel driver ====
  
Line 34: Line 194:
         #0: bf5xx_ad183x (AD183X)         #0: bf5xx_ad183x (AD183X)
 </code> </code>
 +
 ==== Testing the audio module ==== ==== Testing the audio module ====
 <code> <code>
Line 61: Line 222:
 </code> </code>
  
-===== Testing Audio =====+===== Driver testing =====
  
   - Check the output    - Check the output 
Line 125: Line 286:
   Also you can run "alsamixer" to get graphic configuration interface, OSS-based "mixer" can work too.   Also you can run "alsamixer" to get graphic configuration interface, OSS-based "mixer" can work too.
   - Check to make sure mp3s work (assuming you have built mp3play),   - Check to make sure mp3s work (assuming you have built mp3play),
-    - The first step is to download a mp3 file onto the platform. The ''wget'' command assumes that networking is properly configured (you have an IP number, the default gateway is set, and DNS servers can be accessed), and working. See the [[:setting_up_the_network|network setup page]] for more info. <xterm>root:/> **cd /var**+    - The first step is to download a mp3 file onto the platform. The ''wget'' command assumes that networking is properly configured (you have an IP number, the default gateway is set, and DNS servers can be accessed), and working. <xterm>root:/> **cd /var**
 root:/var> **wget http://www.radiocrazy.com/shows/A/AbbottCostello/ABCOWhosOnFirstclip.mp3** root:/var> **wget http://www.radiocrazy.com/shows/A/AbbottCostello/ABCOWhosOnFirstclip.mp3**
 </xterm> </xterm>
resources/tools-software/linux-drivers/sound/ad1835a.1304691923.txt.gz · Last modified: 06 May 2011 16:25 by andyr