ASoC: rt5677: Support DSP function for VAD application
Subsystems (3)
Oder Chiou
maintainerPATCH v2 1/1 ASoC: rt5677: Support DSP function for VAD application
The ALC5677 has a programmable DSP, and there is a SPI that is dadicated for DSP firmware loading. Therefore, the patch includes a SPI driver for writing the DSP firmware. The VAD(Voice Activaty Detection) has be implemented and use the DSP to recognize the key phase.
--- sound/soc/codecs/Makefile | 2 +- sound/soc/codecs/rt5677-spi.c | 129 +++++++++++++++++++ sound/soc/codecs/rt5677-spi.h | 21 +++ sound/soc/codecs/rt5677.c | 288 +++++++++++++++++++++++++++++++++++++++++- sound/soc/codecs/rt5677.h | 6 + 5 files changed, 441 insertions(+), 5 deletions(-) create mode 100644 sound/soc/codecs/rt5677-spi.c create mode 100644 sound/soc/codecs/rt5677-spi.h
sound/soc/codecs/Makefile +1 -1
@@ -79,7 +79,7 @@ snd-soc-rt5640-objs := rt5640.o snd-soc-rt5645-objs := rt5645.o snd-soc-rt5651-objs := rt5651.o snd-soc-rt5670-objs := rt5670.o -snd-soc-rt5677-objs := rt5677.o +snd-soc-rt5677-objs := rt5677.o rt5677-spi.o snd-soc-sgtl5000-objs := sgtl5000.o snd-soc-alc5623-objs := alc5623.o snd-soc-alc5632-objs := alc5632.o
sound/soc/codecs/rt5677-spi.c new file +129 -0
129 lines not on this page · raw message
sound/soc/codecs/rt5677-spi.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* rt5677-spi.h -- RT5677 ALSA SoC audio codec driver +* +* Copyright 2013 Realtek Semiconductor Corp. +* Author: Oder Chiou <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __RT5671_SPI_H__ +#define __RT5671_SPI_H__ + +#define RT5677_SPI_BUF_LEN 240 +#define RT5677_SPI_CMD_BURST_WRITE 0x05 + +int rt5677_spi_write (u8 *txbuf,size_t len); +int rt5677_spi_burst_write (u32 addr,const struct firmware *fw); + +#endif /* __RT5677_SPI_H__ */
sound/soc/codecs/rt5677.c +284 -4
348 lines not on this page · raw message
sound/soc/codecs/rt5677.h +6 -0
@@ -1506,6 +1506,9 @@#define RT5677_GPIO5_FUNC_GPIO (0x0 << 9)#define RT5677_GPIO5_FUNC_DMIC (0x1 << 9) +#define RT5677_FIRMWARE1 "rt5677_dsp_fw1.bin" +#define RT5677_FIRMWARE2 "rt5677_dsp_fw2.bin" +/* System Clock Source */ enum {RT5677_SCLK_S_MCLK ,
@@ -1545,6 +1548,8 @@ struct rt5677_priv {struct snd_soc_codec *codec;struct rt5677_platform_data pdata;struct regmap *regmap; +const struct firmware *fw1, *fw2; +struct mutex dsp_cmd_lock;int sysclk;int sysclk_src;
@@ -1558,6 +1563,7 @@ struct rt5677_priv {#ifdef CONFIG_GPIOLIB struct gpio_chip gpio_chip;#endif + bool dsp_vad_en; };#endif /* __RT5677_H__ */
Signature · 1 line
1.8.1.1.439.g50a6b54
Quoted 4 lines · Oder Chiou
The ALC5677 has a programmable DSP, and there is a SPI that is dadicated for DSP firmware loading. Therefore, the patch includes a SPI driver for writing the DSP firmware. The VAD(Voice Activaty Detection) has be implemented and use the DSP to recognize the key phase.
Applied, thanks. One small thing which I fixed up:
sound/soc/codecs/rt5677-spi.c line 125
Quoted 9 lines
sound/soc/codecs/rt5677-spi.c new file +9
-0+static struct spi_driver rt5677_spi_driver = { + .driver = { + .name ="rt5677_spidev" , + .bus = &spi_bus_type, + .owner =THIS_MODULE , + }, + .probe = rt5677_spi_probe, +}; +module_spi_driver (rt5677_spi_driver);
It is better form to remove the _spidev from the name. I fixed this, the indentation and the redundant .bus initialization.
We really should do something better to tie the two devices together though - but I'm not quite seeing the elegant thing. I'm wondering if the I2C driver should defer probe until the SPI driver is there.
Hi
Quoted 6 lines · Oder Chiou
The ALC5677 has a programmable DSP, and there is a SPI that is dadicated for DSP firmware loading. Therefore, the patch includes a SPI driver for writing the DSP firmware. The VAD(Voice Activaty Detection) has be implemented and use the DSP to recognize the key phase.
Signed-off-by Oder Chiou <[email protected]>
Quoted 9 lines
--- sound/soc/codecs/Makefile | 2 +- sound/soc/codecs/rt5677-spi.c | 129 +++++++++++++++++++ sound/soc/codecs/rt5677-spi.h | 21 +++ sound/soc/codecs/rt5677.c | 288 +++++++++++++++++++++++++++++++++++++++++- sound/soc/codecs/rt5677.h | 6 + 5 files changed, 441 insertions(+), 5 deletions(-) create mode 100644 sound/soc/codecs/rt5677-spi.c create mode 100644 sound/soc/codecs/rt5677-spi.h
I am trying to compile rt5677 topic branch from Mark's repo and I get following linking problem
LD [M] sound/soc/codecs/snd-soc-rt5670.o
LD [M] sound/soc/codecs/snd-soc-rt5677.osound/soc/codecs/rt5677-spi.o: In function `init_module':
rt5677-spi.c:(.init.text+0x0): multiple definition of init_module' sound/soc/codecs/rt5677.o:rt5677.c:(.init.text+0x0): first defined here sound/soc/codecs/rt5677-spi.o: In function cleanup_module':
rt5677-spi.c:(.exit.text+0x0): multiple definition of `cleanup_module' sound/soc/codecs/rt5677.o:rt5677.c:(.exit.text+0x0): first defined here make[3]: *** [sound/soc/codecs/snd-soc-rt5677.o] Error 1 make[2]: *** [sound/soc/codecs] Error 2
make[1]: *** [sound/soc] Error 2
make[1]: *** Waiting for unfinished jobs....
I use CONFIG_SND_SOC_ALL_CODEC.