Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/dtor/input

* 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/dtor/input: (65 commits)
  Input: gpio_keys - add support for switches (EV_SW)
  Input: cobalt_btns - convert to use polldev library
  Input: add skeleton for simple polled devices
  Input: update some documentation
  Input: wistron - fix typo in keymap for Acer TM610
  Input: add input_set_capability() helper
  Input: i8042 - add Fujitsu touchscreen/touchpad PNP IDs
  Input: i8042 - add Panasonic CF-29 to nomux list
  Input: lifebook - split into 2 devices
  Input: lifebook - add signature of Panasonic CF-29
  Input: lifebook - activate 6-byte protocol on select models
  Input: lifebook - work properly on Panasonic CF-18
  Input: cobalt buttons - separate device and driver registration
  Input: ati_remote - make button repeat sensitivity configurable
  Input: pxa27x - do not use deprecated SA_INTERRUPT flag
  Input: ucb1400 - make delays configurable
  Input: misc devices - switch to using input_dev->dev.parent
  Input: joysticks - switch to using input_dev->dev.parent
  Input: touchscreens - switch to using input_dev->dev.parent
  Input: mice - switch to using input_dev->dev.parent
  ...

Fixed up conflicts with core device model removal of "struct subsystem" manually.

Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Linus Torvalds 2007-05-04 18:13:17 -07:00
commit a3d52136ee
120 changed files with 4334 additions and 3250 deletions

View file

@ -10,9 +10,6 @@ obj-$(CONFIG_USB_ATI_REMOTE) += ati_remote.o
obj-$(CONFIG_USB_ATI_REMOTE2) += ati_remote2.o
obj-$(CONFIG_USB_KBTAB) += kbtab.o
obj-$(CONFIG_USB_KEYSPAN_REMOTE) += keyspan_remote.o
obj-$(CONFIG_USB_MTOUCH) += mtouchusb.o
obj-$(CONFIG_USB_ITMTOUCH) += itmtouch.o
obj-$(CONFIG_USB_EGALAX) += touchkitusb.o
obj-$(CONFIG_USB_TOUCHSCREEN) += usbtouchscreen.o
obj-$(CONFIG_USB_POWERMATE) += powermate.o
obj-$(CONFIG_USB_WACOM) += wacom.o
@ -20,7 +17,7 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o
obj-$(CONFIG_USB_YEALINK) += yealink.o
obj-$(CONFIG_USB_XPAD) += xpad.o
obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o
obj-$(CONFIG_USB_GTCO) += gtco.o
obj-$(CONFIG_USB_GTCO) += gtco.o
ifeq ($(CONFIG_USB_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG

View file

@ -111,7 +111,7 @@ resubmit:
static int usb_acecad_open(struct input_dev *dev)
{
struct usb_acecad *acecad = dev->private;
struct usb_acecad *acecad = input_get_drvdata(dev);
acecad->irq->dev = acecad->usbdev;
if (usb_submit_urb(acecad->irq, GFP_KERNEL))
@ -122,7 +122,7 @@ static int usb_acecad_open(struct input_dev *dev)
static void usb_acecad_close(struct input_dev *dev)
{
struct usb_acecad *acecad = dev->private;
struct usb_acecad *acecad = input_get_drvdata(dev);
usb_kill_urb(acecad->irq);
}
@ -135,6 +135,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
struct usb_acecad *acecad;
struct input_dev *input_dev;
int pipe, maxp;
int err = -ENOMEM;
if (interface->desc.bNumEndpoints != 1)
return -ENODEV;
@ -149,16 +150,22 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL);
input_dev = input_allocate_device();
if (!acecad || !input_dev)
if (!acecad || !input_dev) {
err = -ENOMEM;
goto fail1;
}
acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma);
if (!acecad->data)
if (!acecad->data) {
err= -ENOMEM;
goto fail1;
}
acecad->irq = usb_alloc_urb(0, GFP_KERNEL);
if (!acecad->irq)
if (!acecad->irq) {
err = -ENOMEM;
goto fail2;
}
acecad->usbdev = dev;
acecad->input = input_dev;
@ -178,8 +185,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
input_dev->name = acecad->name;
input_dev->phys = acecad->phys;
usb_to_input_id(dev, &input_dev->id);
input_dev->cdev.dev = &intf->dev;
input_dev->private = acecad;
input_dev->dev.parent = &intf->dev;
input_set_drvdata(input_dev, acecad);
input_dev->open = usb_acecad_open;
input_dev->close = usb_acecad_close;
@ -221,7 +229,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
acecad->irq->transfer_dma = acecad->data_dma;
acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
input_register_device(acecad->input);
err = input_register_device(acecad->input);
if (err)
goto fail2;
usb_set_intfdata(intf, acecad);
@ -230,7 +240,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma);
fail1: input_free_device(input_dev);
kfree(acecad);
return -ENOMEM;
return err;
}
static void usb_acecad_disconnect(struct usb_interface *intf)

View file

