lkml.org 
[lkml]   [1998]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectMouse cleanup
Hi!

Currently, there's quite a lot of mess in mouse drivers - there were
done by block copy. It needs to be cleaned out - and this patch tries
to do it. It compiles, unfortunately, I can not do any more
testing. So I need you, brave owner of one of those devices, to do
testing for me. Changes were pretty trivial, so it could work on the
first try and it will probably work after minor modifications.

Please, please, test it out, and let me know.

Pavel


--- clean/drivers/char/amigamouse.c Fri Mar 27 14:23:51 1998
+++ linux/drivers/char/amigamouse.c Tue Jul 7 15:34:17 1998
@@ -30,6 +30,8 @@
* Moved the isr-allocation to the mouse_{open,close} calls, as there
* is no reason to service the mouse in the vertical blank isr if
* the mouse is not in use. Jes Sorensen
+ *
+ * Merged into <linux/mouse.h>, 1998 Pavel Machek <pavel@ucw.cz>
*/

#include <linux/module.h>
@@ -44,7 +46,6 @@
#include <linux/random.h>
#include <linux/poll.h>
#include <linux/init.h>
-#include <linux/busmouse.h>

#include <asm/setup.h>
#include <asm/system.h>
@@ -53,11 +54,10 @@
#include <asm/amigahw.h>
#include <asm/amigaints.h>

-#define AMI_MSE_INT_ON() mouseint_allowed = 1
-#define AMI_MSE_INT_OFF() mouseint_allowed = 0
+#include <linux/mouse.h>

-
-static struct mouse_status mouse;
+static void enable_mouse_int(void) { mouseint_allowed = 1; }
+static void disable_mouse_int(void) { mouseint_allowed = 0; }

static int mouseint_allowed;

@@ -72,7 +72,7 @@

if(!mouseint_allowed)
return;
- AMI_MSE_INT_OFF();
+ disable_mouse_int();

/*
* This routine assumes, just like Kickstart, that the mouse
@@ -127,45 +127,8 @@
#endif
(potgor & 0x0400 ? 1 : 0); /* right button */

-
- if (dx != 0 || dy != 0 || buttons != mouse.buttons) {
- add_mouse_randomness((buttons << 16) + (dy << 8) + dx);
- mouse.buttons = buttons;
- mouse.dx += dx;
- mouse.dy -= dy;
- mouse.ready = 1;
- wake_up_interruptible(&mouse.wait);
-
- /*
- * keep dx/dy reasonable, but still able to track when X (or
- * whatever) must page or is busy (i.e. long waits between
- * reads)
- */
- if (mouse.dx < -2048)
- mouse.dx = -2048;
- else
- if (mouse.dx > 2048)
- mouse.dx = 2048;
-
- if (mouse.dy < -2048)
- mouse.dy = -2048;
- else
- if (mouse.dy > 2048)
- mouse.dy = 2048;
-
- if (mouse.fasyncptr)
- kill_fasync(mouse.fasyncptr, SIGIO);
- }
- AMI_MSE_INT_ON();
-}
-
-static int fasync_mouse(struct file *filp, int on)
-{
- int retval;
- retval = fasync_helper(filp, on, &mouse.fasyncptr);
- if (retval < 0)
- return retval;
- return 0;
+ generic_mouse_moves(dx,dy,buttons);
+ enable_mouse_int();
}

