Ignore:
Timestamp:
10/18/03 21:09:43 (9 years ago)
Author:
aet
Message:
  • Remove obsolete ifd_device_open_channel / ifd_sysdep_channel_to_name
  • Some polishing for sysdep usb layer, as not all usb api implementations work on top of a file descriptor
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ifd/sys-bsd.c

    r398 r409  
    5454} 
    5555 
    56 const char * 
    57 ifd_sysdep_channel_to_name(unsigned int num) 
    58 { 
    59         static char     namebuf[256]; 
    60  
    61         switch (num >> 24) { 
    62         case 0: 
    63                 sprintf(namebuf, "/dev/ttyS%u", num); 
    64                 break; 
    65         case 1: 
    66 #ifdef __FreeBSD__ 
    67                 sprintf(namebuf, "/dev/ugen%d", num); 
    68 #else 
    69                 sprintf(namebuf, "/dev/ugen%d.00", num); 
    70 #endif 
    71                 break; 
    72         default: 
    73                 ct_error("Unknown device channel 0x%x\n", num); 
    74                 return NULL; 
    75         } 
    76  
    77         return namebuf; 
    78 } 
    79  
    8056/* 
    8157 * USB control command 
    8258 */ 
    8359int 
    84 ifd_sysdep_usb_control(int fd, 
     60ifd_sysdep_usb_control(ifd_device_t *dev, 
    8561                unsigned int requesttype, 
    8662                unsigned int request, 
     
    10581 
    10682        val = timeout; 
    107         rc = ioctl(fd, USB_SET_TIMEOUT, &val); 
     83        rc = ioctl(dev->fd, USB_SET_TIMEOUT, &val); 
    10884        if (rc < 0) { 
    10985                ct_error("usb_set_timeout failed: %m"); 
     
    11187        } 
    11288  
    113         if ((rc = ioctl(fd, USB_DO_REQUEST, &ctrl)) < 0) { 
     89        if ((rc = ioctl(dev->fd, USB_DO_REQUEST, &ctrl)) < 0) { 
    11490                ct_error("usb_control failed: %m"); 
    11591                return IFD_ERROR_COMM_ERROR; 
     
    144120 
    145121int 
    146 ifd_sysdep_usb_begin_capture(int fd, 
     122ifd_sysdep_usb_begin_capture(ifd_device_t *dev, 
    147123                int type, int endpoint, size_t maxpacket, 
    148124                ifd_usb_capture_t **capret) 
     
    155131        /* Assume the interface # is 0 */ 
    156132        cap->interface = 0; 
    157         rc = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &cap->interface); 
     133        rc = ioctl(dev->fd, USBDEVFS_CLAIMINTERFACE, &cap->interface); 
    158134        if (rc < 0) { 
    159135                ct_error("usb_claiminterface failed: %m"); 
     
    166142        cap->maxpacket = maxpacket; 
    167143 
    168         if (usb_submit_urb(fd, cap) < 0) { 
     144        if (usb_submit_urb(dev->fd, cap) < 0) { 
    169145                ct_error("usb_submiturb failed: %m"); 
    170                 ifd_sysdep_usb_end_capture(fd, cap); 
     146                ifd_sysdep_usb_end_capture(dev, cap); 
    171147                return IFD_ERROR_COMM_ERROR; 
    172148        } 
     
    177153 
    178154int 
    179 ifd_sysdep_usb_capture(int fd, 
     155ifd_sysdep_usb_capture(ifd_device_t *dev, 
    180156                ifd_usb_capture_t *cap, 
    181157                void *buffer, size_t len, 
     
    198174                        return IFD_ERROR_TIMEOUT; 
    199175 
    200                 pfd.fd = fd; 
     176                pfd.fd = dev->fd; 
    201177                pfd.events = POLLOUT; 
    202178                if (poll(&pfd, 1, wait) != 1) 
     
    204180 
    205181                purb = NULL; 
    206                 rc = ioctl(fd, USBDEVFS_REAPURBNDELAY, &purb); 
     182                rc = ioctl(dev->fd, USBDEVFS_REAPURBNDELAY, &purb); 
    207183                if (rc < 0) { 
    208184                        if (errno == EAGAIN) 
     
    235211 
    236212int 
    237 ifd_sysdep_usb_end_capture(int fd, ifd_usb_capture_t *cap) 
     213ifd_sysdep_usb_end_capture(ifd_device_t *dev, ifd_usb_capture_t *cap) 
    238214{ 
    239215        int     rc = 0; 
    240216 
    241         if (ioctl(fd, USBDEVFS_DISCARDURB, &cap->urb) < 0 && errno != EINVAL) { 
     217        if (ioctl(dev->fd, USBDEVFS_DISCARDURB, &cap->urb) < 0 && errno != EINVAL) { 
    242218                ct_error("usb_discardurb failed: %m"); 
    243219                rc = IFD_ERROR_COMM_ERROR; 
     
    248224         * clobbering random memory. 
    249225         */ 
    250         (void) ioctl(fd, USBDEVFS_REAPURBNDELAY, &cap->urb); 
    251         if (ioctl(fd, USBDEVFS_RELEASEINTERFACE, &cap->interface) < 0) { 
     226        (void) ioctl(dev->fd, USBDEVFS_REAPURBNDELAY, &cap->urb); 
     227        if (ioctl(dev->fd, USBDEVFS_RELEASEINTERFACE, &cap->interface) < 0) { 
    252228                ct_error("usb_releaseinterface failed: %m"); 
    253229                rc = IFD_ERROR_COMM_ERROR; 
     
    259235/* 
    260236 * Scan all usb devices to see if there is one we support 
    261  * This function is called at start-up because we can't be 
    262  * sure the hotplug system notifies us of devices that were 
    263  * attached at startup time already. 
    264237 */ 
    265238int 
    266239ifd_scan_usb(void) 
    267240{ 
    268         /* do some cold plugging here */  
    269  
    270241        return 0; 
    271242} 
Note: See TracChangeset for help on using the changeset viewer.