Dmitry Torokhov a écrit :

Hi Edouard,

On 6/1/05, Edouard TISSERANT <[EMAIL PROTECTED]> wrote:
Hi all.

Patch should be now OK.

It should fit to last Dimitry's requests.


Yes, it is much better now. I still have couple of concerns though:

+       acecad->dev.absmin[ABS_MISC] = 0;
+       acecad->dev.absmax[ABS_MISC] = 4294967295U;

What this is for? As far as I can see Acecad does not report any MISC
events, why does it claim to have ABS_MISC?

+static ssize_t show_tabletSize(struct device *dev, char *buf)
+{
+       struct usb_acecad *acecad = dev_get_drvdata(dev);
+
+       if (acecad == NULL)
+               return 0;

This check - is it really needed? Attributes are deleted in
disconnect... Wait, this needs locking because if someone happens to
read one of the attributes while usb_acecad_disconnect is running you
may end up accessing just freed memory, no?

+static struct attribute *acecad_attrs[] = {
+       &dev_attr_size.attr,
+       &dev_attr_product_id.attr,
+       &dev_attr_vendor_id.attr,
+       &dev_attr_vendor.attr,
+       &dev_attr_product.attr,

You know, I have been looking at these attributes and wondered if it
would be better if we'd just let them go... We have numeric vendor ID
and product ID data exported in /proc/bus/input/devices and it will be
also exported within /sys/class/input_dev - uniformly - so tools can
pick it from the standard place with a standard name. Also userland
(X) drivers should probably just query /dev/eventX devices with
EVIOCGID to get entire input_id structure and latch onto device(s)
they support. Is there any tools/users that rely on character
representation of vendor string? That leaves up with tablet size.
Again, is there any users or is was mostly a debug thing? We can have
2 options here - have drivers use EVIOCGABS to query devices or again
attempt to export it at input_dev class level. What do you think?

+       acecad->dev.name = acecad->name;
+       acecad->dev.phys = acecad->phys;
+       acecad->dev.id.bustype = BUS_USB;
+       acecad->dev.id.vendor = dev->descriptor.idVendor;
+       acecad->dev.id.product = dev->descriptor.idProduct;
+       acecad->dev.id.version = dev->descriptor.bcdDevice;

It also needs:

           acecad->dev.dev = &intf->dev;

so there is a ling from /sys/class/input/eventX -> /sys/bus/usb/devices/.....

Please making these changes and I will add the driver to my tree and
hopefully Vojtech and Andrew will pick it from there.

   Hello,

I have removed these superfluous attributes and unused MISC things, added the dev.dev field.
The gimp is working fine with this version of the module. Patch is attached.

Regards,
   Stef
diff -Naur linux-2.6.12-rc5/drivers/usb/Makefile 
linux-2.6.12-rc5-acecad/drivers/usb/Makefile
--- linux-2.6.12-rc5/drivers/usb/Makefile       2005-05-26 21:49:40.000000000 
+0200
+++ linux-2.6.12-rc5-acecad/drivers/usb/Makefile        2005-05-30 
20:13:22.000000000 +0200
@@ -31,6 +31,7 @@
 obj-$(CONFIG_USB_MTOUCH)       += input/
 obj-$(CONFIG_USB_POWERMATE)    += input/
 obj-$(CONFIG_USB_WACOM)                += input/
+obj-$(CONFIG_USB_ACECAD)       += input/
 obj-$(CONFIG_USB_XPAD)         += input/
 
 obj-$(CONFIG_USB_DABUSB)       += media/
diff -Naur linux-2.6.12-rc5/drivers/usb/input/Kconfig 
linux-2.6.12-rc5-acecad/drivers/usb/input/Kconfig
--- linux-2.6.12-rc5/drivers/usb/input/Kconfig  2005-03-02 08:38:17.000000000 
+0100
+++ linux-2.6.12-rc5-acecad/drivers/usb/input/Kconfig   2005-05-30 
20:13:22.000000000 +0200
@@ -151,6 +151,18 @@
          To compile this driver as a module, choose M here: the
          module will be called wacom.
 
+config USB_ACECAD
+       tristate "Acecad Flair tablet support"
+       depends on USB && INPUT
+       help
+         Say Y here if you want to use the USB version of the Acecad Flair
+         tablet.  Make sure to say Y to "Mouse support"
+         (CONFIG_INPUT_MOUSEDEV) and/or "Event interface support"
+         (CONFIG_INPUT_EVDEV) as well.
+
+         To compile this driver as a module, choose M here: the
+         module will be called acecad.
+
 config USB_KBTAB
        tristate "KB Gear JamStudio tablet support"
        depends on USB && INPUT
diff -Naur linux-2.6.12-rc5/drivers/usb/input/Makefile 
linux-2.6.12-rc5-acecad/drivers/usb/input/Makefile
--- linux-2.6.12-rc5/drivers/usb/input/Makefile 2005-03-02 08:38:12.000000000 
+0100
+++ linux-2.6.12-rc5-acecad/drivers/usb/input/Makefile  2005-05-30 
20:13:22.000000000 +0200
@@ -36,4 +36,5 @@
 obj-$(CONFIG_USB_EGALAX)       += touchkitusb.o
 obj-$(CONFIG_USB_POWERMATE)    += powermate.o
 obj-$(CONFIG_USB_WACOM)                += wacom.o
+obj-$(CONFIG_USB_ACECAD)       += acecad.o
 obj-$(CONFIG_USB_XPAD)         += xpad.o
diff -Naur linux-2.6.12-rc5/drivers/usb/input/acecad.c 
linux-2.6.12-rc5-acecad/drivers/usb/input/acecad.c
--- linux-2.6.12-rc5/drivers/usb/input/acecad.c 1970-01-01 01:00:00.000000000 
+0100
+++ linux-2.6.12-rc5-acecad/drivers/usb/input/acecad.c  2005-06-02 
07:27:28.000000000 +0200
@@ -0,0 +1,308 @@
+/*
+ *  Copyright (c) 2001-2005 Edouard TISSERANT   <[EMAIL PROTECTED]>
+ *  Copyright (c) 2004-2005 Stéphane VOLTZ      <[EMAIL PROTECTED]>
+ *
+ *  USB Acecad "Acecad Flair" tablet support
+ *
+ *  Changelog:
+ *      v3.2 - Added sysfs support
+ */
+
+/*
+ * 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/kernel.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/usb.h>
+
+/*
+ * Version Information
+ */
+#define DRIVER_VERSION "v3.2"
+#define DRIVER_DESC    "USB Acecad Flair tablet driver"
+#define DRIVER_LICENSE "GPL"
+#define DRIVER_AUTHOR  "Edouard TISSERANT <[EMAIL PROTECTED]>"
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE(DRIVER_LICENSE);
+
+#define USB_VENDOR_ID_ACECAD   0x0460
+#define USB_DEVICE_ID_FLAIR    0x0004
+#define USB_DEVICE_ID_302      0x0008
+
+struct acecad_features {
+       char manufacturer[64];
+       char product[64];
+};
+
+struct usb_acecad {
+       char name[128];
+       char phys[64];
+       struct usb_device *usbdev;
+       struct input_dev dev;
+       struct urb *irq;
+
+       signed char *data;
+       dma_addr_t data_dma;
+
+       struct acecad_features features;
+};
+
+
+
+
+static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs)
+{
+       struct usb_acecad *acecad = urb->context;
+       unsigned char *data = acecad->data;
+       struct input_dev *dev = &acecad->dev;
+       int prox,status;
+
+
+       prox = (data[0] & 0x04) >> 2;
+       switch (urb->status) {
+               case 0:
+                       /* success */
+                       break;
+               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 resubmit;
+       }
+
+       input_report_key(dev, BTN_TOOL_PEN, prox);
+
+       if (prox) {
+               int x = data[1] | (data[2] << 8);
+               int y = data[3] | (data[4] << 8);
+               /*Pressure should compute the same way for flair and 302*/
+               int pressure = data[5] | ((int)data[6] << 8);
+               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:
+       status = usb_submit_urb (urb, GFP_ATOMIC);
+       if (status)
+               err ("can't resubmit intr, %s-%s/input0, status %d",
+                               acecad->usbdev->bus->bus_name,
+                               acecad->usbdev->devpath, status);
+}
+
+static int usb_acecad_open(struct input_dev *dev)
+{
+       struct usb_acecad *acecad = dev->private;
+
+       acecad->irq->dev = acecad->usbdev;
+       if (usb_submit_urb(acecad->irq,GFP_KERNEL))
+               return -EIO;
+
+       return 0;
+}
+
+static void usb_acecad_close(struct input_dev *dev)
+{
+       struct usb_acecad *acecad = dev->private;
+
+       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;
+       struct usb_endpoint_descriptor *endpoint;
+       struct usb_acecad *acecad;
+       int pipe, maxp;
+       char path[64];
+       char *buf;
+
+       interface = intf->cur_altsetting;
+
+       if (interface->desc.bNumEndpoints != 1)
+               return -ENODEV;
+
+       endpoint = &interface->endpoint[0].desc;
+       if (!(endpoint->bEndpointAddress & 0x80)) 
+               return -ENODEV;
+       if ((endpoint->bmAttributes & 3) != 3) 
+               return -ENODEV;
+
+       pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
+       maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
+
+       if (!(acecad = kmalloc(sizeof(struct usb_acecad), GFP_KERNEL))) 
+               return -ENOMEM;
+       memset(acecad, 0, sizeof(struct usb_acecad));
+
+       acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma);
+       if (!acecad->data) {
+               kfree(acecad);
+               return -ENOMEM;
+       }
+
+       acecad->irq = usb_alloc_urb(0, GFP_KERNEL);
+       if (!acecad->irq) {
+               usb_buffer_free(dev, 8, acecad->data, acecad->data_dma);
+               kfree(acecad);
+               return -ENODEV;
+       }
+
+       if (!(buf = kmalloc(63, GFP_KERNEL))) {
+               usb_buffer_free(dev, 8, acecad->data, acecad->data_dma);
+               usb_free_urb(acecad->irq);
+               kfree(acecad);
+               return -ENOMEM;
+       }
+
+       if (dev->descriptor.iManufacturer &&
+                       usb_string(dev, dev->descriptor.iManufacturer, buf, 63) 
> 0)        {
+               strcat(acecad->name, buf);
+               strcpy(acecad->features.manufacturer, buf);
+       }
+       if (dev->descriptor.iProduct &&
+                       usb_string(dev, dev->descriptor.iProduct, buf, 63) > 0) 
{
+               strcat(acecad->name, " ");
+               strcat(acecad->name, buf);
+               strcpy(acecad->features.product, buf);
+       }
+
+       kfree(buf);
+
+       acecad->usbdev = dev;
+
+       acecad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+       acecad->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
+       acecad->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | 
BIT(BTN_MIDDLE);
+       acecad->dev.keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) 
| BIT(BTN_STYLUS) | BIT(BTN_STYLUS2);
+
+       switch(id->driver_info) {
+               case 0:
+                       acecad->dev.absmax[ABS_X] = 5000;
+                       acecad->dev.absmax[ABS_Y] = 3750;
+                       acecad->dev.absmax[ABS_PRESSURE] = 512;
+                       if (!strlen(acecad->name))
+                               sprintf(acecad->name, "USB Acecad Flair Tablet 
%04x:%04x", dev->descriptor.idVendor, dev->descriptor.idProduct);
+                       break;
+               case 1:
+                       acecad->dev.absmax[ABS_X] = 3000;
+                       acecad->dev.absmax[ABS_Y] = 2250;
+                       acecad->dev.absmax[ABS_PRESSURE] = 1024;
+                       if (!strlen(acecad->name))
+                               sprintf(acecad->name, "USB Acecad 302 Tablet 
%04x:%04x", dev->descriptor.idVendor, dev->descriptor.idProduct);
+                       break;
+       }
+
+       acecad->dev.absfuzz[ABS_X] = 4;
+       acecad->dev.absfuzz[ABS_Y] = 4;
+
+       acecad->dev.private = acecad;
+       acecad->dev.open = usb_acecad_open;
+       acecad->dev.close = usb_acecad_close;
+
+       usb_make_path(dev, path, 64);
+       sprintf(acecad->phys, "%s/input0", path);
+
+       acecad->dev.name = acecad->name;
+       acecad->dev.phys = acecad->phys;
+       acecad->dev.id.bustype = BUS_USB;
+       acecad->dev.id.vendor = dev->descriptor.idVendor;
+       acecad->dev.id.product = dev->descriptor.idProduct;
+       acecad->dev.id.version = dev->descriptor.bcdDevice;
+       acecad->dev.dev = &intf->dev;
+
+       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;
+
+       input_register_device(&acecad->dev);
+
+       printk(KERN_INFO "input: %s with packet size %d on %s\n",
+                       acecad->name, maxp, path);
+
+       usb_set_intfdata(intf, acecad);
+
+       return 0;
+}
+
+static void usb_acecad_disconnect(struct usb_interface *intf)
+{
+       struct usb_acecad *acecad = usb_get_intfdata (intf);
+
+       usb_set_intfdata(intf, NULL);
+       if (acecad) {
+               usb_kill_urb(acecad->irq);
+               input_unregister_device(&acecad->dev);
+               usb_free_urb(acecad->irq);
+               usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, 
acecad->data_dma);
+               kfree(acecad);
+       }
+
+}
+
+static struct usb_device_id usb_acecad_id_table [] = {
+       { USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_FLAIR) },
+       { USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_302) },
+    { }                                        
+};
+
+MODULE_DEVICE_TABLE (usb, usb_acecad_id_table);
+
+static struct usb_driver usb_acecad_driver = {
+       .owner =        THIS_MODULE,
+       .name =         "usb_acecad",
+       .probe =        usb_acecad_probe,
+       .disconnect =   usb_acecad_disconnect,
+       .id_table =     usb_acecad_id_table,
+};
+
+static int __init usb_acecad_init(void)
+{
+       int result = usb_register(&usb_acecad_driver);
+       if (result == 0)
+               info(DRIVER_VERSION ":" DRIVER_DESC);
+       return result;
+}
+
+static void __exit usb_acecad_exit(void)
+{
+       usb_deregister(&usb_acecad_driver);
+}
+
+module_init(usb_acecad_init);
+module_exit(usb_acecad_exit);
diff -Naur linux-2.6.12-rc5/drivers/usb/input/hid-core.c 
linux-2.6.12-rc5-acecad/drivers/usb/input/hid-core.c
--- linux-2.6.12-rc5/drivers/usb/input/hid-core.c       2005-05-26 
21:49:42.000000000 +0200
+++ linux-2.6.12-rc5-acecad/drivers/usb/input/hid-core.c        2005-05-30 
20:14:21.000000000 +0200
@@ -1316,6 +1316,10 @@
 #define USB_DEVICE_ID_WACOM_VOLITO     0x0060
 #define USB_DEVICE_ID_WACOM_PTU                0x0003
 
+#define USB_VENDOR_ID_ACECAD           0x0460
+#define USB_DEVICE_ID_ACECAD_FLAIR     0x0004
+#define USB_DEVICE_ID_ACECAD_302       0x0008
+
 #define USB_VENDOR_ID_KBGEAR           0x084e
 #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001
 
@@ -1484,6 +1488,9 @@
        { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, 
HID_QUIRK_IGNORE },
        { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, 
HID_QUIRK_IGNORE },
 
+       { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR, HID_QUIRK_IGNORE },
+       { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302, HID_QUIRK_IGNORE },
+
        { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },

Reply via email to