2019-05-27 06:55:05 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-06-06 07:22:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2001-2005 Edouard TISSERANT <edouard.tisserant@wanadoo.fr>
|
|
|
|
* Copyright (c) 2004-2005 Stephane VOLTZ <svoltz@numericable.fr>
|
|
|
|
*
|
|
|
|
* USB Acecad "Acecad Flair" tablet support
|
|
|
|
*
|
|
|
|
* Changelog:
|
|
|
|
* v3.2 - Added sysfs support
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/module.h>
|
2006-06-13 17:04:34 +00:00
|
|
|
#include <linux/usb/input.h>
|
2005-06-06 07:22:37 +00:00
|
|
|
|
2018-01-17 00:56:54 +00:00
|
|
|
MODULE_AUTHOR("Edouard TISSERANT <edouard.tisserant@wanadoo.fr>");
|
|
|
|
MODULE_DESCRIPTION("USB Acecad Flair tablet driver");
|
2018-01-17 00:36:48 +00:00
|
|
|
MODULE_LICENSE("GPL");
|
2005-06-06 07:22:37 +00:00
|
|
|
|
|
|
|
#define USB_VENDOR_ID_ACECAD 0x0460
|
|
|
|
#define USB_DEVICE_ID_FLAIR 0x0004
|
|
|
|
#define USB_DEVICE_ID_302 0x0008
|
|
|
|
|
|
|
|
struct usb_acecad {
|
|
|
|
char name[128];
|
|
|
|
char phys[64];
|
2012-05-04 22:33:04 +00:00
|
|
|
struct usb_interface *intf;
|
2005-09-15 07:01:47 +00:00
|
|
|
struct input_dev *input;
|
2005-06-06 07:22:37 +00:00
|
|
|
struct urb *irq;
|
|
|
|
|
2007-05-03 04:54:54 +00:00
|
|
|
unsigned char *data;
|
2005-06-06 07:22:37 +00:00
|
|
|
dma_addr_t data_dma;
|
|
|
|
};
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static void usb_acecad_irq(struct urb *urb)
|
2005-06-06 07:22:37 +00:00
|
|
|
{
|
|
|
|
struct usb_acecad *acecad = urb->context;
|
|
|
|
unsigned char *data = acecad->data;
|
2005-09-15 07:01:47 +00:00
|
|
|
struct input_dev *dev = acecad->input;
|
2012-05-04 22:33:04 +00:00
|
|
|
struct usb_interface *intf = acecad->intf;
|
2016-03-31 17:59:41 +00:00
|
|
|
struct usb_device *udev = interface_to_usbdev(intf);
|
2005-06-06 07:22:37 +00:00
|
|
|
int prox, status;
|
|
|
|
|
|
|
|
switch (urb->status) {
|
2010-04-21 05:30:22 +00:00
|
|
|
case 0:
|
|
|
|
/* success */
|
|
|
|
break;
|
|
|
|
case -ECONNRESET:
|
|
|
|
case -ENOENT:
|
|
|
|
case -ESHUTDOWN:
|
|
|
|
/* this urb is terminated, clean up */
|
2012-05-04 22:33:04 +00:00
|
|
|
dev_dbg(&intf->dev, "%s - urb shutting down with status: %d\n",
|
2012-05-02 04:33:09 +00:00
|
|
|
__func__, urb->status);
|
2010-04-21 05:30:22 +00:00
|
|
|
return;
|
|
|
|
default:
|
2012-05-04 22:33:04 +00:00
|
|
|
dev_dbg(&intf->dev, "%s - nonzero urb status received: %d\n",
|
2012-05-02 04:33:09 +00:00
|
|
|
__func__, urb->status);
|
2010-04-21 05:30:22 +00:00
|
|
|
goto resubmit;
|
2005-06-06 07:22:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
prox = (data[0] & 0x04) >> 2;
|
|
|
|
input_report_key(dev, BTN_TOOL_PEN, prox);
|
|
|
|
|
|
|
|
if (prox) {
|
|
|
|
int x = data[1] | (data[2] << 8);
|
|
|
|
int y = data[3] | (data[4] << 8);
|
2005-06-30 05:48:51 +00:00
|
|
|
/* Pressure should compute the same way for flair and 302 */
|
|
|
|
int pressure = data[5] | (data[6] << 8);
|
2005-06-06 07:22:37 +00:00
|
|
|
int touch = data[0] & 0x01;
|
|
|
|
int stylus = (data[0] & 0x10) >> 4;
|
|
|
|
int stylus2 = (data[0] & 0x20) >> 5;
|
|
|
|
input_report_abs(dev, ABS_X, x);
|
|
|
|
input_report_abs(dev, ABS_Y, y);
|
|
|
|
input_report_abs(dev, ABS_PRESSURE, pressure);
|
|
|
|
input_report_key(dev, BTN_TOUCH, touch);
|
|
|
|
input_report_key(dev, BTN_STYLUS, stylus);
|
|
|
|
input_report_key(dev, BTN_STYLUS2, stylus2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* event termination */
|
|
|
|
input_sync(dev);
|
|
|
|
|
|
|
|
resubmit:
|
2005-06-30 05:48:51 +00:00
|
|
|
status = usb_submit_urb(urb, GFP_ATOMIC);
|
2005-06-06 07:22:37 +00:00
|
|
|
if (status)
|
2012-05-04 22:33:04 +00:00
|
|
|
dev_err(&intf->dev,
|
2012-04-25 21:48:34 +00:00
|
|
|
"can't resubmit intr, %s-%s/input0, status %d\n",
|
2016-03-31 17:59:41 +00:00
|
|
|
udev->bus->bus_name,
|
|
|
|
udev->devpath, status);
|
2005-06-06 07:22:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int usb_acecad_open(struct input_dev *dev)
|
|
|
|
{
|
2007-04-12 05:34:39 +00:00
|
|
|
struct usb_acecad *acecad = input_get_drvdata(dev);
|
2005-06-06 07:22:37 +00:00
|
|
|
|
2016-03-31 17:59:41 +00:00
|
|
|
acecad->irq->dev = interface_to_usbdev(acecad->intf);
|
2005-06-06 07:22:37 +00:00
|
|
|
if (usb_submit_urb(acecad->irq, GFP_KERNEL))
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void usb_acecad_close(struct input_dev *dev)
|
|
|
|
{
|
2007-04-12 05:34:39 +00:00
|
|
|
struct usb_acecad *acecad = input_get_drvdata(dev);
|
2005-06-06 07:22:37 +00:00
|
|
|
|
|
|
|
usb_kill_urb(acecad->irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
struct usb_device *dev = interface_to_usbdev(intf);
|
|
|
|
struct usb_host_interface *interface = intf->cur_altsetting;
|
|
|
|
struct usb_endpoint_descriptor *endpoint;
|
|
|
|
struct usb_acecad *acecad;
|
2005-09-15 07:01:47 +00:00
|
|
|
struct input_dev *input_dev;
|
2005-06-06 07:22:37 +00:00
|
|
|
int pipe, maxp;
|
2010-04-21 05:30:22 +00:00
|
|
|
int err;
|
2005-06-06 07:22:37 +00:00
|
|
|
|
|
|
|
if (interface->desc.bNumEndpoints != 1)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
endpoint = &interface->endpoint[0].desc;
|
|
|
|
|
2006-09-27 18:58:53 +00:00
|
|
|
if (!usb_endpoint_is_int_in(endpoint))
|
2005-06-06 07:22:37 +00:00
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
|
2022-03-17 03:55:08 +00:00
|
|
|
maxp = usb_maxpacket(dev, pipe);
|
2005-06-06 07:22:37 +00:00
|
|
|
|
2005-09-06 22:18:34 +00:00
|
|
|
acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL);
|
2005-09-15 07:01:47 +00:00
|
|
|
input_dev = input_allocate_device();
|
2007-04-12 05:33:39 +00:00
|
|
|
if (!acecad || !input_dev) {
|
|
|
|
err = -ENOMEM;
|
2005-09-15 07:01:47 +00:00
|
|
|
goto fail1;
|
2007-04-12 05:33:39 +00:00
|
|
|
}
|
2005-06-06 07:22:37 +00:00
|
|
|
|
2010-04-12 11:17:25 +00:00
|
|
|
acecad->data = usb_alloc_coherent(dev, 8, GFP_KERNEL, &acecad->data_dma);
|
2007-04-12 05:33:39 +00:00
|
|
|
if (!acecad->data) {
|
|
|
|
err= -ENOMEM;
|
2005-06-06 07:22:37 +00:00
|
|
|
goto fail1;
|
2007-04-12 05:33:39 +00:00
|
|
|
}
|
2005-06-06 07:22:37 +00:00
|
|
|
|
|
|
|
acecad->irq = usb_alloc_urb(0, GFP_KERNEL);
|
2007-04-12 05:33:39 +00:00
|
|
|
if (!acecad->irq) {
|
|
|
|
err = -ENOMEM;
|
2005-06-06 07:22:37 +00:00
|
|
|
goto fail2;
|
2007-04-12 05:33:39 +00:00
|
|
|
}
|
2005-06-06 07:22:37 +00:00
|
|
|
|
2012-05-04 22:33:04 +00:00
|
|
|
acecad->intf = intf;
|
2005-09-15 07:01:47 +00:00
|
|
|
acecad->input = input_dev;
|
|
|
|
|
2005-06-06 07:22:37 +00:00
|
|
|
if (dev->manufacturer)
|
2022-08-18 22:05:06 +00:00
|
|
|
strscpy(acecad->name, dev->manufacturer, sizeof(acecad->name));
|
2005-06-06 07:22:37 +00:00
|
|
|
|
|
|
|
if (dev->product) {
|
|
|
|
if (dev->manufacturer)
|
|
|
|
strlcat(acecad->name, " ", sizeof(acecad->name));
|
|
|
|
strlcat(acecad->name, dev->product, sizeof(acecad->name));
|
|
|
|
}
|
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
usb_make_path(dev, acecad->phys, sizeof(acecad->phys));
|
|
|
|
strlcat(acecad->phys, "/input0", sizeof(acecad->phys));
|
2005-06-06 07:22:37 +00:00
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
input_dev->name = acecad->name;
|
|
|
|
input_dev->phys = acecad->phys;
|
|
|
|
usb_to_input_id(dev, &input_dev->id);
|
2007-04-12 05:35:03 +00:00
|
|
|
input_dev->dev.parent = &intf->dev;
|
2007-04-12 05:34:39 +00:00
|
|
|
|
|
|
|
input_set_drvdata(input_dev, acecad);
|
2005-06-06 07:22:37 +00:00
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
input_dev->open = usb_acecad_open;
|
|
|
|
input_dev->close = usb_acecad_close;
|
|
|
|
|
2007-10-19 06:40:32 +00:00
|
|
|
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
|
|
|
|
input_dev->keybit[BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_TOOL_PEN) |
|
|
|
|
BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS) |
|
|
|
|
BIT_MASK(BTN_STYLUS2);
|
2005-06-06 07:22:37 +00:00
|
|
|
|
|
|
|
switch (id->driver_info) {
|
2010-04-21 05:30:22 +00:00
|
|
|
case 0:
|
|
|
|
input_set_abs_params(input_dev, ABS_X, 0, 5000, 4, 0);
|
|
|
|
input_set_abs_params(input_dev, ABS_Y, 0, 3750, 4, 0);
|
|
|
|
input_set_abs_params(input_dev, ABS_PRESSURE, 0, 512, 0, 0);
|
|
|
|
if (!strlen(acecad->name))
|
|
|
|
snprintf(acecad->name, sizeof(acecad->name),
|
|
|
|
"USB Acecad Flair Tablet %04x:%04x",
|
|
|
|
le16_to_cpu(dev->descriptor.idVendor),
|
|
|
|
le16_to_cpu(dev->descriptor.idProduct));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
input_set_abs_params(input_dev, ABS_X, 0, 53000, 4, 0);
|
|
|
|
input_set_abs_params(input_dev, ABS_Y, 0, 2250, 4, 0);
|
|
|
|
input_set_abs_params(input_dev, ABS_PRESSURE, 0, 1024, 0, 0);
|
|
|
|
if (!strlen(acecad->name))
|
|
|
|
snprintf(acecad->name, sizeof(acecad->name),
|
|
|
|
"USB Acecad 302 Tablet %04x:%04x",
|
|
|
|
le16_to_cpu(dev->descriptor.idVendor),
|
|
|
|
le16_to_cpu(dev->descriptor.idProduct));
|
|
|
|
break;
|
2005-06-06 07:22:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usb_fill_int_urb(acecad->irq, dev, pipe,
|
|
|
|
acecad->data, maxp > 8 ? 8 : maxp,
|
|
|
|
usb_acecad_irq, acecad, endpoint->bInterval);
|
|
|
|
acecad->irq->transfer_dma = acecad->data_dma;
|
|
|
|
acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
|
|
|
|
2007-04-12 05:33:39 +00:00
|
|
|
err = input_register_device(acecad->input);
|
|
|
|
if (err)
|
2010-11-11 07:05:07 +00:00
|
|
|
goto fail3;
|
2005-06-06 07:22:37 +00:00
|
|
|
|
|
|
|
usb_set_intfdata(intf, acecad);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2010-11-11 07:05:07 +00:00
|
|
|
fail3: usb_free_urb(acecad->irq);
|
2010-04-12 11:17:25 +00:00
|
|
|
fail2: usb_free_coherent(dev, 8, acecad->data, acecad->data_dma);
|
2005-09-15 07:01:47 +00:00
|
|
|
fail1: input_free_device(input_dev);
|
|
|
|
kfree(acecad);
|
2007-04-12 05:33:39 +00:00
|
|
|
return err;
|
2005-06-06 07:22:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void usb_acecad_disconnect(struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
struct usb_acecad *acecad = usb_get_intfdata(intf);
|
2016-03-31 17:59:41 +00:00
|
|
|
struct usb_device *udev = interface_to_usbdev(intf);
|
2005-06-06 07:22:37 +00:00
|
|
|
|
|
|
|
usb_set_intfdata(intf, NULL);
|
2010-04-21 05:20:37 +00:00
|
|
|
|
|
|
|
input_unregister_device(acecad->input);
|
|
|
|
usb_free_urb(acecad->irq);
|
2016-03-31 17:59:41 +00:00
|
|
|
usb_free_coherent(udev, 8, acecad->data, acecad->data_dma);
|
2010-04-21 05:20:37 +00:00
|
|
|
kfree(acecad);
|
2005-06-06 07:22:37 +00:00
|
|
|
}
|
|
|
|
|
2017-08-08 02:44:49 +00:00
|
|
|
static const struct usb_device_id usb_acecad_id_table[] = {
|
2005-06-06 07:22:37 +00:00
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_FLAIR), .driver_info = 0 },
|
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_302), .driver_info = 1 },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(usb, usb_acecad_id_table);
|
|
|
|
|
|
|
|
static struct usb_driver usb_acecad_driver = {
|
|
|
|
.name = "usb_acecad",
|
|
|
|
.probe = usb_acecad_probe,
|
|
|
|
.disconnect = usb_acecad_disconnect,
|
|
|
|
.id_table = usb_acecad_id_table,
|
|
|
|
};
|
|
|
|
|
2011-11-18 17:48:31 +00:00
|
|
|
module_usb_driver(usb_acecad_driver);
|