@ -798,7 +798,7 @@ MODULE_DEVICE_TABLE(usb, aiptek_ids);
*/
static int aiptek_open(struct input_dev *inputdev)
{
struct aiptek *aiptek = inputdev->private;
struct aiptek *aiptek = input_get_drvdata(inputdev);
aiptek->urb->dev = aiptek->usbdev;
if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0)
@ -812,7 +812,7 @@ static int aiptek_open(struct input_dev *inputdev)
*/
static void aiptek_close(struct input_dev *inputdev)
{
struct aiptek *aiptek = inputdev->private;
struct aiptek *aiptek = input_get_drvdata(inputdev);
usb_kill_urb(aiptek->urb);
}
@ -1972,6 +1972,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
AIPTEK_PROGRAMMABLE_DELAY_200,
AIPTEK_PROGRAMMABLE_DELAY_300
};
int err = -ENOMEM;
/* programmableDelay is where the command-line specified
* delay is kept. We make it the first element of speeds[],
@ -2043,8 +2044,10 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
inputdev->name = "Aiptek";
inputdev->phys = aiptek->features.usbPath;
usb_to_input_id(usbdev, &inputdev->id);
inputdev->cdev.dev = &intf->dev;
inputdev->private = aiptek;
inputdev->dev.parent = &intf->dev;
input_set_drvdata(inputdev, aiptek);
inputdev->open = aiptek_open;
inputdev->close = aiptek_close;
@ -2133,7 +2136,9 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
/* Register the tablet as an Input Device
*/
input_register_device(aiptek->inputdev);
err = input_register_device(aiptek->inputdev);
if (err)
goto fail2;
/* We now will look for the evdev device which is mapped to
* the tablet. The partial name is kept in the link list of
@ -2165,23 +2170,13 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
return 0;
fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
aiptek->data_dma);
fail1: input_free_device(inputdev);
fail1: input_free_device(inputdev);
kfree(aiptek);
return -ENOMEM;
return err;
}
/* Forward declaration */
static void aiptek_disconnect(struct usb_interface *intf);
static struct usb_driver aiptek_driver = {
.name = "aiptek",
.probe = aiptek_probe,
.disconnect = aiptek_disconnect,
.id_table = aiptek_ids,
};
/***********************************************************************
* Deal with tablet disconnecting from the system.
*/
@ -2206,6 +2201,13 @@ static void aiptek_disconnect(struct usb_interface *intf)
}
}
static struct usb_driver aiptek_driver = {
.name = "aiptek",
.probe = aiptek_probe,
.disconnect = aiptek_disconnect,
.id_table = aiptek_ids,
};
static int __init aiptek_init(void)
{
int result = usb_register(&aiptek_driver);

View file

@ -466,7 +466,7 @@ exit:
static int atp_open(struct input_dev *input)
{
struct atp *dev = input->private;
struct atp *dev = input_get_drvdata(input);
if (usb_submit_urb(dev->urb, GFP_ATOMIC))
return -EIO;
@ -477,7 +477,7 @@ static int atp_open(struct input_dev *input)
static void atp_close(struct input_dev *input)
{
struct atp *dev = input->private;
struct atp *dev = input_get_drvdata(input);
usb_kill_urb(dev->urb);
dev->open = 0;
@ -491,8 +491,7 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint;
int int_in_endpointAddr = 0;
int i, retval = -ENOMEM;
int i, error = -ENOMEM;
/* set up the endpoint information */
/* use only the first interrupt-in endpoint */
@ -567,17 +566,13 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
}
dev->urb = usb_alloc_urb(0, GFP_KERNEL);
if (!dev->urb) {
retval = -ENOMEM;
if (!dev->urb)
goto err_free_devs;
}
dev->data = usb_buffer_alloc(dev->udev, dev->datalen, GFP_KERNEL,
&dev->urb->transfer_dma);
if (!dev->data) {
retval = -ENOMEM;
if (!dev->data)
goto err_free_urb;
}
usb_fill_int_urb(dev->urb, udev,
usb_rcvintpipe(udev, int_in_endpointAddr),
@ -589,9 +584,10 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
input_dev->name = "appletouch";
input_dev->phys = dev->phys;
usb_to_input_id(dev->udev, &input_dev->id);
input_dev->cdev.dev = &iface->dev;
input_dev->dev.parent = &iface->dev;
input_set_drvdata(input_dev, dev);
input_dev->private = dev;
input_dev->open = atp_open;
input_dev->close = atp_close;
@ -633,20 +629,25 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
set_bit(BTN_LEFT, input_dev->keybit);
input_register_device(dev->input);
error = input_register_device(dev->input);
if (error)
goto err_free_buffer;
/* save our data pointer in this interface device */
usb_set_intfdata(iface, dev);
return 0;
err_free_buffer:
usb_buffer_free(dev->udev, dev->datalen,
dev->data, dev->urb->transfer_dma);
err_free_urb:
usb_free_urb(dev->urb);
err_free_devs:
usb_set_intfdata(iface, NULL);
kfree(dev);
input_free_device(input_dev);
return retval;
return error;
}
static void atp_disconnect(struct usb_interface *iface)

View file

@ -120,6 +120,7 @@
* behaviour.
*/
#define FILTER_TIME 60 /* msec */
#define REPEAT_DELAY 500 /* msec */
static unsigned long channel_mask;
module_param(channel_mask, ulong, 0644);
@ -133,6 +134,10 @@ static int repeat_filter = FILTER_TIME;
module_param(repeat_filter, int, 0644);
MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec");
static int repeat_delay = REPEAT_DELAY;
module_param(repeat_delay, int, 0644);
MODULE_PARM_DESC(repeat_delay, "Delay before sending repeats, default = 500 msec");
#define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0)
#undef err
#define err(format, arg...) printk(KERN_ERR format , ## arg)
@ -174,6 +179,8 @@ struct ati_remote {
unsigned char old_data[2]; /* Detect duplicate events */
unsigned long old_jiffies;
unsigned long acc_jiffies; /* handle acceleration */
unsigned long first_jiffies;
unsigned int repeat_count;
char name[NAME_BUFSIZE];
@ -318,7 +325,7 @@ static void ati_remote_dump(unsigned char *data, unsigned int len)
*/
static int ati_remote_open(struct input_dev *inputdev)
{
struct ati_remote *ati_remote = inputdev->private;
struct ati_remote *ati_remote = input_get_drvdata(inputdev);
/* On first open, submit the read urb which was set up previously. */
ati_remote->irq_urb->dev = ati_remote->udev;
@ -336,7 +343,7 @@ static int ati_remote_open(struct input_dev *inputdev)
*/
static void ati_remote_close(struct input_dev *inputdev)
{
struct ati_remote *ati_remote = inputdev->private;
struct ati_remote *ati_remote = input_get_drvdata(inputdev);
usb_kill_urb(ati_remote->irq_urb);
}
@ -501,21 +508,31 @@ static void ati_remote_input_report(struct urb *urb)
}
if (ati_remote_tbl[index].kind == KIND_FILTERED) {
unsigned long now = jiffies;
/* Filter duplicate events which happen "too close" together. */
if (ati_remote->old_data[0] == data[1] &&
ati_remote->old_data[1] == data[2] &&
time_before(jiffies, ati_remote->old_jiffies + msecs_to_jiffies(repeat_filter))) {
time_before(now, ati_remote->old_jiffies +
msecs_to_jiffies(repeat_filter))) {
ati_remote->repeat_count++;
} else {
ati_remote->repeat_count = 0;
ati_remote->first_jiffies = now;
}
ati_remote->old_data[0] = data[1];
ati_remote->old_data[1] = data[2];
ati_remote->old_jiffies = jiffies;
ati_remote->old_jiffies = now;
/* Ensure we skip at least the 4 first duplicate events (generated
* by a single keypress), and continue skipping until repeat_delay
* msecs have passed
*/
if (ati_remote->repeat_count > 0 &&
ati_remote->repeat_count < 5)
(ati_remote->repeat_count < 5 ||
time_before(now, ati_remote->first_jiffies +
msecs_to_jiffies(repeat_delay))))
return;
@ -653,7 +670,8 @@ static void ati_remote_input_init(struct ati_remote *ati_remote)
if (ati_remote_tbl[i].type == EV_KEY)
set_bit(ati_remote_tbl[i].code, idev->keybit);
idev->private = ati_remote;
input_set_drvdata(idev, ati_remote);
idev->open = ati_remote_open;
idev->close = ati_remote_close;
@ -661,7 +679,7 @@ static void ati_remote_input_init(struct ati_remote *ati_remote)
idev->phys = ati_remote->phys;
usb_to_input_id(ati_remote->udev, &idev->id);
idev->cdev.dev = &ati_remote->udev->dev;
idev->dev.parent = &ati_remote->udev->dev;
}
static int ati_remote_initialize(struct ati_remote *ati_remote)
@ -772,15 +790,17 @@ static int ati_remote_probe(struct usb_interface *interface, const struct usb_de
goto fail3;
/* Set up and register input device */
input_register_device(ati_remote->idev);
err = input_register_device(ati_remote->idev);
if (err)
goto fail3;
usb_set_intfdata(interface, ati_remote);
return 0;
fail3: usb_kill_urb(ati_remote->irq_urb);
fail3: usb_kill_urb(ati_remote->irq_urb);
usb_kill_urb(ati_remote->out_urb);
fail2: ati_remote_free_buffers(ati_remote);
fail1: input_free_device(input_dev);
fail2: ati_remote_free_buffers(ati_remote);
fail1: input_free_device(input_dev);
kfree(ati_remote);
return err;
}

View file

@ -131,7 +131,7 @@ static struct usb_driver ati_remote2_driver = {
static int ati_remote2_open(struct input_dev *idev)
{
struct ati_remote2 *ar2 = idev->private;
struct ati_remote2 *ar2 = input_get_drvdata(idev);
int r;
r = usb_submit_urb(ar2->urb[0], GFP_KERNEL);
@ -153,7 +153,7 @@ static int ati_remote2_open(struct input_dev *idev)
static void ati_remote2_close(struct input_dev *idev)
{
struct ati_remote2 *ar2 = idev->private;
struct ati_remote2 *ar2 = input_get_drvdata(idev);
usb_kill_urb(ar2->urb[0]);
usb_kill_urb(ar2->urb[1]);
@ -337,14 +337,14 @@ static void ati_remote2_complete_key(struct urb *urb)
static int ati_remote2_input_init(struct ati_remote2 *ar2)
{
struct input_dev *idev;
int i;
int i, retval;
idev = input_allocate_device();
if (!idev)
return -ENOMEM;
ar2->idev = idev;
idev->private = ar2;
input_set_drvdata(idev, ar2);
idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_REL);
idev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
@ -362,13 +362,13 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2)
idev->phys = ar2->phys;
usb_to_input_id(ar2->udev, &idev->id);
idev->cdev.dev = &ar2->udev->dev;
idev->dev.parent = &ar2->udev->dev;
i = input_register_device(idev);
if (i)
retval = input_register_device(idev);
if (retval)
input_free_device(idev);
return i;
return retval;
}
static int ati_remote2_urb_init(struct ati_remote2 *ar2)

File diff suppressed because it is too large Load diff

View file

@ -1,271 +0,0 @@
/******************************************************************************
* itmtouch.c -- Driver for ITM touchscreen panel
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Based upon original work by Chris Collins <xfire-itmtouch@xware.cx>.
*
* Kudos to ITM for providing me with the datasheet for the panel,
* even though it was a day later than I had finished writing this
* driver.
*
* It has meant that I've been able to correct my interpretation of the
* protocol packets however.
*
* CC -- 2003/9/29
*
* History
* 1.0 & 1.1 2003 (CC) vojtech@suse.cz
* Original version for 2.4.x kernels
*
* 1.2 02/03/2005 (HCE) hc@mivu.no
* Complete rewrite to support Linux 2.6.10, thanks to mtouchusb.c for hints.
* Unfortunately no calibration support at this time.
*
* 1.2.1 09/03/2005 (HCE) hc@mivu.no
* Code cleanup and adjusting syntax to start matching kernel standards
*
* 1.2.2 10/05/2006 (MJA) massad@gmail.com
* Flag for detecting if the screen was being touch was incorrectly
* inverted, so no touch events were being detected.
*
*****************************************************************************/
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/usb/input.h>
/* only an 8 byte buffer necessary for a single packet */
#define ITM_BUFSIZE 8
#define PATH_SIZE 64
#define USB_VENDOR_ID_ITMINC 0x0403
#define USB_PRODUCT_ID_TOUCHPANEL 0xf9e9
#define DRIVER_AUTHOR "Hans-Christian Egtvedt <[email protected]>"
#define DRIVER_VERSION "v1.2.2"
#define DRIVER_DESC "USB ITM Inc Touch Panel Driver"
#define DRIVER_LICENSE "GPL"
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE( DRIVER_LICENSE );
struct itmtouch_dev {
struct usb_device *usbdev; /* usb device */
struct input_dev *inputdev; /* input device */
struct urb *readurb; /* urb */
char rbuf[ITM_BUFSIZE]; /* data */
int users;
char name[128];
char phys[64];
};
static struct usb_device_id itmtouch_ids [] = {
{ USB_DEVICE(USB_VENDOR_ID_ITMINC, USB_PRODUCT_ID_TOUCHPANEL) },
{ }
};
static void itmtouch_irq(struct urb *urb)
{
struct itmtouch_dev *itmtouch = urb->context;
unsigned char *data = urb->transfer_buffer;
struct input_dev *dev = itmtouch->inputdev;
int retval;
switch (urb->status) {
case 0:
/* success */
break;
case -ETIME:
/* this urb is timing out */
dbg("%s - urb timed out - was the device unplugged?",
__FUNCTION__);
return;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
/* this urb is terminated, clean up */
dbg("%s - urb shutting down with status: %d",
__FUNCTION__, urb->status);
return;
default:
dbg("%s - nonzero urb status received: %d",
__FUNCTION__, urb->status);
goto exit;
}
/* if pressure has been released, then don't report X/Y */
if (!(data[7] & 0x20)) {
input_report_abs(dev, ABS_X, (data[0] & 0x1F) << 7 | (data[3] & 0x7F));
input_report_abs(dev, ABS_Y, (data[1] & 0x1F) << 7 | (data[4] & 0x7F));
}
input_report_abs(dev, ABS_PRESSURE, (data[2] & 1) << 7 | (data[5] & 0x7F));
input_report_key(dev, BTN_TOUCH, ~data[7] & 0x20);
input_sync(dev);
exit:
retval = usb_submit_urb (urb, GFP_ATOMIC);
if (retval)
printk(KERN_ERR "%s - usb_submit_urb failed with result: %d",
__FUNCTION__, retval);
}
static int itmtouch_open(struct input_dev *input)
{
struct itmtouch_dev *itmtouch = input->private;
itmtouch->readurb->dev = itmtouch->usbdev;
if (usb_submit_urb(itmtouch->readurb, GFP_KERNEL))
return -EIO;
return 0;
}
static void itmtouch_close(struct input_dev *input)
{
struct itmtouch_dev *itmtouch = input->private;
usb_kill_urb(itmtouch->readurb);
}
static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct itmtouch_dev *itmtouch;
struct input_dev *input_dev;
struct usb_host_interface *interface;
struct usb_endpoint_descriptor *endpoint;
struct usb_device *udev = interface_to_usbdev(intf);
unsigned int pipe;
unsigned int maxp;
interface = intf->cur_altsetting;
endpoint = &interface->endpoint[0].desc;
itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL);
input_dev = input_allocate_device();
if (!itmtouch || !input_dev) {
err("%s - Out of memory.", __FUNCTION__);
goto fail;
}
itmtouch->usbdev = udev;
itmtouch->inputdev = input_dev;
if (udev->manufacturer)
strlcpy(itmtouch->name, udev->manufacturer, sizeof(itmtouch->name));
if (udev->product) {
if (udev->manufacturer)
strlcat(itmtouch->name, " ", sizeof(itmtouch->name));
strlcat(itmtouch->name, udev->product, sizeof(itmtouch->name));
}
if (!strlen(itmtouch->name))
sprintf(itmtouch->name, "USB ITM touchscreen");
usb_make_path(udev, itmtouch->phys, sizeof(itmtouch->phys));
strlcpy(itmtouch->phys, "/input0", sizeof(itmtouch->phys));
input_dev->name = itmtouch->name;
input_dev->phys = itmtouch->phys;
usb_to_input_id(udev, &input_dev->id);
input_dev->cdev.dev = &intf->dev;
input_dev->private = itmtouch;
input_dev->open = itmtouch_open;
input_dev->close = itmtouch_close;
input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
/* device limits */
/* as specified by the ITM datasheet, X and Y are 12bit,
* Z (pressure) is 8 bit. However, the fields are defined up
* to 14 bits for future possible expansion.
*/
input_set_abs_params(input_dev, ABS_X, 0, 0x0FFF, 2, 0);
input_set_abs_params(input_dev, ABS_Y, 0, 0x0FFF, 2, 0);
input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xFF, 2, 0);
/* initialise the URB so we can read from the transport stream */
pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress);
maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
if (maxp > ITM_BUFSIZE)
maxp = ITM_BUFSIZE;
itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL);
if (!itmtouch->readurb) {
dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__);
goto fail;
}
usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf,
maxp, itmtouch_irq, itmtouch, endpoint->bInterval);
input_register_device(itmtouch->inputdev);
usb_set_intfdata(intf, itmtouch);
return 0;
fail: input_free_device(input_dev);
kfree(itmtouch);
return -ENOMEM;
}
static void itmtouch_disconnect(struct usb_interface *intf)
{
struct itmtouch_dev *itmtouch = usb_get_intfdata(intf);
usb_set_intfdata(intf, NULL);
if (itmtouch) {
input_unregister_device(itmtouch->inputdev);
usb_kill_urb(itmtouch->readurb);
usb_free_urb(itmtouch->readurb);
kfree(itmtouch);
}
}
MODULE_DEVICE_TABLE(usb, itmtouch_ids);
static struct usb_driver itmtouch_driver = {
.name = "itmtouch",
.probe = itmtouch_probe,
.disconnect = itmtouch_disconnect,
.id_table = itmtouch_ids,
};
static int __init itmtouch_init(void)
{
info(DRIVER_DESC " " DRIVER_VERSION);
info(DRIVER_AUTHOR);
return usb_register(&itmtouch_driver);
}
static void __exit itmtouch_exit(void)
{
usb_deregister(&itmtouch_driver);
}
module_init(itmtouch_init);
module_exit(itmtouch_exit);

