Skip to content

Commit

Permalink
Merge master.kernel.org:/pub/scm/linux/kernel/git/dtor/input
Browse files Browse the repository at this point in the history
  • Loading branch information
Linus Torvalds committed Jul 29, 2005
2 parents ca49a60 + 33fdfa9 commit e0d7ff1
Show file tree
Hide file tree
Showing 34 changed files with 530 additions and 520 deletions.
4 changes: 2 additions & 2 deletions drivers/char/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ int setkeycode(unsigned int scancode, unsigned int keycode)

if (scancode >= dev->keycodemax)
return -EINVAL;
if (keycode > KEY_MAX)
return -EINVAL;
if (keycode < 0 || keycode > KEY_MAX)
return -EINVAL;
if (keycode >> (dev->keycodesize * 8))
return -EINVAL;

oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode);

Expand Down
146 changes: 65 additions & 81 deletions drivers/char/sonypi.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ static struct {
{ 0, 0 },
};

struct sonypi_keypress {
struct input_dev *dev;
int key;
};

static struct sonypi_device {
struct pci_dev *dev;
struct platform_device *pdev;
Expand Down Expand Up @@ -710,22 +715,61 @@ static void sonypi_setbluetoothpower(u8 state)

static void input_keyrelease(void *data)
{
struct input_dev *input_dev;
int key;

while (1) {
if (kfifo_get(sonypi_device.input_fifo,
(unsigned char *)&input_dev,
sizeof(input_dev)) != sizeof(input_dev))
return;
if (kfifo_get(sonypi_device.input_fifo,
(unsigned char *)&key,
sizeof(key)) != sizeof(key))
return;
struct sonypi_keypress kp;

while (kfifo_get(sonypi_device.input_fifo, (unsigned char *)&kp,
sizeof(kp)) == sizeof(kp)) {
msleep(10);
input_report_key(input_dev, key, 0);
input_sync(input_dev);
input_report_key(kp.dev, kp.key, 0);
input_sync(kp.dev);
}
}

static void sonypi_report_input_event(u8 event)
{
struct input_dev *jog_dev = &sonypi_device.input_jog_dev;
struct input_dev *key_dev = &sonypi_device.input_key_dev;
struct sonypi_keypress kp = { NULL };
int i;

switch (event) {
case SONYPI_EVENT_JOGDIAL_UP:
case SONYPI_EVENT_JOGDIAL_UP_PRESSED:
input_report_rel(jog_dev, REL_WHEEL, 1);
input_sync(jog_dev);
break;

case SONYPI_EVENT_JOGDIAL_DOWN:
case SONYPI_EVENT_JOGDIAL_DOWN_PRESSED:
input_report_rel(jog_dev, REL_WHEEL, -1);
input_sync(jog_dev);
break;

case SONYPI_EVENT_JOGDIAL_PRESSED:
kp.key = BTN_MIDDLE;
kp.dev = jog_dev;
break;

case SONYPI_EVENT_FNKEY_RELEASED:
/* Nothing, not all VAIOs generate this event */
break;

default:
for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
if (event == sonypi_inputkeys[i].sonypiev) {
kp.dev = key_dev;
kp.key = sonypi_inputkeys[i].inputev;
break;
}
break;
}

if (kp.dev) {
input_report_key(kp.dev, kp.key, 1);
input_sync(kp.dev);
kfifo_put(sonypi_device.input_fifo,
(unsigned char *)&kp, sizeof(kp));
schedule_work(&sonypi_device.input_work);
}
}

Expand Down Expand Up @@ -768,51 +812,8 @@ static irqreturn_t sonypi_irq(int irq, void *dev_id, struct pt_regs *regs)
printk(KERN_INFO
"sonypi: event port1=0x%02x,port2=0x%02x\n", v1, v2);

if (useinput) {
struct input_dev *input_jog_dev = &sonypi_device.input_jog_dev;
struct input_dev *input_key_dev = &sonypi_device.input_key_dev;
switch (event) {
case SONYPI_EVENT_JOGDIAL_UP:
case SONYPI_EVENT_JOGDIAL_UP_PRESSED:
input_report_rel(input_jog_dev, REL_WHEEL, 1);
break;
case SONYPI_EVENT_JOGDIAL_DOWN:
case SONYPI_EVENT_JOGDIAL_DOWN_PRESSED:
input_report_rel(input_jog_dev, REL_WHEEL, -1);
break;
case SONYPI_EVENT_JOGDIAL_PRESSED: {
int key = BTN_MIDDLE;
input_report_key(input_jog_dev, key, 1);
kfifo_put(sonypi_device.input_fifo,
(unsigned char *)&input_jog_dev,
sizeof(input_jog_dev));
kfifo_put(sonypi_device.input_fifo,
(unsigned char *)&key, sizeof(key));
break;
}
case SONYPI_EVENT_FNKEY_RELEASED:
/* Nothing, not all VAIOs generate this event */
break;
}
input_sync(input_jog_dev);

for (i = 0; sonypi_inputkeys[i].sonypiev; i++) {
int key;

if (event != sonypi_inputkeys[i].sonypiev)
continue;

key = sonypi_inputkeys[i].inputev;
input_report_key(input_key_dev, key, 1);
kfifo_put(sonypi_device.input_fifo,
(unsigned char *)&input_key_dev,
sizeof(input_key_dev));
kfifo_put(sonypi_device.input_fifo,
(unsigned char *)&key, sizeof(key));
}
input_sync(input_key_dev);
schedule_work(&sonypi_device.input_work);
}
if (useinput)
sonypi_report_input_event(event);

kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event));
kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN);
Expand Down Expand Up @@ -1227,14 +1228,7 @@ static int __devinit sonypi_probe(void)
sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] =
BIT(BTN_MIDDLE);
sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL);
sonypi_device.input_jog_dev.name =
kmalloc(sizeof(SONYPI_JOG_INPUTNAME), GFP_KERNEL);
if (!sonypi_device.input_jog_dev.name) {
printk(KERN_ERR "sonypi: kmalloc failed\n");
ret = -ENOMEM;
goto out_inkmallocinput1;
}
sprintf(sonypi_device.input_jog_dev.name, SONYPI_JOG_INPUTNAME);
sonypi_device.input_jog_dev.name = SONYPI_JOG_INPUTNAME;
sonypi_device.input_jog_dev.id.bustype = BUS_ISA;
sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY;