/*
@@ -174,11 +137,11 @@

static int release_mouse(struct inode * inode, struct file * file)
{
- fasync_mouse(file, 0);
+ generic_fasync_mouse(file, 0);
if (--mouse.active)
return 0;
free_irq(IRQ_AMIGA_VERTB, mouse_interrupt);
- AMI_MSE_INT_OFF();
+ disable_mouse_int();
MOD_DEC_USE_COUNT;
return 0;
}
@@ -211,97 +174,22 @@
mouse.buttons = 0x87;
mouse.active = 1;
MOD_INC_USE_COUNT;
- AMI_MSE_INT_ON();
- return 0;
-}
-
-/*
- * writes are disallowed
- */
-
-static ssize_t write_mouse(struct file * file, const char * buffer,
- size_t count, loff_t *ppos)
-{
- return -EINVAL;
-}
-
-/*
- * read mouse data. Currently never blocks.
- */
-
-static ssize_t read_mouse(struct file * file, char * buffer,
- size_t count, loff_t *ppos)
-{
- int dx;
- int dy;
- unsigned char buttons;
-
- if (count < 3)
- return -EINVAL;
- if (!mouse.ready)
- return -EAGAIN;
-
- /*
- * Obtain the current mouse parameters and limit as appropriate for
- * the return data format. Interrupts are only disabled while
- * obtaining the parameters, NOT during the puts_user() calls,
- * so paging in put_user() does not effect mouse tracking.
- */
-
- AMI_MSE_INT_OFF();
- dx = mouse.dx;
- dy = mouse.dy;
- if (dx < -127)
- dx = -127;
- else
- if (dx > 127)
- dx = 127;
- if (dy < -127)
- dy = -127;
- else
- if (dy > 127)
- dy = 127;
- buttons = mouse.buttons;
- mouse.dx -= dx;
- mouse.dy -= dy;
- mouse.ready = 0;
- AMI_MSE_INT_ON();
-
- if (put_user(buttons | 0x80, buffer++) ||
- put_user((char)dx, buffer++) ||
- put_user((char)dy, buffer++))
- return -EINVAL;
-
- if (count > 3)
- if (clear_user(buffer, count - 3))
- return -EFAULT;
- return count;
-}
-
-/*
- * poll for mouse input
- */
-
-static unsigned int mouse_poll(struct file *file, poll_table * wait)
-{
- poll_wait(file, &mouse.wait, wait);
- if (mouse.ready)
- return POLLIN | POLLRDNORM;
+ enable_mouse_int();
return 0;
}

struct file_operations amiga_mouse_fops = {
NULL, /* mouse_seek */
- read_mouse,
- write_mouse,
+ generic_read_mouse,
+ generic_write_mouse,
NULL, /* mouse_readdir */
- mouse_poll, /* mouse_poll */
+ generic_poll_mouse, /* mouse_poll */
NULL, /* mouse_ioctl */
NULL, /* mouse_mmap */
open_mouse,
release_mouse,
NULL,
- fasync_mouse,
+ generic_fasync_mouse,
};

static struct miscdevice amiga_mouse = {
@@ -315,7 +203,7 @@

custom.joytest = 0; /* reset counters */

- AMI_MSE_INT_OFF();
+ disable_mouse_int();

mouse.active = 0;
mouse.ready = 0;
--- clean/drivers/char/busmouse.c Sun Mar 8 12:49:55 1998
+++ linux/drivers/char/busmouse.c Tue Jul 7 13:49:19 1998
@@ -31,13 +31,14 @@
* Nathan Laredo <laredo@gnu.ai.mit.edu>
*
* Track I/O ports with request_region(). 12 Dec 95 Philip Blundell
+ *
+ * Modified to use new <linux/mouse.h> 7 Jul 98 Pavel Machek <pavel@ucw.cz>
*/

#include <linux/module.h>

#include <linux/kernel.h>
#include <linux/sched.h>
-#include <linux/busmouse.h>
#include <linux/signal.h>
#include <linux/errno.h>
#include <linux/mm.h>
@@ -53,9 +54,17 @@
#include <asm/system.h>
#include <asm/irq.h>

+#include <linux/busmouse.h>
+
static struct mouse_status mouse;
static int mouse_irq = MOUSE_IRQ;

+static void enable_mouse_hwint(void) { outb(MSE_ENABLE_INTERRUPTS, MSE_CONTROL_PORT); }
+static void disable_mouse_hwint(void) { outb(MSE_DISABLE_INTERRUPTS, MSE_CONTROL_PORT); }
+
+static void enable_mouse_int(void) { enable_irq(mouse_irq); }
+static void disable_mouse_int(void) { disable_irq(mouse_irq); }
+
__initfunc(void bmouse_setup(char *str, int *ints))
{
if (ints[0] > 0)
@@ -77,43 +86,9 @@
buttons = inb(MSE_DATA_PORT);
dy |= (buttons & 0xf) << 4;
buttons = ((buttons >> 5) & 0x07);
- if (dx != 0 || dy != 0 || buttons != mouse.buttons) {
- add_mouse_randomness((buttons << 16) + (dy << 8) + dx);
- mouse.buttons = buttons;
- mouse.dx += dx;
- mouse.dy -= dy;
- mouse.ready = 1;
- wake_up_interruptible(&mouse.wait);
-
- /*
- * keep dx/dy reasonable, but still able to track when X (or
- * whatever) must page or is busy (i.e. long waits between
- * reads)
- */
- if (mouse.dx < -2048)
- mouse.dx = -2048;
- if (mouse.dx > 2048)
- mouse.dx = 2048;
-
- if (mouse.dy < -2048)
- mouse.dy = -2048;
- if (mouse.dy > 2048)
- mouse.dy = 2048;

- if (mouse.fasyncptr)
- kill_fasync(mouse.fasyncptr, SIGIO);
- }
- MSE_INT_ON();
-}
-
-static int fasync_mouse(struct file *filp, int on)
-{
- int retval;
-
- retval = fasync_helper(filp, on, &mouse.fasyncptr);
- if (retval < 0)
- return retval;
- return 0;
+ generic_mouse_moves(dx,dy,buttons);
+ enable_mouse_hwint();
}

/*
@@ -122,10 +97,10 @@

static int close_mouse(struct inode * inode, struct file * file)
{
- fasync_mouse(file, 0);
+ generic_fasync_mouse(file, 0);
if (--mouse.active)
return 0;
- MSE_INT_OFF();
+ disable_mouse_hwint();
free_irq(mouse_irq, NULL);
MOD_DEC_USE_COUNT;
return 0;
@@ -150,97 +125,22 @@
mouse.dy = 0;
mouse.buttons = 0x87;
MOD_INC_USE_COUNT;
- MSE_INT_ON();
- return 0;
-}
-
-/*
- * writes are disallowed
- */
-
-static ssize_t write_mouse(struct file * file,
- const char * buffer, size_t count, loff_t *ppos)
-{
- return -EINVAL;
-}
-
-/*
- * read mouse data. Currently never blocks.
- */
-
-static ssize_t read_mouse(struct file * file,
- char * buffer, size_t count, loff_t *ppos)
-{
- int r;
- int dx;
- int dy;
- unsigned char buttons;
- /* long flags; */
-
- if (count < 3)
- return -EINVAL;
- if ((r = verify_area(VERIFY_WRITE, buffer, count)))
- return r;
- if (!mouse.ready)
- return -EAGAIN;
-
- /*
- * Obtain the current mouse parameters and limit as appropriate for
- * the return data format. Interrupts are only disabled while
- * obtaining the parameters, NOT during the puts_fs_byte() calls,
- * so paging in put_user() does not effect mouse tracking.
- */
-
- /* save_flags(flags); cli(); */
- disable_irq(mouse_irq);
- dx = mouse.dx;
- dy = mouse.dy;
- if (dx < -127)
- dx = -127;
- if (dx > 127)
- dx = 127;
- if (dy < -127)
- dy = -127;
- if (dy > 127)
- dy = 127;
- buttons = mouse.buttons;
- mouse.dx -= dx;
- mouse.dy -= dy;
- mouse.ready = 0;
- enable_irq(mouse_irq);
- /* restore_flags(flags); */
-
- put_user(buttons | 0x80, buffer);
- put_user((char)dx, buffer + 1);
- put_user((char)dy, buffer + 2);
- for (r = 3; r < count; r++)
- put_user(0x00, buffer + r);
- return r;
-}
-
-/*
- * poll for mouse input
- */
-static unsigned int mouse_poll(struct file *file, poll_table * wait)
-{
- poll_wait(file, &mouse.wait, wait);
- if (mouse.ready)
- return POLLIN | POLLRDNORM;
+ enable_mouse_hwint();
return 0;
}

struct file_operations bus_mouse_fops = {
NULL, /* mouse_seek */
- read_mouse,
- write_mouse,
+ generic_read_mouse,
+ generic_write_mouse,
NULL, /* mouse_readdir */
- mouse_poll, /* mouse_poll */
+ generic_poll_mouse, /* mouse_poll */
NULL, /* mouse_ioctl */
NULL, /* mouse_mmap */
open_mouse,
close_mouse,
NULL,
- fasync_mouse,
+ generic_fasync_mouse,
};

static struct miscdevice bus_mouse = {
@@ -262,7 +162,7 @@
return -EIO;
}
outb(MSE_DEFAULT_MODE, MSE_CONFIG_PORT);
- MSE_INT_OFF();
+ disable_mouse_hwint();

request_region(LOGIBM_BASE, LOGIBM_EXTENT, "busmouse");

--- clean/drivers/char/msbusmouse.c Sun Mar 8 12:49:56 1998
+++ linux/drivers/char/msbusmouse.c Tue Jul 7 13:46:57 1998
@@ -35,7 +35,6 @@
#include <linux/kernel.h>
#include <linux/ioport.h>
#include <linux/sched.h>
-#include <linux/busmouse.h>
#include <linux/signal.h>
#include <linux/errno.h>
#include <linux/miscdevice.h>
@@ -48,9 +47,13 @@
#include <asm/system.h>
#include <asm/irq.h>

-static struct mouse_status mouse;
+#include <linux/busmouse.h>
+
static int mouse_irq = MOUSE_IRQ;

+static void disable_mouse_int(void) { }
+static void enable_mouse_int(void) { }
+
__initfunc(void msmouse_setup(char *str, int *ints))
{
if (ints[0] > 0)
@@ -77,31 +80,12 @@
outb(MS_MSE_COMMAND_MODE, MS_MSE_CONTROL_PORT);
outb((inb(MS_MSE_DATA_PORT) & 0xdf), MS_MSE_DATA_PORT);

- if (dx != 0 || dy != 0 || buttons != mouse.buttons || ((~buttons) & 0x07)) {
- add_mouse_randomness((buttons << 16) + (dy << 8) + dx);
- mouse.buttons = buttons;
- mouse.dx += dx;
- mouse.dy += dy;
- mouse.ready = 1;
- wake_up_interruptible(&mouse.wait);
- if (mouse.fasyncptr)
- kill_fasync(mouse.fasyncptr, SIGIO);
- }
-}
-
-static int fasync_mouse(struct file *filp, int on)
-{
- int retval;
-
- retval = fasync_helper(filp, on, &mouse.fasyncptr);
- if (retval < 0)
- return retval;
- return 0;
+ generic_mouse_moves(dx,dy,buttons);
}

static int release_mouse(struct inode * inode, struct file * file)
{
- fasync_mouse(file, 0);
+ generic_fasync_mouse(file, 0);
if (--mouse.active)
return 0;
MS_MSE_INT_OFF();
@@ -129,54 +113,18 @@
return 0;
}

-static ssize_t write_mouse(struct file * file,
- const char * buffer, size_t count, loff_t *ppos)
-{
- return -EINVAL;
-}
-
-static ssize_t read_mouse(struct file * file,
- char * buffer, size_t count, loff_t *ppos)
-{
- int i, dx, dy;
-
- if (count < 3)
- return -EINVAL;
- if (!mouse.ready)
- return -EAGAIN;
- put_user(mouse.buttons | 0x80, buffer);
- dx = mouse.dx < -127 ? -127 : mouse.dx > 127 ? 127 : mouse.dx;
- dy = mouse.dy < -127 ? 127 : mouse.dy > 127 ? -127 : -mouse.dy;
- put_user((char)dx, buffer + 1);
- put_user((char)dy, buffer + 2);
- for (i = 3; i < count; i++)
- put_user(0x00, buffer + i);
- mouse.dx -= dx;
- mouse.dy += dy;
- mouse.ready = 0;
- return i;
-}
-
-static unsigned int mouse_poll(struct file *file, poll_table * wait)
-{
- poll_wait(file, &mouse.wait, wait);
- if (mouse.ready)
- return POLLIN | POLLRDNORM;
- return 0;
-}
-
struct file_operations ms_bus_mouse_fops = {
NULL, /* mouse_seek */
- read_mouse,
- write_mouse,
+ generic_read_mouse,
+ generic_write_mouse,
NULL, /* mouse_readdir */
- mouse_poll, /* mouse_poll */
+ generic_poll_mouse, /* mouse_poll */
NULL, /* mouse_ioctl */
NULL, /* mouse_mmap */
open_mouse,
release_mouse,
NULL,
- fasync_mouse,
+ generic_fasync_mouse,
};

static struct miscdevice ms_bus_mouse = {
--- clean/drivers/char/atixlmouse.c Sun Mar 8 12:49:55 1998
+++ linux/drivers/char/atixlmouse.c Tue Jul 7 14:10:43 1998
@@ -26,6 +26,8 @@
#include <asm/system.h>
#include <asm/irq.h>

+#include <linux/mouse.h>
+
#define ATIXL_MOUSE_IRQ 5 /* H/W interrupt # set up on ATIXL board */
#define ATIXL_BUSMOUSE 3 /* Minor device # (mknod c 10 3 /dev/bm) */

@@ -42,12 +44,12 @@
/* Some nice ATI XL macros */

/* Select IR7, HOLD UPDATES (INT ENABLED), save X,Y */
-#define ATIXL_MSE_DISABLE_UPDATE() { outb( 0x07, ATIXL_MSE_CONTROL_PORT ); \
- outb( (0x20 | inb( ATIXL_MSE_DATA_PORT )), ATIXL_MSE_DATA_PORT ); }
+void disable_mouse_int(void) { outb( 0x07, ATIXL_MSE_CONTROL_PORT );
+ outb( (0x20 | inb( ATIXL_MSE_DATA_PORT )), ATIXL_MSE_DATA_PORT ); }

/* Select IR7, Enable updates (INT ENABLED) */
-#define ATIXL_MSE_ENABLE_UPDATE() { outb( 0x07, ATIXL_MSE_CONTROL_PORT ); \
- outb( (0xdf & inb( ATIXL_MSE_DATA_PORT )), ATIXL_MSE_DATA_PORT ); }
+void enable_mouse_int(void) { outb( 0x07, ATIXL_MSE_CONTROL_PORT );
+ outb( (0xdf & inb( ATIXL_MSE_DATA_PORT )), ATIXL_MSE_DATA_PORT ); }

/* Select IR7 - Mode Register, NO INTERRUPTS */
#define ATIXL_MSE_INT_OFF() { outb( 0x07, ATIXL_MSE_CONTROL_PORT ); \
@@ -57,56 +59,25 @@
#define ATIXL_MSE_INT_ON() { outb( 0x07, ATIXL_MSE_CONTROL_PORT ); \
outb( (0x08 | inb( ATIXL_MSE_DATA_PORT )), ATIXL_MSE_DATA_PORT ); }

-/* Same general mouse structure */
-
-static struct mouse_status {
- char buttons;
- char latch_buttons;
- int dx;
- int dy;
- int present;
- int ready;
- int active;
- struct wait_queue *wait;
- struct fasync_struct *fasync;
-} mouse;
-
void mouse_interrupt(int irq, void *dev_id, struct pt_regs * regs)
{
char dx, dy, buttons;

- ATIXL_MSE_DISABLE_UPDATE(); /* Note that interrupts are still enabled */
+ disable_mouse_int(); /* Note that interrupts are still enabled */
outb(ATIXL_MSE_READ_X, ATIXL_MSE_CONTROL_PORT); /* Select IR1 - X movement */
dx = inb( ATIXL_MSE_DATA_PORT);
outb(ATIXL_MSE_READ_Y, ATIXL_MSE_CONTROL_PORT); /* Select IR2 - Y movement */
dy = inb( ATIXL_MSE_DATA_PORT);
outb(ATIXL_MSE_READ_BUTTONS, ATIXL_MSE_CONTROL_PORT); /* Select IR0 - Button Status */
buttons = inb( ATIXL_MSE_DATA_PORT);
- if (dx != 0 || dy != 0 || buttons != mouse.latch_buttons) {
- add_mouse_randomness((buttons << 16) + (dy << 8) + dx);
- mouse.latch_buttons |= buttons;
- mouse.dx += dx;
- mouse.dy += dy;
- mouse.ready = 1;
- wake_up_interruptible(&mouse.wait);
- if (mouse.fasync)
- kill_fasync(mouse.fasync, SIGIO);
- }
- ATIXL_MSE_ENABLE_UPDATE();
-}