View file

@ -100,7 +100,7 @@ MODULE_DEVICE_TABLE(usb, kbtab_ids);
static int kbtab_open(struct input_dev *dev)
{
struct kbtab *kbtab = dev->private;
struct kbtab *kbtab = input_get_drvdata(dev);
kbtab->irq->dev = kbtab->usbdev;
if (usb_submit_urb(kbtab->irq, GFP_KERNEL))
@ -111,7 +111,7 @@ static int kbtab_open(struct input_dev *dev)
static void kbtab_close(struct input_dev *dev)
{
struct kbtab *kbtab = dev->private;
struct kbtab *kbtab = input_get_drvdata(dev);
usb_kill_urb(kbtab->irq);
}
@ -122,6 +122,7 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
struct usb_endpoint_descriptor *endpoint;
struct kbtab *kbtab;
struct input_dev *input_dev;
int error = -ENOMEM;
kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL);
input_dev = input_allocate_device();
@ -145,8 +146,9 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
input_dev->name = "KB Gear Tablet";
input_dev->phys = kbtab->phys;
usb_to_input_id(dev, &input_dev->id);
input_dev->cdev.dev = &intf->dev;
input_dev->private = kbtab;
input_dev->dev.parent = &intf->dev;
input_set_drvdata(input_dev, kbtab);
input_dev->open = kbtab_open;
input_dev->close = kbtab_close;
@ -168,15 +170,19 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
kbtab->irq->transfer_dma = kbtab->data_dma;
kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
input_register_device(kbtab->dev);
error = input_register_device(kbtab->dev);
if (error)
goto fail3;
usb_set_intfdata(intf, kbtab);
return 0;
fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma);
fail1: input_free_device(input_dev);
fail3: usb_free_urb(kbtab->irq);
fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma);
fail1: input_free_device(input_dev);
kfree(kbtab);
return -ENOMEM;
return error;
}
static void kbtab_disconnect(struct usb_interface *intf)

