Discussion:
[PORT to 2.6.x] "Disable Trackpad while typing" on Notebooks with a PS/2 Trackpad
(too old to reply)
Hans-Georg Thien
2003-09-30 21:00:26 UTC
Permalink
-----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-----

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hans-Georg Thien
2003-10-02 17:50:12 UTC
Permalink
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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Karim Yaghmour
2003-10-02 19:00:13 UTC
Permalink
Post by 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
( )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
--
Author, Speaker, Developer, Consultant
Pushing Embedded and Real-Time Linux Systems Beyond the Limits
http://www.opersys.com || ***@opersys.com || 514-812-4145

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Richard B. Johnson
2003-10-02 19:00:23 UTC
Permalink
Post by 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.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Peter Chubb
2003-10-02 22:50:16 UTC
Permalink
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hans-Georg Thien
2003-10-04 04:10:09 UTC
Permalink
Post by Karim Yaghmour
Post by 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
( )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 ?
http://www.opersys.com/LTT/
It records micro-second time-stamps for quite a few events, including
interrupts.
thanke a lot for reply Karim,

but I think that LTT does not fit to my needs. It needs to modify the
kernel - and that is what I want to avoid.

I'm looking for a already existing built-in capability.

Maybe signal SIGIO is a solution, if it does not

(x) give me *every* IO event
(x) has to much overhead - I have to respond to keyboard/mouse events, *not*
disk events
grafic card events
eth event
etc. ...


- Hans




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Gabriel Paubert
2003-10-06 15:40:07 UTC
Permalink
Post by Hans-Georg Thien
Post by Karim Yaghmour
Post by 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
( )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 ?
http://www.opersys.com/LTT/
It records micro-second time-stamps for quite a few events, including
interrupts.
thanke a lot for reply Karim,
but I think that LTT does not fit to my needs. It needs to modify the
kernel - and that is what I want to avoid.
I'm looking for a already existing built-in capability.
Maybe signal SIGIO is a solution, if it does not
(x) give me *every* IO event
(x) has to much overhead - I have to respond to keyboard/mouse events, *not*
Doesn't the input layer add a timestamp to every event?

At least that's the impression I have from xxd /dev/input/eventN: the
first eight bytes of each 16 bytes packet look so furiously close to
a struct timeval that they can't be anything else :-)

Just that I don't know how the devices and N are associated, it seems to be
order of discovery/registering at boot.

Regards,
Gabriel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hans-Georg Thien
2003-10-06 18:40:29 UTC
Permalink
Post by Gabriel Paubert
[...]
Post by Hans-Georg Thien
I am looking for a possibility to read out the last timestamp when an
interrupt has occured.
[...]
Doesn't the input layer add a timestamp to every event?
At least that's the impression I have from xxd /dev/input/eventN: the
first eight bytes of each 16 bytes packet look so furiously close to
a struct timeval that they can't be anything else :-)
Just that I don't know how the devices and N are associated, it seems to be
order of discovery/registering at boot.
Hello Gabriel,

Oh yes, - that looks quite good to me. I'm investigating on that now. I
found out, that you need at least to compile the "evdev" module.

-Hans


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hans-Georg Thien
2003-10-04 04:10:10 UTC
Permalink
Post by Richard B. Johnson
Post by 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.
Thanks a lot Richard,

... but ... can I use signals in kernel mode?


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Richard B. Johnson
2003-10-06 13:00:17 UTC
Permalink
Post by Hans-Georg Thien
Post by Richard B. Johnson
Post by 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.
Thanks a lot Richard,
... but ... can I use signals in kernel mode?
Well you talked about the user pressing a key and getting
a time-stamp as a result. If you need time-stamps
inside the kernel, i.e, a module, then you can call
the kernel's do_gettimeofday() function.

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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hans-Georg Thien
2003-10-06 18:30:22 UTC
Permalink
Post by Richard B. Johnson
Post by Hans-Georg Thien
Post by Richard B. Johnson
[...]
Post by 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.
Thanks a lot Richard,
... but ... can I use signals in kernel mode?
Well you talked about the user pressing a key and getting
a time-stamp as a result. If you need time-stamps
inside the kernel, i.e, a module, then you can call
the kernel's do_gettimeofday() function.
Hello Richard, - It seems, that I should be more precise about what I
exactly mean...


I'm writing a kernel mode device driver (mouse).

In that device driver I need the timestamp of the last event for another
kernel mode device (keyboard).

