diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2011-01-10 10:25:44 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-01-10 10:46:53 -0500 |
commit | 9600732b6caba595f34acf2abd930098ec9a0b2b (patch) | |
tree | 7474e1b11894623186a2acd47a388aa87fdd002e /sound/pci/oxygen | |
parent | b532d6b8d3aa163e1dc143bc729e9ee92f75baf5 (diff) |
ALSA: core, oxygen, virtuoso: add an enum control info helper
Introduce the helper function snd_ctl_enum_info() to fill out the
elem_info fields for an enumerated control.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/oxygen')
-rw-r--r-- | sound/pci/oxygen/oxygen.c | 16 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_mixer.c | 15 | ||||
-rw-r--r-- | sound/pci/oxygen/xonar_cs43xx.c | 8 | ||||
-rw-r--r-- | sound/pci/oxygen/xonar_dg.c | 30 | ||||
-rw-r--r-- | sound/pci/oxygen/xonar_pcm179x.c | 24 | ||||
-rw-r--r-- | sound/pci/oxygen/xonar_wm87x6.c | 25 |
6 files changed, 16 insertions, 102 deletions
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index b59aeefd14db..45427d85045e 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c | |||
@@ -415,13 +415,7 @@ static int rolloff_info(struct snd_kcontrol *ctl, | |||
415 | "Sharp Roll-off", "Slow Roll-off" | 415 | "Sharp Roll-off", "Slow Roll-off" |
416 | }; | 416 | }; |
417 | 417 | ||
418 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 418 | return snd_ctl_enum_info(info, 1, 2, names); |
419 | info->count = 1; | ||
420 | info->value.enumerated.items = 2; | ||
421 | if (info->value.enumerated.item >= 2) | ||
422 | info->value.enumerated.item = 1; | ||
423 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
424 | return 0; | ||
425 | } | 419 | } |
426 | 420 | ||
427 | static int rolloff_get(struct snd_kcontrol *ctl, | 421 | static int rolloff_get(struct snd_kcontrol *ctl, |
@@ -473,13 +467,7 @@ static int hpf_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) | |||
473 | "None", "High-pass Filter" | 467 | "None", "High-pass Filter" |
474 | }; | 468 | }; |
475 | 469 | ||
476 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 470 | return snd_ctl_enum_info(info, 1, 2, names); |
477 | info->count = 1; | ||
478 | info->value.enumerated.items = 2; | ||
479 | if (info->value.enumerated.item >= 2) | ||
480 | info->value.enumerated.item = 1; | ||
481 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
482 | return 0; | ||
483 | } | 471 | } |
484 | 472 | ||
485 | static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | 473 | static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) |
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c index d327c36fbddf..821df1c9d1d0 100644 --- a/sound/pci/oxygen/oxygen_mixer.c +++ b/sound/pci/oxygen/oxygen_mixer.c | |||
@@ -119,13 +119,7 @@ static int upmix_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) | |||
119 | struct oxygen *chip = ctl->private_data; | 119 | struct oxygen *chip = ctl->private_data; |
120 | unsigned int count = upmix_item_count(chip); | 120 | unsigned int count = upmix_item_count(chip); |
121 | 121 | ||
122 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 122 | return snd_ctl_enum_info(info, 1, count, names); |
123 | info->count = 1; | ||
124 | info->value.enumerated.items = count; | ||
125 | if (info->value.enumerated.item >= count) | ||
126 | info->value.enumerated.item = count - 1; | ||
127 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
128 | return 0; | ||
129 | } | 123 | } |
130 | 124 | ||
131 | static int upmix_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | 125 | static int upmix_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) |
@@ -659,12 +653,7 @@ static int mic_fmic_source_info(struct snd_kcontrol *ctl, | |||
659 | { | 653 | { |
660 | static const char *const names[] = { "Mic Jack", "Front Panel" }; | 654 | static const char *const names[] = { "Mic Jack", "Front Panel" }; |
661 | 655 | ||
662 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 656 | return snd_ctl_enum_info(info, 1, 2, names); |
663 | info->count = 1; | ||
664 | info->value.enumerated.items = 2; | ||
665 | info->value.enumerated.item &= 1; | ||
666 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
667 | return 0; | ||
668 | } | 657 | } |
669 | 658 | ||
670 | static int mic_fmic_source_get(struct snd_kcontrol *ctl, | 659 | static int mic_fmic_source_get(struct snd_kcontrol *ctl, |
diff --git a/sound/pci/oxygen/xonar_cs43xx.c b/sound/pci/oxygen/xonar_cs43xx.c index 55c52c7e19b2..9f72d424969c 100644 --- a/sound/pci/oxygen/xonar_cs43xx.c +++ b/sound/pci/oxygen/xonar_cs43xx.c | |||
@@ -298,13 +298,7 @@ static int rolloff_info(struct snd_kcontrol *ctl, | |||
298 | "Fast Roll-off", "Slow Roll-off" | 298 | "Fast Roll-off", "Slow Roll-off" |
299 | }; | 299 | }; |
300 | 300 | ||
301 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 301 | return snd_ctl_enum_info(info, 1, 2, names); |
302 | info->count = 1; | ||
303 | info->value.enumerated.items = 2; | ||
304 | if (info->value.enumerated.item >= 2) | ||
305 | info->value.enumerated.item = 1; | ||
306 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
307 | return 0; | ||
308 | } | 302 | } |
309 | 303 | ||
310 | static int rolloff_get(struct snd_kcontrol *ctl, | 304 | static int rolloff_get(struct snd_kcontrol *ctl, |
diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c index 7ed3284d7d5b..cc610ac1fc19 100644 --- a/sound/pci/oxygen/xonar_dg.c +++ b/sound/pci/oxygen/xonar_dg.c | |||
@@ -213,13 +213,7 @@ static int output_switch_info(struct snd_kcontrol *ctl, | |||
213 | "Speakers", "Headphones", "FP Headphones" | 213 | "Speakers", "Headphones", "FP Headphones" |
214 | }; | 214 | }; |
215 | 215 | ||
216 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 216 | return snd_ctl_enum_info(info, 1, 3, names); |
217 | info->count = 1; | ||
218 | info->value.enumerated.items = 3; | ||
219 | if (info->value.enumerated.item >= 3) | ||
220 | info->value.enumerated.item = 2; | ||
221 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
222 | return 0; | ||
223 | } | 217 | } |
224 | 218 | ||
225 | static int output_switch_get(struct snd_kcontrol *ctl, | 219 | static int output_switch_get(struct snd_kcontrol *ctl, |
@@ -276,13 +270,7 @@ static int hp_volume_offset_info(struct snd_kcontrol *ctl, | |||
276 | "< 64 ohms", "64-150 ohms", "150-300 ohms" | 270 | "< 64 ohms", "64-150 ohms", "150-300 ohms" |
277 | }; | 271 | }; |
278 | 272 | ||
279 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 273 | return snd_ctl_enum_info(info, 1, 3, names); |
280 | info->count = 1; | ||
281 | info->value.enumerated.items = 3; | ||
282 | if (info->value.enumerated.item >= 3) | ||
283 | info->value.enumerated.item = 2; | ||
284 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
285 | return 0; | ||
286 | } | 274 | } |
287 | 275 | ||
288 | static int hp_volume_offset_get(struct snd_kcontrol *ctl, | 276 | static int hp_volume_offset_get(struct snd_kcontrol *ctl, |
@@ -390,12 +378,7 @@ static int input_sel_info(struct snd_kcontrol *ctl, | |||
390 | "Mic", "Aux", "Front Mic", "Line" | 378 | "Mic", "Aux", "Front Mic", "Line" |
391 | }; | 379 | }; |
392 | 380 | ||
393 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 381 | return snd_ctl_enum_info(info, 1, 4, names); |
394 | info->count = 1; | ||
395 | info->value.enumerated.items = 4; | ||
396 | info->value.enumerated.item &= 3; | ||
397 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
398 | return 0; | ||
399 | } | 382 | } |
400 | 383 | ||
401 | static int input_sel_get(struct snd_kcontrol *ctl, | 384 | static int input_sel_get(struct snd_kcontrol *ctl, |
@@ -453,12 +436,7 @@ static int hpf_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) | |||
453 | { | 436 | { |
454 | static const char *const names[2] = { "Active", "Frozen" }; | 437 | static const char *const names[2] = { "Active", "Frozen" }; |
455 | 438 | ||
456 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 439 | return snd_ctl_enum_info(info, 1, 2, names); |
457 | info->count = 1; | ||
458 | info->value.enumerated.items = 2; | ||
459 | info->value.enumerated.item &= 1; | ||
460 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
461 | return 0; | ||
462 | } | 440 | } |
463 | 441 | ||
464 | static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | 442 | static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) |
diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c index bf4fd4bb1359..54cad38ec30a 100644 --- a/sound/pci/oxygen/xonar_pcm179x.c +++ b/sound/pci/oxygen/xonar_pcm179x.c | |||
@@ -678,13 +678,7 @@ static int rolloff_info(struct snd_kcontrol *ctl, | |||
678 | "Sharp Roll-off", "Slow Roll-off" | 678 | "Sharp Roll-off", "Slow Roll-off" |
679 | }; | 679 | }; |
680 | 680 | ||
681 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 681 | return snd_ctl_enum_info(info, 1, 2, names); |
682 | info->count = 1; | ||
683 | info->value.enumerated.items = 2; | ||
684 | if (info->value.enumerated.item >= 2) | ||
685 | info->value.enumerated.item = 1; | ||
686 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
687 | return 0; | ||
688 | } | 682 | } |
689 | 683 | ||
690 | static int rolloff_get(struct snd_kcontrol *ctl, | 684 | static int rolloff_get(struct snd_kcontrol *ctl, |
@@ -748,13 +742,7 @@ static int st_output_switch_info(struct snd_kcontrol *ctl, | |||
748 | "Speakers", "Headphones", "FP Headphones" | 742 | "Speakers", "Headphones", "FP Headphones" |
749 | }; | 743 | }; |
750 | 744 | ||
751 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 745 | return snd_ctl_enum_info(info, 1, 3, names); |
752 | info->count = 1; | ||
753 | info->value.enumerated.items = 3; | ||
754 | if (info->value.enumerated.item >= 3) | ||
755 | info->value.enumerated.item = 2; | ||
756 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
757 | return 0; | ||
758 | } | 746 | } |
759 | 747 | ||
760 | static int st_output_switch_get(struct snd_kcontrol *ctl, | 748 | static int st_output_switch_get(struct snd_kcontrol *ctl, |
@@ -809,13 +797,7 @@ static int st_hp_volume_offset_info(struct snd_kcontrol *ctl, | |||
809 | "< 64 ohms", "64-300 ohms", "300-600 ohms" | 797 | "< 64 ohms", "64-300 ohms", "300-600 ohms" |
810 | }; | 798 | }; |
811 | 799 | ||
812 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 800 | return snd_ctl_enum_info(info, 1, 3, names); |
813 | info->count = 1; | ||
814 | info->value.enumerated.items = 3; | ||
815 | if (info->value.enumerated.item > 2) | ||
816 | info->value.enumerated.item = 2; | ||
817 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
818 | return 0; | ||
819 | } | 801 | } |
820 | 802 | ||
821 | static int st_hp_volume_offset_get(struct snd_kcontrol *ctl, | 803 | static int st_hp_volume_offset_get(struct snd_kcontrol *ctl, |
diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index ad48356c54e4..42d1ab136217 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c | |||
@@ -577,11 +577,6 @@ static int wm8776_field_enum_info(struct snd_kcontrol *ctl, | |||
577 | const char *const *names; | 577 | const char *const *names; |
578 | 578 | ||
579 | max = (ctl->private_value >> 12) & 0xf; | 579 | max = (ctl->private_value >> 12) & 0xf; |
580 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
581 | info->count = 1; | ||
582 | info->value.enumerated.items = max + 1; | ||
583 | if (info->value.enumerated.item > max) | ||
584 | info->value.enumerated.item = max; | ||
585 | switch ((ctl->private_value >> 24) & 0x1f) { | 580 | switch ((ctl->private_value >> 24) & 0x1f) { |
586 | case WM8776_ALCCTRL2: | 581 | case WM8776_ALCCTRL2: |
587 | names = hld; | 582 | names = hld; |
@@ -605,8 +600,7 @@ static int wm8776_field_enum_info(struct snd_kcontrol *ctl, | |||
605 | default: | 600 | default: |
606 | return -ENXIO; | 601 | return -ENXIO; |
607 | } | 602 | } |
608 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | 603 | return snd_ctl_enum_info(info, 1, max + 1, names); |
609 | return 0; | ||
610 | } | 604 | } |
611 | 605 | ||
612 | static int wm8776_field_volume_info(struct snd_kcontrol *ctl, | 606 | static int wm8776_field_volume_info(struct snd_kcontrol *ctl, |
@@ -863,13 +857,8 @@ static int wm8776_level_control_info(struct snd_kcontrol *ctl, | |||
863 | static const char *const names[3] = { | 857 | static const char *const names[3] = { |
864 | "None", "Peak Limiter", "Automatic Level Control" | 858 | "None", "Peak Limiter", "Automatic Level Control" |
865 | }; | 859 | }; |
866 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 860 | |
867 | info->count = 1; | 861 | return snd_ctl_enum_info(info, 1, 3, names); |
868 | info->value.enumerated.items = 3; | ||
869 | if (info->value.enumerated.item >= 3) | ||
870 | info->value.enumerated.item = 2; | ||
871 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
872 | return 0; | ||
873 | } | 862 | } |
874 | 863 | ||
875 | static int wm8776_level_control_get(struct snd_kcontrol *ctl, | 864 | static int wm8776_level_control_get(struct snd_kcontrol *ctl, |
@@ -955,13 +944,7 @@ static int hpf_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) | |||
955 | "None", "High-pass Filter" | 944 | "None", "High-pass Filter" |
956 | }; | 945 | }; |
957 | 946 | ||
958 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 947 | return snd_ctl_enum_info(info, 1, 2, names); |
959 | info->count = 1; | ||
960 | info->value.enumerated.items = 2; | ||
961 | if (info->value.enumerated.item >= 2) | ||
962 | info->value.enumerated.item = 1; | ||
963 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
964 | return 0; | ||
965 | } | 948 | } |
966 | 949 | ||
967 | static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | 950 | static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) |