ALSA: firewire-lib: transfer rx packets on-the-fly when replaying
[linux-2.6-microblaze.git] / sound / firewire / oxfw / oxfw-stream.c
index 80c9dc1..9792d4b 100644 (file)
@@ -9,7 +9,7 @@
 #include <linux/delay.h>
 
 #define AVC_GENERIC_FRAME_MAXIMUM_BYTES        512
-#define CALLBACK_TIMEOUT       200
+#define READY_TIMEOUT_MS       200
 
 /*
  * According to datasheet of Oxford Semiconductor:
@@ -153,12 +153,23 @@ static int init_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
        struct cmp_connection *conn;
        enum cmp_direction c_dir;
        enum amdtp_stream_direction s_dir;
+       unsigned int flags;
        int err;
 
+       if (!(oxfw->quirks & SND_OXFW_QUIRK_BLOCKING_TRANSMISSION))
+               flags = CIP_NONBLOCKING;
+       else
+               flags = CIP_BLOCKING;
+
        if (stream == &oxfw->tx_stream) {
                conn = &oxfw->out_conn;
                c_dir = CMP_OUTPUT;
                s_dir = AMDTP_IN_STREAM;
+
+               if (oxfw->quirks & SND_OXFW_QUIRK_JUMBO_PAYLOAD)
+                       flags |= CIP_JUMBO_PAYLOAD;
+               if (oxfw->quirks & SND_OXFW_QUIRK_WRONG_DBS)
+                       flags |= CIP_WRONG_DBS;
        } else {
                conn = &oxfw->in_conn;
                c_dir = CMP_INPUT;
@@ -169,24 +180,12 @@ static int init_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream)
        if (err < 0)
                return err;
 
-       err = amdtp_am824_init(stream, oxfw->unit, s_dir, CIP_NONBLOCKING);
+       err = amdtp_am824_init(stream, oxfw->unit, s_dir, flags);
        if (err < 0) {
                cmp_connection_destroy(conn);
                return err;
        }
 
-       /*
-        * OXFW starts to transmit packets with non-zero dbc.
-        * OXFW postpone transferring packets till handling any asynchronous
-        * packets. As a result, next isochronous packet includes more data
-        * blocks than IEC 61883-6 defines.
-        */
-       if (stream == &oxfw->tx_stream) {
-               oxfw->tx_stream.flags |= CIP_JUMBO_PAYLOAD;
-               if (oxfw->wrong_dbs)
-                       oxfw->tx_stream.flags |= CIP_WRONG_DBS;
-       }
-
        return 0;
 }
 
@@ -355,24 +354,14 @@ int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw)
                        }
                }
 
-               err = amdtp_domain_start(&oxfw->domain, 0);
+               err = amdtp_domain_start(&oxfw->domain, 0, false, false);
                if (err < 0)
                        goto error;
 
-               // Wait first packet.
-               if (!amdtp_stream_wait_callback(&oxfw->rx_stream,
-                                               CALLBACK_TIMEOUT)) {
+               if (!amdtp_domain_wait_ready(&oxfw->domain, READY_TIMEOUT_MS)) {
                        err = -ETIMEDOUT;
                        goto error;
                }
-
-               if (oxfw->has_output) {
-                       if (!amdtp_stream_wait_callback(&oxfw->tx_stream,
-                                                       CALLBACK_TIMEOUT)) {
-                               err = -ETIMEDOUT;
-                               goto error;
-                       }
-               }
        }
 
        return 0;