V4L/DVB (7677): saa7134: Add/fix Beholder entries
[deliverable/linux.git] / drivers / media / video / saa7134 / saa7134-input.c
CommitLineData
1da177e4 1/*
1da177e4
LT
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>
1da177e4
LT
22#include <linux/init.h>
23#include <linux/delay.h>
1da177e4
LT
24#include <linux/interrupt.h>
25#include <linux/input.h>
26
27#include "saa7134-reg.h"
28#include "saa7134.h"
29
ff699e6b 30static unsigned int disable_ir;
1da177e4
LT
31module_param(disable_ir, int, 0444);
32MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
33
ff699e6b 34static unsigned int ir_debug;
1da177e4
LT
35module_param(ir_debug, int, 0644);
36MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
37
ff699e6b 38static int pinnacle_remote;
b93eedb6
SP
39module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */
40MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)");
41
c408a6f6 42static int ir_rc5_remote_gap = 885;
9160723e 43module_param(ir_rc5_remote_gap, int, 0644);
c408a6f6 44static int ir_rc5_key_timeout = 115;
9160723e
HP
45module_param(ir_rc5_key_timeout, int, 0644);
46
0938e319
P
47static int repeat_delay = 500;
48module_param(repeat_delay, int, 0644);
49MODULE_PARM_DESC(repeat_delay, "delay before key repeat started");
50static int repeat_period = 33;
51module_param(repeat_period, int, 0644);
ac9bb7f5 52MODULE_PARM_DESC(repeat_period, "repeat period between "
0938e319
P
53 "keypresses when key is down");
54
e8018c9e
AMT
55static unsigned int disable_other_ir;
56module_param(disable_other_ir, int, 0644);
57MODULE_PARM_DESC(disable_other_ir, "disable full codes of "
58 "alternative remotes from other manufacturers");
59
1da177e4
LT
60#define dprintk(fmt, arg...) if (ir_debug) \
61 printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
ac9cd976
RC
62#define i2cdprintk(fmt, arg...) if (ir_debug) \
63 printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg)
1da177e4 64
9160723e
HP
65/** rc5 functions */
66static int saa7134_rc5_irq(struct saa7134_dev *dev);
67
ac9cd976 68/* -------------------- GPIO generic keycode builder -------------------- */
1da177e4
LT
69
70static int build_key(struct saa7134_dev *dev)
71{
9160723e 72 struct card_ir *ir = dev->remote;
1da177e4
LT
73 u32 gpio, data;
74
0938e319
P
75 /* here comes the additional handshake steps for some cards */
76 switch (dev->board) {
77 case SAA7134_BOARD_GOTVIEW_7135:
78 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80);
79 saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80);
80 break;
81 }
1da177e4
LT
82 /* rising SAA7134_GPIO_GPRESCAN reads the status */
83 saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
84 saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
85
86 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
4ac97914
MCC
87 if (ir->polling) {
88 if (ir->last_gpio == gpio)
89 return 0;
90 ir->last_gpio = gpio;
91 }
1da177e4 92
4ac97914 93 data = ir_extract_bits(gpio, ir->mask_keycode);
1da177e4
LT
94 dprintk("build_key gpio=0x%x mask=0x%x data=%d\n",
95 gpio, ir->mask_keycode, data);
96
0602fbb2
PM
97 if (ir->polling) {
98 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
99 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
100 ir_input_keydown(ir->dev, &ir->ir, data, data);
101 } else {
102 ir_input_nokey(ir->dev, &ir->ir);
103 }
1da177e4 104 }
0602fbb2
PM
105 else { /* IRQ driven mode - handle key press and release in one go */
106 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
107 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
108 ir_input_keydown(ir->dev, &ir->ir, data, data);
109 ir_input_nokey(ir->dev, &ir->ir);
110 }
111 }
112
1da177e4
LT
113 return 0;
114}
115
ac9cd976
RC
116/* --------------------- Chip specific I2C key builders ----------------- */
117
118static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
119{
120 unsigned char b;
121
122 /* poll IR chip */
123 if (1 != i2c_master_recv(&ir->c,&b,1)) {
124 i2cdprintk("read error\n");
125 return -EIO;
126 }
127
128 /* no button press */
129 if (b==0)
130 return 0;
131
132 /* repeating */
133 if (b & 0x80)
134 return 1;
135
136 *ir_key = b;
137 *ir_raw = b;
138 return 1;
139}
140
177aaaf8
TG
141static int get_key_hvr1110(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
142{
143 unsigned char buf[5], cod4, code3, code4;
144
145 /* poll IR chip */
146 if (5 != i2c_master_recv(&ir->c,buf,5))
147 return -EIO;
148
149 cod4 = buf[4];
150 code4 = (cod4 >> 2);
151 code3 = buf[3];
152 if (code3 == 0)
153 /* no key pressed */
154 return 0;
155
156 /* return key */
157 *ir_key = code4;
158 *ir_raw = code4;
159 return 1;
160}
161
e8018c9e
AMT
162
163static int get_key_beholdm6xx(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
164{
165 unsigned char data[12];
166 u32 gpio;
167
168 struct saa7134_dev *dev = ir->c.adapter->algo_data;
169
170 /* rising SAA7134_GPIO_GPRESCAN reads the status */
171 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
172 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
173
174 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
175
616f8878 176 if (0x400000 & ~gpio)
e8018c9e
AMT
177 return 0; /* No button press */
178
179 ir->c.addr = 0x5a >> 1;
180
181 if (12 != i2c_master_recv(&ir->c, data, 12)) {
182 i2cdprintk("read error\n");
183 return -EIO;
184 }
185 /* IR of this card normally decode signals NEC-standard from
186 * - Sven IHOO MT 5.1R remote. xxyye718
187 * - Sven DVD HD-10xx remote. xxyyf708
188 * - BBK ...
189 * - mayby others
190 * So, skip not our, if disable full codes mode.
191 */
192 if (data[10] != 0x6b && data[11] != 0x86 && disable_other_ir)
193 return 0;
194
195 *ir_key = data[9];
196 *ir_raw = data[9];
197
198 return 1;
199}
200
1da177e4
LT
201void saa7134_input_irq(struct saa7134_dev *dev)
202{
9160723e 203 struct card_ir *ir = dev->remote;
1da177e4 204
9160723e 205 if (!ir->polling && !ir->rc5_gpio) {
1da177e4 206 build_key(dev);
9160723e
HP
207 } else if (ir->rc5_gpio) {
208 saa7134_rc5_irq(dev);
209 }
1da177e4
LT
210}
211
212static void saa7134_input_timer(unsigned long data)
213{
b4ba7884 214 struct saa7134_dev *dev = (struct saa7134_dev *)data;
9160723e 215 struct card_ir *ir = dev->remote;
1da177e4
LT
216
217 build_key(dev);
b4ba7884 218 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
1da177e4
LT
219}
220
c458473e 221void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
b07b4783
DT
222{
223 if (ir->polling) {
b4ba7884
DT
224 setup_timer(&ir->timer, saa7134_input_timer,
225 (unsigned long)dev);
b07b4783
DT
226 ir->timer.expires = jiffies + HZ;
227 add_timer(&ir->timer);
9160723e
HP
228 } else if (ir->rc5_gpio) {
229 /* set timer_end for code completion */
230 init_timer(&ir->timer_end);
231 ir->timer_end.function = ir_rc5_timer_end;
232 ir->timer_end.data = (unsigned long)ir;
233 init_timer(&ir->timer_keyup);
234 ir->timer_keyup.function = ir_rc5_timer_keyup;
235 ir->timer_keyup.data = (unsigned long)ir;
236 ir->shift_by = 2;
237 ir->start = 0x2;
238 ir->addr = 0x17;
239 ir->rc5_key_timeout = ir_rc5_key_timeout;
240 ir->rc5_remote_gap = ir_rc5_remote_gap;
b07b4783
DT
241 }
242}
243
c458473e 244void saa7134_ir_stop(struct saa7134_dev *dev)
b07b4783
DT
245{
246 if (dev->remote->polling)
247 del_timer_sync(&dev->remote->timer);
248}
249
1da177e4
LT
250int saa7134_input_init1(struct saa7134_dev *dev)
251{
9160723e 252 struct card_ir *ir;
b7df3910 253 struct input_dev *input_dev;
1da177e4
LT
254 IR_KEYTAB_TYPE *ir_codes = NULL;
255 u32 mask_keycode = 0;
256 u32 mask_keydown = 0;
257 u32 mask_keyup = 0;
258 int polling = 0;
9160723e 259 int rc5_gpio = 0;
1da177e4 260 int ir_type = IR_TYPE_OTHER;
b07b4783 261 int err;
1da177e4 262
cb2444df 263 if (dev->has_remote != SAA7134_REMOTE_GPIO)
1da177e4
LT
264 return -ENODEV;
265 if (disable_ir)
266 return -ENODEV;
267
268 /* detect & configure */
269 switch (dev->board) {
270 case SAA7134_BOARD_FLYVIDEO2000:
271 case SAA7134_BOARD_FLYVIDEO3000:
4ac97914 272 case SAA7134_BOARD_FLYTVPLATINUM_FM:
6af90ab5 273 case SAA7134_BOARD_FLYTVPLATINUM_MINI2:
4c0f631e 274 ir_codes = ir_codes_flyvideo;
1da177e4
LT
275 mask_keycode = 0xEC00000;
276 mask_keydown = 0x0040000;
277 break;
278 case SAA7134_BOARD_CINERGY400:
279 case SAA7134_BOARD_CINERGY600:
280 case SAA7134_BOARD_CINERGY600_MK3:
4c0f631e 281 ir_codes = ir_codes_cinergy;
1da177e4
LT
282 mask_keycode = 0x00003f;
283 mask_keyup = 0x040000;
284 break;
285 case SAA7134_BOARD_ECS_TVP3XP:
286 case SAA7134_BOARD_ECS_TVP3XP_4CB5:
4c0f631e 287 ir_codes = ir_codes_eztv;
330a115a
MCC
288 mask_keycode = 0x00017c;
289 mask_keyup = 0x000002;
1da177e4 290 polling = 50; // ms
330a115a
MCC
291 break;
292 case SAA7134_BOARD_KWORLD_XPERT:
1da177e4 293 case SAA7134_BOARD_AVACSSMARTTV:
b639f9d2 294 ir_codes = ir_codes_pixelview;
1da177e4
LT
295 mask_keycode = 0x00001F;
296 mask_keyup = 0x000020;
297 polling = 50; // ms
298 break;
299 case SAA7134_BOARD_MD2819:
ac19ecc6 300 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
1da177e4
LT
301 case SAA7134_BOARD_AVERMEDIA_305:
302 case SAA7134_BOARD_AVERMEDIA_307:
ac19ecc6
MCC
303 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
304 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
3ac706d2 305 case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
ac19ecc6 306 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
d2761f22 307 case SAA7134_BOARD_AVERMEDIA_M102:
b639f9d2 308 ir_codes = ir_codes_avermedia;
1da177e4
LT
309 mask_keycode = 0x0007C8;
310 mask_keydown = 0x000010;
311 polling = 50; // ms
312 /* Set GPIO pin2 to high to enable the IR controller */
313 saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
314 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
315 break;
450efcfd 316 case SAA7134_BOARD_AVERMEDIA_777:
29e0f1a1 317 case SAA7134_BOARD_AVERMEDIA_A16AR:
450efcfd 318 ir_codes = ir_codes_avermedia;
319 mask_keycode = 0x02F200;
320 mask_keydown = 0x000400;
321 polling = 50; // ms
322 /* Without this we won't receive key up events */
323 saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
324 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
4dd7406e 325 break;
4ac97914 326 case SAA7134_BOARD_KWORLD_TERMINATOR:
b639f9d2 327 ir_codes = ir_codes_pixelview;
dc2286cf
JW
328 mask_keycode = 0x00001f;
329 mask_keyup = 0x000060;
330 polling = 50; // ms
331 break;
ac19ecc6
MCC
332 case SAA7134_BOARD_MANLI_MTV001:
333 case SAA7134_BOARD_MANLI_MTV002:
b34dddbe
DB
334 ir_codes = ir_codes_manli;
335 mask_keycode = 0x001f00;
336 mask_keyup = 0x004000;
337 polling = 50; /* ms */
338 break;
a8ff417e 339 case SAA7134_BOARD_BEHOLD_409FM:
e8018c9e
AMT
340 case SAA7134_BOARD_BEHOLD_401:
341 case SAA7134_BOARD_BEHOLD_403:
342 case SAA7134_BOARD_BEHOLD_403FM:
343 case SAA7134_BOARD_BEHOLD_405:
344 case SAA7134_BOARD_BEHOLD_405FM:
345 case SAA7134_BOARD_BEHOLD_407:
346 case SAA7134_BOARD_BEHOLD_407FM:
347 case SAA7134_BOARD_BEHOLD_409:
348 case SAA7134_BOARD_BEHOLD_505FM:
349 case SAA7134_BOARD_BEHOLD_507_9FM:
4c0f631e 350 ir_codes = ir_codes_manli;
b34dddbe
DB
351 mask_keycode = 0x003f00;
352 mask_keyup = 0x004000;
353 polling = 50; /* ms */
354 break;
355 case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM:
356 ir_codes = ir_codes_behold_columbus;
357 mask_keycode = 0x003f00;
ac19ecc6 358 mask_keyup = 0x004000;
ac19ecc6
MCC
359 polling = 50; // ms
360 break;
17ce1ff9 361 case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS:
4c0f631e 362 ir_codes = ir_codes_pctv_sedna;
c3d93192
PM
363 mask_keycode = 0x001f00;
364 mask_keyup = 0x004000;
365 polling = 50; // ms
366 break;
4ac97914 367 case SAA7134_BOARD_GOTVIEW_7135:
4c0f631e 368 ir_codes = ir_codes_gotview7135;
0938e319 369 mask_keycode = 0x0003CC;
6b961440 370 mask_keydown = 0x000010;
0938e319
P
371 polling = 5; /* ms */
372 saa_setb(SAA7134_GPIO_GPMODE1, 0x80);
6b961440 373 break;
1da177e4 374 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
2a9a9a84 375 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
330a115a 376 case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
4c0f631e 377 ir_codes = ir_codes_videomate_tv_pvr;
1da177e4
LT
378 mask_keycode = 0x00003F;
379 mask_keyup = 0x400000;
380 polling = 50; // ms
381 break;
b04c1baf
MM
382 case SAA7134_BOARD_PROTEUS_2309:
383 ir_codes = ir_codes_proteus_2309;
384 mask_keycode = 0x00007F;
385 mask_keyup = 0x000080;
386 polling = 50; // ms
387 break;
4ac97914
MCC
388 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
389 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
4c0f631e 390 ir_codes = ir_codes_videomate_tv_pvr;
fea095fe
NS
391 mask_keycode = 0x003F00;
392 mask_keyup = 0x040000;
393 break;
f5c965ab 394 case SAA7134_BOARD_FLYDVBS_LR300:
3d8466ec 395 case SAA7134_BOARD_FLYDVBT_LR301:
a8029170 396 case SAA7134_BOARD_FLYDVBTDUO:
3d8466ec
GG
397 ir_codes = ir_codes_flydvb;
398 mask_keycode = 0x0001F00;
399 mask_keydown = 0x0040000;
400 break;
9160723e 401 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
904ab884 402 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
9160723e
HP
403 ir_codes = ir_codes_asus_pc39;
404 mask_keydown = 0x0040000;
405 rc5_gpio = 1;
406 break;
c36c459a
JPS
407 case SAA7134_BOARD_ENCORE_ENLTV:
408 case SAA7134_BOARD_ENCORE_ENLTV_FM:
409 ir_codes = ir_codes_encore_enltv;
410 mask_keycode = 0x00007f;
411 mask_keyup = 0x040000;
412 polling = 50; // ms
413 break;
480f75ac
TW
414 case SAA7134_BOARD_10MOONSTVMASTER3:
415 ir_codes = ir_codes_encore_enltv;
416 mask_keycode = 0x5f80000;
417 mask_keyup = 0x8000000;
418 polling = 50; //ms
419 break;
f0ba356c
AP
420 case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
421 ir_codes = ir_codes_genius_tvgo_a11mce;
422 mask_keycode = 0xff;
423 mask_keydown = 0xf00000;
424 polling = 50; /* ms */
425 break;
1da177e4
LT
426 }
427 if (NULL == ir_codes) {
428 printk("%s: Oops: IR config error [card=%d]\n",
429 dev->name, dev->board);
430 return -ENODEV;
431 }
432
b7df3910
DT
433 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
434 input_dev = input_allocate_device();
435 if (!ir || !input_dev) {
b07b4783
DT
436 err = -ENOMEM;
437 goto err_out_free;
b7df3910 438 }
1da177e4 439
d271d1c2
DT
440 ir->dev = input_dev;
441
1da177e4
LT
442 /* init hardware-specific stuff */
443 ir->mask_keycode = mask_keycode;
444 ir->mask_keydown = mask_keydown;
445 ir->mask_keyup = mask_keyup;
4ac97914 446 ir->polling = polling;
9160723e 447 ir->rc5_gpio = rc5_gpio;
1da177e4
LT
448
449 /* init input device */
450 snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)",
451 saa7134_boards[dev->board].name);
452 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
453 pci_name(dev->pci));
454
b7df3910
DT
455 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
456 input_dev->name = ir->name;
457 input_dev->phys = ir->phys;
458 input_dev->id.bustype = BUS_PCI;
459 input_dev->id.version = 1;
1da177e4 460 if (dev->pci->subsystem_vendor) {
b7df3910
DT
461 input_dev->id.vendor = dev->pci->subsystem_vendor;
462 input_dev->id.product = dev->pci->subsystem_device;
1da177e4 463 } else {
b7df3910
DT
464 input_dev->id.vendor = dev->pci->vendor;
465 input_dev->id.product = dev->pci->device;
1da177e4 466 }
2c8a3a33 467 input_dev->dev.parent = &dev->pci->dev;
1da177e4 468
1da177e4 469 dev->remote = ir;
b07b4783
DT
470 saa7134_ir_start(dev, ir);
471
472 err = input_register_device(ir->dev);
473 if (err)
474 goto err_out_stop;
1da177e4 475
0938e319
P
476 /* the remote isn't as bouncy as a keyboard */
477 ir->dev->rep[REP_DELAY] = repeat_delay;
478 ir->dev->rep[REP_PERIOD] = repeat_period;
479
1da177e4 480 return 0;
b07b4783
DT
481
482 err_out_stop:
483 saa7134_ir_stop(dev);
484 dev->remote = NULL;
485 err_out_free:
486 input_free_device(input_dev);
487 kfree(ir);
488 return err;
1da177e4
LT
489}
490
491void saa7134_input_fini(struct saa7134_dev *dev)
492{
493 if (NULL == dev->remote)
494 return;
495
b07b4783 496 saa7134_ir_stop(dev);
b7df3910 497 input_unregister_device(dev->remote->dev);
1da177e4
LT
498 kfree(dev->remote);
499 dev->remote = NULL;
500}
501
ac9cd976
RC
502void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir)
503{
504 if (disable_ir) {
cb2444df 505 dprintk("Found supported i2c remote, but IR has been disabled\n");
ac9cd976
RC
506 ir->get_key=NULL;
507 return;
508 }
509
510 switch (dev->board) {
511 case SAA7134_BOARD_PINNACLE_PCTV_110i:
eb591af3 512 case SAA7134_BOARD_PINNACLE_PCTV_310i:
ac9cd976 513 snprintf(ir->c.name, sizeof(ir->c.name), "Pinnacle PCTV");
b93eedb6
SP
514 if (pinnacle_remote == 0) {
515 ir->get_key = get_key_pinnacle_color;
516 ir->ir_codes = ir_codes_pinnacle_color;
517 } else {
518 ir->get_key = get_key_pinnacle_grey;
519 ir->ir_codes = ir_codes_pinnacle_grey;
520 }
ac9cd976
RC
521 break;
522 case SAA7134_BOARD_UPMOST_PURPLE_TV:
523 snprintf(ir->c.name, sizeof(ir->c.name), "Purple TV");
524 ir->get_key = get_key_purpletv;
525 ir->ir_codes = ir_codes_purpletv;
526 break;
177aaaf8
TG
527 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
528 snprintf(ir->c.name, sizeof(ir->c.name), "HVR 1110");
529 ir->get_key = get_key_hvr1110;
530 ir->ir_codes = ir_codes_hauppauge_new;
531 break;
e8018c9e
AMT
532 case SAA7134_BOARD_BEHOLD_607_9FM:
533 case SAA7134_BOARD_BEHOLD_M6:
534 snprintf(ir->c.name, sizeof(ir->c.name), "BeholdTV");
535 ir->get_key = get_key_beholdm6xx;
536 ir->ir_codes = ir_codes_behold;
537 break;
ac9cd976
RC
538 default:
539 dprintk("Shouldn't get here: Unknown board %x for I2C IR?\n",dev->board);
540 break;
541 }
542
543}
9160723e
HP
544
545static int saa7134_rc5_irq(struct saa7134_dev *dev)
546{
547 struct card_ir *ir = dev->remote;
548 struct timeval tv;
549 u32 gap;
550 unsigned long current_jiffies, timeout;
551
552 /* get time of bit */
553 current_jiffies = jiffies;
554 do_gettimeofday(&tv);
555
556 /* avoid overflow with gap >1s */
557 if (tv.tv_sec - ir->base_time.tv_sec > 1) {
558 gap = 200000;
559 } else {
560 gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
561 tv.tv_usec - ir->base_time.tv_usec;
562 }
563
564 /* active code => add bit */
565 if (ir->active) {
566 /* only if in the code (otherwise spurious IRQ or timer
567 late) */
568 if (ir->last_bit < 28) {
569 ir->last_bit = (gap - ir_rc5_remote_gap / 2) /
570 ir_rc5_remote_gap;
571 ir->code |= 1 << ir->last_bit;
572 }
573 /* starting new code */
574 } else {
575 ir->active = 1;
576 ir->code = 0;
577 ir->base_time = tv;
578 ir->last_bit = 0;
579
580 timeout = current_jiffies + (500 + 30 * HZ) / 1000;
581 mod_timer(&ir->timer_end, timeout);
582 }
583
584 return 1;
585}
586
1da177e4
LT
587/* ----------------------------------------------------------------------
588 * Local variables:
589 * c-basic-offset: 8
590 * End:
591 */
This page took 0.475254 seconds and 5 git commands to generate.