Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef __USBHID_H
0003 #define __USBHID_H
0004 
0005 /*
0006  *  Copyright (c) 1999 Andreas Gal
0007  *  Copyright (c) 2000-2001 Vojtech Pavlik
0008  *  Copyright (c) 2006 Jiri Kosina
0009  */
0010 
0011 /*
0012  */
0013 
0014 #include <linux/types.h>
0015 #include <linux/slab.h>
0016 #include <linux/list.h>
0017 #include <linux/mutex.h>
0018 #include <linux/timer.h>
0019 #include <linux/wait.h>
0020 #include <linux/workqueue.h>
0021 #include <linux/input.h>
0022 
0023 /*  API provided by hid-core.c for USB HID drivers */
0024 void usbhid_init_reports(struct hid_device *hid);
0025 struct usb_interface *usbhid_find_interface(int minor);
0026 
0027 /* iofl flags */
0028 #define HID_CTRL_RUNNING    1
0029 #define HID_OUT_RUNNING     2
0030 #define HID_IN_RUNNING      3
0031 #define HID_RESET_PENDING   4
0032 #define HID_SUSPENDED       5
0033 #define HID_CLEAR_HALT      6
0034 #define HID_DISCONNECTED    7
0035 #define HID_STARTED     8
0036 #define HID_KEYS_PRESSED    10
0037 #define HID_NO_BANDWIDTH    11
0038 #define HID_RESUME_RUNNING  12
0039 /*
0040  * The device is opened, meaning there is a client that is interested
0041  * in data coming from the device.
0042  */
0043 #define HID_OPENED      13
0044 /*
0045  * We are polling input endpoint by [re]submitting IN URB, because
0046  * either HID device is opened or ALWAYS POLL quirk is set for the
0047  * device.
0048  */
0049 #define HID_IN_POLLING      14
0050 
0051 /*
0052  * USB-specific HID struct, to be pointed to
0053  * from struct hid_device->driver_data
0054  */
0055 
0056 struct usbhid_device {
0057     struct hid_device *hid;                     /* pointer to corresponding HID dev */
0058 
0059     struct usb_interface *intf;                                     /* USB interface */
0060     int ifnum;                                                      /* USB interface number */
0061 
0062     unsigned int bufsize;                                           /* URB buffer size */
0063 
0064     struct urb *urbin;                                              /* Input URB */
0065     char *inbuf;                                                    /* Input buffer */
0066     dma_addr_t inbuf_dma;                                           /* Input buffer dma */
0067 
0068     struct urb *urbctrl;                                            /* Control URB */
0069     struct usb_ctrlrequest *cr;                                     /* Control request struct */
0070     struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE];        /* Control fifo */
0071     unsigned char ctrlhead, ctrltail;                               /* Control fifo head & tail */
0072     char *ctrlbuf;                                                  /* Control buffer */
0073     dma_addr_t ctrlbuf_dma;                                         /* Control buffer dma */
0074     unsigned long last_ctrl;                        /* record of last output for timeouts */
0075 
0076     struct urb *urbout;                                             /* Output URB */
0077     struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE];              /* Output pipe fifo */
0078     unsigned char outhead, outtail;                                 /* Output pipe fifo head & tail */
0079     char *outbuf;                                                   /* Output buffer */
0080     dma_addr_t outbuf_dma;                                          /* Output buffer dma */
0081     unsigned long last_out;                         /* record of last output for timeouts */
0082 
0083     struct mutex mutex;                     /* start/stop/open/close */
0084     spinlock_t lock;                        /* fifo spinlock */
0085     unsigned long iofl;                                             /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
0086     struct timer_list io_retry;                                     /* Retry timer */
0087     unsigned long stop_retry;                                       /* Time to give up, in jiffies */
0088     unsigned int retry_delay;                                       /* Delay length in ms */
0089     struct work_struct reset_work;                                  /* Task context for resets */
0090     wait_queue_head_t wait;                     /* For sleeping */
0091 };
0092 
0093 #define hid_to_usb_dev(hid_dev) \
0094     to_usb_device(hid_dev->dev.parent->parent)
0095 
0096 #endif
0097