Hi, On Thu, Jul 23, 2009 at 08:51:34AM +0200, Riccardo Mottola wrote: > I hope we soon get a newer kernel and a basic toolchain, X11 and > libraries to work on. The 2.4 kernel for example is unsuitable for > typing. The keyboard inserts random characters. This is incovenient > both for note taking as well as for small programming. > I also hope some performance improvment.
For the kernel I'm writing, Iris, I have a better keyboard driver than the code in 2.6. On average it responds faster to keys, and it takes less processor time. I'm writing the details here, so they can be ported to Linux if anyone is interested. The essential parts are interrupts: - Interrupts on change (currently falling or rising edge, but perhaps lever interrupts are better) are enabled for all row pins. Between scans, all columns are set to output 0. The rows are pull-up inputs. If all inputs are high, no keys are pressed. - The first key that is pressed will always generate an interrupt. Therefore, periodic scanning is disabled while no keys are pressed. This reduces processor time. - Some other key presses or releases also trigger interrupts (changes in "are all keys in a row pressed?"). This results in a faster response to those events than from periodic scanning. - Finally, I read out an entire port in one go. The kernel uses 8 times gpio_get_pin, which means 8 reads of the port. Since these are uncached, this is slower than needed. The same is true for other bulk register changes, such as setting port direction or data output, but those are less wasteful (than the data read) in the 2.6 kernel. This may be insignificant, and has the drawback of requiring either direct use of the port, or new functions in ops.h. For reference, I include the source[0] of my keyboard driver. Things to keep in mind while reading it: - I have stripped REG_ from all register definitions. The values without the prefix are only used by Linux to define the values with it. AFAICS any reference of a value without REG_ in Linux is a bug in the kernel. I have no idea why this approach is chosen. - The code is C++ so that it can use member functions and default function arguments. It should be readable for anyone who only knows C, though. - A lot of original code has been stripped out for clarity. In particular the parts for other GPIO devices. That's it for now. In case of any questions, please ask. Thanks, Bas [0] This isn't really the source; I'm using a preprocessor which makes the source look a bit like Python. I'm posting the preprocessed source here, because I expect people to be unfamiliar with the preprocessor. -- I encourage people to send encrypted e-mail (see http://www.gnupg.org). If you have problems reading my e-mail, use a better reader. Please send the central message of e-mails as plain text in the message body, not as HTML and definitely not as MS Word. Please do not use the MS Word format for attachments either. For more information, see http://a82-93-13-222.adsl.xs4all.nl/e-mail.html
signature.asc
Description: Digital signature
_______________________________________________ Mipsbook-devel mailing list Mipsbook-devel@linuxtogo.org http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/mipsbook-devel