-static int fasync_mouse(struct file *filp, int on)
-{
- int retval;
- retval = fasync_helper(filp, on, &mouse.fasync);
- if (retval < 0)
- return retval;
- return 0;
+ generic_mouse_moves(dx,-dy,(~buttons)&7);
+ enable_mouse_int();
}

static int release_mouse(struct inode * inode, struct file * file)
{
- fasync_mouse(file, 0);
+ generic_fasync_mouse(file, 0);
if (--mouse.active)
return 0;
ATIXL_MSE_INT_OFF(); /* Interrupts are really shut down here */
@@ -129,71 +100,24 @@
mouse.ready = 0;
mouse.dx = 0;
mouse.dy = 0;
- mouse.buttons = mouse.latch_buttons = 0;
+ mouse.buttons = mouse.buttons = 0;
ATIXL_MSE_INT_ON(); /* Interrupts are really enabled here */
MOD_INC_USE_COUNT;
return 0;
}

-
-static ssize_t write_mouse(struct file * file, const char * buffer,
- size_t count, loff_t *ppos)
-{
- return -EINVAL;
-}
-
-static ssize_t read_mouse(struct file * file, char * buffer,
- size_t count, loff_t *ppos)
-{
- ssize_t i;
-
- if (count < 3)
- return -EINVAL;
- if (!mouse.ready)
- return -EAGAIN;
- ATIXL_MSE_DISABLE_UPDATE();
- /* Allowed interrupts to occur during data gathering - shouldn't hurt */
- put_user((char)(~mouse.latch_buttons&7) | 0x80 , buffer);
- if (mouse.dx < -127)
- mouse.dx = -127;
- if (mouse.dx > 127)
- mouse.dx = 127;
- put_user((char)mouse.dx, buffer + 1);
- if (mouse.dy < -127)
- mouse.dy = -127;
- if (mouse.dy > 127)
- mouse.dy = 127;
- put_user((char)-mouse.dy, buffer + 2);
- for(i = 3; i < count; i++)
- put_user(0x00, buffer + i);
- mouse.dx = 0;
- mouse.dy = 0;
- mouse.latch_buttons = mouse.buttons;
- mouse.ready = 0;
- ATIXL_MSE_ENABLE_UPDATE();
- return i; /* i data bytes returned */
-}
-
-static unsigned int mouse_poll(struct file *file, poll_table * wait)
-{
- poll_wait(file, &mouse.wait, wait);
- if (mouse.ready)
- return POLLIN | POLLRDNORM;
- return 0;
-}
-
struct file_operations atixl_busmouse_fops = {
NULL, /* mouse_seek */
- read_mouse,
- write_mouse,
+ generic_read_mouse,
+ generic_write_mouse,
NULL, /* mouse_readdir */
- mouse_poll, /* mouse_poll */
+ generic_poll_mouse, /* mouse_poll */
NULL, /* mouse_ioctl */
NULL, /* mouse_mmap */
open_mouse,
release_mouse,
NULL,
- fasync_mouse,
+ generic_fasync_mouse,
};

