Input: vsxxxaa - change formatting style to match the rest of the kernel
- no spaces between function name and opening parenthesis - switch statements were indented too much This makes checkpatch (and me) happy. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
7d3fadd148
commit
216023255a
|
@ -86,27 +86,28 @@
|
||||||
|
|
||||||
#define DRIVER_DESC "Driver for DEC VSXXX-AA and -GA mice and VSXXX-AB tablet"
|
#define DRIVER_DESC "Driver for DEC VSXXX-AA and -GA mice and VSXXX-AB tablet"
|
||||||
|
|
||||||
MODULE_AUTHOR ("Jan-Benedict Glaw <jbglaw@lug-owl.de>");
|
MODULE_AUTHOR("Jan-Benedict Glaw <jbglaw@lug-owl.de>");
|
||||||
MODULE_DESCRIPTION (DRIVER_DESC);
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
||||||
MODULE_LICENSE ("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
#undef VSXXXAA_DEBUG
|
#undef VSXXXAA_DEBUG
|
||||||
#ifdef VSXXXAA_DEBUG
|
#ifdef VSXXXAA_DEBUG
|
||||||
#define DBG(x...) printk (x)
|
#define DBG(x...) printk(x)
|
||||||
#else
|
#else
|
||||||
#define DBG(x...) do {} while (0)
|
#define DBG(x...) do {} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VSXXXAA_INTRO_MASK 0x80
|
#define VSXXXAA_INTRO_MASK 0x80
|
||||||
#define VSXXXAA_INTRO_HEAD 0x80
|
#define VSXXXAA_INTRO_HEAD 0x80
|
||||||
#define IS_HDR_BYTE(x) (((x) & VSXXXAA_INTRO_MASK) \
|
#define IS_HDR_BYTE(x) \
|
||||||
== VSXXXAA_INTRO_HEAD)
|
(((x) & VSXXXAA_INTRO_MASK) == VSXXXAA_INTRO_HEAD)
|
||||||
|
|
||||||
#define VSXXXAA_PACKET_MASK 0xe0
|
#define VSXXXAA_PACKET_MASK 0xe0
|
||||||
#define VSXXXAA_PACKET_REL 0x80
|
#define VSXXXAA_PACKET_REL 0x80
|
||||||
#define VSXXXAA_PACKET_ABS 0xc0
|
#define VSXXXAA_PACKET_ABS 0xc0
|
||||||
#define VSXXXAA_PACKET_POR 0xa0
|
#define VSXXXAA_PACKET_POR 0xa0
|
||||||
#define MATCH_PACKET_TYPE(data, type) (((data) & VSXXXAA_PACKET_MASK) == (type))
|
#define MATCH_PACKET_TYPE(data, type) \
|
||||||
|
(((data) & VSXXXAA_PACKET_MASK) == (type))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,52 +124,50 @@ struct vsxxxaa {
|
||||||
char phys[32];
|
char phys[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void vsxxxaa_drop_bytes(struct vsxxxaa *mouse, int num)
|
||||||
vsxxxaa_drop_bytes (struct vsxxxaa *mouse, int num)
|
|
||||||
{
|
{
|
||||||
if (num >= mouse->count)
|
if (num >= mouse->count) {
|
||||||
mouse->count = 0;
|
mouse->count = 0;
|
||||||
else {
|
} else {
|
||||||
memmove (mouse->buf, mouse->buf + num - 1, BUFLEN - num);
|
memmove(mouse->buf, mouse->buf + num - 1, BUFLEN - num);
|
||||||
mouse->count -= num;
|
mouse->count -= num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void vsxxxaa_queue_byte(struct vsxxxaa *mouse, unsigned char byte)
|
||||||
vsxxxaa_queue_byte (struct vsxxxaa *mouse, unsigned char byte)
|
|
||||||
{
|
{
|
||||||
if (mouse->count == BUFLEN) {
|
if (mouse->count == BUFLEN) {
|
||||||
printk (KERN_ERR "%s on %s: Dropping a byte of full buffer.\n",
|
printk(KERN_ERR "%s on %s: Dropping a byte of full buffer.\n",
|
||||||
mouse->name, mouse->phys);
|
mouse->name, mouse->phys);
|
||||||
vsxxxaa_drop_bytes (mouse, 1);
|
vsxxxaa_drop_bytes(mouse, 1);
|
||||||
}
|
}
|
||||||
DBG (KERN_INFO "Queueing byte 0x%02x\n", byte);
|
|
||||||
|
DBG(KERN_INFO "Queueing byte 0x%02x\n", byte);
|
||||||
|
|
||||||
mouse->buf[mouse->count++] = byte;
|
mouse->buf[mouse->count++] = byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void vsxxxaa_detection_done(struct vsxxxaa *mouse)
|
||||||
vsxxxaa_detection_done (struct vsxxxaa *mouse)
|
|
||||||
{
|
{
|
||||||
switch (mouse->type) {
|
switch (mouse->type) {
|
||||||
case 0x02:
|
case 0x02:
|
||||||
strlcpy (mouse->name, "DEC VSXXX-AA/-GA mouse",
|
strlcpy(mouse->name, "DEC VSXXX-AA/-GA mouse",
|
||||||
sizeof (mouse->name));
|
sizeof(mouse->name));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x04:
|
case 0x04:
|
||||||
strlcpy (mouse->name, "DEC VSXXX-AB digitizer",
|
strlcpy(mouse->name, "DEC VSXXX-AB digitizer",
|
||||||
sizeof (mouse->name));
|
sizeof(mouse->name));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf (mouse->name, sizeof (mouse->name),
|
snprintf(mouse->name, sizeof(mouse->name),
|
||||||
"unknown DEC pointer device (type = 0x%02x)",
|
"unknown DEC pointer device (type = 0x%02x)",
|
||||||
mouse->type);
|
mouse->type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printk (KERN_INFO
|
printk(KERN_INFO
|
||||||
"Found %s version 0x%02x from country 0x%02x on port %s\n",
|
"Found %s version 0x%02x from country 0x%02x on port %s\n",
|
||||||
mouse->name, mouse->version, mouse->country, mouse->phys);
|
mouse->name, mouse->version, mouse->country, mouse->phys);
|
||||||
}
|
}
|
||||||
|
@ -176,42 +175,38 @@ vsxxxaa_detection_done (struct vsxxxaa *mouse)
|
||||||
/*
|
/*
|
||||||
* Returns number of bytes to be dropped, 0 if packet is okay.
|
* Returns number of bytes to be dropped, 0 if packet is okay.
|
||||||
*/
|
*/
|
||||||
static int
|
static int vsxxxaa_check_packet(struct vsxxxaa *mouse, int packet_len)
|
||||||
vsxxxaa_check_packet (struct vsxxxaa *mouse, int packet_len)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* First byte must be a header byte */
|
/* First byte must be a header byte */
|
||||||
if (!IS_HDR_BYTE (mouse->buf[0])) {
|
if (!IS_HDR_BYTE(mouse->buf[0])) {
|
||||||
DBG ("vsck: len=%d, 1st=0x%02x\n", packet_len, mouse->buf[0]);
|
DBG("vsck: len=%d, 1st=0x%02x\n", packet_len, mouse->buf[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check all following bytes */
|
/* Check all following bytes */
|
||||||
if (packet_len > 1) {
|
for (i = 1; i < packet_len; i++) {
|
||||||
for (i = 1; i < packet_len; i++) {
|
if (IS_HDR_BYTE(mouse->buf[i])) {
|
||||||
if (IS_HDR_BYTE (mouse->buf[i])) {
|
printk(KERN_ERR
|
||||||
printk (KERN_ERR "Need to drop %d bytes "
|
"Need to drop %d bytes of a broken packet.\n",
|
||||||
"of a broken packet.\n",
|
i - 1);
|
||||||
i - 1);
|
DBG(KERN_INFO "check: len=%d, b[%d]=0x%02x\n",
|
||||||
DBG (KERN_INFO "check: len=%d, b[%d]=0x%02x\n",
|
packet_len, i, mouse->buf[i]);
|
||||||
packet_len, i, mouse->buf[i]);
|
return i - 1;
|
||||||
return i - 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int
|
static inline int vsxxxaa_smells_like_packet(struct vsxxxaa *mouse,
|
||||||
vsxxxaa_smells_like_packet (struct vsxxxaa *mouse, unsigned char type, size_t len)
|
unsigned char type, size_t len)
|
||||||
{
|
{
|
||||||
return (mouse->count >= len) && MATCH_PACKET_TYPE (mouse->buf[0], type);
|
return mouse->count >= len && MATCH_PACKET_TYPE(mouse->buf[0], type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void vsxxxaa_handle_REL_packet(struct vsxxxaa *mouse)
|
||||||
vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse)
|
|
||||||
{
|
{
|
||||||
struct input_dev *dev = mouse->dev;
|
struct input_dev *dev = mouse->dev;
|
||||||
unsigned char *buf = mouse->buf;
|
unsigned char *buf = mouse->buf;
|
||||||
|
@ -232,43 +227,42 @@ vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse)
|
||||||
* 0, bit 4 of byte 0 is direction.
|
* 0, bit 4 of byte 0 is direction.
|
||||||
*/
|
*/
|
||||||
dx = buf[1] & 0x7f;
|
dx = buf[1] & 0x7f;
|
||||||
dx *= ((buf[0] >> 4) & 0x01)? 1: -1;
|
dx *= ((buf[0] >> 4) & 0x01) ? 1 : -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Low 7 bit of byte 2 are abs(dy), bit 7 is
|
* Low 7 bit of byte 2 are abs(dy), bit 7 is
|
||||||
* 0, bit 3 of byte 0 is direction.
|
* 0, bit 3 of byte 0 is direction.
|
||||||
*/
|
*/
|
||||||
dy = buf[2] & 0x7f;
|
dy = buf[2] & 0x7f;
|
||||||
dy *= ((buf[0] >> 3) & 0x01)? -1: 1;
|
dy *= ((buf[0] >> 3) & 0x01) ? -1 : 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get button state. It's the low three bits
|
* Get button state. It's the low three bits
|
||||||
* (for three buttons) of byte 0.
|
* (for three buttons) of byte 0.
|
||||||
*/
|
*/
|
||||||
left = (buf[0] & 0x04)? 1: 0;
|
left = buf[0] & 0x04;
|
||||||
middle = (buf[0] & 0x02)? 1: 0;
|
middle = buf[0] & 0x02;
|
||||||
right = (buf[0] & 0x01)? 1: 0;
|
right = buf[0] & 0x01;
|
||||||
|
|
||||||
vsxxxaa_drop_bytes (mouse, 3);
|
vsxxxaa_drop_bytes(mouse, 3);
|
||||||
|
|
||||||
DBG (KERN_INFO "%s on %s: dx=%d, dy=%d, buttons=%s%s%s\n",
|
DBG(KERN_INFO "%s on %s: dx=%d, dy=%d, buttons=%s%s%s\n",
|
||||||
mouse->name, mouse->phys, dx, dy,
|
mouse->name, mouse->phys, dx, dy,
|
||||||
left? "L": "l", middle? "M": "m", right? "R": "r");
|
left ? "L" : "l", middle ? "M" : "m", right ? "R" : "r");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Report what we've found so far...
|
* Report what we've found so far...
|
||||||
*/
|
*/
|
||||||
input_report_key (dev, BTN_LEFT, left);
|
input_report_key(dev, BTN_LEFT, left);
|
||||||
input_report_key (dev, BTN_MIDDLE, middle);
|
input_report_key(dev, BTN_MIDDLE, middle);
|
||||||
input_report_key (dev, BTN_RIGHT, right);
|
input_report_key(dev, BTN_RIGHT, right);
|
||||||
input_report_key (dev, BTN_TOUCH, 0);
|
input_report_key(dev, BTN_TOUCH, 0);
|
||||||
input_report_rel (dev, REL_X, dx);
|
input_report_rel(dev, REL_X, dx);
|
||||||
input_report_rel (dev, REL_Y, dy);
|
input_report_rel(dev, REL_Y, dy);
|
||||||
input_sync (dev);
|
input_sync(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void vsxxxaa_handle_ABS_packet(struct vsxxxaa *mouse)
|
||||||
vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse)
|
|
||||||
{
|
{
|
||||||
struct input_dev *dev = mouse->dev;
|
struct input_dev *dev = mouse->dev;
|
||||||
unsigned char *buf = mouse->buf;
|
unsigned char *buf = mouse->buf;
|
||||||
|
@ -296,32 +290,31 @@ vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse)
|
||||||
/*
|
/*
|
||||||
* Get button state. It's bits <4..1> of byte 0.
|
* Get button state. It's bits <4..1> of byte 0.
|
||||||
*/
|
*/
|
||||||
left = (buf[0] & 0x02)? 1: 0;
|
left = buf[0] & 0x02;
|
||||||
middle = (buf[0] & 0x04)? 1: 0;
|
middle = buf[0] & 0x04;
|
||||||
right = (buf[0] & 0x08)? 1: 0;
|
right = buf[0] & 0x08;
|
||||||
touch = (buf[0] & 0x10)? 1: 0;
|
touch = buf[0] & 0x10;
|
||||||
|
|
||||||
vsxxxaa_drop_bytes (mouse, 5);
|
vsxxxaa_drop_bytes(mouse, 5);
|
||||||
|
|
||||||
DBG (KERN_INFO "%s on %s: x=%d, y=%d, buttons=%s%s%s%s\n",
|
DBG(KERN_INFO "%s on %s: x=%d, y=%d, buttons=%s%s%s%s\n",
|
||||||
mouse->name, mouse->phys, x, y,
|
mouse->name, mouse->phys, x, y,
|
||||||
left? "L": "l", middle? "M": "m",
|
left ? "L" : "l", middle ? "M" : "m",
|
||||||
right? "R": "r", touch? "T": "t");
|
right ? "R" : "r", touch ? "T" : "t");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Report what we've found so far...
|
* Report what we've found so far...
|
||||||
*/
|
*/
|
||||||
input_report_key (dev, BTN_LEFT, left);
|
input_report_key(dev, BTN_LEFT, left);
|
||||||
input_report_key (dev, BTN_MIDDLE, middle);
|
input_report_key(dev, BTN_MIDDLE, middle);
|
||||||
input_report_key (dev, BTN_RIGHT, right);
|
input_report_key(dev, BTN_RIGHT, right);
|
||||||
input_report_key (dev, BTN_TOUCH, touch);
|
input_report_key(dev, BTN_TOUCH, touch);
|
||||||
input_report_abs (dev, ABS_X, x);
|
input_report_abs(dev, ABS_X, x);
|
||||||
input_report_abs (dev, ABS_Y, y);
|
input_report_abs(dev, ABS_Y, y);
|
||||||
input_sync (dev);
|
input_sync(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void vsxxxaa_handle_POR_packet(struct vsxxxaa *mouse)
|
||||||
vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse)
|
|
||||||
{
|
{
|
||||||
struct input_dev *dev = mouse->dev;
|
struct input_dev *dev = mouse->dev;
|
||||||
unsigned char *buf = mouse->buf;
|
unsigned char *buf = mouse->buf;
|
||||||
|
@ -356,24 +349,24 @@ vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse)
|
||||||
* (for three buttons) of byte 0. Maybe even the bit <3>
|
* (for three buttons) of byte 0. Maybe even the bit <3>
|
||||||
* has some meaning if a tablet is attached.
|
* has some meaning if a tablet is attached.
|
||||||
*/
|
*/
|
||||||
left = (buf[0] & 0x04)? 1: 0;
|
left = buf[0] & 0x04;
|
||||||
middle = (buf[0] & 0x02)? 1: 0;
|
middle = buf[0] & 0x02;
|
||||||
right = (buf[0] & 0x01)? 1: 0;
|
right = buf[0] & 0x01;
|
||||||
|
|
||||||
vsxxxaa_drop_bytes (mouse, 4);
|
vsxxxaa_drop_bytes(mouse, 4);
|
||||||
vsxxxaa_detection_done (mouse);
|
vsxxxaa_detection_done(mouse);
|
||||||
|
|
||||||
if (error <= 0x1f) {
|
if (error <= 0x1f) {
|
||||||
/* No (serious) error. Report buttons */
|
/* No (serious) error. Report buttons */
|
||||||
input_report_key (dev, BTN_LEFT, left);
|
input_report_key(dev, BTN_LEFT, left);
|
||||||
input_report_key (dev, BTN_MIDDLE, middle);
|
input_report_key(dev, BTN_MIDDLE, middle);
|
||||||
input_report_key (dev, BTN_RIGHT, right);
|
input_report_key(dev, BTN_RIGHT, right);
|
||||||
input_report_key (dev, BTN_TOUCH, 0);
|
input_report_key(dev, BTN_TOUCH, 0);
|
||||||
input_sync (dev);
|
input_sync(dev);
|
||||||
|
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
printk (KERN_INFO "Your %s on %s reports error=0x%02x\n",
|
printk(KERN_INFO "Your %s on %s reports error=0x%02x\n",
|
||||||
mouse->name, mouse->phys, error);
|
mouse->name, mouse->phys, error);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,18 +374,18 @@ vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse)
|
||||||
* If the mouse was hot-plugged, we need to force differential mode
|
* If the mouse was hot-plugged, we need to force differential mode
|
||||||
* now... However, give it a second to recover from it's reset.
|
* now... However, give it a second to recover from it's reset.
|
||||||
*/
|
*/
|
||||||
printk (KERN_NOTICE "%s on %s: Forceing standard packet format, "
|
printk(KERN_NOTICE
|
||||||
"incremental streaming mode and 72 samples/sec\n",
|
"%s on %s: Forcing standard packet format, "
|
||||||
mouse->name, mouse->phys);
|
"incremental streaming mode and 72 samples/sec\n",
|
||||||
serio_write (mouse->serio, 'S'); /* Standard format */
|
mouse->name, mouse->phys);
|
||||||
mdelay (50);
|
serio_write(mouse->serio, 'S'); /* Standard format */
|
||||||
serio_write (mouse->serio, 'R'); /* Incremental */
|
mdelay(50);
|
||||||
mdelay (50);
|
serio_write(mouse->serio, 'R'); /* Incremental */
|
||||||
serio_write (mouse->serio, 'L'); /* 72 samples/sec */
|
mdelay(50);
|
||||||
|
serio_write(mouse->serio, 'L'); /* 72 samples/sec */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void vsxxxaa_parse_buffer(struct vsxxxaa *mouse)
|
||||||
vsxxxaa_parse_buffer (struct vsxxxaa *mouse)
|
|
||||||
{
|
{
|
||||||
unsigned char *buf = mouse->buf;
|
unsigned char *buf = mouse->buf;
|
||||||
int stray_bytes;
|
int stray_bytes;
|
||||||
|
@ -409,122 +402,107 @@ vsxxxaa_parse_buffer (struct vsxxxaa *mouse)
|
||||||
* activity on the mouse.
|
* activity on the mouse.
|
||||||
*/
|
*/
|
||||||
while (mouse->count > 0 && !IS_HDR_BYTE(buf[0])) {
|
while (mouse->count > 0 && !IS_HDR_BYTE(buf[0])) {
|
||||||
printk (KERN_ERR "%s on %s: Dropping a byte to regain "
|
printk(KERN_ERR "%s on %s: Dropping a byte to regain "
|
||||||
"sync with mouse data stream...\n",
|
"sync with mouse data stream...\n",
|
||||||
mouse->name, mouse->phys);
|
mouse->name, mouse->phys);
|
||||||
vsxxxaa_drop_bytes (mouse, 1);
|
vsxxxaa_drop_bytes(mouse, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for packets we know about.
|
* Check for packets we know about.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (vsxxxaa_smells_like_packet (mouse, VSXXXAA_PACKET_REL, 3)) {
|
if (vsxxxaa_smells_like_packet(mouse, VSXXXAA_PACKET_REL, 3)) {
|
||||||
/* Check for broken packet */
|
/* Check for broken packet */
|
||||||
stray_bytes = vsxxxaa_check_packet (mouse, 3);
|
stray_bytes = vsxxxaa_check_packet(mouse, 3);
|
||||||
if (stray_bytes > 0) {
|
if (!stray_bytes)
|
||||||
printk (KERN_ERR "Dropping %d bytes now...\n",
|
vsxxxaa_handle_REL_packet(mouse);
|
||||||
stray_bytes);
|
|
||||||
vsxxxaa_drop_bytes (mouse, stray_bytes);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
vsxxxaa_handle_REL_packet (mouse);
|
} else if (vsxxxaa_smells_like_packet(mouse,
|
||||||
continue; /* More to parse? */
|
VSXXXAA_PACKET_ABS, 5)) {
|
||||||
|
/* Check for broken packet */
|
||||||
|
stray_bytes = vsxxxaa_check_packet(mouse, 5);
|
||||||
|
if (!stray_bytes)
|
||||||
|
vsxxxaa_handle_ABS_packet(mouse);
|
||||||
|
|
||||||
|
} else if (vsxxxaa_smells_like_packet(mouse,
|
||||||
|
VSXXXAA_PACKET_POR, 4)) {
|
||||||
|
/* Check for broken packet */
|
||||||
|
stray_bytes = vsxxxaa_check_packet(mouse, 4);
|
||||||
|
if (!stray_bytes)
|
||||||
|
vsxxxaa_handle_POR_packet(mouse);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
break; /* No REL, ABS or POR packet found */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vsxxxaa_smells_like_packet (mouse, VSXXXAA_PACKET_ABS, 5)) {
|
if (stray_bytes > 0) {
|
||||||
/* Check for broken packet */
|
printk(KERN_ERR "Dropping %d bytes now...\n",
|
||||||
stray_bytes = vsxxxaa_check_packet (mouse, 5);
|
stray_bytes);
|
||||||
if (stray_bytes > 0) {
|
vsxxxaa_drop_bytes(mouse, stray_bytes);
|
||||||
printk (KERN_ERR "Dropping %d bytes now...\n",
|
|
||||||
stray_bytes);
|
|
||||||
vsxxxaa_drop_bytes (mouse, stray_bytes);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
vsxxxaa_handle_ABS_packet (mouse);
|
|
||||||
continue; /* More to parse? */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vsxxxaa_smells_like_packet (mouse, VSXXXAA_PACKET_POR, 4)) {
|
|
||||||
/* Check for broken packet */
|
|
||||||
stray_bytes = vsxxxaa_check_packet (mouse, 4);
|
|
||||||
if (stray_bytes > 0) {
|
|
||||||
printk (KERN_ERR "Dropping %d bytes now...\n",
|
|
||||||
stray_bytes);
|
|
||||||
vsxxxaa_drop_bytes (mouse, stray_bytes);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
vsxxxaa_handle_POR_packet (mouse);
|
|
||||||
continue; /* More to parse? */
|
|
||||||
}
|
|
||||||
|
|
||||||
break; /* No REL, ABS or POR packet found */
|
|
||||||
} while (1);
|
} while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static irqreturn_t
|
static irqreturn_t vsxxxaa_interrupt(struct serio *serio,
|
||||||
vsxxxaa_interrupt (struct serio *serio, unsigned char data, unsigned int flags)
|
unsigned char data, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct vsxxxaa *mouse = serio_get_drvdata (serio);
|
struct vsxxxaa *mouse = serio_get_drvdata(serio);
|
||||||
|
|
||||||
vsxxxaa_queue_byte (mouse, data);
|
vsxxxaa_queue_byte(mouse, data);
|
||||||
vsxxxaa_parse_buffer (mouse);
|
vsxxxaa_parse_buffer(mouse);
|
||||||
|
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void vsxxxaa_disconnect(struct serio *serio)
|
||||||
vsxxxaa_disconnect (struct serio *serio)
|
|
||||||
{
|
{
|
||||||
struct vsxxxaa *mouse = serio_get_drvdata (serio);
|
struct vsxxxaa *mouse = serio_get_drvdata(serio);
|
||||||
|
|
||||||
serio_close (serio);
|
serio_close(serio);
|
||||||
serio_set_drvdata (serio, NULL);
|
serio_set_drvdata(serio, NULL);
|
||||||
input_unregister_device (mouse->dev);
|
input_unregister_device(mouse->dev);
|
||||||
kfree (mouse);
|
kfree(mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int vsxxxaa_connect(struct serio *serio, struct serio_driver *drv)
|
||||||
vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
|
|
||||||
{
|
{
|
||||||
struct vsxxxaa *mouse;
|
struct vsxxxaa *mouse;
|
||||||
struct input_dev *input_dev;
|
struct input_dev *input_dev;
|
||||||
int err = -ENOMEM;
|
int err = -ENOMEM;
|
||||||
|
|
||||||
mouse = kzalloc (sizeof (struct vsxxxaa), GFP_KERNEL);
|
mouse = kzalloc(sizeof(struct vsxxxaa), GFP_KERNEL);
|
||||||
input_dev = input_allocate_device ();
|
input_dev = input_allocate_device();
|
||||||
if (!mouse || !input_dev)
|
if (!mouse || !input_dev)
|
||||||
goto fail1;
|
goto fail1;
|
||||||
|
|
||||||
mouse->dev = input_dev;
|
mouse->dev = input_dev;
|
||||||
mouse->serio = serio;
|
mouse->serio = serio;
|
||||||
strlcat (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer",
|
strlcat(mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer",
|
||||||
sizeof (mouse->name));
|
sizeof(mouse->name));
|
||||||
snprintf (mouse->phys, sizeof (mouse->phys), "%s/input0", serio->phys);
|
snprintf(mouse->phys, sizeof(mouse->phys), "%s/input0", serio->phys);
|
||||||
|
|
||||||
input_dev->name = mouse->name;
|
input_dev->name = mouse->name;
|
||||||
input_dev->phys = mouse->phys;
|
input_dev->phys = mouse->phys;
|
||||||
input_dev->id.bustype = BUS_RS232;
|
input_dev->id.bustype = BUS_RS232;
|
||||||
input_dev->dev.parent = &serio->dev;
|
input_dev->dev.parent = &serio->dev;
|
||||||
|
|
||||||
set_bit (EV_KEY, input_dev->evbit); /* We have buttons */
|
__set_bit(EV_KEY, input_dev->evbit); /* We have buttons */
|
||||||
set_bit (EV_REL, input_dev->evbit);
|
__set_bit(EV_REL, input_dev->evbit);
|
||||||
set_bit (EV_ABS, input_dev->evbit);
|
__set_bit(EV_ABS, input_dev->evbit);
|
||||||
set_bit (BTN_LEFT, input_dev->keybit); /* We have 3 buttons */
|
__set_bit(BTN_LEFT, input_dev->keybit); /* We have 3 buttons */
|
||||||
set_bit (BTN_MIDDLE, input_dev->keybit);
|
__set_bit(BTN_MIDDLE, input_dev->keybit);
|
||||||
set_bit (BTN_RIGHT, input_dev->keybit);
|
__set_bit(BTN_RIGHT, input_dev->keybit);
|
||||||
set_bit (BTN_TOUCH, input_dev->keybit); /* ...and Tablet */
|
__set_bit(BTN_TOUCH, input_dev->keybit); /* ...and Tablet */
|
||||||
set_bit (REL_X, input_dev->relbit);
|
__set_bit(REL_X, input_dev->relbit);
|
||||||
set_bit (REL_Y, input_dev->relbit);
|
__set_bit(REL_Y, input_dev->relbit);
|
||||||
input_set_abs_params (input_dev, ABS_X, 0, 1023, 0, 0);
|
input_set_abs_params(input_dev, ABS_X, 0, 1023, 0, 0);
|
||||||
input_set_abs_params (input_dev, ABS_Y, 0, 1023, 0, 0);
|
input_set_abs_params(input_dev, ABS_Y, 0, 1023, 0, 0);
|
||||||
|
|
||||||
serio_set_drvdata (serio, mouse);
|
serio_set_drvdata(serio, mouse);
|
||||||
|
|
||||||
err = serio_open (serio, drv);
|
err = serio_open(serio, drv);
|
||||||
if (err)
|
if (err)
|
||||||
goto fail2;
|
goto fail2;
|
||||||
|
|
||||||
|
@ -532,18 +510,18 @@ vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
|
||||||
* Request selftest. Standard packet format and differential
|
* Request selftest. Standard packet format and differential
|
||||||
* mode will be requested after the device ID'ed successfully.
|
* mode will be requested after the device ID'ed successfully.
|
||||||
*/
|
*/
|
||||||
serio_write (serio, 'T'); /* Test */
|
serio_write(serio, 'T'); /* Test */
|
||||||
|
|
||||||
err = input_register_device (input_dev);
|
err = input_register_device(input_dev);
|
||||||
if (err)
|
if (err)
|
||||||
goto fail3;
|
goto fail3;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail3: serio_close (serio);
|
fail3: serio_close(serio);
|
||||||
fail2: serio_set_drvdata (serio, NULL);
|
fail2: serio_set_drvdata(serio, NULL);
|
||||||
fail1: input_free_device (input_dev);
|
fail1: input_free_device(input_dev);
|
||||||
kfree (mouse);
|
kfree(mouse);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,18 +548,16 @@ static struct serio_driver vsxxxaa_drv = {
|
||||||
.disconnect = vsxxxaa_disconnect,
|
.disconnect = vsxxxaa_disconnect,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init
|
static int __init vsxxxaa_init(void)
|
||||||
vsxxxaa_init (void)
|
|
||||||
{
|
{
|
||||||
return serio_register_driver(&vsxxxaa_drv);
|
return serio_register_driver(&vsxxxaa_drv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit
|
static void __exit vsxxxaa_exit(void)
|
||||||
vsxxxaa_exit (void)
|
|
||||||
{
|
{
|
||||||
serio_unregister_driver(&vsxxxaa_drv);
|
serio_unregister_driver(&vsxxxaa_drv);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init (vsxxxaa_init);
|
module_init(vsxxxaa_init);
|
||||||
module_exit (vsxxxaa_exit);
|
module_exit(vsxxxaa_exit);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue