3 * handle saa7134 IR remotes via linux kernel input layer.
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.
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.
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
21 #include <linux/module.h>
22 #include <linux/init.h>
23 #include <linux/delay.h>
24 #include <linux/interrupt.h>
25 #include <linux/slab.h>
27 #include "saa7134-reg.h"
30 #define MODULE_NAME "saa7134"
32 static unsigned int disable_ir;
33 module_param(disable_ir, int, 0444);
34 MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
36 static unsigned int ir_debug;
37 module_param(ir_debug, int, 0644);
38 MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
40 static int pinnacle_remote;
41 module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */
42 MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)");
44 static int ir_rc5_remote_gap = 885;
45 module_param(ir_rc5_remote_gap, int, 0644);
47 static unsigned int disable_other_ir;
48 module_param(disable_other_ir, int, 0644);
49 MODULE_PARM_DESC(disable_other_ir, "disable full codes of "
50 "alternative remotes from other manufacturers");
52 #define dprintk(fmt, arg...) if (ir_debug) \
53 printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
54 #define i2cdprintk(fmt, arg...) if (ir_debug) \
55 printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg)
57 /* Helper function for raw decoding at GPIO16 or GPIO18 */
58 static int saa7134_raw_decode_irq(struct saa7134_dev *dev);
60 /* -------------------- GPIO generic keycode builder -------------------- */
62 static int build_key(struct saa7134_dev *dev)
64 struct card_ir *ir = dev->remote;
67 /* here comes the additional handshake steps for some cards */
69 case SAA7134_BOARD_GOTVIEW_7135:
70 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80);
71 saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80);
74 /* rising SAA7134_GPIO_GPRESCAN reads the status */
75 saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
76 saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
78 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
80 if (ir->last_gpio == gpio)
85 data = ir_extract_bits(gpio, ir->mask_keycode);
86 dprintk("build_key gpio=0x%x mask=0x%x data=%d\n",
87 gpio, ir->mask_keycode, data);
90 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
91 if (data == ir->mask_keycode)
94 ir_keydown_notimeout(ir->dev, data, 0);
99 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
100 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
101 ir_keydown_notimeout(ir->dev, data, 0);
106 else { /* IRQ driven mode - handle key press and release in one go */
107 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
108 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
109 ir_keydown_notimeout(ir->dev, data, 0);
117 /* --------------------- Chip specific I2C key builders ----------------- */
119 static int get_key_flydvb_trio(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
125 /* We need this to access GPI Used by the saa_readl macro. */
126 struct saa7134_dev *dev = ir->c->adapter->algo_data;
129 i2cdprintk("get_key_flydvb_trio: "
130 "ir->c->adapter->algo_data is NULL!\n");
134 /* rising SAA7134_GPIGPRESCAN reads the status */
135 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
136 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
138 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
141 return 0; /* No button press */
143 /* No button press - only before first key pressed */
148 /* weak up the IR chip */
151 while (1 != i2c_master_send(ir->c, &b, 1)) {
152 if ((attempt++) < 10) {
154 * wait a bit for next attempt -
155 * I don't know how make it better
160 i2cdprintk("send wake up byte to pic16C505 (IR chip)"
161 "failed %dx\n", attempt);
164 if (1 != i2c_master_recv(ir->c, &b, 1)) {
165 i2cdprintk("read error\n");
174 static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, u32 *ir_key,
180 /* <dev> is needed to access GPIO. Used by the saa_readl macro. */
181 struct saa7134_dev *dev = ir->c->adapter->algo_data;
183 i2cdprintk("get_key_msi_tvanywhere_plus: "
184 "ir->c->adapter->algo_data is NULL!\n");
188 /* rising SAA7134_GPIO_GPRESCAN reads the status */
190 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
191 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
193 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
195 /* GPIO&0x40 is pulsed low when a button is pressed. Don't do
196 I2C receive if gpio&0x40 is not low. */
199 return 0; /* No button press */
201 /* GPIO says there is a button press. Get it. */
203 if (1 != i2c_master_recv(ir->c, &b, 1)) {
204 i2cdprintk("read error\n");
208 /* No button press */
215 dprintk("get_key_msi_tvanywhere_plus: Key = 0x%02X\n", b);
221 static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
226 if (1 != i2c_master_recv(ir->c, &b, 1)) {
227 i2cdprintk("read error\n");
231 /* no button press */
244 static int get_key_hvr1110(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
246 unsigned char buf[5], cod4, code3, code4;
249 if (5 != i2c_master_recv(ir->c, buf, 5))
266 static int get_key_beholdm6xx(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
268 unsigned char data[12];
271 struct saa7134_dev *dev = ir->c->adapter->algo_data;
273 /* rising SAA7134_GPIO_GPRESCAN reads the status */
274 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
275 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
277 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
279 if (0x400000 & ~gpio)
280 return 0; /* No button press */
282 ir->c->addr = 0x5a >> 1;
284 if (12 != i2c_master_recv(ir->c, data, 12)) {
285 i2cdprintk("read error\n");
288 /* IR of this card normally decode signals NEC-standard from
289 * - Sven IHOO MT 5.1R remote. xxyye718
290 * - Sven DVD HD-10xx remote. xxyyf708
293 * So, skip not our, if disable full codes mode.
295 if (data[10] != 0x6b && data[11] != 0x86 && disable_other_ir)
298 /* Wrong data decode fix */
299 if (data[9] != (unsigned char)(~data[8]))
308 /* Common (grey or coloured) pinnacle PCTV remote handling
311 static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
312 int parity_offset, int marker, int code_modulo)
315 unsigned int start = 0,parity = 0,code = 0;
318 if (4 != i2c_master_recv(ir->c, b, 4)) {
319 i2cdprintk("read error\n");
323 for (start = 0; start < ARRAY_SIZE(b); start++) {
324 if (b[start] == marker) {
325 code=b[(start+parity_offset + 1) % 4];
326 parity=b[(start+parity_offset) % 4];
335 if (ir->old == parity)
340 /* drop special codes when a key is held down a long time for the grey controller
341 In this case, the second bit of the code is asserted */
342 if (marker == 0xfe && (code & 0x40))
350 i2cdprintk("Pinnacle PCTV key %02x\n", code);
355 /* The grey pinnacle PCTV remote
357 * There are one issue with this remote:
358 * - I2c packet does not change when the same key is pressed quickly. The workaround
359 * is to hold down each key for about half a second, so that another code is generated
360 * in the i2c packet, and the function can distinguish key presses.
362 * Sylvain Pasche <sylvain.pasche@gmail.com>
364 static int get_key_pinnacle_grey(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
367 return get_key_pinnacle(ir, ir_key, ir_raw, 1, 0xfe, 0xff);
371 /* The new pinnacle PCTV remote (with the colored buttons)
373 * Ricardo Cerqueira <v4l@cerqueira.org>
375 static int get_key_pinnacle_color(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
377 /* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE
379 * this is the only value that results in 42 unique
383 return get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88);
386 void saa7134_input_irq(struct saa7134_dev *dev)
390 if (!dev || !dev->remote)
397 if (!ir->polling && !ir->raw_decode) {
399 } else if (ir->raw_decode) {
400 saa7134_raw_decode_irq(dev);
404 static void saa7134_input_timer(unsigned long data)
406 struct saa7134_dev *dev = (struct saa7134_dev *)data;
407 struct card_ir *ir = dev->remote;
410 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
413 static void ir_raw_decode_timer_end(unsigned long data)
415 struct saa7134_dev *dev = (struct saa7134_dev *)data;
416 struct card_ir *ir = dev->remote;
418 ir_raw_event_handle(dev->remote->dev);
423 static int __saa7134_ir_start(void *priv)
425 struct saa7134_dev *dev = priv;
440 setup_timer(&ir->timer, saa7134_input_timer,
442 ir->timer.expires = jiffies + HZ;
443 add_timer(&ir->timer);
444 } else if (ir->raw_decode) {
445 /* set timer_end for code completion */
446 init_timer(&ir->timer_end);
447 ir->timer_end.function = ir_raw_decode_timer_end;
448 ir->timer_end.data = (unsigned long)dev;
455 static void __saa7134_ir_stop(void *priv)
457 struct saa7134_dev *dev = priv;
469 if (dev->remote->polling)
470 del_timer_sync(&dev->remote->timer);
471 else if (ir->raw_decode) {
472 del_timer_sync(&ir->timer_end);
481 int saa7134_ir_start(struct saa7134_dev *dev)
483 if (dev->remote->users)
484 return __saa7134_ir_start(dev);
489 void saa7134_ir_stop(struct saa7134_dev *dev)
491 if (dev->remote->users)
492 __saa7134_ir_stop(dev);
495 static int saa7134_ir_open(struct rc_dev *rc)
497 struct saa7134_dev *dev = rc->priv;
499 dev->remote->users++;
500 return __saa7134_ir_start(dev);
503 static void saa7134_ir_close(struct rc_dev *rc)
505 struct saa7134_dev *dev = rc->priv;
507 dev->remote->users--;
508 if (!dev->remote->users)
509 __saa7134_ir_stop(dev);
512 int saa7134_input_init1(struct saa7134_dev *dev)
516 char *ir_codes = NULL;
517 u32 mask_keycode = 0;
518 u32 mask_keydown = 0;
524 if (dev->has_remote != SAA7134_REMOTE_GPIO)
529 /* detect & configure */
530 switch (dev->board) {
531 case SAA7134_BOARD_FLYVIDEO2000:
532 case SAA7134_BOARD_FLYVIDEO3000:
533 case SAA7134_BOARD_FLYTVPLATINUM_FM:
534 case SAA7134_BOARD_FLYTVPLATINUM_MINI2:
535 case SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM:
536 ir_codes = RC_MAP_FLYVIDEO;
537 mask_keycode = 0xEC00000;
538 mask_keydown = 0x0040000;
540 case SAA7134_BOARD_CINERGY400:
541 case SAA7134_BOARD_CINERGY600:
542 case SAA7134_BOARD_CINERGY600_MK3:
543 ir_codes = RC_MAP_CINERGY;
544 mask_keycode = 0x00003f;
545 mask_keyup = 0x040000;
547 case SAA7134_BOARD_ECS_TVP3XP:
548 case SAA7134_BOARD_ECS_TVP3XP_4CB5:
549 ir_codes = RC_MAP_EZTV;
550 mask_keycode = 0x00017c;
551 mask_keyup = 0x000002;
554 case SAA7134_BOARD_KWORLD_XPERT:
555 case SAA7134_BOARD_AVACSSMARTTV:
556 ir_codes = RC_MAP_PIXELVIEW;
557 mask_keycode = 0x00001F;
558 mask_keyup = 0x000020;
561 case SAA7134_BOARD_MD2819:
562 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
563 case SAA7134_BOARD_AVERMEDIA_305:
564 case SAA7134_BOARD_AVERMEDIA_307:
565 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
566 case SAA7134_BOARD_AVERMEDIA_STUDIO_505:
567 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
568 case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
569 case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA:
570 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
571 case SAA7134_BOARD_AVERMEDIA_M102:
572 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS:
573 ir_codes = RC_MAP_AVERMEDIA;
574 mask_keycode = 0x0007C8;
575 mask_keydown = 0x000010;
577 /* Set GPIO pin2 to high to enable the IR controller */
578 saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
579 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
581 case SAA7134_BOARD_AVERMEDIA_M135A:
582 ir_codes = RC_MAP_AVERMEDIA_M135A;
583 mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */
584 mask_keyup = 0x0040000;
585 mask_keycode = 0xffff;
588 case SAA7134_BOARD_AVERMEDIA_M733A:
589 ir_codes = RC_MAP_AVERMEDIA_M733A_RM_K6;
590 mask_keydown = 0x0040000;
591 mask_keyup = 0x0040000;
592 mask_keycode = 0xffff;
595 case SAA7134_BOARD_AVERMEDIA_777:
596 case SAA7134_BOARD_AVERMEDIA_A16AR:
597 ir_codes = RC_MAP_AVERMEDIA;
598 mask_keycode = 0x02F200;
599 mask_keydown = 0x000400;
601 /* Without this we won't receive key up events */
602 saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
603 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
605 case SAA7134_BOARD_AVERMEDIA_A16D:
606 ir_codes = RC_MAP_AVERMEDIA_A16D;
607 mask_keycode = 0x02F200;
608 mask_keydown = 0x000400;
609 polling = 50; /* ms */
610 /* Without this we won't receive key up events */
611 saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
612 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
614 case SAA7134_BOARD_KWORLD_TERMINATOR:
615 ir_codes = RC_MAP_PIXELVIEW;
616 mask_keycode = 0x00001f;
617 mask_keyup = 0x000060;
620 case SAA7134_BOARD_MANLI_MTV001:
621 case SAA7134_BOARD_MANLI_MTV002:
622 ir_codes = RC_MAP_MANLI;
623 mask_keycode = 0x001f00;
624 mask_keyup = 0x004000;
625 polling = 50; /* ms */
627 case SAA7134_BOARD_BEHOLD_409FM:
628 case SAA7134_BOARD_BEHOLD_401:
629 case SAA7134_BOARD_BEHOLD_403:
630 case SAA7134_BOARD_BEHOLD_403FM:
631 case SAA7134_BOARD_BEHOLD_405:
632 case SAA7134_BOARD_BEHOLD_405FM:
633 case SAA7134_BOARD_BEHOLD_407:
634 case SAA7134_BOARD_BEHOLD_407FM:
635 case SAA7134_BOARD_BEHOLD_409:
636 case SAA7134_BOARD_BEHOLD_505FM:
637 case SAA7134_BOARD_BEHOLD_505RDS_MK5:
638 case SAA7134_BOARD_BEHOLD_505RDS_MK3:
639 case SAA7134_BOARD_BEHOLD_507_9FM:
640 case SAA7134_BOARD_BEHOLD_507RDS_MK3:
641 case SAA7134_BOARD_BEHOLD_507RDS_MK5:
642 ir_codes = RC_MAP_MANLI;
643 mask_keycode = 0x003f00;
644 mask_keyup = 0x004000;
645 polling = 50; /* ms */
647 case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM:
648 ir_codes = RC_MAP_BEHOLD_COLUMBUS;
649 mask_keycode = 0x003f00;
650 mask_keyup = 0x004000;
653 case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS:
654 ir_codes = RC_MAP_PCTV_SEDNA;
655 mask_keycode = 0x001f00;
656 mask_keyup = 0x004000;
659 case SAA7134_BOARD_GOTVIEW_7135:
660 ir_codes = RC_MAP_GOTVIEW7135;
661 mask_keycode = 0x0003CC;
662 mask_keydown = 0x000010;
663 polling = 5; /* ms */
664 saa_setb(SAA7134_GPIO_GPMODE1, 0x80);
666 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
667 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
668 case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
669 ir_codes = RC_MAP_VIDEOMATE_TV_PVR;
670 mask_keycode = 0x00003F;
671 mask_keyup = 0x400000;
674 case SAA7134_BOARD_PROTEUS_2309:
675 ir_codes = RC_MAP_PROTEUS_2309;
676 mask_keycode = 0x00007F;
677 mask_keyup = 0x000080;
680 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
681 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
682 ir_codes = RC_MAP_VIDEOMATE_TV_PVR;
683 mask_keycode = 0x003F00;
684 mask_keyup = 0x040000;
686 case SAA7134_BOARD_FLYDVBS_LR300:
687 case SAA7134_BOARD_FLYDVBT_LR301:
688 case SAA7134_BOARD_FLYDVBTDUO:
689 ir_codes = RC_MAP_FLYDVB;
690 mask_keycode = 0x0001F00;
691 mask_keydown = 0x0040000;
693 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
694 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
695 case SAA7134_BOARD_ASUSTeK_P7131_ANALOG:
696 ir_codes = RC_MAP_ASUS_PC39;
697 mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */
698 mask_keyup = 0x0040000;
699 mask_keycode = 0xffff;
702 case SAA7134_BOARD_ENCORE_ENLTV:
703 case SAA7134_BOARD_ENCORE_ENLTV_FM:
704 ir_codes = RC_MAP_ENCORE_ENLTV;
705 mask_keycode = 0x00007f;
706 mask_keyup = 0x040000;
709 case SAA7134_BOARD_ENCORE_ENLTV_FM53:
710 ir_codes = RC_MAP_ENCORE_ENLTV_FM53;
711 mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */
712 mask_keyup = 0x0040000;
713 mask_keycode = 0xffff;
716 case SAA7134_BOARD_10MOONSTVMASTER3:
717 ir_codes = RC_MAP_ENCORE_ENLTV;
718 mask_keycode = 0x5f80000;
719 mask_keyup = 0x8000000;
722 case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
723 ir_codes = RC_MAP_GENIUS_TVGO_A11MCE;
725 mask_keydown = 0xf00000;
726 polling = 50; /* ms */
728 case SAA7134_BOARD_REAL_ANGEL_220:
729 ir_codes = RC_MAP_REAL_AUDIO_220_32_KEYS;
730 mask_keycode = 0x3f00;
732 polling = 50; /* ms */
734 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
735 ir_codes = RC_MAP_KWORLD_PLUS_TV_ANALOG;
737 polling = 40; /* ms */
739 case SAA7134_BOARD_VIDEOMATE_S350:
740 ir_codes = RC_MAP_VIDEOMATE_S350;
741 mask_keycode = 0x003f00;
742 mask_keydown = 0x040000;
744 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
745 ir_codes = RC_MAP_WINFAST;
746 mask_keycode = 0x5f00;
747 mask_keyup = 0x020000;
748 polling = 50; /* ms */
751 if (NULL == ir_codes) {
752 printk("%s: Oops: IR config error [card=%d]\n",
753 dev->name, dev->board);
757 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
758 rc = rc_allocate_device();
769 /* init hardware-specific stuff */
770 ir->mask_keycode = mask_keycode;
771 ir->mask_keydown = mask_keydown;
772 ir->mask_keyup = mask_keyup;
773 ir->polling = polling;
774 ir->raw_decode = raw_decode;
776 /* init input device */
777 snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)",
778 saa7134_boards[dev->board].name);
779 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
783 rc->open = saa7134_ir_open;
784 rc->close = saa7134_ir_close;
786 rc->driver_type = RC_DRIVER_IR_RAW;
788 rc->input_name = ir->name;
789 rc->input_phys = ir->phys;
790 rc->input_id.bustype = BUS_PCI;
791 rc->input_id.version = 1;
792 if (dev->pci->subsystem_vendor) {
793 rc->input_id.vendor = dev->pci->subsystem_vendor;
794 rc->input_id.product = dev->pci->subsystem_device;
796 rc->input_id.vendor = dev->pci->vendor;
797 rc->input_id.product = dev->pci->device;
799 rc->dev.parent = &dev->pci->dev;
800 rc->map_name = ir_codes;
801 rc->driver_name = MODULE_NAME;
803 err = rc_register_device(rc);
816 void saa7134_input_fini(struct saa7134_dev *dev)
818 if (NULL == dev->remote)
821 saa7134_ir_stop(dev);
822 rc_unregister_device(dev->remote->dev);
827 void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
829 struct i2c_board_info info;
831 struct i2c_msg msg_msi = {
841 dprintk("IR has been disabled, not probing for i2c remote\n");
845 memset(&info, 0, sizeof(struct i2c_board_info));
846 memset(&dev->init_data, 0, sizeof(dev->init_data));
847 strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
849 switch (dev->board) {
850 case SAA7134_BOARD_PINNACLE_PCTV_110i:
851 case SAA7134_BOARD_PINNACLE_PCTV_310i:
852 dev->init_data.name = "Pinnacle PCTV";
853 if (pinnacle_remote == 0) {
854 dev->init_data.get_key = get_key_pinnacle_color;
855 dev->init_data.ir_codes = RC_MAP_PINNACLE_COLOR;
858 dev->init_data.get_key = get_key_pinnacle_grey;
859 dev->init_data.ir_codes = RC_MAP_PINNACLE_GREY;
863 case SAA7134_BOARD_UPMOST_PURPLE_TV:
864 dev->init_data.name = "Purple TV";
865 dev->init_data.get_key = get_key_purpletv;
866 dev->init_data.ir_codes = RC_MAP_PURPLETV;
869 case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS:
870 dev->init_data.name = "MSI TV@nywhere Plus";
871 dev->init_data.get_key = get_key_msi_tvanywhere_plus;
872 dev->init_data.ir_codes = RC_MAP_MSI_TVANYWHERE_PLUS;
874 * MSI TV@nyware Plus requires more frequent polling
875 * otherwise it will miss some keypresses
877 dev->init_data.polling_interval = 50;
879 /* MSI TV@nywhere Plus controller doesn't seem to
880 respond to probes unless we read something from
881 an existing device. Weird...
882 REVISIT: might no longer be needed */
883 rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
884 dprintk("probe 0x%02x @ %s: %s\n",
885 msg_msi.addr, dev->i2c_adap.name,
886 (1 == rc) ? "yes" : "no");
888 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
889 dev->init_data.name = "HVR 1110";
890 dev->init_data.get_key = get_key_hvr1110;
891 dev->init_data.ir_codes = RC_MAP_HAUPPAUGE_NEW;
894 case SAA7134_BOARD_BEHOLD_607FM_MK3:
895 case SAA7134_BOARD_BEHOLD_607FM_MK5:
896 case SAA7134_BOARD_BEHOLD_609FM_MK3:
897 case SAA7134_BOARD_BEHOLD_609FM_MK5:
898 case SAA7134_BOARD_BEHOLD_607RDS_MK3:
899 case SAA7134_BOARD_BEHOLD_607RDS_MK5:
900 case SAA7134_BOARD_BEHOLD_609RDS_MK3:
901 case SAA7134_BOARD_BEHOLD_609RDS_MK5:
902 case SAA7134_BOARD_BEHOLD_M6:
903 case SAA7134_BOARD_BEHOLD_M63:
904 case SAA7134_BOARD_BEHOLD_M6_EXTRA:
905 case SAA7134_BOARD_BEHOLD_H6:
906 case SAA7134_BOARD_BEHOLD_X7:
907 case SAA7134_BOARD_BEHOLD_H7:
908 case SAA7134_BOARD_BEHOLD_A7:
909 dev->init_data.name = "BeholdTV";
910 dev->init_data.get_key = get_key_beholdm6xx;
911 dev->init_data.ir_codes = RC_MAP_BEHOLD;
912 dev->init_data.type = IR_TYPE_NEC;
915 case SAA7134_BOARD_AVERMEDIA_CARDBUS_501:
916 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
919 case SAA7134_BOARD_FLYDVB_TRIO:
920 dev->init_data.name = "FlyDVB Trio";
921 dev->init_data.get_key = get_key_flydvb_trio;
922 dev->init_data.ir_codes = RC_MAP_FLYDVB;
926 dprintk("No I2C IR support for board %x\n", dev->board);
930 if (dev->init_data.name)
931 info.platform_data = &dev->init_data;
932 i2c_new_device(&dev->i2c_adap, &info);
935 static int saa7134_raw_decode_irq(struct saa7134_dev *dev)
937 struct card_ir *ir = dev->remote;
938 unsigned long timeout;
941 /* Generate initial event */
942 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
943 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
944 space = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown;
945 ir_raw_event_store_edge(dev->remote->dev, space ? IR_SPACE : IR_PULSE);
949 * Wait 15 ms from the start of the first IR event before processing
950 * the event. This time is enough for NEC protocol. May need adjustments
951 * to work with other protocols.
954 timeout = jiffies + jiffies_to_msecs(15);
955 mod_timer(&ir->timer_end, timeout);