diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-10-20 12:16:48 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-10-21 02:59:23 -0400 |
commit | 1541c66d3bb78c8a388025b074c75658c790b72f (patch) | |
tree | 593c4e563d1e67db4fa90fd65b15f44b566718c5 /sound/pci/emu10k1 | |
parent | c69a4f3046ee5a28ab09a1786a73d04bd6177445 (diff) |
ALSA: emu10k1: Use snd_ctl_enum_info()
... and reduce the open codes. Also add missing const to text arrays.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/emu10k1')
-rw-r--r-- | sound/pci/emu10k1/emumixer.c | 58 | ||||
-rw-r--r-- | sound/pci/emu10k1/p16v.c | 20 |
2 files changed, 17 insertions, 61 deletions
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index c5ae2a24d8a5..1de33025669a 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c | |||
@@ -83,7 +83,7 @@ static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol, | |||
83 | * Items labels in enum mixer controls assigning source data to | 83 | * Items labels in enum mixer controls assigning source data to |
84 | * each destination | 84 | * each destination |
85 | */ | 85 | */ |
86 | static char *emu1010_src_texts[] = { | 86 | static const char * const emu1010_src_texts[] = { |
87 | "Silence", | 87 | "Silence", |
88 | "Dock Mic A", | 88 | "Dock Mic A", |
89 | "Dock Mic B", | 89 | "Dock Mic B", |
@@ -141,7 +141,7 @@ static char *emu1010_src_texts[] = { | |||
141 | 141 | ||
142 | /* 1616(m) cardbus */ | 142 | /* 1616(m) cardbus */ |
143 | 143 | ||
144 | static char *emu1616_src_texts[] = { | 144 | static const char * const emu1616_src_texts[] = { |
145 | "Silence", | 145 | "Silence", |
146 | "Dock Mic A", | 146 | "Dock Mic A", |
147 | "Dock Mic B", | 147 | "Dock Mic B", |
@@ -393,23 +393,11 @@ static int snd_emu1010_input_output_source_info(struct snd_kcontrol *kcontrol, | |||
393 | struct snd_ctl_elem_info *uinfo) | 393 | struct snd_ctl_elem_info *uinfo) |
394 | { | 394 | { |
395 | struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); | 395 | struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); |
396 | char **items; | ||
397 | 396 | ||
398 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 397 | if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) |
399 | uinfo->count = 1; | 398 | return snd_ctl_enum_info(uinfo, 1, 49, emu1616_src_texts); |
400 | if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) { | 399 | else |
401 | uinfo->value.enumerated.items = 49; | 400 | return snd_ctl_enum_info(uinfo, 1, 53, emu1010_src_texts); |
402 | items = emu1616_src_texts; | ||
403 | } else { | ||
404 | uinfo->value.enumerated.items = 53; | ||
405 | items = emu1010_src_texts; | ||
406 | } | ||
407 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
408 | uinfo->value.enumerated.item = | ||
409 | uinfo->value.enumerated.items - 1; | ||
410 | strcpy(uinfo->value.enumerated.name, | ||
411 | items[uinfo->value.enumerated.item]); | ||
412 | return 0; | ||
413 | } | 401 | } |
414 | 402 | ||
415 | static int snd_emu1010_output_source_get(struct snd_kcontrol *kcontrol, | 403 | static int snd_emu1010_output_source_get(struct snd_kcontrol *kcontrol, |
@@ -699,19 +687,11 @@ static struct snd_kcontrol_new snd_emu1010_dac_pads[] = { | |||
699 | static int snd_emu1010_internal_clock_info(struct snd_kcontrol *kcontrol, | 687 | static int snd_emu1010_internal_clock_info(struct snd_kcontrol *kcontrol, |
700 | struct snd_ctl_elem_info *uinfo) | 688 | struct snd_ctl_elem_info *uinfo) |
701 | { | 689 | { |
702 | static char *texts[4] = { | 690 | static const char * const texts[4] = { |
703 | "44100", "48000", "SPDIF", "ADAT" | 691 | "44100", "48000", "SPDIF", "ADAT" |
704 | }; | 692 | }; |
705 | 693 | ||
706 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 694 | return snd_ctl_enum_info(uinfo, 1, 4, texts); |
707 | uinfo->count = 1; | ||
708 | uinfo->value.enumerated.items = 4; | ||
709 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
710 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | ||
711 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
712 | return 0; | ||
713 | |||
714 | |||
715 | } | 695 | } |
716 | 696 | ||
717 | static int snd_emu1010_internal_clock_get(struct snd_kcontrol *kcontrol, | 697 | static int snd_emu1010_internal_clock_get(struct snd_kcontrol *kcontrol, |
@@ -830,21 +810,15 @@ static int snd_audigy_i2c_capture_source_info(struct snd_kcontrol *kcontrol, | |||
830 | struct snd_ctl_elem_info *uinfo) | 810 | struct snd_ctl_elem_info *uinfo) |
831 | { | 811 | { |
832 | #if 0 | 812 | #if 0 |
833 | static char *texts[4] = { | 813 | static const char * const texts[4] = { |
834 | "Unknown1", "Unknown2", "Mic", "Line" | 814 | "Unknown1", "Unknown2", "Mic", "Line" |
835 | }; | 815 | }; |
836 | #endif | 816 | #endif |
837 | static char *texts[2] = { | 817 | static const char * const texts[2] = { |
838 | "Mic", "Line" | 818 | "Mic", "Line" |
839 | }; | 819 | }; |
840 | 820 | ||
841 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 821 | return snd_ctl_enum_info(uinfo, 1, 2, texts); |
842 | uinfo->count = 1; | ||
843 | uinfo->value.enumerated.items = 2; | ||
844 | if (uinfo->value.enumerated.item > 1) | ||
845 | uinfo->value.enumerated.item = 1; | ||
846 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
847 | return 0; | ||
848 | } | 822 | } |
849 | 823 | ||
850 | static int snd_audigy_i2c_capture_source_get(struct snd_kcontrol *kcontrol, | 824 | static int snd_audigy_i2c_capture_source_get(struct snd_kcontrol *kcontrol, |
@@ -997,15 +971,9 @@ static struct snd_kcontrol_new snd_audigy_i2c_volume_ctls[] = { | |||
997 | #if 0 | 971 | #if 0 |
998 | static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 972 | static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
999 | { | 973 | { |
1000 | static char *texts[] = {"44100", "48000", "96000"}; | 974 | static const char * const texts[] = {"44100", "48000", "96000"}; |
1001 | 975 | ||
1002 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 976 | return snd_ctl_enum_info(uinfo, 1, 3, texts); |
1003 | uinfo->count = 1; | ||
1004 | uinfo->value.enumerated.items = 3; | ||
1005 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
1006 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | ||
1007 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
1008 | return 0; | ||
1009 | } | 977 | } |
1010 | 978 | ||
1011 | static int snd_audigy_spdif_output_rate_get(struct snd_kcontrol *kcontrol, | 979 | static int snd_audigy_spdif_output_rate_get(struct snd_kcontrol *kcontrol, |
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index a4fe7f0c9458..7ef3898a7806 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c | |||
@@ -757,18 +757,12 @@ static int snd_p16v_volume_put(struct snd_kcontrol *kcontrol, | |||
757 | static int snd_p16v_capture_source_info(struct snd_kcontrol *kcontrol, | 757 | static int snd_p16v_capture_source_info(struct snd_kcontrol *kcontrol, |
758 | struct snd_ctl_elem_info *uinfo) | 758 | struct snd_ctl_elem_info *uinfo) |
759 | { | 759 | { |
760 | static char *texts[8] = { | 760 | static const char * const texts[8] = { |
761 | "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", | 761 | "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", |
762 | "CDIF", "FX", "AC97" | 762 | "CDIF", "FX", "AC97" |
763 | }; | 763 | }; |
764 | 764 | ||
765 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 765 | return snd_ctl_enum_info(uinfo, 1, 8, texts); |
766 | uinfo->count = 1; | ||
767 | uinfo->value.enumerated.items = 8; | ||
768 | if (uinfo->value.enumerated.item > 7) | ||
769 | uinfo->value.enumerated.item = 7; | ||
770 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
771 | return 0; | ||
772 | } | 766 | } |
773 | 767 | ||
774 | static int snd_p16v_capture_source_get(struct snd_kcontrol *kcontrol, | 768 | static int snd_p16v_capture_source_get(struct snd_kcontrol *kcontrol, |
@@ -805,15 +799,9 @@ static int snd_p16v_capture_source_put(struct snd_kcontrol *kcontrol, | |||
805 | static int snd_p16v_capture_channel_info(struct snd_kcontrol *kcontrol, | 799 | static int snd_p16v_capture_channel_info(struct snd_kcontrol *kcontrol, |
806 | struct snd_ctl_elem_info *uinfo) | 800 | struct snd_ctl_elem_info *uinfo) |
807 | { | 801 | { |
808 | static char *texts[4] = { "0", "1", "2", "3", }; | 802 | static const char * const texts[4] = { "0", "1", "2", "3", }; |
809 | 803 | ||
810 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 804 | return snd_ctl_enum_info(uinfo, 1, 4, texts); |
811 | uinfo->count = 1; | ||
812 | uinfo->value.enumerated.items = 4; | ||
813 | if (uinfo->value.enumerated.item > 3) | ||
814 | uinfo->value.enumerated.item = 3; | ||
815 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
816 | return 0; | ||
817 | } | 805 | } |
818 | 806 | ||
819 | static int snd_p16v_capture_channel_get(struct snd_kcontrol *kcontrol, | 807 | static int snd_p16v_capture_channel_get(struct snd_kcontrol *kcontrol, |