ASoC: Add new Realtek ALC5632 CODEC driver.
PATCH v4 1/1 ASoC: Add new Realtek ALC5632 CODEC driver.
From: Leon Romanovsky <[email protected]>
This driver implements basic functionality, using I²C for the control channel.
---
v4:
* Use dev_info instead dev_err for information messages.
* Use EINVAL for incorrect pll_id.
* Mark cache as needed to sync on resume.
* Use mask for power registers to protect reserved bits.
* Move power management logic from probe to set_bias function.
* Remove references to sound platform device.
v3:
* DAC is now handled by DAPM
* Power down control correct handling.
* Fixed speaker dapm routes.
* Remove unused variables.
* Sync stream names in DAPM and codec dai.
* Use update bits instead write to reg in power depop function.
* Rename Route to AB-D Amp Mux
* Add snd controls to codec driver. Don't register it in probe.
* Add dapm widgets and routes to codec driver. Don't register it.
* Don't force power for spk apm, main i2s. It is described in DAPM.
* Set symmetric_rates flag to prevent different rates for playback and capture.
* Removed commented DEBUG definition.
* Use SOC infrastructure sync cache mechanism.
* Remove non possible IF switch.
* Fix indentation issues
* Convert alc5632 MICBIAS to a supply widget
* Remove codec input parameter
* Remove VERSION define
* Remove unnecessary dev_kfree() and update copyright notice
* Control speaker amplifier with DAPM.
* Let machine driver choose master/slave mode for the codec.
* Clean up. removed dev_dbg.
* Use devm_kzalloc/devm_kzfree for memory allocation/deallocation.
* Fixed stereo headphones playback.
* Set up correct name for Stereo DAC volume item.
v2: Free from checkpatch warnings
v1: Initial code drop
---
--- sound/soc/codecs/Kconfig | 3 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/alc5632.c | 1153 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/alc5632.h | 249 ++++++++++ 4 files changed, 1407 insertions(+), 0 deletions(-) create mode 100644 sound/soc/codecs/alc5632.c create mode 100644 sound/soc/codecs/alc5632.h
sound/soc/codecs/Kconfig +3 -0
@@ -26,6 +26,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_AK4642 if I2C select SND_SOC_AK4671 if I2C select SND_SOC_ALC5623 if I2C + select SND_SOC_ALC5632 if I2C select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC select SND_SOC_CS42L51 if I2C select SND_SOC_CS4270 if I2C
@@ -168,6 +169,8 @@ config SND_SOC_AK4671 config SND_SOC_ALC5623 tristate +config SND_SOC_ALC5632 + tristate config SND_SOC_CQ0093VC tristate
sound/soc/codecs/Makefile +2 -0
@@ -29,6 +29,7 @@ snd-soc-pcm3008-objs := pcm3008.o snd-soc-rt5631-objs := rt5631.o snd-soc-sgtl5000-objs := sgtl5000.o snd-soc-alc5623-objs := alc5623.o +snd-soc-alc5632-objs := alc5632.o snd-soc-sn95031-objs := sn95031.o snd-soc-spdif-objs := spdif_transciever.o snd-soc-ssm2602-objs := ssm2602.o
@@ -113,6 +114,7 @@ obj-$(CONFIG_SND_SOC_AK4641) += snd-soc-ak4641.o obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o obj-$(CONFIG_SND_SOC_AK4671) += snd-soc-ak4671.o obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o +obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o obj-$(CONFIG_SND_SOC_CS42L51) += snd-soc-cs42l51.o obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o
sound/soc/codecs/alc5632.c new file +1153 -0
1,153 lines not on this page · raw message
sound/soc/codecs/alc5632.h new file +249 -0
249 lines not on this page · raw message
Signature · 6 lines
1.7.3.4 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 4 lines · On Sat, Nov 05, 2011 at 12:38:02PM +0200, [email protected] wrote:
From: Leon Romanovsky <[email protected]>
This driver implements basic functionality, using I²C for the control channel.
This is mostly looking good so I've applied it to save on review time but there are a few fairly minor issues which you really should address in follow on patches
sound/soc/codecs/alc5632.c line 815
Quoted 5 lines
sound/soc/codecs/alc5632.c new file +5
-0+static int alc5632_mute (struct snd_soc_dai *dai,int mute) +{ +struct snd_soc_codec *codec = dai->codec; +u16 hp_mute =ALC5632_MISC_HP_DEPOP_MUTE_L \ + |ALC5632_MISC_HP_DEPOP_MUTE_R ;
No need for the \ here.
sound/soc/codecs/alc5632.c line 986
Quoted 6 lines
sound/soc/codecs/alc5632.c new file +6
-0+#define ALC5632_ADC_REC_GAIN_COMP (x) (int)((x - ALC5632_ADC_REC_GAIN_BASE) \ + / ALC5632_ADC_REC_GAIN_STEP) + +#define ALC5632_MIC_BOOST_COMP (x) (int)(x / ALC5632_MIC_BOOST_STEP) + +#define ALC5632_SPK_OUT_VOL_COMP (x) (int)(x / ALC5632_SPK_OUT_VOL_STEP)
These aren't used and should probably be deleted.
Quoted 4 lines
sound/soc/codecs/alc5632.c new file +4
-0+static int alc5632_i2c_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct alc5632_priv *alc5632;
sound/soc/codecs/alc5632.c line 1061
Quoted 10 lines
sound/soc/codecs/alc5632.c new file +10
-0+int ret, vid1, vid2; + + vid1 =i2c_smbus_read_word_data (client,ALC5632_VENDOR_ID1 ); +if (vid1 <0 ) { +dev_err (&client->dev,"failed to read I2C\n" ); +return -EIO ; + }else { +dev_info (&client->dev,"got vid1: %x\n" , vid1); + } + vid1 = ((vid1 &0xff ) <<8 ) | (vid1 >>8 );
Ideally you should convert the driver over to work with the regmap API and make use of the cache code it provides. This is going to be required at some point in the future and would mean that you could use the same register I/O functionality here where you're identifying the device (which is definitely good practice).
I'd also do an initial device reset here to make sure that in the interval between the driver registering and ASoC starting the hardware is in a known good state.
Quoted 10 lines · Mark Brown
Quoted 4 lines · On Sat, Nov 05, 2011 at 12:38:02PM +0200, [email protected] wrote:
From: Leon Romanovsky <[email protected]>
This driver implements basic functionality, using I涎 for the control channel.
This is mostly looking good so I've applied it to save on review time but there are a few fairly minor issues which you really should address in follow on patches
Thanks, for review, I'll send the incremental patches in the near future.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
+static int
alc5632_mute(struct snd_soc_dai *dai, int mute)+{
+ structsnd_soc_codec*codec =dai->codec;
+ u16hp_mute=ALC5632_MISC_HP_DEPOP_MUTE_L\
+ |ALC5632_MISC_HP_DEPOP_MUTE_R;No need for the \ here.
Quoted 8 lines
sound/soc/codecs/alc5632.c line 986
Quoted 6 lines
sound/soc/codecs/alc5632.c new file +6
-0+#define ALC5632_ADC_REC_GAIN_COMP (x) (int)((x - ALC5632_ADC_REC_GAIN_BASE) \ + / ALC5632_ADC_REC_GAIN_STEP) + +#define ALC5632_MIC_BOOST_COMP (x) (int)(x / ALC5632_MIC_BOOST_STEP) + +#define ALC5632_SPK_OUT_VOL_COMP (x) (int)(x / ALC5632_SPK_OUT_VOL_STEP)These aren't used and should probably be deleted.
You are right.
Quoted 13 lines
Quoted 13 lines
sound/soc/codecs/alc5632.c new file +12
-0+static int alc5632_i2c_probe (struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct alc5632_priv *alc5632; + int ret, vid1, vid2; + + vid1 = i2c_smbus_read_word_data(client, ALC5632_VENDOR_ID1); + if (vid1 < 0) { + dev_err(&client->dev, "failed to read I2C\n"); + return -EIO; + } else { + dev_info(&client->dev, "got vid1: %x\n", vid1);
Quoted 8 lines
Quoted 2 lines
+ }
+ vid1 = ((vid1 &0xff) << 8) | (vid1 >> 8);Ideally you should convert the driver over to work with the regmap API and make use of the cache code it provides. This is going to be required at some point in the future and would mean that you could use the same register I/O functionality here where you're identifying the device (which is definitely good practice).
If it possible, I would prefer to wait with this. I'll not be able to test the regmap interface properly because it was implemented for the 3.0 tree, and my development machine doesn't support it yet.
Sure, firstly I'll try to apply your patches on our tree
(http://lwn.net/Articles/451178/)
Quoted 3 lines
Quoted 1 line
I'd also do an initial device reset here to make sure that in the
interval between the driver registering and ASoC starting the hardware is in a known good state.
Ok, thanks.
--
Leon Romanovsky | Independent Linux Consultant
www.leon.nu | [email protected]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 11 lines · Leon Romanovsky
On Thu, Nov 10, 2011 at 14:11, Mark Brown
Quoted 5 lines
Ideally you should convert the driver over to work with the regmap API and make use of the cache code it provides. This is going to be required at some point in the future and would mean that you could use the same register I/O functionality here where you're identifying the device (which is definitely good practice).
If it possible, I would prefer to wait with this. I'll not be able to test the regmap interface properly because it was implemented for the 3.0 tree, and my development machine doesn't support it yet.
As it's an entirely new subsystem it should be really easy to backport if you just copy the code into the older kernel.