staging: ozwpan: isoc latency for audio burst
authorRupesh Gujare <rgujare@ozmodevices.com>
Mon, 23 Jul 2012 17:49:46 +0000 (18:49 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Aug 2012 02:17:17 +0000 (19:17 -0700)
Set audio latency. This fixes issue where audio clips heard during
link outage.

Signed-off-by: Rupesh Gujare <rgujare@ozmodevices.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ozwpan/ozpd.c
drivers/staging/ozwpan/ozpd.h
drivers/staging/ozwpan/ozproto.c
drivers/staging/ozwpan/ozproto.h
drivers/staging/ozwpan/ozprotocol.h

index 6c287ac6eaeafba2d04529076736ad542e582f0b..f546b5aee8690b06928ac691a57fb0c2082da44f 100644 (file)
 /*------------------------------------------------------------------------------
  */
 #define OZ_MAX_TX_POOL_SIZE    6
-/* Maximum number of uncompleted isoc frames that can be pending in network.
- */
-#define OZ_MAX_SUBMITTED_ISOC  16
-/* Maximum number of uncompleted isoc frames that can be pending in Tx Queue.
- */
-#define OZ_MAX_TX_QUEUE_ISOC   32
 /*------------------------------------------------------------------------------
  */
 static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd);
@@ -854,7 +848,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len)
                if (!(pd->mode & OZ_F_ISOC_ANYTIME)) {
                        struct oz_tx_frame *isoc_unit = NULL;
                        int nb = pd->nb_queued_isoc_frames;
-                       if (nb >= OZ_MAX_TX_QUEUE_ISOC) {
+                       if (nb >= pd->isoc_latency) {
                                oz_trace2(OZ_TRACE_TX_FRAMES,
                                                "Dropping ISOC Unit nb= %d\n",
                                                                        nb);
index ddf1341b4e674a9f538cc9ea0de0b52dc3fc9cf6..d35b0ea44f67b844485a9cf795aa66b142c81945 100644 (file)
@@ -82,6 +82,7 @@ struct oz_pd {
        u8              heartbeat_requested;
        u8              mode;
        u8              ms_per_isoc;
+       unsigned        isoc_latency;
        unsigned        max_stream_buffering;
        int             nb_queued_frames;
        int             nb_queued_isoc_frames;
index a50ab18a598795a001f3fa808842f0a2c5ab8dc9..cfb5160d1ebedbdbd24ca95f02418c2258feb250 100644 (file)
@@ -220,6 +220,19 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt,
                pd->ms_per_isoc = body->ms_per_isoc;
                if (!pd->ms_per_isoc)
                        pd->ms_per_isoc = 4;
+
+               switch (body->ms_isoc_latency & OZ_LATENCY_MASK) {
+               case OZ_ONE_MS_LATENCY:
+                       pd->isoc_latency = (body->ms_isoc_latency &
+                                       ~OZ_LATENCY_MASK) / pd->ms_per_isoc;
+                       break;
+               case OZ_TEN_MS_LATENCY:
+                       pd->isoc_latency = ((body->ms_isoc_latency &
+                               ~OZ_LATENCY_MASK) * 10) / pd->ms_per_isoc;
+                       break;
+               default:
+                       pd->isoc_latency = OZ_MAX_TX_QUEUE_ISOC;
+               }
        }
        if (body->max_len_div16)
                pd->max_tx_size = ((u16)body->max_len_div16)<<4;
index 7d5b47693f3ff765d53a7f4c58298ed5129c073b..755a08d0e1ca05436ee911262b3a41b4ac55da9d 100644 (file)
 /* Maximun sizes of tx frames. */
 #define OZ_MAX_TX_SIZE         1514
 
+/* Maximum number of uncompleted isoc frames that can be pending in network. */
+#define OZ_MAX_SUBMITTED_ISOC  16
+
+/* Maximum number of uncompleted isoc frames that can be pending in Tx Queue. */
+#define OZ_MAX_TX_QUEUE_ISOC   32
+
 /* Application handler functions.
  */
 typedef int (*oz_app_init_fn_t)(void);
index 1e4edbeb61cde6f58f79557a4253ce459eb37a65..17b09b9a5b0869b0442cbc14995ac6cfa6c7fdf4 100644 (file)
@@ -65,6 +65,10 @@ struct oz_hdr {
 
 #define OZ_LAST_PN_HALF_CYCLE  127
 
+#define OZ_LATENCY_MASK                0xc0
+#define OZ_ONE_MS_LATENCY      0x40
+#define OZ_TEN_MS_LATENCY      0x80
+
 /* Connect request data structure.
  */
 struct oz_elt_connect_req {
@@ -73,7 +77,7 @@ struct oz_elt_connect_req {
        u8      pd_info;
        u8      session_id;
        u8      presleep;
-       u8      resv2;
+       u8      ms_isoc_latency;
        u8      host_vendor;
        u8      keep_alive;
        u16     apps;