2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Generic linux-input device driver for axis-bearing devices
|
|
|
|
*
|
|
|
|
* Copyright (c) 2001 Brian S. Julin
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL").
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
*
|
|
|
|
* References:
|
|
|
|
* HP-HIL Technical Reference Manual. Hewlett Packard Product No. 45918A
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/hil.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/serio.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/pci_ids.h>
|
|
|
|
|
|
|
|
#define PREFIX "HIL PTR: "
|
|
|
|
#define HIL_GENERIC_NAME "HIL pointer device"
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>");
|
|
|
|
MODULE_DESCRIPTION(HIL_GENERIC_NAME " driver");
|
|
|
|
MODULE_LICENSE("Dual BSD/GPL");
|
2008-12-29 12:44:44 +00:00
|
|
|
MODULE_ALIAS("serio:ty03pr25id0Fex*");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define TABLET_SIMULATES_MOUSE /* allow tablet to be used as mouse */
|
|
|
|
#undef TABLET_AUTOADJUST /* auto-adjust valid tablet ranges */
|
|
|
|
|
|
|
|
|
|
|
|
#define HIL_PTR_MAX_LENGTH 16
|
|
|
|
|
|
|
|
struct hil_ptr {
|
2006-03-26 14:41:55 +00:00
|
|
|
struct input_dev *dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct serio *serio;
|
|
|
|
|
|
|
|
/* Input buffer and index for packets from HIL bus. */
|
|
|
|
hil_packet data[HIL_PTR_MAX_LENGTH];
|
|
|
|
int idx4; /* four counts per packet */
|
|
|
|
|
|
|
|
/* Raw device info records from HIL bus, see hil.h for fields. */
|
|
|
|
char idd[HIL_PTR_MAX_LENGTH]; /* DID byte and IDD record */
|
|
|
|
char rsc[HIL_PTR_MAX_LENGTH]; /* RSC record */
|
|
|
|
char exd[HIL_PTR_MAX_LENGTH]; /* EXD record */
|
|
|
|
char rnm[HIL_PTR_MAX_LENGTH + 1]; /* RNM record + NULL term. */
|
|
|
|
|
|
|
|
/* Extra device details not contained in struct input_dev. */
|
|
|
|
unsigned int nbtn, naxes;
|
|
|
|
unsigned int btnmap[7];
|
|
|
|
|
|
|
|
/* Something to sleep around with. */
|
|
|
|
struct semaphore sem;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Process a complete packet after transfer from the HIL */
|
|
|
|
static void hil_ptr_process_record(struct hil_ptr *ptr)
|
|
|
|
{
|
2006-03-26 14:41:55 +00:00
|
|
|
struct input_dev *dev = ptr->dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
hil_packet *data = ptr->data;
|
|
|
|
hil_packet p;
|
|
|
|
int idx, i, cnt, laxis;
|
|
|
|
int ax16, absdev;
|
|
|
|
|
|
|
|
idx = ptr->idx4/4;
|
|
|
|
p = data[idx - 1];
|
|
|
|
|
2007-03-01 04:51:29 +00:00
|
|
|
if ((p & ~HIL_CMDCT_POL) ==
|
|
|
|
(HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL))
|
|
|
|
goto report;
|
|
|
|
if ((p & ~HIL_CMDCT_RPL) ==
|
|
|
|
(HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL))
|
|
|
|
goto report;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Not a poll response. See if we are loading config records. */
|
|
|
|
switch (p & HIL_PKT_DATA_MASK) {
|
|
|
|
case HIL_CMD_IDD:
|
|
|
|
for (i = 0; i < idx; i++)
|
|
|
|
ptr->idd[i] = ptr->data[i] & HIL_PKT_DATA_MASK;
|
|
|
|
for (; i < HIL_PTR_MAX_LENGTH; i++)
|
|
|
|
ptr->idd[i] = 0;
|
|
|
|
break;
|
2007-03-01 04:51:29 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
case HIL_CMD_RSC:
|
|
|
|
for (i = 0; i < idx; i++)
|
|
|
|
ptr->rsc[i] = ptr->data[i] & HIL_PKT_DATA_MASK;
|
|
|
|
for (; i < HIL_PTR_MAX_LENGTH; i++)
|
|
|
|
ptr->rsc[i] = 0;
|
|
|
|
break;
|
2007-03-01 04:51:29 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
case HIL_CMD_EXD:
|
|
|
|
for (i = 0; i < idx; i++)
|
|
|
|
ptr->exd[i] = ptr->data[i] & HIL_PKT_DATA_MASK;
|
|
|
|
for (; i < HIL_PTR_MAX_LENGTH; i++)
|
|
|
|
ptr->exd[i] = 0;
|
|
|
|
break;
|
2007-03-01 04:51:29 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
case HIL_CMD_RNM:
|
|
|
|
for (i = 0; i < idx; i++)
|
|
|
|
ptr->rnm[i] = ptr->data[i] & HIL_PKT_DATA_MASK;
|
|
|
|
for (; i < HIL_PTR_MAX_LENGTH + 1; i++)
|
2007-03-01 04:51:29 +00:00
|
|
|
ptr->rnm[i] = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
2007-03-01 04:51:29 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
default:
|
|
|
|
/* These occur when device isn't present */
|
2007-03-01 04:51:29 +00:00
|
|
|
if (p == (HIL_ERR_INT | HIL_PKT_CMD))
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Anything else we'd like to know about. */
|
|
|
|
printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
report:
|
|
|
|
if ((p & HIL_CMDCT_POL) != idx - 1) {
|
2007-03-01 04:51:29 +00:00
|
|
|
printk(KERN_WARNING PREFIX
|
|
|
|
"Malformed poll packet %x (idx = %i)\n", p, idx);
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = (ptr->data[0] & HIL_POL_AXIS_ALT) ? 3 : 0;
|
|
|
|
laxis = ptr->data[0] & HIL_POL_NUM_AXES_MASK;
|
|
|
|
laxis += i;
|
|
|
|
|
|
|
|
ax16 = ptr->idd[1] & HIL_IDD_HEADER_16BIT; /* 8 or 16bit resolution */
|
2007-03-01 04:51:29 +00:00
|
|
|
absdev = ptr->idd[1] & HIL_IDD_HEADER_ABS;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
for (cnt = 1; i < laxis; i++) {
|
|
|
|
unsigned int lo,hi,val;
|
|
|
|
lo = ptr->data[cnt++] & HIL_PKT_DATA_MASK;
|
|
|
|
hi = ax16 ? (ptr->data[cnt++] & HIL_PKT_DATA_MASK) : 0;
|
|
|
|
if (absdev) {
|
|
|
|
val = lo + (hi<<8);
|
|
|
|
#ifdef TABLET_AUTOADJUST
|
2006-03-26 14:41:55 +00:00
|
|
|
if (val < dev->absmin[ABS_X + i])
|
|
|
|
dev->absmin[ABS_X + i] = val;
|
|
|
|
if (val > dev->absmax[ABS_X + i])
|
|
|
|
dev->absmax[ABS_X + i] = val;
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
2006-03-26 14:41:55 +00:00
|
|
|
if (i%3) val = dev->absmax[ABS_X + i] - val;
|
2005-04-16 22:20:36 +00:00
|
|
|
input_report_abs(dev, ABS_X + i, val);
|
|
|
|
} else {
|
|
|
|
val = (int) (((int8_t)lo) | ((int8_t)hi<<8));
|
2007-03-01 04:51:29 +00:00
|
|
|
if (i%3)
|
|
|
|
val *= -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
input_report_rel(dev, REL_X + i, val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (cnt < idx - 1) {
|
|
|
|
unsigned int btn;
|
|
|
|
int up;
|
|
|
|
btn = ptr->data[cnt++];
|
|
|
|
up = btn & 1;
|
|
|
|
btn &= 0xfe;
|
2007-03-01 04:51:29 +00:00
|
|
|
if (btn == 0x8e)
|
2005-04-16 22:20:36 +00:00
|
|
|
continue; /* TODO: proximity == touch? */
|
2007-03-01 04:51:29 +00:00
|
|
|
else
|
|
|
|
if ((btn > 0x8c) || (btn < 0x80))
|
|
|
|
continue;
|
2005-04-16 22:20:36 +00:00
|
|
|
btn = (btn - 0x80) >> 1;
|
|
|
|
btn = ptr->btnmap[btn];
|
|
|
|
input_report_key(dev, btn, !up);
|
|
|
|
}
|
|
|
|
input_sync(dev);
|
|
|
|
out:
|
|
|
|
ptr->idx4 = 0;
|
|
|
|
up(&ptr->sem);
|
|
|
|
}
|
|
|
|
|
2007-03-01 04:51:29 +00:00
|
|
|
static void hil_ptr_process_err(struct hil_ptr *ptr)
|
|
|
|
{
|
2005-04-16 22:20:36 +00:00
|
|
|
printk(KERN_WARNING PREFIX "errored HIL packet\n");
|
|
|
|
ptr->idx4 = 0;
|
|
|
|
up(&ptr->sem);
|
|
|
|
}
|
|
|
|
|
2007-03-01 04:51:29 +00:00
|
|
|
static irqreturn_t hil_ptr_interrupt(struct serio *serio,
|
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
|
|
|
unsigned char data, unsigned int flags)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct hil_ptr *ptr;
|
|
|
|
hil_packet packet;
|
|
|
|
int idx;
|
|
|
|
|
2005-10-22 02:58:51 +00:00
|
|
|
ptr = serio_get_drvdata(serio);
|
2007-03-01 04:51:29 +00:00
|
|
|
BUG_ON(ptr == NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (ptr->idx4 >= (HIL_PTR_MAX_LENGTH * sizeof(hil_packet))) {
|
|
|
|
hil_ptr_process_err(ptr);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
idx = ptr->idx4/4;
|
2007-03-01 04:51:29 +00:00
|
|
|
if (!(ptr->idx4 % 4))
|
|
|
|
ptr->data[idx] = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
packet = ptr->data[idx];
|
|
|
|
packet |= ((hil_packet)data) << ((3 - (ptr->idx4 % 4)) * 8);
|
|
|
|
ptr->data[idx] = packet;
|
|
|
|
|
|
|
|
/* Records of N 4-byte hil_packets must terminate with a command. */
|
2007-03-01 04:51:29 +00:00
|
|
|
if ((++(ptr->idx4)) % 4)
|
|
|
|
return IRQ_HANDLED;
|
2005-04-16 22:20:36 +00:00
|
|
|
if ((packet & 0xffff0000) != HIL_ERR_INT) {
|
|
|
|
hil_ptr_process_err(ptr);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
2007-03-01 04:51:29 +00:00
|
|
|
if (packet & HIL_PKT_CMD)
|
2005-04-16 22:20:36 +00:00
|
|
|
hil_ptr_process_record(ptr);
|
2007-03-01 04:51:29 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hil_ptr_disconnect(struct serio *serio)
|
|
|
|
{
|
|
|
|
struct hil_ptr *ptr;
|
|
|
|
|
2005-10-22 02:58:51 +00:00
|
|
|
ptr = serio_get_drvdata(serio);
|
2007-03-01 04:51:29 +00:00
|
|
|
BUG_ON(ptr == NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
serio_close(serio);
|
2006-03-30 16:47:32 +00:00
|
|
|
input_unregister_device(ptr->dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
kfree(ptr);
|
|
|
|
}
|
|
|
|
|
2005-10-22 02:58:51 +00:00
|
|
|
static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-05-06 16:10:39 +00:00
|
|
|
struct hil_ptr *ptr;
|
|
|
|
const char *txt;
|
|
|
|
unsigned int i, naxsets, btntype;
|
|
|
|
uint8_t did, *idd;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
ptr = kzalloc(sizeof(struct hil_ptr), GFP_KERNEL);
|
|
|
|
if (!ptr)
|
2006-03-14 05:09:16 +00:00
|
|
|
return -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-03-26 14:41:55 +00:00
|
|
|
ptr->dev = input_allocate_device();
|
2008-05-06 16:10:39 +00:00
|
|
|
if (!ptr->dev) {
|
|
|
|
error = -ENOMEM;
|
2006-03-14 05:09:16 +00:00
|
|
|
goto bail0;
|
2008-05-06 16:10:39 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-05-06 16:10:39 +00:00
|
|
|
error = serio_open(serio, driver);
|
|
|
|
if (error)
|
2006-04-02 05:08:05 +00:00
|
|
|
goto bail1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-10-22 02:58:51 +00:00
|
|
|
serio_set_drvdata(serio, ptr);
|
2005-04-16 22:20:36 +00:00
|
|
|
ptr->serio = serio;
|
|
|
|
|
2007-03-01 04:51:29 +00:00
|
|
|
init_MUTEX_LOCKED(&ptr->sem);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Get device info. MLC driver supplies devid/status/etc. */
|
|
|
|
serio->write(serio, 0);
|
|
|
|
serio->write(serio, 0);
|
|
|
|
serio->write(serio, HIL_PKT_CMD >> 8);
|
|
|
|
serio->write(serio, HIL_CMD_IDD);
|
2007-03-01 04:51:29 +00:00
|
|
|
down(&ptr->sem);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
serio->write(serio, 0);
|
|
|
|
serio->write(serio, 0);
|
|
|
|
serio->write(serio, HIL_PKT_CMD >> 8);
|
|
|
|
serio->write(serio, HIL_CMD_RSC);
|
2007-03-01 04:51:29 +00:00
|
|
|
down(&ptr->sem);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
serio->write(serio, 0);
|
|
|
|
serio->write(serio, 0);
|
|
|
|
serio->write(serio, HIL_PKT_CMD >> 8);
|
|
|
|
serio->write(serio, HIL_CMD_RNM);
|
2007-03-01 04:51:29 +00:00
|
|
|
down(&ptr->sem);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
serio->write(serio, 0);
|
|
|
|
serio->write(serio, 0);
|
|
|
|
serio->write(serio, HIL_PKT_CMD >> 8);
|
|
|
|
serio->write(serio, HIL_CMD_EXD);
|
2007-03-01 04:51:29 +00:00
|
|
|
down(&ptr->sem);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-03-01 04:51:29 +00:00
|
|
|
up(&ptr->sem);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
did = ptr->idd[0];
|
|
|
|
idd = ptr->idd + 1;
|
|
|
|
txt = "unknown";
|
2008-05-06 16:10:39 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) {
|
2007-10-19 06:40:32 +00:00
|
|
|
ptr->dev->evbit[0] = BIT_MASK(EV_REL);
|
2005-04-16 22:20:36 +00:00
|
|
|
txt = "relative";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_ABS) {
|
2007-10-19 06:40:32 +00:00
|
|
|
ptr->dev->evbit[0] = BIT_MASK(EV_ABS);
|
2005-04-16 22:20:36 +00:00
|
|
|
txt = "absolute";
|
|
|
|
}
|
2008-05-06 16:10:39 +00:00
|
|
|
|
|
|
|
if (!ptr->dev->evbit[0]) {
|
|
|
|
error = -ENODEV;
|
2006-03-26 14:41:55 +00:00
|
|
|
goto bail2;
|
2008-05-06 16:10:39 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd);
|
2007-03-01 04:51:29 +00:00
|
|
|
if (ptr->nbtn)
|
2007-10-19 06:40:32 +00:00
|
|
|
ptr->dev->evbit[0] |= BIT_MASK(EV_KEY);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
naxsets = HIL_IDD_NUM_AXSETS(*idd);
|
|
|
|
ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd);
|
|
|
|
|
|
|
|
printk(KERN_INFO PREFIX "HIL pointer device found (did: 0x%02x, axis: %s)\n",
|
|
|
|
did, txt);
|
|
|
|
printk(KERN_INFO PREFIX "HIL pointer has %i buttons and %i sets of %i axes\n",
|
|
|
|
ptr->nbtn, naxsets, ptr->naxes);
|
2007-03-01 04:51:29 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
btntype = BTN_MISC;
|
|
|
|
if ((did & HIL_IDD_DID_ABS_TABLET_MASK) == HIL_IDD_DID_ABS_TABLET)
|
|
|
|
#ifdef TABLET_SIMULATES_MOUSE
|
|
|
|
btntype = BTN_TOUCH;
|
|
|
|
#else
|
|
|
|
btntype = BTN_DIGI;
|
|
|
|
#endif
|
|
|
|
if ((did & HIL_IDD_DID_ABS_TSCREEN_MASK) == HIL_IDD_DID_ABS_TSCREEN)
|
|
|
|
btntype = BTN_TOUCH;
|
2007-03-01 04:51:29 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if ((did & HIL_IDD_DID_REL_MOUSE_MASK) == HIL_IDD_DID_REL_MOUSE)
|
|
|
|
btntype = BTN_MOUSE;
|
|
|
|
|
|
|
|
for (i = 0; i < ptr->nbtn; i++) {
|
2006-03-26 14:41:55 +00:00
|
|
|
set_bit(btntype | i, ptr->dev->keybit);
|
2005-04-16 22:20:36 +00:00
|
|
|
ptr->btnmap[i] = btntype | i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (btntype == BTN_MOUSE) {
|
|
|
|
/* Swap buttons 2 and 3 */
|
|
|
|
ptr->btnmap[1] = BTN_MIDDLE;
|
|
|
|
ptr->btnmap[2] = BTN_RIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) {
|
2007-03-01 04:51:29 +00:00
|
|
|
for (i = 0; i < ptr->naxes; i++)
|
2006-03-26 14:41:55 +00:00
|
|
|
set_bit(REL_X + i, ptr->dev->relbit);
|
2007-03-01 04:51:29 +00:00
|
|
|
for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++)
|
2006-03-26 14:41:55 +00:00
|
|
|
set_bit(REL_X + i, ptr->dev->relbit);
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
|
|
|
for (i = 0; i < ptr->naxes; i++) {
|
2006-03-26 14:41:55 +00:00
|
|
|
set_bit(ABS_X + i, ptr->dev->absbit);
|
|
|
|
ptr->dev->absmin[ABS_X + i] = 0;
|
|
|
|
ptr->dev->absmax[ABS_X + i] =
|
2005-04-16 22:20:36 +00:00
|
|
|
HIL_IDD_AXIS_MAX((ptr->idd + 1), i);
|
|
|
|
}
|
|
|
|
for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) {
|
2006-03-26 14:41:55 +00:00
|
|
|
set_bit(ABS_X + i, ptr->dev->absbit);
|
|
|
|
ptr->dev->absmin[ABS_X + i] = 0;
|
|
|
|
ptr->dev->absmax[ABS_X + i] =
|
2005-04-16 22:20:36 +00:00
|
|
|
HIL_IDD_AXIS_MAX((ptr->idd + 1), (i - 3));
|
|
|
|
}
|
|
|
|
#ifdef TABLET_AUTOADJUST
|
|
|
|
for (i = 0; i < ABS_MAX; i++) {
|
2006-03-26 14:41:55 +00:00
|
|
|
int diff = ptr->dev->absmax[ABS_X + i] / 10;
|
|
|
|
ptr->dev->absmin[ABS_X + i] += diff;
|
|
|
|
ptr->dev->absmax[ABS_X + i] -= diff;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-03-26 14:41:55 +00:00
|
|
|
ptr->dev->name = strlen(ptr->rnm) ? ptr->rnm : HIL_GENERIC_NAME;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-03-26 14:41:55 +00:00
|
|
|
ptr->dev->id.bustype = BUS_HIL;
|
|
|
|
ptr->dev->id.vendor = PCI_VENDOR_ID_HP;
|
|
|
|
ptr->dev->id.product = 0x0001; /* TODO: get from ptr->rsc */
|
|
|
|
ptr->dev->id.version = 0x0100; /* TODO: get from ptr->rsc */
|
2007-04-12 05:35:09 +00:00
|
|
|
ptr->dev->dev.parent = &serio->dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-05-06 16:10:39 +00:00
|
|
|
error = input_register_device(ptr->dev);
|
|
|
|
if (error) {
|
|
|
|
printk(KERN_INFO PREFIX "Unable to register input device\n");
|
|
|
|
goto bail2;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
printk(KERN_INFO "input: %s (%s), ID: %d\n",
|
2006-03-26 14:41:55 +00:00
|
|
|
ptr->dev->name,
|
2005-04-16 22:20:36 +00:00
|
|
|
(btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad",
|
|
|
|
did);
|
|
|
|
|
2005-10-22 02:58:51 +00:00
|
|
|
return 0;
|
2008-05-06 16:10:39 +00:00
|
|
|
|
2006-03-26 14:41:55 +00:00
|
|
|
bail2:
|
2005-04-16 22:20:36 +00:00
|
|
|
serio_close(serio);
|
2006-03-26 14:41:55 +00:00
|
|
|
bail1:
|
|
|
|
input_free_device(ptr->dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
bail0:
|
|
|
|
kfree(ptr);
|
2005-10-22 02:58:51 +00:00
|
|
|
serio_set_drvdata(serio, NULL);
|
2008-05-06 16:10:39 +00:00
|
|
|
return error;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-10-22 02:58:51 +00:00
|
|
|
static struct serio_device_id hil_ptr_ids[] = {
|
|
|
|
{
|
|
|
|
.type = SERIO_HIL_MLC,
|
|
|
|
.proto = SERIO_HIL,
|
|
|
|
.id = SERIO_ANY,
|
|
|
|
.extra = SERIO_ANY,
|
|
|
|
},
|
|
|
|
{ 0 }
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static struct serio_driver hil_ptr_serio_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "hil_ptr",
|
|
|
|
},
|
|
|
|
.description = "HP HIL mouse/tablet driver",
|
2005-10-22 02:58:51 +00:00
|
|
|
.id_table = hil_ptr_ids,
|
|
|
|
.connect = hil_ptr_connect,
|
|
|
|
.disconnect = hil_ptr_disconnect,
|
|
|
|
.interrupt = hil_ptr_interrupt
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init hil_ptr_init(void)
|
|
|
|
{
|
2006-11-24 04:35:10 +00:00
|
|
|
return serio_register_driver(&hil_ptr_serio_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-03-01 04:51:29 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static void __exit hil_ptr_exit(void)
|
|
|
|
{
|
|
|
|
serio_unregister_driver(&hil_ptr_serio_driver);
|
|
|
|
}
|
2007-03-01 04:51:29 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
module_init(hil_ptr_init);
|
|
|
|
module_exit(hil_ptr_exit);
|