static struct miscdevice atixl_mouse = {
@@ -220,7 +144,7 @@
mouse.present = 1;
mouse.active = 0;
mouse.ready = 0;
- mouse.buttons = mouse.latch_buttons = 0;
+ mouse.buttons = 0;
mouse.dx = mouse.dy = 0;
mouse.wait = NULL;
printk("Bus mouse detected and installed.\n");
--- clean/include/linux/busmouse.h Thu Dec 14 07:16:53 1995
+++ linux/include/linux/busmouse.h Tue Jul 7 13:35:17 1998
@@ -5,6 +5,8 @@
* linux/include/linux/busmouse.h: header file for Logitech Bus Mouse driver
* by James Banks
*
+ * Should be included last.
+ *
* based on information gleamed from various mouse drivers on the net
*
* Heavily modified by David giller (rafetmad@oxy.edu)
@@ -27,6 +29,8 @@
*
*/

+#include <linux/mouse.h>
+
#define MOUSE_IRQ 5
#define LOGITECH_BUSMOUSE 0 /* Minor device # for Logitech */
#define MICROSOFT_BUSMOUSE 2 /* Minor device # for Microsoft */
@@ -56,9 +60,6 @@

/* useful Logitech Mouse macros */

-#define MSE_INT_OFF() outb(MSE_DISABLE_INTERRUPTS, MSE_CONTROL_PORT)
-#define MSE_INT_ON() outb(MSE_ENABLE_INTERRUPTS, MSE_CONTROL_PORT)
-
/*--------- MICROSOFT BUSMOUSE ITEMS -------------*/

#define MSBM_BASE 0x23d
@@ -86,19 +87,6 @@
outb(MS_MSE_ENABLE_INTERRUPTS, MS_MSE_DATA_PORT);}


