1#ifndef __VSF_LINUX_USB_H__
2#define __VSF_LINUX_USB_H__
10#include <linux/device.h>
20#define module_usb_driver(__usb_driver) \
21 module_driver(__usb_driver, usb_register, usb_deregister)
22#define module_usb_driver_init(__usb_driver) \
23 module_driver_init(__usb_driver)
25#define USB_DEVICE_ID_MATCH_VENDOR VSF_USBH_MATCH_FLAGS_VENDOR
26#define USB_DEVICE_ID_MATCH_PRODUCT VSF_USBH_MATCH_FLAGS_PRODUCT
27#define USB_DEVICE_ID_MATCH_DEVICE (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
28#define USB_DEVICE_ID_MATCH_DEV_CLASS VSF_USBH_MATCH_FLAGS_DEV_CLASS
29#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS VSF_USBH_MATCH_FLAGS_DEV_SUBCLASS
30#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL VSF_USBH_MATCH_FLAGS_DEV_PROTOCOL
31#define USB_DEVICE_ID_MATCH_DEV_INFO (USB_DEVICE_ID_MATCH_DEV_CLASS | USB_DEVICE_ID_MATCH_DEV_SUBCLASS | USB_DEVICE_ID_MATCH_DEV_PROTOCOL)
32#define USB_DEVICE_ID_MATCH_INT_CLASS VSF_USBH_MATCH_FLAGS_IFS_CLASS
33#define USB_DEVICE_ID_MATCH_INT_SUBCLASS VSF_USBH_MATCH_FLAGS_IFS_SUBCLASS
34#define USB_DEVICE_ID_MATCH_INT_PROTOCOL VSF_USBH_MATCH_FLAGS_IFS_PROTOCOL
35#define USB_DEVICE_ID_MATCH_INT_INFO (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL)
36#define USB_DEVICE_ID_MATCH_INT_NUMBER VSF_USBH_MATCH_FLAGS_IFS_NUM
37#define usb_device_id vk_usbh_dev_id_t
38#define USB_DEVICE(__vid, __pid) \
39 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
40 .idVendor = (__vid), \
43#define URB_SHORT_NOT_OK 0x0001
44#define URB_ISO_ASAP 0x0002
45#define URB_NO_TRANSFER_DMA_MAP 0x0004
46#define URB_ZERO_PACKET 0x0040
47#define URB_NO_INTERRUPT 0x0080
48#define URB_FREE_BUFFER 0x0100
80#define to_usb_interface(__d) vsf_container_of(__d, struct usb_interface, dev)
81static inline void *usb_get_intfdata(
struct usb_interface *intf)
83 return dev_get_drvdata(&intf->
dev);
88 dev_set_drvdata(&intf->
dev,
data);
91#define USB_MAXENDPOINTS 30
92#define USB_MAXINTERFACES 32
93#define USB_MAXIADS (USB_MAXINTERFACES / 2)
111static inline void init_usb_anchor(
struct usb_anchor *anchor)
113 memset(anchor, 0,
sizeof(*anchor));
115 init_waitqueue_head(&anchor->
wait);
118static inline int usb_anchor_empty(
struct usb_anchor *anchor)
120 return list_empty(&anchor->
urb_list);
145#define to_usb_device(__d) vsf_container_of(__d, struct usb_device, dev)
206#define PIPE_ISOCHRONOUS USB_ENDPOINT_XFER_ISOC
207#define PIPE_INTERRUPT USB_ENDPOINT_XFER_INT
208#define PIPE_CONTROL USB_ENDPOINT_XFER_CONTROL
209#define PIPE_BULK USB_ENDPOINT_XFER_BULK
211#define usb_pipein(__pipe) ({ \
212 vk_usbh_pipe_flag_t flag; \
213 flag.value = (__pipe); \
216#define usb_pipeout(__pipe) (!usb_pipein(__pipe))
217#define usb_pipedevice(__pipe) ({ \
218 vk_usbh_pipe_flag_t flag; \
219 flag.value = (__pipe); \
222#define usb_pipeendpoint(__pipe) ({ \
223 vk_usbh_pipe_flag_t flag; \
224 flag.value = (__pipe); \
227#define usb_pipetype(__pipe) ({ \
228 vk_usbh_pipe_flag_t flag; \
229 flag.value = (__pipe); \
232#define usb_pipeisoc(__pipe) (usb_pipetype(__pipe) == PIPE_ISOCHRONOUS)
233#define usb_pipeint(__pipe) (usb_pipetype(__pipe) == PIPE_INTERRUPT)
234#define usb_pipeCONTROL(__pipe) (usb_pipetype(__pipe) == PIPE_CONTROL)
235#define usb_pipebulk(__pipe) (usb_pipetype(__pipe) == PIPE_BULK)
238#define usb_sndctrlpipe(__udev, __endpoint) __vk_usbh_get_pipe_value((__udev)->__dev, __endpoint, PIPE_CONTROL, (__udev)->ep_out[__endpoint]->desc.wMaxPacketSize)
239#define usb_rcvctrlpipe(__udev, __endpoint) __vk_usbh_get_pipe_value((__udev)->__dev, __endpoint | USB_DIR_IN, PIPE_CONTROL, (__udev)->ep_out[__endpoint]->desc.wMaxPacketSize)
240#define usb_sndisocpipe(__udev, __endpoint) __vk_usbh_get_pipe_value((__udev)->__dev, __endpoint, PIPE_ISOCHRONOUS, (__udev)->ep_out[__endpoint]->desc.wMaxPacketSize)
241#define usb_rcvisocpipe(__udev, __endpoint) __vk_usbh_get_pipe_value((__udev)->__dev, __endpoint | USB_DIR_IN, PIPE_ISOCHRONOUS, (__udev)->ep_out[__endpoint]->desc.wMaxPacketSize)
242#define usb_sndbulkpipe(__udev, __endpoint) __vk_usbh_get_pipe_value((__udev)->__dev, __endpoint, PIPE_BULK, (__udev)->ep_out[__endpoint]->desc.wMaxPacketSize)
243#define usb_rcvbulkpipe(__udev, __endpoint) __vk_usbh_get_pipe_value((__udev)->__dev, __endpoint | USB_DIR_IN, PIPE_BULK, (__udev)->ep_out[__endpoint]->desc.wMaxPacketSize)
244#define usb_sndintpipe(__udev, __endpoint) __vk_usbh_get_pipe_value((__udev)->__dev, __endpoint, PIPE_INTERRUPT, (__udev)->ep_out[__endpoint]->desc.wMaxPacketSize)
245#define usb_rcvintpipe(__udev, __endpoint) __vk_usbh_get_pipe_value((__udev)->__dev, __endpoint | USB_DIR_IN, PIPE_INTERRUPT, (__udev)->ep_out[__endpoint]->desc.wMaxPacketSize)
252static inline void usb_fill_control_urb(
struct urb *
urb,
255 unsigned char *setup_packet,
256 void *transfer_buffer,
270static inline void usb_fill_bulk_urb(
struct urb *
urb,
273 void *transfer_buffer,
286static inline void usb_fill_int_urb(
struct urb *
urb,
289 void *transfer_buffer,
313#define usb_enable_autosuspend(__udev)
314#define usb_disable_autosuspend(__udev)
315#define usb_autopm_get_interface(__udev) 0
316#define usb_autopm_put_interface(__udev) 0
335#define usb_put_urb usb_free_urb
358static inline int usb_urb_dir_out(
struct urb *
urb)
371static inline int usb_get_std_status(
struct usb_device *udev,
int recip,
int target,
void *
data)
384#define usb_register(__drv) usb_register_driver((__drv), THIS_MODULE, KBUILD_MODNAME)
385#define usb_deregister(__drv) usb_deregister_driver((__drv))
389static inline int usb_interface_claimed(
struct usb_interface *iface)
#define vsf_min(__a, __b)
Definition __type.h:152
#define vsf_max(__a, __b)
Definition __type.h:151
#define usb_device_speed
Definition ch9.h:17
#define usb_config_descriptor
Definition ch9.h:20
#define usb_endpoint_descriptor
Definition ch9.h:22
#define usb_interface_descriptor
Definition ch9.h:21
Definition vsf_usbh.h:478
Definition vsf_usbh.h:523
Definition vsf_usbh.h:450
unsigned int gfp_t
Definition gfp.h:10
struct ieee80211_ext_chansw_ie data
Definition ieee80211.h:80
__le16 timeout
Definition ieee80211.h:94
#define usb_control_msg
Definition libusb.h:869
#define usb_set_configuration
Definition libusb.h:870
#define usb_get_descriptor
Definition libusb.h:873
uintalu_t dma_addr_t
Definition types.h:90
uint8_t __u8
Definition types.h:51
uint16_t __u16
Definition types.h:53
#define NULL
Definition lvgl.h:26
unsigned int u32
Definition lvgl.h:43
unsigned short uint16_t
Definition lvgl.h:41
unsigned int uint32_t
Definition lvgl.h:43
unsigned char uint8_t
Definition lvgl.h:40
int usb_reset_endpoint(struct usb_device *udev, unsigned int epaddr)
void usb_scuttle_anchored_urbs(struct usb_anchor *anchor)
void usb_driver_release_interface(struct usb_driver *driver, struct usb_interface *iface)
Definition vsf_linux_core_usb.c:373
void usb_init_urb(struct urb *urb)
Definition vsf_linux_core_usb.c:382
int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, unsigned int timeout)
Definition vsf_linux_core_usb.c:205
#define usb_device_id
Definition usb.h:37
void usb_unanchor_urb(struct urb *urb)
Definition vsf_linux_core_usb.c:152
int usb_string(struct usb_device *udev, int index, char *buf, size_t size)
int usb_clear_halt(struct usb_device *udev, int pipe)
Definition vsf_linux_core_usb.c:592
int usb_unlink_urb(struct urb *urb)
Definition vsf_linux_core_usb.c:475
int usb_reset_configuration(struct usb_device *udev)
struct urb * usb_alloc_urb(int iso_packets, gfp_t mem_flags)
Definition vsf_linux_core_usb.c:419
void usb_register_driver(struct usb_driver *drv, struct module *mod, const char *name)
Definition vsf_linux_core_usb.c:317
int usb_interrupt_msg(struct usb_device *udev, unsigned int pipe, void *data, int len, int *actual_length, int timeout)
Definition vsf_linux_core_usb.c:531
void usb_anchor_suspend_wakeups(struct usb_anchor *anchor)
void usb_unlink_anchored_urbs(struct usb_anchor *anchor)
Definition vsf_linux_core_usb.c:196
int usb_set_interface(struct usb_device *udev, int ifnum, int alternate)
Definition vsf_linux_core_usb.c:598
int usb_bulk_msg(struct usb_device *udev, unsigned int pipe, void *data, int len, int *actual_length, int timeout)
Definition vsf_linux_core_usb.c:555
void usb_unpoison_anchored_urbs(struct usb_anchor *anchor)
int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
Definition vsf_linux_core_usb.c:458
struct usb_interface * usb_ifnum_to_if(const struct usb_device *dev, unsigned ifnum)
Definition vsf_linux_core_usb.c:608
void usb_kill_anchored_urbs(struct usb_anchor *anchor)
Definition vsf_linux_core_usb.c:173
struct usb_host_interface * usb_altnum_to_altsetting(const struct usb_interface *intf, unsigned int altnum)
Definition vsf_linux_core_usb.c:624
#define usb_pipein(__pipe)
Definition usb.h:211
int usb_reset_device(struct usb_device *udev)
Definition vsf_linux_core_usb.c:560
struct usb_interface * usb_find_interface(struct usb_driver *drv, int minor)
Definition vsf_linux_core_usb.c:660
int usb_control_msg_send(struct usb_device *udev, __u8 endpoint, __u8 request, __u8 requesttype, __u16 value, __u16 index, const void *data, __u16 size, int timeout, gfp_t memflags)
Definition vsf_linux_core_usb.c:519
#define to_usb_device(__d)
Definition usb.h:145
int usb_find_common_endpoints(struct usb_host_interface *alt, struct usb_endpoint_descriptor **bulk_in, struct usb_endpoint_descriptor **bulk_out, struct usb_endpoint_descriptor **int_in, struct usb_endpoint_descriptor **int_out)
Definition vsf_linux_core_usb.c:708
int usb_get_status(struct usb_device *udev, int recip, int type, int target, void *data)
Definition vsf_linux_core_usb.c:573
void usb_poison_anchored_urbs(struct usb_anchor *anchor)
void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor)
Definition vsf_linux_core_usb.c:131
void(* usb_complete_t)(struct urb *)
Definition usb.h:151
uint32_t __vk_usbh_get_pipe_value(vk_usbh_dev_t *dev, uint8_t endpoint, uint8_t type, uint16_t size)
Definition vsf_usbh.c:149
struct usb_host_interface * usb_find_alt_setting(struct usb_host_config *config, unsigned int iface_num, unsigned int alt_num)
Definition vsf_linux_core_usb.c:634
void usb_deregister_driver(struct usb_driver *drv)
Definition vsf_linux_core_usb.c:343
#define USB_MAXIADS
Definition usb.h:93
int usb_urb_dir_in(struct urb *urb)
Definition vsf_linux_core_usb.c:66
struct urb * usb_get_from_anchor(struct usb_anchor *anchor)
Definition vsf_linux_core_usb.c:158
#define USB_MAXINTERFACES
Definition usb.h:92
void usb_anchor_resume_wakeups(struct usb_anchor *anchor)
int usb_find_common_endpoints_reverse(struct usb_host_interface *alt, struct usb_endpoint_descriptor **bulk_in, struct usb_endpoint_descriptor **bulk_out, struct usb_endpoint_descriptor **int_in, struct usb_endpoint_descriptor **int_out)
Definition vsf_linux_core_usb.c:736
void usb_poison_urb(struct urb *urb)
int usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface *iface, void *data)
Definition vsf_linux_core_usb.c:362
void usb_free_urb(struct urb *urb)
Definition vsf_linux_core_usb.c:451
void usb_unpoison_urb(struct urb *urb)
int usb_control_msg_recv(struct usb_device *udev, __u8 endpoint, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout, gfp_t memflags)
Definition vsf_linux_core_usb.c:525
struct urb * usb_get_urb(struct urb *urb)
Definition vsf_linux_core_usb.c:392
void usb_block_urb(struct urb *urb)
void vsf_linux_usb_init(vk_usbh_t *usbh)
Definition vsf_linux_core_usb.c:119
void usb_kill_urb(struct urb *urb)
Definition vsf_linux_core_usb.c:481
#define usb_pipeendpoint(__pipe)
Definition usb.h:222
void * memset(void *s, int ch, size_t n)
struct device * parent
Definition device.h:35
struct device_driver * driver
Definition device.h:40
struct usb_iso_packet_descriptor iso_frame_desc[]
Definition usb.h:182
int start_frame
Definition usb.h:169
unsigned int pipe
Definition usb.h:161
int status
Definition usb.h:162
struct usb_anchor * anchor
Definition usb.h:158
struct work_struct done_work
Definition usb.h:180
struct list_head anchor_list
Definition usb.h:157
int interval
Definition usb.h:171
u32 transfer_buffer_length
Definition usb.h:165
vk_usbh_urb_t __urb
Definition usb.h:153
vsf_eda_t * eda_pending
Definition usb.h:177
bool is_submitted
Definition usb.h:176
void * context
Definition usb.h:178
usb_complete_t complete
Definition usb.h:179
short error_count
Definition usb.h:175
struct usb_device * dev
Definition usb.h:159
int number_of_packets
Definition usb.h:170
unsigned int transfer_flags
Definition usb.h:163
void * transfer_buffer
Definition usb.h:164
unsigned char * setup_packet
Definition usb.h:167
dma_addr_t transfer_dma
Definition usb.h:173
u32 actual_length
Definition usb.h:166
struct list_head urb_list
Definition usb.h:156
atomic_t suspend_wakeups
Definition usb.h:107
struct list_head urb_list
Definition usb.h:105
wait_queue_head_t wait
Definition usb.h:106
bool poisoned
Definition usb.h:108
vk_usbh_t * __host
Definition usb.h:132
struct usb_host_endpoint * ep_out[16]
Definition usb.h:141
enum usb_device_speed speed
Definition usb.h:137
void * dev
Definition libusb.h:896
struct usb_host_endpoint * ep_in[16]
Definition usb.h:140
vk_usbh_dev_t * __dev
Definition usb.h:133
int devnum
Definition usb.h:135
char devpath[16]
Definition usb.h:136
struct usb_host_config * actconfig
Definition usb.h:139
const struct usb_device_id * id_table
Definition usb.h:199
bool supports_autosuspend
Definition usb.h:201
struct usbdrv_wrap drvwrap
Definition usb.h:197
bool soft_unbind
Definition usb.h:203
int(* suspend)(struct usb_interface *intf, pm_message_t message)
Definition usb.h:194
bool disable_hub_initiated_lpm
Definition usb.h:202
const char * name
Definition usb.h:190
int(* probe)(struct usb_interface *intf, const struct usb_device_id *id)
Definition usb.h:192
int(* resume)(struct usb_interface *intf)
Definition usb.h:195
bool no_dynamic_id
Definition usb.h:200
void(* disconnect)(struct usb_interface *intf)
Definition usb.h:193
struct usb_interface * interface[USB_MAXINTERFACES]
Definition usb.h:98
struct usb_interface_assoc_descriptor * intf_assoc[USB_MAXIADS]
Definition usb.h:97
int extralen
Definition usb.h:101
struct usb_interface_cache * intf_cache[USB_MAXINTERFACES]
Definition usb.h:99
char * string
Definition usb.h:96
struct usb_config_descriptor desc
Definition usb.h:95
unsigned char * extra
Definition usb.h:100
unsigned char * extra
Definition usb.h:53
int extralen
Definition usb.h:54
struct usb_endpoint_descriptor desc
Definition usb.h:51
struct usb_host_endpoint * endpoint
Definition usb.h:61
char * string
Definition usb.h:62
int extralen
Definition usb.h:59
unsigned char * extra
Definition usb.h:60
struct usb_interface_descriptor desc
Definition usb.h:58
struct usb_host_interface altsetting[]
Definition usb.h:67
unsigned num_altsetting
Definition usb.h:66
unsigned needs_remote_wakeup
Definition usb.h:78
struct usb_host_interface * cur_altsetting
Definition usb.h:72
struct usb_host_interface * altsetting
Definition usb.h:71
struct device * usb_dev
Definition usb.h:76
struct device dev
Definition usb.h:75
unsigned num_altsetting
Definition usb.h:73
int status
Definition usb.h:127
unsigned int length
Definition usb.h:125
unsigned int offset
Definition usb.h:124
unsigned int actual_length
Definition usb.h:126
struct device_driver driver
Definition usb.h:186
Definition workqueue.h:15
unsigned int minor(dev_t dev)
Definition vsf_linux.c:3935
#define pipe
Definition unistd.h:86
@ USB_SPEED_HIGH
Definition usb_common.h:270
@ USB_SPEED_SUPER
Definition usb_common.h:272
vk_av_control_value_t value
Definition vsf_audio.h:171
vk_av_control_type_t type
Definition vsf_audio.h:170
uint32_t size
Definition vsf_memfs.h:50
#define vsf_usbh_malloc
Definition vsf_usbh.h:98
#define vsf_usbh_free
Definition vsf_usbh.h:108