Re: keyboard driver question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If your keyboard is not USB based, then perhaps article like this is possibly your answer:

http://www.computer-engineering.org/ps2keyboard/
http://eduunix.ccut.edu.cn/index2/html/linux/Sybex%20Linux%20Power%20Tools%202003/6222final/LiB0023.html
http://freeworld.thc.org/papers/writing-linux-kernel-keylogger.txt

Since your KB is usb-based, u can look here for internal info:

http://www.emntech.com/docs/USB_KeyBoard_Driver_eMNTech.pdf

Inside there is a picture on the overall flow.   

Essentially is the usb_kbd_probe() function.   Your problem of linking/delinking the KB may also be answered by:

http://unix.stackexchange.com/questions/12005/how-to-use-linux-kernel-driver-bind-unbind-interface-for-usb-hid-devices

Another good ref is:

http://www.linux.it/~rubini/docs/usb/usb.html

as it simplified the complex flow of USB processing in the kernel for HID part in particular.

A good analogy to your problem is the apple keyboard:

http://www.cyberciti.biz/faq/linux-apple-usb-keyboard-driver-installation/

and looking into implementation drivers/hid/hid-apple.c (kernel source) perhaps can give u some insight.

Another thing is the non-kernel processing of scancode:

http://eduunix.ccut.edu.cn/index2/html/linux/Sybex%20Linux%20Power%20Tools%202003/6222final/LiB0023.html

As describe within, X windows keymap may also be used to change the mapping.

http://www.in-ulm.de/~mascheck/X11/xmodmap.html

http://bochs.sourceforge.net/doc/docbook/user/keymap.html

http://madduck.net/docs/extending-xkb/

http://www.pixelbeat.org/docs/xkeyboard/



On Fri, Jan 4, 2013 at 2:17 AM, Racz Zoli <racz.zoli@xxxxxxxxx> wrote:
Hi.

I`m sorry if this isn`t the right place to post my question, but first I tried posting it on forum.kernelnewbies.org and nobody answered. Here`s my question:


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. 

The code is the following: 

#include <linux/module.h> 
#include <linux/kernel.h> 
#include <linux/init.h> 
#include <linux/interrupt.h> 
#include <asm/io.h> 


MODULE_LICENSE("Dual BSD/GPL");

static int gembirdkb_init(void); 
static void gembirdkb_exit(void); 


irq_handler_t irq_handler (int irq, void *dev_id, struct pt_regs *regs) 

static unsigned char scancode; 

scancode = inb (0x60); 

printk("gembirdkb: irq handled... scancode: %d\n",scancode); 

return (irq_handler_t) IRQ_HANDLED; 



static int gembirdkb_init(void) 

int ret; 

/* free original interrupt handler */ 
// free_irq(1, NULL); 

ret = request_irq (1, (irq_handler_t) irq_handler, IRQF_SHARED, "gembirdkb", (void *)&irq_handler); 

printk("gembirdkb: request_irq result: %d\n", ret); 

return ret; 


static void gembirdkb_exit(void) 

free_irq(1, (void *)&irq_handler); 



module_init(gembirdkb_init); 
module_exit(gembirdkb_exit); 

Is there any way I can remove the native driver, or I need to recompile the kernel without it, and insert mine? 

P.s.: Why every topic on the forum is full with questions about mac, iphone, samsung galaxy etc.?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




--
Regards,
Peter Teoh
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux