This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
resources:tools-software:linux-drivers:sound:adau1373 [29 Aug 2011 14:58] – [ADAU1373 driver] Michael Hennerich | resources:tools-software:linux-drivers:sound:adau1373 [31 Aug 2011 13:14] – Evaluation board driver Lars-Peter Clausen | ||
---|---|---|---|
Line 80: | Line 80: | ||
===== ALSA Controls ===== | ===== ALSA Controls ===== | ||
- | ^ Name ^ Description ^ Configuration ^ | + | ^ Name ^ Description ^ Configuration ^ |
- | | AIF1 Capture Volume | | | | + | | AIF1 Capture Volume | Digital Audio Interface A Recording Volume |
- | | AIF2 Capture Volume | | | | + | | AIF2 Capture Volume | Digital Audio Interface B Recording Volume |
- | | AIF3 Capture Volume | | | | + | | AIF3 Capture Volume | Digital Audio Interface C Recording Volume |
- | | ADC Capture Volume | + | | ADC Capture Volume | ADC Recording Volume |
- | | DMIC Capture Volume | + | | DMIC Capture Volume | DMIC Recording Volume |
- | | AIF1 Playback | + | | Input 1 Capture |
- | | AIF2 Playback | + | | Input 2 Capture |
- | | AIF3 Playback | + | | Input 3 Capture |
- | | DAC1 Playback | + | | Input 4 Capture |
- | | DAC2 Playback | + | | Input 1 Boost Capture |
- | | Lineout1 Playback | + | | Input 2 Boost Capture |
- | | Speaker Playback | + | | Input 3 Boost Capture |
- | | Headphone | + | | Input 4 Boost Capture Volume | Input 4 ADC Boost (+20dB) | | |
- | | Input 1 Capture | + | | AIF1 Playback Volume | Digital Audio Interface A Playback Datapath Volume |
- | | Input 2 Capture | + | | AIF2 Playback |
- | | Input 3 Capture | + | | AIF3 Playback |
- | | Input 4 Capture | + | | DAC1 Playback |
- | | Earpiece | + | | DAC2 Playback |
- | | AIF3 Boost Playback Volume | | | | + | | Lineout1 |
- | | AIF2 Boost Playback Volume | | | | + | | Lineout2 |
- | | AIF1 Boost Playback Volume | | | | + | | Speaker |
- | | AIF3 Boost Capture | + | | Headphone |
- | | AIF2 Boost Capture | + | | Earpiece Playback |
- | | AIF1 Boost Capture | + | | AIF1 Boost Playback |
- | | DMIC Boost Capture | + | | AIF2 Boost Playback |
- | | ADC Boost Capture Volume | | | | + | | AIF3 Boost Playback |
- | | DAC2 Boost Playback | + | | AIF1 Boost Capture Volume | Digital Audio Interface C Recording Gain (+6dB) |
- | | DAC1 Boost Playback | + | | AIF2 Boost Capture |
- | | Input 1 Boost Capture Volume | | | | + | | AIF3 Boost Capture |
- | | Input 2 Boost Capture Volume | | | | + | | ADC Boost Capture Volume | ADC Recording Gain (+6dB) |
- | | Input 3 Boost Capture | + | | DMIC Boost Capture Volume | DMIC Recording Gain (+6dB) |
- | | Input 4 Boost Capture | + | | DAC1 Boost Playback |
- | | Speaker Boost Playback Volume | | | | + | | DAC2 Boost Playback |
- | | Lineout1 LR Mux | | | | + | | Speaker Boost Playback Volume | Speaker Output Gain |
- | | Speaker LR Mux | | | | + | | Lineout1 LR Mux | Lineout1 Left-Right Mux (Mono Stereo Control)\\ Valid values: " |
- | | HPF Cutoff | | | | + | | Lineout2 LR Mux | Lineout2 Left-Right Mux (Mono Stereo Control)\\ Valid values: " |
- | | HPF Switch | | | | + | | Speaker LR Mux | Speaker Left-Right Mux (Mono Stereo Control)\\ Valid values: " |
- | | HPF Channel | | | | + | | HPF Cutoff | High-pass-filter cutoff frequency.\\ Valid values: " |
- | | Bass HPF Cutoff | | | | + | | HPF Switch | Enable/ |
- | | Bass Clip Level Threshold | | | | + | | HPF Channel | Hight-pass-filter channel.\\ Valid values: " |
- | | Bass LPF Cutoff | | | | + | | Bass HPF Cutoff | Bass High-pass-filter cutoff frequency.\\ Valid values: |
- | | Bass Playback Switch | | | | + | | Bass Clip Level Threshold | Signal Extend Density (Clip Level). Overdrive level for bass enhancement. \\ Valid values: " |
- | | Bass Playback Volume | | | | + | | Bass LPF Cutoff | Bass Low-pass-filter cutoff frequency.\\ Valid values: " |
- | | Bass Channel | | | | + | | Bass Playback Switch | Enable/ |
- | | 3D Freq | | | | + | | Bass Playback Volume | Bass Enhancement Gain | | |
- | | 3D Level | | | | + | | Bass Channel | Bass Enhancement Channel.\\ Valid values: " |
- | | 3D Playback Switch | | | | + | | 3D Freq | 3D Enhancement cutoff frequency (relative to the sampling rate).\\ Valid values: "No 3D", " |
- | | 3D Playback Volume | | | | + | | 3D Level | 3D Enhancement effect level. \\ Valid values: " |
- | | 3D Channel | | | | + | | 3D Playback Switch | Enable/ |
- | | Zero Cross Switch | | | | + | | 3D Playback Volume | 3D Enhancement Gain | | |
- | | Lineout2 Playback Volume | | Single-ended lineout | + | | 3D Channel | 3D Enhancement Channel.\\ Valid values: " |
- | | Lineout2 LR Mux | | Single-ended lineout | + | | Zero Cross Switch | Enable/ |
- | | DRC1 Channel | | | | + | | DRC1 Channel | Dynamic Range Control 1 Channel.\\ Valid values: " |
- | | DRC2 Channel | | | | + | | DRC2 Channel | Dynamic Range Control 2 Channel.\\ Valid values: " |
- | | DRC3 Channel | | | | + | | DRC3 Channel | Dynamic Range Control 3 Channel.\\ Valid values: " |
- | ===== Supported DAI formats | + | ===== PLL Configuration ====== |
+ | |||
+ | The ADAU1373 features two PLLs: | ||
+ | |||
+ | <code c> | ||
+ | enum adau1373_pll { | ||
+ | ADAU1373_PLL1 = 0, | ||
+ | ADAU1373_PLL2 = 1, | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | Each PLLs input frequency can be selected from a variety of signals: | ||
+ | <code c> | ||
+ | enum adau1373_pll_src { | ||
+ | ADAU1373_PLL_SRC_MCLK1 = 0, | ||
+ | ADAU1373_PLL_SRC_BCLK1 = 1, | ||
+ | ADAU1373_PLL_SRC_BCLK2 = 2, | ||
+ | ADAU1373_PLL_SRC_BCLK3 = 3, | ||
+ | ADAU1373_PLL_SRC_LRCLK1 = 4, | ||
+ | ADAU1373_PLL_SRC_LRCLK2 = 5, | ||
+ | ADAU1373_PLL_SRC_LRCLK3 = 6, | ||
+ | ADAU1373_PLL_SRC_GPIO1 = 7, | ||
+ | ADAU1373_PLL_SRC_GPIO2 = 8, | ||
+ | ADAU1373_PLL_SRC_GPIO3 = 9, | ||
+ | ADAU1373_PLL_SRC_GPIO4 = 10, | ||
+ | ADAU1373_PLL_SRC_MCLK2 = 11, | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | The input frequency must configured to be between 7813 and 27000000 Hz. The output frequency must be configured to be between 45158000 and 49152000. Configuring the PLL with other input or output frequency will fail. | ||
+ | |||
+ | The PLL runs at 1024 times the base sample rate. So for a 48000 Hz based sample rate you'd normally choose 49152000 Hz for the PLL output frequncey and for a 44100 Hz based sample rate 45158400 Hz. | ||
+ | |||
+ | ===== DAI configuration ===== | ||
+ | |||
+ | The codec driver registers three DAIs: | ||
+ | * " | ||
+ | * " | ||
+ | * " | ||
+ | |||
+ | ==== Supported DAI formats ==== | ||
^ Name ^ Supported by driver ^ Description ^ | ^ Name ^ Supported by driver ^ Description ^ | ||
Line 158: | Line 198: | ||
| SND_SOC_DAIFMT_CBS_CFS | yes | Codec bit- and frameclock slave | | | SND_SOC_DAIFMT_CBS_CFS | yes | Codec bit- and frameclock slave | | ||
+ | ==== DAI sysclk ==== | ||
+ | |||
+ | The DAIs can either use PLL1 or PLL2 as source. When configuring a DAI its rate should be set to the rate of the source PLL. | ||
+ | |||
+ | <code c> | ||
+ | enum adau1373_clk_src { | ||
+ | ADAU1373_CLK_SRC_PLL1 = 0, | ||
+ | ADAU1373_CLK_SRC_PLL2 = 1, | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ==== Example DAI configuration ==== | ||
+ | |||
+ | <code c> | ||
+ | static int bfin_eval_adau1373_hw_params(struct snd_pcm_substream *substream, | ||
+ | struct snd_pcm_hw_params *params) | ||
+ | { | ||
+ | struct snd_soc_pcm_runtime *rtd = substream-> | ||
+ | struct snd_soc_dai *cpu_dai = rtd-> | ||
+ | struct snd_soc_dai *codec_dai = rtd-> | ||
+ | int ret; | ||
+ | int pll_rate; | ||
+ | |||
+ | ret = snd_soc_dai_set_fmt(cpu_dai, | ||
+ | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); | ||
+ | if (ret) | ||
+ | return ret; | ||
+ | |||
+ | ret = snd_soc_dai_set_fmt(codec_dai, | ||
+ | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); | ||
+ | if (ret) | ||
+ | return ret; | ||
+ | |||
+ | switch (params_rate(params)) { | ||
+ | case 48000: | ||
+ | case 8000: | ||
+ | case 12000: | ||
+ | case 16000: | ||
+ | case 24000: | ||
+ | case 32000: | ||
+ | pll_rate = 48000 * 1024; | ||
+ | break; | ||
+ | case 44100: | ||
+ | case 7350: | ||
+ | case 11025: | ||
+ | case 14700: | ||
+ | case 22050: | ||
+ | case 29400: | ||
+ | pll_rate = 44100 * 1024; | ||
+ | break; | ||
+ | default: | ||
+ | return -EINVAL; | ||
+ | } | ||
+ | |||
+ | ret = snd_soc_dai_set_pll(codec_dai, | ||
+ | ADAU1373_PLL_SRC_MCLK1, | ||
+ | if (ret) | ||
+ | return ret; | ||
+ | |||
+ | ret = snd_soc_dai_set_sysclk(codec_dai, | ||
+ | SND_SOC_CLOCK_IN); | ||
+ | |||
+ | return ret; | ||
+ | } | ||
+ | |||
+ | static int bfin_eval_adau1373_codec_init(struct snd_soc_pcm_runtime *rtd) | ||
+ | { | ||
+ | struct snd_soc_dai *codec_dai = rtd-> | ||
+ | unsigned int pll_rate = 48000 * 1024; | ||
+ | int ret; | ||
+ | |||
+ | ret = snd_soc_dai_set_pll(codec_dai, | ||
+ | ADAU1373_PLL_SRC_MCLK1, | ||
+ | if (ret) | ||
+ | return ret; | ||
+ | |||
+ | ret = snd_soc_dai_set_sysclk(codec_dai, | ||
+ | SND_SOC_CLOCK_IN); | ||
+ | |||
+ | return ret; | ||
+ | } | ||
+ | static struct snd_soc_ops bfin_eval_adau1373_ops = { | ||
+ | .hw_params = bfin_eval_adau1373_hw_params, | ||
+ | }; | ||
+ | |||
+ | static struct snd_soc_dai_link bfin_eval_adau1373_dai = { | ||
+ | .name = " | ||
+ | .stream_name = " | ||
+ | .cpu_dai_name = " | ||
+ | .codec_dai_name = " | ||
+ | .platform_name = " | ||
+ | .codec_name = " | ||
+ | .ops = & | ||
+ | .init = bfin_eval_adau1373_codec_init, | ||
+ | }; | ||
+ | </ | ||
====== ADAU1373 evaluation board driver ====== | ====== ADAU1373 evaluation board driver ====== | ||
+ | |||
+ | There is no dedicated Blackfin STAMP evaluation board for the ADAU1373. During test and driver development we used the [[adi> | ||
+ | |||
+ | It can be easily wired to the Blackfin STAMP SPORT header. | ||
===== Source ===== | ===== Source ===== | ||
Line 173: | Line 313: | ||
| driver | | driver | ||
- | ===== Adding | + | ===== Kernel |
- | Skip this section if you want to build the driver into the kernel directly. | + | |
- | To add support for codec ADAU1373 to the kernel build system, a few things must be enabled properly for things to work.The configuration is as following: | + | |
< | < | ||
- | Linux Kernel Configuration | + | Device Drivers |
- | | + | [*] I2C support |
- | | + | [*] I2C Hardware Bus support |
- | < | + | *** I2C system bus drivers |
- | Advanced Linux Sound Architecture | + | <*> Blackfin TWI I2C support |
- | < | + | (100) |
- | < > Sequencer support | + | |
- | <M> OSS Mixer API | + | |
- | <M> OSS PCM (digital audio) API | + | |
- | System | + | |
- | <M> ALSA for SoC audio support | + | |
- | <M> SoC I2S Audio for the ADI BF5xx chip | + | |
- | <M> SoC ADAU1373 Audio support | + | |
- | < > SoC AC97 Audio support for BF5xx | + | |
- | | + | |
</ | </ | ||
- | <note important> | + | Enable ALSA SoC evaluation board driver: |
- | I2C bus is used to configure the codec. | + | |
- | </ | + | |
< | < | ||
- | Linux Kernel Configuration | + | Device Drivers |
- | | + | <M> Sound card support |
- | <*> I2C support | + | < |
- | --- I2C support | + | < |
- | I2C Hardware Bus Support | + | <M> Support for the EVAL-ADAU1373 boards on Blackfin |
- | <*> Blackfin | + | |
</ | </ | ||
- | 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. | + | ===== Hardware configuration ===== |
+ | TODO | ||
- | ==== Testing the built in kernel driver | + | ===== Driver testing ===== |
- | If audio is configured as modules, skip this section. If audio is built into kernel | + | Load the driver |
- | - Check the boot messages to see if you have booted the correct kernel. During kernel boot, it should print out: <code> | + | <box 100% green|shell prompt running on the target> |
- | Advanced Linux Sound Architecture Driver Version 1.0.12rc1 (Thu Jun 22 13:55:50 2006 UTC). | + | <xterm> |
- | ASoC version 0.13.1 | + | root:/> modprobe snd-bf5xx-i2s |
- | dma rx:3 tx:4, err irq:15, regs: | + | root:/> |
- | adau1371 Audio Codec 0.1<6>dma_alloc_init: | + | root:/> modprobe snd-soc-adau1373 |
- | asoc: ADAU1373 <-> bf5xx-i2s-0 mapping ok | + | root:/> modprobe snd-soc-bfin-eval-adau1373 |
- | ALSA device list: | + | dma rx:3 tx:4, err irq:45, regs: |
- | #0: bf5xx_adau1373 (ADAU1373) | + | asoc: ADAU1373 <-> bf5xx-i2s mapping ok |
- | </code> | + | |
- | + | ||
- | ==== Testing the audio module ==== | + | |
- | + | ||
- | < | + | |
- | root:~> **modprobe snd-pcm-oss** | + | |
- | root:~> **lsmod** | + | |
- | Module | + | |
- | snd_pcm_oss | + | |
- | snd_mixer_oss | + | |
- | snd_adau1373 | + | |
- | snd_soc_adau1373 | + | |
- | snd_soc_bf5xx | + | |
- | snd_soc_bf5xx_i2s | + | |
- | snd_soc_core | + | |
- | snd_pcm | + | |
- | snd_page_alloc | + | |
- | snd_timer | + | |
- | snd 31092 6 snd_pcm_oss, | + | |
- | soundcore | + | |
- | + | ||
- | root:~> **tone** | + | |
- | TONE: generating sine wave at 1000 Hz... | + | |
</ | </ | ||
+ | </ | ||
+ | <box 100% green|shell prompt running on the target> | ||
+ | < | ||
+ | root:/> modprobe snd-pcm-oss | ||
+ | root:/> tone | ||
+ | TONE: generating sine wave at 1000 Hz... | ||
- | ===== Testing Audio ===== | + | root:/> |
- | + | Recording WAVE 'stdin' | |
- | - Check the output < | + | Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo |
- | TONE: generating sine wave at 1000 Hz... | + | |
- | </xterm> You should hear something out of the headphone Jack on the top of J8. | + | |
- | | + | |
- | Simple mixer control | + | |
- | | + | |
- | Items: | + | |
- | Item0: ' | + | |
- | - Check to make sure mp3s work (assuming you have built mp3play), | + | |
- | - The first step is to download a mp3 file onto the platform. The '' | + | |
- | root:/ | + | |
- | </ | + | |
- | - Next, play it with mp3play: < | + | |
- | - You can play it in one step with: < | + | |
- | %%http:// | + | |
</ | </ | ||
- | - Optionally check to make sure the audio out is right: | + | </box> |
- | Simple mixer control ' | + | |
- | Capabilities: | + | |
- | Items: ' | + | |
- | Item0: ' | + | |
- | root:~> **arecord -d 10 test.wav** | + | |
- | Recording WAVE " | + | |
- | root:~> **aplay test.wav** | + | |
- | Adjust playback volume can be done through command: | + | |
- | here 80 is the ratio. | + | |
- | </ | + | |
- | - You should also be able to do a " | + |