libusb10.c (215253) | libusb10.c (219100) |
---|---|
1/* $FreeBSD: head/lib/libusb/libusb10.c 215253 2010-11-13 19:25:11Z hselasky $ */ | 1/* $FreeBSD: head/lib/libusb/libusb10.c 219100 2011-02-28 17:23:15Z hselasky $ */ |
2/*- 3 * Copyright (c) 2009 Sylvestre Gallon. All rights reserved. 4 * Copyright (c) 2009 Hans Petter Selasky. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright --- 36 unchanged lines hidden (view full) --- 46#include "libusb10.h" 47 48static pthread_mutex_t default_context_lock = PTHREAD_MUTEX_INITIALIZER; 49struct libusb_context *usbi_default_context = NULL; 50 51/* Prototypes */ 52 53static struct libusb20_transfer *libusb10_get_transfer(struct libusb20_device *, uint8_t, uint8_t); | 2/*- 3 * Copyright (c) 2009 Sylvestre Gallon. All rights reserved. 4 * Copyright (c) 2009 Hans Petter Selasky. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright --- 36 unchanged lines hidden (view full) --- 46#include "libusb10.h" 47 48static pthread_mutex_t default_context_lock = PTHREAD_MUTEX_INITIALIZER; 49struct libusb_context *usbi_default_context = NULL; 50 51/* Prototypes */ 52 53static struct libusb20_transfer *libusb10_get_transfer(struct libusb20_device *, uint8_t, uint8_t); |
54static int libusb10_get_maxframe(struct libusb20_device *, libusb_transfer *); | |
55static int libusb10_get_buffsize(struct libusb20_device *, libusb_transfer *); 56static int libusb10_convert_error(uint8_t status); 57static void libusb10_complete_transfer(struct libusb20_transfer *, struct libusb_super_transfer *, int); 58static void libusb10_isoc_proxy(struct libusb20_transfer *); 59static void libusb10_bulk_intr_proxy(struct libusb20_transfer *); 60static void libusb10_ctrl_proxy(struct libusb20_transfer *); 61static void libusb10_submit_transfer_sub(struct libusb20_device *, uint8_t); 62 --- 742 unchanged lines hidden (view full) --- 805 free(uxfer->buffer); 806 807 sxfer = (struct libusb_super_transfer *)( 808 (uint8_t *)uxfer - sizeof(*sxfer)); 809 810 free(sxfer); 811} 812 | 54static int libusb10_get_buffsize(struct libusb20_device *, libusb_transfer *); 55static int libusb10_convert_error(uint8_t status); 56static void libusb10_complete_transfer(struct libusb20_transfer *, struct libusb_super_transfer *, int); 57static void libusb10_isoc_proxy(struct libusb20_transfer *); 58static void libusb10_bulk_intr_proxy(struct libusb20_transfer *); 59static void libusb10_ctrl_proxy(struct libusb20_transfer *); 60static void libusb10_submit_transfer_sub(struct libusb20_device *, uint8_t); 61 --- 742 unchanged lines hidden (view full) --- 804 free(uxfer->buffer); 805 806 sxfer = (struct libusb_super_transfer *)( 807 (uint8_t *)uxfer - sizeof(*sxfer)); 808 809 free(sxfer); 810} 811 |
813static int | 812static uint32_t |
814libusb10_get_maxframe(struct libusb20_device *pdev, libusb_transfer *xfer) 815{ | 813libusb10_get_maxframe(struct libusb20_device *pdev, libusb_transfer *xfer) 814{ |
816 int ret; 817 int usb_speed; | 815 uint32_t ret; |
818 | 816 |
819 usb_speed = libusb20_dev_get_speed(pdev); 820 | |
821 switch (xfer->type) { 822 case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: | 817 switch (xfer->type) { 818 case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: |
823 switch (usb_speed) { 824 case LIBUSB20_SPEED_LOW: 825 case LIBUSB20_SPEED_FULL: 826 ret = 60 * 1; 827 break; 828 default: 829 ret = 60 * 8; 830 break; 831 } | 819 ret = 60 | LIBUSB20_MAX_FRAME_PRE_SCALE; /* 60ms */ |
832 break; 833 case LIBUSB_TRANSFER_TYPE_CONTROL: 834 ret = 2; 835 break; 836 default: 837 ret = 1; 838 break; 839 } --- 604 unchanged lines hidden --- | 820 break; 821 case LIBUSB_TRANSFER_TYPE_CONTROL: 822 ret = 2; 823 break; 824 default: 825 ret = 1; 826 break; 827 } --- 604 unchanged lines hidden --- |