Skip to contentSkip to conversation

ASoC: sunxi: DMIC: Add controls for adjusting the mic gains

PATCH Superseded Joao Schim 2 participants 6 messages Apr 22, 2024 – Apr 29, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Joao Schim

author
#0 lore raw

PATCH 1/1 ASoC: sunxi: DMIC: Add controls for adjusting the mic gains

The AllWinner H6 and later SoCs that sport a DMIC block contain a set of registers to control the gain (left + right) of each of the four supported channels.

Add ASoC controls for changing each of the stereo channel gains using alsamixer and alike

---
 sound/soc/sunxi/sun50i-dmic.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
sound/soc/sunxi/sun50i-dmic.c +34 -0
index c76628bc86c6..f8613d8c3462 100644
@@ -14,6 +14,7 @@
 #include <sound/dmaengine_pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
+#include <sound/tlv.h>
 
 #define SUN50I_DMIC_EN_CTL			(0x00)
 	#define SUN50I_DMIC_EN_CTL_GLOBE			BIT(8)
@@ -43,6 +44,17 @@
 	#define SUN50I_DMIC_CH_NUM_N_MASK			GENMASK(2, 0)
 #define SUN50I_DMIC_CNT				(0x2c)
 	#define SUN50I_DMIC_CNT_N				(1 << 0)
+#define SUN50I_DMIC_D0D1_VOL_CTR		(0x30)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0R			(0)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0L			(8)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1R			(16)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1L			(24)
+#define SUN50I_DMIC_D2D3_VOL_CTR                (0x34)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2R                     (0)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2L                     (8)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3R                     (16)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3L                     (24)
+
 #define SUN50I_DMIC_HPF_CTRL			(0x38)
 #define SUN50I_DMIC_VERSION			(0x50)
 
@@ -273,8 +285,30 @@ static const struct of_device_id sun50i_dmic_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, sun50i_dmic_of_match);
 