Expand All @@ -1248,14 +1242,7 @@ static int __devinit sonypi_probe(void)
if (sonypi_inputkeys[i].inputev)
set_bit(sonypi_inputkeys[i].inputev,
sonypi_device.input_key_dev.keybit);
sonypi_device.input_key_dev.name =
kmalloc(sizeof(SONYPI_KEY_INPUTNAME), GFP_KERNEL);
if (!sonypi_device.input_key_dev.name) {
printk(KERN_ERR "sonypi: kmalloc failed\n");
ret = -ENOMEM;
goto out_inkmallocinput2;
}
sprintf(sonypi_device.input_key_dev.name, SONYPI_KEY_INPUTNAME);
sonypi_device.input_key_dev.name = SONYPI_KEY_INPUTNAME;
sonypi_device.input_key_dev.id.bustype = BUS_ISA;
sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY;

Expand Down Expand Up @@ -1313,11 +1300,7 @@ static int __devinit sonypi_probe(void)
kfifo_free(sonypi_device.input_fifo);
out_infifo:
input_unregister_device(&sonypi_device.input_key_dev);
kfree(sonypi_device.input_key_dev.name);
out_inkmallocinput2:
input_unregister_device(&sonypi_device.input_jog_dev);
kfree(sonypi_device.input_jog_dev.name);
out_inkmallocinput1:
free_irq(sonypi_device.irq, sonypi_irq);
out_reqirq:
release_region(sonypi_device.ioport1, sonypi_device.region_size);
Expand All @@ -1337,13 +1320,14 @@ static void __devexit sonypi_remove(void)
{
sonypi_disable();

synchronize_sched(); /* Allow sonypi interrupt to complete. */
flush_scheduled_work();

platform_device_unregister(sonypi_device.pdev);

if (useinput) {
input_unregister_device(&sonypi_device.input_key_dev);
kfree(sonypi_device.input_key_dev.name);
input_unregister_device(&sonypi_device.input_jog_dev);
kfree(sonypi_device.input_jog_dev.name);
kfifo_free(sonypi_device.input_fifo);
}

Expand Down
1 change: 1 addition & 0 deletions drivers/input/evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL;
if (get_user(v, ip + 1)) return -EFAULT;
if (v < 0 || v > KEY_MAX) return -EINVAL;
if (v >> (dev->keycodesize * 8)) return -EINVAL;
u = SET_INPUT_KEYCODE(dev, t, v);
clear_bit(u, dev->keybit);
set_bit(v, dev->keybit);
Expand Down
Loading

0 comments on commit e0d7ff1

Please sign in to comment.