2006-12-09 01:41:03 +08:00
|
|
|
#ifndef __USBHID_H
|
|
|
|
#define __USBHID_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1999 Andreas Gal
|
|
|
|
* Copyright (c) 2000-2001 Vojtech Pavlik
|
|
|
|
* Copyright (c) 2006 Jiri Kosina
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/list.h>
|
2008-10-27 19:16:15 +08:00
|
|
|
#include <linux/mutex.h>
|
2006-12-09 01:41:03 +08:00
|
|
|
#include <linux/timer.h>
|
2008-03-20 04:55:04 +08:00
|
|
|
#include <linux/wait.h>
|
2006-12-09 01:41:03 +08:00
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
/* API provided by hid-core.c for USB HID drivers */
|
|
|
|
int usbhid_wait_io(struct hid_device* hid);
|
|
|
|
void usbhid_close(struct hid_device *hid);
|
|
|
|
int usbhid_open(struct hid_device *hid);
|
|
|
|
void usbhid_init_reports(struct hid_device *hid);
|
2008-12-17 22:38:03 +08:00
|
|
|
void usbhid_submit_report
|
|
|
|
(struct hid_device *hid, struct hid_report *report, unsigned char dir);
|
|
|
|
int usbhid_get_power(struct hid_device *hid);
|
|
|
|
void usbhid_put_power(struct hid_device *hid);
|
2010-09-13 03:32:35 +08:00
|
|
|
struct usb_interface *usbhid_find_interface(int minor);
|
2006-12-09 01:41:03 +08:00
|
|
|
|
2008-11-24 23:20:07 +08:00
|
|
|
/* iofl flags */
|
|
|
|
#define HID_CTRL_RUNNING 1
|
|
|
|
#define HID_OUT_RUNNING 2
|
|
|
|
#define HID_IN_RUNNING 3
|
|
|
|
#define HID_RESET_PENDING 4
|
|
|
|
#define HID_SUSPENDED 5
|
|
|
|
#define HID_CLEAR_HALT 6
|
|
|
|
#define HID_DISCONNECTED 7
|
|
|
|
#define HID_STARTED 8
|
2008-12-17 22:38:03 +08:00
|
|
|
#define HID_REPORTED_IDLE 9
|
|
|
|
#define HID_KEYS_PRESSED 10
|
2012-03-28 19:16:19 +08:00
|
|
|
#define HID_NO_BANDWIDTH 11
|
2008-11-24 23:20:07 +08:00
|
|
|
|
2006-12-09 01:41:03 +08:00
|
|
|
/*
|
|
|
|
* USB-specific HID struct, to be pointed to
|
|
|
|
* from struct hid_device->driver_data
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct usbhid_device {
|
|
|
|
struct hid_device *hid; /* pointer to corresponding HID dev */
|
|
|
|
|
|
|
|
struct usb_interface *intf; /* USB interface */
|
|
|
|
int ifnum; /* USB interface number */
|
|
|
|
|
|
|
|
unsigned int bufsize; /* URB buffer size */
|
|
|
|
|
|
|
|
struct urb *urbin; /* Input URB */
|
|
|
|
char *inbuf; /* Input buffer */
|
|
|
|
dma_addr_t inbuf_dma; /* Input buffer dma */
|
|
|
|
|
|
|
|
struct urb *urbctrl; /* Control URB */
|
|
|
|
struct usb_ctrlrequest *cr; /* Control request struct */
|
|
|
|
struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */
|
|
|
|
unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */
|
|
|
|
char *ctrlbuf; /* Control buffer */
|
|
|
|
dma_addr_t ctrlbuf_dma; /* Control buffer dma */
|
2010-02-12 20:02:28 +08:00
|
|
|
unsigned long last_ctrl; /* record of last output for timeouts */
|
2006-12-09 01:41:03 +08:00
|
|
|
|
|
|
|
struct urb *urbout; /* Output URB */
|
2008-10-04 20:44:06 +08:00
|
|
|
struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
|
2006-12-09 01:41:03 +08:00
|
|
|
unsigned char outhead, outtail; /* Output pipe fifo head & tail */
|
|
|
|
char *outbuf; /* Output buffer */
|
|
|
|
dma_addr_t outbuf_dma; /* Output buffer dma */
|
2010-02-12 20:02:28 +08:00
|
|
|
unsigned long last_out; /* record of last output for timeouts */
|
2006-12-09 01:41:03 +08:00
|
|
|
|
2008-12-17 22:38:03 +08:00
|
|
|
spinlock_t lock; /* fifo spinlock */
|
2006-12-09 01:41:03 +08:00
|
|
|
unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
|
|
|
|
struct timer_list io_retry; /* Retry timer */
|
|
|
|
unsigned long stop_retry; /* Time to give up, in jiffies */
|
|
|
|
unsigned int retry_delay; /* Delay length in ms */
|
|
|
|
struct work_struct reset_work; /* Task context for resets */
|
2008-03-20 04:55:04 +08:00
|
|
|
wait_queue_head_t wait; /* For sleeping */
|
2008-12-17 22:38:03 +08:00
|
|
|
int ledcount; /* counting the number of active leds */
|
2011-11-17 19:23:50 +08:00
|
|
|
|
|
|
|
struct work_struct led_work; /* Task context for setting LEDs */
|
2006-12-09 01:41:03 +08:00
|
|
|
};
|
|
|
|
|
2007-01-20 01:28:17 +08:00
|
|
|
#define hid_to_usb_dev(hid_dev) \
|
2008-05-16 17:49:15 +08:00
|
|
|
container_of(hid_dev->dev.parent->parent, struct usb_device, dev)
|
2007-01-20 01:28:17 +08:00
|
|
|
|
2006-12-09 01:41:03 +08:00
|
|
|
#endif
|
|
|
|
|