Ticket #34338: libusb.diff

File libusb.diff, 8.7 KB (added by adfernandes (Andrew Fernandes), 13 years ago)

update libusb, libusb-compat, and libusb-devel

  • libusb-compat/Portfile

     
    33PortSystem 1.0
    44
    55name            libusb-compat
    6 version         0.1.3
     6version         0.1.4
    77categories      devel
    88
    99description     library for USB device access
     
    1717maintainers     toby brett
    1818
    1919master_sites    sourceforge:libusb
    20 checksums       md5 570ac2ea085b80d1f74ddc7c6a93c0eb \
    21                 sha1 d5710d5bc4b67c5344e779475b76168c7ccc5e69 \
    22                 rmd160 d00e00b9f9733efc43eb4e44b84298540e896691
     20checksums       md5     2ca521fffadd0c28fdf174e6ec73865b \
     21                sha1    fdc1df6f5cf7b71de7a74292aeea1aa2a39552ae \
     22                rmd160  84a7aa3a294a6065838fcb464935926b659e4fee
    2323
    2424use_bzip2       yes
    2525
  • libusb/Portfile

     
    44
    55name            libusb
    66conflicts       libusb-devel
    7 version         1.0.8
     7version         1.0.9
    88categories      devel
    99
    1010description     library for USB device access
     
    1818maintainers     wilcoxd.com:rwilcox toby brett
    1919
    2020master_sites    sourceforge
    21 checksums       md5 37d34e6eaa69a4b645a19ff4ca63ceef \
    22                 sha1 5484397860f709c9b51611d224819f8ed5994063 \
    23                 rmd160 5a413a77e240a15480ef1437d5f5393badbae985
     21checksums       md5     7f5a02375ad960d4e33a6dae7d63cfcb \
     22                sha1    025582ff2f6216e2dbc2610ae16b2e073e1b3346 \
     23                rmd160  5410570f8ce31783044eb04aebaae7ade3b21a61
    2424
    2525use_bzip2       yes
    2626
  • libusb-devel/files/patch-USBI_OS_HANDLES_TIMEOUT.diff

     
    1 --- a/libusb/libusbi.h
    2 +++ b/libusb/libusbi.h
    3 @@ -288,13 +288,21 @@ struct libusb_device_handle {
    4         unsigned char os_priv[0];
    5  };
    6  
    7 -#define USBI_TRANSFER_TIMED_OUT                                (1<<0)
    8 -
    9  enum {
    10    USBI_CLOCK_MONOTONIC,
    11    USBI_CLOCK_REALTIME
    12  };
    13  
    14 +/* flags for struct usbi_transfer:
    15 + *  USBI_TRANSFER_TIMED_OUT
    16 + *  USBI_TRANSFER_OS_HANDLES_TIMEOUT - set in the backend submit_transfer if the os will handle the timeout
    17 + */
    18 +enum {
    19 +  USBI_TRANSFER_TIMED_OUT          = (1 << 0),
    20 +  USBI_TRANSFER_OS_HANDLES_TIMEOUT = (1 << 1)
    21 +};
    22 +
    23 +
    24  /* in-memory transfer layout:
    25   *
    26   * 1. struct usbi_transfer
    27 diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
    28 index 646c938..79ba6c6 100644
    29 --- a/libusb/os/darwin_usb.c
    30 +++ b/libusb/os/darwin_usb.c
    31 @@ -1137,6 +1137,8 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) {
    32        ret = (*(cInterface->interface))->WritePipeAsync(cInterface->interface, pipeRef, transfer->buffer,
    33                                                        transfer->length, darwin_async_io_callback, itransfer);
    34    } else {
    35 +    itransfer->flags |= USBI_TRANSFER_OS_HANDLES_TIMEOUT;
    36 
    37      if (is_read)
    38        ret = (*(cInterface->interface))->ReadPipeAsyncTO(cInterface->interface, pipeRef, transfer->buffer,
    39                                                         transfer->length, transfer->timeout, transfer->timeout,
    40 @@ -1171,10 +1173,19 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
    41    /* are we reading or writing? */
    42    is_read = transfer->endpoint & LIBUSB_ENDPOINT_IN;
    43  
    44 -  /* construct an array of IOUSBIsocFrames */
    45 -  tpriv->isoc_framelist = (IOUSBIsocFrame*) calloc (transfer->num_iso_packets, sizeof(IOUSBIsocFrame));
    46 -  if (!tpriv->isoc_framelist)
    47 -    return LIBUSB_ERROR_NO_MEM;
    48 +  /* construct an array of IOUSBIsocFrames, reuse the old one if possible */
    49 +  if (tpriv->isoc_framelist != NULL && tpriv->num_iso_packets != transfer->num_iso_packets)
    50 +  {
    51 +    free(tpriv->isoc_framelist);
    52 +    tpriv->isoc_framelist = NULL;
    53 +  }
    54 +  if (tpriv->isoc_framelist == NULL)
    55 +  {
    56 +    tpriv->isoc_framelist = (IOUSBIsocFrame*) calloc (transfer->num_iso_packets, sizeof(IOUSBIsocFrame));
    57 +    tpriv->num_iso_packets = transfer->num_iso_packets;
    58 +    if (!tpriv->isoc_framelist)
    59 +      return LIBUSB_ERROR_NO_MEM;
    60 +  }
    61  
    62    /* copy the frame list from the libusb descriptor (the structures differ only is member order) */
    63    for (i = 0 ; i < transfer->num_iso_packets ; i++)
    64 @@ -1198,9 +1209,11 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
    65  
    66      return darwin_to_libusb (kresult);
    67    }
    68 -
    69    /* schedule for a frame a little in the future */
    70 -  frame += 2;
    71 +  frame += 4;
    72 +
    73 +  if(cInterface->frames[transfer->endpoint] && frame < cInterface->frames[transfer->endpoint])
    74 +    frame = cInterface->frames[transfer->endpoint];
    75  
    76    /* submit the request */
    77    if (is_read)
    78 @@ -1211,6 +1224,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
    79      kresult = (*(cInterface->interface))->WriteIsochPipeAsync(cInterface->interface, pipeRef, transfer->buffer, frame,
    80                                                               transfer->num_iso_packets, tpriv->isoc_framelist, darwin_async_io_callback,
    81                                                               itransfer);
    82 +  cInterface->frames[transfer->endpoint] = frame + transfer->num_iso_packets / 8;
    83  
    84    if (kresult != kIOReturnSuccess) {
    85      usbi_err (TRANSFER_CTX (transfer), "isochronous transfer failed (dir: %s): %s", is_read ? "In" : "Out",
    86 @@ -1243,6 +1257,8 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) {
    87    tpriv->req.pData             = transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
    88    tpriv->req.completionTimeout = transfer->timeout;
    89    tpriv->req.noDataTimeout     = transfer->timeout;
    90 
    91 +  itransfer->flags |= USBI_TRANSFER_OS_HANDLES_TIMEOUT;
    92  
    93    /* all transfers in libusb-1.0 are async */
    94    kresult = (*(dpriv->device))->DeviceRequestAsyncTO(dpriv->device, &(tpriv->req), darwin_async_io_callback, itransfer);
    95 @@ -1358,6 +1374,9 @@ static void darwin_async_io_callback (void *refcon, IOReturn result, void *arg0)
    96  }
    97  
    98  static int darwin_transfer_status (struct usbi_transfer *itransfer, kern_return_t result) {
    99 +       if (itransfer->flags & USBI_TRANSFER_TIMED_OUT)
    100 +               result = kIOUSBTransactionTimeout;
    101 +               
    102    switch (result) {
    103    case kIOReturnUnderrun:
    104    case kIOReturnSuccess:
    105 @@ -1372,6 +1391,7 @@ static int darwin_transfer_status (struct usbi_transfer *itransfer, kern_return_
    106      return LIBUSB_TRANSFER_OVERFLOW;
    107    case kIOUSBTransactionTimeout:
    108      usbi_err (ITRANSFER_CTX (itransfer), "transfer error: timed out");
    109 +       itransfer->flags |= USBI_TRANSFER_TIMED_OUT;
    110      return LIBUSB_TRANSFER_TIMED_OUT;
    111    default:
    112      usbi_err (ITRANSFER_CTX (itransfer), "transfer error: %s (value = 0x%08x)", darwin_error_str (result), result);
    113 diff --git a/libusb/os/darwin_usb.h b/libusb/os/darwin_usb.h
    114 index a71d464..4aadf8c 100644
    115 --- a/libusb/os/darwin_usb.h
    116 +++ b/libusb/os/darwin_usb.h
    117 @@ -139,6 +139,7 @@ struct darwin_device_handle_priv {
    118      usb_interface_t    **interface;
    119      uint8_t              num_endpoints;
    120      CFRunLoopSourceRef   cfSource;
    121 +    UInt64               frames[256];
    122      uint8_t            endpoint_addrs[USB_MAXENDPOINTS];
    123    } interfaces[USB_MAXINTERFACES];
    124  };
    125 @@ -146,6 +147,7 @@ struct darwin_device_handle_priv {
    126  struct darwin_transfer_priv {
    127    /* Isoc */
    128    IOUSBIsocFrame *isoc_framelist;
    129 +  size_t num_iso_packets;
    130  
    131    /* Control */
    132  #if !defined (LIBUSB_NO_TIMEOUT_DEVICE)
    133  No newline at end of file
  • libusb-devel/Portfile

     
    33PortSystem 1.0
    44
    55name            libusb-devel
     6replaced_by     libusb
    67version         1.0.8.20101017
    7 revision        2
     8revision        3
    89categories      devel
    910
    1011description         library for USB device access
     
    1314                   
    1415homepage        http://www.libusb.org/
    1516
    16 platforms       darwin
    17 license         LGPL-2.1
    18 maintainers     adfernandes openmaintainer
     17maintainers     nomaintainer
    1918
    20 conflicts       libusb
     19distfiles
    2120
    22 fetch.type      git
    23 git.url         http://git.libusb.org/libusb.git
    24 git.branch      7da756e09fd97efad2b35b5cee0e2b2550aac2cb
    25 
    26 depends_build   port:autoconf port:automake port:libtool
    27 pre-configure   { system "cd ${worksrcpath}; ./autogen.sh" }
    28 configure.ldflags-append "-framework IOKit -framework CoreFoundation"
    29 
    30                 # This patch is required for the Kinect: http://openkinect.org/wiki/Getting_Started
    31                 # and is a known issue: <http://vimeo.com/16734124> and <http://www.libusb.org/ticket/31>
    32 patch.pre_args  -p1
    33 patchfiles      patch-USBI_OS_HANDLES_TIMEOUT.diff
     21pre-configure {
     22    ui_error "Please do not install this port since it has been replaced by 'libusb'."
     23    return -code error
     24}
    3425       
     26livecheck       none