+static const DECLARE_TLV_DB_SCALE(sun50i_dmic_vol_scale, -12000, 75, 1);
+
+static const struct snd_kcontrol_new sun50i_dmic_controls[] = {
+
+        SOC_DOUBLE_TLV("DMIC Channel 0 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_0L, SUN50I_DMIC_D0D1_VOL_CTR_0R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 1 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_1L, SUN50I_DMIC_D0D1_VOL_CTR_1R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 2 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_2L, SUN50I_DMIC_D2D3_VOL_CTR_2R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 3 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_3L, SUN50I_DMIC_D2D3_VOL_CTR_3R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+
+
+};
+
 static const struct snd_soc_component_driver sun50i_dmic_component = {
 	.name           = "sun50i-dmic",
+	.controls	= sun50i_dmic_controls,
+	.num_controls	= ARRAY_SIZE(sun50i_dmic_controls),
 };
 
 static int sun50i_dmic_runtime_suspend(struct device *dev)
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#1 lore raw

Hi Joao,

Dne ponedeljek, 22. april 2024 ob 17:02:13 GMT +2 je Joao Schim napisal(a):

Quoted 4 lines

The AllWinner H6 and later SoCs that sport a DMIC block contain a set of registers to control the gain (left + right) of each of the four supported channels.

Add ASoC controls for changing each of the stereo channel gains using alsamixer and alike

Add SoB tag.

Quoted 35 lines
---
 sound/soc/sunxi/sun50i-dmic.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
sound/soc/sunxi/sun50i-dmic.c +12 -0
index c76628bc86c6..f8613d8c3462 100644
@@ -14,6 +14,7 @@
 #include <sound/dmaengine_pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
+#include <sound/tlv.h>
 
 #define SUN50I_DMIC_EN_CTL			(0x00)
 	#define SUN50I_DMIC_EN_CTL_GLOBE			BIT(8)
@@ -43,6 +44,17 @@
 	#define SUN50I_DMIC_CH_NUM_N_MASK			GENMASK(2, 0)
 #define SUN50I_DMIC_CNT				(0x2c)
 	#define SUN50I_DMIC_CNT_N				(1 << 0)
+#define SUN50I_DMIC_D0D1_VOL_CTR		(0x30)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0R			(0)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0L			(8)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1R			(16)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1L			(24)
+#define SUN50I_DMIC_D2D3_VOL_CTR                (0x34)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2R                     (0)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2L                     (8)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3R                     (16)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3L                     (24)
+
 #define SUN50I_DMIC_HPF_CTRL			(0x38)
 #define SUN50I_DMIC_VERSION			(0x50)
 

sound/soc/sunxi/sun50i-dmic.c static const struct of_device_id sun50i_dmic_of_match[] = { · line 288

Quoted 4 lines
sound/soc/sunxi/sun50i-dmic.c +1 -0
@@ -273,8 +285,30 @@ static const struct of_device_id sun50i_dmic_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, sun50i_dmic_of_match);
 
+static const DECLARE_TLV_DB_SCALE(sun50i_dmic_vol_scale, -12000, 75, 1);

DECLARE_TLV_DB_SCALE is old name, SNDRV_CTL_TLVD_DECLARE_DB_SCALE should be used instead.

Other than that, it looks fine.

Best regards,
Jernej

Quoted 27 lines
sound/soc/sunxi/sun50i-dmic.c +21 -0
+
+static const struct snd_kcontrol_new sun50i_dmic_controls[] = {
+
+        SOC_DOUBLE_TLV("DMIC Channel 0 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_0L, SUN50I_DMIC_D0D1_VOL_CTR_0R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 1 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_1L, SUN50I_DMIC_D0D1_VOL_CTR_1R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 2 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_2L, SUN50I_DMIC_D2D3_VOL_CTR_2R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 3 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_3L, SUN50I_DMIC_D2D3_VOL_CTR_3R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+
+
+};
+
 static const struct snd_soc_component_driver sun50i_dmic_component = {
 	.name           = "sun50i-dmic",
+	.controls	= sun50i_dmic_controls,
+	.num_controls	= ARRAY_SIZE(sun50i_dmic_controls),
 };
 
 static int sun50i_dmic_runtime_suspend(struct device *dev)
author
#2 lore raw
Quoted 1 line · Jernej Škrabec

Hi Joao,

Hi Jernej,  thanks for your prompt response.

Quoted 7 lines

Dne ponedeljek, 22. april 2024 ob 17:02:13 GMT +2 je Joao Schim napisal(a):

Quoted 4 lines

The AllWinner H6 and later SoCs that sport a DMIC block contain a set of registers to control the gain (left + right) of each of the four supported channels.

Add ASoC controls for changing each of the stereo channel gains using alsamixer and alike

Add SoB tag.

Yeah, i realized that too late. Thanks for bringing that to my attention. I will add it in v1.

Quoted 35 lines
Quoted 35 lines
---
  sound/soc/sunxi/sun50i-dmic.c | 34 ++++++++++++++++++++++++++++++++++
  1 file changed, 34 insertions(+)
sound/soc/sunxi/sun50i-dmic.c +12 -0
index c76628bc86c6..f8613d8c3462 100644
@@ -14,6 +14,7 @@
  #include <sound/dmaengine_pcm.h>
  #include <sound/pcm_params.h>
  #include <sound/soc.h>
+#include <sound/tlv.h>
 
  #define SUN50I_DMIC_EN_CTL			(0x00)
  	#define SUN50I_DMIC_EN_CTL_GLOBE			BIT(8)
@@ -43,6 +44,17 @@
  	#define SUN50I_DMIC_CH_NUM_N_MASK			GENMASK(2, 0)
  #define SUN50I_DMIC_CNT				(0x2c)
  	#define SUN50I_DMIC_CNT_N				(1 << 0)
+#define SUN50I_DMIC_D0D1_VOL_CTR		(0x30)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0R			(0)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0L			(8)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1R			(16)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1L			(24)
+#define SUN50I_DMIC_D2D3_VOL_CTR                (0x34)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2R                     (0)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2L                     (8)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3R                     (16)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3L                     (24)
+
  #define SUN50I_DMIC_HPF_CTRL			(0x38)
  #define SUN50I_DMIC_VERSION			(0x50)
 
Quoted 7 lines

sound/soc/sunxi/sun50i-dmic.c static const struct of_device_id sun50i_dmic_of_match[] = { · line 288

Quoted 5 lines
sound/soc/sunxi/sun50i-dmic.c +1 -0
@@ -273,8 +285,30 @@ static const struct of_device_id sun50i_dmic_of_match[] = {
  };
  MODULE_DEVICE_TABLE(of, sun50i_dmic_of_match);
 
+static const DECLARE_TLV_DB_SCALE(sun50i_dmic_vol_scale, -12000, 75, 1);

DECLARE_TLV_DB_SCALE is old name, SNDRV_CTL_TLVD_DECLARE_DB_SCALE should be used instead.

I can't seem to find that define in HEAD. what code-base are you referring to that i should checkout ?

Quoted 2 lines

Other than that, it looks fine.

Thanks.

Quoted 28 lines

Best regards,
Jernej

Quoted 25 lines
sound/soc/sunxi/sun50i-dmic.c +21 -0
+
+static const struct snd_kcontrol_new sun50i_dmic_controls[] = {
+
+        SOC_DOUBLE_TLV("DMIC Channel 0 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_0L, SUN50I_DMIC_D0D1_VOL_CTR_0R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 1 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_1L, SUN50I_DMIC_D0D1_VOL_CTR_1R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 2 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_2L, SUN50I_DMIC_D2D3_VOL_CTR_2R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 3 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_3L, SUN50I_DMIC_D2D3_VOL_CTR_3R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+
+
+};
+
  static const struct snd_soc_component_driver sun50i_dmic_component = {
  	.name           = "sun50i-dmic",
+	.controls	= sun50i_dmic_controls,
+	.num_controls	= ARRAY_SIZE(sun50i_dmic_controls),
  };
 
Quoted 5 lines

sound/soc/sunxi/sun50i-dmic.c static const struct of_device_id sun50i_dmic_of_match[] = { · line 314

Quoted 2 lines
sound/soc/sunxi/sun50i-dmic.c +0 -0
  static int sun50i_dmic_runtime_suspend(struct device *dev)

Kind regards,

Joao

maintainer
#3 lore raw

Dne četrtek, 25. april 2024 ob 13:03:56 GMT +2 je Joao Schim napisal(a):

Quoted 51 lines · Jernej Škrabec
Quoted 1 line

Hi Joao,

Hi Jernej, thanks for your prompt response.

Quoted 7 lines

Dne ponedeljek, 22. april 2024 ob 17:02:13 GMT +2 je Joao Schim napisal(a):

Quoted 4 lines

The AllWinner H6 and later SoCs that sport a DMIC block contain a set of registers to control the gain (left + right) of each of the four supported channels.

Add ASoC controls for changing each of the stereo channel gains using alsamixer and alike

Add SoB tag.

Yeah, i realized that too late. Thanks for bringing that to my attention. I will add it in v1.

Quoted 39 lines
Quoted 39 lines
---
  sound/soc/sunxi/sun50i-dmic.c | 34 ++++++++++++++++++++++++++++++++++
  1 file changed, 34 insertions(+)
sound/soc/sunxi/sun50i-dmic.c +12 -0
index c76628bc86c6..f8613d8c3462 100644
@@ -14,6 +14,7 @@
  #include <sound/dmaengine_pcm.h>
  #include <sound/pcm_params.h>
  #include <sound/soc.h>
+#include <sound/tlv.h>
 
  #define SUN50I_DMIC_EN_CTL			(0x00)
  	#define SUN50I_DMIC_EN_CTL_GLOBE			BIT(8)
@@ -43,6 +44,17 @@
  	#define SUN50I_DMIC_CH_NUM_N_MASK			GENMASK(2, 0)
  #define SUN50I_DMIC_CNT				(0x2c)
  	#define SUN50I_DMIC_CNT_N				(1 << 0)
+#define SUN50I_DMIC_D0D1_VOL_CTR		(0x30)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0R			(0)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0L			(8)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1R			(16)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1L			(24)
+#define SUN50I_DMIC_D2D3_VOL_CTR                (0x34)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2R                     (0)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2L                     (8)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3R                     (16)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3L                     (24)
+
  #define SUN50I_DMIC_HPF_CTRL			(0x38)
  #define SUN50I_DMIC_VERSION			(0x50)
 
@@ -273,8 +285,30 @@ static const struct of_device_id sun50i_dmic_of_match[] = {
  };
  MODULE_DEVICE_TABLE(of, sun50i_dmic_of_match);
 
Quoted 5 lines
Quoted 3 lines

sound/soc/sunxi/sun50i-dmic.c static const struct of_device_id sun50i_dmic_of_match[] = { · line 288

Quoted 1 line
sound/soc/sunxi/sun50i-dmic.c +1 -0
+static const DECLARE_TLV_DB_SCALE(sun50i_dmic_vol_scale, -12000, 75, 1);

DECLARE_TLV_DB_SCALE is old name, SNDRV_CTL_TLVD_DECLARE_DB_SCALE should be used instead.

I can't seem to find that define in HEAD. what code-base are you referring to that i should checkout ?

Here is define:
https://elixir.bootlin.com/linux/v6.9-rc1/source/include/uapi/sound/tlv.h#L52

However, I'm not sure if this message means DECLARE_TLV_DB_SCALE is deprecated or not:
https://elixir.bootlin.com/linux/v6.9-rc1/source/include/sound/tlv.h#L12

Best regards,
Jernej

Quoted 43 lines
Quoted 2 lines

Other than that, it looks fine.

Thanks.

Quoted 28 lines

Best regards,
Jernej

Quoted 25 lines
sound/soc/sunxi/sun50i-dmic.c +21 -0
+
+static const struct snd_kcontrol_new sun50i_dmic_controls[] = {
+
+        SOC_DOUBLE_TLV("DMIC Channel 0 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_0L, SUN50I_DMIC_D0D1_VOL_CTR_0R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 1 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_1L, SUN50I_DMIC_D0D1_VOL_CTR_1R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 2 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_2L, SUN50I_DMIC_D2D3_VOL_CTR_2R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 3 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_3L, SUN50I_DMIC_D2D3_VOL_CTR_3R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+
+
+};
+
  static const struct snd_soc_component_driver sun50i_dmic_component = {
  	.name           = "sun50i-dmic",
+	.controls	= sun50i_dmic_controls,
+	.num_controls	= ARRAY_SIZE(sun50i_dmic_controls),
  };
 
Quoted 5 lines

sound/soc/sunxi/sun50i-dmic.c static const struct of_device_id sun50i_dmic_of_match[] = { · line 314

Quoted 2 lines
sound/soc/sunxi/sun50i-dmic.c +0 -0
  static int sun50i_dmic_runtime_suspend(struct device *dev)

Kind regards,

Joao

author
#4 lore raw
Quoted 53 lines · Jernej Škrabec

Dne četrtek, 25. april 2024 ob 13:03:56 GMT +2 je Joao Schim napisal(a):

Quoted 52 lines · Jernej Škrabec
Quoted 1 line

Hi Joao,

Hi Jernej, thanks for your prompt response.

Quoted 6 lines

Dne ponedeljek, 22. april 2024 ob 17:02:13 GMT +2 je Joao Schim napisal(a):

Quoted 4 lines

The AllWinner H6 and later SoCs that sport a DMIC block contain a set of registers to control the gain (left + right) of each of the four supported channels.

Add ASoC controls for changing each of the stereo channel gains using alsamixer and alike

Add SoB tag.

Yeah, i realized that too late. Thanks for bringing that to my attention. I will add it in v1.

Quoted 41 lines
Quoted 35 lines
---
   sound/soc/sunxi/sun50i-dmic.c | 34 ++++++++++++++++++++++++++++++++++
   1 file changed, 34 insertions(+)
sound/soc/sunxi/sun50i-dmic.c +12 -0
index c76628bc86c6..f8613d8c3462 100644
@@ -14,6 +14,7 @@
   #include <sound/dmaengine_pcm.h>
   #include <sound/pcm_params.h>
   #include <sound/soc.h>
+#include <sound/tlv.h>
 
   #define SUN50I_DMIC_EN_CTL			(0x00)
   	#define SUN50I_DMIC_EN_CTL_GLOBE			BIT(8)
@@ -43,6 +44,17 @@
   	#define SUN50I_DMIC_CH_NUM_N_MASK			GENMASK(2, 0)
   #define SUN50I_DMIC_CNT				(0x2c)
   	#define SUN50I_DMIC_CNT_N				(1 << 0)
+#define SUN50I_DMIC_D0D1_VOL_CTR		(0x30)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0R			(0)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0L			(8)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1R			(16)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1L			(24)
+#define SUN50I_DMIC_D2D3_VOL_CTR                (0x34)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2R                     (0)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2L                     (8)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3R                     (16)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3L                     (24)
+
   #define SUN50I_DMIC_HPF_CTRL			(0x38)
   #define SUN50I_DMIC_VERSION			(0x50)
 

sound/soc/sunxi/sun50i-dmic.c static const struct of_device_id sun50i_dmic_of_match[] = { · line 288

Quoted 4 lines
sound/soc/sunxi/sun50i-dmic.c +1 -0
@@ -273,8 +285,30 @@ static const struct of_device_id sun50i_dmic_of_match[] = {
   };
   MODULE_DEVICE_TABLE(of, sun50i_dmic_of_match);
 
+static const DECLARE_TLV_DB_SCALE(sun50i_dmic_vol_scale, -12000, 75, 1);

DECLARE_TLV_DB_SCALE is old name, SNDRV_CTL_TLVD_DECLARE_DB_SCALE should be used instead.

Quoted 8 lines
Quoted 2 lines

I can't seem to find that define in HEAD. what code-base are you referring to that i should checkout ?

Here is define:
https://elixir.bootlin.com/linux/v6.9-rc1/source/include/uapi/sound/tlv.h#L52

However, I'm not sure if this message means DECLARE_TLV_DB_SCALE is deprecated or not:
https://elixir.bootlin.com/linux/v6.9-rc1/source/include/sound/tlv.h#L12

Right, apparently i sneaked in another D in the name. That explains i could not find it.

Will send v1 in a few minutes. Thanks.

Kind regards,

Joao

Quoted 46 lines

Best regards,
Jernej

Quoted 40 lines
Quoted 1 line

Other than that, it looks fine.

Thanks.

Quoted 28 lines

Best regards,
Jernej

Quoted 25 lines
sound/soc/sunxi/sun50i-dmic.c +21 -0
+
+static const struct snd_kcontrol_new sun50i_dmic_controls[] = {
+
+        SOC_DOUBLE_TLV("DMIC Channel 0 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_0L, SUN50I_DMIC_D0D1_VOL_CTR_0R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 1 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_1L, SUN50I_DMIC_D0D1_VOL_CTR_1R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 2 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_2L, SUN50I_DMIC_D2D3_VOL_CTR_2R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 3 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_3L, SUN50I_DMIC_D2D3_VOL_CTR_3R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+
+
+};
+
   static const struct snd_soc_component_driver sun50i_dmic_component = {
   	.name           = "sun50i-dmic",
+	.controls	= sun50i_dmic_controls,
+	.num_controls	= ARRAY_SIZE(sun50i_dmic_controls),
   };
 
Quoted 4 lines

sound/soc/sunxi/sun50i-dmic.c static const struct of_device_id sun50i_dmic_of_match[] = { · line 314

Quoted 2 lines
sound/soc/sunxi/sun50i-dmic.c +0 -0
   static int sun50i_dmic_runtime_suspend(struct device *dev)

Kind regards,

Joao

maintainer
#5 lore raw

Dne ponedeljek, 29. april 2024 ob 20:39:24 GMT +2 je Joao Schim napisal(a):

Quoted 59 lines · Jernej Škrabec
Quoted 58 lines

Dne četrtek, 25. april 2024 ob 13:03:56 GMT +2 je Joao Schim napisal(a):

Quoted 49 lines · Jernej Škrabec
Quoted 1 line

Hi Joao,

Hi Jernej, thanks for your prompt response.

Quoted 6 lines

Dne ponedeljek, 22. april 2024 ob 17:02:13 GMT +2 je Joao Schim napisal(a):

Quoted 4 lines

The AllWinner H6 and later SoCs that sport a DMIC block contain a set of registers to control the gain (left + right) of each of the four supported channels.

Add ASoC controls for changing each of the stereo channel gains using alsamixer and alike

Add SoB tag.

Yeah, i realized that too late. Thanks for bringing that to my attention. I will add it in v1.

Quoted 38 lines
Quoted 38 lines
---
   sound/soc/sunxi/sun50i-dmic.c | 34 ++++++++++++++++++++++++++++++++++
   1 file changed, 34 insertions(+)
sound/soc/sunxi/sun50i-dmic.c +12 -0
index c76628bc86c6..f8613d8c3462 100644
@@ -14,6 +14,7 @@
   #include <sound/dmaengine_pcm.h>
   #include <sound/pcm_params.h>
   #include <sound/soc.h>
+#include <sound/tlv.h>
 
   #define SUN50I_DMIC_EN_CTL			(0x00)
   	#define SUN50I_DMIC_EN_CTL_GLOBE			BIT(8)
@@ -43,6 +44,17 @@
   	#define SUN50I_DMIC_CH_NUM_N_MASK			GENMASK(2, 0)
   #define SUN50I_DMIC_CNT				(0x2c)
   	#define SUN50I_DMIC_CNT_N				(1 << 0)
+#define SUN50I_DMIC_D0D1_VOL_CTR		(0x30)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0R			(0)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_0L			(8)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1R			(16)
+	#define SUN50I_DMIC_D0D1_VOL_CTR_1L			(24)
+#define SUN50I_DMIC_D2D3_VOL_CTR                (0x34)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2R                     (0)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_2L                     (8)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3R                     (16)
+        #define SUN50I_DMIC_D2D3_VOL_CTR_3L                     (24)
+
   #define SUN50I_DMIC_HPF_CTRL			(0x38)
   #define SUN50I_DMIC_VERSION			(0x50)
 
@@ -273,8 +285,30 @@ static const struct of_device_id sun50i_dmic_of_match[] = {
   };
   MODULE_DEVICE_TABLE(of, sun50i_dmic_of_match);
 
Quoted 5 lines
Quoted 3 lines

sound/soc/sunxi/sun50i-dmic.c static const struct of_device_id sun50i_dmic_of_match[] = { · line 288

Quoted 1 line
sound/soc/sunxi/sun50i-dmic.c +1 -0
+static const DECLARE_TLV_DB_SCALE(sun50i_dmic_vol_scale, -12000, 75, 1);

DECLARE_TLV_DB_SCALE is old name, SNDRV_CTL_TLVD_DECLARE_DB_SCALE should be used instead.

I can't seem to find that define in HEAD. what code-base are you referring to that i should checkout ?

Here is define:
https://elixir.bootlin.com/linux/v6.9-rc1/source/include/uapi/sound/tlv.h#L52

Quoted 8 lines
Quoted 3 lines

However, I'm not sure if this message means DECLARE_TLV_DB_SCALE is deprecated or not:
https://elixir.bootlin.com/linux/v6.9-rc1/source/include/sound/tlv.h#L12

Right, apparently i sneaked in another D in the name. That explains i could not find it.

Will send v1 in a few minutes. Thanks.

that would be v2?

v1 is first submission and it's usually not marked as such.

Best regards,
Jernej

Quoted 52 lines

Kind regards,

Joao

Quoted 46 lines

Best regards,
Jernej

Quoted 40 lines
Quoted 1 line

Other than that, it looks fine.

Thanks.

Quoted 28 lines

Best regards,
Jernej

Quoted 25 lines
sound/soc/sunxi/sun50i-dmic.c +21 -0
+
+static const struct snd_kcontrol_new sun50i_dmic_controls[] = {
+
+        SOC_DOUBLE_TLV("DMIC Channel 0 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_0L, SUN50I_DMIC_D0D1_VOL_CTR_0R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 1 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
+                       SUN50I_DMIC_D0D1_VOL_CTR_1L, SUN50I_DMIC_D0D1_VOL_CTR_1R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 2 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_2L, SUN50I_DMIC_D2D3_VOL_CTR_2R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+        SOC_DOUBLE_TLV("DMIC Channel 3 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
+                       SUN50I_DMIC_D2D3_VOL_CTR_3L, SUN50I_DMIC_D2D3_VOL_CTR_3R,
+                       0xFF, 0, sun50i_dmic_vol_scale),
+
+
+};
+
   static const struct snd_soc_component_driver sun50i_dmic_component = {
   	.name           = "sun50i-dmic",
+	.controls	= sun50i_dmic_controls,
+	.num_controls	= ARRAY_SIZE(sun50i_dmic_controls),
   };
 
Quoted 4 lines

sound/soc/sunxi/sun50i-dmic.c static const struct of_device_id sun50i_dmic_of_match[] = { · line 314

Quoted 2 lines
sound/soc/sunxi/sun50i-dmic.c +0 -0
   static int sun50i_dmic_runtime_suspend(struct device *dev)

Kind regards,

Joao