Skip to content

Commit 9a8cadd

Browse files
Schimsalabimbroonie
authored andcommitted
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 Signed-off-by: Joao Schim <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 4a1baee commit 9a8cadd

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

sound/soc/sunxi/sun50i-dmic.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <sound/dmaengine_pcm.h>
1515
#include <sound/pcm_params.h>
1616
#include <sound/soc.h>
17+
#include <sound/tlv.h>
1718

1819
#define SUN50I_DMIC_EN_CTL (0x00)
1920
#define SUN50I_DMIC_EN_CTL_GLOBE BIT(8)
@@ -43,6 +44,17 @@
4344
#define SUN50I_DMIC_CH_NUM_N_MASK GENMASK(2, 0)
4445
#define SUN50I_DMIC_CNT (0x2c)
4546
#define SUN50I_DMIC_CNT_N (1 << 0)
47+
#define SUN50I_DMIC_D0D1_VOL_CTR (0x30)
48+
#define SUN50I_DMIC_D0D1_VOL_CTR_0R (0)
49+
#define SUN50I_DMIC_D0D1_VOL_CTR_0L (8)
50+
#define SUN50I_DMIC_D0D1_VOL_CTR_1R (16)
51+
#define SUN50I_DMIC_D0D1_VOL_CTR_1L (24)
52+
#define SUN50I_DMIC_D2D3_VOL_CTR (0x34)
53+
#define SUN50I_DMIC_D2D3_VOL_CTR_2R (0)
54+
#define SUN50I_DMIC_D2D3_VOL_CTR_2L (8)
55+
#define SUN50I_DMIC_D2D3_VOL_CTR_3R (16)
56+
#define SUN50I_DMIC_D2D3_VOL_CTR_3L (24)
57+
4658
#define SUN50I_DMIC_HPF_CTRL (0x38)
4759
#define SUN50I_DMIC_VERSION (0x50)
4860

@@ -273,8 +285,30 @@ static const struct of_device_id sun50i_dmic_of_match[] = {
273285
};
274286
MODULE_DEVICE_TABLE(of, sun50i_dmic_of_match);
275287

288+
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(sun50i_dmic_vol_scale, -12000, 75, 1);
289+
290+
static const struct snd_kcontrol_new sun50i_dmic_controls[] = {
291+
292+
SOC_DOUBLE_TLV("DMIC Channel 0 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
293+
SUN50I_DMIC_D0D1_VOL_CTR_0L, SUN50I_DMIC_D0D1_VOL_CTR_0R,
294+
0xFF, 0, sun50i_dmic_vol_scale),
295+
SOC_DOUBLE_TLV("DMIC Channel 1 Capture Volume", SUN50I_DMIC_D0D1_VOL_CTR,
296+
SUN50I_DMIC_D0D1_VOL_CTR_1L, SUN50I_DMIC_D0D1_VOL_CTR_1R,
297+
0xFF, 0, sun50i_dmic_vol_scale),
298+
SOC_DOUBLE_TLV("DMIC Channel 2 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
299+
SUN50I_DMIC_D2D3_VOL_CTR_2L, SUN50I_DMIC_D2D3_VOL_CTR_2R,
300+
0xFF, 0, sun50i_dmic_vol_scale),
301+
SOC_DOUBLE_TLV("DMIC Channel 3 Capture Volume", SUN50I_DMIC_D2D3_VOL_CTR,
302+
SUN50I_DMIC_D2D3_VOL_CTR_3L, SUN50I_DMIC_D2D3_VOL_CTR_3R,
303+
0xFF, 0, sun50i_dmic_vol_scale),
304+
305+
306+
};
307+
276308
static const struct snd_soc_component_driver sun50i_dmic_component = {
277309
.name = "sun50i-dmic",
310+
.controls = sun50i_dmic_controls,
311+
.num_controls = ARRAY_SIZE(sun50i_dmic_controls),
278312
};
279313

280314
static int sun50i_dmic_runtime_suspend(struct device *dev)

0 commit comments

Comments
 (0)