paramvir
paramvir

Reputation: 404

Source code of keyboard driver of linux

I have been working on making my own keyboard driver for linux. So I came accross these two links: usbkbd.c and atkbd.c.

Now I am confused which of these is the actual code driving my keyboard at the present. As I see it atkbd.c is quite gory and there is a conversion of scancodes to keycodes. So it should be the code, though I am not sure.

If atkbd.c is the code, then what is the other code for?

Upvotes: 5

Views: 9099

Answers (1)

bytefire
bytefire

Reputation: 4422

This is easy to check. Let's take usbkbd.c.

The corresponding Kconfig (http://lxr.free-electrons.com/source/drivers/hid/usbhid/Kconfig#L50) says:

Say Y here only if you are absolutely sure that you don't want to use the generic HID driver for your USB keyboard and prefer to use the keyboard in its limited Boot Protocol mode instead.

This is almost certainly not what you want. This is mostly useful for embedded applications or simple keyboards.

So it looks unlikely to be the keyboard driver we are looking for. Also check current kernel config for USB_KBD. The config can be found under /boot directory or by running zcat /proc/config.gz. If USB_KBD is not there, you're not using it. If usbkbd.c is built as module, then will be worth checking if it is actually loaded. Makefile (http://lxr.free-electrons.com/source/drivers/hid/usbhid/Makefile#L10) gives the target as usbkbd. We can check if it is loaded by grepping for it in output of lsmod.

In contrast, Kconfig (http://lxr.free-electrons.com/source/drivers/input/keyboard/Kconfig#L69) for atkbd.c seem much more likely:

Say Y here if you want to use a standard AT or PS/2 keyboard. Usually you'll need this, unless you have a different type keyboard (USB, ADB or other). This also works for AT and PS/2 keyboards connected over a PS/2 to serial converter. If unsure, say Y.

Also check kernel config for KEYBOARD_ATKBD. If it is Y, you know it is being used. If it's M, check output of lsmod for atkbd.

Upvotes: 2

Related Questions