Skip to contentSkip to conversation

"Disable Trackpad while typing" on Notebooks withh a PS/2 Trackpad

RFC PATCH In review Hans-Georg Thien 7 participants 14 messages May 1, 2003 – Oct 2, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 "Disable Trackpad while typing" on Notebooks withh a PS/2 Trackpad

Sorry for this long text and my bad english. And please be kind to me - it is my very first posting to this mailing list ...

I have written a *very small* patch against the linux 2.4.20 kernel and I want to submit it now.

The short story
---------------
The trackpad on the MacIntosh iBook Notebooks have a feature that prevents unintended trackpad input while typing on the keyboard. There are no mouse-moves or mouse-taps for a short period of time after each keystroke.

I believe that many people with i386 notebooks would like this feature and I want to give it to the linux community.

First I had the idea of writing a loadable kernel module "trackpad" that implements that feature and is loadable via

insmod keybd_irq=? mouse_irq=? delay=?

The long story
--------------
My first approach was - because I came from the bad old M$-DOS times - write something like a "terminate and stay resident program"

Procedure LoadModule
Save the currentlly installed handlers for keyboard and mouse. Install your own interrupt handlers for keyboard and mouse.
End

Procedure UnloadModule
Stop and remove "reset-timer" if necessary Restore the saved interrupt handlers for keyboard and mouse
End

Procedure KbdHandler
Stop or modify "reset-timer" if necessary
Set global variable block_mouse_events=1
Start a timer that resets block_mouse_events=0 after ??? mSec Call the old keyboard interrupt handler
End

Proceure MouseHandler
if block_mouse_events>0 then
call ACK(mouse irq) if necessary
do nothing
else
call old mouse interrupt handler
End

So I bought the book "Linux Device Drivers" written by Alessandro Rubini & Jonathan Corbert. It is an excellent book about LKM, but I couldn't find a way to "save and restore" irq-handlers as in the design described above.

That's why I requested a little help in the newsgroup at comp.os.linux.development.system. This ended up with some people who said "don't mess around with irq-handlers in that way".

While trying to gain a deeper understanding of irq-handling - espically for mouse and keyboard handlers - I found out that the keyboard and mouse interrupts are handled *both* in /usr/src/linux/drivers/char/pc_keyb.c.

Ok, that is only true for PS/2 mice, but the majority of notebooks on the market have a PS/2 trackpad. On modifiying the pc_keyb.c file there is no longer a need to save/restore Interrupt handlers or to call them indirecty via a function pointer. Unfortunatly it has to be compiled in the kernel and cannot be written as a LKM module.

But anyway - I sad down and got a working solution very quickly! I'm very glad with it! I needed not more than 45 minutes to get this working! Works in textmode (gpm) and under X11 as expected!

Testing
-------
I have tested my patch only on my own notebook (Compaq M300). It would help a lot if there are some volunteers...

Future Plans
------------
[x] make the "disable trackpad time" configurable via the /proc filesystem. Do you think that /proc/sys/kernel/trackpad is a good place for it? There are other files under the /proc/sys/kernel directory that fall in the category "keyboard handling", e.g. ctrl-alt-del or sysrq.

[x] make a /proc entry to allow "disable trackpad" and "enable trackpad". That would allow to turn the builtin trackpad off when an external mouse is pluged in, and to re-enable it when an external mouse is unplugged again.

Here is the patch
-----------------

usr/src/linux/Documentation/Configure.help renamed from Documentation/Configure.help +10 -0
diff -urN -X /tmp/dontdiff linux-2.4.20/Documentation/Configure.help /usr/src/linux/Documentation/Configure.help
@@ -17752,6 +17752,16 @@
   <ftp://gnu.systemy.it/pub/gpm/>) solves this problem, or you can get
   the "mconv2" utility from <ftp://ibiblio.org/pub/Linux/system/mouse/>.
 
+Disable trackpad while typing
+CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+  For people with a notebook that have a build in trackpad.
+
+  It prevents unintended mouse moves and mouse taps while typing on
+  the notebook keyboard.
+
+  The majority of notebooks on the market have a PS/2 trackpad. 
+  So you will probably say "Y" if you have a notebook with a trackpad.
+
 C&T 82C710 mouse port support (as on TI Travelmate)
 CONFIG_82C710_MOUSE
   This is a certain kind of PS/2 mouse used on the TI Travelmate. If
usr/src/linux/drivers/char/Config.in renamed from drivers/char/Config.in +7 -0
diff -urN -X /tmp/dontdiff linux-2.4.20/drivers/char/Config.in /usr/src/linux/drivers/char/Config.in
@@ -170,6 +170,13 @@
 tristate 'Mouse Support (not serial and bus mice)' CONFIG_MOUSE
 if [ "$CONFIG_MOUSE" != "n" ]; then
    bool '  PS/2 mouse (aka "auxiliary device") support' CONFIG_PSMOUSE
+
+   if [ "$CONFIG_PSMOUSE" = "y" ]
+   then
+     bool '    Disable Trackpad while typing on Notebooks' CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+   fi
+
+
    tristate '  C&T 82C710 mouse port support (as on TI Travelmate)' CONFIG_82C710_MOUSE
    tristate '  PC110 digitizer pad support' CONFIG_PC110_PAD
    tristate '  MK712 touch screen support' CONFIG_MK712_MOUSE
usr/src/linux/drivers/char/pc_keyb.c renamed from drivers/char/pc_keyb.c +47 -0

73 lines not on this page · raw message

#1 lore raw
Quoted 14 lines · Hans-Georg Thien

static inline void handle_keyboard_event(unsigned char scancode) {

usr/src/linux/drivers/char/pc_keyb.c renamed from drivers/char/pc_keyb.c +12 -0
+
+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+
+        /* setup a timer to re-enable the trackpad */
+        static struct timer_list enable_trackpad_timer;
+        static int enable_trackpad_timer_initialized=0;
+
+        disable_trackpad_while_typing=1; /* disable trackpad */
+
+        if(enable_trackpad_timer_initialized)
+        {
+                 /* trackpad timer already exists, - just restart it */

usr/src/linux/drivers/char/pc_keyb.c line 515

Quoted 10 lines
usr/src/linux/drivers/char/pc_keyb.c renamed from drivers/char/pc_keyb.c +10 -0
+                 mod_timer(&enable_trackpad_timer, jiffies+trackpad_delay);
+        }
+        else
+        {
+                 /* no trackpad timer yet. Initialize and start it */
+                 init_timer(&enable_trackpad_timer);
+                 enable_trackpad_timer.expires=jiffies+trackpad_delay;
+                 enable_trackpad_timer.function=enable_trackpad;
+                 add_timer(&enable_trackpad_timer);
+                 enable_trackpad_timer_initialized=1;

The else block would probably be better off in some initialization function. Maybe the same place that sets up the interrupt handler is appropriate.

Signature · 2 lines
Måns Rullgård
[email protected]
#2 lore raw
In reply to Hans-Georg Thien

Hi Hans-Georg Thien,

Quoted 5 lines · On Thu, 01 May 2003 23:48:21 +0200 Hans-Georg Thien <[email protected]>…

Sorry for this long text and my bad english. And please be kind to me - it is my very first posting to this mailing list ...

I have written a *very small* patch against the linux 2.4.20 kernel and I want to submit it now.

Would it be possible to enable/disable this feature from userspace using an echo 1 > /proc/blabla, or only using insmod/modprobe -r? Anyway, very good idea!

Regards,

Signature · 1 line
wwp
#3 lore raw
Quoted 8 lines · wwp

Hi Hans-Georg Thien,

Would it be possible to enable/disable this feature from userspace using an echo 1 > /proc/blabla, or only using insmod/modprobe -r? Anyway, very good idea!

I'm working on an "echo ??? >/proc/something?" solution, where ??? is

delay=1200 # adjust trackpad to delay 1200 mSec after last keystroke
delay=0 # no delay, => disable that feature

-Hans

#4 lore raw

Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh aPS/2 Trackpad

In reply to Hans-Georg Thien

This patch makes it impossible to perform any operation that requires pressing a key on the keyboard while clicking a mouse button - for example bringing up X-terminal menu with CTRL-<middle button>. I am sure there are other similar combination used by other software. You would think 1 second after the CTRL key is pressed (which is when a keyboard event is generated), mouse will be re-enabled and you should be able to click mouse buttons as long as you do not let go of the key. Does not seem to work that way. Mouse stays disabled as long as the key is pressed.

--
Khalid

Quoted 93 lines · Hans-Georg Thien

Sorry for this long text and my bad english. And please be kind to me - it is my very first posting to this mailing list ...

I have written a *very small* patch against the linux 2.4.20 kernel and I want to submit it now.

The short story
---------------
The trackpad on the MacIntosh iBook Notebooks have a feature that prevents unintended trackpad input while typing on the keyboard. There are no mouse-moves or mouse-taps for a short period of time after each keystroke.

I believe that many people with i386 notebooks would like this feature and I want to give it to the linux community.

First I had the idea of writing a loadable kernel module "trackpad" that implements that feature and is loadable via

insmod keybd_irq=? mouse_irq=? delay=?

The long story
--------------
My first approach was - because I came from the bad old M$-DOS times - write something like a "terminate and stay resident program"

Procedure LoadModule
Save the currentlly installed handlers for keyboard and mouse. Install your own interrupt handlers for keyboard and mouse.
End

Procedure UnloadModule
Stop and remove "reset-timer" if necessary Restore the saved interrupt handlers for keyboard and mouse
End

Procedure KbdHandler
Stop or modify "reset-timer" if necessary
Set global variable block_mouse_events=1
Start a timer that resets block_mouse_events=0 after ??? mSec Call the old keyboard interrupt handler
End

Proceure MouseHandler
if block_mouse_events>0 then
call ACK(mouse irq) if necessary
do nothing
else
call old mouse interrupt handler
End

So I bought the book "Linux Device Drivers" written by Alessandro Rubini & Jonathan Corbert. It is an excellent book about LKM, but I couldn't find a way to "save and restore" irq-handlers as in the design described above.

That's why I requested a little help in the newsgroup at comp.os.linux.development.system. This ended up with some people who said "don't mess around with irq-handlers in that way".

While trying to gain a deeper understanding of irq-handling - espically for mouse and keyboard handlers - I found out that the keyboard and mouse interrupts are handled *both* in /usr/src/linux/drivers/char/pc_keyb.c.

Ok, that is only true for PS/2 mice, but the majority of notebooks on the market have a PS/2 trackpad. On modifiying the pc_keyb.c file there is no longer a need to save/restore Interrupt handlers or to call them indirecty via a function pointer. Unfortunatly it has to be compiled in the kernel and cannot be written as a LKM module.

But anyway - I sad down and got a working solution very quickly! I'm very glad with it! I needed not more than 45 minutes to get this working! Works in textmode (gpm) and under X11 as expected!

Testing
-------
I have tested my patch only on my own notebook (Compaq M300). It would help a lot if there are some volunteers...

Future Plans
------------
[x] make the "disable trackpad time" configurable via the /proc filesystem. Do you think that /proc/sys/kernel/trackpad is a good place for it? There are other files under the /proc/sys/kernel directory that fall in the category "keyboard handling", e.g. ctrl-alt-del or sysrq.

[x] make a /proc entry to allow "disable trackpad" and "enable trackpad". That would allow to turn the builtin trackpad off when an external mouse is pluged in, and to re-enable it when an external mouse is unplugged again.

Signature · 7 lines
====================================================================
Khalid Aziz                                Linux and Open Source Lab
(970)898-9214                                        Hewlett-Packard
[email protected]                                       Fort Collins, CO

"The Linux kernel is subject to relentless development" 
				- Alessandro Rubini
#5 lore raw

Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh aPS/2 Trackpad

Quoted 10 lines · Khalid Aziz

[...] impossible to perform any operation that requires pressing a key on the keyboard while clicking a mouse button - for example bringing up X-terminal menu with CTRL-<middle button>. I am sure there are other similar combination used by other software. You would think 1 second after the CTRL key is pressed (which is when a keyboard event is generated), mouse will be re-enabled and you should be able to click mouse buttons as long as you do not let go of the key. Does not seem to work that way. Mouse stays disabled as long as the key is pressed.

Thanks a lot Khalid! I have fixed that now.

Now, when you first press a key the trackpad is disabled. But the "timer" is not restarted now when you hold the key pressed down (prev_scancode == actual_scancode).

usr/src/linux/Documentation/Configure.help renamed from usr/src/linux-2.4.20/Documentation/Configure.help +10 -0
@@ -17752,6 +17752,16 @@
   <ftp://gnu.systemy.it/pub/gpm/>) solves this problem, or you can get
   the "mconv2" utility from <ftp://ibiblio.org/pub/Linux/system/mouse/>.
 
+Disable trackpad while typing
+CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+  For people with a notebook that have a build in trackpad.
+
+  It prevents unintended mouse moves and mouse taps while typing on
+  the notebook keyboard.
+
+  The majority of notebooks on the market have a PS/2 trackpad. 
+  So you will probably say "Y" if you have a notebook with a trackpad.
+
 C&T 82C710 mouse port support (as on TI Travelmate)
 CONFIG_82C710_MOUSE
   This is a certain kind of PS/2 mouse used on the TI Travelmate. If
usr/src/linux/drivers/char/Config.in renamed from usr/src/linux-2.4.20/drivers/char/Config.in +7 -0
@@ -170,6 +170,13 @@
 tristate 'Mouse Support (not serial and bus mice)' CONFIG_MOUSE
 if [ "$CONFIG_MOUSE" != "n" ]; then
    bool '  PS/2 mouse (aka "auxiliary device") support' CONFIG_PSMOUSE
+
+   if [ "$CONFIG_PSMOUSE" = "y" ]
+   then
+     bool '    Disable Trackpad while typing on Notebooks' CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+   fi
+
+
    tristate '  C&T 82C710 mouse port support (as on TI Travelmate)' CONFIG_82C710_MOUSE
    tristate '  PC110 digitizer pad support' CONFIG_PC110_PAD
    tristate '  MK712 touch screen support' CONFIG_MK712_MOUSE
usr/src/linux/drivers/char/pc_keyb.c renamed from usr/src/linux-2.4.20/drivers/char/pc_keyb.c +26 -0
@@ -13,6 +13,11 @@
  * Code fixes to handle mouse ACKs properly.
  * C. Scott Ananian <[email protected]> 1999-01-29.
  *
+ * Implemented the "disable trackpad while typing" feature. This prevents
+ * unintended mouse moves and mouse taps while typing on the keyboard on
+ * notebooks with a PS/2 trackpad.
+ * Hans-Georg Thien <[email protected]> 2003-04-30.
+ *
  */
 
 #include <linux/config.h>
@@ -67,6 +72,11 @@
 static void aux_write_ack(int val);
 static void __aux_write_ack(int val);
 static int aux_reconnect = 0;
+
+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+static int last_kbd_event = 0; /* used to hold timestamp of last kbd event */
+#endif
+
 #endif
 
 #ifndef kbd_controller_present
@@ -449,6 +459,11 @@
 		return;
 	}
 
+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+        /* do nothing if time since last kbd event is less then 1Sec */
+        if ( abs(jiffies - last_kbd_event) < HZ ) return;
+#endif
+
 	prev_code = scancode;
 	add_mouse_randomness(scancode);
 	if (aux_count) {
@@ -469,6 +484,17 @@
 
 static inline void handle_keyboard_event(unsigned char scancode)
 {
+
+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+        static unsigned char prev_scancode=0;
+
+        if (scancode != prev_scancode)
+        {
+                last_kbd_event = jiffies;
+                prev_scancode=scancode;
+        }
+#endif
+
 #ifdef CONFIG_VT
 	kbd_exists = 1;
 	if (do_acknowledge(scancode))
#6 lore raw

Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh aPS/2 Trackpad

In reply to Khalid Aziz
Quoted 6 lines · Hans-Georg Thien

The short story
---------------
Apple MacIntosh iBook Notebooks computers have a nice feature that prevents unintended trackpad input while typing on the keyboard. There are no mouse-moves or mouse-taps for a short period of time after each keystroke. I wanted to have this feature on my i386 notebook ...

It it is now possible to adjust some settings via

      echo ???? > /proc/tty/ps2-trackpad

(1) Set the delay time to 2 Secs (default is 10 ==> 1 Sec)

echo "delay 20" > /proc/tty/ps2-trackpad

(2) Completely disable the trackpad (default 0). Useful if you plug in an external mouse.

echo "disable 1" > /proc/tty/ps2-trackpad

(3) Escape the keyboard scancode for a key. These scancodes are passed without a delay. (defaults are the scancodes for CTRL and SHIFT keys).

This is useful for some applications ( like xterm ) which are using keydown events in combination with mouseclick events.

You can use showkey -s to find out the scancodes of your own keys.
To unescape a scancode you must apply that scancode twice! For keys with multiple scancodes you must use the *last* generated scancode.

Example: define an escape for HOME-KeyDown

echo "escape 0x047" > /proc/tty/ps2-trackpad

usr/src/linux/Documentation/Configure.help renamed from usr/src/linux-2.4.20/Documentation/Configure.help +38 -0
@@ -17752,6 +17752,44 @@
   <ftp://gnu.systemy.it/pub/gpm/>) solves this problem, or you can get
   the "mconv2" utility from <ftp://ibiblio.org/pub/Linux/system/mouse/>.
 
+Disable trackpad while typing
+CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+  For people with a notebook that have a build in trackpad.
+
+  It prevents unintended mouse moves and mouse taps while typing on
+  the notebook keyboard.
+
+  The majority of notebooks on the market have a PS/2 trackpad. 
+  So you will probably say "Y" if you have a notebook with a trackpad.
+
+  Also note that you can control the behaviour of the trackpad via the 
+  /proc/tty/ps2-trackpad file, e.g.
+
+  Set the delay time to 2 Secs (default is 10 ==> 1 Sec)
+
+  	echo "delay 20" > /proc/tty/ps2-trackpad
+  
+
+  Completely disable the trackpad (default 0). Useful if you plug in an
+  external mouse.
+
+  	echo "disable 1" > /proc/tty/ps2-trackpad
+
+
+  Escape the keyboard scancode for the key. These scancodes are passed
+  without a delay. (defaults are the scancodes for CTRL and SHIFT keys). 
+
+  This is useful for some applications ( like xterm ) which are using
+  keydown-click events.
+
+  You can use showkey -s to find out the scancodes of your own keys. 
+  Apply "escape 0x0??" twice to unescape a scancode. For keys with
+  multiple scancodes you must use the *last* generated scancode.
+
+  Example: define an escape for HOME-KeyDown 
+
+  	echo "escape 0x047" > /proc/tty/ps2-trackpad
+
 C&T 82C710 mouse port support (as on TI Travelmate)
 CONFIG_82C710_MOUSE
   This is a certain kind of PS/2 mouse used on the TI Travelmate. If
usr/src/linux/drivers/char/Config.in renamed from usr/src/linux-2.4.20/drivers/char/Config.in +7 -0
@@ -170,6 +170,13 @@
 tristate 'Mouse Support (not serial and bus mice)' CONFIG_MOUSE
 if [ "$CONFIG_MOUSE" != "n" ]; then
    bool '  PS/2 mouse (aka "auxiliary device") support' CONFIG_PSMOUSE
+
+   if [ "$CONFIG_PSMOUSE" = "y" ]
+   then
+     bool '    Disable Trackpad while typing on Notebooks' CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+   fi
+
+
    tristate '  C&T 82C710 mouse port support (as on TI Travelmate)' CONFIG_82C710_MOUSE
    tristate '  PC110 digitizer pad support' CONFIG_PC110_PAD
    tristate '  MK712 touch screen support' CONFIG_MK712_MOUSE
usr/src/linux/drivers/char/pc_keyb.c renamed from usr/src/linux-2.4.20/drivers/char/pc_keyb.c +144 -1

181 lines not on this page · raw message

#7 lore raw

Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh aPS/2 Trackpad

Hi Hans-Georg Thien,

Quoted 1 line · On Tue, 27 May 2003 22:47:06 +0200 Hans-Georg Thien <[email protected]>…

Hans-Georg Thien wrote:

[snip]

Quoted 9 lines

It it is now possible to adjust some settings via

       echo ???? > /proc/tty/ps2-trackpad

(1) Set the delay time to 2 Secs (default is 10 ==> 1 Sec)

echo "delay 20" > /proc/tty/ps2-trackpad

Quoted 6 lines

(2) Completely disable the trackpad (default 0). Useful if you plug in an external mouse.

echo "disable 1" > /proc/tty/ps2-trackpad

(3) Escape the keyboard scancode for a key. These scancodes are

[snip]

Sounds good, thanx for your work, guy :-).
Do you think/know if this patch will be merged to the official tree?

Regards,

Signature · 1 line
wwp
#8 lore raw

Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh aPS/2 Trackpad

Quoted 22 lines · wwp

Hi Hans-Georg Thien,

Quoted 1 line · On Tue, 27 May 2003 22:47:06 +0200 Hans-Georg Thien <[email protected]>…

Hans-Georg Thien wrote:

[snip]

Quoted 11 lines

It it is now possible to adjust some settings via

      echo ???? > /proc/tty/ps2-trackpad

(1) Set the delay time to 2 Secs (default is 10 ==> 1 Sec)

echo "delay 20" > /proc/tty/ps2-trackpad

(2) Completely disable the trackpad (default 0). Useful if you plug in an external mouse.

Quoted 9 lines
Quoted 3 lines

echo "disable 1" > /proc/tty/ps2-trackpad

(3) Escape the keyboard scancode for a key. These scancodes are

[snip]

Sounds good, thanx for your work, guy :-).
Do you think/know if this patch will be merged to the official tree?

I hope, of course ... If you know a way to enforce it - let me know!

#9 lore raw

[PORT to 2.6.x] "Disable Trackpad while typing" on Notebooks with a PS/2 Trackpad

In reply to wwp

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I have written a patch against the linux 2.4.x kernel and I want to port it to the 2.6.x Kernel now.

What it is
- ----------
The trackpad on the MacIntosh iBook notebooks have a feature that prevents unintended trackpad input while typing on the keyboard. There are no mouse-moves or mouse-taps for a short period of time after each keystroke.

I thougt that was a nice-to-have for my i386 notebook and have implemented it ( with some very important help of other people, namely Torsten Foertsch ).

This feature is fully configurable via a proc entry.

How it currently works
- ----------------------

In the 2.4.x kernel the handling of keyboard and PS/2 mouse where both done in linux/drivers/char/pc_keyb.c. So it was easy to apply a patch without touching other files.

It simply stores a timestamp whenever a key event occurs. If a mouse event occurs it compares the timestamp of the mouse event with stored timestamp of the key event. If the delta of these timestamps is less than a treshold value, than this mouse event is simply discarded. There where some things more to consider about, but I think you have the idea.

Where I need help now
- ---------------------
Since I do not want to touch the keyboard driver, I wonder if there is better way to get the timestamp when the last keyboard event occured?

Maybe a function call, a callback function where I can register to the be notified when a event occurs, a global accessible variable, a proc entry or something like that.

Any ideas ?

- - Hans

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)

iD8DBQE/eezq2xSpXPjN/jsRAgyAAJ9djvaiYsgiR4pOf4GRJ2xNKCUa5QCdFreB 4/iOjaoS+3XX0dL8DFGEaJk=
=zh+9
-----END PGP SIGNATURE-----

#10 lore raw

getting timestamp of last interrupt?

In reply to wwp

I am looking for a possibility to read out the last timestamp when an interrupt has occured.

e.g.: the user presses a key on the keyboard. Where can I read out the timestamp of this event?

To be more precise, I 'm looking for

( )a function call
( ) a callback where I can register to be notified when an event occurs ( ) a global accessible variable
( ) a /proc entry

or something like that.

Any ideas ?

- Hans

#11 lore raw

Re: getting timestamp of last interrupt?

Quoted 6 lines · Hans-Georg Thien

I am looking for a possibility to read out the last timestamp when an interrupt has occured.

e.g.: the user presses a key on the keyboard. Where can I read out the timestamp of this event?

To be more precise, I 'm looking for

Quoted 8 lines

( )a function call
( ) a callback where I can register to be notified when an event occurs ( ) a global accessible variable
( ) a /proc entry

or something like that.

Any ideas ?

Have a look at the Linux Trace Toolkit:
http://www.opersys.com/LTT/
It records micro-second time-stamps for quite a few events, including interrupts.

