我尝试各种办法,wm8960始终不能得到声音输出。调试过程如下:
首先,打开电源使能脚:
ret=gpio_request(SABRESD_CODEC_PWR_EN, "audio_pwr_en");
if (!ret){
printk("Turn on audio(wm8962) power!(1:enable)\n");
gpio_direction_output(SABRESD_CODEC_PWR_EN, 1); // 0:enable, 1:disable
gpio_free(SABRESD_CODEC_PWR_EN);
}
串口打印如下出错信息:
wm8962 0-001a: Failed to get supply 'SPKVDD1': -19
wm8962 0-001a: Failed to request supplies: -19
wm8962 0-001a: asoc: failed to probe CODEC wm8962.0-001a: -19
asoc: failed to instantiate card wm8962-audio: -19
Initialize HDMI-audio failed. Load HDMI-video first!
ALSA device list:
No soundcards found.
把imx6q_init_audio();后移几行,上面的错误就没有了。但出现下面错误 :
wm8962 0-001a: Device is not a WM8962, ID 0 != 6243
wm8962 0-001a: asoc: failed to probe CODEC wm8962.0-001a: -22
asoc: failed to instantiate card wm8962-audio: -22
把sound/soc/codec/下面的wm8962.c改用wm8960.c(修改Kconfig和Makefile)。
wm8960_i2c_probe不调用。原因是:
.driver = {
.name = "wm8960",
而 {
I2C_BOARD_INFO("wm8962", 0x1a),
.platform_data = &wm8962_config_data,
},
linux driver是根据name来匹配的,如果匹配就调用。
登记了snd_soc_register_codec后,codec的probe也不调用。
原因是下面这个snd_dai_driver的name要一致才能调用。
static struct snd_soc_dai_driver wm8960_dai = {
.name = "wm8960",
static struct snd_soc_dai_link imx_dai[] = {
{
.name = "HiFi",
.stream_name = "HiFi",
.codec_dai_name = "wm8960",
调用后显示:
wm8960 0-001a: wm8960 probed success!
wm8960 0-001a: Failed to add route HPOUTL->Headphone Jack
asoc: wm8960 <-> imx-ssi.1 mapping ok
input: wm8960-audio DMIC as /devices/platform/soc-audio.5/sound/card0/input1
input: wm8960-audio Ext Spk as /devices/platform/soc-audio.5/sound/card0/input2
ALSA device list:
#0: wm8960-audio
root@imx6solo ~$ find / -name *wm8960*
/sys/devices/platform/imx-wm8960.0
/sys/bus/platform/devices/imx-wm8960.0
/sys/bus/platform/drivers/imx-wm8960
/sys/bus/platform/drivers/imx-wm8960/imx-wm8960.0
/sys/bus/i2c/drivers/wm8960
/proc/asound/wm8960audio
root@imx6solo ~$
问题是/dev/下面并没有增加设备,无法使用/dev/pcm。
root@imx6solo /usr/bin$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
root@imx6solo /usr/bin$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: wm8960audio [wm8960-audio], device 0: HiFi wm8960-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
root@imx6solo /usr/bin$
现在应该是试试ALSA驱动程序是不是真能用的时候了. 接者就是使用它.
查看声卡是否存在:
root@imx6solo ~$ cat /proc/asound/cards
0 [wm8960audio ]: wm8960-audio - wm8960-audio
wm8960-audio
ALSA 驱动程序在 /dev/snd/ 目录下有自己的驱动程序。
root@imx6solo ~$ ls /dev/snd/
controlC0 pcmC0D0c pcmC0D0p timer
http://www.alsa-project.org/main/index.php/Download上面下载alsa tester包括alsa-lib, alsa-utils。
编译:./gitcompile CC=arm-linux-gcc --host=arm-linux
现在进化到configure都从网络上临时下载的地步了,我有点out了。
编译alsa-utils总是过不去。重新下载alsaplayer。
./configure --host=arm-linux CC=arm-linux-gcc --disable-oggvorbis
然后make.
对比了wm8960.c/wm8962.c, imx-wm8960.c/imx-wm8962.c,差别其实非常大。
https://bbs.21ic.com/forum.php?mod=viewthread&tid=869393,从这个链接地址可以下载imx-wm8960.c。
重新配置linux kernel,设备/dev/dsp和/dev/mixer出来,这是OSS接口的要求。
root@imx6solo /test/audio$ ./wavplay test.wav
-------------------------------------------------------------------->
File Magic: [RIFF]
File Length: [424636]
File Type: [WAVE]
Fmt Magic: [fmt ]
Fmt Size: [16]
Fmt Format: [PCM]
Fmt Channels: [2]
Fmt Sample_rate: [22050](HZ),22khz
Fmt Bytes_p_second: [88200]
Fmt Blocks_align: [4]
Fmt Sample_length: [16]
Chunk Type: [data]
Chunk Length: [424600]
<--------------------------------------------------------------------
Plug PCM: Rate conversion PCM (44100, sformat=S16_LE)
Converter: linear-interpolation
Protocol version: 10002
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 22050
exact rate : 22050 (22050/1)
msbits : 16
buffer_size : 8192
period_size : 256
period_time : 11609
tstamp_mode : NONE
period_step : 1
avail_min : 256
period_event : 0
start_threshold : 1
stop_threshold : 8192
silence_threshold: 0
silence_size : 0
boundary : 536870912
Slave: Direct Stream Mixing PCM
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100 //44khz
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 16384
period_size : 512
period_time : 11609
tstamp_mode : NONE
period_step : 1
avail_min : 512
period_event : 0
start_threshold : 2
stop_threshold : 16384
silence_threshold: 0
silence_size : 0
boundary : 1073741824
Hardware PCM card 0 'wm8960-audio' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100 //44khz
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 16384
period_size : 512
period_time : 11609
tstamp_mode : ENABLE
period_step : 1
avail_min : 512
period_event : 0
start_threshold : 1
stop_threshold : 1073741824
silence_threshold: 0
silence_size : 1073741824
boundary : 1073741824
appl_ptr : 0
hw_ptr : 0
root@imx6solo /test/audio$ aplay test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Stereo
Aborted by signal Interrupt...
root@imx6solo /test/audio$
仍然是没有声音输出!!
换了一个44khz采集率的wav文件,仍然没有声音输出!
root@imx6solo /test/audio$ aplay xihuanni.wav
Playing WAVE 'xihuanni.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Aborted by signal Interrupt...
再次检查了pin mux config,是正确的。但就是没有任何audio输出!
如果直接用imx-wm8962.c,则有许多出错信息,如下:
root@imx6solo /test/audio$ aplay xihuanni.wav
WM8960 PLL: Unsupported N=3
Failed to start FLL: -22
Failed to set SYSCLK: -22
asoc: machine hw_params failed
Failed to set SYSCLK: -22
ALSA lib pcm_direct.c:980:(snd1_pFailed to set SYSCLK: -22
cm_direct_initialize_slave) unable to install hw params
ALSA lib pcm_dmix.c:1030:(snd_pcm_dmix_open) unable to initialize slave
aplay: main:660: audio open error: Invalid argument
所以,要用imx-wm8962.c来修改的话,还有点麻烦,不会很容易。
网上找了一个人交流,他用的是imx-wm8960.module,就是编译出来的.o
ifneq ($(wildcard sound/soc/imx/imx-wm8960.c),)
snd-soc-imx-wm8960-objs := imx-wm8960.c
else
snd-soc-imx-wm8960-objs := imx-wm8960.module
endif
我这样修改后,运行导致crash。
register wm8960 I2C driver success!
Unable to handle kernel paging request at virtual address f8f2fe18
pgd = 80004000
[f8f2fe18] *pgd=1bce9811, *pte=00000000, *ppte=00000000
Internal error: Oops: 807 [#1] PREEMPT
Modules linked in:
CPU: 0 Not tainted (3.0.101-2790-gc248ed7 #274)
|