Skip to contentSkip to conversation

ASoC: rt5645: Add codec driver

PATCH In review Oder Chiou 2 participants 6 messages Apr 28, 2014 – May 8, 2014

Subsystems (3)
lore
Share & tools
lore

Oder Chiou

author maintainer
#0 lore raw

PATCH v2 1/1 ASoC: rt5645: Add codec driver

This patch adds the Realtek ALC5645 codec driver. It is the base version that because the jack detect function is not implemented to it, the headphone and AMIC1 are not workable. We will fill up the further functions later.

---
 include/sound/rt5645.h    |   25 +
 sound/soc/codecs/Kconfig  |    4 +
 sound/soc/codecs/Makefile |    2 +
 sound/soc/codecs/rt5645.c | 2476 +++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt5645.h | 2188 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 4695 insertions(+)
 create mode 100644 include/sound/rt5645.h
 create mode 100644 sound/soc/codecs/rt5645.c
 create mode 100644 sound/soc/codecs/rt5645.h
include/sound/rt5645.h new file +25 -0
new file mode 100644
index 0000000..1de744c
@@ -0,0 +1,25 @@
+/*
+ * linux/sound/rt5645.h -- Platform data for RT5645
+ *
+ * Copyright 2013 Realtek Microelectronics
+ *
+ * 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 __LINUX_SND_RT5645_H
+#define __LINUX_SND_RT5645_H
+
+struct rt5645_platform_data {
+	/* IN2 can optionally be differential */
+	bool in2_diff;
+
+	bool dmic_en;
+	unsigned int dmic1_data_pin;
+	/* 0 = IN2N; 1 = GPIO5; 2 = GPIO11 */
+	unsigned int dmic2_data_pin;
+	/* 0 = IN2P; 1 = GPIO6; 2 = GPIO10; 3 = GPIO12 */
+};
+
+#endif
sound/soc/codecs/Kconfig +4 -0
index 5e0a4e2..f6ce2fe 100644
@@ -71,6 +71,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_PCM512x_SPI if SPI_MASTER
 	select SND_SOC_RT5631 if I2C
 	select SND_SOC_RT5640 if I2C
+	select SND_SOC_RT5645 if I2C
 	select SND_SOC_RT5651 if I2C
 	select SND_SOC_SGTL5000 if I2C
 	select SND_SOC_SI476X if MFD_SI476X_CORE
@@ -402,6 +403,9 @@ config SND_SOC_RT5631
 config SND_SOC_RT5640
 	tristate
 
+config SND_SOC_RT5645
+        tristate
+
 config SND_SOC_RT5651
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 8d1930d..3dd8c52 100644
@@ -61,6 +61,7 @@ snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o
 snd-soc-pcm512x-spi-objs := pcm512x-spi.o
 snd-soc-rt5631-objs := rt5631.o
 snd-soc-rt5640-objs := rt5640.o
+snd-soc-rt5645-objs := rt5645.o
 snd-soc-rt5651-objs := rt5651.o
 snd-soc-sgtl5000-objs := sgtl5000.o
 snd-soc-alc5623-objs := alc5623.o
@@ -215,6 +216,7 @@ obj-$(CONFIG_SND_SOC_PCM512x_I2C)	+= snd-soc-pcm512x-i2c.o
 obj-$(CONFIG_SND_SOC_PCM512x_SPI)	+= snd-soc-pcm512x-spi.o
 obj-$(CONFIG_SND_SOC_RT5631)	+= snd-soc-rt5631.o
 obj-$(CONFIG_SND_SOC_RT5640)	+= snd-soc-rt5640.o
+obj-$(CONFIG_SND_SOC_RT5645)	+= snd-soc-rt5645.o
 obj-$(CONFIG_SND_SOC_RT5651)	+= snd-soc-rt5651.o
 obj-$(CONFIG_SND_SOC_SGTL5000)  += snd-soc-sgtl5000.o
 obj-$(CONFIG_SND_SOC_SIGMADSP)	+= snd-soc-sigmadsp.o