View file

@ -394,7 +394,7 @@ resubmit:
static int keyspan_open(struct input_dev *dev)
{
struct usb_keyspan *remote = dev->private;
struct usb_keyspan *remote = input_get_drvdata(dev);
remote->irq_urb->dev = remote->udev;
if (usb_submit_urb(remote->irq_urb, GFP_KERNEL))
@ -405,7 +405,7 @@ static int keyspan_open(struct input_dev *dev)
static void keyspan_close(struct input_dev *dev)
{
struct usb_keyspan *remote = dev->private;
struct usb_keyspan *remote = input_get_drvdata(dev);
usb_kill_urb(remote->irq_urb);
}
@ -437,7 +437,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
struct usb_endpoint_descriptor *endpoint;
struct usb_keyspan *remote;
struct input_dev *input_dev;
int i, retval;
int i, error;
endpoint = keyspan_get_in_endpoint(interface->cur_altsetting);
if (!endpoint)
@ -446,7 +446,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
remote = kzalloc(sizeof(*remote), GFP_KERNEL);
input_dev = input_allocate_device();
if (!remote || !input_dev) {
retval = -ENOMEM;
error = -ENOMEM;
goto fail1;
}
@ -458,19 +458,19 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma);
if (!remote->in_buffer) {
retval = -ENOMEM;
error = -ENOMEM;
goto fail1;
}
remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!remote->irq_urb) {
retval = -ENOMEM;
error = -ENOMEM;
goto fail2;
}
retval = keyspan_setup(udev);
if (retval) {
retval = -ENODEV;
error = keyspan_setup(udev);
if (error) {
error = -ENODEV;
goto fail3;
}
@ -495,14 +495,15 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
input_dev->name = remote->name;
input_dev->phys = remote->phys;
usb_to_input_id(udev, &input_dev->id);
input_dev->cdev.dev = &interface->dev;
input_dev->dev.parent = &interface->dev;
input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */
for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++)
if (keyspan_key_table[i] != KEY_RESERVED)
set_bit(keyspan_key_table[i], input_dev->keybit);
input_dev->private = remote;
input_set_drvdata(input_dev, remote);
input_dev->open = keyspan_open;
input_dev->close = keyspan_close;
@ -517,7 +518,9 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
/* we can register the device now, as it is ready */
input_register_device(remote->input);
error = input_register_device(remote->input);
if (error)
goto fail3;
/* save our data pointer in this interface device */
usb_set_intfdata(interface, remote);
@ -529,7 +532,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
fail1: kfree(remote);
input_free_device(input_dev);
return retval;
return error;
}
/*

View file

@ -1,332 +0,0 @@
/******************************************************************************
* mtouchusb.c -- Driver for Microtouch (Now 3M) USB Touchscreens
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Based upon original work by Radoslaw Garbacz (usb-support@ite.pl)
* (http://freshmeat.net/projects/3mtouchscreendriver)
*
* History
*
* 0.3 & 0.4 2002 (TEJ) tejohnson@yahoo.com
* Updated to 2.4.18, then 2.4.19
* Old version still relied on stealing a minor
*
* 0.5 02/26/2004 (TEJ) tejohnson@yahoo.com
* Complete rewrite using Linux Input in 2.6.3
* Unfortunately no calibration support at this time
*
* 1.4 04/25/2004 (TEJ) tejohnson@yahoo.com
* Changed reset from standard USB dev reset to vendor reset
* Changed data sent to host from compensated to raw coordinates
* Eliminated vendor/product module params
* Performed multiple successful tests with an EXII-5010UC
*
* 1.5 02/27/2005 ddstreet@ieee.org
* Added module parameter to select raw or hw-calibrated coordinate reporting
*
*****************************************************************************/
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/usb/input.h>
#define MTOUCHUSB_MIN_XC 0x0
#define MTOUCHUSB_MAX_RAW_XC 0x4000
#define MTOUCHUSB_MAX_CALIB_XC 0xffff
#define MTOUCHUSB_XC_FUZZ 0x0
#define MTOUCHUSB_XC_FLAT 0x0
#define MTOUCHUSB_MIN_YC 0x0
#define MTOUCHUSB_MAX_RAW_YC 0x4000
#define MTOUCHUSB_MAX_CALIB_YC 0xffff
#define MTOUCHUSB_YC_FUZZ 0x0
#define MTOUCHUSB_YC_FLAT 0x0
#define MTOUCHUSB_ASYNC_REPORT 1
#define MTOUCHUSB_RESET 7
#define MTOUCHUSB_REPORT_DATA_SIZE 11
#define MTOUCHUSB_REQ_CTRLLR_ID 10
#define MTOUCHUSB_GET_RAW_XC(data) (data[8]<<8 | data[7])
#define MTOUCHUSB_GET_CALIB_XC(data) (data[4]<<8 | data[3])
#define MTOUCHUSB_GET_RAW_YC(data) (data[10]<<8 | data[9])
#define MTOUCHUSB_GET_CALIB_YC(data) (data[6]<<8 | data[5])
#define MTOUCHUSB_GET_XC(data) (raw_coordinates ? \
MTOUCHUSB_GET_RAW_XC(data) : \
MTOUCHUSB_GET_CALIB_XC(data))
#define MTOUCHUSB_GET_YC(data) (raw_coordinates ? \
MTOUCHUSB_GET_RAW_YC(data) : \
MTOUCHUSB_GET_CALIB_YC(data))
#define MTOUCHUSB_GET_TOUCHED(data) ((data[2] & 0x40) ? 1:0)
#define DRIVER_VERSION "v1.5"
#define DRIVER_AUTHOR "Todd E. Johnson, [email protected]"
#define DRIVER_DESC "3M USB Touchscreen Driver"
#define DRIVER_LICENSE "GPL"
static int raw_coordinates = 1;
module_param(raw_coordinates, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) or hardware-calibrated coordinate values (n)");
struct mtouch_usb {
unsigned char *data;
dma_addr_t data_dma;
struct urb *irq;
struct usb_device *udev;
struct input_dev *input;
char name[128];
char phys[64];
};
static struct usb_device_id mtouchusb_devices[] = {
{ USB_DEVICE(0x0596, 0x0001) },
{ }
};
static void mtouchusb_irq(struct urb *urb)
{
struct mtouch_usb *mtouch = urb->context;
int retval;
switch (urb->status) {
case 0:
/* success */
break;
case -ETIME:
/* this urb is timing out */
dbg("%s - urb timed out - was the device unplugged?",
__FUNCTION__);
return;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
/* this urb is terminated, clean up */
dbg("%s - urb shutting down with status: %d",
__FUNCTION__, urb->status);
return;
default:
dbg("%s - nonzero urb status received: %d",
__FUNCTION__, urb->status);
goto exit;
}
input_report_key(mtouch->input, BTN_TOUCH,
MTOUCHUSB_GET_TOUCHED(mtouch->data));
input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data));
input_report_abs(mtouch->input, ABS_Y,
(raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC)
- MTOUCHUSB_GET_YC(mtouch->data));
input_sync(mtouch->input);
exit:
retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval)
err("%s - usb_submit_urb failed with result: %d",
__FUNCTION__, retval);
}
static int mtouchusb_open(struct input_dev *input)
{
struct mtouch_usb *mtouch = input->private;
mtouch->irq->dev = mtouch->udev;
if (usb_submit_urb(mtouch->irq, GFP_ATOMIC))
return -EIO;
return 0;
}
static void mtouchusb_close(struct input_dev *input)
{
struct mtouch_usb *mtouch = input->private;
usb_kill_urb(mtouch->irq);
}
static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch)
{
dbg("%s - called", __FUNCTION__);
mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE,
GFP_ATOMIC, &mtouch->data_dma);
if (!mtouch->data)
return -1;
return 0;
}
static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *mtouch)
{
dbg("%s - called", __FUNCTION__);
if (mtouch->data)
usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE,
mtouch->data, mtouch->data_dma);
}
static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct mtouch_usb *mtouch;
struct input_dev *input_dev;
struct usb_host_interface *interface;
struct usb_endpoint_descriptor *endpoint;
struct usb_device *udev = interface_to_usbdev(intf);
int nRet;
dbg("%s - called", __FUNCTION__);
dbg("%s - setting interface", __FUNCTION__);
interface = intf->cur_altsetting;
dbg("%s - setting endpoint", __FUNCTION__);
endpoint = &interface->endpoint[0].desc;
mtouch = kzalloc(sizeof(struct mtouch_usb), GFP_KERNEL);
input_dev = input_allocate_device();
if (!mtouch || !input_dev) {
err("%s - Out of memory.", __FUNCTION__);
goto fail1;
}
dbg("%s - allocating buffers", __FUNCTION__);
if (mtouchusb_alloc_buffers(udev, mtouch))
goto fail2;
mtouch->udev = udev;
mtouch->input = input_dev;
if (udev->manufacturer)
strlcpy(mtouch->name, udev->manufacturer, sizeof(mtouch->name));
if (udev->product) {
if (udev->manufacturer)
strlcat(mtouch->name, " ", sizeof(mtouch->name));
strlcat(mtouch->name, udev->product, sizeof(mtouch->name));
}
if (!strlen(mtouch->name))
snprintf(mtouch->name, sizeof(mtouch->name),
"USB Touchscreen %04x:%04x",
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct));
usb_make_path(udev, mtouch->phys, sizeof(mtouch->phys));
strlcpy(mtouch->phys, "/input0", sizeof(mtouch->phys));
input_dev->name = mtouch->name;
input_dev->phys = mtouch->phys;
usb_to_input_id(udev, &input_dev->id);
input_dev->cdev.dev = &intf->dev;
input_dev->private = mtouch;
input_dev->open = mtouchusb_open;
input_dev->close = mtouchusb_close;
input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
input_set_abs_params(input_dev, ABS_X, MTOUCHUSB_MIN_XC,
raw_coordinates ? MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC,
MTOUCHUSB_XC_FUZZ, MTOUCHUSB_XC_FLAT);
input_set_abs_params(input_dev, ABS_Y, MTOUCHUSB_MIN_YC,
raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC,
MTOUCHUSB_YC_FUZZ, MTOUCHUSB_YC_FLAT);
nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0),
MTOUCHUSB_RESET,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d",
__FUNCTION__, nRet);
dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__);
mtouch->irq = usb_alloc_urb(0, GFP_KERNEL);
if (!mtouch->irq) {
dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__);
goto fail2;
}
dbg("%s - usb_fill_int_urb", __FUNCTION__);
usb_fill_int_urb(mtouch->irq, mtouch->udev,
usb_rcvintpipe(mtouch->udev, 0x81),
mtouch->data, MTOUCHUSB_REPORT_DATA_SIZE,
mtouchusb_irq, mtouch, endpoint->bInterval);
dbg("%s - input_register_device", __FUNCTION__);
input_register_device(mtouch->input);
nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0),
MTOUCHUSB_ASYNC_REPORT,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
__FUNCTION__, nRet);
usb_set_intfdata(intf, mtouch);
return 0;
fail2: mtouchusb_free_buffers(udev, mtouch);
fail1: input_free_device(input_dev);
kfree(mtouch);
return -ENOMEM;
}
static void mtouchusb_disconnect(struct usb_interface *intf)
{
struct mtouch_usb *mtouch = usb_get_intfdata(intf);
dbg("%s - called", __FUNCTION__);
usb_set_intfdata(intf, NULL);
if (mtouch) {
dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__);
usb_kill_urb(mtouch->irq);
input_unregister_device(mtouch->input);
usb_free_urb(mtouch->irq);
mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch);
kfree(mtouch);
}
}
MODULE_DEVICE_TABLE(usb, mtouchusb_devices);
static struct usb_driver mtouchusb_driver = {
.name = "mtouchusb",
.probe = mtouchusb_probe,
.disconnect = mtouchusb_disconnect,
.id_table = mtouchusb_devices,
};
static int __init mtouchusb_init(void)
{
dbg("%s - called", __FUNCTION__);
return usb_register(&mtouchusb_driver);
}
static void __exit mtouchusb_cleanup(void)
{
dbg("%s - called", __FUNCTION__);
usb_deregister(&mtouchusb_driver);
}
module_init(mtouchusb_init);
module_exit(mtouchusb_cleanup);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");

