Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/usb.h
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
#define USB_DEVICE_ID_MATCH_DEVICE \ | #define USB_DEVICE_ID_MATCH_DEVICE \ | ||||
(USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT) | (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT) | ||||
#define USB_DEVICE(vend,prod) \ | #define USB_DEVICE(vend,prod) \ | ||||
.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), \ | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), \ | ||||
.idProduct = (prod) | .idProduct = (prod) | ||||
#define USB_DEVICE_AND_INTERFACE_INFO(vend, prod, class, subclass, proto) \ | |||||
.match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ | |||||
hselasky: Match flags should be:
```
.match_flags = USB_DEVICE_ID_MATCH_VENDOR |… | |||||
.idVendor = (vend), \ | |||||
.idProduct = (prod), \ | |||||
.bInterfaceClass = (class), \ | |||||
.bInterfaceSubClass = (subclass), \ | |||||
.bInterfaceProtocol = (proto) | |||||
/* The "usb_driver" structure holds the Linux USB device driver | /* The "usb_driver" structure holds the Linux USB device driver | ||||
* callbacks, and a pointer to device ID's which this entry should | * callbacks, and a pointer to device ID's which this entry should | ||||
* match against. Usually this entry is exposed to the USB emulation | * match against. Usually this entry is exposed to the USB emulation | ||||
* layer using the "USB_DRIVER_EXPORT()" macro, which is defined | * layer using the "USB_DRIVER_EXPORT()" macro, which is defined | ||||
* below. | * below. | ||||
*/ | */ | ||||
struct usb_driver { | struct usb_driver { | ||||
const char *name; | const char *name; | ||||
Show All 36 Lines | |||||
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 | #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 | ||||
/* CONTROL REQUEST SUPPORT */ | /* CONTROL REQUEST SUPPORT */ | ||||
/* | /* | ||||
* Definition of direction mask for | * Definition of direction mask for | ||||
* "bEndpointAddress" and "bmRequestType": | * "bEndpointAddress" and "bmRequestType": | ||||
*/ | */ | ||||
#define USB_DIR_MASK 0x80 | #define USB_DIR_MASK UE_DIR_IN | ||||
#define USB_DIR_OUT 0x00 /* write to USB device */ | #define USB_DIR_OUT UE_DIR_OUT /* write to USB device */ | ||||
#define USB_DIR_IN 0x80 /* read from USB device */ | #define USB_DIR_IN UE_DIR_IN /* read from USB device */ | ||||
static inline bool | |||||
usb_endpoint_dir_in(const struct usb_endpoint_descriptor *ed) | |||||
{ | |||||
return (UE_GET_DIR(ed->bEndpointAddress) == USB_DIR_IN); | |||||
} | |||||
static inline bool | |||||
usb_endpoint_dir_out(const struct usb_endpoint_descriptor *ed) | |||||
{ | |||||
return (UE_GET_DIR(ed->bEndpointAddress) == USB_DIR_OUT); | |||||
} | |||||
static inline int | |||||
usb_endpoint_num(const struct usb_endpoint_descriptor *ed) | |||||
{ | |||||
return (ed->bEndpointAddress & UE_ADDR); | |||||
} | |||||
static inline bool | |||||
usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *ed) | |||||
{ | |||||
return (UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK); | |||||
} | |||||
static inline bool | |||||
usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *ed) | |||||
{ | |||||
return (UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT); | |||||
} | |||||
hselaskyUnsubmitted Not Done Inline ActionsCan you add the same for UE_ISOCHRONOUS, so the list is complete? hselasky: Can you add the same for UE_ISOCHRONOUS, so the list is complete? | |||||
/* | /* | ||||
* Definition of type mask for | * Definition of type mask for | ||||
* "bmRequestType": | * "bmRequestType": | ||||
*/ | */ | ||||
#define USB_TYPE_MASK (0x03 << 5) | #define USB_TYPE_MASK (0x03 << 5) | ||||
#define USB_TYPE_STANDARD (0x00 << 5) | #define USB_TYPE_STANDARD (0x00 << 5) | ||||
#define USB_TYPE_CLASS (0x01 << 5) | #define USB_TYPE_CLASS (0x01 << 5) | ||||
#define USB_TYPE_VENDOR (0x02 << 5) | #define USB_TYPE_VENDOR (0x02 << 5) | ||||
▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | #define URB_IS_SLEEPING 0x0020 /* custom flags */ | ||||
uint8_t setup_dma; /* (in) not used on FreeBSD */ | uint8_t setup_dma; /* (in) not used on FreeBSD */ | ||||
uint8_t transfer_dma; /* (in) not used on FreeBSD */ | uint8_t transfer_dma; /* (in) not used on FreeBSD */ | ||||
uint8_t bsd_isread; | uint8_t bsd_isread; | ||||
uint8_t kill_count; /* FreeBSD specific */ | uint8_t kill_count; /* FreeBSD specific */ | ||||
struct usb_iso_packet_descriptor iso_frame_desc[]; /* (in) ISO ONLY */ | struct usb_iso_packet_descriptor iso_frame_desc[]; /* (in) ISO ONLY */ | ||||
}; | }; | ||||
static inline void | |||||
usb_fill_control_urb(struct urb *urb, struct usb_device * udev, | |||||
/* unsigned int pipe */ struct usb_host_endpoint *ep, | |||||
hselaskyUnsubmitted Not Done Inline ActionsJust remove this /* unsigned int pipe */ and this: /* urb->pipe = pipe; */ hselasky: Just remove this /* unsigned int pipe */
and this:
/* urb->pipe = pipe; */ | |||||
uint8_t *setuppkt, uint8_t *transbuf, usb_size_t transbuflen, | |||||
usb_complete_t complete_cb_fn, void *ctx) | |||||
{ | |||||
urb->dev = udev; | |||||
/* | |||||
* This seems to be unsigned int pipe in Linux based on calling code. | |||||
* Our macros using usb_find_host_endpoint() already return an *ep. | |||||
* So we change some code. | |||||
*/ | |||||
/* urb->pipe = pipe; */ | |||||
urb->endpoint = ep; | |||||
urb->setup_packet = setuppkt; | |||||
urb->transfer_buffer = transbuf; | |||||
urb->transfer_buffer_length = transbuflen; | |||||
urb->complete = complete_cb_fn; | |||||
urb->context = ctx; | |||||
} | |||||
#define USB_STATE_NOTATTACHED USB_STATE_DETACHED /* enum usb_dev_state */ | |||||
/* libusb::struct usb_ctrl_setup */ | |||||
struct usb_ctrlrequest { | |||||
uint8_t bRequestType; | |||||
uint8_t bRequest; | |||||
uint16_t wValue; | |||||
uint16_t wIndex; | |||||
uint16_t wLength; | |||||
}; | |||||
/* various prototypes */ | /* various prototypes */ | ||||
int usb_submit_urb(struct urb *urb, uint16_t mem_flags); | int usb_submit_urb(struct urb *urb, uint16_t mem_flags); | ||||
int usb_unlink_urb(struct urb *urb); | int usb_unlink_urb(struct urb *urb); | ||||
int usb_clear_halt(struct usb_device *dev, struct usb_host_endpoint *uhe); | int usb_clear_halt(struct usb_device *dev, struct usb_host_endpoint *uhe); | ||||
int usb_control_msg(struct usb_device *dev, struct usb_host_endpoint *ep, | int usb_control_msg(struct usb_device *dev, struct usb_host_endpoint *ep, | ||||
uint8_t request, uint8_t requesttype, uint16_t value, | uint8_t request, uint8_t requesttype, uint16_t value, | ||||
uint16_t index, void *data, uint16_t size, usb_timeout_t timeout); | uint16_t index, void *data, uint16_t size, usb_timeout_t timeout); | ||||
Show All 23 Lines | |||||
void usb_fill_bulk_urb(struct urb *, struct usb_device *, | void usb_fill_bulk_urb(struct urb *, struct usb_device *, | ||||
struct usb_host_endpoint *, void *, int, usb_complete_t, void *); | struct usb_host_endpoint *, void *, int, usb_complete_t, void *); | ||||
int usb_bulk_msg(struct usb_device *, struct usb_host_endpoint *, | int usb_bulk_msg(struct usb_device *, struct usb_host_endpoint *, | ||||
void *, int, uint16_t *, usb_timeout_t); | void *, int, uint16_t *, usb_timeout_t); | ||||
#define interface_to_usbdev(intf) (intf)->linux_udev | #define interface_to_usbdev(intf) (intf)->linux_udev | ||||
#define interface_to_bsddev(intf) (intf)->linux_udev | #define interface_to_bsddev(intf) (intf)->linux_udev | ||||
#define module_usb_driver(_driver) \ | |||||
\ | |||||
static inline void \ | |||||
hselaskyUnsubmitted Not Done Inline ActionsRemove "inline" here. The function is always static. hselasky: Remove "inline" here. The function is always static. | |||||
_usb_init(void) \ | |||||
{ \ | |||||
\ | |||||
usb_linux_register(&_driver); \ | |||||
} \ | |||||
\ | |||||
static inline void \ | |||||
hselaskyUnsubmitted Not Done Inline Actionsditto. hselasky: ditto. | |||||
_usb_exit(void) \ | |||||
{ \ | |||||
\ | |||||
usb_linux_deregister(&_driver); \ | |||||
} \ | |||||
\ | |||||
module_init(_usb_init); \ | |||||
module_exit(_usb_exit) | |||||
static inline void * | |||||
usb_get_intfdata(struct usb_interface *intf) | |||||
hselaskyUnsubmitted Not Done Inline ActionsCan you merge this with the function above: void *usbd_get_intfdata(struct usb_interface *intf); hselasky: Can you merge this with the function above:
```
void *usbd_get_intfdata(struct usb_interface… | |||||
{ | |||||
return (NULL); | |||||
} | |||||
static inline struct usb_device * | |||||
usb_get_dev(struct usb_device *dev) | |||||
{ | |||||
hselaskyUnsubmitted Not Done Inline ActionsWe do have a USB device refcounting function, but I guess it is not needed? hselasky: We do have a USB device refcounting function, but I guess it is not needed? | |||||
return (dev); | |||||
} | |||||
static inline void | |||||
usb_put_dev(struct usb_device *dev) | |||||
{ | |||||
return; | |||||
} | |||||
static inline int | |||||
usb_reset_device(struct usb_device *dev) | |||||
{ | |||||
return (-ENXIO); | |||||
} | |||||
#endif /* _USB_COMPAT_LINUX_H */ | #endif /* _USB_COMPAT_LINUX_H */ |
Match flags should be:
Else you are only matching the two first fields :-)