Linux Audio

Check our new training course

Loading...
Note: File does not exist in v5.14.15.
  1/*
  2 * Copyright (C) 2003-2008 Takahiro Hirofuchi
  3 *
  4 * This is free software; you can redistribute it and/or modify
  5 * it under the terms of the GNU General Public License as published by
  6 * the Free Software Foundation; either version 2 of the License, or
  7 * (at your option) any later version.
  8 *
  9 */
 10
 11#include <linux/device.h>
 12#include <linux/list.h>
 13#include <linux/spinlock.h>
 14#include <linux/sysfs.h>
 15#include <linux/types.h>
 16#include <linux/usb.h>
 17#include <linux/usb/hcd.h>
 18#include <linux/wait.h>
 19
 20struct vhci_device {
 21	struct usb_device *udev;
 22
 23	/*
 24	 * devid specifies a remote usb device uniquely instead
 25	 * of combination of busnum and devnum.
 26	 */
 27	__u32 devid;
 28
 29	/* speed of a remote device */
 30	enum usb_device_speed speed;
 31
 32	/* vhci root-hub port to which this device is attached */
 33	__u32 rhport;
 34
 35	struct usbip_device ud;
 36
 37	/* lock for the below link lists */
 38	spinlock_t priv_lock;
 39
 40	/* vhci_priv is linked to one of them. */
 41	struct list_head priv_tx;
 42	struct list_head priv_rx;
 43
 44	/* vhci_unlink is linked to one of them */
 45	struct list_head unlink_tx;
 46	struct list_head unlink_rx;
 47
 48	/* vhci_tx thread sleeps for this queue */
 49	wait_queue_head_t waitq_tx;
 50};
 51
 52/* urb->hcpriv, use container_of() */
 53struct vhci_priv {
 54	unsigned long seqnum;
 55	struct list_head list;
 56
 57	struct vhci_device *vdev;
 58	struct urb *urb;
 59};
 60
 61struct vhci_unlink {
 62	/* seqnum of this request */
 63	unsigned long seqnum;
 64
 65	struct list_head list;
 66
 67	/* seqnum of the unlink target */
 68	unsigned long unlink_seqnum;
 69};
 70
 71/*
 72 * The number of ports is less than 16 ?
 73 * USB_MAXCHILDREN is statically defined to 16 in usb.h.  Its maximum value
 74 * would be 31 because the event_bits[1] of struct usb_hub is defined as
 75 * unsigned long in hub.h
 76 */
 77#define VHCI_NPORTS 8
 78
 79/* for usb_bus.hcpriv */
 80struct vhci_hcd {
 81	spinlock_t lock;
 82
 83	u32 port_status[VHCI_NPORTS];
 84
 85	unsigned resuming:1;
 86	unsigned long re_timeout;
 87
 88	atomic_t seqnum;
 89
 90	/*
 91	 * NOTE:
 92	 * wIndex shows the port number and begins from 1.
 93	 * But, the index of this array begins from 0.
 94	 */
 95	struct vhci_device vdev[VHCI_NPORTS];
 96};
 97
 98extern struct vhci_hcd *the_controller;
 99extern const struct attribute_group dev_attr_group;
100#define hardware (&the_controller->pdev.dev)
101
102/* vhci_hcd.c */
103void rh_port_connect(int rhport, enum usb_device_speed speed);
104void rh_port_disconnect(int rhport);
105
106/* vhci_rx.c */
107struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum);
108int vhci_rx_loop(void *data);
109
110/* vhci_tx.c */
111int vhci_tx_loop(void *data);
112
113static inline struct vhci_device *port_to_vdev(__u32 port)
114{
115	return &the_controller->vdev[port];
116}
117
118static inline struct vhci_hcd *hcd_to_vhci(struct usb_hcd *hcd)
119{
120	return (struct vhci_hcd *) (hcd->hcd_priv);
121}
122
123static inline struct usb_hcd *vhci_to_hcd(struct vhci_hcd *vhci)
124{
125	return container_of((void *) vhci, struct usb_hcd, hcd_priv);
126}
127
128static inline struct device *vhci_dev(struct vhci_hcd *vhci)
129{
130	return vhci_to_hcd(vhci)->self.controller;
131}