]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
4916b3a5 JK |
2 | #ifndef __USBHID_H |
3 | #define __USBHID_H | |
4 | ||
5 | /* | |
6 | * Copyright (c) 1999 Andreas Gal | |
7 | * Copyright (c) 2000-2001 Vojtech Pavlik | |
8 | * Copyright (c) 2006 Jiri Kosina | |
9 | */ | |
10 | ||
11 | /* | |
4916b3a5 JK |
12 | */ |
13 | ||
14 | #include <linux/types.h> | |
15 | #include <linux/slab.h> | |
16 | #include <linux/list.h> | |
3d5afd32 | 17 | #include <linux/mutex.h> |
4916b3a5 | 18 | #include <linux/timer.h> |
1d1bdd20 | 19 | #include <linux/wait.h> |
4916b3a5 JK |
20 | #include <linux/workqueue.h> |
21 | #include <linux/input.h> | |
22 | ||
23 | /* API provided by hid-core.c for USB HID drivers */ | |
4916b3a5 | 24 | void usbhid_init_reports(struct hid_device *hid); |
8fe294ca | 25 | struct usb_interface *usbhid_find_interface(int minor); |
4916b3a5 | 26 | |
0ed94b33 JS |
27 | /* iofl flags */ |
28 | #define HID_CTRL_RUNNING 1 | |
29 | #define HID_OUT_RUNNING 2 | |
30 | #define HID_IN_RUNNING 3 | |
31 | #define HID_RESET_PENDING 4 | |
32 | #define HID_SUSPENDED 5 | |
33 | #define HID_CLEAR_HALT 6 | |
34 | #define HID_DISCONNECTED 7 | |
35 | #define HID_STARTED 8 | |
0361a28d | 36 | #define HID_KEYS_PRESSED 10 |
a8c52b66 | 37 | #define HID_NO_BANDWIDTH 11 |
b905811a | 38 | #define HID_RESUME_RUNNING 12 |
28cbc863 DT |
39 | /* |
40 | * The device is opened, meaning there is a client that is interested | |
41 | * in data coming from the device. | |
42 | */ | |
43 | #define HID_OPENED 13 | |
44 | /* | |
45 | * We are polling input endpoint by [re]submitting IN URB, because | |
46 | * either HID device is opened or ALWAYS POLL quirk is set for the | |
47 | * device. | |
48 | */ | |
49 | #define HID_IN_POLLING 14 | |
0ed94b33 | 50 | |
4916b3a5 JK |
51 | /* |
52 | * USB-specific HID struct, to be pointed to | |
53 | * from struct hid_device->driver_data | |
54 | */ | |
55 | ||
56 | struct usbhid_device { | |
57 | struct hid_device *hid; /* pointer to corresponding HID dev */ | |
58 | ||
59 | struct usb_interface *intf; /* USB interface */ | |
60 | int ifnum; /* USB interface number */ | |
61 | ||
62 | unsigned int bufsize; /* URB buffer size */ | |
63 | ||
64 | struct urb *urbin; /* Input URB */ | |
65 | char *inbuf; /* Input buffer */ | |
66 | dma_addr_t inbuf_dma; /* Input buffer dma */ | |
4916b3a5 JK |
67 | |
68 | struct urb *urbctrl; /* Control URB */ | |
69 | struct usb_ctrlrequest *cr; /* Control request struct */ | |
4916b3a5 JK |
70 | struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */ |
71 | unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */ | |
72 | char *ctrlbuf; /* Control buffer */ | |
73 | dma_addr_t ctrlbuf_dma; /* Control buffer dma */ | |
858155fb | 74 | unsigned long last_ctrl; /* record of last output for timeouts */ |
4916b3a5 JK |
75 | |
76 | struct urb *urbout; /* Output URB */ | |
f129ea6d | 77 | struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */ |
4916b3a5 JK |
78 | unsigned char outhead, outtail; /* Output pipe fifo head & tail */ |
79 | char *outbuf; /* Output buffer */ | |
80 | dma_addr_t outbuf_dma; /* Output buffer dma */ | |
858155fb | 81 | unsigned long last_out; /* record of last output for timeouts */ |
4916b3a5 | 82 | |
0361a28d | 83 | spinlock_t lock; /* fifo spinlock */ |
4916b3a5 JK |
84 | unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ |
85 | struct timer_list io_retry; /* Retry timer */ | |
86 | unsigned long stop_retry; /* Time to give up, in jiffies */ | |
87 | unsigned int retry_delay; /* Delay length in ms */ | |
88 | struct work_struct reset_work; /* Task context for resets */ | |
1d1bdd20 | 89 | wait_queue_head_t wait; /* For sleeping */ |
4916b3a5 JK |
90 | }; |
91 | ||
be820975 | 92 | #define hid_to_usb_dev(hid_dev) \ |
7775fb92 | 93 | to_usb_device(hid_dev->dev.parent->parent) |
be820975 | 94 | |
4916b3a5 JK |
95 | #endif |
96 |