All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de, tiwai@suse.de
Cc: alsa-devel@alsa-project.org
Subject: [PATCH 03/14] ALSA: firewire-motu: localize protocol data
Date: Tue, 19 May 2020 20:16:30 +0900	[thread overview]
Message-ID: <20200519111641.123211-4-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20200519111641.123211-1-o-takashi@sakamocchi.jp>

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

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/motu/amdtp-motu.c       |  7 ++++---
 sound/firewire/motu/motu-protocol-v2.c |  6 +++++-
 sound/firewire/motu/motu-protocol-v3.c |  5 ++++-
 sound/firewire/motu/motu-stream.c      |  2 +-
 sound/firewire/motu/motu.h             | 11 +++++++----
 5 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/sound/firewire/motu/amdtp-motu.c b/sound/firewire/motu/amdtp-motu.c
index 0fd36e469ad0..17c9ea8eb4c8 100644
--- a/sound/firewire/motu/amdtp-motu.c
+++ b/sound/firewire/motu/amdtp-motu.c
@@ -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;
diff --git a/sound/firewire/motu/motu-protocol-v2.c b/sound/firewire/motu/motu-protocol-v2.c
index ed71c08e5942..2cd710a7c792 100644
--- a/sound/firewire/motu/motu-protocol-v2.c
+++ b/sound/firewire/motu/motu-protocol-v2.c
@@ -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.
diff --git a/sound/firewire/motu/motu-protocol-v3.c b/sound/firewire/motu/motu-protocol-v3.c
index 947fab7905fe..548c97752cb8 100644
--- a/sound/firewire/motu/motu-protocol-v3.c
+++ b/sound/firewire/motu/motu-protocol-v3.c
@@ -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 |
diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c
index a17ddceb1bec..11a2b8b37768 100644
--- a/sound/firewire/motu/motu-stream.c
+++ b/sound/firewire/motu/motu-stream.c
@@ -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);
 
diff --git a/sound/firewire/motu/motu.h b/sound/firewire/motu/motu.h
index 7774c23f1637..9db692006d95 100644
--- a/sound/firewire/motu/motu.h
+++ b/sound/firewire/motu/motu.h
@@ -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);
-- 
2.25.1


  parent reply	other threads:[~2020-05-19 11:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19 11:16 [PATCH 00/14] ALSA: firewire-motu: code refactoring to obsolete protocol structure Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 01/14] ALSA: firewire-motu: move spec data to v2 protocol file Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 02/14] ALSA: firewire-motu: move spec data to v3 " Takashi Sakamoto
2020-05-19 11:16 ` Takashi Sakamoto [this message]
2020-05-19 11:16 ` [PATCH 04/14] ALSA: firewire-motu: add wrapper functions for protocol-dependent operations Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 05/14] ALSA: firewire-motu: drop protocol structure Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 06/14] ALSA: firewire-motu: add model-specific table of chunk count Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 07/14] ALSA: firewire-motu: add alternative functions to detect packet format for protocol v2 Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 08/14] ALSA: firewire-motu: add alternative functions to detect packet format for protocol v3 Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 09/14] ALSA: firewire-motu: use table-based calculation of packet formats for proc Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 10/14] ALSA: firewire-motu: use table-based calculation of packet formats for stream management Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 11/14] ALSA: firewire-motu: remove obsoleted codes Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 12/14] ALSA: firewire-motu: refactoring protocol v2 for clock source getter Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 13/14] ALSA: firewire-motu: refactoring protocol v3 " Takashi Sakamoto
2020-05-19 11:16 ` [PATCH 14/14] ALSA: firewire-motu: refactoring protocol v2 for fetching mode switch Takashi Sakamoto
2020-05-22 14:53 ` [PATCH 00/14] ALSA: firewire-motu: code refactoring to obsolete protocol structure Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200519111641.123211-4-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.