diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2011-06-06 07:38:36 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-06-06 16:54:41 -0400 |
commit | 90bc11d1d0310e5e6bfbdea6ed21047b3865df05 (patch) | |
tree | ec6599e1c21f88b7dd8e8407a3e0b6e2cdd7dd0c /sound/soc/codecs/ad1836.c | |
parent | 85e9e766380fe40e1937b8316e8aa867544f09f1 (diff) |
ASoC: AD1836: Add ADC/DAC controls helper macros
The different ADC and DAC controls follow the same scheme, so add some helper
macros for declaring them.
This should make the code a bit more readable and also decreases the code size
a bit.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/ad1836.c')
-rw-r--r-- | sound/soc/codecs/ad1836.c | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c index ab63d52e36e1..675d6ccdf9d6 100644 --- a/sound/soc/codecs/ad1836.c +++ b/sound/soc/codecs/ad1836.c | |||
@@ -44,28 +44,32 @@ static const char *ad1836_deemp[] = {"None", "44.1kHz", "32kHz", "48kHz"}; | |||
44 | static const struct soc_enum ad1836_deemp_enum = | 44 | static const struct soc_enum ad1836_deemp_enum = |
45 | SOC_ENUM_SINGLE(AD1836_DAC_CTRL1, 8, 4, ad1836_deemp); | 45 | SOC_ENUM_SINGLE(AD1836_DAC_CTRL1, 8, 4, ad1836_deemp); |
46 | 46 | ||
47 | #define AD1836_DAC_VOLUME(x) \ | ||
48 | SOC_DOUBLE_R("DAC" #x " Playback Volume", AD1836_DAC_L_VOL(x), \ | ||
49 | AD1836_DAC_R_VOL(x), 0, 0x3FF, 0) | ||
50 | |||
51 | #define AD1836_DAC_SWITCH(x) \ | ||
52 | SOC_DOUBLE("DAC" #x " Playback Switch", AD1836_DAC_CTRL2, \ | ||
53 | AD1836_MUTE_LEFT(x), AD1836_MUTE_RIGHT(x), 1, 1) | ||
54 | |||
55 | #define AD1836_ADC_SWITCH(x) \ | ||
56 | SOC_DOUBLE("ADC" #x " Capture Switch", AD1836_ADC_CTRL2, \ | ||
57 | AD1836_MUTE_LEFT(x), AD1836_MUTE_RIGHT(x), 1, 1) | ||
58 | |||
47 | static const struct snd_kcontrol_new ad1836_snd_controls[] = { | 59 | static const struct snd_kcontrol_new ad1836_snd_controls[] = { |
48 | /* DAC volume control */ | 60 | /* DAC volume control */ |
49 | SOC_DOUBLE_R("DAC1 Volume", AD1836_DAC_L1_VOL, | 61 | AD1836_DAC_VOLUME(1), |
50 | AD1836_DAC_R1_VOL, 0, 0x3FF, 0), | 62 | AD1836_DAC_VOLUME(2), |
51 | SOC_DOUBLE_R("DAC2 Volume", AD1836_DAC_L2_VOL, | 63 | AD1836_DAC_VOLUME(3), |
52 | AD1836_DAC_R2_VOL, 0, 0x3FF, 0), | ||
53 | SOC_DOUBLE_R("DAC3 Volume", AD1836_DAC_L3_VOL, | ||
54 | AD1836_DAC_R3_VOL, 0, 0x3FF, 0), | ||
55 | 64 | ||
56 | /* ADC switch control */ | 65 | /* ADC switch control */ |
57 | SOC_DOUBLE("ADC1 Switch", AD1836_ADC_CTRL2, AD1836_ADCL1_MUTE, | 66 | AD1836_ADC_SWITCH(1), |
58 | AD1836_ADCR1_MUTE, 1, 1), | 67 | AD1836_ADC_SWITCH(2), |
59 | SOC_DOUBLE("ADC2 Switch", AD1836_ADC_CTRL2, AD1836_ADCL2_MUTE, | ||
60 | AD1836_ADCR2_MUTE, 1, 1), | ||
61 | 68 | ||
62 | /* DAC switch control */ | 69 | /* DAC switch control */ |
63 | SOC_DOUBLE("DAC1 Switch", AD1836_DAC_CTRL2, AD1836_DACL1_MUTE, | 70 | AD1836_DAC_SWITCH(1), |
64 | AD1836_DACR1_MUTE, 1, 1), | 71 | AD1836_DAC_SWITCH(2), |
65 | SOC_DOUBLE("DAC2 Switch", AD1836_DAC_CTRL2, AD1836_DACL2_MUTE, | 72 | AD1836_DAC_SWITCH(3), |
66 | AD1836_DACR2_MUTE, 1, 1), | ||
67 | SOC_DOUBLE("DAC3 Switch", AD1836_DAC_CTRL2, AD1836_DACL3_MUTE, | ||
68 | AD1836_DACR3_MUTE, 1, 1), | ||
69 | 73 | ||
70 | /* ADC high-pass filter */ | 74 | /* ADC high-pass filter */ |
71 | SOC_SINGLE("ADC High Pass Filter Switch", AD1836_ADC_CTRL1, | 75 | SOC_SINGLE("ADC High Pass Filter Switch", AD1836_ADC_CTRL1, |
@@ -242,12 +246,12 @@ static int ad1836_probe(struct snd_soc_codec *codec) | |||
242 | /* left/right diff:PGA/MUX */ | 246 | /* left/right diff:PGA/MUX */ |
243 | snd_soc_write(codec, AD1836_ADC_CTRL3, 0x3A); | 247 | snd_soc_write(codec, AD1836_ADC_CTRL3, 0x3A); |
244 | /* volume */ | 248 | /* volume */ |
245 | snd_soc_write(codec, AD1836_DAC_L1_VOL, 0x3FF); | 249 | snd_soc_write(codec, AD1836_DAC_L_VOL(1), 0x3FF); |
246 | snd_soc_write(codec, AD1836_DAC_R1_VOL, 0x3FF); | 250 | snd_soc_write(codec, AD1836_DAC_R_VOL(1), 0x3FF); |
247 | snd_soc_write(codec, AD1836_DAC_L2_VOL, 0x3FF); | 251 | snd_soc_write(codec, AD1836_DAC_L_VOL(2), 0x3FF); |
248 | snd_soc_write(codec, AD1836_DAC_R2_VOL, 0x3FF); | 252 | snd_soc_write(codec, AD1836_DAC_R_VOL(2), 0x3FF); |
249 | snd_soc_write(codec, AD1836_DAC_L3_VOL, 0x3FF); | 253 | snd_soc_write(codec, AD1836_DAC_L_VOL(3), 0x3FF); |
250 | snd_soc_write(codec, AD1836_DAC_R3_VOL, 0x3FF); | 254 | snd_soc_write(codec, AD1836_DAC_R_VOL(3), 0x3FF); |
251 | 255 | ||
252 | snd_soc_add_controls(codec, ad1836_snd_controls, | 256 | snd_soc_add_controls(codec, ad1836_snd_controls, |
253 | ARRAY_SIZE(ad1836_snd_controls)); | 257 | ARRAY_SIZE(ad1836_snd_controls)); |