I do not care if that timestamp is in jiffies or in gettimeofday()
format or whatever format does exist in the world. I am absolutely sure
I can convert it somehow to fit my needs.

But since it is a kernel mode driver it can not -AFAIK- use the signal()
syscall.

-Hans



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Richard B. Johnson
2003-10-06 18:40:28 UTC
Permalink
Post by Hans-Georg Thien
Post by Richard B. Johnson
Post by Hans-Georg Thien
Post by Richard B. Johnson
[...]
Post by 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.
Thanks a lot Richard,
... but ... can I use signals in kernel mode?
Well you talked about the user pressing a key and getting
a time-stamp as a result. If you need time-stamps
inside the kernel, i.e, a module, then you can call
the kernel's do_gettimeofday() function.
Hello Richard, - It seems, that I should be more precise about what I
exactly mean...
I'm writing a kernel mode device driver (mouse).
In that device driver I need the timestamp of the last event for another
kernel mode device (keyboard).
I do not care if that timestamp is in jiffies or in gettimeofday()
format or whatever format does exist in the world. I am absolutely sure
I can convert it somehow to fit my needs.
But since it is a kernel mode driver it can not -AFAIK- use the signal()
syscall.
-Hans
Then it gets real simple. Just use jiffies, if you can stand the
wrap that will occur every (2^32 -1)/HZ seconds ~= 497 days with
HZ = 100. If not, call sys_gettimeofday(). Also, if your events
are closer in time than a HZ, then you must get time from
sys_gettimeofday().

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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hans-Georg Thien
2003-10-06 19:20:12 UTC
Permalink
Post by Hans-Georg Thien
[...]
I'm writing a kernel mode device driver (mouse).
In that device driver I need the timestamp of the last event for another
kernel mode device (keyboard).
I do not care if that timestamp is in jiffies or in gettimeofday()
format or whatever format does exist in the world. I am absolutely sure
I can convert it somehow to fit my needs.
But since it is a kernel mode driver it can not -AFAIK- use the signal()
syscall.
-Hans
Then it gets real simple. Just use jiffies, if you can stand the [...]
I fear that there is still some miss-understanding. Jiffies are totally
OK for me. I can use them without any conversion.

I'll try to formulate the problem with some other words:

I hope that there is is something like a "jiffie-counter" for the
keyboard driver, that stores the actual jiffies value whenever a
keyboard interrupt occurs.

I hope too, that there is a way to query that "jiffie-counter" from
another kernel driver, so that I can write something like


mymouse_module.c

...
void mouse_event(){

// get the current time in jiffies
int now=jiffies;

// get the jiffie value of the last kbd event
int last_kbd_event= ????; // ... but how to do that ...

if ((now - last_kbd_event) > delay) {
do_some_very_smart_things();
}
}
...

-Hans


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Richard B. Johnson
2003-10-06 19:40:23 UTC
Permalink
Post by Hans-Georg Thien
Post by Hans-Georg Thien
[...]
I'm writing a kernel mode device driver (mouse).
In that device driver I need the timestamp of the last event for another
kernel mode device (keyboard).
I do not care if that timestamp is in jiffies or in gettimeofday()
format or whatever format does exist in the world. I am absolutely sure
I can convert it somehow to fit my needs.
But since it is a kernel mode driver it can not -AFAIK- use the signal()
syscall.
-Hans
Then it gets real simple. Just use jiffies, if you can stand the [...]
I fear that there is still some miss-understanding. Jiffies are totally
OK for me. I can use them without any conversion.
I hope that there is is something like a "jiffie-counter" for the
keyboard driver, that stores the actual jiffies value whenever a
keyboard interrupt occurs.
Well the keyboard driver and the mouse driver are entirely
different devices.

The keyboard has a built-int CPU that generates scan-codes for
every key-press/key-release. It also performs auto-repeat. The
mouse generates mouse data at each interrupting event. This data
represents direction and three key events. Wheel mouse have may
have additional data, I haven't looked at them. They are not
related in any way.
Post by Hans-Georg Thien
I hope too, that there is a way to query that "jiffie-counter" from
another kernel driver, so that I can write something like
mymouse_module.c
...
void mouse_event(){
// get the current time in jiffies
int now=jiffies;
// get the jiffie value of the last kbd event
int last_kbd_event= ????; // ... but how to do that ...
if ((now - last_kbd_event) > delay) {
do_some_very_smart_things();
}
}
...
Now this pseudo-code shows a "last_kbd_event", not a mouse-
Post by Hans-Georg Thien
Post by Hans-Georg Thien
I'm writing a kernel mode device driver (mouse).
... your words, not mine.