-struct mouse_status {
- unsigned char buttons;
- unsigned char latch_buttons;
- int dx;
- int dy;
- int present;
- int ready;
- int active;
- struct wait_queue *wait;
- struct fasync_struct *fasyncptr;
-};
-
-/* Function Prototypes */

#endif

--- /dev/null Wed May 21 13:24:05 1997
+++ linux/include/linux/mouse.h Tue Jul 7 14:06:43 1998
@@ -0,0 +1,118 @@
+#ifndef _LINUX_MOUSE_H
+#define _LINUX_MOUSE_H
+
+/*
+ * header file for mouse devices under linux
+ *
+ * Should be included last.
+ */
+
+struct mouse_status {
+ unsigned char buttons;
+ int dx;
+ int dy;
+ int present;
+ int ready;
+ int active;
+ struct wait_queue *wait;
+ struct fasync_struct *fasyncptr;
+};
+
+static struct mouse_status mouse;
+
+/* Function Prototypes */
+
+static void disable_mouse_int(void);
+static void enable_mouse_int(void);
+
+static ssize_t
+generic_write_mouse(struct file * file, const char * buffer, size_t count, loff_t *ppos)
+{
+ return -EINVAL;
+}
+
+static ssize_t
+generic_read_mouse(struct file * file, char * buffer, size_t count, loff_t *ppos)
+{
+ int dx,dy;
+ unsigned char buttons;
+
+ if (count < 3)
+ return -EINVAL;
+ if (!mouse.ready)
+ return -EAGAIN;
+
+ /*
+ * Obtain the current mouse parameters and limit as appropriate for
+ * the return data format. Interrupts are only disabled while
+ * obtaining the parameters, NOT during the puts_user() calls,
+ * so paging in put_user() does not effect mouse tracking.
+ */
+
+ disable_mouse_int();
+ dx = mouse.dx < -127 ? -127 : mouse.dx > 127 ? 127 : mouse.dx;
+ dy = mouse.dy < -127 ? -127 : mouse.dy > 127 ? 127 : mouse.dy;
+ buttons = mouse.buttons;
+ mouse.dx -= dx;
+ mouse.dy -= dy;
+ mouse.ready = 0;
+ enable_mouse_int();
+
+ if (put_user(buttons | 0x80, buffer++) ||
+ put_user((char)dx, buffer++) ||
+ put_user((char)dy, buffer++))
+ return -EINVAL;
+
+ if (count > 3)
+ if (clear_user(buffer, count - 3))
+ return -EFAULT;
+ return count;
+}
+
+static int
+generic_fasync_mouse(struct file *filp, int on)
+{
+ int retval;
+ retval = fasync_helper(filp, on, &mouse.fasyncptr);
+ if (retval < 0)
+ return retval;
+ return 0;
+}
+
+static unsigned int
+generic_poll_mouse(struct file *file, poll_table * wait)
+{
+ poll_wait(file, &mouse.wait, wait);
+ if (mouse.ready)
+ return POLLIN | POLLRDNORM;
+ return 0;
+}
+
+static void
+generic_mouse_moves(int dx, int dy, int buttons)
+{
+ if (dx != 0 || dy != 0 || buttons != mouse.buttons || ((~buttons) & 0x07)) {
+ add_mouse_randomness((buttons << 16) + (dy << 8) + dx);
+ mouse.buttons = buttons;
+ mouse.dx += dx;
+ mouse.dy -= dy;
+ mouse.ready = 1;
+
+ /*
+ * keep dx/dy reasonable, but still able to track when X (or
+ * whatever) must page or is busy (i.e. long waits between
+ * reads)
+ */
+ if (mouse.dx < -2048) mouse.dx = -2048;
+ if (mouse.dx > 2048) mouse.dx = 2048;
+ if (mouse.dy < -2048) mouse.dy = -2048;
+ if (mouse.dy > 2048) mouse.dy = 2048;
+
+ wake_up_interruptible(&mouse.wait);
+ if (mouse.fasyncptr)
+ kill_fasync(mouse.fasyncptr, SIGIO);
+ }
+}
+
+
+#endif
--
I'm really pavel@atrey.karlin.mff.cuni.cz. Pavel
Look at http://atrey.karlin.mff.cuni.cz/~pavel/ ;-).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:43    [W:0.109 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site