aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-input.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@brturbo.com.br>2005-11-09 00:37:32 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:18 -0500
commitd5e5265315770bda46c50ecaa64e2b9790f2064c (patch)
tree5c92fa1125dee3f766bd06f18840ce78bf0cd861 /drivers/media/video/em28xx/em28xx-input.c
parentda45a2a5b96afd7188c058a55eb2917d6524c0cf (diff)
[PATCH] v4l: 784: several improvement on i2c ir handling for em2820
- Several Improvement on I2C IR handling for em2820: - moved Pinnacle IR table (ir_codes_em2820) to em2820-input.c - IR struct renamed and moved to a header file. - New file to handle em2820-specific IR. - Some cleanups. - attach now detects I2C IR and calls em2820-specific IR code - IR compat code moved to compat.h - New header with struct IR_i2c there, to allow it to be used by board-specific input handlers. - Some improvements at em28xx board detection: - Board detection message improved to show interface and class. - Now it doesn't touch audio interfaces. Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-input.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c150
1 files changed, 150 insertions, 0 deletions
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
new file mode 100644
index 000000000000..d6b3e15a0350
--- /dev/null
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -0,0 +1,150 @@
1/*
2 *
3 * handle saa7134 IR remotes via linux kernel input layer.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21#include <linux/module.h>
22#include <linux/moduleparam.h>
23#include <linux/init.h>
24#include <linux/delay.h>
25#include <linux/sched.h>
26#include <linux/interrupt.h>
27#include <linux/input.h>
28#include <linux/usb.h>
29
30#include "em2820.h"
31
32static unsigned int disable_ir = 0;
33module_param(disable_ir, int, 0444);
34MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
35
36static unsigned int ir_debug = 0;
37module_param(ir_debug, int, 0644);
38MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
39
40#define dprintk(fmt, arg...) if (ir_debug) \
41 printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg)
42
43/* ---------------------------------------------------------------------- */
44
45static IR_KEYTAB_TYPE ir_codes_em_pinnacle[IR_KEYTAB_SIZE] = {
46 [ 0 ] = KEY_CHANNEL,
47 [ 1 ] = KEY_SELECT,
48 [ 2 ] = KEY_MUTE,
49 [ 3 ] = KEY_POWER,
50 [ 4 ] = KEY_KP1,
51 [ 5 ] = KEY_KP2,
52 [ 6 ] = KEY_KP3,
53 [ 7 ] = KEY_CHANNELUP,
54 [ 8 ] = KEY_KP4,
55 [ 9 ] = KEY_KP5,
56 [ 10 ] = KEY_KP6,
57
58 [ 11 ] = KEY_CHANNELDOWN,
59 [ 12 ] = KEY_KP7,
60 [ 13 ] = KEY_KP8,
61 [ 14 ] = KEY_KP9,
62 [ 15 ] = KEY_VOLUMEUP,
63 [ 16 ] = KEY_KP0,
64 [ 17 ] = KEY_MENU,
65 [ 18 ] = KEY_PRINT,
66
67 [ 19 ] = KEY_VOLUMEDOWN,
68 [ 21 ] = KEY_PAUSE,
69 [ 23 ] = KEY_RECORD,
70 [ 24 ] = KEY_REWIND,
71 [ 25 ] = KEY_PLAY,
72 [ 27 ] = KEY_BACKSPACE,
73 [ 29 ] = KEY_STOP,
74 [ 31 ] = KEY_ZOOM,
75};
76
77/* ----------------------------------------------------------------------- */
78
79static int get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
80{
81 unsigned char buf[2];
82 unsigned char code;
83
84 /* poll IR chip */
85 if (2 != i2c_master_recv(&ir->c,buf,2))
86 return -EIO;
87
88 /* Does eliminate repeated parity code */
89 if (buf[1]==0xff)
90 return 0;
91
92 /* avoid fast reapeating */
93 if (buf[1]==ir->old)
94 return 0;
95 ir->old=buf[1];
96
97 /* Rearranges bits to the right order */
98 code= ((buf[0]&0x01)<<5) | /* 0010 0000 */
99 ((buf[0]&0x02)<<3) | /* 0001 0000 */
100 ((buf[0]&0x04)<<1) | /* 0000 1000 */
101 ((buf[0]&0x08)>>1) | /* 0000 0100 */
102 ((buf[0]&0x10)>>3) | /* 0000 0010 */
103 ((buf[0]&0x20)>>5); /* 0000 0001 */
104
105 dprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x)\n",code,buf[0]);
106
107 /* return key */
108 *ir_key = code;
109 *ir_raw = code;
110 return 1;
111}
112
113/* ----------------------------------------------------------------------- */
114void em2820_set_ir(struct em2820 * dev,struct IR_i2c *ir)
115{
116 if (disable_ir)
117 return ;
118
119 /* detect & configure */
120 switch (dev->model) {
121 case (EM2800_BOARD_UNKNOWN):
122 break;
123 case (EM2820_BOARD_UNKNOWN):
124 break;
125 case (EM2820_BOARD_TERRATEC_CINERGY_250):
126 break;
127 case (EM2820_BOARD_PINNACLE_USB_2):
128 ir->ir_codes = ir_codes_em_pinnacle;
129 break;
130 case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
131 ir->ir_codes = ir_codes_hauppauge_new;
132 ir->get_key = get_key_em_haup;
133 snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (EM2840 Hauppage)");
134 break;
135 case (EM2820_BOARD_MSI_VOX_USB_2):
136 break;
137 case (EM2800_BOARD_TERRATEC_CINERGY_200):
138 break;
139 case (EM2800_BOARD_LEADTEK_WINFAST_USBII):
140 break;
141 case (EM2800_BOARD_KWORLD_USB2800):
142 break;
143 }
144}
145
146/* ----------------------------------------------------------------------
147 * Local variables:
148 * c-basic-offset: 8
149 * End:
150 */