View file

@ -252,7 +252,7 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne
static int powermate_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int _value)
{
unsigned int command = (unsigned int)_value;
struct powermate_device *pm = dev->private;
struct powermate_device *pm = input_get_drvdata(dev);
if (type == EV_MSC && code == MSC_PULSELED){
/*
@ -308,7 +308,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
struct powermate_device *pm;
struct input_dev *input_dev;
int pipe, maxp;
int err = -ENOMEM;
int error = -ENOMEM;
interface = intf->cur_altsetting;
endpoint = &interface->endpoint[0].desc;
@ -359,8 +359,9 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
input_dev->phys = pm->phys;
usb_to_input_id(udev, &input_dev->id);
input_dev->cdev.dev = &intf->dev;
input_dev->private = pm;
input_dev->dev.parent = &intf->dev;
input_set_drvdata(input_dev, pm);
input_dev->event = powermate_input_event;
@ -387,11 +388,14 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
/* register our interrupt URB with the USB system */
if (usb_submit_urb(pm->irq, GFP_KERNEL)) {
err = -EIO;
error = -EIO;
goto fail4;
}
input_register_device(pm->input);
error = input_register_device(pm->input);
if (error)
goto fail5;
/* force an update of everything */
pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS;
@ -400,12 +404,13 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
usb_set_intfdata(intf, pm);
return 0;
fail4: usb_free_urb(pm->config);
fail3: usb_free_urb(pm->irq);
fail2: powermate_free_buffers(udev, pm);
fail1: input_free_device(input_dev);
fail5: usb_kill_urb(pm->irq);
fail4: usb_free_urb(pm->config);
fail3: usb_free_urb(pm->irq);
fail2: powermate_free_buffers(udev, pm);
fail1: input_free_device(input_dev);
kfree(pm);
return err;
return error;
}
/* Called when a USB device we've accepted ownership of is removed */

View file

@ -1,392 +0,0 @@
/******************************************************************************
* touchkitusb.c -- Driver for eGalax TouchKit USB Touchscreens
*
* Copyright (C) 2004-2005 by Daniel Ritz <daniel.ritz@gmx.ch>
* Copyright (C) by Todd E. Johnson (mtouchusb.c)
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Based upon mtouchusb.c
*
*****************************************************************************/
//#define DEBUG
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/usb/input.h>
#define TOUCHKIT_MIN_XC 0x0
#define TOUCHKIT_MAX_XC 0x07ff
#define TOUCHKIT_XC_FUZZ 0x0
#define TOUCHKIT_XC_FLAT 0x0
#define TOUCHKIT_MIN_YC 0x0
#define TOUCHKIT_MAX_YC 0x07ff
#define TOUCHKIT_YC_FUZZ 0x0
#define TOUCHKIT_YC_FLAT 0x0
#define TOUCHKIT_REPORT_DATA_SIZE 16
#define TOUCHKIT_DOWN 0x01
#define TOUCHKIT_PKT_TYPE_MASK 0xFE
#define TOUCHKIT_PKT_TYPE_REPT 0x80
#define TOUCHKIT_PKT_TYPE_DIAG 0x0A
#define DRIVER_VERSION "v0.1"
#define DRIVER_AUTHOR "Daniel Ritz <[email protected]>"
#define DRIVER_DESC "eGalax TouchKit USB HID Touchscreen Driver"
static int swap_xy;
module_param(swap_xy, bool, 0644);
MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
struct touchkit_usb {
unsigned char *data;
dma_addr_t data_dma;
char buffer[TOUCHKIT_REPORT_DATA_SIZE];
int buf_len;
struct urb *irq;
struct usb_device *udev;
struct input_dev *input;
char name[128];
char phys[64];
};
static struct usb_device_id touchkit_devices[] = {
{USB_DEVICE(0x3823, 0x0001)},
{USB_DEVICE(0x0123, 0x0001)},
{USB_DEVICE(0x0eef, 0x0001)},
{USB_DEVICE(0x0eef, 0x0002)},
{}
};
/* helpers to read the data */
static inline int touchkit_get_touched(char *data)
{
return (data[0] & TOUCHKIT_DOWN) ? 1 : 0;
}
static inline int touchkit_get_x(char *data)
{
return ((data[3] & 0x0F) << 7) | (data[4] & 0x7F);
}
static inline int touchkit_get_y(char *data)
{
return ((data[1] & 0x0F) << 7) | (data[2] & 0x7F);
}
/* processes one input packet. */
static void touchkit_process_pkt(struct touchkit_usb *touchkit, char *pkt)
{
int x, y;
/* only process report packets */
if ((pkt[0] & TOUCHKIT_PKT_TYPE_MASK) != TOUCHKIT_PKT_TYPE_REPT)
return;
if (swap_xy) {
y = touchkit_get_x(pkt);
x = touchkit_get_y(pkt);
} else {
x = touchkit_get_x(pkt);
y = touchkit_get_y(pkt);
}
input_report_key(touchkit->input, BTN_TOUCH, touchkit_get_touched(pkt));
input_report_abs(touchkit->input, ABS_X, x);
input_report_abs(touchkit->input, ABS_Y, y);
input_sync(touchkit->input);
}
static int touchkit_get_pkt_len(char *buf)
{
switch (buf[0] & TOUCHKIT_PKT_TYPE_MASK) {
case TOUCHKIT_PKT_TYPE_REPT:
return 5;
case TOUCHKIT_PKT_TYPE_DIAG:
return buf[1] + 2;
}
return 0;
}
static void touchkit_process(struct touchkit_usb *touchkit, int len)
{
char *buffer;
int pkt_len, buf_len, pos;
/* if the buffer contains data, append */
if (unlikely(touchkit->buf_len)) {
int tmp;
/* if only 1 byte in buffer, add another one to get length */
if (touchkit->buf_len == 1)
touchkit->buffer[1] = touchkit->data[0];
pkt_len = touchkit_get_pkt_len(touchkit->buffer);
/* unknown packet: drop everything */
if (!pkt_len)
return;
/* append, process */
tmp = pkt_len - touchkit->buf_len;
memcpy(touchkit->buffer + touchkit->buf_len, touchkit->data, tmp);
touchkit_process_pkt(touchkit, touchkit->buffer);
buffer = touchkit->data + tmp;
buf_len = len - tmp;
} else {
buffer = touchkit->data;
buf_len = len;
}
/* only one byte left in buffer */
if (unlikely(buf_len == 1)) {
touchkit->buffer[0] = buffer[0];
touchkit->buf_len = 1;
return;
}
/* loop over the buffer */
pos = 0;
while (pos < buf_len) {
/* get packet len */
pkt_len = touchkit_get_pkt_len(buffer + pos);
/* unknown packet: drop everything */
if (unlikely(!pkt_len))
return;
/* full packet: process */
if (likely(pkt_len <= buf_len)) {
touchkit_process_pkt(touchkit, buffer + pos);
} else {
/* incomplete packet: save in buffer */
memcpy(touchkit->buffer, buffer + pos, buf_len - pos);
touchkit->buf_len = buf_len - pos;
}
pos += pkt_len;
}
}
static void touchkit_irq(struct urb *urb)
{
struct touchkit_usb *touchkit = urb->context;
int retval;
switch (urb->status) {
case 0:
/* success */
break;
case -ETIME:
/* this urb is timing out */
dbg("%s - urb timed out - was the device unplugged?",
__FUNCTION__);
return;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
/* this urb is terminated, clean up */
dbg("%s - urb shutting down with status: %d",
__FUNCTION__, urb->status);
return;
default:
dbg("%s - nonzero urb status received: %d",
__FUNCTION__, urb->status);
goto exit;
}
touchkit_process(touchkit, urb->actual_length);
exit:
retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval)
err("%s - usb_submit_urb failed with result: %d",
__FUNCTION__, retval);
}
static int touchkit_open(struct input_dev *input)
{
struct touchkit_usb *touchkit = input->private;
touchkit->irq->dev = touchkit->udev;
if (usb_submit_urb(touchkit->irq, GFP_ATOMIC))
return -EIO;
return 0;
}
static void touchkit_close(struct input_dev *input)
{
struct touchkit_usb *touchkit = input->private;
usb_kill_urb(touchkit->irq);
}
static int touchkit_alloc_buffers(struct usb_device *udev,
struct touchkit_usb *touchkit)
{
touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE,
GFP_ATOMIC, &touchkit->data_dma);
if (!touchkit->data)
return -1;
return 0;
}
static void touchkit_free_buffers(struct usb_device *udev,
struct touchkit_usb *touchkit)
{
if (touchkit->data)
usb_buffer_free(udev, TOUCHKIT_REPORT_DATA_SIZE,
touchkit->data, touchkit->data_dma);
}
static int touchkit_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct touchkit_usb *touchkit;
struct input_dev *input_dev;
struct usb_host_interface *interface;
struct usb_endpoint_descriptor *endpoint;
struct usb_device *udev = interface_to_usbdev(intf);
interface = intf->cur_altsetting;
endpoint = &interface->endpoint[0].desc;
touchkit = kzalloc(sizeof(struct touchkit_usb), GFP_KERNEL);
input_dev = input_allocate_device();
if (!touchkit || !input_dev)
goto out_free;
if (touchkit_alloc_buffers(udev, touchkit))
goto out_free;
touchkit->irq = usb_alloc_urb(0, GFP_KERNEL);
if (!touchkit->irq) {
dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__);
goto out_free_buffers;
}
touchkit->udev = udev;
touchkit->input = input_dev;
if (udev->manufacturer)
strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name));
if (udev->product) {
if (udev->manufacturer)
strlcat(touchkit->name, " ", sizeof(touchkit->name));
strlcat(touchkit->name, udev->product, sizeof(touchkit->name));
}
if (!strlen(touchkit->name))
snprintf(touchkit->name, sizeof(touchkit->name),
"USB Touchscreen %04x:%04x",
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct));
usb_make_path(udev, touchkit->phys, sizeof(touchkit->phys));
strlcpy(touchkit->phys, "/input0", sizeof(touchkit->phys));
input_dev->name = touchkit->name;
input_dev->phys = touchkit->phys;
usb_to_input_id(udev, &input_dev->id);
input_dev->cdev.dev = &intf->dev;
input_dev->private = touchkit;
input_dev->open = touchkit_open;
input_dev->close = touchkit_close;
input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
input_set_abs_params(input_dev, ABS_X, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC,
TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT);
input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC,
TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT);
usb_fill_int_urb(touchkit->irq, touchkit->udev,
usb_rcvintpipe(touchkit->udev, 0x81),
touchkit->data, TOUCHKIT_REPORT_DATA_SIZE,
touchkit_irq, touchkit, endpoint->bInterval);
touchkit->irq->transfer_dma = touchkit->data_dma;
touchkit->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
input_register_device(touchkit->input);
usb_set_intfdata(intf, touchkit);
return 0;
out_free_buffers:
touchkit_free_buffers(udev, touchkit);
out_free:
input_free_device(input_dev);
kfree(touchkit);
return -ENOMEM;
}
static void touchkit_disconnect(struct usb_interface *intf)
{
struct touchkit_usb *touchkit = usb_get_intfdata(intf);
dbg("%s - called", __FUNCTION__);
if (!touchkit)
return;
dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__);
usb_set_intfdata(intf, NULL);
usb_kill_urb(touchkit->irq);
input_unregister_device(touchkit->input);
usb_free_urb(touchkit->irq);
touchkit_free_buffers(interface_to_usbdev(intf), touchkit);
kfree(touchkit);
}
MODULE_DEVICE_TABLE(usb, touchkit_devices);
static struct usb_driver touchkit_driver = {
.name = "touchkitusb",
.probe = touchkit_probe,
.disconnect = touchkit_disconnect,
.id_table = touchkit_devices,
};
static int __init touchkit_init(void)
{
return usb_register(&touchkit_driver);
}
static void __exit touchkit_cleanup(void)
{
usb_deregister(&touchkit_driver);
}
module_init(touchkit_init);
module_exit(touchkit_cleanup);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");

