1. 程式人生 > >I.mx6s上移植wm8960驅動(基於linux3.0.101版本)

I.mx6s上移植wm8960驅動(基於linux3.0.101版本)

注意上面最後的引數:--disable-alsamixer 若不加此引數編譯會報錯:configure error required courses helper header not found 具體原因不清楚!!

7.2 編譯
make

7.3安裝(需要root許可權)
sudo make install
8 開發板配置: 8.1 庫的拷貝:
sudo cp alsa-lib/lib/libasound.* /home/**/rootfs/lib/

8.2  alsa-utils拷貝 將alsa-utils/bin目錄小的內容拷貝到目標板根檔案系統中的bin下
sudo cp alsa-utils/bin/* /home/**/rootfs/bin

8.3 alsa的配置檔案拷貝  除了庫之外alsa的配置檔案也需要拷貝到目標板根檔案系統中,這裡需要注意的是share目錄在目標板的存放位置必須和在主機的存放路徑一致!!
sudo cp -R **/alsa/alsa-lib/share/ /home/**/rootfs/**/alsa/alsa-lib/
重新掛載檔案系統到目標板,通過 aplay  -l可以檢視我們的音訊裝置。
[email protected] ~$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
[email protected]
~$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: wm8960audio [wm8960-audio], device 0: HiFi wm8960-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0

播放聲音檔案:
aplay **.wav

最開始一直沒有聲音,後來發現是wm8960沒有初始化的原因,所以要對其進行初始化:

初始化步驟:

第1步 設定power1 2 3;
第2步 設定時鐘;
第3步 設定ADC-DAC,注意設定非靜音;
第4步 設定audio interface;
第5步 設定volume;
第6步 設定mixer;
參考如下程式碼(init at imx-wm8960.c:imx_hifi_hw_params function):
void wm8960_init(struct snd_soc_dai *codec_dai)
{
struct snd_soc_codec *codec = codec_dai->codec;

snd_soc_write(codec, 0x19, 0xc0); /* power1, ok*/
snd_soc_write(codec, 0x1a, 0x199); /* power2, ok*/

snd_soc_write(codec, 0x31, 0xf7); /* classd1 : enable L&R, ok */
snd_soc_write(codec, 0x33, 0x11b); /* classd3 : volume max, ok */

snd_soc_write(codec, 0x28, 0x179); /* ok */
snd_soc_write(codec, 0x29, 0x179); /* ok */

snd_soc_write(codec, 0x22, 0x100); /* dac to mixer, ok */
snd_soc_write(codec, 0x25, 0x100); /* dac to mixer, ok */

snd_soc_write(codec, 0x2f, 0x0c); /* left & right output mixer enable, ok */
snd_soc_write(codec, 0x05, 0x00); /* ok */
}