If your keyboard is not USB based, then perhaps article like this is possibly your answer:<div><br><div><a href="http://www.computer-engineering.org/ps2keyboard/">http://www.computer-engineering.org/ps2keyboard/</a></div><div>
<a href="http://eduunix.ccut.edu.cn/index2/html/linux/Sybex%20Linux%20Power%20Tools%202003/6222final/LiB0023.html">http://eduunix.ccut.edu.cn/index2/html/linux/Sybex%20Linux%20Power%20Tools%202003/6222final/LiB0023.html</a></div>
<div><a href="http://freeworld.thc.org/papers/writing-linux-kernel-keylogger.txt" target="_blank">http://freeworld.thc.org/papers/writing-linux-kernel-keylogger.txt</a></div>
<div><br></div><div>Since your KB is usb-based, u can look here for internal info:<div><br></div><div><a href="http://www.emntech.com/docs/USB_KeyBoard_Driver_eMNTech.pdf" target="_blank">http://www.emntech.com/docs/USB_KeyBoard_Driver_eMNTech.pdf</a></div>

<div>
<br></div><div>Inside there is a picture on the overall flow.   </div><div><br></div><div>Essentially is the usb_kbd_probe() function.   Your problem of linking/delinking the KB may also be answered by:</div><div><br></div>


<div><a href="http://unix.stackexchange.com/questions/12005/how-to-use-linux-kernel-driver-bind-unbind-interface-for-usb-hid-devices" target="_blank">http://unix.stackexchange.com/questions/12005/how-to-use-linux-kernel-driver-bind-unbind-interface-for-usb-hid-devices</a></div>


<div><br></div><div>Another good ref is:</div><div><br></div><div><a href="http://www.linux.it/~rubini/docs/usb/usb.html" target="_blank">http://www.linux.it/~rubini/docs/usb/usb.html</a></div><div><br></div><div>as it simplified the complex flow of USB processing in the kernel for HID part in particular.</div>


<div><br></div><div>A good analogy to your problem is the apple keyboard:</div><div><br></div><div><a href="http://www.cyberciti.biz/faq/linux-apple-usb-keyboard-driver-installation/" target="_blank">http://www.cyberciti.biz/faq/linux-apple-usb-keyboard-driver-installation/</a></div>


<div><br></div><div>and looking into implementation drivers/hid/hid-apple.c (kernel source) perhaps can give u some insight.</div><div><br></div><div>Another thing is the non-kernel processing of scancode:</div><div><br>

</div>
<div><a href="http://eduunix.ccut.edu.cn/index2/html/linux/Sybex%20Linux%20Power%20Tools%202003/6222final/LiB0023.html" target="_blank">http://eduunix.ccut.edu.cn/index2/html/linux/Sybex%20Linux%20Power%20Tools%202003/6222final/LiB0023.html</a></div>


<div><br></div><div>As describe within, X windows keymap may also be used to change the mapping.</div><div><br></div><div><a href="http://www.in-ulm.de/~mascheck/X11/xmodmap.html" target="_blank">http://www.in-ulm.de/~mascheck/X11/xmodmap.html</a></div>


<div><br></div><div><a href="http://bochs.sourceforge.net/doc/docbook/user/keymap.html" target="_blank">http://bochs.sourceforge.net/doc/docbook/user/keymap.html</a></div><div><br></div><div><a href="http://madduck.net/docs/extending-xkb/" target="_blank">http://madduck.net/docs/extending-xkb/</a></div>


<div><br></div><div><a href="http://www.pixelbeat.org/docs/xkeyboard/" target="_blank">http://www.pixelbeat.org/docs/xkeyboard/</a></div><div><br></div><div><br><br><div class="gmail_quote">On Fri, Jan 4, 2013 at 2:17 AM, Racz Zoli <span dir="ltr">&lt;<a href="mailto:racz.zoli@gmail.com" target="_blank">racz.zoli@gmail.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Hi.</span><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">



<br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">I`m sorry if this isn`t the right place to post my question, but first I tried posting it on <a href="http://forum.kernelnewbies.org/" style="color:rgb(17,85,204)" target="_blank">forum.kernelnewbies.org</a> and nobody answered. Here`s my question:</div>



