diff options
author | Philipp Zabel <philipp.zabel@gmail.com> | 2008-01-10 08:37:42 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:29:50 -0500 |
commit | a7a4ac86b4754f44eb06221f3087debb4775d588 (patch) | |
tree | 63240035ca77fca21c4bb3b0db7566f53501053a /sound/soc/soc-dapm.c | |
parent | 0b4d221b8d56deefca4984d01b3a010107ae1f72 (diff) |
[ALSA] ASoC TLV support
Add TLV support to ASoC.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r-- | sound/soc/soc-dapm.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 16ebb60ed3d4..7eb6c5c03775 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -1018,8 +1018,9 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, | |||
1018 | int reg = kcontrol->private_value & 0xff; | 1018 | int reg = kcontrol->private_value & 0xff; |
1019 | int shift = (kcontrol->private_value >> 8) & 0x0f; | 1019 | int shift = (kcontrol->private_value >> 8) & 0x0f; |
1020 | int rshift = (kcontrol->private_value >> 12) & 0x0f; | 1020 | int rshift = (kcontrol->private_value >> 12) & 0x0f; |
1021 | int mask = (kcontrol->private_value >> 16) & 0xff; | 1021 | int max = (kcontrol->private_value >> 16) & 0xff; |
1022 | int invert = (kcontrol->private_value >> 24) & 0x01; | 1022 | int invert = (kcontrol->private_value >> 24) & 0x01; |
1023 | int mask = (1 << fls(max)) - 1; | ||
1023 | 1024 | ||
1024 | /* return the saved value if we are powered down */ | 1025 | /* return the saved value if we are powered down */ |
1025 | if (widget->id == snd_soc_dapm_pga && !widget->power) { | 1026 | if (widget->id == snd_soc_dapm_pga && !widget->power) { |
@@ -1034,10 +1035,10 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, | |||
1034 | (snd_soc_read(widget->codec, reg) >> rshift) & mask; | 1035 | (snd_soc_read(widget->codec, reg) >> rshift) & mask; |
1035 | if (invert) { | 1036 | if (invert) { |
1036 | ucontrol->value.integer.value[0] = | 1037 | ucontrol->value.integer.value[0] = |
1037 | mask - ucontrol->value.integer.value[0]; | 1038 | max - ucontrol->value.integer.value[0]; |
1038 | if (shift != rshift) | 1039 | if (shift != rshift) |
1039 | ucontrol->value.integer.value[1] = | 1040 | ucontrol->value.integer.value[1] = |
1040 | mask - ucontrol->value.integer.value[1]; | 1041 | max - ucontrol->value.integer.value[1]; |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | return 0; | 1044 | return 0; |
@@ -1060,7 +1061,8 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |||
1060 | int reg = kcontrol->private_value & 0xff; | 1061 | int reg = kcontrol->private_value & 0xff; |
1061 | int shift = (kcontrol->private_value >> 8) & 0x0f; | 1062 | int shift = (kcontrol->private_value >> 8) & 0x0f; |
1062 | int rshift = (kcontrol->private_value >> 12) & 0x0f; | 1063 | int rshift = (kcontrol->private_value >> 12) & 0x0f; |
1063 | int mask = (kcontrol->private_value >> 16) & 0xff; | 1064 | int max = (kcontrol->private_value >> 16) & 0xff; |
1065 | int mask = (1 << fls(max)) - 1; | ||
1064 | int invert = (kcontrol->private_value >> 24) & 0x01; | 1066 | int invert = (kcontrol->private_value >> 24) & 0x01; |
1065 | unsigned short val, val2, val_mask; | 1067 | unsigned short val, val2, val_mask; |
1066 | int ret; | 1068 | int ret; |
@@ -1068,13 +1070,13 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |||
1068 | val = (ucontrol->value.integer.value[0] & mask); | 1070 | val = (ucontrol->value.integer.value[0] & mask); |
1069 | 1071 | ||
1070 | if (invert) | 1072 | if (invert) |
1071 | val = mask - val; | 1073 | val = max - val; |
1072 | val_mask = mask << shift; | 1074 | val_mask = mask << shift; |
1073 | val = val << shift; | 1075 | val = val << shift; |
1074 | if (shift != rshift) { | 1076 | if (shift != rshift) { |
1075 | val2 = (ucontrol->value.integer.value[1] & mask); | 1077 | val2 = (ucontrol->value.integer.value[1] & mask); |
1076 | if (invert) | 1078 | if (invert) |
1077 | val2 = mask - val2; | 1079 | val2 = max - val2; |
1078 | val_mask |= mask << rshift; | 1080 | val_mask |= mask << rshift; |
1079 | val |= val2 << rshift; | 1081 | val |= val2 << rshift; |
1080 | } | 1082 | } |