diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-10-20 12:19:53 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-10-21 03:12:11 -0400 |
commit | 7298ece7a26753b073a9ce5f979a4942d3904d44 (patch) | |
tree | 5ca8d32b5daacff024fcafb02dac7f0166917bc2 | |
parent | c69a637b4df37fc5a011a89e422636ea393af5b0 (diff) |
ALSA: rme9652: 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/rme9652/rme9652.c | 58 |
1 files changed, 18 insertions, 40 deletions
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index fa9a2a8dce5a..6521521853b8 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c | |||
@@ -920,15 +920,9 @@ static int rme9652_set_adat1_input(struct snd_rme9652 *rme9652, int internal) | |||
920 | 920 | ||
921 | static int snd_rme9652_info_adat1_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 921 | static int snd_rme9652_info_adat1_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
922 | { | 922 | { |
923 | static char *texts[2] = {"ADAT1", "Internal"}; | 923 | static const char * const texts[2] = {"ADAT1", "Internal"}; |
924 | 924 | ||
925 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 925 | return snd_ctl_enum_info(uinfo, 1, 2, texts); |
926 | uinfo->count = 1; | ||
927 | uinfo->value.enumerated.items = 2; | ||
928 | if (uinfo->value.enumerated.item > 1) | ||
929 | uinfo->value.enumerated.item = 1; | ||
930 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
931 | return 0; | ||
932 | } | 926 | } |
933 | 927 | ||
934 | static int snd_rme9652_get_adat1_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 928 | static int snd_rme9652_get_adat1_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
@@ -991,15 +985,9 @@ static int rme9652_set_spdif_input(struct snd_rme9652 *rme9652, int in) | |||
991 | 985 | ||
992 | static int snd_rme9652_info_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 986 | static int snd_rme9652_info_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
993 | { | 987 | { |
994 | static char *texts[3] = {"ADAT1", "Coaxial", "Internal"}; | 988 | static const char * const texts[3] = {"ADAT1", "Coaxial", "Internal"}; |
995 | 989 | ||
996 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 990 | return snd_ctl_enum_info(uinfo, 1, 3, texts); |
997 | uinfo->count = 1; | ||
998 | uinfo->value.enumerated.items = 3; | ||
999 | if (uinfo->value.enumerated.item > 2) | ||
1000 | uinfo->value.enumerated.item = 2; | ||
1001 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
1002 | return 0; | ||
1003 | } | 991 | } |
1004 | 992 | ||
1005 | static int snd_rme9652_get_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 993 | static int snd_rme9652_get_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
@@ -1140,15 +1128,11 @@ static int rme9652_set_sync_mode(struct snd_rme9652 *rme9652, int mode) | |||
1140 | 1128 | ||
1141 | static int snd_rme9652_info_sync_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 1129 | static int snd_rme9652_info_sync_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1142 | { | 1130 | { |
1143 | static char *texts[3] = {"AutoSync", "Master", "Word Clock"}; | 1131 | static const char * const texts[3] = { |
1132 | "AutoSync", "Master", "Word Clock" | ||
1133 | }; | ||
1144 | 1134 | ||
1145 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 1135 | return snd_ctl_enum_info(uinfo, 1, 3, texts); |
1146 | uinfo->count = 1; | ||
1147 | uinfo->value.enumerated.items = 3; | ||
1148 | if (uinfo->value.enumerated.item > 2) | ||
1149 | uinfo->value.enumerated.item = 2; | ||
1150 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
1151 | return 0; | ||
1152 | } | 1136 | } |
1153 | 1137 | ||
1154 | static int snd_rme9652_get_sync_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 1138 | static int snd_rme9652_get_sync_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
@@ -1231,16 +1215,14 @@ static int rme9652_set_sync_pref(struct snd_rme9652 *rme9652, int pref) | |||
1231 | 1215 | ||
1232 | static int snd_rme9652_info_sync_pref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 1216 | static int snd_rme9652_info_sync_pref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1233 | { | 1217 | { |
1234 | static char *texts[4] = {"IEC958 In", "ADAT1 In", "ADAT2 In", "ADAT3 In"}; | 1218 | static const char * const texts[4] = { |
1219 | "IEC958 In", "ADAT1 In", "ADAT2 In", "ADAT3 In" | ||
1220 | }; | ||
1235 | struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); | 1221 | struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); |
1236 | 1222 | ||
1237 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 1223 | return snd_ctl_enum_info(uinfo, 1, |
1238 | uinfo->count = 1; | 1224 | rme9652->ss_channels == RME9652_NCHANNELS ? 4 : 3, |
1239 | uinfo->value.enumerated.items = rme9652->ss_channels == RME9652_NCHANNELS ? 4 : 3; | 1225 | texts); |
1240 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
1241 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | ||
1242 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
1243 | return 0; | ||
1244 | } | 1226 | } |
1245 | 1227 | ||
1246 | static int snd_rme9652_get_sync_pref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 1228 | static int snd_rme9652_get_sync_pref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
@@ -1392,15 +1374,11 @@ static int snd_rme9652_get_spdif_rate(struct snd_kcontrol *kcontrol, struct snd_ | |||
1392 | 1374 | ||
1393 | static int snd_rme9652_info_adat_sync(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 1375 | static int snd_rme9652_info_adat_sync(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1394 | { | 1376 | { |
1395 | static char *texts[4] = {"No Lock", "Lock", "No Lock Sync", "Lock Sync"}; | 1377 | static const char * const texts[4] = { |
1378 | "No Lock", "Lock", "No Lock Sync", "Lock Sync" | ||
1379 | }; | ||
1396 | 1380 | ||
1397 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 1381 | return snd_ctl_enum_info(uinfo, 1, 4, texts); |
1398 | uinfo->count = 1; | ||
1399 | uinfo->value.enumerated.items = 4; | ||
1400 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
1401 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | ||
1402 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
1403 | return 0; | ||
1404 | } | 1382 | } |
1405 | 1383 | ||
1406 | static int snd_rme9652_get_adat_sync(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 1384 | static int snd_rme9652_get_adat_sync(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |