|
14 | 14 | #include <sound/dmaengine_pcm.h>
|
15 | 15 | #include <sound/pcm_params.h>
|
16 | 16 | #include <sound/soc.h>
|
| 17 | +#include <sound/tlv.h> |
17 | 18 |
|
18 | 19 | #define SUN50I_DMIC_EN_CTL (0x00)
|
19 | 20 | #define SUN50I_DMIC_EN_CTL_GLOBE BIT(8)
|
|
43 | 44 | #define SUN50I_DMIC_CH_NUM_N_MASK GENMASK(2, 0)
|
44 | 45 | #define SUN50I_DMIC_CNT (0x2c)
|
45 | 46 | #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 | + |
46 | 58 | #define SUN50I_DMIC_HPF_CTRL (0x38)
|
47 | 59 | #define SUN50I_DMIC_VERSION (0x50)
|
48 | 60 |
|
@@ -273,8 +285,30 @@ static const struct of_device_id sun50i_dmic_of_match[] = {
|
273 | 285 | };
|
274 | 286 | MODULE_DEVICE_TABLE(of, sun50i_dmic_of_match);
|
275 | 287 |
|
| 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 | + |
276 | 308 | static const struct snd_soc_component_driver sun50i_dmic_component = {
|
277 | 309 | .name = "sun50i-dmic",
|
| 310 | + .controls = sun50i_dmic_controls, |
| 311 | + .num_controls = ARRAY_SIZE(sun50i_dmic_controls), |
278 | 312 | };
|
279 | 313 |
|
280 | 314 | static int sun50i_dmic_runtime_suspend(struct device *dev)
|
|
0 commit comments