|
21 | 21 | #include <sound/pcm_params.h> |
22 | 22 | #include <sound/soc.h> |
23 | 23 | #include <sound/soc-dapm.h> |
| 24 | +#include <sound/tlv.h> |
24 | 25 |
|
25 | 26 | #define SUN8I_SYSCLK_CTL 0x00c |
26 | 27 | #define SUN8I_SYSCLK_CTL_AIF1CLK_ENA 11 |
|
72 | 73 | #define SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_AIF2DACR 10 |
73 | 74 | #define SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_ADCR 9 |
74 | 75 | #define SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_AIF2DACL 8 |
| 76 | +#define SUN8I_AIF1_VOL_CTRL1 0x050 |
| 77 | +#define SUN8I_AIF1_VOL_CTRL1_AD0L_VOL 8 |
| 78 | +#define SUN8I_AIF1_VOL_CTRL1_AD0R_VOL 0 |
| 79 | +#define SUN8I_AIF1_VOL_CTRL3 0x058 |
| 80 | +#define SUN8I_AIF1_VOL_CTRL3_DA0L_VOL 8 |
| 81 | +#define SUN8I_AIF1_VOL_CTRL3_DA0R_VOL 0 |
75 | 82 | #define SUN8I_AIF2_ADCDAT_CTRL 0x084 |
76 | 83 | #define SUN8I_AIF2_ADCDAT_CTRL_AIF2_ADCL_ENA 15 |
77 | 84 | #define SUN8I_AIF2_ADCDAT_CTRL_AIF2_ADCR_ENA 14 |
|
91 | 98 | #define SUN8I_AIF2_MXR_SRC_ADCR_MXR_SRC_AIF1DA1R 10 |
92 | 99 | #define SUN8I_AIF2_MXR_SRC_ADCR_MXR_SRC_AIF2DACL 9 |
93 | 100 | #define SUN8I_AIF2_MXR_SRC_ADCR_MXR_SRC_ADCR 8 |
| 101 | +#define SUN8I_AIF2_VOL_CTRL1 0x090 |
| 102 | +#define SUN8I_AIF2_VOL_CTRL1_ADCL_VOL 8 |
| 103 | +#define SUN8I_AIF2_VOL_CTRL1_ADCR_VOL 0 |
| 104 | +#define SUN8I_AIF2_VOL_CTRL2 0x098 |
| 105 | +#define SUN8I_AIF2_VOL_CTRL2_DACL_VOL 8 |
| 106 | +#define SUN8I_AIF2_VOL_CTRL2_DACR_VOL 0 |
94 | 107 | #define SUN8I_AIF3_CLK_CTRL_AIF3_CLK_SRC_AIF1 (0x0 << 0) |
95 | 108 | #define SUN8I_AIF3_CLK_CTRL_AIF3_CLK_SRC_AIF2 (0x1 << 0) |
96 | 109 | #define SUN8I_AIF3_CLK_CTRL_AIF3_CLK_SRC_AIF1CLK (0x2 << 0) |
|
102 | 115 | #define SUN8I_ADC_DIG_CTRL_ENAD 15 |
103 | 116 | #define SUN8I_ADC_DIG_CTRL_ADOUT_DTS 2 |
104 | 117 | #define SUN8I_ADC_DIG_CTRL_ADOUT_DLY 1 |
| 118 | +#define SUN8I_ADC_VOL_CTRL 0x104 |
| 119 | +#define SUN8I_ADC_VOL_CTRL_ADCL_VOL 8 |
| 120 | +#define SUN8I_ADC_VOL_CTRL_ADCR_VOL 0 |
105 | 121 | #define SUN8I_DAC_DIG_CTRL 0x120 |
106 | 122 | #define SUN8I_DAC_DIG_CTRL_ENDA 15 |
| 123 | +#define SUN8I_DAC_VOL_CTRL 0x124 |
| 124 | +#define SUN8I_DAC_VOL_CTRL_DACL_VOL 8 |
| 125 | +#define SUN8I_DAC_VOL_CTRL_DACR_VOL 0 |
107 | 126 | #define SUN8I_DAC_MXR_SRC 0x130 |
108 | 127 | #define SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF1DA0L 15 |
109 | 128 | #define SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF1DA1L 14 |
@@ -696,6 +715,41 @@ static struct snd_soc_dai_driver sun8i_codec_dais[] = { |
696 | 715 | }, |
697 | 716 | }; |
698 | 717 |
|
| 718 | +static const DECLARE_TLV_DB_SCALE(sun8i_codec_vol_scale, -12000, 75, 1); |
| 719 | + |
| 720 | +static const struct snd_kcontrol_new sun8i_codec_controls[] = { |
| 721 | + SOC_DOUBLE_TLV("AIF1 AD0 Capture Volume", |
| 722 | + SUN8I_AIF1_VOL_CTRL1, |
| 723 | + SUN8I_AIF1_VOL_CTRL1_AD0L_VOL, |
| 724 | + SUN8I_AIF1_VOL_CTRL1_AD0R_VOL, |
| 725 | + 0xc0, 0, sun8i_codec_vol_scale), |
| 726 | + SOC_DOUBLE_TLV("AIF1 DA0 Playback Volume", |
| 727 | + SUN8I_AIF1_VOL_CTRL3, |
| 728 | + SUN8I_AIF1_VOL_CTRL3_DA0L_VOL, |
| 729 | + SUN8I_AIF1_VOL_CTRL3_DA0R_VOL, |
| 730 | + 0xc0, 0, sun8i_codec_vol_scale), |
| 731 | + SOC_DOUBLE_TLV("AIF2 ADC Capture Volume", |
| 732 | + SUN8I_AIF2_VOL_CTRL1, |
| 733 | + SUN8I_AIF2_VOL_CTRL1_ADCL_VOL, |
| 734 | + SUN8I_AIF2_VOL_CTRL1_ADCR_VOL, |
| 735 | + 0xc0, 0, sun8i_codec_vol_scale), |
| 736 | + SOC_DOUBLE_TLV("AIF2 DAC Playback Volume", |
| 737 | + SUN8I_AIF2_VOL_CTRL2, |
| 738 | + SUN8I_AIF2_VOL_CTRL2_DACL_VOL, |
| 739 | + SUN8I_AIF2_VOL_CTRL2_DACR_VOL, |
| 740 | + 0xc0, 0, sun8i_codec_vol_scale), |
| 741 | + SOC_DOUBLE_TLV("ADC Capture Volume", |
| 742 | + SUN8I_ADC_VOL_CTRL, |
| 743 | + SUN8I_ADC_VOL_CTRL_ADCL_VOL, |
| 744 | + SUN8I_ADC_VOL_CTRL_ADCR_VOL, |
| 745 | + 0xc0, 0, sun8i_codec_vol_scale), |
| 746 | + SOC_DOUBLE_TLV("DAC Playback Volume", |
| 747 | + SUN8I_DAC_VOL_CTRL, |
| 748 | + SUN8I_DAC_VOL_CTRL_DACL_VOL, |
| 749 | + SUN8I_DAC_VOL_CTRL_DACR_VOL, |
| 750 | + 0xc0, 0, sun8i_codec_vol_scale), |
| 751 | +}; |
| 752 | + |
699 | 753 | static int sun8i_codec_aif_event(struct snd_soc_dapm_widget *w, |
700 | 754 | struct snd_kcontrol *kcontrol, int event) |
701 | 755 | { |
@@ -1215,6 +1269,8 @@ static int sun8i_codec_component_probe(struct snd_soc_component *component) |
1215 | 1269 | } |
1216 | 1270 |
|
1217 | 1271 | static const struct snd_soc_component_driver sun8i_soc_component = { |
| 1272 | + .controls = sun8i_codec_controls, |
| 1273 | + .num_controls = ARRAY_SIZE(sun8i_codec_controls), |
1218 | 1274 | .dapm_widgets = sun8i_codec_dapm_widgets, |
1219 | 1275 | .num_dapm_widgets = ARRAY_SIZE(sun8i_codec_dapm_widgets), |
1220 | 1276 | .dapm_routes = sun8i_codec_dapm_routes, |
|
0 commit comments