Commit fa71c605 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: combine hil_kbd and hil_ptr drivers

hil_kbd and hil_ptr look like twins so it makes sense to combine them
into a single driver.

[deller@gmx.de: add MODULE_ALIAS() entry for mouse]
Tested-by: default avatarHelge Deller <deller@gmx.de>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 1437dc30
...@@ -187,7 +187,7 @@ config KEYBOARD_HIL_OLD ...@@ -187,7 +187,7 @@ config KEYBOARD_HIL_OLD
submenu. submenu.
config KEYBOARD_HIL config KEYBOARD_HIL
tristate "HP HIL keyboard support" tristate "HP HIL keyboard/pointer support"
depends on GSC || HP300 depends on GSC || HP300
default y default y
select HP_SDC select HP_SDC
...@@ -196,7 +196,8 @@ config KEYBOARD_HIL ...@@ -196,7 +196,8 @@ config KEYBOARD_HIL
help help
The "Human Interface Loop" is a older, 8-channel USB-like The "Human Interface Loop" is a older, 8-channel USB-like
controller used in several Hewlett Packard models. controller used in several Hewlett Packard models.
This driver implements support for HIL-keyboards attached This driver implements support for HIL-keyboards and pointing
devices (mice, tablets, touchscreens) attached
to your machine, so normally you should say Y here. to your machine, so normally you should say Y here.
config KEYBOARD_HP6XX config KEYBOARD_HP6XX
......
...@@ -41,13 +41,13 @@ ...@@ -41,13 +41,13 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pci_ids.h> #include <linux/pci_ids.h>
#define PREFIX "HIL KEYB: " #define PREFIX "HIL: "
#define HIL_GENERIC_NAME "HIL keyboard"
MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>");
MODULE_DESCRIPTION(HIL_GENERIC_NAME " driver"); MODULE_DESCRIPTION("HIL keyboard/mouse driver");
MODULE_LICENSE("Dual BSD/GPL"); MODULE_LICENSE("Dual BSD/GPL");
MODULE_ALIAS("serio:ty03pr25id00ex*"); MODULE_ALIAS("serio:ty03pr25id00ex*"); /* HIL keyboard */
MODULE_ALIAS("serio:ty03pr25id0Fex*"); /* HIL mouse */
#define HIL_PACKET_MAX_LENGTH 16 #define HIL_PACKET_MAX_LENGTH 16
...@@ -82,6 +82,11 @@ struct hil_dev { ...@@ -82,6 +82,11 @@ struct hil_dev {
char rnm[HIL_PACKET_MAX_LENGTH + 1]; /* RNM record + NULL term. */ char rnm[HIL_PACKET_MAX_LENGTH + 1]; /* RNM record + NULL term. */
struct completion cmd_done; struct completion cmd_done;
bool is_pointer;
/* Extra device details needed for pointing devices. */
unsigned int nbtn, naxes;
unsigned int btnmap[7];
}; };
static bool hil_dev_is_command_response(hil_packet p) static bool hil_dev_is_command_response(hil_packet p)
...@@ -139,7 +144,7 @@ static void hil_dev_handle_command_response(struct hil_dev *dev) ...@@ -139,7 +144,7 @@ static void hil_dev_handle_command_response(struct hil_dev *dev)
complete(&dev->cmd_done); complete(&dev->cmd_done);
} }
static void hil_dev_handle_key_events(struct hil_dev *kbd) static void hil_dev_handle_kbd_events(struct hil_dev *kbd)
{ {
struct input_dev *dev = kbd->dev; struct input_dev *dev = kbd->dev;
int idx = kbd->idx4 / 4; int idx = kbd->idx4 / 4;
...@@ -198,6 +203,67 @@ static void hil_dev_handle_key_events(struct hil_dev *kbd) ...@@ -198,6 +203,67 @@ static void hil_dev_handle_key_events(struct hil_dev *kbd)
input_sync(dev); input_sync(dev);
} }
static void hil_dev_handle_ptr_events(struct hil_dev *ptr)
{
struct input_dev *dev = ptr->dev;
int idx = ptr->idx4 / 4;
hil_packet p = ptr->data[idx - 1];
int i, cnt, laxis;
bool absdev, ax16;
if ((p & HIL_CMDCT_POL) != idx - 1) {
printk(KERN_WARNING PREFIX
"Malformed poll packet %x (idx = %i)\n", p, idx);
return;
}
i = (p & HIL_POL_AXIS_ALT) ? 3 : 0;
laxis = (p & HIL_POL_NUM_AXES_MASK) + i;
ax16 = ptr->idd[1] & HIL_IDD_HEADER_16BIT; /* 8 or 16bit resolution */
absdev = ptr->idd[1] & HIL_IDD_HEADER_ABS;
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
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;
#endif
if (i%3) val = dev->absmax[ABS_X + i] - val;
input_report_abs(dev, ABS_X + i, val);
} else {
val = (int) (((int8_t)lo) | ((int8_t)hi << 8));
if (i % 3)
val *= -1;
input_report_rel(dev, REL_X + i, val);
}
}
while (cnt < idx - 1) {
unsigned int btn = ptr->data[cnt++];
int up = btn & 1;
btn &= 0xfe;
if (btn == 0x8e)
continue; /* TODO: proximity == touch? */
if (btn > 0x8c || btn < 0x80)
continue;
btn = (btn - 0x80) >> 1;
btn = ptr->btnmap[btn];
input_report_key(dev, btn, !up);
}
input_sync(dev);
}
static void hil_dev_process_err(struct hil_dev *dev) static void hil_dev_process_err(struct hil_dev *dev)
{ {
printk(KERN_WARNING PREFIX "errored HIL packet\n"); printk(KERN_WARNING PREFIX "errored HIL packet\n");
...@@ -234,8 +300,10 @@ static irqreturn_t hil_dev_interrupt(struct serio *serio, ...@@ -234,8 +300,10 @@ static irqreturn_t hil_dev_interrupt(struct serio *serio,
} else if (packet & HIL_PKT_CMD) { } else if (packet & HIL_PKT_CMD) {
if (hil_dev_is_command_response(packet)) if (hil_dev_is_command_response(packet))
hil_dev_handle_command_response(dev); hil_dev_handle_command_response(dev);
else if (dev->is_pointer)
hil_dev_handle_ptr_events(dev);
else else
hil_dev_handle_key_events(dev); hil_dev_handle_kbd_events(dev);
dev->idx4 = 0; dev->idx4 = 0;
} }
} }
...@@ -251,15 +319,130 @@ static void hil_dev_disconnect(struct serio *serio) ...@@ -251,15 +319,130 @@ static void hil_dev_disconnect(struct serio *serio)
serio_close(serio); serio_close(serio);
input_unregister_device(dev->dev); input_unregister_device(dev->dev);
serio_set_drvdata(serio, NULL);
kfree(dev); kfree(dev);
} }
static void hil_dev_keyboard_setup(struct hil_dev *kbd)
{
struct input_dev *input_dev = kbd->dev;
uint8_t did = kbd->idd[0];
int i;
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
input_dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) |
BIT_MASK(LED_SCROLLL);
for (i = 0; i < 128; i++) {
__set_bit(hil_kbd_set1[i], input_dev->keybit);
__set_bit(hil_kbd_set3[i], input_dev->keybit);
}
__clear_bit(KEY_RESERVED, input_dev->keybit);
input_dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE;
input_dev->keycodesize = sizeof(hil_kbd_set1[0]);
input_dev->keycode = hil_kbd_set1;
input_dev->name = strlen(kbd->rnm) ? kbd->rnm : "HIL keyboard";
input_dev->phys = "hpkbd/input0";
printk(KERN_INFO PREFIX "HIL keyboard found (did = 0x%02x, lang = %s)\n",
did, hil_language[did & HIL_IDD_DID_TYPE_KB_LANG_MASK]);
}
static void hil_dev_pointer_setup(struct hil_dev *ptr)
{
struct input_dev *input_dev = ptr->dev;
uint8_t did = ptr->idd[0];
uint8_t *idd = ptr->idd + 1;
unsigned int naxsets = HIL_IDD_NUM_AXSETS(*idd);
unsigned int i, btntype;
const char *txt;
ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd);
switch (did & HIL_IDD_DID_TYPE_MASK) {
case HIL_IDD_DID_TYPE_REL:
input_dev->evbit[0] = BIT_MASK(EV_REL);
for (i = 0; i < ptr->naxes; i++)
__set_bit(REL_X + i, input_dev->relbit);
for (i = 3; naxsets > 1 && i < ptr->naxes + 3; i++)
__set_bit(REL_X + i, input_dev->relbit);
txt = "relative";
break;
case HIL_IDD_DID_TYPE_ABS:
input_dev->evbit[0] = BIT_MASK(EV_ABS);
for (i = 0; i < ptr->naxes; i++)
input_set_abs_params(input_dev, ABS_X + i,
0, HIL_IDD_AXIS_MAX(idd, i), 0, 0);
for (i = 3; naxsets > 1 && i < ptr->naxes + 3; i++)
input_set_abs_params(input_dev, ABS_X + i,
0, HIL_IDD_AXIS_MAX(idd, i - 3), 0, 0);
#ifdef TABLET_AUTOADJUST
for (i = 0; i < ABS_MAX; i++) {
int diff = input_dev->absmax[ABS_X + i] / 10;
input_dev->absmin[ABS_X + i] += diff;
input_dev->absmax[ABS_X + i] -= diff;
}
#endif
txt = "absolute";
break;
default:
BUG();
}
ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd);
if (ptr->nbtn)
input_dev->evbit[0] |= BIT_MASK(EV_KEY);
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;
if ((did & HIL_IDD_DID_REL_MOUSE_MASK) == HIL_IDD_DID_REL_MOUSE)
btntype = BTN_MOUSE;
for (i = 0; i < ptr->nbtn; i++) {
__set_bit(btntype | i, input_dev->keybit);
ptr->btnmap[i] = btntype | i;
}
if (btntype == BTN_MOUSE) {
/* Swap buttons 2 and 3 */
ptr->btnmap[1] = BTN_MIDDLE;
ptr->btnmap[2] = BTN_RIGHT;
}
input_dev->name = strlen(ptr->rnm) ? ptr->rnm : "HIL pointer device";
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);
}
static int hil_dev_connect(struct serio *serio, struct serio_driver *drv) static int hil_dev_connect(struct serio *serio, struct serio_driver *drv)
{ {
struct hil_dev *dev; struct hil_dev *dev;
struct input_dev *input_dev; struct input_dev *input_dev;
uint8_t did, *idd; uint8_t did, *idd;
int i;
int error; int error;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
...@@ -317,49 +500,47 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv) ...@@ -317,49 +500,47 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv)
did = dev->idd[0]; did = dev->idd[0];
idd = dev->idd + 1; idd = dev->idd + 1;
switch (did & HIL_IDD_DID_TYPE_MASK) { switch (did & HIL_IDD_DID_TYPE_MASK) {
case HIL_IDD_DID_TYPE_KB_INTEGRAL: case HIL_IDD_DID_TYPE_KB_INTEGRAL:
case HIL_IDD_DID_TYPE_KB_ITF: case HIL_IDD_DID_TYPE_KB_ITF:
case HIL_IDD_DID_TYPE_KB_RSVD: case HIL_IDD_DID_TYPE_KB_RSVD:
case HIL_IDD_DID_TYPE_CHAR: case HIL_IDD_DID_TYPE_CHAR:
printk(KERN_INFO PREFIX "HIL keyboard found (did = 0x%02x, lang = %s)\n", if (HIL_IDD_NUM_BUTTONS(idd) ||
did, hil_language[did & HIL_IDD_DID_TYPE_KB_LANG_MASK]); HIL_IDD_NUM_AXES_PER_SET(*idd)) {
break; printk(KERN_INFO PREFIX
default: "combo devices are not supported.\n");
goto bail1; goto bail1;
} }
if (HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { dev->is_pointer = false;
printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n"); hil_dev_keyboard_setup(dev);
break;
case HIL_IDD_DID_TYPE_REL:
case HIL_IDD_DID_TYPE_ABS:
dev->is_pointer = true;
hil_dev_pointer_setup(dev);
break;
default:
goto bail1; goto bail1;
} }
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
input_dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) |
BIT_MASK(LED_SCROLLL);
input_dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE;
input_dev->keycodesize = sizeof(hil_kbd_set1[0]);
input_dev->keycode = hil_kbd_set1;
input_dev->name = strlen(dev->rnm) ? dev->rnm : HIL_GENERIC_NAME;
input_dev->phys = "hpkbd/input0"; /* XXX */
input_dev->id.bustype = BUS_HIL; input_dev->id.bustype = BUS_HIL;
input_dev->id.vendor = PCI_VENDOR_ID_HP; input_dev->id.vendor = PCI_VENDOR_ID_HP;
input_dev->id.product = 0x0001; /* TODO: get from kbd->rsc */ input_dev->id.product = 0x0001; /* TODO: get from kbd->rsc */
input_dev->id.version = 0x0100; /* TODO: get from kbd->rsc */ input_dev->id.version = 0x0100; /* TODO: get from kbd->rsc */
input_dev->dev.parent = &serio->dev; input_dev->dev.parent = &serio->dev;
for (i = 0; i < 128; i++) { if (!dev->is_pointer) {
__set_bit(hil_kbd_set1[i], input_dev->keybit);
__set_bit(hil_kbd_set3[i], input_dev->keybit);
}
__clear_bit(KEY_RESERVED, input_dev->keybit);
serio_write(serio, 0); serio_write(serio, 0);
serio_write(serio, 0); serio_write(serio, 0);
serio_write(serio, HIL_PKT_CMD >> 8); serio_write(serio, HIL_PKT_CMD >> 8);
serio_write(serio, HIL_CMD_EK1); /* Enable Keyswitch Autorepeat 1 */ /* Enable Keyswitch Autorepeat 1 */
serio_write(serio, HIL_CMD_EK1);
/* No need to wait for completion */ /* No need to wait for completion */
}
error = input_register_device(input_dev); error = input_register_device(input_dev);
if (error) if (error)
...@@ -388,9 +569,9 @@ static struct serio_device_id hil_dev_ids[] = { ...@@ -388,9 +569,9 @@ static struct serio_device_id hil_dev_ids[] = {
static struct serio_driver hil_serio_drv = { static struct serio_driver hil_serio_drv = {
.driver = { .driver = {
.name = "hil_kbd", .name = "hil_dev",
}, },
.description = "HP HIL keyboard driver", .description = "HP HIL keyboard/mouse/tablet driver",
.id_table = hil_dev_ids, .id_table = hil_dev_ids,
.connect = hil_dev_connect, .connect = hil_dev_connect,
.disconnect = hil_dev_disconnect, .disconnect = hil_dev_disconnect,
......
...@@ -262,14 +262,6 @@ config MOUSE_VSXXXAA ...@@ -262,14 +262,6 @@ config MOUSE_VSXXXAA
described in the source file). This driver also works with the described in the source file). This driver also works with the
digitizer (VSXXX-AB) DEC produced. digitizer (VSXXX-AB) DEC produced.
config MOUSE_HIL
tristate "HIL pointers (mice etc)."
depends on GSC || HP300
select HP_SDC
select HIL_MLC
help
Say Y here to support HIL pointers.
config MOUSE_GPIO config MOUSE_GPIO
tristate "GPIO mouse" tristate "GPIO mouse"
depends on GENERIC_GPIO depends on GENERIC_GPIO
......
...@@ -9,7 +9,6 @@ obj-$(CONFIG_MOUSE_APPLETOUCH) += appletouch.o ...@@ -9,7 +9,6 @@ obj-$(CONFIG_MOUSE_APPLETOUCH) += appletouch.o
obj-$(CONFIG_MOUSE_ATARI) += atarimouse.o obj-$(CONFIG_MOUSE_ATARI) += atarimouse.o
obj-$(CONFIG_MOUSE_BCM5974) += bcm5974.o obj-$(CONFIG_MOUSE_BCM5974) += bcm5974.o
obj-$(CONFIG_MOUSE_GPIO) += gpio_mouse.o obj-$(CONFIG_MOUSE_GPIO) += gpio_mouse.o
obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o
obj-$(CONFIG_MOUSE_INPORT) += inport.o obj-$(CONFIG_MOUSE_INPORT) += inport.o
obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o
obj-$(CONFIG_MOUSE_MAPLE) += maplemouse.o obj-$(CONFIG_MOUSE_MAPLE) += maplemouse.o
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment