aboutsummaryrefslogtreecommitdiffstats
path: root/sound/firewire
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2015-06-13 23:49:29 -0400
committerTakashi Iwai <tiwai@suse.de>2015-06-15 07:34:47 -0400
commitba5177131d8cb4b778a43ce995155928be851117 (patch)
tree75f16bb07caade26f0bd97daa3d4075f15bd0ebc /sound/firewire
parent13a4f42016fecbf971c3f6e249027a009a83839f (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.c27
-rw-r--r--sound/firewire/bebob/bebob_maudio.c13
-rw-r--r--sound/firewire/bebob/bebob_terratec.c26
-rw-r--r--sound/firewire/bebob/bebob_yamaha.c18
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)
106static const char *const saffirepro_10_clk_src_labels[] = { 106static 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};
109static 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};
109static const char *const saffirepro_26_clk_src_labels[] = { 114static 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};
117static 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. */
113static const signed char saffirepro_clk_maps[][SAFFIREPRO_CLOCK_SOURCE_COUNT] = { 125static 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;
198static const char *const saffire_both_clk_src_labels[] = { 210static const char *const saffire_both_clk_src_labels[] = {
199 SND_BEBOB_CLOCK_INTERNAL, "S/PDIF" 211 SND_BEBOB_CLOCK_INTERNAL, "S/PDIF"
200}; 212};
213static enum snd_bebob_clock_type saffire_both_clk_src_types[] = {
214 SND_BEBOB_CLOCK_TYPE_INTERNAL,
215 SND_BEBOB_CLOCK_TYPE_EXTERNAL,
216};
201static int 217static int
202saffire_both_clk_src_get(struct snd_bebob *bebob, unsigned int *id) 218saffire_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 */
261static struct snd_bebob_clock_spec saffirepro_26_clk_spec = { 277static 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};
266struct snd_bebob_spec saffirepro_26_spec = { 283struct 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 */
272static struct snd_bebob_clock_spec saffirepro_10_clk_spec = { 289static 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};
277struct snd_bebob_spec saffirepro_10_spec = { 295struct 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};
287static struct snd_bebob_clock_spec saffire_both_clk_spec = { 305static 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:
343static const char *const special_clk_labels[] = { 343static 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};
346static 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};
346static int special_clk_get(struct snd_bebob *bebob, unsigned int *id) 352static 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)
352static int special_clk_ctl_info(struct snd_kcontrol *kctl, 358static 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}
358static int special_clk_ctl_get(struct snd_kcontrol *kctl, 364static 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};
710static struct snd_bebob_clock_spec special_clk_spec = { 716static 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};
715static struct snd_bebob_meter_spec special_meter_spec = { 722static 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 @@
11static const char *const phase88_rack_clk_src_labels[] = { 11static 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};
14static 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};
14static int 19static int
15phase88_rack_clk_src_get(struct snd_bebob *bebob, unsigned int *id) 20phase88_rack_clk_src_get(struct snd_bebob *bebob, unsigned int *id)
16{ 21{
@@ -37,10 +42,23 @@ end:
37static const char *const phase24_series_clk_src_labels[] = { 42static const char *const phase24_series_clk_src_labels[] = {
38 SND_BEBOB_CLOCK_INTERNAL, "Digital In" 43 SND_BEBOB_CLOCK_INTERNAL, "Digital In"
39}; 44};
45static 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};
40static int 49static int
41phase24_series_clk_src_get(struct snd_bebob *bebob, unsigned int *id) 50phase24_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
46static struct snd_bebob_rate_spec phase_series_rate_spec = { 64static 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 */
52static struct snd_bebob_clock_spec phase88_rack_clk = { 70static 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};
57struct snd_bebob_spec phase88_rack_spec = { 76struct 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' */
64static struct snd_bebob_clock_spec phase24_series_clk = { 83static 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};
69struct snd_bebob_spec phase24_series_spec = { 89struct 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
31static const char *const clk_src_labels[] = {SND_BEBOB_CLOCK_INTERNAL, "SPDIF"}; 31static const char *const clk_src_labels[] = {SND_BEBOB_CLOCK_INTERNAL, "SPDIF"};
32static enum snd_bebob_clock_type clk_src_types[] = {
33 SND_BEBOB_CLOCK_TYPE_INTERNAL,
34 SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */
35};
32static int 36static int
33clk_src_get(struct snd_bebob *bebob, unsigned int *id) 37clk_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}
37static struct snd_bebob_clock_spec clock_spec = { 50static 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};