<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><span style="font-size:medium;font-family:Arial">I have a Gembird kb-9140l keyboard with some multimedia keys which are not working on linux. I thought about writing my own driver for it, so as a start, I wrote a small module, which registers an interrupt handler on irq 1 with the IRQF_SHARED flag. In the handler function I put a simple printk with the scancode read from the keyboard. The problem is, that the handler never gets executed. I searched on google, and found that because the native driver doesn`t share its interrupt with another modules, before I call request_irq I have to free the original interrupt handler from the native driver. This would make my computer practically unusable until I reboot, but at least I would see, it works, but it doesn`t. The original driver works fine after I insert my module, and the interrupt handler still doesn`t get called. The weird thing is, when I remove my module, my handler executes ones, and the scancode is 0xFE. </span><br style="clear:both;font-family:Arial;font-size:medium">



<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">The code is the following: </span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium">



<span style="font-size:medium;font-family:Arial">#include &lt;linux/module.h&gt; </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">#include &lt;linux/kernel.h&gt; </span><br style="clear:both;font-family:Arial;font-size:medium">



<span style="font-size:medium;font-family:Arial">#include &lt;linux/init.h&gt; </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">#include &lt;linux/interrupt.h&gt; </span><br style="clear:both;font-family:Arial;font-size:medium">



<span style="font-size:medium;font-family:Arial">#include &lt;asm/io.h&gt; </span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium">



<span style="font-size:medium;font-family:Arial">MODULE_LICENSE(&quot;Dual BSD/GPL&quot;);</span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">static int gembirdkb_init(void); </span><br style="clear:both;font-family:Arial;font-size:medium">



<span style="font-size:medium;font-family:Arial">static void gembirdkb_exit(void); </span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium">



<span style="font-size:medium;font-family:Arial">irq_handler_t irq_handler (int irq, void *dev_id, struct pt_regs *regs) </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">{ </span><br style="clear:both;font-family:Arial;font-size:medium">



<span style="font-size:medium;font-family:Arial">static unsigned char scancode; </span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">scancode = inb (0x60); </span><br style="clear:both;font-family:Arial;font-size:medium">



<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">printk(&quot;gembirdkb: irq handled... scancode: %d\n&quot;,scancode); </span><br style="clear:both;font-family:Arial;font-size:medium">



<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">return (irq_handler_t) IRQ_HANDLED; </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">} </span><br style="clear:both;font-family:Arial;font-size:medium">



<br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">static int gembirdkb_init(void) </span><br style="clear:both;font-family:Arial;font-size:medium">



<span style="font-size:medium;font-family:Arial">{ </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">int ret; </span><br style="clear:both;font-family:Arial;font-size:medium">



<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">/* free original interrupt handler */ </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">// free_irq(1, NULL); </span><br style="clear:both;font-family:Arial;font-size:medium">



<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">ret = request_irq (1, (irq_handler_t) irq_handler, IRQF_SHARED, &quot;gembirdkb&quot;, (void *)&amp;irq_handler); </span><br style="clear:both;font-family:Arial;font-size:medium">



<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">printk(&quot;gembirdkb: request_irq result: %d\n&quot;, ret); </span><br style="clear:both;font-family:Arial;font-size:medium">



<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">return ret; </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">} </span><br style="clear:both;font-family:Arial;font-size:medium">



<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">static void gembirdkb_exit(void) </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">{ </span><br style="clear:both;font-family:Arial;font-size:medium">



<span style="font-size:medium;font-family:Arial">free_irq(1, (void *)&amp;irq_handler); </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">} </span><br style="clear:both;font-family:Arial;font-size:medium">



<br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">module_init(gembirdkb_init); </span><br style="clear:both;font-family:Arial;font-size:medium">



<span style="font-size:medium;font-family:Arial">module_exit(gembirdkb_exit); </span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">Is there any way I can remove the native driver, or I need to recompile the kernel without it, and insert mine? </span></div>



<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><span style="font-size:medium;font-family:Arial"><br></span></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">



<span style="font-size:medium;font-family:Arial">P.s.: Why every topic on the forum is full with questions about mac, iphone, samsung galaxy etc.?</span></div>
<br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>Peter Teoh
</div>
</div>
</div>