I presume that you are replacing the existing mouse-driver.
If so, your mouse-buffer, i.e., the place you put the
mouse-event movement-codes can be something like:

struct mouse_event {
unsigned long time;
int mouse_code;
}

You allocate a buffer of this type and, during each interrupt,
you put both the jiffie-time and the mouse code into your buffer.

If you are not replacing the existing mouse driver, then you
need to share its interrupt with your new module. The new
module records the time-stamp of each of the interrupts, only.

Every bit of mouse-data was obtained as a result of an interrupt.
Using that knowledge, you should be able to correlate a time-stamp
to mouse-data (clear your time-stamp buffer when no mouse data
are available).

If you are using the keyboard, not the mouse, then the same
things apply.

If you just want to patch the existing keyboard or mouse
ISR to save a time-stamp in your module code, you need to
make the built-in keyboard or mouse ISR code call a function
by pointer. This pointer must be initialized to point to a
stub that simply returns. You need to export this symbol
so it can be found by your module.

When your module is installed, it saves the value in that
pointer. It then changes the pointer value to the address of
your routine. It needs to do this under a spin-lock.

When your module is un-installed, it needs to restore the
previous (saved) value of that pointer.

Whatever code you make that pointer point-to, must be
interrupt-safe. It can get the jiffie-count and put it
into a buffer, then return.


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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hans-Georg Thien
2003-10-06 22:10:10 UTC
Permalink
Post by Richard B. Johnson
Post by Hans-Georg Thien
Post by Hans-Georg Thien
[...]
I'm writing a kernel mode device driver (mouse).
In that device driver I need the timestamp of the last event for another
kernel mode device (keyboard).
I do not care if that timestamp is in jiffies or in gettimeofday()
format or whatever format does exist in the world. I am absolutely sure
I can convert it somehow to fit my needs.
But since it is a kernel mode driver it can not -AFAIK- use the signal()
syscall.
-Hans
Then it gets real simple. Just use jiffies, if you can stand the [...]
I fear that there is still some miss-understanding. Jiffies are totally
OK for me. I can use them without any conversion.
I hope that there is is something like a "jiffie-counter" for the
keyboard driver, that stores the actual jiffies value whenever a
keyboard interrupt occurs.
Well the keyboard driver and the mouse driver are entirely
different devices.
yes, - I know
Post by Richard B. Johnson
The keyboard has a built-int CPU that generates scan-codes for
every key-press/key-release. It also performs auto-repeat. The
mouse generates mouse data at each interrupting event. This data
represents direction and three key events. Wheel mouse have may
have additional data, I haven't looked at them. They are not
related in any way.
yes, - I know
Post by Richard B. Johnson
Post by Hans-Georg Thien
I hope too, that there is a way to query that "jiffie-counter" from
another kernel driver, so that I can write something like
mymouse_module.c
...
void mouse_event(){
// get the current time in jiffies
int now=jiffies;
// get the jiffie value of the last kbd event
int last_kbd_event= ????; // ... but how to do that ...
if ((now - last_kbd_event) > delay) {
do_some_very_smart_things();
}
}
...
Now this pseudo-code shows a "last_kbd_event", not a mouse-
yes, - I know =8))

It is because I want do some things with the mouse in relation to
keyboard events.
Post by Richard B. Johnson
[... a quite detailed explanation on mouse interrupts, mouse data ...]
yes, I know. But my question was: how can I get the timestamp of the
last keyboard interrupt.
Post by Richard B. Johnson
When your module is un-installed, it needs to restore the
previous (saved) value of that pointer.
yes, - I know
Post by Richard B. Johnson
Whatever code you make that pointer point-to, must be
interrupt-safe. It can get the jiffie-count and put it
into a buffer, then return.
yes, - I know

Hey Richard, - what is so difficult to understand ?

Anyway, - have you read the email reply from Gabriel Paubert regarding
this topic? Sounds very good for a 2.6.x kernel. It seems that I can use
the /dev/input/event? device files. I have just modprobed the "evdev"
module. It seems that I can get my timestamps by reading one of this
files. Have to investigate still which one of them I have to use.

-Hans


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Continue reading on narkive:
Loading...