diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2015-09-18 22:21:56 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-09-29 06:48:02 -0400 |
commit | 51c29fd21389d9995a8a18a91eeb8dd1220a2119 (patch) | |
tree | bc45c96ca22ad4eb7754da35d99a5394ed831a61 | |
parent | 5955815e71ff9c773b156680c781c87728e37bea (diff) |
ALSA: firewire-lib: rename parameter setting function for AM824 with FDF field
The value of FDF field in CIP header is protocol-dependent. Thus, it's
better to allow data block processing layer to decide the value in any
timing.
In AM824 data format, the value of FDF field in CIP header indicates
N-flag and Nominal Sampling Frequency Code (sfc). The N-flag is for
switching 'Clock-based rate control mode' and 'Command-based rate control
mode'. In our implementation, 'Clock-based rate control mode' is just
supported. Therefore, When sampling transfer frequency is decided, then
the FDF can be set.
This commit replaces 'amdtp_stream_set_parameters' with
'amdtp_am824_set_parameters' to set the FDF. This is the same timing
to decide the ration between the number of data blocks and the number of
PCM frames.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/firewire/amdtp-am824.c | 42 | ||||
-rw-r--r-- | sound/firewire/amdtp-am824.h | 5 | ||||
-rw-r--r-- | sound/firewire/amdtp-stream.c | 21 | ||||
-rw-r--r-- | sound/firewire/amdtp-stream.h | 3 | ||||
-rw-r--r-- | sound/firewire/bebob/bebob_stream.c | 12 | ||||
-rw-r--r-- | sound/firewire/dice/dice-stream.c | 4 | ||||
-rw-r--r-- | sound/firewire/fireworks/fireworks_stream.c | 4 | ||||
-rw-r--r-- | sound/firewire/oxfw/oxfw-stream.c | 4 |
8 files changed, 62 insertions, 33 deletions
diff --git a/sound/firewire/amdtp-am824.c b/sound/firewire/amdtp-am824.c index da4b643eff40..f5edcbfa3157 100644 --- a/sound/firewire/amdtp-am824.c +++ b/sound/firewire/amdtp-am824.c | |||
@@ -10,6 +10,48 @@ | |||
10 | 10 | ||
11 | #define CIP_FMT_AM 0x10 | 11 | #define CIP_FMT_AM 0x10 |
12 | 12 | ||
13 | /* "Clock-based rate control mode" is just supported. */ | ||
14 | #define AMDTP_FDF_AM824 0x00 | ||
15 | |||
16 | /** | ||
17 | * amdtp_am824_set_parameters - set stream parameters | ||
18 | * @s: the AMDTP stream to configure | ||
19 | * @rate: the sample rate | ||
20 | * @pcm_channels: the number of PCM samples in each data block, to be encoded | ||
21 | * as AM824 multi-bit linear audio | ||
22 | * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels) | ||
23 | * @double_pcm_frames: one data block transfers two PCM frames | ||
24 | * | ||
25 | * The parameters must be set before the stream is started, and must not be | ||
26 | * changed while the stream is running. | ||
27 | */ | ||
28 | int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate, | ||
29 | unsigned int pcm_channels, | ||
30 | unsigned int midi_ports, | ||
31 | bool double_pcm_frames) | ||
32 | { | ||
33 | int err; | ||
34 | |||
35 | err = amdtp_stream_set_parameters(s, rate, pcm_channels, midi_ports); | ||
36 | if (err < 0) | ||
37 | return err; | ||
38 | |||
39 | s->fdf = AMDTP_FDF_AM824 | s->sfc; | ||
40 | |||
41 | /* | ||
42 | * In IEC 61883-6, one data block represents one event. In ALSA, one | ||
43 | * event equals to one PCM frame. But Dice has a quirk at higher | ||
44 | * sampling rate to transfer two PCM frames in one data block. | ||
45 | */ | ||
46 | if (double_pcm_frames) | ||
47 | s->frame_multiplier = 2; | ||
48 | else | ||
49 | s->frame_multiplier = 1; | ||
50 | |||
51 | return 0; | ||
52 | } | ||
53 | EXPORT_SYMBOL_GPL(amdtp_am824_set_parameters); | ||
54 | |||
13 | /** | 55 | /** |
14 | * amdtp_am824_init - initialize an AMDTP stream structure to handle AM824 | 56 | * amdtp_am824_init - initialize an AMDTP stream structure to handle AM824 |
15 | * data block | 57 | * data block |
diff --git a/sound/firewire/amdtp-am824.h b/sound/firewire/amdtp-am824.h index ed96ac56628f..cfc0d61e0db4 100644 --- a/sound/firewire/amdtp-am824.h +++ b/sound/firewire/amdtp-am824.h | |||
@@ -3,6 +3,11 @@ | |||
3 | 3 | ||
4 | #include "amdtp-stream.h" | 4 | #include "amdtp-stream.h" |
5 | 5 | ||
6 | int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate, | ||
7 | unsigned int pcm_channels, | ||
8 | unsigned int midi_ports, | ||
9 | bool double_pcm_frames); | ||
10 | |||
6 | int amdtp_am824_init(struct amdtp_stream *s, struct fw_unit *unit, | 11 | int amdtp_am824_init(struct amdtp_stream *s, struct fw_unit *unit, |
7 | enum amdtp_stream_direction dir, enum cip_flags flags); | 12 | enum amdtp_stream_direction dir, enum cip_flags flags); |
8 | #endif | 13 | #endif |
diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 2254eec4521b..53d84e9bf241 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c | |||
@@ -54,12 +54,8 @@ | |||
54 | #define CIP_SYT_MASK 0x0000ffff | 54 | #define CIP_SYT_MASK 0x0000ffff |
55 | #define CIP_SYT_NO_INFO 0xffff | 55 | #define CIP_SYT_NO_INFO 0xffff |
56 | 56 | ||
57 | /* | 57 | /* Audio and Music transfer protocol specific parameters */ |
58 | * Audio and Music transfer protocol specific parameters | ||
59 | * only "Clock-based rate control mode" is supported | ||
60 | */ | ||
61 | #define CIP_FMT_AM 0x10 | 58 | #define CIP_FMT_AM 0x10 |
62 | #define AMDTP_FDF_AM824 0x00 | ||
63 | #define AMDTP_FDF_NO_DATA 0xff | 59 | #define AMDTP_FDF_NO_DATA 0xff |
64 | 60 | ||
65 | /* TODO: make these configurable */ | 61 | /* TODO: make these configurable */ |
@@ -204,8 +200,7 @@ EXPORT_SYMBOL(amdtp_stream_add_pcm_hw_constraints); | |||
204 | int amdtp_stream_set_parameters(struct amdtp_stream *s, | 200 | int amdtp_stream_set_parameters(struct amdtp_stream *s, |
205 | unsigned int rate, | 201 | unsigned int rate, |
206 | unsigned int pcm_channels, | 202 | unsigned int pcm_channels, |
207 | unsigned int midi_ports, | 203 | unsigned int midi_ports) |
208 | bool double_pcm_frames) | ||
209 | { | 204 | { |
210 | unsigned int i, sfc, midi_channels; | 205 | unsigned int i, sfc, midi_channels; |
211 | 206 | ||
@@ -228,18 +223,6 @@ int amdtp_stream_set_parameters(struct amdtp_stream *s, | |||
228 | s->data_block_quadlets = s->pcm_channels + midi_channels; | 223 | s->data_block_quadlets = s->pcm_channels + midi_channels; |
229 | s->midi_ports = midi_ports; | 224 | s->midi_ports = midi_ports; |
230 | 225 | ||
231 | s->fdf = AMDTP_FDF_AM824 | s->sfc; | ||
232 | |||
233 | /* | ||
234 | * In IEC 61883-6, one data block represents one event. In ALSA, one | ||
235 | * event equals to one PCM frame. But Dice has a quirk at higher | ||
236 | * sampling rate to transfer two PCM frames in one data block. | ||
237 | */ | ||
238 | if (double_pcm_frames) | ||
239 | s->frame_multiplier = 2; | ||
240 | else | ||
241 | s->frame_multiplier = 1; | ||
242 | |||
243 | s->syt_interval = amdtp_syt_intervals[sfc]; | 226 | s->syt_interval = amdtp_syt_intervals[sfc]; |
244 | 227 | ||
245 | /* default buffering in the device */ | 228 | /* default buffering in the device */ |
diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index 5f96affe37b7..d915940a14c9 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h | |||
@@ -181,8 +181,7 @@ void amdtp_stream_destroy(struct amdtp_stream *s); | |||
181 | int amdtp_stream_set_parameters(struct amdtp_stream *s, | 181 | int amdtp_stream_set_parameters(struct amdtp_stream *s, |
182 | unsigned int rate, | 182 | unsigned int rate, |
183 | unsigned int pcm_channels, | 183 | unsigned int pcm_channels, |
184 | unsigned int midi_ports, | 184 | unsigned int midi_ports); |
185 | bool double_pcm_frames); | ||
186 | unsigned int amdtp_stream_get_max_payload(struct amdtp_stream *s); | 185 | unsigned int amdtp_stream_get_max_payload(struct amdtp_stream *s); |
187 | 186 | ||
188 | int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed); | 187 | int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed); |
diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index 34bc3a419993..fa510f30cf8f 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c | |||
@@ -427,17 +427,17 @@ make_both_connections(struct snd_bebob *bebob, unsigned int rate) | |||
427 | index = get_formation_index(rate); | 427 | index = get_formation_index(rate); |
428 | pcm_channels = bebob->tx_stream_formations[index].pcm; | 428 | pcm_channels = bebob->tx_stream_formations[index].pcm; |
429 | midi_channels = bebob->tx_stream_formations[index].midi; | 429 | midi_channels = bebob->tx_stream_formations[index].midi; |
430 | err = amdtp_stream_set_parameters(&bebob->tx_stream, rate, | 430 | err = amdtp_am824_set_parameters(&bebob->tx_stream, rate, |
431 | pcm_channels, midi_channels * 8, | 431 | pcm_channels, midi_channels * 8, |
432 | false); | 432 | false); |
433 | if (err < 0) | 433 | if (err < 0) |
434 | goto end; | 434 | goto end; |
435 | 435 | ||
436 | pcm_channels = bebob->rx_stream_formations[index].pcm; | 436 | pcm_channels = bebob->rx_stream_formations[index].pcm; |
437 | midi_channels = bebob->rx_stream_formations[index].midi; | 437 | midi_channels = bebob->rx_stream_formations[index].midi; |
438 | err = amdtp_stream_set_parameters(&bebob->rx_stream, rate, | 438 | err = amdtp_am824_set_parameters(&bebob->rx_stream, rate, |
439 | pcm_channels, midi_channels * 8, | 439 | pcm_channels, midi_channels * 8, |
440 | false); | 440 | false); |
441 | if (err < 0) | 441 | if (err < 0) |
442 | goto end; | 442 | goto end; |
443 | 443 | ||
diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c index 917860e88b66..89483818785e 100644 --- a/sound/firewire/dice/dice-stream.c +++ b/sound/firewire/dice/dice-stream.c | |||
@@ -132,8 +132,8 @@ static int start_stream(struct snd_dice *dice, struct amdtp_stream *stream, | |||
132 | pcm_chs *= 2; | 132 | pcm_chs *= 2; |
133 | } | 133 | } |
134 | 134 | ||
135 | err = amdtp_stream_set_parameters(stream, rate, pcm_chs, midi_ports, | 135 | err = amdtp_am824_set_parameters(stream, rate, pcm_chs, midi_ports, |
136 | false); | 136 | double_pcm_frames); |
137 | if (err < 0) | 137 | if (err < 0) |
138 | goto end; | 138 | goto end; |
139 | 139 | ||
diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index 8cac5b987cc1..759f6e3ed44a 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c | |||
@@ -73,8 +73,8 @@ start_stream(struct snd_efw *efw, struct amdtp_stream *stream, | |||
73 | midi_ports = efw->midi_in_ports; | 73 | midi_ports = efw->midi_in_ports; |
74 | } | 74 | } |
75 | 75 | ||
76 | err = amdtp_stream_set_parameters(stream, sampling_rate, | 76 | err = amdtp_am824_set_parameters(stream, sampling_rate, |
77 | pcm_channels, midi_ports, false); | 77 | pcm_channels, midi_ports, false); |
78 | if (err < 0) | 78 | if (err < 0) |
79 | goto end; | 79 | goto end; |
80 | 80 | ||
diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 83683414793f..4982befc9c25 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c | |||
@@ -155,8 +155,8 @@ static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream, | |||
155 | err = -EINVAL; | 155 | err = -EINVAL; |
156 | goto end; | 156 | goto end; |
157 | } | 157 | } |
158 | err = amdtp_stream_set_parameters(stream, rate, | 158 | err = amdtp_am824_set_parameters(stream, rate, pcm_channels, midi_ports, |
159 | pcm_channels, midi_ports, false); | 159 | false); |
160 | if (err < 0) | 160 | if (err < 0) |
161 | goto end; | 161 | goto end; |
162 | 162 | ||