summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2019-08-04 02:21:24 -0400
committerTakashi Iwai <tiwai@suse.de>2019-08-05 13:57:19 -0400
commit94491c175d6bf4b838043a3fb5adabd731d8fbab (patch)
tree4f9c0f4bdc78a095b5d40bb94b1ef9d0144d88ae
parent9b4702b06c0e25abc612e6f02f3e25a51c684a01 (diff)
ALSA: fireworks: code refactoring for initialization/destruction of AMDTP streams
This commit is a preparation to support AMDTP domain. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/firewire/fireworks/fireworks_stream.c77
1 files changed, 36 insertions, 41 deletions
diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c
index 385fc9686365..0f62c50055e9 100644
--- a/sound/firewire/fireworks/fireworks_stream.c
+++ b/sound/firewire/fireworks/fireworks_stream.c
@@ -8,8 +8,7 @@
8 8
9#define CALLBACK_TIMEOUT 100 9#define CALLBACK_TIMEOUT 100
10 10
11static int 11static int init_stream(struct snd_efw *efw, struct amdtp_stream *stream)
12init_stream(struct snd_efw *efw, struct amdtp_stream *stream)
13{ 12{
14 struct cmp_connection *conn; 13 struct cmp_connection *conn;
15 enum cmp_direction c_dir; 14 enum cmp_direction c_dir;
@@ -28,14 +27,37 @@ init_stream(struct snd_efw *efw, struct amdtp_stream *stream)
28 27
29 err = cmp_connection_init(conn, efw->unit, c_dir, 0); 28 err = cmp_connection_init(conn, efw->unit, c_dir, 0);
30 if (err < 0) 29 if (err < 0)
31 goto end; 30 return err;
32 31
33 err = amdtp_am824_init(stream, efw->unit, s_dir, CIP_BLOCKING); 32 err = amdtp_am824_init(stream, efw->unit, s_dir, CIP_BLOCKING);
34 if (err < 0) { 33 if (err < 0) {
35 amdtp_stream_destroy(stream); 34 amdtp_stream_destroy(stream);
36 cmp_connection_destroy(conn); 35 cmp_connection_destroy(conn);
36 return err;
37 } 37 }
38end: 38
39 if (stream == &efw->tx_stream) {
40 // Fireworks transmits NODATA packets with TAG0.
41 efw->tx_stream.flags |= CIP_EMPTY_WITH_TAG0;
42 // Fireworks has its own meaning for dbc.
43 efw->tx_stream.flags |= CIP_DBC_IS_END_EVENT;
44 // Fireworks reset dbc at bus reset.
45 efw->tx_stream.flags |= CIP_SKIP_DBC_ZERO_CHECK;
46 // But Recent firmwares starts packets with non-zero dbc.
47 // Driver version 5.7.6 installs firmware version 5.7.3.
48 if (efw->is_fireworks3 &&
49 (efw->firmware_version == 0x5070000 ||
50 efw->firmware_version == 0x5070300 ||
51 efw->firmware_version == 0x5080000))
52 efw->tx_stream.flags |= CIP_UNALIGHED_DBC;
53 // AudioFire9 always reports wrong dbs.
54 if (efw->is_af9)
55 efw->tx_stream.flags |= CIP_WRONG_DBS;
56 // Firmware version 5.5 reports fixed interval for dbc.
57 if (efw->firmware_version == 0x5050000)
58 efw->tx_stream.ctx_data.tx.dbc_interval = 8;
59 }
60
39 return err; 61 return err;
40} 62}
41 63
@@ -83,22 +105,16 @@ static int start_stream(struct snd_efw *efw, struct amdtp_stream *stream,
83 return 0; 105 return 0;
84} 106}
85 107
86/* 108// This function should be called before starting the stream or after stopping
87 * This function should be called before starting the stream or after stopping 109// the streams.
88 * the streams. 110static void destroy_stream(struct snd_efw *efw, struct amdtp_stream *stream)
89 */
90static void
91destroy_stream(struct snd_efw *efw, struct amdtp_stream *stream)
92{ 111{
93 struct cmp_connection *conn; 112 amdtp_stream_destroy(stream);
94 113
95 if (stream == &efw->tx_stream) 114 if (stream == &efw->tx_stream)
96 conn = &efw->out_conn; 115 cmp_connection_destroy(&efw->out_conn);
97 else 116 else
98 conn = &efw->in_conn; 117 cmp_connection_destroy(&efw->in_conn);
99
100 amdtp_stream_destroy(stream);
101 cmp_connection_destroy(conn);
102} 118}
103 119
104static int 120static int
@@ -131,42 +147,21 @@ int snd_efw_stream_init_duplex(struct snd_efw *efw)
131 147
132 err = init_stream(efw, &efw->tx_stream); 148 err = init_stream(efw, &efw->tx_stream);
133 if (err < 0) 149 if (err < 0)
134 goto end; 150 return err;
135 /* Fireworks transmits NODATA packets with TAG0. */
136 efw->tx_stream.flags |= CIP_EMPTY_WITH_TAG0;
137 /* Fireworks has its own meaning for dbc. */
138 efw->tx_stream.flags |= CIP_DBC_IS_END_EVENT;
139 /* Fireworks reset dbc at bus reset. */
140 efw->tx_stream.flags |= CIP_SKIP_DBC_ZERO_CHECK;
141 /*
142 * But Recent firmwares starts packets with non-zero dbc.
143 * Driver version 5.7.6 installs firmware version 5.7.3.
144 */
145 if (efw->is_fireworks3 &&
146 (efw->firmware_version == 0x5070000 ||
147 efw->firmware_version == 0x5070300 ||
148 efw->firmware_version == 0x5080000))
149 efw->tx_stream.flags |= CIP_UNALIGHED_DBC;
150 /* AudioFire9 always reports wrong dbs. */
151 if (efw->is_af9)
152 efw->tx_stream.flags |= CIP_WRONG_DBS;
153 /* Firmware version 5.5 reports fixed interval for dbc. */
154 if (efw->firmware_version == 0x5050000)
155 efw->tx_stream.ctx_data.tx.dbc_interval = 8;
156 151
157 err = init_stream(efw, &efw->rx_stream); 152 err = init_stream(efw, &efw->rx_stream);
158 if (err < 0) { 153 if (err < 0) {
159 destroy_stream(efw, &efw->tx_stream); 154 destroy_stream(efw, &efw->tx_stream);
160 goto end; 155 return err;
161 } 156 }
162 157
163 /* set IEC61883 compliant mode (actually not fully compliant...) */ 158 // set IEC61883 compliant mode (actually not fully compliant...).
164 err = snd_efw_command_set_tx_mode(efw, SND_EFW_TRANSPORT_MODE_IEC61883); 159 err = snd_efw_command_set_tx_mode(efw, SND_EFW_TRANSPORT_MODE_IEC61883);
165 if (err < 0) { 160 if (err < 0) {
166 destroy_stream(efw, &efw->tx_stream); 161 destroy_stream(efw, &efw->tx_stream);
167 destroy_stream(efw, &efw->rx_stream); 162 destroy_stream(efw, &efw->rx_stream);
168 } 163 }
169end: 164
170 return err; 165 return err;
171} 166}
172 167