NeTV IR driver

NeTV uses a GPIO-based IR sensor. That means that it's simply counting the pattern of 0s and 1s coming from a sensor that performs IR detection and demodulation.

There is currently no LIRC driver. Instead, it acts as a keyboard driver, using a hard-coded set of scancodes and key equivalents. By modifying the driver, it's possible to add new keys or to change the mapping.

Note that it might be useful to build the kernel as a module. That way you can try new code without having to reboot.

These steps instruct you on how to load a new kernel onto your device. Any time you modify the kernel, you risk making your system unbootable. Do not continue unless you are familiar with how to re-image your SD card.

Setting up your build environment
These steps will set up an environment that will allow you to modify the IR kernel drivers. These steps only need to be completed once.
 * 1) Install and configure the NeTV toolchain
 * 2) Enable SSH on your NeTV
 * 3) Check out the kernel
 * 4) * git clone git://github.com/sutajiokousagi/linux-2.6.28-silvermoon.git; cd linux-2.6.28-silvermoon/src/; git checkout netv
 * 5) Grab the latest config file
 * 6) * wget -O .config https://raw.github.com/sutajiokousagi/meta-chumby/master/recipes/linux/linux-silvermoon-netv/defconfig
 * 7) Convert the IR driver from a builtin to a module
 * 8) * make menuconfig
 * 9) * Go to Device Drivers ---> Input Device Support ---> CIR device and set it from <*> to 
 * 10) * Select < Exit > repeatedly, answer < Yes > when it asks you to save your new kernel configuration
 * 11) Enable DEBUG mode in the GPIO IR driver
 * 12) * nano -w drivers/input/gpio_ir.c
 * 13) * Add the following to the very top of the file:
 * 14) ** #define DEBUG
 * 15) * Save and quit:
 * 16) ** Control-X, Y, Enter
 * 17) Build a new kernel
 * 18) * make
 * 19) Copy the kernel to your NeTV
 * 20) * scp arch/arm/boot/zImage root@[NeTV-address]:
 * 21) On your NeTV, write the new kernel
 * 22) * config_util --cmd=putblock --block=krnA < zImage
 * 23) On your NeTV, reboot into the new kernel
 * 24) * reboot

Modifying the GPIO IR driver
Every time you make changes to the GPIO driver, you must rebuild the module, copy the kernel object over, and reload it. You do not need to reboot your NeTV unless there is a problem with resource management, or if there is a crash in the driver. 00000000 e9 06 00 00 3f b7 06 00  01 00 1c 00 01 00 00 00  |....?...........| 00000010 e9 06 00 00 a4 87 0a 00  01 00 1c 00 02 00 00 00  |................| 00000020 e9 06 00 00 ba 87 0a 00  01 00 1c 00 00 00 00 00  |................|
 * 1) Make changes to drivers/input/gpio_ir.c
 * 2) Rebuild kernel modules
 * 3) * make modules
 * 4) Copy gpio_ir.ko to your NeTV
 * 5) * scp drivers/input/gpio_ir.ko root@[NeTV-address]:
 * 6) On your NeTV, make sure the GPIO IR driver is not installed
 * 7) * rmmod gpio_ir
 * 8) On your NeTV, install the newly-copied GPIO IR driver
 * 9) * insmod gpio_ir.ko
 * 10) Check to see your key is doing what you want it to:
 * 11) * Run "hexdump -C /dev/input/event1"
 * 12) * Press the newly-defined button. Your output should look like the following, with the new keycode defined in the bolded field.  Press Control-C to exit:

Adding new IR codes
When DEBUG mode is enabled, the driver will report all unrecognized keycodes. Use logread to report these keycodes, then add them to the driver and rebuild.
 * 1) Load the module as described above
 * 2) Run the following command on your NeTV to monitor syslog events:
 * 3) * logread -f
 * 4) Point your remote control at your NeTV and press a button
 * 5) Note the message that gets printed.  It will be something of the form:
 * 6) * Apr 16 16:46:24 chumby-silvermoon-netv user.debug kernel: [ 1262.366693] aspenite-cir aspenite-cir.0: No key found for code 0xfd027d82
 * 7) Edit drivers/input/gpio_ir.c
 * 8) Add the code mentioned to the nikon_key_table array, along with the keycode.  Possible keycodes are listed in input.h.
 * 9) Save and rebuild the GPIO IR driver, as mentioned above

Making the changes permanent
Once you have your changes made, you'll want to have them automatically load at boot. To do that, you will need to modify the kernel configuration to compile gpio_ir as a builtin rather than as a module.
 * 1) Convert the IR driver from a module to a builtin
 * 2) * make menuconfig
 * 3) * Go to Device Drivers ---> Input Device Support ---> CIR device and set it from  to <*> by moving the cursor over it and hitting "Y"
 * 4) * Select < Exit > repeatedly, answer < Yes > when it asks you to save your new kernel configuration
 * 5) Enable DEBUG mode in the GPIO IR driver
 * 6) * nano -w drivers/input/gpio_ir.c
 * 7) * Remove the following from the very top of the file:
 * 8) ** #define DEBUG
 * 9) * Save and quit:
 * 10) ** Control-X, Y, Enter
 * 11) Build a new kernel
 * 12) * make
 * 13) Copy the kernel to your NeTV
 * 14) * scp arch/arm/boot/zImage root@[NeTV-address]:
 * 15) On your NeTV, write the new kernel
 * 16) * config_util --cmd=putblock --block=krnA < zImage
 * 17) On your NeTV, reboot into the new kernel
 * 18) * reboot