aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2011-01-10 10:25:44 -0500
committerTakashi Iwai <tiwai@suse.de>2011-01-10 10:46:53 -0500
commit9600732b6caba595f34acf2abd930098ec9a0b2b (patch)
tree7474e1b11894623186a2acd47a388aa87fdd002e /sound/pci/oxygen
parentb532d6b8d3aa163e1dc143bc729e9ee92f75baf5 (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.c16
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c15
-rw-r--r--sound/pci/oxygen/xonar_cs43xx.c8
-rw-r--r--sound/pci/oxygen/xonar_dg.c30
-rw-r--r--sound/pci/oxygen/xonar_pcm179x.c24
-rw-r--r--sound/pci/oxygen/xonar_wm87x6.c25
6 files changed, 16 insertions, 102 deletions
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index b59aeefd14d..45427d85045 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
427static int rolloff_get(struct snd_kcontrol *ctl, 421static 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
485static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) 473static 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 d327c36fbdd..821df1c9d1d 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
131static int upmix_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) 125static 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
670static int mic_fmic_source_get(struct snd_kcontrol *ctl, 659static 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 55c52c7e19b..9f72d424969 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
310static int rolloff_get(struct snd_kcontrol *ctl, 304static int rolloff_get(struct snd_kcontrol *ctl,
diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c
index 7ed3284d7d5..cc610ac1fc1 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
225static int output_switch_get(struct snd_kcontrol *ctl, 219static 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
288static int hp_volume_offset_get(struct snd_kcontrol *ctl, 276static 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
401static int input_sel_get(struct snd_kcontrol *ctl, 384static 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
464static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) 442static 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 bf4fd4bb135..54cad38ec30 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
690static int rolloff_get(struct snd_kcontrol *ctl, 684static 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
760static int st_output_switch_get(struct snd_kcontrol *ctl, 748static 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
821static int st_hp_volume_offset_get(struct snd_kcontrol *ctl, 803static 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 ad48356c54e..42d1ab13621 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
612static int wm8776_field_volume_info(struct snd_kcontrol *ctl, 606static 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
875static int wm8776_level_control_get(struct snd_kcontrol *ctl, 864static 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
967static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) 950static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)