HTH,

Karim

Signature · 3 lines
Author, Speaker, Developer, Consultant
Pushing Embedded and Real-Time Linux Systems Beyond the Limits
http://www.opersys.com || [email protected] || 514-812-4145
#12 lore raw

Re: getting timestamp of last interrupt?

In reply to Hans-Georg Thien
Quoted 5 lines · Hans-Georg Thien

I am looking for a possibility to read out the last timestamp when an interrupt has occured.

e.g.: the user presses a key on the keyboard. Where can I read out the timestamp of this event?

You can get A SIGIO signal for every keyboard, (or other input) event. What you do with it is entirely up to you. Linux/Unix doesn't have "callbacks", instead it has signals. It also has select() and poll(), all useful for handling such events. If you want a time-stamp, you call gettimeofday() in your signal handler.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.

#13 lore raw

getting timestamp of last interrupt?

In reply to Hans-Georg Thien
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Hans-Georg" == Hans-Georg Thien <[email protected]> writes:

Hans-Georg> I am looking for a possibility to read out the last Hans-Georg> timestamp when an interrupt has occured.

Hans-Georg> e.g.: the user presses a key on the keyboard. Where can I Hans-Georg> read out the timestamp of this event?

Hans-Georg> To be more precise, I 'm looking for

Hans-Georg> ( )a function call ( ) a callback where I can register to Hans-Georg> be notified when an event occurs ( ) a global accessible Hans-Georg> variable ( ) a /proc entry

Hans-Georg> or something like that.

Hans-Georg> Any ideas ?

If you have the microstate accoounting patch applied, then the timestamp of each last IRQ is in the array msa_irq_entered[cpu][irq], measured as an architecture-specific number. Convert it to nanoseconds since boot with MSA_TO_NSEC

Peter C