diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2015-06-13 23:49:29 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-06-15 07:34:47 -0400 |
commit | ba5177131d8cb4b778a43ce995155928be851117 (patch) | |
tree | 75f16bb07caade26f0bd97daa3d4075f15bd0ebc /sound/firewire | |
parent | 13a4f42016fecbf971c3f6e249027a009a83839f (diff) |
ALSA: bebob: preparation for replacing string literals by normalized representation for model-dependent structures
Previous commit adds a enumerator as a normalized representation of
clock source, while model-dependent structures still use string literals
for this purpose.
This commit is a preparation for replacement.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire')
-rw-r--r-- | sound/firewire/bebob/bebob_focusrite.c | 27 | ||||
-rw-r--r-- | sound/firewire/bebob/bebob_maudio.c | 13 | ||||
-rw-r--r-- | sound/firewire/bebob/bebob_terratec.c | 26 | ||||
-rw-r--r-- | sound/firewire/bebob/bebob_yamaha.c | 18 |
4 files changed, 72 insertions, 12 deletions
diff --git a/sound/firewire/bebob/bebob_focusrite.c b/sound/firewire/bebob/bebob_focusrite.c index fc67c1b7cb5b..45c8f76d8187 100644 --- a/sound/firewire/bebob/bebob_focusrite.c +++ b/sound/firewire/bebob/bebob_focusrite.c | |||
@@ -106,9 +106,21 @@ saffire_write_quad(struct snd_bebob *bebob, u64 offset, u32 value) | |||
106 | static const char *const saffirepro_10_clk_src_labels[] = { | 106 | static const char *const saffirepro_10_clk_src_labels[] = { |
107 | SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "Word Clock" | 107 | SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "Word Clock" |
108 | }; | 108 | }; |
109 | static enum snd_bebob_clock_type saffirepro_10_clk_src_types[] = { | ||
110 | SND_BEBOB_CLOCK_TYPE_INTERNAL, | ||
111 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ | ||
112 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* Word Clock */ | ||
113 | }; | ||
109 | static const char *const saffirepro_26_clk_src_labels[] = { | 114 | static const char *const saffirepro_26_clk_src_labels[] = { |
110 | SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "ADAT1", "ADAT2", "Word Clock" | 115 | SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "ADAT1", "ADAT2", "Word Clock" |
111 | }; | 116 | }; |
117 | static enum snd_bebob_clock_type saffirepro_26_clk_src_types[] = { | ||
118 | SND_BEBOB_CLOCK_TYPE_INTERNAL, | ||
119 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ | ||
120 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* ADAT1 */ | ||
121 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* ADAT2 */ | ||
122 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* Word Clock */ | ||
123 | }; | ||
112 | /* Value maps between registers and labels for SaffirePro 10/26. */ | 124 | /* Value maps between registers and labels for SaffirePro 10/26. */ |
113 | static const signed char saffirepro_clk_maps[][SAFFIREPRO_CLOCK_SOURCE_COUNT] = { | 125 | static const signed char saffirepro_clk_maps[][SAFFIREPRO_CLOCK_SOURCE_COUNT] = { |
114 | /* SaffirePro 10 */ | 126 | /* SaffirePro 10 */ |
@@ -178,7 +190,7 @@ saffirepro_both_clk_src_get(struct snd_bebob *bebob, unsigned int *id) | |||
178 | goto end; | 190 | goto end; |
179 | 191 | ||
180 | /* depending on hardware, use a different mapping */ | 192 | /* depending on hardware, use a different mapping */ |
181 | if (bebob->spec->clock->labels == saffirepro_10_clk_src_labels) | 193 | if (bebob->spec->clock->types == saffirepro_10_clk_src_types) |
182 | map = saffirepro_clk_maps[0]; | 194 | map = saffirepro_clk_maps[0]; |
183 | else | 195 | else |
184 | map = saffirepro_clk_maps[1]; | 196 | map = saffirepro_clk_maps[1]; |
@@ -198,6 +210,10 @@ struct snd_bebob_spec saffire_le_spec; | |||
198 | static const char *const saffire_both_clk_src_labels[] = { | 210 | static const char *const saffire_both_clk_src_labels[] = { |
199 | SND_BEBOB_CLOCK_INTERNAL, "S/PDIF" | 211 | SND_BEBOB_CLOCK_INTERNAL, "S/PDIF" |
200 | }; | 212 | }; |
213 | static enum snd_bebob_clock_type saffire_both_clk_src_types[] = { | ||
214 | SND_BEBOB_CLOCK_TYPE_INTERNAL, | ||
215 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, | ||
216 | }; | ||
201 | static int | 217 | static int |
202 | saffire_both_clk_src_get(struct snd_bebob *bebob, unsigned int *id) | 218 | saffire_both_clk_src_get(struct snd_bebob *bebob, unsigned int *id) |
203 | { | 219 | { |
@@ -259,8 +275,9 @@ static struct snd_bebob_rate_spec saffirepro_both_rate_spec = { | |||
259 | }; | 275 | }; |
260 | /* Saffire Pro 26 I/O */ | 276 | /* Saffire Pro 26 I/O */ |
261 | static struct snd_bebob_clock_spec saffirepro_26_clk_spec = { | 277 | static struct snd_bebob_clock_spec saffirepro_26_clk_spec = { |
262 | .num = ARRAY_SIZE(saffirepro_26_clk_src_labels), | 278 | .num = ARRAY_SIZE(saffirepro_26_clk_src_types), |
263 | .labels = saffirepro_26_clk_src_labels, | 279 | .labels = saffirepro_26_clk_src_labels, |
280 | .types = saffirepro_26_clk_src_types, | ||
264 | .get = &saffirepro_both_clk_src_get, | 281 | .get = &saffirepro_both_clk_src_get, |
265 | }; | 282 | }; |
266 | struct snd_bebob_spec saffirepro_26_spec = { | 283 | struct snd_bebob_spec saffirepro_26_spec = { |
@@ -270,8 +287,9 @@ struct snd_bebob_spec saffirepro_26_spec = { | |||
270 | }; | 287 | }; |
271 | /* Saffire Pro 10 I/O */ | 288 | /* Saffire Pro 10 I/O */ |
272 | static struct snd_bebob_clock_spec saffirepro_10_clk_spec = { | 289 | static struct snd_bebob_clock_spec saffirepro_10_clk_spec = { |
273 | .num = ARRAY_SIZE(saffirepro_10_clk_src_labels), | 290 | .num = ARRAY_SIZE(saffirepro_10_clk_src_types), |
274 | .labels = saffirepro_10_clk_src_labels, | 291 | .labels = saffirepro_10_clk_src_labels, |
292 | .types = saffirepro_10_clk_src_types, | ||
275 | .get = &saffirepro_both_clk_src_get, | 293 | .get = &saffirepro_both_clk_src_get, |
276 | }; | 294 | }; |
277 | struct snd_bebob_spec saffirepro_10_spec = { | 295 | struct snd_bebob_spec saffirepro_10_spec = { |
@@ -285,8 +303,9 @@ static struct snd_bebob_rate_spec saffire_both_rate_spec = { | |||
285 | .set = &snd_bebob_stream_set_rate, | 303 | .set = &snd_bebob_stream_set_rate, |
286 | }; | 304 | }; |
287 | static struct snd_bebob_clock_spec saffire_both_clk_spec = { | 305 | static struct snd_bebob_clock_spec saffire_both_clk_spec = { |
288 | .num = ARRAY_SIZE(saffire_both_clk_src_labels), | 306 | .num = ARRAY_SIZE(saffire_both_clk_src_types), |
289 | .labels = saffire_both_clk_src_labels, | 307 | .labels = saffire_both_clk_src_labels, |
308 | .types = saffire_both_clk_src_types, | ||
290 | .get = &saffire_both_clk_src_get, | 309 | .get = &saffire_both_clk_src_get, |
291 | }; | 310 | }; |
292 | /* Saffire LE */ | 311 | /* Saffire LE */ |
diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c index 9ee25a63f684..7a43afcfa9bd 100644 --- a/sound/firewire/bebob/bebob_maudio.c +++ b/sound/firewire/bebob/bebob_maudio.c | |||
@@ -343,6 +343,12 @@ end: | |||
343 | static const char *const special_clk_labels[] = { | 343 | static const char *const special_clk_labels[] = { |
344 | SND_BEBOB_CLOCK_INTERNAL " with Digital Mute", "Digital", | 344 | SND_BEBOB_CLOCK_INTERNAL " with Digital Mute", "Digital", |
345 | "Word Clock", SND_BEBOB_CLOCK_INTERNAL}; | 345 | "Word Clock", SND_BEBOB_CLOCK_INTERNAL}; |
346 | static enum snd_bebob_clock_type special_clk_types[] = { | ||
347 | SND_BEBOB_CLOCK_TYPE_INTERNAL, /* With digital mute */ | ||
348 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* SPDIF/ADAT */ | ||
349 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* Word Clock */ | ||
350 | SND_BEBOB_CLOCK_TYPE_INTERNAL, | ||
351 | }; | ||
346 | static int special_clk_get(struct snd_bebob *bebob, unsigned int *id) | 352 | static int special_clk_get(struct snd_bebob *bebob, unsigned int *id) |
347 | { | 353 | { |
348 | struct special_params *params = bebob->maudio_special_quirk; | 354 | struct special_params *params = bebob->maudio_special_quirk; |
@@ -352,7 +358,7 @@ static int special_clk_get(struct snd_bebob *bebob, unsigned int *id) | |||
352 | static int special_clk_ctl_info(struct snd_kcontrol *kctl, | 358 | static int special_clk_ctl_info(struct snd_kcontrol *kctl, |
353 | struct snd_ctl_elem_info *einf) | 359 | struct snd_ctl_elem_info *einf) |
354 | { | 360 | { |
355 | return snd_ctl_enum_info(einf, 1, ARRAY_SIZE(special_clk_labels), | 361 | return snd_ctl_enum_info(einf, 1, ARRAY_SIZE(special_clk_types), |
356 | special_clk_labels); | 362 | special_clk_labels); |
357 | } | 363 | } |
358 | static int special_clk_ctl_get(struct snd_kcontrol *kctl, | 364 | static int special_clk_ctl_get(struct snd_kcontrol *kctl, |
@@ -371,7 +377,7 @@ static int special_clk_ctl_put(struct snd_kcontrol *kctl, | |||
371 | int err, id; | 377 | int err, id; |
372 | 378 | ||
373 | id = uval->value.enumerated.item[0]; | 379 | id = uval->value.enumerated.item[0]; |
374 | if (id >= ARRAY_SIZE(special_clk_labels)) | 380 | if (id >= ARRAY_SIZE(special_clk_types)) |
375 | return -EINVAL; | 381 | return -EINVAL; |
376 | 382 | ||
377 | mutex_lock(&bebob->mutex); | 383 | mutex_lock(&bebob->mutex); |
@@ -708,8 +714,9 @@ static struct snd_bebob_rate_spec special_rate_spec = { | |||
708 | .set = &special_set_rate, | 714 | .set = &special_set_rate, |
709 | }; | 715 | }; |
710 | static struct snd_bebob_clock_spec special_clk_spec = { | 716 | static struct snd_bebob_clock_spec special_clk_spec = { |
711 | .num = ARRAY_SIZE(special_clk_labels), | 717 | .num = ARRAY_SIZE(special_clk_types), |
712 | .labels = special_clk_labels, | 718 | .labels = special_clk_labels, |
719 | .types = special_clk_types, | ||
713 | .get = &special_clk_get, | 720 | .get = &special_clk_get, |
714 | }; | 721 | }; |
715 | static struct snd_bebob_meter_spec special_meter_spec = { | 722 | static struct snd_bebob_meter_spec special_meter_spec = { |
diff --git a/sound/firewire/bebob/bebob_terratec.c b/sound/firewire/bebob/bebob_terratec.c index ad635004d699..3b64d8db8e14 100644 --- a/sound/firewire/bebob/bebob_terratec.c +++ b/sound/firewire/bebob/bebob_terratec.c | |||
@@ -11,6 +11,11 @@ | |||
11 | static const char *const phase88_rack_clk_src_labels[] = { | 11 | static const char *const phase88_rack_clk_src_labels[] = { |
12 | SND_BEBOB_CLOCK_INTERNAL, "Digital In", "Word Clock" | 12 | SND_BEBOB_CLOCK_INTERNAL, "Digital In", "Word Clock" |
13 | }; | 13 | }; |
14 | static enum snd_bebob_clock_type phase88_rack_clk_src_types[] = { | ||
15 | SND_BEBOB_CLOCK_TYPE_INTERNAL, | ||
16 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ | ||
17 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* Word Clock */ | ||
18 | }; | ||
14 | static int | 19 | static int |
15 | phase88_rack_clk_src_get(struct snd_bebob *bebob, unsigned int *id) | 20 | phase88_rack_clk_src_get(struct snd_bebob *bebob, unsigned int *id) |
16 | { | 21 | { |
@@ -37,10 +42,23 @@ end: | |||
37 | static const char *const phase24_series_clk_src_labels[] = { | 42 | static const char *const phase24_series_clk_src_labels[] = { |
38 | SND_BEBOB_CLOCK_INTERNAL, "Digital In" | 43 | SND_BEBOB_CLOCK_INTERNAL, "Digital In" |
39 | }; | 44 | }; |
45 | static enum snd_bebob_clock_type phase24_series_clk_src_types[] = { | ||
46 | SND_BEBOB_CLOCK_TYPE_INTERNAL, | ||
47 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ | ||
48 | }; | ||
40 | static int | 49 | static int |
41 | phase24_series_clk_src_get(struct snd_bebob *bebob, unsigned int *id) | 50 | phase24_series_clk_src_get(struct snd_bebob *bebob, unsigned int *id) |
42 | { | 51 | { |
43 | return avc_audio_get_selector(bebob->unit, 0, 4, id); | 52 | int err; |
53 | |||
54 | err = avc_audio_get_selector(bebob->unit, 0, 4, id); | ||
55 | if (err < 0) | ||
56 | return err; | ||
57 | |||
58 | if (*id >= ARRAY_SIZE(phase24_series_clk_src_types)) | ||
59 | return -EIO; | ||
60 | |||
61 | return 0; | ||
44 | } | 62 | } |
45 | 63 | ||
46 | static struct snd_bebob_rate_spec phase_series_rate_spec = { | 64 | static struct snd_bebob_rate_spec phase_series_rate_spec = { |
@@ -50,8 +68,9 @@ static struct snd_bebob_rate_spec phase_series_rate_spec = { | |||
50 | 68 | ||
51 | /* PHASE 88 Rack FW */ | 69 | /* PHASE 88 Rack FW */ |
52 | static struct snd_bebob_clock_spec phase88_rack_clk = { | 70 | static struct snd_bebob_clock_spec phase88_rack_clk = { |
53 | .num = ARRAY_SIZE(phase88_rack_clk_src_labels), | 71 | .num = ARRAY_SIZE(phase88_rack_clk_src_types), |
54 | .labels = phase88_rack_clk_src_labels, | 72 | .labels = phase88_rack_clk_src_labels, |
73 | .types = phase88_rack_clk_src_types, | ||
55 | .get = &phase88_rack_clk_src_get, | 74 | .get = &phase88_rack_clk_src_get, |
56 | }; | 75 | }; |
57 | struct snd_bebob_spec phase88_rack_spec = { | 76 | struct snd_bebob_spec phase88_rack_spec = { |
@@ -62,8 +81,9 @@ struct snd_bebob_spec phase88_rack_spec = { | |||
62 | 81 | ||
63 | /* 'PHASE 24 FW' and 'PHASE X24 FW' */ | 82 | /* 'PHASE 24 FW' and 'PHASE X24 FW' */ |
64 | static struct snd_bebob_clock_spec phase24_series_clk = { | 83 | static struct snd_bebob_clock_spec phase24_series_clk = { |
65 | .num = ARRAY_SIZE(phase24_series_clk_src_labels), | 84 | .num = ARRAY_SIZE(phase24_series_clk_src_types), |
66 | .labels = phase24_series_clk_src_labels, | 85 | .labels = phase24_series_clk_src_labels, |
86 | .types = phase24_series_clk_src_types, | ||
67 | .get = &phase24_series_clk_src_get, | 87 | .get = &phase24_series_clk_src_get, |
68 | }; | 88 | }; |
69 | struct snd_bebob_spec phase24_series_spec = { | 89 | struct snd_bebob_spec phase24_series_spec = { |
diff --git a/sound/firewire/bebob/bebob_yamaha.c b/sound/firewire/bebob/bebob_yamaha.c index ef1fe3823a9c..2f59512ad91e 100644 --- a/sound/firewire/bebob/bebob_yamaha.c +++ b/sound/firewire/bebob/bebob_yamaha.c | |||
@@ -29,13 +29,27 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | static const char *const clk_src_labels[] = {SND_BEBOB_CLOCK_INTERNAL, "SPDIF"}; | 31 | static const char *const clk_src_labels[] = {SND_BEBOB_CLOCK_INTERNAL, "SPDIF"}; |
32 | static enum snd_bebob_clock_type clk_src_types[] = { | ||
33 | SND_BEBOB_CLOCK_TYPE_INTERNAL, | ||
34 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ | ||
35 | }; | ||
32 | static int | 36 | static int |
33 | clk_src_get(struct snd_bebob *bebob, unsigned int *id) | 37 | clk_src_get(struct snd_bebob *bebob, unsigned int *id) |
34 | { | 38 | { |
35 | return avc_audio_get_selector(bebob->unit, 0, 4, id); | 39 | int err; |
40 | |||
41 | err = avc_audio_get_selector(bebob->unit, 0, 4, id); | ||
42 | if (err < 0) | ||
43 | return err; | ||
44 | |||
45 | if (*id >= ARRAY_SIZE(clk_src_types)) | ||
46 | return -EIO; | ||
47 | |||
48 | return 0; | ||
36 | } | 49 | } |
37 | static struct snd_bebob_clock_spec clock_spec = { | 50 | static struct snd_bebob_clock_spec clock_spec = { |
38 | .num = ARRAY_SIZE(clk_src_labels), | 51 | .num = ARRAY_SIZE(clk_src_types), |
52 | .types = clk_src_types, | ||
39 | .labels = clk_src_labels, | 53 | .labels = clk_src_labels, |
40 | .get = &clk_src_get, | 54 | .get = &clk_src_get, |
41 | }; | 55 | }; |