aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-10-20 12:16:38 -0400
committerTakashi Iwai <tiwai@suse.de>2014-10-21 02:56:28 -0400
commitc69a4f3046ee5a28ab09a1786a73d04bd6177445 (patch)
tree14fb0a5541e38e870c08629268959f7777573f7f
parentde95eae25a2744ba5f9bd3c862bb43a1b177ad58 (diff)
ALSA: echoaudio: 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>
-rw-r--r--sound/pci/echoaudio/echoaudio.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 631aaa4046ad..d82321ff549b 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -1416,21 +1416,14 @@ static struct snd_kcontrol_new snd_echo_vmixer = {
1416static int snd_echo_digital_mode_info(struct snd_kcontrol *kcontrol, 1416static int snd_echo_digital_mode_info(struct snd_kcontrol *kcontrol,
1417 struct snd_ctl_elem_info *uinfo) 1417 struct snd_ctl_elem_info *uinfo)
1418{ 1418{
1419 static char *names[4] = { 1419 static const char * const names[4] = {
1420 "S/PDIF Coaxial", "S/PDIF Optical", "ADAT Optical", 1420 "S/PDIF Coaxial", "S/PDIF Optical", "ADAT Optical",
1421 "S/PDIF Cdrom" 1421 "S/PDIF Cdrom"
1422 }; 1422 };
1423 struct echoaudio *chip; 1423 struct echoaudio *chip;
1424 1424
1425 chip = snd_kcontrol_chip(kcontrol); 1425 chip = snd_kcontrol_chip(kcontrol);
1426 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1426 return snd_ctl_enum_info(uinfo, 1, chip->num_digital_modes, names);
1427 uinfo->value.enumerated.items = chip->num_digital_modes;
1428 uinfo->count = 1;
1429 if (uinfo->value.enumerated.item >= chip->num_digital_modes)
1430 uinfo->value.enumerated.item = chip->num_digital_modes - 1;
1431 strcpy(uinfo->value.enumerated.name, names[
1432 chip->digital_mode_list[uinfo->value.enumerated.item]]);
1433 return 0;
1434} 1427}
1435 1428
1436static int snd_echo_digital_mode_get(struct snd_kcontrol *kcontrol, 1429static int snd_echo_digital_mode_get(struct snd_kcontrol *kcontrol,
@@ -1509,16 +1502,9 @@ static struct snd_kcontrol_new snd_echo_digital_mode_switch = {
1509static int snd_echo_spdif_mode_info(struct snd_kcontrol *kcontrol, 1502static int snd_echo_spdif_mode_info(struct snd_kcontrol *kcontrol,
1510 struct snd_ctl_elem_info *uinfo) 1503 struct snd_ctl_elem_info *uinfo)
1511{ 1504{
1512 static char *names[2] = {"Consumer", "Professional"}; 1505 static const char * const names[2] = {"Consumer", "Professional"};
1513 1506
1514 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1507 return snd_ctl_enum_info(uinfo, 1, 2, names);
1515 uinfo->value.enumerated.items = 2;
1516 uinfo->count = 1;
1517 if (uinfo->value.enumerated.item)
1518 uinfo->value.enumerated.item = 1;
1519 strcpy(uinfo->value.enumerated.name,
1520 names[uinfo->value.enumerated.item]);
1521 return 0;
1522} 1508}
1523 1509
1524static int snd_echo_spdif_mode_get(struct snd_kcontrol *kcontrol, 1510static int snd_echo_spdif_mode_get(struct snd_kcontrol *kcontrol,
@@ -1566,21 +1552,14 @@ static struct snd_kcontrol_new snd_echo_spdif_mode_switch = {
1566static int snd_echo_clock_source_info(struct snd_kcontrol *kcontrol, 1552static int snd_echo_clock_source_info(struct snd_kcontrol *kcontrol,
1567 struct snd_ctl_elem_info *uinfo) 1553 struct snd_ctl_elem_info *uinfo)
1568{ 1554{
1569 static char *names[8] = { 1555 static const char * const names[8] = {
1570 "Internal", "Word", "Super", "S/PDIF", "ADAT", "ESync", 1556 "Internal", "Word", "Super", "S/PDIF", "ADAT", "ESync",
1571 "ESync96", "MTC" 1557 "ESync96", "MTC"
1572 }; 1558 };
1573 struct echoaudio *chip; 1559 struct echoaudio *chip;
1574 1560
1575 chip = snd_kcontrol_chip(kcontrol); 1561 chip = snd_kcontrol_chip(kcontrol);
1576 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1562 return snd_ctl_enum_info(uinfo, 1, chip->num_clock_sources, names);
1577 uinfo->value.enumerated.items = chip->num_clock_sources;
1578 uinfo->count = 1;
1579 if (uinfo->value.enumerated.item >= chip->num_clock_sources)
1580 uinfo->value.enumerated.item = chip->num_clock_sources - 1;
1581 strcpy(uinfo->value.enumerated.name, names[
1582 chip->clock_source_list[uinfo->value.enumerated.item]]);
1583 return 0;
1584} 1563}
1585 1564
1586static int snd_echo_clock_source_get(struct snd_kcontrol *kcontrol, 1565static int snd_echo_clock_source_get(struct snd_kcontrol *kcontrol,