]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/media/video/cx88/cx88-input.c
649bbf7bcc2943b6deeebc3376f00c493564eb94
[karo-tx-linux.git] / drivers / media / video / cx88 / cx88-input.c
1 /*
2  *
3  * Device driver for GPIO attached remote control interfaces
4  * on Conexant 2388x based TV/DVB cards.
5  *
6  * Copyright (c) 2003 Pavel Machek
7  * Copyright (c) 2004 Gerd Knorr
8  * Copyright (c) 2004 Chris Pascoe
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24
25 #include <linux/init.h>
26 #include <linux/delay.h>
27 #include <linux/input.h>
28 #include <linux/pci.h>
29 #include <linux/module.h>
30 #include <linux/moduleparam.h>
31
32 #include "cx88.h"
33 #include <media/ir-common.h>
34
35 /* ---------------------------------------------------------------------- */
36
37 /* DigitalNow DNTV Live DVB-T Remote */
38 static IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE] = {
39         [0x00] = KEY_ESC,               /* 'go up a level?' */
40         /* Keys 0 to 9 */
41         [0x0a] = KEY_KP0,
42         [0x01] = KEY_KP1,
43         [0x02] = KEY_KP2,
44         [0x03] = KEY_KP3,
45         [0x04] = KEY_KP4,
46         [0x05] = KEY_KP5,
47         [0x06] = KEY_KP6,
48         [0x07] = KEY_KP7,
49         [0x08] = KEY_KP8,
50         [0x09] = KEY_KP9,
51
52         [0x0b] = KEY_TUNER,             /* tv/fm */
53         [0x0c] = KEY_SEARCH,            /* scan */
54         [0x0d] = KEY_STOP,
55         [0x0e] = KEY_PAUSE,
56         [0x0f] = KEY_LIST,              /* source */
57
58         [0x10] = KEY_MUTE,
59         [0x11] = KEY_REWIND,            /* backward << */
60         [0x12] = KEY_POWER,
61         [0x13] = KEY_S,                 /* snap */
62         [0x14] = KEY_AUDIO,             /* stereo */
63         [0x15] = KEY_CLEAR,             /* reset */
64         [0x16] = KEY_PLAY,
65         [0x17] = KEY_ENTER,
66         [0x18] = KEY_ZOOM,              /* full screen */
67         [0x19] = KEY_FASTFORWARD,       /* forward >> */
68         [0x1a] = KEY_CHANNELUP,
69         [0x1b] = KEY_VOLUMEUP,
70         [0x1c] = KEY_INFO,              /* preview */
71         [0x1d] = KEY_RECORD,            /* record */
72         [0x1e] = KEY_CHANNELDOWN,
73         [0x1f] = KEY_VOLUMEDOWN,
74 };
75
76 /* ---------------------------------------------------------------------- */
77
78 /* IO-DATA BCTV7E Remote */
79 static IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE] = {
80         [0x40] = KEY_TV,
81         [0x20] = KEY_RADIO,             /* FM */
82         [0x60] = KEY_EPG,
83         [0x00] = KEY_POWER,
84
85         /* Keys 0 to 9 */
86         [0x44] = KEY_KP0,               /* 10 */
87         [0x50] = KEY_KP1,
88         [0x30] = KEY_KP2,
89         [0x70] = KEY_KP3,
90         [0x48] = KEY_KP4,
91         [0x28] = KEY_KP5,
92         [0x68] = KEY_KP6,
93         [0x58] = KEY_KP7,
94         [0x38] = KEY_KP8,
95         [0x78] = KEY_KP9,
96
97         [0x10] = KEY_L,                 /* Live */
98         [0x08] = KEY_T,                 /* Time Shift */
99
100         [0x18] = KEY_PLAYPAUSE,         /* Play */
101
102         [0x24] = KEY_ENTER,             /* 11 */
103         [0x64] = KEY_ESC,               /* 12 */
104         [0x04] = KEY_M,                 /* Multi */
105
106         [0x54] = KEY_VIDEO,
107         [0x34] = KEY_CHANNELUP,
108         [0x74] = KEY_VOLUMEUP,
109         [0x14] = KEY_MUTE,
110
111         [0x4c] = KEY_S,                 /* SVIDEO */
112         [0x2c] = KEY_CHANNELDOWN,
113         [0x6c] = KEY_VOLUMEDOWN,
114         [0x0c] = KEY_ZOOM,
115
116         [0x5c] = KEY_PAUSE,
117         [0x3c] = KEY_C,                 /* || (red) */
118         [0x7c] = KEY_RECORD,            /* recording */
119         [0x1c] = KEY_STOP,
120
121         [0x41] = KEY_REWIND,            /* backward << */
122         [0x21] = KEY_PLAY,
123         [0x61] = KEY_FASTFORWARD,       /* forward >> */
124         [0x01] = KEY_NEXT,              /* skip >| */
125 };
126
127 /* ---------------------------------------------------------------------- */
128
129 /* ADS Tech Instant TV DVB-T PCI Remote */
130 static IR_KEYTAB_TYPE ir_codes_adstech_dvb_t_pci[IR_KEYTAB_SIZE] = {
131         /* Keys 0 to 9 */
132         [0x4d] = KEY_0,
133         [0x57] = KEY_1,
134         [0x4f] = KEY_2,
135         [0x53] = KEY_3,
136         [0x56] = KEY_4,
137         [0x4e] = KEY_5,
138         [0x5e] = KEY_6,
139         [0x54] = KEY_7,
140         [0x4c] = KEY_8,
141         [0x5c] = KEY_9,
142
143         [0x5b] = KEY_POWER,
144         [0x5f] = KEY_MUTE,
145         [0x55] = KEY_GOTO,
146         [0x5d] = KEY_SEARCH,
147         [0x17] = KEY_EPG,               /* Guide */
148         [0x1f] = KEY_MENU,
149         [0x0f] = KEY_UP,
150         [0x46] = KEY_DOWN,
151         [0x16] = KEY_LEFT,
152         [0x1e] = KEY_RIGHT,
153         [0x0e] = KEY_SELECT,            /* Enter */
154         [0x5a] = KEY_INFO,
155         [0x52] = KEY_EXIT,
156         [0x59] = KEY_PREVIOUS,
157         [0x51] = KEY_NEXT,
158         [0x58] = KEY_REWIND,
159         [0x50] = KEY_FORWARD,
160         [0x44] = KEY_PLAYPAUSE,
161         [0x07] = KEY_STOP,
162         [0x1b] = KEY_RECORD,
163         [0x13] = KEY_TUNER,             /* Live */
164         [0x0a] = KEY_A,
165         [0x12] = KEY_B,
166         [0x03] = KEY_PROG1,             /* 1 */
167         [0x01] = KEY_PROG2,             /* 2 */
168         [0x00] = KEY_PROG3,             /* 3 */
169         [0x06] = KEY_DVD,
170         [0x48] = KEY_AUX,               /* Photo */
171         [0x40] = KEY_VIDEO,
172         [0x19] = KEY_AUDIO,             /* Music */
173         [0x0b] = KEY_CHANNELUP,
174         [0x08] = KEY_CHANNELDOWN,
175         [0x15] = KEY_VOLUMEUP,
176         [0x1c] = KEY_VOLUMEDOWN,
177 };
178
179 /* ---------------------------------------------------------------------- */
180
181 /* MSI TV@nywhere remote */
182 static IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE] = {
183         /* Keys 0 to 9 */
184         [0x00] = KEY_0,
185         [0x01] = KEY_1,
186         [0x02] = KEY_2,
187         [0x03] = KEY_3,
188         [0x04] = KEY_4,
189         [0x05] = KEY_5,
190         [0x06] = KEY_6,
191         [0x07] = KEY_7,
192         [0x08] = KEY_8,
193         [0x09] = KEY_9,
194
195         [0x0c] = KEY_MUTE,
196         [0x0f] = KEY_SCREEN,            /* Full Screen */
197         [0x10] = KEY_F,                 /* Funtion */
198         [0x11] = KEY_T,                 /* Time shift */
199         [0x12] = KEY_POWER,
200         [0x13] = KEY_MEDIA,             /* MTS */
201         [0x14] = KEY_SLOW,
202         [0x16] = KEY_REWIND,            /* backward << */
203         [0x17] = KEY_ENTER,             /* Return */
204         [0x18] = KEY_FASTFORWARD,       /* forward >> */
205         [0x1a] = KEY_CHANNELUP,
206         [0x1b] = KEY_VOLUMEUP,
207         [0x1e] = KEY_CHANNELDOWN,
208         [0x1f] = KEY_VOLUMEDOWN,
209 };
210
211 /* ---------------------------------------------------------------------- */
212
213 /* Cinergy 1400 DVB-T */
214 static IR_KEYTAB_TYPE ir_codes_cinergy_1400[IR_KEYTAB_SIZE] = {
215         [0x01] = KEY_POWER,
216         [0x02] = KEY_1,
217         [0x03] = KEY_2,
218         [0x04] = KEY_3,
219         [0x05] = KEY_4,
220         [0x06] = KEY_5,
221         [0x07] = KEY_6,
222         [0x08] = KEY_7,
223         [0x09] = KEY_8,
224         [0x0a] = KEY_9,
225         [0x0c] = KEY_0,
226
227         [0x0b] = KEY_VIDEO,
228         [0x0d] = KEY_REFRESH,
229         [0x0e] = KEY_SELECT,
230         [0x0f] = KEY_EPG,
231         [0x10] = KEY_UP,
232         [0x11] = KEY_LEFT,
233         [0x12] = KEY_OK,
234         [0x13] = KEY_RIGHT,
235         [0x14] = KEY_DOWN,
236         [0x15] = KEY_TEXT,
237         [0x16] = KEY_INFO,
238
239         [0x17] = KEY_RED,
240         [0x18] = KEY_GREEN,
241         [0x19] = KEY_YELLOW,
242         [0x1a] = KEY_BLUE,
243
244         [0x1b] = KEY_CHANNELUP,
245         [0x1c] = KEY_VOLUMEUP,
246         [0x1d] = KEY_MUTE,
247         [0x1e] = KEY_VOLUMEDOWN,
248         [0x1f] = KEY_CHANNELDOWN,
249
250         [0x40] = KEY_PAUSE,
251         [0x4c] = KEY_PLAY,
252         [0x58] = KEY_RECORD,
253         [0x54] = KEY_PREVIOUS,
254         [0x48] = KEY_STOP,
255         [0x5c] = KEY_NEXT,
256 };
257
258 /* ---------------------------------------------------------------------- */
259
260 /* AVERTV STUDIO 303 Remote */
261 static IR_KEYTAB_TYPE ir_codes_avertv_303[IR_KEYTAB_SIZE] = {
262         [ 0x2a ] = KEY_KP1,
263         [ 0x32 ] = KEY_KP2,
264         [ 0x3a ] = KEY_KP3,
265         [ 0x4a ] = KEY_KP4,
266         [ 0x52 ] = KEY_KP5,
267         [ 0x5a ] = KEY_KP6,
268         [ 0x6a ] = KEY_KP7,
269         [ 0x72 ] = KEY_KP8,
270         [ 0x7a ] = KEY_KP9,
271         [ 0x0e ] = KEY_KP0,
272
273         [ 0x02 ] = KEY_POWER,
274         [ 0x22 ] = KEY_VIDEO,
275         [ 0x42 ] = KEY_AUDIO,
276         [ 0x62 ] = KEY_ZOOM,
277         [ 0x0a ] = KEY_TV,
278         [ 0x12 ] = KEY_CD,
279         [ 0x1a ] = KEY_TEXT,
280
281         [ 0x16 ] = KEY_SUBTITLE,
282         [ 0x1e ] = KEY_REWIND,
283         [ 0x06 ] = KEY_PRINT,
284
285         [ 0x2e ] = KEY_SEARCH,
286         [ 0x36 ] = KEY_SLEEP,
287         [ 0x3e ] = KEY_SHUFFLE,
288         [ 0x26 ] = KEY_MUTE,
289
290         [ 0x4e ] = KEY_RECORD,
291         [ 0x56 ] = KEY_PAUSE,
292         [ 0x5e ] = KEY_STOP,
293         [ 0x46 ] = KEY_PLAY,
294
295         [ 0x6e ] = KEY_RED,
296         [ 0x0b ] = KEY_GREEN,
297         [ 0x66 ] = KEY_YELLOW,
298         [ 0x03 ] = KEY_BLUE,
299
300         [ 0x76 ] = KEY_LEFT,
301         [ 0x7e ] = KEY_RIGHT,
302         [ 0x13 ] = KEY_DOWN,
303         [ 0x1b ] = KEY_UP,
304 };
305
306 /* ---------------------------------------------------------------------- */
307
308 struct cx88_IR {
309         struct cx88_core *core;
310         struct input_dev *input;
311         struct ir_input_state ir;
312         char name[32];
313         char phys[32];
314
315         /* sample from gpio pin 16 */
316         int sampling;
317         u32 samples[16];
318         int scount;
319         unsigned long release;
320
321         /* poll external decoder */
322         int polling;
323         struct work_struct work;
324         struct timer_list timer;
325         u32 gpio_addr;
326         u32 last_gpio;
327         u32 mask_keycode;
328         u32 mask_keydown;
329         u32 mask_keyup;
330 };
331
332 static int ir_debug = 0;
333 module_param(ir_debug, int, 0644);      /* debug level [IR] */
334 MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
335
336 #define ir_dprintk(fmt, arg...) if (ir_debug) \
337         printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg)
338
339 /* ---------------------------------------------------------------------- */
340
341 static void cx88_ir_handle_key(struct cx88_IR *ir)
342 {
343         struct cx88_core *core = ir->core;
344         u32 gpio, data;
345
346         /* read gpio value */
347         gpio = cx_read(ir->gpio_addr);
348         if (ir->polling) {
349                 if (ir->last_gpio == gpio)
350                         return;
351                 ir->last_gpio = gpio;
352         }
353
354         /* extract data */
355         data = ir_extract_bits(gpio, ir->mask_keycode);
356         ir_dprintk("irq gpio=0x%x code=%d | %s%s%s\n",
357                    gpio, data,
358                    ir->polling ? "poll" : "irq",
359                    (gpio & ir->mask_keydown) ? " down" : "",
360                    (gpio & ir->mask_keyup) ? " up" : "");
361
362         if (ir->mask_keydown) {
363                 /* bit set on keydown */
364                 if (gpio & ir->mask_keydown) {
365                         ir_input_keydown(ir->input, &ir->ir, data, data);
366                 } else {
367                         ir_input_nokey(ir->input, &ir->ir);
368                 }
369
370         } else if (ir->mask_keyup) {
371                 /* bit cleared on keydown */
372                 if (0 == (gpio & ir->mask_keyup)) {
373                         ir_input_keydown(ir->input, &ir->ir, data, data);
374                 } else {
375                         ir_input_nokey(ir->input, &ir->ir);
376                 }
377
378         } else {
379                 /* can't distinguish keydown/up :-/ */
380                 ir_input_keydown(ir->input, &ir->ir, data, data);
381                 ir_input_nokey(ir->input, &ir->ir);
382         }
383 }
384
385 static void ir_timer(unsigned long data)
386 {
387         struct cx88_IR *ir = (struct cx88_IR *)data;
388
389         schedule_work(&ir->work);
390 }
391
392 static void cx88_ir_work(void *data)
393 {
394         struct cx88_IR *ir = data;
395         unsigned long timeout;
396
397         cx88_ir_handle_key(ir);
398         timeout = jiffies + (ir->polling * HZ / 1000);
399         mod_timer(&ir->timer, timeout);
400 }
401
402 /* ---------------------------------------------------------------------- */
403
404 int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
405 {
406         struct cx88_IR *ir;
407         struct input_dev *input_dev;
408         IR_KEYTAB_TYPE *ir_codes = NULL;
409         int ir_type = IR_TYPE_OTHER;
410
411         ir = kzalloc(sizeof(*ir), GFP_KERNEL);
412         input_dev = input_allocate_device();
413         if (!ir || !input_dev) {
414                 kfree(ir);
415                 input_free_device(input_dev);
416                 return -ENOMEM;
417         }
418
419         ir->input = input_dev;
420
421         /* detect & configure */
422         switch (core->board) {
423         case CX88_BOARD_DNTV_LIVE_DVB_T:
424         case CX88_BOARD_KWORLD_DVB_T:
425                 ir_codes = ir_codes_dntv_live_dvb_t;
426                 ir->gpio_addr = MO_GP1_IO;
427                 ir->mask_keycode = 0x1f;
428                 ir->mask_keyup = 0x60;
429                 ir->polling = 50; /* ms */
430                 break;
431         case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
432                 ir_codes = ir_codes_cinergy_1400;
433                 ir_type = IR_TYPE_PD;
434                 ir->sampling = 1;
435                 break;
436         case CX88_BOARD_HAUPPAUGE:
437         case CX88_BOARD_HAUPPAUGE_DVB_T1:
438         case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
439         case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
440         case CX88_BOARD_HAUPPAUGE_HVR1100:
441                 ir_codes = ir_codes_hauppauge_new;
442                 ir_type = IR_TYPE_RC5;
443                 ir->sampling = 1;
444                 break;
445         case CX88_BOARD_WINFAST2000XP_EXPERT:
446                 ir_codes = ir_codes_winfast;
447                 ir->gpio_addr = MO_GP0_IO;
448                 ir->mask_keycode = 0x8f8;
449                 ir->mask_keyup = 0x100;
450                 ir->polling = 1; /* ms */
451                 break;
452         case CX88_BOARD_IODATA_GVBCTV7E:
453                 ir_codes = ir_codes_iodata_bctv7e;
454                 ir->gpio_addr = MO_GP0_IO;
455                 ir->mask_keycode = 0xfd;
456                 ir->mask_keydown = 0x02;
457                 ir->polling = 5; /* ms */
458                 break;
459         case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO:
460                 ir_codes = ir_codes_pixelview;
461                 ir->gpio_addr = MO_GP1_IO;
462                 ir->mask_keycode = 0x1f;
463                 ir->mask_keyup = 0x80;
464                 ir->polling = 1; /* ms */
465                 break;
466         case CX88_BOARD_ADSTECH_DVB_T_PCI:
467                 ir_codes = ir_codes_adstech_dvb_t_pci;
468                 ir->gpio_addr = MO_GP1_IO;
469                 ir->mask_keycode = 0xbf;
470                 ir->mask_keyup = 0x40;
471                 ir->polling = 50; /* ms */
472                 break;
473         case CX88_BOARD_MSI_TVANYWHERE_MASTER:
474                 ir_codes = ir_codes_msi_tvanywhere;
475                 ir->gpio_addr = MO_GP1_IO;
476                 ir->mask_keycode = 0x1f;
477                 ir->mask_keyup = 0x40;
478                 ir->polling = 1; /* ms */
479                 break;
480         case CX88_BOARD_AVERTV_303:
481                 ir_codes         = ir_codes_avertv_303;
482                 ir->gpio_addr    = MO_GP2_IO;
483                 ir->mask_keycode = 0xfb;
484                 ir->mask_keydown = 0x02;
485                 ir->polling      = 50; /* ms */
486                 break;
487         }
488
489         if (NULL == ir_codes) {
490                 kfree(ir);
491                 input_free_device(input_dev);
492                 return -ENODEV;
493         }
494
495         /* init input device */
496         snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)",
497                  cx88_boards[core->board].name);
498         snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
499
500         ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
501         input_dev->name = ir->name;
502         input_dev->phys = ir->phys;
503         input_dev->id.bustype = BUS_PCI;
504         input_dev->id.version = 1;
505         if (pci->subsystem_vendor) {
506                 input_dev->id.vendor = pci->subsystem_vendor;
507                 input_dev->id.product = pci->subsystem_device;
508         } else {
509                 input_dev->id.vendor = pci->vendor;
510                 input_dev->id.product = pci->device;
511         }
512         input_dev->cdev.dev = &pci->dev;
513         /* record handles to ourself */
514         ir->core = core;
515         core->ir = ir;
516
517         if (ir->polling) {
518                 INIT_WORK(&ir->work, cx88_ir_work, ir);
519                 init_timer(&ir->timer);
520                 ir->timer.function = ir_timer;
521                 ir->timer.data = (unsigned long)ir;
522                 schedule_work(&ir->work);
523         }
524         if (ir->sampling) {
525                 core->pci_irqmask |= (1 << 18); /* IR_SMP_INT */
526                 cx_write(MO_DDS_IO, 0xa80a80);  /* 4 kHz sample rate */
527                 cx_write(MO_DDSCFG_IO, 0x5);    /* enable */
528         }
529
530         /* all done */
531         input_register_device(ir->input);
532
533         return 0;
534 }
535
536 int cx88_ir_fini(struct cx88_core *core)
537 {
538         struct cx88_IR *ir = core->ir;
539
540         /* skip detach on non attached boards */
541         if (NULL == ir)
542                 return 0;
543
544         if (ir->polling) {
545                 del_timer(&ir->timer);
546                 flush_scheduled_work();
547         }
548
549         input_unregister_device(ir->input);
550         kfree(ir);
551
552         /* done */
553         core->ir = NULL;
554         return 0;
555 }
556
557 /* ---------------------------------------------------------------------- */
558
559 void cx88_ir_irq(struct cx88_core *core)
560 {
561         struct cx88_IR *ir = core->ir;
562         u32 samples, ircode;
563         int i;
564
565         if (NULL == ir)
566                 return;
567         if (!ir->sampling)
568                 return;
569
570         samples = cx_read(MO_SAMPLE_IO);
571         if (0 != samples && 0xffffffff != samples) {
572                 /* record sample data */
573                 if (ir->scount < ARRAY_SIZE(ir->samples))
574                         ir->samples[ir->scount++] = samples;
575                 return;
576         }
577         if (!ir->scount) {
578                 /* nothing to sample */
579                 if (ir->ir.keypressed && time_after(jiffies, ir->release))
580                         ir_input_nokey(ir->input, &ir->ir);
581                 return;
582         }
583
584         /* have a complete sample */
585         if (ir->scount < ARRAY_SIZE(ir->samples))
586                 ir->samples[ir->scount++] = samples;
587         for (i = 0; i < ir->scount; i++)
588                 ir->samples[i] = ~ir->samples[i];
589         if (ir_debug)
590                 ir_dump_samples(ir->samples, ir->scount);
591
592         /* decode it */
593         switch (core->board) {
594         case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
595                 ircode = ir_decode_pulsedistance(ir->samples, ir->scount, 1, 4);
596
597                 if (ircode == 0xffffffff) { /* decoding error */
598                         ir_dprintk("pulse distance decoding error\n");
599                         break;
600                 }
601
602                 ir_dprintk("pulse distance decoded: %x\n", ircode);
603
604                 if (ircode == 0) { /* key still pressed */
605                         ir_dprintk("pulse distance decoded repeat code\n");
606                         ir->release = jiffies + msecs_to_jiffies(120);
607                         break;
608                 }
609
610                 if ((ircode & 0xffff) != 0xeb04) { /* wrong address */
611                         ir_dprintk("pulse distance decoded wrong address\n");
612                         break;
613                 }
614
615                 if (((~ircode >> 24) & 0xff) != ((ircode >> 16) & 0xff)) { /* wrong checksum */
616                         ir_dprintk("pulse distance decoded wrong check sum\n");
617                         break;
618                 }
619
620                 ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f);
621
622                 ir_input_keydown(ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff);
623                 ir->release = jiffies + msecs_to_jiffies(120);
624                 break;
625         case CX88_BOARD_HAUPPAUGE:
626         case CX88_BOARD_HAUPPAUGE_DVB_T1:
627         case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
628         case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
629                 ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
630                 ir_dprintk("biphase decoded: %x\n", ircode);
631                 if ((ircode & 0xfffff000) != 0x3000)
632                         break;
633                 ir_input_keydown(ir->input, &ir->ir, ircode & 0x3f, ircode);
634                 ir->release = jiffies + msecs_to_jiffies(120);
635                 break;
636         }
637
638         ir->scount = 0;
639         return;
640 }
641
642 /* ---------------------------------------------------------------------- */
643
644 MODULE_AUTHOR("Gerd Knorr, Pavel Machek, Chris Pascoe");
645 MODULE_DESCRIPTION("input driver for cx88 GPIO-based IR remote controls");
646 MODULE_LICENSE("GPL");
647 /*
648  * Local variables:
649  * c-basic-offset: 8
650  * End:
651  */