2 handle em28xx IR remotes via linux kernel input layer.
4 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
5 Markus Rechberger <mrechberger@gmail.com>
6 Mauro Carvalho Chehab <mchehab@brturbo.com.br>
7 Sascha Sommer <saschasommer@freenet.de>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <linux/module.h>
25 #include <linux/moduleparam.h>
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/sched.h>
29 #include <linux/interrupt.h>
30 #include <linux/input.h>
31 #include <linux/usb.h>
35 static unsigned int disable_ir
= 0;
36 module_param(disable_ir
, int, 0444);
37 MODULE_PARM_DESC(disable_ir
,"disable infrared remote support");
39 static unsigned int ir_debug
= 0;
40 module_param(ir_debug
, int, 0644);
41 MODULE_PARM_DESC(ir_debug
,"enable debug messages [IR]");
43 #define dprintk(fmt, arg...) if (ir_debug) \
44 printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg)
46 /* ---------------------------------------------------------------------- */
48 static IR_KEYTAB_TYPE ir_codes_em_terratec
[IR_KEYTAB_SIZE
] = {
49 [ 0x01 ] = KEY_CHANNEL
,
50 [ 0x02 ] = KEY_SELECT
,
56 [ 0x08 ] = KEY_CHANNELUP
,
60 [ 0x0c ] = KEY_CHANNELDOWN
,
64 [ 0x10 ] = KEY_VOLUMEUP
,
68 [ 0x14 ] = KEY_VOLUMEDOWN
,
70 [ 0x18 ] = KEY_RECORD
,
71 [ 0x19 ] = KEY_REWIND
,
73 [ 0x1b ] = KEY_FORWARD
,
74 [ 0x1c ] = KEY_BACKSPACE
,
79 /* ----------------------------------------------------------------------- */
81 static int get_key_terratec(struct IR_i2c
*ir
, u32
*ir_key
, u32
*ir_raw
)
86 if (1 != i2c_master_recv(&ir
->c
,&b
,1)) {
87 dprintk("read error\n");
91 /* it seems that 0xFE indicates that a button is still hold
92 down, while 0xff indicates that no button is hold
93 down. 0xfe sequences are sometimes interrupted by 0xFF */
95 dprintk("key %02x\n", b
);
110 static int get_key_em_haup(struct IR_i2c
*ir
, u32
*ir_key
, u32
*ir_raw
)
112 unsigned char buf
[2];
116 if (2 != i2c_master_recv(&ir
->c
,buf
,2))
119 /* Does eliminate repeated parity code */
125 /* Rearranges bits to the right order */
126 code
= ((buf
[0]&0x01)<<5) | /* 0010 0000 */
127 ((buf
[0]&0x02)<<3) | /* 0001 0000 */
128 ((buf
[0]&0x04)<<1) | /* 0000 1000 */
129 ((buf
[0]&0x08)>>1) | /* 0000 0100 */
130 ((buf
[0]&0x10)>>3) | /* 0000 0010 */
131 ((buf
[0]&0x20)>>5); /* 0000 0001 */
133 dprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x)\n",code
,buf
[0]);
141 /* ----------------------------------------------------------------------- */
142 void em28xx_set_ir(struct em28xx
* dev
,struct IR_i2c
*ir
)
149 /* detect & configure */
150 switch (dev
->model
) {
151 case (EM2800_BOARD_UNKNOWN
):
153 case (EM2820_BOARD_UNKNOWN
):
155 case (EM2800_BOARD_TERRATEC_CINERGY_200
):
156 case (EM2820_BOARD_TERRATEC_CINERGY_250
):
157 ir
->ir_codes
= ir_codes_em_terratec
;
158 ir
->get_key
= get_key_terratec
;
159 snprintf(ir
->c
.name
, sizeof(ir
->c
.name
), "i2c IR (EM28XX Terratec)");
161 case (EM2820_BOARD_PINNACLE_USB_2
):
163 case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2
):
164 ir
->ir_codes
= ir_codes_hauppauge_new
;
165 ir
->get_key
= get_key_em_haup
;
166 snprintf(ir
->c
.name
, sizeof(ir
->c
.name
), "i2c IR (EM2840 Hauppauge)");
168 case (EM2820_BOARD_MSI_VOX_USB_2
):
170 case (EM2800_BOARD_LEADTEK_WINFAST_USBII
):
172 case (EM2800_BOARD_KWORLD_USB2800
):
177 /* ----------------------------------------------------------------------