sound/soc/codecs/rt5645.c new file +2476 -0

2,476 lines not on this page · raw message

sound/soc/codecs/rt5645.h new file +2188 -0

469 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.8.1.1.439.g50a6b54

Part of the diff is not shown here. View the raw message.

maintainer
#1 lore raw
Quoted 4 lines · Oder Chiou

This patch adds the Realtek ALC5645 codec driver. It is the base version that because the jack detect function is not implemented to it, the headphone and AMIC1 are not workable. We will fill up the further functions later.

Applied, thanks. Like I previously said it really does look like there is a lot of opportunity to share code here with the other similar drivers, please look into doing something like the arizona drivers. Also...

sound/soc/codecs/rt5645.c line 497

Quoted 3 lines
sound/soc/codecs/rt5645.c new file +3 -0
+	/* I2S2 function select */
+	SOC_SINGLE("I2S2 Func Switch", RT5645_GPIO_CTRL1, RT5645_I2S2_SEL_SFT,
+		1, 1),

What functions is this switching?

sound/soc/codecs/rt5645.c line 508

Quoted 10 lines
sound/soc/codecs/rt5645.c new file +10 -0
+	/* TDM */
+	SOC_ENUM("TDM Adc Slot0 1 Data", rt5645_tdm_adc_slot0_1_enum),
+	SOC_ENUM("TDM Adc Slot2 3 Data", rt5645_tdm_adc_slot2_3_enum),
+	SOC_ENUM("TDM Adc Slot4 5 Data", rt5645_tdm_adc_slot4_5_enum),
+	SOC_ENUM("TDM Adc Slot6 7 Data", rt5645_tdm_adc_slot6_7_enum),
+	SOC_ENUM("TDM IF1 ADC DATA Sel", rt5645_tdm_adc_sel_enum),
+	SOC_SINGLE("TDM IF1_DAC1_L Sel", RT5645_TDM_CTRL_3, 12, 7, 0),
+	SOC_SINGLE("TDM IF1_DAC1_R Sel", RT5645_TDM_CTRL_3, 8, 7, 0),
+	SOC_SINGLE("TDM IF1_DAC2_L Sel", RT5645_TDM_CTRL_3, 4, 7, 0),
+	SOC_SINGLE("TDM IF1_DAC2_R Sel", RT5645_TDM_CTRL_3, 0, 7, 0),

These look like they should be part of DAPM, they're about routing data as far as I can tell.

author maintainer
#2 lore raw
Quoted 6 lines

sound/soc/codecs/rt5645.c line 497

Quoted 3 lines
sound/soc/codecs/rt5645.c new file +3 -0
+	/* I2S2 function select */
+	SOC_SINGLE("I2S2 Func Switch", RT5645_GPIO_CTRL1, RT5645_I2S2_SEL_SFT,
+		1, 1),

What functions is this switching?

It is the pin share switch. The I2S data pins are the pin share to GPIO3/4/5/6. If we want to use the GPIO3/4/5/6, we need to set it. We will modify it using the platform data to set it.

Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/rt5645.c new file +5 -0
+	/* TDM */
+	SOC_ENUM("TDM Adc Slot0 1 Data", rt5645_tdm_adc_slot0_1_enum),
+	SOC_ENUM("TDM Adc Slot2 3 Data", rt5645_tdm_adc_slot2_3_enum),
+	SOC_ENUM("TDM Adc Slot4 5 Data", rt5645_tdm_adc_slot4_5_enum),
+	SOC_ENUM("TDM Adc Slot6 7 Data", rt5645_tdm_adc_slot6_7_enum),
Quoted 9 lines

sound/soc/codecs/rt5645.c line 508

