Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1 | #ifndef __USBHID_H |
| 2 | #define __USBHID_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright (c) 1999 Andreas Gal |
| 6 | * Copyright (c) 2000-2001 Vojtech Pavlik |
| 7 | * Copyright (c) 2006 Jiri Kosina |
| 8 | */ |
| 9 | |
| 10 | /* |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #include <linux/types.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/list.h> |
Jiri Slaby | 3d5afd3 | 2008-10-27 12:16:15 +0100 | [diff] [blame] | 30 | #include <linux/mutex.h> |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 31 | #include <linux/timer.h> |
Jiri Slaby | 1d1bdd2 | 2008-03-19 21:55:04 +0100 | [diff] [blame] | 32 | #include <linux/wait.h> |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 33 | #include <linux/workqueue.h> |
| 34 | #include <linux/input.h> |
| 35 | |
| 36 | /* API provided by hid-core.c for USB HID drivers */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 37 | void usbhid_close(struct hid_device *hid); |
| 38 | int usbhid_open(struct hid_device *hid); |
| 39 | void usbhid_init_reports(struct hid_device *hid); |
Oliver Neukum | 0361a28 | 2008-12-17 15:38:03 +0100 | [diff] [blame] | 40 | int usbhid_get_power(struct hid_device *hid); |
| 41 | void usbhid_put_power(struct hid_device *hid); |
Guillaume Chazarain | 8fe294c | 2010-09-12 21:32:35 +0200 | [diff] [blame] | 42 | struct usb_interface *usbhid_find_interface(int minor); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 43 | |
Jiri Slaby | 0ed94b3 | 2008-11-24 16:20:07 +0100 | [diff] [blame] | 44 | /* iofl flags */ |
| 45 | #define HID_CTRL_RUNNING 1 |
| 46 | #define HID_OUT_RUNNING 2 |
| 47 | #define HID_IN_RUNNING 3 |
| 48 | #define HID_RESET_PENDING 4 |
| 49 | #define HID_SUSPENDED 5 |
| 50 | #define HID_CLEAR_HALT 6 |
| 51 | #define HID_DISCONNECTED 7 |
| 52 | #define HID_STARTED 8 |
Oliver Neukum | 0361a28 | 2008-12-17 15:38:03 +0100 | [diff] [blame] | 53 | #define HID_KEYS_PRESSED 10 |
Oliver Neukum | a8c52b6 | 2012-03-28 13:16:19 +0200 | [diff] [blame] | 54 | #define HID_NO_BANDWIDTH 11 |
Benjamin Tissoires | b905811 | 2014-09-30 14:28:22 -0400 | [diff] [blame] | 55 | #define HID_RESUME_RUNNING 12 |
Jiri Slaby | 0ed94b3 | 2008-11-24 16:20:07 +0100 | [diff] [blame] | 56 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 57 | /* |
| 58 | * USB-specific HID struct, to be pointed to |
| 59 | * from struct hid_device->driver_data |
| 60 | */ |
| 61 | |
| 62 | struct usbhid_device { |
| 63 | struct hid_device *hid; /* pointer to corresponding HID dev */ |
| 64 | |
| 65 | struct usb_interface *intf; /* USB interface */ |
| 66 | int ifnum; /* USB interface number */ |
| 67 | |
| 68 | unsigned int bufsize; /* URB buffer size */ |
| 69 | |
| 70 | struct urb *urbin; /* Input URB */ |
| 71 | char *inbuf; /* Input buffer */ |
| 72 | dma_addr_t inbuf_dma; /* Input buffer dma */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 73 | |
| 74 | struct urb *urbctrl; /* Control URB */ |
| 75 | struct usb_ctrlrequest *cr; /* Control request struct */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 76 | struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */ |
| 77 | unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */ |
| 78 | char *ctrlbuf; /* Control buffer */ |
| 79 | dma_addr_t ctrlbuf_dma; /* Control buffer dma */ |
Oliver Neukum | 858155f | 2010-02-12 13:02:28 +0100 | [diff] [blame] | 80 | unsigned long last_ctrl; /* record of last output for timeouts */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 81 | |
| 82 | struct urb *urbout; /* Output URB */ |
Anssi Hannula | f129ea6 | 2008-10-04 14:44:06 +0200 | [diff] [blame] | 83 | struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 84 | unsigned char outhead, outtail; /* Output pipe fifo head & tail */ |
| 85 | char *outbuf; /* Output buffer */ |
| 86 | dma_addr_t outbuf_dma; /* Output buffer dma */ |
Oliver Neukum | 858155f | 2010-02-12 13:02:28 +0100 | [diff] [blame] | 87 | unsigned long last_out; /* record of last output for timeouts */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 88 | |
Oliver Neukum | 0361a28 | 2008-12-17 15:38:03 +0100 | [diff] [blame] | 89 | spinlock_t lock; /* fifo spinlock */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 90 | unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ |
| 91 | struct timer_list io_retry; /* Retry timer */ |
| 92 | unsigned long stop_retry; /* Time to give up, in jiffies */ |
| 93 | unsigned int retry_delay; /* Delay length in ms */ |
| 94 | struct work_struct reset_work; /* Task context for resets */ |
Jiri Slaby | 1d1bdd2 | 2008-03-19 21:55:04 +0100 | [diff] [blame] | 95 | wait_queue_head_t wait; /* For sleeping */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 96 | }; |
| 97 | |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 98 | #define hid_to_usb_dev(hid_dev) \ |
Geliang Tang | 7775fb9 | 2015-12-23 21:26:53 +0800 | [diff] [blame] | 99 | to_usb_device(hid_dev->dev.parent->parent) |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 100 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 101 | #endif |
| 102 | |