移植内核的声卡驱动。原因没有声卡驱动,WM9713声卡驱动移植(原来的内核有UDA1341声卡驱动,我们再次基础上直接修改)
1、直接复制内核得到三个文件:s3c2416_wm9713.c , wm9713.c , s3c2416_ac97.c.
linux-3.1\sound\soc\codecs\Wm9713.c---->wm9713.c;
linux-3.1\sound\soc\samsung\Smdk_wm9713.c---->s3c2416_wm9713.c;
linux-3.1\sound\soc\samsung\Ac97.c------------>s3c2416_ac97.c.
2、使得内核支持那三个文件:
在linux-3.1\sound\soc\samsung\Makefile添加:
snd-soc-s3c2416-wm9713-objs := s3c2416_wm9713.o
obj-$(CONFIG_SND_SOC_SAMSUNG_SMDK_WM9713) += snd-soc-s3c2416-wm9713.o
snd-soc-s3c2416-ac97-objs := s3c2416_ac97.o
obj-$(CONFIG_SND_SAMSUNG_AC97) += snd-soc-s3c2416-ac97.o
在linux-3.1\sound\soc\codec\Makefile添加:
snd-soc-wm9713-objs := wm9713.o
obj-$(CONFIG_SND_SOC_WM9713)+= snd-soc-wm9713.o
在linux-3.1/sound/soc/samsung/kconfig 配上WM9713configSND_SOC_SAMSUNG_SMDK_WM9713tristate "SoC AC97 Audio support for s3c2416 with WM9713"## depends on SND_SOC_SAMSUNG && (MACH_SMDK6410 || MACH_SMDKC100 || MACH_SMDKV210 || ##MACH_SMDKC110 || MACH_SMDKV310 || MACH_SMDKC210) #屏蔽掉depends on SND_SOC_SAMSUNG && ARCH_S3C24XX ##add by ljfselectSND_SOC_WM9713selectSND_SAMSUNG_AC97helpSat Y if you want to add support for SoC audio on the SMDK.这样在内核中“make menuconfig”里面就可以看到"SoC AC97 Audio support for s3c2416 with WM9713",并选中他。接下来我们要在内核中加入这个平台驱动设备:
在“arch/arm/mach-s3c2416/”的mach-tq2416.c中添加:
添加头文件
#include //add by ljf
#include //add by ljf
#include //add by ljf
//add by ljf/** AC97*///at plat-s3c24xx/devs.cstatic int s3c2416_ac97_cfg_gpio(struct platform_device *pdev){return s3c_gpio_cfgpin_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(3));//硬件是使用GPE0~4,S3C_GPIO_SFN(3)表示使用第三功能为AC接口static struct resource s3c_ac97_resource[] = {[0] = {.start = S3C2440_PA_AC97,.end = S3C2440_PA_AC97 + S3C2440_SZ_AC97 -1,.flags = IORESOURCE_MEM,},[1] = {.start = IRQ_S3C244x_AC97,.end = IRQ_S3C244x_AC97,.flags = IORESOURCE_IRQ,},[2] = {.name = "PCM out",.start = DMACH_PCM_OUT,.end = DMACH_PCM_OUT,.flags = IORESOURCE_DMA,},[3] = {.name = "PCM in",.start = DMACH_PCM_IN,.end = DMACH_PCM_IN,.flags = IORESOURCE_DMA,},[4] = {.name = "Mic in",.start = DMACH_MIC_IN,.end = DMACH_MIC_IN,.flags = IORESOURCE_DMA,},};static struct s3c_audio_pdata s3c_ac97_pdata = {.cfg_gpio = s3c2416_ac97_cfg_gpio,};static u64 s3c_device_audio_dmamask = DMA_BIT_MASK(32);//0xffffffffUL;//will changestruct platform_device s3c_device_ac97 = {.name = "samsung-ac97",//.id = -1,.num_resources = ARRAY_SIZE(s3c_ac97_resource),.resource = s3c_ac97_resource,.dev = {.platform_data = &s3c_ac97_pdata,.dma_mask = &s3c_device_audio_dmamask,.coherent_dma_mask = DMA_BIT_MASK(32)//;0xffffffffUL//will change}};//add by ljf然后在“struct platform_device *tq2416_devices[] __initdata”中加入//add by ljf#ifdef CONFIG_SND_SOC_SAMSUNG_SMDK_WM9713&s3c_device_ac97,&samsung_asoc_dma,#endif//add by ljf然后编译、烧写。内核打印信息有asoc: wm9713-hifi samsung-ac97 mapping okALSA device list:
#0: SMDK WM9713
其实到这边,你去播放音乐时还是没声音。
原因:由于在ac97初始化的时候,没有设置wm9713相关为喇叭输出功能。解决:在\sound\soc\samsung\s3c2416_ac97.cstatic struct snd_soc_dai_ops s3c_ac97_dai_ops结构体添加:.prepare = earphone_out,(初始化函数)实现该函数(写在s3c_ac97_dai_ops结构体上面就行了):int earphone_out(struct snd_pcm_substream *substream,struct snd_soc_dai *dai){struct snd_ac97 *ac97;ac97 = 0;s3c_ac97_write(ac97,0x26,0x0);s3c_ac97_write(ac97, 0x0c, 0x0808);s3c_ac97_write(ac97,0x3c, 0xf803);s3c_ac97_write(ac97,0x3e,0xb990);if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {//s3c6400_ac97_write(0,0x02, 0x8080);s3c_ac97_write(ac97,0x02, 0x0404);s3c_ac97_write(ac97, 0x04, 0x0606);//s3c6400_ac97_write(0,0x1c, 0x00aa);s3c_ac97_write(ac97,0x1c, 0x12aa);}else{s3c_ac97_write(ac97, 0x12, 0x0f0f);#ifdef CONFIG_SOUND_WM9713_INPUT_STREAM_MICs3c_ac97_write(ac97,0x5c,0x2);s3c_ac97_write(ac97,0x10,0x68);s3c_ac97_write(ac97,0x14,0xfe00);#else /* Input Stream is LINE-IN */s3c_ac97_write(ac97, 0x14, 0xd612);#endif}return 0;}
到这边声卡就移植结束了。
再次编译,烧写。
再次测试一下:
cat /dev/urandom > /dev/dsp
可以听到“莎莎”的声音,说明移植成功。