Quoted 5 lines
sound/soc/codecs/rt5645.c new file +5 -0
+	SOC_ENUM("TDM IF1 ADC DATA Sel", rt5645_tdm_adc_sel_enum),
+	SOC_SINGLE("TDM IF1_DAC1_L Sel", RT5645_TDM_CTRL_3, 12, 7, 0),
+	SOC_SINGLE("TDM IF1_DAC1_R Sel", RT5645_TDM_CTRL_3, 8, 7, 0),
+	SOC_SINGLE("TDM IF1_DAC2_L Sel", RT5645_TDM_CTRL_3, 4, 7, 0),
+	SOC_SINGLE("TDM IF1_DAC2_R Sel", RT5645_TDM_CTRL_3, 0, 7, 0),

These look like they should be part of DAPM, they're about routing data as far as I can tell.

These are the data related controls with TDM function, not related the routing path. For instance, it likes the L and R channel data swap, or copy function.

maintainer
#3 lore raw
Quoted 9 lines · Oder Chiou
Quoted 5 lines

sound/soc/codecs/rt5645.c line 497

Quoted 3 lines
sound/soc/codecs/rt5645.c new file +3 -0
+	/* I2S2 function select */
+	SOC_SINGLE("I2S2 Func Switch", RT5645_GPIO_CTRL1, RT5645_I2S2_SEL_SFT,
+		1, 1),

What functions is this switching?

It is the pin share switch. The I2S data pins are the pin share to GPIO3/4/5/6. If we want to use the GPIO3/4/5/6, we need to set it. We will modify it using the platform data to set it.

Yes, please - this shouldn't be visible at runtime.

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/rt5645.c new file +5 -0
+	/* TDM */
+	SOC_ENUM("TDM Adc Slot0 1 Data", rt5645_tdm_adc_slot0_1_enum),
+	SOC_ENUM("TDM Adc Slot2 3 Data", rt5645_tdm_adc_slot2_3_enum),
+	SOC_ENUM("TDM Adc Slot4 5 Data", rt5645_tdm_adc_slot4_5_enum),
+	SOC_ENUM("TDM Adc Slot6 7 Data", rt5645_tdm_adc_slot6_7_enum),
Quoted 8 lines

sound/soc/codecs/rt5645.c line 508

Quoted 5 lines
sound/soc/codecs/rt5645.c new file +5 -0
+	SOC_ENUM("TDM IF1 ADC DATA Sel", rt5645_tdm_adc_sel_enum),
+	SOC_SINGLE("TDM IF1_DAC1_L Sel", RT5645_TDM_CTRL_3, 12, 7, 0),
+	SOC_SINGLE("TDM IF1_DAC1_R Sel", RT5645_TDM_CTRL_3, 8, 7, 0),
+	SOC_SINGLE("TDM IF1_DAC2_L Sel", RT5645_TDM_CTRL_3, 4, 7, 0),
+	SOC_SINGLE("TDM IF1_DAC2_R Sel", RT5645_TDM_CTRL_3, 0, 7, 0),

These look like they should be part of DAPM, they're about routing data as far as I can tell.

Quoted 2 lines

These are the data related controls with TDM function, not related the routing path. For instance, it likes the L and R channel data swap, or copy function.

These are very much routing controls - the routing operates at a mono level. Doing a left/right swap or stereo duplication of a mono control is a routing thing.

author maintainer
#4 lore raw
In reply to Mark Brown
Quoted 4 lines

Applied, thanks. Like I previously said it really does look like there is a lot of opportunity to share code here with the other similar drivers, please look into doing something like the arizona drivers. Also...

Excuse me. Why can't I pull the latest code which included the rt5645?

maintainer
#5 lore raw
Quoted 6 lines · Oder
Quoted 4 lines

Applied, thanks. Like I previously said it really does look like there is a lot of opportunity to share code here with the other similar drivers, please look into doing something like the arizona drivers. Also...

Excuse me. Why can't I pull the latest code which included the rt5645?

-next.