View file

@ -647,7 +647,7 @@ exit:
static int usbtouch_open(struct input_dev *input)
{
struct usbtouch_usb *usbtouch = input->private;
struct usbtouch_usb *usbtouch = input_get_drvdata(input);
usbtouch->irq->dev = usbtouch->udev;
@ -659,7 +659,7 @@ static int usbtouch_open(struct input_dev *input)
static void usbtouch_close(struct input_dev *input)
{
struct usbtouch_usb *usbtouch = input->private;
struct usbtouch_usb *usbtouch = input_get_drvdata(input);
usb_kill_urb(usbtouch->irq);
}
@ -740,8 +740,10 @@ static int usbtouch_probe(struct usb_interface *intf,
input_dev->name = usbtouch->name;
input_dev->phys = usbtouch->phys;
usb_to_input_id(udev, &input_dev->id);
input_dev->cdev.dev = &intf->dev;
input_dev->private = usbtouch;
input_dev->dev.parent = &intf->dev;
input_set_drvdata(input_dev, usbtouch);
input_dev->open = usbtouch_open;
input_dev->close = usbtouch_close;

View file

@ -122,7 +122,7 @@ void wacom_input_sync(void *wcombo)
static int wacom_open(struct input_dev *dev)
{
struct wacom *wacom = dev->private;
struct wacom *wacom = input_get_drvdata(dev);
wacom->irq->dev = wacom->usbdev;
if (usb_submit_urb(wacom->irq, GFP_KERNEL))
@ -133,7 +133,7 @@ static int wacom_open(struct input_dev *dev)
static void wacom_close(struct input_dev *dev)
{
struct wacom *wacom = dev->private;
struct wacom *wacom = input_get_drvdata(dev);
usb_kill_urb(wacom->irq);
}
@ -201,6 +201,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
struct wacom *wacom;
struct wacom_wac *wacom_wac;
struct input_dev *input_dev;
int error = -ENOMEM;
char rep_data[2], limit = 0;
wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
@ -229,8 +230,10 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
wacom->wacom_wac = wacom_wac;
usb_to_input_id(dev, &input_dev->id);
input_dev->cdev.dev = &intf->dev;
input_dev->private = wacom;
input_dev->dev.parent = &intf->dev;
input_set_drvdata(input_dev, wacom);
input_dev->open = wacom_open;
input_dev->close = wacom_close;
@ -252,7 +255,9 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
wacom->irq->transfer_dma = wacom->data_dma;
wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
input_register_device(wacom->dev);
error = input_register_device(wacom->dev);
if (error)
goto fail3;
/* Ask the tablet to report tablet data. Repeat until it succeeds */
do {
@ -265,11 +270,12 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
usb_set_intfdata(intf, wacom);
return 0;
fail2: usb_buffer_free(dev, 10, wacom_wac->data, wacom->data_dma);
fail1: input_free_device(input_dev);
fail3: usb_free_urb(wacom->irq);
fail2: usb_buffer_free(dev, 10, wacom_wac->data, wacom->data_dma);
fail1: input_free_device(input_dev);
kfree(wacom);
kfree(wacom_wac);
return -ENOMEM;
return error;
}
static void wacom_disconnect(struct usb_interface *intf)

View file

@ -267,7 +267,7 @@ exit:
static int xpad_open (struct input_dev *dev)
{
struct usb_xpad *xpad = dev->private;
struct usb_xpad *xpad = input_get_drvdata(dev);
xpad->irq_in->dev = xpad->udev;
if (usb_submit_urb(xpad->irq_in, GFP_KERNEL))
@ -278,7 +278,7 @@ static int xpad_open (struct input_dev *dev)
static void xpad_close (struct input_dev *dev)
{
struct usb_xpad *xpad = dev->private;
struct usb_xpad *xpad = input_get_drvdata(dev);
usb_kill_urb(xpad->irq_in);
}
@ -312,6 +312,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
struct input_dev *input_dev;
struct usb_endpoint_descriptor *ep_irq_in;
int i;
int error = -ENOMEM;
for (i = 0; xpad_device[i].idVendor; i++) {
if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
@ -344,8 +345,10 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
input_dev->name = xpad_device[i].name;
input_dev->phys = xpad->phys;
usb_to_input_id(udev, &input_dev->id);
input_dev->cdev.dev = &intf->dev;
input_dev->private = xpad;
input_dev->dev.parent = &intf->dev;
input_set_drvdata(input_dev, xpad);
input_dev->open = xpad_open;
input_dev->close = xpad_close;
@ -373,15 +376,18 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
xpad->irq_in->transfer_dma = xpad->idata_dma;
xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
input_register_device(xpad->dev);
error = input_register_device(xpad->dev);
if (error)
goto fail3;
usb_set_intfdata(intf, xpad);
return 0;
fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
fail1: input_free_device(input_dev);
fail3: usb_free_urb(xpad->irq_in);
fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
fail1: input_free_device(input_dev);
kfree(xpad);
return -ENOMEM;
return error;
}

View file

@ -502,7 +502,7 @@ static int input_ev(struct input_dev *dev, unsigned int type,
static int input_open(struct input_dev *dev)
{
struct yealink_dev *yld = dev->private;
struct yealink_dev *yld = input_get_drvdata(dev);
int i, ret;
dbg("%s", __FUNCTION__);
@ -529,7 +529,7 @@ static int input_open(struct input_dev *dev)
static void input_close(struct input_dev *dev)
{
struct yealink_dev *yld = dev->private;
struct yealink_dev *yld = input_get_drvdata(dev);
usb_kill_urb(yld->urb_ctl);
usb_kill_urb(yld->urb_irq);
@ -937,9 +937,10 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
input_dev->name = nfo->name;
input_dev->phys = yld->phys;
usb_to_input_id(udev, &input_dev->id);
input_dev->cdev.dev = &intf->dev;
input_dev->dev.parent = &intf->dev;
input_set_drvdata(input_dev, yld);
input_dev->private = yld;
input_dev->open = input_open;
input_dev->close = input_close;
/* input_dev->event = input_ev; TODO */
@ -955,7 +956,9 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
}
}
input_register_device(yld->idev);
ret = input_register_device(yld->idev);
if (ret)
return usb_cleanup(yld, ret);
usb_set_intfdata(intf, yld);