ALSA: firewire-motu: localize protocol data

This commit adds enumerations of protocol version to localize protocol
data.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200519111641.123211-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Sakamoto 2020-05-19 20:16:30 +09:00 committed by Takashi Iwai
parent c806a0e228
commit 61d79c70c9
5 changed files with 21 additions and 10 deletions

View File

@ -440,7 +440,7 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir,
const struct snd_motu_protocol *const protocol)
const struct snd_motu_spec *spec)
{
amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
int fmt = CIP_FMT_MOTU;
@ -454,14 +454,15 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
* Units of version 3 transmits packets with invalid CIP header
* against IEC 61883-1.
*/
if (protocol == &snd_motu_protocol_v3) {
if (spec->protocol_version == SND_MOTU_PROTOCOL_V3) {
flags |= CIP_WRONG_DBS |
CIP_SKIP_DBC_ZERO_CHECK |
CIP_HEADER_WITHOUT_EOH;
fmt = CIP_FMT_MOTU_TX_V3;
}
if (protocol == &snd_motu_protocol_v2) {
if (spec == &snd_motu_spec_8pre ||
spec == &snd_motu_spec_ultralite) {
// 8pre has some quirks.
flags |= CIP_WRONG_DBS |
CIP_SKIP_DBC_ZERO_CHECK;

View File

@ -293,7 +293,7 @@ static int v2_cache_packet_formats(struct snd_motu *motu)
return 0;
}
const struct snd_motu_protocol snd_motu_protocol_v2 = {
static const struct snd_motu_protocol snd_motu_protocol_v2 = {
.get_clock_rate = v2_get_clock_rate,
.set_clock_rate = v2_set_clock_rate,
.get_clock_source = v2_get_clock_source,
@ -303,6 +303,7 @@ const struct snd_motu_protocol snd_motu_protocol_v2 = {
const struct snd_motu_spec snd_motu_spec_828mk2 = {
.name = "828mk2",
.protocol_version = SND_MOTU_PROTOCOL_V2,
.protocol = &snd_motu_protocol_v2,
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
SND_MOTU_SPEC_TX_MICINST_CHUNK |
@ -319,6 +320,7 @@ const struct snd_motu_spec snd_motu_spec_828mk2 = {
const struct snd_motu_spec snd_motu_spec_traveler = {
.name = "Traveler",
.protocol = &snd_motu_protocol_v2,
.protocol_version = SND_MOTU_PROTOCOL_V2,
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
SND_MOTU_SPEC_SUPPORT_CLOCK_X4 |
SND_MOTU_SPEC_TX_RETURN_CHUNK |
@ -333,6 +335,7 @@ const struct snd_motu_spec snd_motu_spec_traveler = {
const struct snd_motu_spec snd_motu_spec_ultralite = {
.name = "UltraLite",
.protocol_version = SND_MOTU_PROTOCOL_V2,
.protocol = &snd_motu_protocol_v2,
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
SND_MOTU_SPEC_TX_MICINST_CHUNK | // padding.
@ -346,6 +349,7 @@ const struct snd_motu_spec snd_motu_spec_ultralite = {
const struct snd_motu_spec snd_motu_spec_8pre = {
.name = "8pre",
.protocol_version = SND_MOTU_PROTOCOL_V2,
.protocol = &snd_motu_protocol_v2,
// In tx, use coax chunks for mix-return 1/2. In rx, use coax chunks for
// dummy 1/2.

View File

@ -307,7 +307,7 @@ static int v3_cache_packet_formats(struct snd_motu *motu)
return 0;
}
const struct snd_motu_protocol snd_motu_protocol_v3 = {
static const struct snd_motu_protocol snd_motu_protocol_v3 = {
.get_clock_rate = v3_get_clock_rate,
.set_clock_rate = v3_set_clock_rate,
.get_clock_source = v3_get_clock_source,
@ -317,6 +317,7 @@ const struct snd_motu_protocol snd_motu_protocol_v3 = {
const struct snd_motu_spec snd_motu_spec_828mk3 = {
.name = "828mk3",
.protocol_version = SND_MOTU_PROTOCOL_V3,
.protocol = &snd_motu_protocol_v3,
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
SND_MOTU_SPEC_SUPPORT_CLOCK_X4 |
@ -335,6 +336,7 @@ const struct snd_motu_spec snd_motu_spec_828mk3 = {
const struct snd_motu_spec snd_motu_spec_audio_express = {
.name = "AudioExpress",
.protocol_version = SND_MOTU_PROTOCOL_V3,
.protocol = &snd_motu_protocol_v3,
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
SND_MOTU_SPEC_TX_MICINST_CHUNK |
@ -348,6 +350,7 @@ const struct snd_motu_spec snd_motu_spec_audio_express = {
const struct snd_motu_spec snd_motu_spec_4pre = {
.name = "4pre",
.protocol_version = SND_MOTU_PROTOCOL_V3,
.protocol = &snd_motu_protocol_v3,
.flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 |
SND_MOTU_SPEC_TX_MICINST_CHUNK |

View File

@ -317,7 +317,7 @@ static int init_stream(struct snd_motu *motu, struct amdtp_stream *s)
if (err < 0)
return err;
err = amdtp_motu_init(s, motu->unit, dir, motu->spec->protocol);
err = amdtp_motu_init(s, motu->unit, dir, motu->spec);
if (err < 0)
fw_iso_resources_destroy(resources);

View File

@ -108,6 +108,11 @@ enum snd_motu_clock_source {
SND_MOTU_CLOCK_SOURCE_UNKNOWN,
};
enum snd_motu_protocol_version {
SND_MOTU_PROTOCOL_V2,
SND_MOTU_PROTOCOL_V3,
};
struct snd_motu_protocol {
int (*get_clock_rate)(struct snd_motu *motu, unsigned int *rate);
int (*set_clock_rate)(struct snd_motu *motu, unsigned int rate);
@ -119,6 +124,7 @@ struct snd_motu_protocol {
struct snd_motu_spec {
const char *const name;
enum snd_motu_protocol_version protocol_version;
enum snd_motu_spec_flags flags;
unsigned char analog_in_ports;
@ -127,9 +133,6 @@ struct snd_motu_spec {
const struct snd_motu_protocol *const protocol;
};
extern const struct snd_motu_protocol snd_motu_protocol_v2;
extern const struct snd_motu_protocol snd_motu_protocol_v3;
extern const struct snd_motu_spec snd_motu_spec_828mk2;
extern const struct snd_motu_spec snd_motu_spec_traveler;
extern const struct snd_motu_spec snd_motu_spec_ultralite;
@ -141,7 +144,7 @@ extern const struct snd_motu_spec snd_motu_spec_4pre;
int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir,
const struct snd_motu_protocol *const protocol);
const struct snd_motu_spec *spec);
int amdtp_motu_set_parameters(struct amdtp_stream *s, unsigned int rate,
unsigned int midi_ports,
struct snd_motu_packet_format *formats);