ALSA: firewire-lib: add an argument for Dice's dual wire mode
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 19 Sep 2015 02:21:50 +0000 (11:21 +0900)
committerTakashi Iwai <tiwai@suse.de>
Tue, 29 Sep 2015 10:35:46 +0000 (12:35 +0200)
In IEC 61883-6, one data block represents one event. In ALSA, the event is
one PCM frame. Therefore, when processing one data block, current
implementation counts one PCM frame.

On the other hand, Dice platform has a quirk called as 'dual wire' at
higher sampling rate. In detail, see comment of commit 6eb6c81eee2a
("ALSA: dice: Split stream functionality into a file").

Currently, to handle this quirk, AMDTP stream structure has a
'double_pcm_frames' member. When this is enabled, two PCM frames are
counted. Each driver set this flag by accessing the structure member
directly.

In future commit, some members related to AM824 data block will be moved
to specific structure, to separate packet streaming layer and data block
processing layer. The access will be limited by opaque pointer.

For this reason, this commit adds an argument into
amdtp_stream_set_parameter() to set the flag.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/amdtp.c
sound/firewire/amdtp.h
sound/firewire/bebob/bebob_stream.c
sound/firewire/dice/dice-stream.c
sound/firewire/fireworks/fireworks_stream.c
sound/firewire/oxfw/oxfw-stream.c

index 2bacb5173ff86f831af404a46923c0f66a2aabcd..094982f7c0fd2d02f5428bec0c776cd1ba928059 100644 (file)
@@ -193,6 +193,7 @@ EXPORT_SYMBOL(amdtp_stream_add_pcm_hw_constraints);
  * @pcm_channels: the number of PCM samples in each data block, to be encoded
  *                as AM824 multi-bit linear audio
  * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels)
+ * @double_pcm_frames: one data block transfers two PCM frames
  *
  * The parameters must be set before the stream is started, and must not be
  * changed while the stream is running.
@@ -200,7 +201,8 @@ EXPORT_SYMBOL(amdtp_stream_add_pcm_hw_constraints);
 int amdtp_stream_set_parameters(struct amdtp_stream *s,
                                unsigned int rate,
                                unsigned int pcm_channels,
-                               unsigned int midi_ports)
+                               unsigned int midi_ports,
+                               bool double_pcm_frames)
 {
        unsigned int i, sfc, midi_channels;
 
index 3fb8db7ecd68dff9786e735e4c9ea6070b2a2bdc..2c91306957803829d50fe86d27d3664fb13f1811 100644 (file)
@@ -177,7 +177,8 @@ void amdtp_stream_destroy(struct amdtp_stream *s);
 int amdtp_stream_set_parameters(struct amdtp_stream *s,
                                unsigned int rate,
                                unsigned int pcm_channels,
-                               unsigned int midi_ports);
+                               unsigned int midi_ports,
+                               bool double_pcm_frames);
 unsigned int amdtp_stream_get_max_payload(struct amdtp_stream *s);
 
 int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed);
index c642b79e7ed4a9ce7ad8a7ae6b9f44cede0a8f1c..920a3b8844eef02678edf54451a3d4e7ea24c91f 100644 (file)
@@ -428,14 +428,16 @@ make_both_connections(struct snd_bebob *bebob, unsigned int rate)
        pcm_channels = bebob->tx_stream_formations[index].pcm;
        midi_channels = bebob->tx_stream_formations[index].midi;
        err = amdtp_stream_set_parameters(&bebob->tx_stream, rate,
-                                         pcm_channels, midi_channels * 8);
+                                         pcm_channels, midi_channels * 8,
+                                         false);
        if (err < 0)
                goto end;
 
        pcm_channels = bebob->rx_stream_formations[index].pcm;
        midi_channels = bebob->rx_stream_formations[index].midi;
        err = amdtp_stream_set_parameters(&bebob->rx_stream, rate,
-                                         pcm_channels, midi_channels * 8);
+                                         pcm_channels, midi_channels * 8,
+                                         false);
        if (err < 0)
                goto end;
 
index c96306adcae0e49e1764e08a76e407636b26e587..e4c6c20d70a092d91fbe2fc185982a9e94165782 100644 (file)
@@ -100,6 +100,7 @@ static int start_stream(struct snd_dice *dice, struct amdtp_stream *stream,
 {
        struct fw_iso_resources *resources;
        unsigned int i, mode, pcm_chs, midi_ports;
+       bool double_pcm_frames;
        int err;
 
        err = snd_dice_stream_get_rate_mode(dice, rate, &mode);
@@ -125,19 +126,18 @@ static int start_stream(struct snd_dice *dice, struct amdtp_stream *stream,
         * For this quirk, blocking mode is required and PCM buffer size should
         * be aligned to SYT_INTERVAL.
         */
-       if (mode > 1) {
+       double_pcm_frames = mode > 1;
+       if (double_pcm_frames) {
                rate /= 2;
                pcm_chs *= 2;
-               stream->double_pcm_frames = true;
-       } else {
-               stream->double_pcm_frames = false;
        }
 
-       err = amdtp_stream_set_parameters(stream, rate, pcm_chs, midi_ports);
+       err = amdtp_stream_set_parameters(stream, rate, pcm_chs, midi_ports,
+                                         false);
        if (err < 0)
                goto end;
 
-       if (mode > 1) {
+       if (double_pcm_frames) {
                pcm_chs /= 2;
 
                for (i = 0; i < pcm_chs; i++) {
index dfefccff3c55b08ca6d0682a8ea989db6115a9f1..85a72e63913d4c0fcfdbcaf9186aaa8c847eb8a2 100644 (file)
@@ -74,7 +74,7 @@ start_stream(struct snd_efw *efw, struct amdtp_stream *stream,
        }
 
        err = amdtp_stream_set_parameters(stream, sampling_rate,
-                                         pcm_channels, midi_ports);
+                                         pcm_channels, midi_ports, false);
        if (err < 0)
                goto end;
 
index d119468fedf45ceb0480fee151106ed5a369c9f1..318f78e1a313694386a7e5fae20806462f8a3143 100644 (file)
@@ -156,7 +156,7 @@ static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream,
                goto end;
        }
        err = amdtp_stream_set_parameters(stream, rate,
-                                         pcm_channels, midi_ports);
+                                         pcm_channels, midi_ports, false);
        if (err < 0)
                goto end;
 
This page took 0.027436 seconds and 5 git commands to generate.