blob: b47f991867e9d096680bde9b7aa8a528f4e8cdb7 [file] [log] [blame]
Jiri Kosina4916b3a2006-12-08 18:41:03 +01001#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>
30#include <linux/timer.h>
Jiri Slaby1d1bdd22008-03-19 21:55:04 +010031#include <linux/wait.h>
Jiri Kosina4916b3a2006-12-08 18:41:03 +010032#include <linux/workqueue.h>
33#include <linux/input.h>
34
35/* API provided by hid-core.c for USB HID drivers */
36int usbhid_wait_io(struct hid_device* hid);
37void usbhid_close(struct hid_device *hid);
38int usbhid_open(struct hid_device *hid);
39void usbhid_init_reports(struct hid_device *hid);
40void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir);
41
42/*
43 * USB-specific HID struct, to be pointed to
44 * from struct hid_device->driver_data
45 */
46
47struct usbhid_device {
48 struct hid_device *hid; /* pointer to corresponding HID dev */
49
50 struct usb_interface *intf; /* USB interface */
51 int ifnum; /* USB interface number */
52
53 unsigned int bufsize; /* URB buffer size */
54
55 struct urb *urbin; /* Input URB */
56 char *inbuf; /* Input buffer */
57 dma_addr_t inbuf_dma; /* Input buffer dma */
58 spinlock_t inlock; /* Input fifo spinlock */
59
60 struct urb *urbctrl; /* Control URB */
61 struct usb_ctrlrequest *cr; /* Control request struct */
62 dma_addr_t cr_dma; /* Control request struct dma */
63 struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */
64 unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */
65 char *ctrlbuf; /* Control buffer */
66 dma_addr_t ctrlbuf_dma; /* Control buffer dma */
67 spinlock_t ctrllock; /* Control fifo spinlock */
68
69 struct urb *urbout; /* Output URB */
70 struct hid_report *out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
71 unsigned char outhead, outtail; /* Output pipe fifo head & tail */
72 char *outbuf; /* Output buffer */
73 dma_addr_t outbuf_dma; /* Output buffer dma */
74 spinlock_t outlock; /* Output fifo spinlock */
75
76 unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
77 struct timer_list io_retry; /* Retry timer */
78 unsigned long stop_retry; /* Time to give up, in jiffies */
79 unsigned int retry_delay; /* Delay length in ms */
80 struct work_struct reset_work; /* Task context for resets */
Jiri Slaby1d1bdd22008-03-19 21:55:04 +010081 wait_queue_head_t wait; /* For sleeping */
Jiri Kosina4916b3a2006-12-08 18:41:03 +010082};
83
Anssi Hannulabe820972007-01-19 19:28:17 +020084#define hid_to_usb_dev(hid_dev) \
Jiri Slaby85cdaf52008-05-16 11:49:15 +020085 container_of(hid_dev->dev.parent->parent, struct usb_device, dev)
Anssi Hannulabe820972007-01-19 19:28:17 +020086
Jiri Kosina4916b3a2006-12-08 18:41:03 +010087#endif
88