aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/soc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sound/soc.h')
-rw-r--r--include/sound/soc.h86
1 files changed, 60 insertions, 26 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 075d7e8ba802..81b55e498f67 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -45,6 +45,11 @@
45 ((unsigned long)&(struct soc_mixer_control) \ 45 ((unsigned long)&(struct soc_mixer_control) \
46 {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \ 46 {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
47 .max = xmax, .platform_max = xmax, .invert = xinvert}) 47 .max = xmax, .platform_max = xmax, .invert = xinvert})
48#define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
49 ((unsigned long)&(struct soc_mixer_control) \
50 {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
51 .max = xmax, .min = xmin, .platform_max = xmax, .sign_bit = xsign_bit, \
52 .invert = xinvert})
48#define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \ 53#define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
49 ((unsigned long)&(struct soc_mixer_control) \ 54 ((unsigned long)&(struct soc_mixer_control) \
50 {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \ 55 {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
@@ -152,6 +157,15 @@
152 {.reg = xreg, .rreg = xrreg, \ 157 {.reg = xreg, .rreg = xrreg, \
153 .shift = xshift, .rshift = xshift, \ 158 .shift = xshift, .rshift = xshift, \
154 .max = xmax, .min = xmin} } 159 .max = xmax, .min = xmin} }
160#define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
161{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
162 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
163 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
164 .tlv.p = (tlv_array), \
165 .info = snd_soc_info_volsw, \
166 .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
167 .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
168 xmin, xmax, xsign_bit, xinvert) }
155#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ 169#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
156{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 170{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
157 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 171 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
@@ -162,30 +176,28 @@
162 .private_value = (unsigned long)&(struct soc_mixer_control) \ 176 .private_value = (unsigned long)&(struct soc_mixer_control) \
163 {.reg = xreg, .min = xmin, .max = xmax, \ 177 {.reg = xreg, .min = xmin, .max = xmax, \
164 .platform_max = xmax} } 178 .platform_max = xmax} }
165#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \ 179#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
166{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ 180{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
167 .max = xmax, .texts = xtexts, \ 181 .items = xitems, .texts = xtexts, \
168 .mask = xmax ? roundup_pow_of_two(xmax) - 1 : 0} 182 .mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
169#define SOC_ENUM_SINGLE(xreg, xshift, xmax, xtexts) \ 183#define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
170 SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts) 184 SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
171#define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \ 185#define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
172{ .max = xmax, .texts = xtexts } 186{ .items = xitems, .texts = xtexts }
173#define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xmax, xtexts, xvalues) \ 187#define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
174{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ 188{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
175 .mask = xmask, .max = xmax, .texts = xtexts, .values = xvalues} 189 .mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
176#define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xmax, xtexts, xvalues) \ 190#define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xnitmes, xtexts, xvalues) \
177 SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xmax, xtexts, xvalues) 191 SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xnitmes, xtexts, xvalues)
192#define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
193 SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
178#define SOC_ENUM(xname, xenum) \ 194#define SOC_ENUM(xname, xenum) \
179{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ 195{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
180 .info = snd_soc_info_enum_double, \ 196 .info = snd_soc_info_enum_double, \
181 .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \ 197 .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
182 .private_value = (unsigned long)&xenum } 198 .private_value = (unsigned long)&xenum }
183#define SOC_VALUE_ENUM(xname, xenum) \ 199#define SOC_VALUE_ENUM(xname, xenum) \
184{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ 200 SOC_ENUM(xname, xenum)
185 .info = snd_soc_info_enum_double, \
186 .get = snd_soc_get_value_enum_double, \
187 .put = snd_soc_put_value_enum_double, \
188 .private_value = (unsigned long)&xenum }
189#define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\ 201#define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
190 xhandler_get, xhandler_put) \ 202 xhandler_get, xhandler_put) \
191{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 203{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
@@ -272,17 +284,19 @@
272 * ARRAY_SIZE internally 284 * ARRAY_SIZE internally
273 */ 285 */
274#define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \ 286#define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
275 struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \ 287 const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
276 ARRAY_SIZE(xtexts), xtexts) 288 ARRAY_SIZE(xtexts), xtexts)
277#define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \ 289#define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
278 SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts) 290 SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
279#define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \ 291#define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
280 struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts) 292 const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
281#define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \ 293#define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
282 struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \ 294 const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
283 ARRAY_SIZE(xtexts), xtexts, xvalues) 295 ARRAY_SIZE(xtexts), xtexts, xvalues)
284#define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \ 296#define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
285 SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues) 297 SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
298#define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
299 const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
286 300
287/* 301/*
288 * Component probe and remove ordering levels for components with runtime 302 * Component probe and remove ordering levels for components with runtime
@@ -500,10 +514,6 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol); 514 struct snd_ctl_elem_value *ucontrol);
501int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, 515int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
502 struct snd_ctl_elem_value *ucontrol); 516 struct snd_ctl_elem_value *ucontrol);
503int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
504 struct snd_ctl_elem_value *ucontrol);
505int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_value *ucontrol);
507int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, 517int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_info *uinfo); 518 struct snd_ctl_elem_info *uinfo);
509#define snd_soc_info_bool_ext snd_ctl_boolean_mono_info 519#define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
@@ -1076,6 +1086,7 @@ struct soc_mixer_control {
1076 int min, max, platform_max; 1086 int min, max, platform_max;
1077 int reg, rreg; 1087 int reg, rreg;
1078 unsigned int shift, rshift; 1088 unsigned int shift, rshift;
1089 unsigned int sign_bit;
1079 unsigned int invert:1; 1090 unsigned int invert:1;
1080 unsigned int autodisable:1; 1091 unsigned int autodisable:1;
1081}; 1092};
@@ -1094,11 +1105,10 @@ struct soc_mreg_control {
1094 1105
1095/* enumerated kcontrol */ 1106/* enumerated kcontrol */
1096struct soc_enum { 1107struct soc_enum {
1097 unsigned short reg; 1108 int reg;
1098 unsigned short reg2;
1099 unsigned char shift_l; 1109 unsigned char shift_l;
1100 unsigned char shift_r; 1110 unsigned char shift_r;
1101 unsigned int max; 1111 unsigned int items;
1102 unsigned int mask; 1112 unsigned int mask;
1103 const char * const *texts; 1113 const char * const *texts;
1104 const unsigned int *values; 1114 const unsigned int *values;
@@ -1177,6 +1187,30 @@ static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
1177 return 1; 1187 return 1;
1178} 1188}
1179 1189
1190static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
1191 unsigned int val)
1192{
1193 unsigned int i;
1194
1195 if (!e->values)
1196 return val;
1197
1198 for (i = 0; i < e->items; i++)
1199 if (val == e->values[i])
1200 return i;
1201
1202 return 0;
1203}
1204
1205static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
1206 unsigned int item)
1207{
1208 if (!e->values)
1209 return item;
1210
1211 return e->values[item];
1212}
1213
1180static inline bool snd_soc_component_is_active( 1214static inline bool snd_soc_component_is_active(
1181 struct snd_soc_component *component) 1215 struct snd_soc_component *component)
1182{ 1216{