2 * FireDTV driver (formerly known as FireSAT)
4 * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
12 #include <linux/bitops.h>
13 #include <linux/input.h>
14 #include <linux/kernel.h>
15 #include <linux/types.h>
17 #include "firesat-rc.h"
19 /* fixed table with older keycodes, geared towards MythTV */
20 const static u16 oldtable[] = {
22 /* code from device: 0x4501...0x451f */
56 /* code from device: 0x4540...0x4542 */
63 /* user-modifiable table for a remote as sold in 2008 */
64 static u16 keytable[] = {
66 /* code from device: 0x0300...0x031f */
85 [0x11] = KEY_TITLE, /* "OSD" - fixme */
87 [0x13] = KEY_F20, /* "16:9" - fixme */
88 [0x14] = KEY_SCREEN, /* "FULL" - fixme */
90 [0x16] = KEY_SUBTITLE,
95 [0x1b] = KEY_PREVIOUS,
97 [0x1d] = KEY_PLAYPAUSE,
99 [0x1f] = KEY_VOLUMEUP,
101 /* code from device: 0x0340...0x0354 */
103 [0x20] = KEY_CHANNELUP,
104 [0x21] = KEY_F21, /* "4:3" - fixme */
112 [0x29] = KEY_CHANNEL, /* "CH.LIST" */
113 [0x2a] = KEY_VENDOR, /* "CI" - fixme */
114 [0x2b] = KEY_VOLUMEDOWN,
115 [0x2c] = KEY_CHANNELDOWN,
118 [0x2f] = KEY_FORWARD,
120 [0x31] = KEY_FAVORITES,
126 static struct input_dev *idev;
128 int firesat_register_rc(void)
132 idev = input_allocate_device();
136 idev->name = "FireDTV remote control";
137 idev->evbit[0] = BIT_MASK(EV_KEY);
138 idev->keycode = keytable;
139 idev->keycodesize = sizeof(keytable[0]);
140 idev->keycodemax = ARRAY_SIZE(keytable);
142 for (i = 0; i < ARRAY_SIZE(keytable); i++)
143 set_bit(keytable[i], idev->keybit);
145 err = input_register_device(idev);
147 input_free_device(idev);
152 void firesat_unregister_rc(void)
154 input_unregister_device(idev);
157 void firesat_handle_rc(unsigned int code)
159 if (code >= 0x0300 && code <= 0x031f)
160 code = keytable[code - 0x0300];
161 else if (code >= 0x0340 && code <= 0x0354)
162 code = keytable[code - 0x0320];
163 else if (code >= 0x4501 && code <= 0x451f)
164 code = oldtable[code - 0x4501];
165 else if (code >= 0x4540 && code <= 0x4542)
166 code = oldtable[code - 0x4521];
168 printk(KERN_DEBUG "firedtv: invalid key code 0x%04x "
169 "from remote control\n", code);
173 input_report_key(idev, code, 1);
174 input_report_key(idev, code, 0);