<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.602   -&gt; 1.603  
#	               (new)	        -&gt; 1.1     drivers/usb/aiptek.c
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/08/05	greg@kroah.com	1.603
# USB: added aiptek driver
# --------------------------------------------
#
diff -Nru a/drivers/usb/aiptek.c b/drivers/usb/aiptek.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/drivers/usb/aiptek.c	Mon Aug  5 14:46:49 2002
@@ -0,0 +1,332 @@
+/*
+ *  Native support for the Aiptek 8000U
+ *
+ *  Copyright (c) 2001 Chris Atenasio		&lt;chris@crud.net&gt;
+ *
+ *  based on wacom.c by
+ *     Vojtech Pavlik      &lt;vojtech@suse.cz&gt;
+ *     Andreas Bach Aaen   &lt;abach@stofanet.dk&gt;
+ *     Clifford Wolf       &lt;clifford@clifford.at&gt;
+ *     Sam Mosel           &lt;sam.mosel@computer.org&gt;
+ *     James E. Blair      &lt;corvus@gnu.org&gt;
+ *     Daniel Egger        &lt;egger@suse.de&gt;
+ *
+ *
+ *  Many thanks to Oliver Kuechemann for his support.
+ *
+ *  ChangeLog:
+ *      v0.1 - Initial release
+ *      v0.2 - Hack to get around fake event 28's.
+ *      v0.3 - Make URB dynamic (Bryan W. Headley, Jun-8-2002)
+ */
+
+/*
+ * 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 &lt;linux/kernel.h&gt;
+#include &lt;linux/slab.h&gt;
+#include &lt;linux/input.h&gt;
+#include &lt;linux/module.h&gt;
+#include &lt;linux/init.h&gt;
+#include &lt;linux/usb.h&gt;
+
+/*
+ * Version Information
+ */
+#define DRIVER_VERSION "v0.3"
+#define DRIVER_AUTHOR "Chris Atenasio &lt;chris@crud.net&gt;"
+#define DRIVER_DESC "USB Aiptek 6000U/8000U tablet driver (Linux 2.4.x)"
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
+/*
+ * Aiptek status packet:
+ *
+ *        bit7  bit6  bit5  bit4  bit3  bit2  bit1  bit0
+ * byte0   0     0     0     0     0     0     1     0
+ * byte1  X7    X6    X5    X4    X3    X2    X1    X0
+ * byte2  X15   X14   X13   X12   X11   X10   X9    X8
+ * byte3  Y7    Y6    Y5    Y4    Y3    Y2    Y1    Y0
+ * byte4  Y15   Y14   Y13   Y12   Y11   Y10   Y9    Y8
+ * byte5   *     *     *    BS2   BS1   Tip   DV    IR
+ * byte6  P7    P6    P5    P4    P3    P2    P1    P0
+ * byte7  P15   P14   P13   P12   P11   P10   P9    P8
+ *
+ * IR: In Range = Proximity on
+ * DV = Data Valid
+ *
+ * 
+ * Command Summary:
+ *
+ * Command/Data    Description     Return Bytes    Return Value
+ * 0x10/0x00       SwitchToMouse       0
+ * 0x10/0x01       SwitchToTablet      0
+ * 0x18/0x04       Resolution500LPI    0
+ * 0x17/0x00       FilterOn            0
+ * 0x12/0xFF       AutoGainOn          0
+ * 0x01/0x00       GetXExtension       2           MaxX
+ * 0x01/0x01       GetYExtension       2           MaxY
+ * 0x02/0x00       GetModelCode        2           ModelCode = LOBYTE
+ * 0x03/0x00       GetODMCode          2           ODMCode
+ * 0x08/0x00       GetPressureLevels   2           =512
+ * 0x04/0x00       GetFirmwareVersion  2           Firmware Version
+ *
+ *
+ * To initialize the tablet:
+ *
+ * (1) Send command Resolution500LPI
+ * (2) Option Commands (GetXExtension, GetYExtension)
+ * (3) Send command SwitchToTablet
+ */
+
+#define USB_VENDOR_ID_AIPTEK   0x08ca
+
+struct aiptek_features {
+	char *name;
+	int pktlen;
+	int x_max;
+	int y_max;
+	int pressure_min;
+	int pressure_max;
+	void (*irq) (struct urb * urb);
+	unsigned long evbit;
+	unsigned long absbit;
+	unsigned long relbit;
+	unsigned long btnbit;
+	unsigned long digibit;
+};
+
+struct aiptek {
+	signed char data[10];
+	struct input_dev dev;
+	struct usb_device *usbdev;
+	struct urb *irq;
+	struct aiptek_features *features;
+	int tool;
+	int open;
+};
+
+static void
+aiptek_irq(struct urb *urb)
+{
+	struct aiptek *aiptek = urb-&gt;context;
+	unsigned char *data = aiptek-&gt;data;
+	struct input_dev *dev = &amp;aiptek-&gt;dev;
+	int x;
+	int y;
+	int pressure;
+	int proximity;
+
+	if (urb-&gt;status)
+		return;
+
+	if ((data[0] &amp; 2) == 0) {
+		dbg("received unknown report #%d", data[0]);
+	}
+
+	proximity = data[5] &amp; 0x01;
+	input_report_key(dev, BTN_TOOL_PEN, proximity);
+
+	x = ((__u32) data[1]) | ((__u32) data[2] &lt;&lt; 8);
+	y = ((__u32) data[3]) | ((__u32) data[4] &lt;&lt; 8);
+	pressure = ((__u32) data[6]) | ((__u32) data[7] &lt;&lt; 8);
+	pressure -= aiptek-&gt;features-&gt;pressure_min;
+
+	if (pressure &lt; 0) {
+		pressure = 0;
+	}
+
+	if (proximity) {
+		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, data[5] &amp; 0x04);
+		input_report_key(dev, BTN_STYLUS, data[5] &amp; 0x08);
+		input_report_key(dev, BTN_STYLUS2, data[5] &amp; 0x10);
+	}
+
+}
+
+struct aiptek_features aiptek_features[] = {
+	{"Aiptek 6000U/8000U", 
+	 8, 3000, 2250, 26, 511, aiptek_irq, 0, 0, 0, 0},
+	{NULL, 0}
+};
+
+struct usb_device_id aiptek_ids[] = {
+	{USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x20), driver_info:0},
+	{}
+};
+
+MODULE_DEVICE_TABLE(usb, aiptek_ids);
+
+static int
+aiptek_open(struct input_dev *dev)
+{
+	struct aiptek *aiptek = dev-&gt;private;
+
+	if (aiptek-&gt;open++)
+		return 0;
+
+	aiptek-&gt;irq-&gt;dev = aiptek-&gt;usbdev;
+	if (usb_submit_urb(aiptek-&gt;irq))
+		return -EIO;
+
+	return 0;
+}
+
+static void
+aiptek_close(struct input_dev *dev)
+{
+	struct aiptek *aiptek = dev-&gt;private;
+
+	if (!--aiptek-&gt;open)
+		usb_unlink_urb(aiptek-&gt;irq);
+}
+
+static void
+aiptek_command(struct usb_device *dev, unsigned int ifnum,
+	       unsigned char command, unsigned char data)
+{
+	__u8 buf[3];
+
+	buf[0] = 4;
+	buf[1] = command;
+	buf[2] = data;
+
+	if (usb_set_report(dev, ifnum, 3, 2, buf, 3) != 3) {
+		dbg("aiptek_command: 0x%x 0x%x\n", command, data);
+	}
+}
+
+static void*
+aiptek_probe(struct usb_device *dev, unsigned int ifnum,
+	     const struct usb_device_id *id)
+{
+	struct usb_endpoint_descriptor *endpoint;
+	struct aiptek *aiptek;
+
+	if (!(aiptek = kmalloc(sizeof (struct aiptek), GFP_KERNEL)))
+		return NULL;
+
+	memset(aiptek, 0, sizeof (struct aiptek));
+
+	aiptek-&gt;irq = usb_alloc_urb(0);
+	if (!aiptek-&gt;irq) {
+		kfree(aiptek);
+		return NULL;
+	}
+
+	// Resolution500LPI
+	aiptek_command(dev, ifnum, 0x18, 0x04);
+
+	// SwitchToTablet
+	aiptek_command(dev, ifnum, 0x10, 0x01);
+
+	aiptek-&gt;features = aiptek_features + id-&gt;driver_info;
+
+	aiptek-&gt;dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC) |
+	    aiptek-&gt;features-&gt;evbit;
+
+	aiptek-&gt;dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) |
+	    BIT(ABS_MISC) | aiptek-&gt;features-&gt;absbit;
+
+	aiptek-&gt;dev.relbit[0] |= aiptek-&gt;features-&gt;relbit;
+
+	aiptek-&gt;dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) |
+	    BIT(BTN_MIDDLE) | aiptek-&gt;features-&gt;btnbit;
+
+	aiptek-&gt;dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) |
+	    BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOUCH) |
+	    BIT(BTN_STYLUS) | BIT(BTN_STYLUS2) | aiptek-&gt;features-&gt;digibit;
+
+	aiptek-&gt;dev.mscbit[0] = BIT(MSC_SERIAL);
+
+	aiptek-&gt;dev.absmax[ABS_X] = aiptek-&gt;features-&gt;x_max;
+	aiptek-&gt;dev.absmax[ABS_Y] = aiptek-&gt;features-&gt;y_max;
+	aiptek-&gt;dev.absmax[ABS_PRESSURE] = aiptek-&gt;features-&gt;pressure_max -
+	    aiptek-&gt;features-&gt;pressure_min;
+
+	aiptek-&gt;dev.absfuzz[ABS_X] = 0;
+	aiptek-&gt;dev.absfuzz[ABS_Y] = 0;
+
+	aiptek-&gt;dev.private = aiptek;
+	aiptek-&gt;dev.open = aiptek_open;
+	aiptek-&gt;dev.close = aiptek_close;
+
+	aiptek-&gt;dev.name = aiptek-&gt;features-&gt;name;
+	aiptek-&gt;dev.idbus = BUS_USB;
+	aiptek-&gt;dev.idvendor = dev-&gt;descriptor.idVendor;
+	aiptek-&gt;dev.idproduct = dev-&gt;descriptor.idProduct;
+	aiptek-&gt;dev.idversion = dev-&gt;descriptor.bcdDevice;
+	aiptek-&gt;usbdev = dev;
+
+	endpoint = dev-&gt;config[0].interface[ifnum].altsetting[0].endpoint + 0;
+
+	FILL_INT_URB(aiptek-&gt;irq,
+		  dev,
+		  usb_rcvintpipe(dev, endpoint-&gt;bEndpointAddress),
+		         aiptek-&gt;data,
+		  aiptek-&gt;features-&gt;pktlen,
+		         aiptek-&gt;features-&gt;irq,
+		  aiptek,
+		  endpoint-&gt;bInterval);
+
+	input_register_device(&amp;aiptek-&gt;dev);
+
+	printk(KERN_INFO "input%d: %s on usb%d:%d.%d\n",
+	       aiptek-&gt;dev.number, aiptek-&gt;features-&gt;name, dev-&gt;bus-&gt;busnum,
+	       dev-&gt;devnum, ifnum);
+
+	return aiptek;
+}
+
+static void
+aiptek_disconnect(struct usb_device *dev, void *ptr)
+{
+	struct aiptek *aiptek = ptr;
+	usb_unlink_urb(aiptek-&gt;irq);
+	input_unregister_device(&amp;aiptek-&gt;dev);
+	usb_free_urb(aiptek-&gt;irq);
+	kfree(aiptek);
+}
+
+static struct usb_driver aiptek_driver = {
+	name:"aiptek",
+	probe:aiptek_probe,
+	disconnect:aiptek_disconnect,
+	id_table:aiptek_ids,
+};
+
+static int __init
+aiptek_init(void)
+{
+	usb_register(&amp;aiptek_driver);
+	info(DRIVER_VERSION " " DRIVER_AUTHOR);
+	info(DRIVER_DESC);
+	return 0;
+}
+
+static void __exit
+aiptek_exit(void)
+{
+	usb_deregister(&amp;aiptek_driver);
+}
+
+module_init(aiptek_init);
+module_exit(aiptek_exit);
</pre></body></html>