2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Elo serial touchscreen driver
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Vojtech Pavlik
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This driver can handle serial Elo touchscreens using either the Elo standard
|
|
|
|
* 'E271-2210' 10-byte protocol, Elo legacy 'E281A-4002' 6-byte protocol, Elo
|
|
|
|
* legacy 'E271-140' 4-byte protocol and Elo legacy 'E261-280' 3-byte protocol.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/serio.h>
|
|
|
|
#include <linux/init.h>
|
2006-08-04 22:29:49 -06:00
|
|
|
#include <linux/ctype.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#define DRIVER_DESC "Elo serial touchscreen driver"
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Definitions & global arrays.
|
|
|
|
*/
|
|
|
|
|
2006-08-04 22:27:59 -06:00
|
|
|
#define ELO_MAX_LENGTH 10
|
|
|
|
|
2006-08-04 22:29:49 -06:00
|
|
|
#define ELO10_PACKET_LEN 8
|
|
|
|
#define ELO10_TOUCH 0x03
|
|
|
|
#define ELO10_PRESSURE 0x80
|
|
|
|
|
2006-08-04 22:27:59 -06:00
|
|
|
#define ELO10_LEAD_BYTE 'U'
|
|
|
|
|
2006-08-04 22:29:49 -06:00
|
|
|
#define ELO10_ID_CMD 'i'
|
|
|
|
|
2006-08-04 22:27:59 -06:00
|
|
|
#define ELO10_TOUCH_PACKET 'T'
|
2006-08-04 22:29:49 -06:00
|
|
|
#define ELO10_ACK_PACKET 'A'
|
|
|
|
#define ELI10_ID_PACKET 'I'
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Per-touchscreen data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct elo {
|
2005-09-15 01:01:46 -06:00
|
|
|
struct input_dev *dev;
|
2005-04-16 16:20:36 -06:00
|
|
|
struct serio *serio;
|
2006-08-04 22:29:49 -06:00
|
|
|
struct mutex cmd_mutex;
|
|
|
|
struct completion cmd_done;
|
2005-04-16 16:20:36 -06:00
|
|
|
int id;
|
|
|
|
int idx;
|
2006-08-04 22:29:49 -06:00
|
|
|
unsigned char expected_packet;
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned char csum;
|
|
|
|
unsigned char data[ELO_MAX_LENGTH];
|
2006-08-04 22:29:49 -06:00
|
|
|
unsigned char response[ELO10_PACKET_LEN];
|
2005-04-16 16:20:36 -06:00
|
|
|
char phys[32];
|
|
|
|
};
|
|
|
|
|
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 07:55:46 -06:00
|
|
|
static void elo_process_data_10(struct elo *elo, unsigned char data)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-09-15 01:01:46 -06:00
|
|
|
struct input_dev *dev = elo->dev;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-08-04 22:27:59 -06:00
|
|
|
elo->data[elo->idx] = data;
|
2005-04-16 16:20:36 -06:00
|
|
|
switch (elo->idx++) {
|
|
|
|
case 0:
|
2006-08-04 22:27:59 -06:00
|
|
|
elo->csum = 0xaa;
|
|
|
|
if (data != ELO10_LEAD_BYTE) {
|
|
|
|
pr_debug("elo: unsynchronized data: 0x%02x\n", data);
|
2005-04-16 16:20:36 -06:00
|
|
|
elo->idx = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
elo->idx = 0;
|
2006-08-04 22:27:59 -06:00
|
|
|
if (data != elo->csum) {
|
|
|
|
pr_debug("elo: bad checksum: 0x%02x, expected 0x%02x\n",
|
|
|
|
data, elo->csum);
|
|
|
|
break;
|
|
|
|
}
|
2006-08-04 22:29:49 -06:00
|
|
|
if (elo->data[1] != elo->expected_packet) {
|
|
|
|
if (elo->data[1] != ELO10_TOUCH_PACKET)
|
|
|
|
pr_debug("elo: unexpected packet: 0x%02x\n",
|
|
|
|
elo->data[1]);
|
2006-08-04 22:27:59 -06:00
|
|
|
break;
|
|
|
|
}
|
2006-08-04 22:29:49 -06:00
|
|
|
if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) {
|
|
|
|
input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]);
|
|
|
|
input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]);
|
|
|
|
if (elo->data[2] & ELO10_PRESSURE)
|
|
|
|
input_report_abs(dev, ABS_PRESSURE,
|
|
|
|
(elo->data[8] << 8) | elo->data[7]);
|
|
|
|
input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH);
|
|
|
|
input_sync(dev);
|
|
|
|
} else if (elo->data[1] == ELO10_ACK_PACKET) {
|
|
|
|
if (elo->data[2] == '0')
|
|
|
|
elo->expected_packet = ELO10_TOUCH_PACKET;
|
|
|
|
complete(&elo->cmd_done);
|
|
|
|
} else {
|
|
|
|
memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN);
|
|
|
|
elo->expected_packet = ELO10_ACK_PACKET;
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
}
|
2006-08-04 22:27:59 -06:00
|
|
|
elo->csum += data;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
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 07:55:46 -06:00
|
|
|
static void elo_process_data_6(struct elo *elo, unsigned char data)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-09-15 01:01:46 -06:00
|
|
|
struct input_dev *dev = elo->dev;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
elo->data[elo->idx] = data;
|
|
|
|
|
|
|
|
switch (elo->idx++) {
|
|
|
|
|
|
|
|
case 0: if ((data & 0xc0) != 0xc0) elo->idx = 0; break;
|
|
|
|
case 1: if ((data & 0xc0) != 0x80) elo->idx = 0; break;
|
|
|
|
case 2: if ((data & 0xc0) != 0x40) elo->idx = 0; break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
if (data & 0xc0) {
|
|
|
|
elo->idx = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f));
|
|
|
|
input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f));
|
|
|
|
|
|
|
|
if (elo->id == 2) {
|
|
|
|
input_report_key(dev, BTN_TOUCH, 1);
|
|
|
|
input_sync(dev);
|
|
|
|
elo->idx = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
if (data) {
|
|
|
|
input_sync(dev);
|
|
|
|
elo->idx = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
if ((data & 0xf0) == 0) {
|
|
|
|
input_report_abs(dev, ABS_PRESSURE, elo->data[5]);
|
2005-09-15 01:01:46 -06:00
|
|
|
input_report_key(dev, BTN_TOUCH, !!elo->data[5]);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
input_sync(dev);
|
|
|
|
elo->idx = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 07:55:46 -06:00
|
|
|
static void elo_process_data_3(struct elo *elo, unsigned char data)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-09-15 01:01:46 -06:00
|
|
|
struct input_dev *dev = elo->dev;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
elo->data[elo->idx] = data;
|
|
|
|
|
|
|
|
switch (elo->idx++) {
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
if ((data & 0x7f) != 0x01)
|
|
|
|
elo->idx = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80));
|
|
|
|
input_report_abs(dev, ABS_X, elo->data[1]);
|
|
|
|
input_report_abs(dev, ABS_Y, elo->data[2]);
|
|
|
|
input_sync(dev);
|
|
|
|
elo->idx = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t elo_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 07:55:46 -06:00
|
|
|
unsigned char data, unsigned int flags)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-08-04 22:27:59 -06:00
|
|
|
struct elo *elo = serio_get_drvdata(serio);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
switch(elo->id) {
|
|
|
|
case 0:
|
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 07:55:46 -06:00
|
|
|
elo_process_data_10(elo, data);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
case 2:
|
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 07:55:46 -06:00
|
|
|
elo_process_data_6(elo, data);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
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 07:55:46 -06:00
|
|
|
elo_process_data_3(elo, data);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2006-08-04 22:29:49 -06:00
|
|
|
static int elo_command_10(struct elo *elo, unsigned char *packet)
|
|
|
|
{
|
|
|
|
int rc = -1;
|
|
|
|
int i;
|
|
|
|
unsigned char csum = 0xaa + ELO10_LEAD_BYTE;
|
|
|
|
|
|
|
|
mutex_lock(&elo->cmd_mutex);
|
|
|
|
|
|
|
|
serio_pause_rx(elo->serio);
|
|
|
|
elo->expected_packet = toupper(packet[0]);
|
|
|
|
init_completion(&elo->cmd_done);
|
|
|
|
serio_continue_rx(elo->serio);
|
|
|
|
|
|
|
|
if (serio_write(elo->serio, ELO10_LEAD_BYTE))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
for (i = 0; i < ELO10_PACKET_LEN; i++) {
|
|
|
|
csum += packet[i];
|
|
|
|
if (serio_write(elo->serio, packet[i]))
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serio_write(elo->serio, csum))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
wait_for_completion_timeout(&elo->cmd_done, HZ);
|
|
|
|
|
|
|
|
if (elo->expected_packet == ELO10_TOUCH_PACKET) {
|
|
|
|
/* We are back in reporting mode, the command was ACKed */
|
|
|
|
memcpy(packet, elo->response, ELO10_PACKET_LEN);
|
|
|
|
rc = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
mutex_unlock(&elo->cmd_mutex);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int elo_setup_10(struct elo *elo)
|
|
|
|
{
|
|
|
|
static const char *elo_types[] = { "Accu", "Dura", "Intelli", "Carroll" };
|
|
|
|
struct input_dev *dev = elo->dev;
|
|
|
|
unsigned char packet[ELO10_PACKET_LEN] = { ELO10_ID_CMD };
|
|
|
|
|
|
|
|
if (elo_command_10(elo, packet))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
dev->id.version = (packet[5] << 8) | packet[4];
|
|
|
|
|
|
|
|
input_set_abs_params(dev, ABS_X, 96, 4000, 0, 0);
|
|
|
|
input_set_abs_params(dev, ABS_Y, 96, 4000, 0, 0);
|
|
|
|
if (packet[3] & ELO10_PRESSURE)
|
|
|
|
input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
|
|
|
|
|
|
|
|
printk(KERN_INFO "elo: %sTouch touchscreen, fw: %02x.%02x, "
|
2008-10-30 07:11:40 -06:00
|
|
|
"features: 0x%02x, controller: 0x%02x\n",
|
2006-08-04 22:29:49 -06:00
|
|
|
elo_types[(packet[1] -'0') & 0x03],
|
|
|
|
packet[5], packet[4], packet[3], packet[7]);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* elo_disconnect() is the opposite of elo_connect()
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void elo_disconnect(struct serio *serio)
|
|
|
|
{
|
2006-08-04 22:27:00 -06:00
|
|
|
struct elo *elo = serio_get_drvdata(serio);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-08-04 22:27:00 -06:00
|
|
|
input_get_device(elo->dev);
|
2005-09-15 01:01:46 -06:00
|
|
|
input_unregister_device(elo->dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
serio_close(serio);
|
|
|
|
serio_set_drvdata(serio, NULL);
|
2006-08-04 22:27:00 -06:00
|
|
|
input_put_device(elo->dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
kfree(elo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* elo_connect() is the routine that is called when someone adds a
|
|
|
|
* new serio device that supports Gunze protocol and registers it as
|
|
|
|
* an input device.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int elo_connect(struct serio *serio, struct serio_driver *drv)
|
|
|
|
{
|
|
|
|
struct elo *elo;
|
2005-09-15 01:01:46 -06:00
|
|
|
struct input_dev *input_dev;
|
2005-04-16 16:20:36 -06:00
|
|
|
int err;
|
|
|
|
|
2005-09-15 01:01:46 -06:00
|
|
|
elo = kzalloc(sizeof(struct elo), GFP_KERNEL);
|
|
|
|
input_dev = input_allocate_device();
|
|
|
|
if (!elo || !input_dev) {
|
|
|
|
err = -ENOMEM;
|
2006-08-04 22:27:00 -06:00
|
|
|
goto fail1;
|
2005-09-15 01:01:46 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-09-15 01:01:46 -06:00
|
|
|
elo->serio = serio;
|
|
|
|
elo->id = serio->id.id;
|
|
|
|
elo->dev = input_dev;
|
2006-08-04 22:29:49 -06:00
|
|
|
elo->expected_packet = ELO10_TOUCH_PACKET;
|
|
|
|
mutex_init(&elo->cmd_mutex);
|
|
|
|
init_completion(&elo->cmd_done);
|
2005-09-15 01:01:46 -06:00
|
|
|
snprintf(elo->phys, sizeof(elo->phys), "%s/input0", serio->phys);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-09-15 01:01:46 -06:00
|
|
|
input_dev->name = "Elo Serial TouchScreen";
|
|
|
|
input_dev->phys = elo->phys;
|
|
|
|
input_dev->id.bustype = BUS_RS232;
|
|
|
|
input_dev->id.vendor = SERIO_ELO;
|
|
|
|
input_dev->id.product = elo->id;
|
|
|
|
input_dev->id.version = 0x0100;
|
2007-04-11 23:35:14 -06:00
|
|
|
input_dev->dev.parent = &serio->dev;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-10-19 00:40:32 -06:00
|
|
|
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
|
|
|
|
input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-08-04 22:29:49 -06:00
|
|
|
serio_set_drvdata(serio, elo);
|
|
|
|
err = serio_open(serio, drv);
|
|
|
|
if (err)
|
|
|
|
goto fail2;
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
switch (elo->id) {
|
|
|
|
|
|
|
|
case 0: /* 10-byte protocol */
|
2006-08-04 22:29:49 -06:00
|
|
|
if (elo_setup_10(elo))
|
|
|
|
goto fail3;
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
2005-05-29 01:28:50 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
case 1: /* 6-byte protocol */
|
2005-09-15 01:01:46 -06:00
|
|
|
input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
case 2: /* 4-byte protocol */
|
2005-09-15 01:01:46 -06:00
|
|
|
input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0);
|
|
|
|
input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* 3-byte protocol */
|
2005-09-15 01:01:46 -06:00
|
|
|
input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0);
|
|
|
|
input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-08-04 22:27:00 -06:00
|
|
|
err = input_register_device(elo->dev);
|
|
|
|
if (err)
|
|
|
|
goto fail3;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return 0;
|
2005-09-15 01:01:46 -06:00
|
|
|
|
2006-08-04 22:27:00 -06:00
|
|
|
fail3: serio_close(serio);
|
|
|
|
fail2: serio_set_drvdata(serio, NULL);
|
|
|
|
fail1: input_free_device(input_dev);
|
2005-09-15 01:01:46 -06:00
|
|
|
kfree(elo);
|
|
|
|
return err;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The serio driver structure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static struct serio_device_id elo_serio_ids[] = {
|
|
|
|
{
|
|
|
|
.type = SERIO_RS232,
|
|
|
|
.proto = SERIO_ELO,
|
|
|
|
.id = SERIO_ANY,
|
|
|
|
.extra = SERIO_ANY,
|
|
|
|
},
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(serio, elo_serio_ids);
|
|
|
|
|
|
|
|
static struct serio_driver elo_drv = {
|
|
|
|
.driver = {
|
|
|
|
.name = "elo",
|
|
|
|
},
|
|
|
|
.description = DRIVER_DESC,
|
|
|
|
.id_table = elo_serio_ids,
|
|
|
|
.interrupt = elo_interrupt,
|
|
|
|
.connect = elo_connect,
|
|
|
|
.disconnect = elo_disconnect,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The functions for inserting/removing us as a module.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int __init elo_init(void)
|
|
|
|
{
|
2006-11-23 21:35:10 -07:00
|
|
|
return serio_register_driver(&elo_drv);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit elo_exit(void)
|
|
|
|
{
|
|
|
|
serio_unregister_driver(&elo_drv);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(elo_init);
|
|
|
|
module_exit(elo_exit);
|