2019-05-27 13:55:05 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2006-12-09 00:41:03 +07:00
|
|
|
#ifndef __USBHID_H
|
|
|
|
#define __USBHID_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1999 Andreas Gal
|
|
|
|
* Copyright (c) 2000-2001 Vojtech Pavlik
|
|
|
|
* Copyright (c) 2006 Jiri Kosina
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/list.h>
|
2008-10-27 18:16:15 +07:00
|
|
|
#include <linux/mutex.h>
|
2006-12-09 00:41:03 +07:00
|
|
|
#include <linux/timer.h>
|
2008-03-20 03:55:04 +07:00
|
|
|
#include <linux/wait.h>
|
2006-12-09 00:41:03 +07:00
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
/* API provided by hid-core.c for USB HID drivers */
|
|
|
|
void usbhid_init_reports(struct hid_device *hid);
|
2010-09-13 02:32:35 +07:00
|
|
|
struct usb_interface *usbhid_find_interface(int minor);
|
2006-12-09 00:41:03 +07:00
|
|
|
|
2008-11-24 22:20:07 +07: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 21:38:03 +07:00
|
|
|
#define HID_KEYS_PRESSED 10
|
2012-03-28 18:16:19 +07:00
|
|
|
#define HID_NO_BANDWIDTH 11
|
HID: usbhid: prevent unwanted events to be sent when re-opening the device
When events occurs while no one is listening to the node (hid->open == 0
and usb_kill_urb() called) some events are still stacked somewhere in
the USB (kernel or device?) stack. When the node gets reopened, these
events are drained, and this results in spurious touch down/up, or mouse
button clicks.
The problem was spotted with touchscreens in fdo bug #81781 [1], but it
actually occurs with any mouse using hid-generic or touchscreen.
A way to reproduce it is to call:
$ xinput disable 9 ; sleep 5 ; xinput enable 9
With 9 being the device ID for the touchscreen/mouse. During the "sleep",
produce some touch events or click events. When "xinput enable" is called,
at least one click is generated.
This patch tries to fix this by draining the queue for 50 msec and
during this time frame, not forwarding these old events to the hid layer.
Hans completed the explanation:
"""
Devices like mice (basically any hid device) will have a fifo
on the device side, when we stop submitting urbs to get hid reports from
it, that fifo will fill up, and when we resume we will get whatever
is there in that fifo.
"""
[1] https://bugs.freedesktop.org/show_bug.cgi?id=81781
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-10-01 01:28:22 +07:00
|
|
|
#define HID_RESUME_RUNNING 12
|
2017-06-07 13:59:33 +07:00
|
|
|
/*
|
|
|
|
* The device is opened, meaning there is a client that is interested
|
|
|
|
* in data coming from the device.
|
|
|
|
*/
|
|
|
|
#define HID_OPENED 13
|
|
|
|
/*
|
|
|
|
* We are polling input endpoint by [re]submitting IN URB, because
|
|
|
|
* either HID device is opened or ALWAYS POLL quirk is set for the
|
|
|
|
* device.
|
|
|
|
*/
|
|
|
|
#define HID_IN_POLLING 14
|
2008-11-24 22:20:07 +07:00
|
|
|
|
2006-12-09 00:41:03 +07: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 19:02:28 +07:00
|
|
|
unsigned long last_ctrl; /* record of last output for timeouts */
|
2006-12-09 00:41:03 +07:00
|
|
|
|
|
|
|
struct urb *urbout; /* Output URB */
|
2008-10-04 19:44:06 +07:00
|
|
|
struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
|
2006-12-09 00:41:03 +07: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 19:02:28 +07:00
|
|
|
unsigned long last_out; /* record of last output for timeouts */
|
2006-12-09 00:41:03 +07:00
|
|
|
|
2008-12-17 21:38:03 +07:00
|
|
|
spinlock_t lock; /* fifo spinlock */
|
2006-12-09 00:41:03 +07: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 03:55:04 +07:00
|
|
|
wait_queue_head_t wait; /* For sleeping */
|
2006-12-09 00:41:03 +07:00
|
|
|
};
|
|
|
|
|
2007-01-20 00:28:17 +07:00
|
|
|
#define hid_to_usb_dev(hid_dev) \
|
2015-12-23 20:26:53 +07:00
|
|
|
to_usb_device(hid_dev->dev.parent->parent)
|
2007-01-20 00:28:17 +07:00
|
|
|
|
2006-12-09 00:41:03 +07:00
|
|
|
#endif
|
|
|
|
|