Skip to content

Commit 61d79c7

Browse files
takaswietiwai
authored andcommitted
ALSA: firewire-motu: localize protocol data
This commit adds enumerations of protocol version to localize protocol data. Signed-off-by: Takashi Sakamoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent c806a0e commit 61d79c7

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

sound/firewire/motu/amdtp-motu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
440440

441441
int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
442442
enum amdtp_stream_direction dir,
443-
const struct snd_motu_protocol *const protocol)
443+
const struct snd_motu_spec *spec)
444444
{
445445
amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
446446
int fmt = CIP_FMT_MOTU;
@@ -454,14 +454,15 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
454454
* Units of version 3 transmits packets with invalid CIP header
455455
* against IEC 61883-1.
456456
*/
457-
if (protocol == &snd_motu_protocol_v3) {
457+
if (spec->protocol_version == SND_MOTU_PROTOCOL_V3) {
458458
flags |= CIP_WRONG_DBS |
459459
CIP_SKIP_DBC_ZERO_CHECK |
460460
CIP_HEADER_WITHOUT_EOH;
461461
fmt = CIP_FMT_MOTU_TX_V3;
462462
}
463463

464-
if (protocol == &snd_motu_protocol_v2) {
464+
if (spec == &snd_motu_spec_8pre ||
465+
spec == &snd_motu_spec_ultralite) {
465466
// 8pre has some quirks.
466467
flags |= CIP_WRONG_DBS |
467468
CIP_SKIP_DBC_ZERO_CHECK;

sound/firewire/motu/motu-protocol-v2.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static int v2_cache_packet_formats(struct snd_motu *motu)
293293
return 0;
294294
}
295295

296-
const struct snd_motu_protocol snd_motu_protocol_v2 = {
296+
static const struct snd_motu_protocol snd_motu_protocol_v2 = {
297297
.get_clock_rate = v2_get_clock_rate,
298298
.set_clock_rate = v2_set_clock_rate,
299299
.get_clock_source = v2_get_clock_source,
@@ -303,6 +303,7 @@ const struct snd_motu_protocol snd_motu_protocol_v2 = {
303303

304304
const struct snd_motu_spec snd_motu_spec_828mk2 = {
305305
.name = "828mk2",
306+
.protocol_version = SND_MOTU_PROTOCOL_V2,
306307
.protocol = &snd_motu_protocol_v2,
307308
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
308309
SND_MOTU_SPEC_TX_MICINST_CHUNK |
@@ -319,6 +320,7 @@ const struct snd_motu_spec snd_motu_spec_828mk2 = {
319320
const struct snd_motu_spec snd_motu_spec_traveler = {
320321
.name = "Traveler",
321322
.protocol = &snd_motu_protocol_v2,
323+
.protocol_version = SND_MOTU_PROTOCOL_V2,
322324
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
323325
SND_MOTU_SPEC_SUPPORT_CLOCK_X4 |
324326
SND_MOTU_SPEC_TX_RETURN_CHUNK |
@@ -333,6 +335,7 @@ const struct snd_motu_spec snd_motu_spec_traveler = {
333335

334336
const struct snd_motu_spec snd_motu_spec_ultralite = {
335337
.name = "UltraLite",
338+
.protocol_version = SND_MOTU_PROTOCOL_V2,
336339
.protocol = &snd_motu_protocol_v2,
337340
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
338341
SND_MOTU_SPEC_TX_MICINST_CHUNK | // padding.
@@ -346,6 +349,7 @@ const struct snd_motu_spec snd_motu_spec_ultralite = {
346349

347350
const struct snd_motu_spec snd_motu_spec_8pre = {
348351
.name = "8pre",
352+
.protocol_version = SND_MOTU_PROTOCOL_V2,
349353
.protocol = &snd_motu_protocol_v2,
350354
// In tx, use coax chunks for mix-return 1/2. In rx, use coax chunks for
351355
// dummy 1/2.

sound/firewire/motu/motu-protocol-v3.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static int v3_cache_packet_formats(struct snd_motu *motu)
307307
return 0;
308308
}
309309

310-
const struct snd_motu_protocol snd_motu_protocol_v3 = {
310+
static const struct snd_motu_protocol snd_motu_protocol_v3 = {
311311
.get_clock_rate = v3_get_clock_rate,
312312
.set_clock_rate = v3_set_clock_rate,
313313
.get_clock_source = v3_get_clock_source,
@@ -317,6 +317,7 @@ const struct snd_motu_protocol snd_motu_protocol_v3 = {
317317

318318
const struct snd_motu_spec snd_motu_spec_828mk3 = {
319319
.name = "828mk3",
320+
.protocol_version = SND_MOTU_PROTOCOL_V3,
320321
.protocol = &snd_motu_protocol_v3,
321322
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
322323
SND_MOTU_SPEC_SUPPORT_CLOCK_X4 |
@@ -335,6 +336,7 @@ const struct snd_motu_spec snd_motu_spec_828mk3 = {
335336

336337
const struct snd_motu_spec snd_motu_spec_audio_express = {
337338
.name = "AudioExpress",
339+
.protocol_version = SND_MOTU_PROTOCOL_V3,
338340
.protocol = &snd_motu_protocol_v3,
339341
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
340342
SND_MOTU_SPEC_TX_MICINST_CHUNK |
@@ -348,6 +350,7 @@ const struct snd_motu_spec snd_motu_spec_audio_express = {
348350

349351
const struct snd_motu_spec snd_motu_spec_4pre = {
350352
.name = "4pre",
353+
.protocol_version = SND_MOTU_PROTOCOL_V3,
351354
.protocol = &snd_motu_protocol_v3,
352355
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
353356
SND_MOTU_SPEC_TX_MICINST_CHUNK |

sound/firewire/motu/motu-stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static int init_stream(struct snd_motu *motu, struct amdtp_stream *s)
317317
if (err < 0)
318318
return err;
319319

320-
err = amdtp_motu_init(s, motu->unit, dir, motu->spec->protocol);
320+
err = amdtp_motu_init(s, motu->unit, dir, motu->spec);
321321
if (err < 0)
322322
fw_iso_resources_destroy(resources);
323323

sound/firewire/motu/motu.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ enum snd_motu_clock_source {
108108
SND_MOTU_CLOCK_SOURCE_UNKNOWN,
109109
};
110110

111+
enum snd_motu_protocol_version {
112+
SND_MOTU_PROTOCOL_V2,
113+
SND_MOTU_PROTOCOL_V3,
114+
};
115+
111116
struct snd_motu_protocol {
112117
int (*get_clock_rate)(struct snd_motu *motu, unsigned int *rate);
113118
int (*set_clock_rate)(struct snd_motu *motu, unsigned int rate);
@@ -119,6 +124,7 @@ struct snd_motu_protocol {
119124

120125
struct snd_motu_spec {
121126
const char *const name;
127+
enum snd_motu_protocol_version protocol_version;
122128
enum snd_motu_spec_flags flags;
123129

124130
unsigned char analog_in_ports;
@@ -127,9 +133,6 @@ struct snd_motu_spec {
127133
const struct snd_motu_protocol *const protocol;
128134
};
129135

130-
extern const struct snd_motu_protocol snd_motu_protocol_v2;
131-
extern const struct snd_motu_protocol snd_motu_protocol_v3;
132-
133136
extern const struct snd_motu_spec snd_motu_spec_828mk2;
134137
extern const struct snd_motu_spec snd_motu_spec_traveler;
135138
extern const struct snd_motu_spec snd_motu_spec_ultralite;
@@ -141,7 +144,7 @@ extern const struct snd_motu_spec snd_motu_spec_4pre;
141144

142145
int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
143146
enum amdtp_stream_direction dir,
144-
const struct snd_motu_protocol *const protocol);
147+
const struct snd_motu_spec *spec);
145148
int amdtp_motu_set_parameters(struct amdtp_stream *s, unsigned int rate,
146149
unsigned int midi_ports,
147150
struct snd_motu_packet_format *formats);

0 commit comments

Comments
 (0)