Commit 948cd8c1 authored by Hans de Goede's avatar Hans de Goede Committed by Sarah Sharp

usbfs: Add support for bulk stream ids

This patch makes it possible to specify a bulk stream id when submitting
an urb using the async usbfs API. It overloads the number_of_packets
usbdevfs_urb field for this. This is not pretty, but given other
constraints it is the best we can do. The reasoning leading to this goes
as follows:

1) We want to support bulk streams in the usbfs API
2) We do not want to extend the usbdevfs_urb struct with a new member, as
   that would mean defining new ioctl numbers for all async API ioctls +
   adding compat versions for the old ones (times 2 for 32 bit support)
3) 1 + 2 means we need to re-use an existing field
4) number_of_packets is only used for isoc urbs, and streams are bulk only
   so it is the best (and only) candidate for re-using

Note that:
1) This patch only uses number_of_packets as stream_id if the app has
   actually allocated streams on the ep, so that old apps which may have
   garbage in there (as it was unused until now in the bulk case), will not
   break
2) This patch does not add support for allocating / freeing bulk-streams, that
   is done in a follow up patch
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
parent b2d03eb5
...@@ -1209,6 +1209,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1209,6 +1209,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
unsigned int u, totlen, isofrmlen; unsigned int u, totlen, isofrmlen;
int i, ret, is_in, num_sgs = 0, ifnum = -1; int i, ret, is_in, num_sgs = 0, ifnum = -1;
int number_of_packets = 0; int number_of_packets = 0;
unsigned int stream_id = 0;
void *buf; void *buf;
if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP | if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP |
...@@ -1294,6 +1295,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1294,6 +1295,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
num_sgs = DIV_ROUND_UP(uurb->buffer_length, USB_SG_SIZE); num_sgs = DIV_ROUND_UP(uurb->buffer_length, USB_SG_SIZE);
if (num_sgs == 1 || num_sgs > ps->dev->bus->sg_tablesize) if (num_sgs == 1 || num_sgs > ps->dev->bus->sg_tablesize)
num_sgs = 0; num_sgs = 0;
if (ep->streams)
stream_id = uurb->stream_id;
break; break;
case USBDEVFS_URB_TYPE_INTERRUPT: case USBDEVFS_URB_TYPE_INTERRUPT:
...@@ -1444,6 +1447,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1444,6 +1447,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
dr = NULL; dr = NULL;
as->urb->start_frame = uurb->start_frame; as->urb->start_frame = uurb->start_frame;
as->urb->number_of_packets = number_of_packets; as->urb->number_of_packets = number_of_packets;
as->urb->stream_id = stream_id;
if (uurb->type == USBDEVFS_URB_TYPE_ISO || if (uurb->type == USBDEVFS_URB_TYPE_ISO ||
ps->dev->speed == USB_SPEED_HIGH) ps->dev->speed == USB_SPEED_HIGH)
as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); as->urb->interval = 1 << min(15, ep->desc.bInterval - 1);
......
...@@ -102,7 +102,10 @@ struct usbdevfs_urb { ...@@ -102,7 +102,10 @@ struct usbdevfs_urb {
int buffer_length; int buffer_length;
int actual_length; int actual_length;
int start_frame; int start_frame;
int number_of_packets; union {
int number_of_packets; /* Only used for isoc urbs */
unsigned int stream_id; /* Only used with bulk streams */
};
int error_count; int error_count;
unsigned int signr; /* signal to be sent on completion, unsigned int signr; /* signal to be sent on completion,
or 0 if none should be sent. */ or 0 if none should be sent. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment