diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-10-20 12:16:26 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-10-21 02:55:04 -0400 |
commit | de95eae25a2744ba5f9bd3c862bb43a1b177ad58 (patch) | |
tree | 632056b3695b9712f62e0f0f3e5b1be6b6b49acc | |
parent | 9b311a0ad9ec0df9f010bcadd19193b1cee593f6 (diff) |
ALSA: ca0106: Use snd_ctl_enum_info()
... and reduce the open codes. Also correct the array size and add
missing const to text arrays.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pci/ca0106/ca0106_mixer.c | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 27de0de90018..68c0eb0a2807 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c | |||
@@ -185,17 +185,11 @@ static int snd_ca0106_shared_spdif_put(struct snd_kcontrol *kcontrol, | |||
185 | static int snd_ca0106_capture_source_info(struct snd_kcontrol *kcontrol, | 185 | static int snd_ca0106_capture_source_info(struct snd_kcontrol *kcontrol, |
186 | struct snd_ctl_elem_info *uinfo) | 186 | struct snd_ctl_elem_info *uinfo) |
187 | { | 187 | { |
188 | static char *texts[6] = { | 188 | static const char * const texts[6] = { |
189 | "IEC958 out", "i2s mixer out", "IEC958 in", "i2s in", "AC97 in", "SRC out" | 189 | "IEC958 out", "i2s mixer out", "IEC958 in", "i2s in", "AC97 in", "SRC out" |
190 | }; | 190 | }; |
191 | 191 | ||
192 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 192 | return snd_ctl_enum_info(uinfo, 1, 6, texts); |
193 | uinfo->count = 1; | ||
194 | uinfo->value.enumerated.items = 6; | ||
195 | if (uinfo->value.enumerated.item > 5) | ||
196 | uinfo->value.enumerated.item = 5; | ||
197 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
198 | return 0; | ||
199 | } | 193 | } |
200 | 194 | ||
201 | static int snd_ca0106_capture_source_get(struct snd_kcontrol *kcontrol, | 195 | static int snd_ca0106_capture_source_get(struct snd_kcontrol *kcontrol, |
@@ -228,17 +222,11 @@ static int snd_ca0106_capture_source_put(struct snd_kcontrol *kcontrol, | |||
228 | static int snd_ca0106_i2c_capture_source_info(struct snd_kcontrol *kcontrol, | 222 | static int snd_ca0106_i2c_capture_source_info(struct snd_kcontrol *kcontrol, |
229 | struct snd_ctl_elem_info *uinfo) | 223 | struct snd_ctl_elem_info *uinfo) |
230 | { | 224 | { |
231 | static char *texts[6] = { | 225 | static const char * const texts[4] = { |
232 | "Phone", "Mic", "Line in", "Aux" | 226 | "Phone", "Mic", "Line in", "Aux" |
233 | }; | 227 | }; |
234 | 228 | ||
235 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 229 | return snd_ctl_enum_info(uinfo, 1, 4, texts); |
236 | uinfo->count = 1; | ||
237 | uinfo->value.enumerated.items = 4; | ||
238 | if (uinfo->value.enumerated.item > 3) | ||
239 | uinfo->value.enumerated.item = 3; | ||
240 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
241 | return 0; | ||
242 | } | 230 | } |
243 | 231 | ||
244 | static int snd_ca0106_i2c_capture_source_get(struct snd_kcontrol *kcontrol, | 232 | static int snd_ca0106_i2c_capture_source_get(struct snd_kcontrol *kcontrol, |
@@ -273,29 +261,17 @@ static int snd_ca0106_i2c_capture_source_put(struct snd_kcontrol *kcontrol, | |||
273 | static int snd_ca0106_capture_line_in_side_out_info(struct snd_kcontrol *kcontrol, | 261 | static int snd_ca0106_capture_line_in_side_out_info(struct snd_kcontrol *kcontrol, |
274 | struct snd_ctl_elem_info *uinfo) | 262 | struct snd_ctl_elem_info *uinfo) |
275 | { | 263 | { |
276 | static char *texts[2] = { "Side out", "Line in" }; | 264 | static const char * const texts[2] = { "Side out", "Line in" }; |
277 | 265 | ||
278 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 266 | return snd_ctl_enum_info(uinfo, 1, 2, texts); |
279 | uinfo->count = 1; | ||
280 | uinfo->value.enumerated.items = 2; | ||
281 | if (uinfo->value.enumerated.item > 1) | ||
282 | uinfo->value.enumerated.item = 1; | ||
283 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
284 | return 0; | ||
285 | } | 267 | } |
286 | 268 | ||
287 | static int snd_ca0106_capture_mic_line_in_info(struct snd_kcontrol *kcontrol, | 269 | static int snd_ca0106_capture_mic_line_in_info(struct snd_kcontrol *kcontrol, |
288 | struct snd_ctl_elem_info *uinfo) | 270 | struct snd_ctl_elem_info *uinfo) |
289 | { | 271 | { |
290 | static char *texts[2] = { "Line in", "Mic in" }; | 272 | static const char * const texts[2] = { "Line in", "Mic in" }; |
291 | 273 | ||
292 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 274 | return snd_ctl_enum_info(uinfo, 1, 2, texts); |
293 | uinfo->count = 1; | ||
294 | uinfo->value.enumerated.items = 2; | ||
295 | if (uinfo->value.enumerated.item > 1) | ||
296 | uinfo->value.enumerated.item = 1; | ||
297 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
298 | return 0; | ||
299 | } | 275 | } |
300 | 276 | ||
301 | static int snd_ca0106_capture_mic_line_in_get(struct snd_kcontrol *kcontrol, | 277 | static int snd_ca0106_capture_mic_line_in_get(struct snd_kcontrol *kcontrol, |