21 #include <linux/module.h>
25 #include <linux/slab.h>
30 #define MODULE_NAME "saa7134"
32 static unsigned int disable_ir;
36 static unsigned int ir_debug;
40 static int pinnacle_remote;
42 MODULE_PARM_DESC(pinnacle_remote,
"Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)");
44 #define dprintk(fmt, arg...) if (ir_debug) \
45 printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
46 #define i2cdprintk(fmt, arg...) if (ir_debug) \
47 printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg)
78 dprintk(
"build_key gpio=0x%x mask=0x%x data=%d\n",
111 static int get_key_flydvb_trio(
struct IR_i2c *ir,
u32 *ir_key,
u32 *ir_raw)
122 "ir->c->adapter->algo_data is NULL!\n");
144 if ((attempt++) < 10) {
152 i2cdprintk(
"send wake up byte to pic16C505 (IR chip)"
153 "failed %dx\n", attempt);
166 static int get_key_msi_tvanywhere_plus(
struct IR_i2c *ir,
u32 *ir_key,
176 "ir->c->adapter->algo_data is NULL!\n");
207 dprintk(
"get_key_msi_tvanywhere_plus: Key = 0x%02X\n", b);
214 static int get_key_kworld_pc150u(
struct IR_i2c *ir,
u32 *ir_key,
224 "ir->c->adapter->algo_data is NULL!\n");
255 dprintk(
"get_key_kworld_pc150u: Key = 0x%02X\n", b);
261 static int get_key_purpletv(
struct IR_i2c *ir,
u32 *ir_key,
u32 *ir_raw)
284 static int get_key_hvr1110(
struct IR_i2c *ir,
u32 *ir_key,
u32 *ir_raw)
286 unsigned char buf[5];
293 if (!(buf[0] & 0x80))
303 *ir_key = 0x1fff & ((buf[3] << 8) | (buf[4] >> 2));
309 static int get_key_beholdm6xx(
struct IR_i2c *ir,
u32 *ir_key,
u32 *ir_raw)
311 unsigned char data[12];
322 if (0x400000 & ~gpio)
325 ir->
c->addr = 0x5a >> 1;
332 if (data[9] != (
unsigned char)(~data[8]))
335 *ir_raw = ((data[10] << 16) | (data[11] << 8) | (data[9] << 0));
344 static int get_key_pinnacle(
struct IR_i2c *ir,
u32 *ir_key,
u32 *ir_raw,
345 int parity_offset,
int marker,
int code_modulo)
356 for (start = 0; start <
ARRAY_SIZE(b); start++) {
357 if (b[start] == marker) {
358 code=b[(start+parity_offset + 1) % 4];
359 parity=b[(start+parity_offset) % 4];
368 if (ir->
old == parity)
375 if (marker == 0xfe && (
code & 0x40))
397 static int get_key_pinnacle_grey(
struct IR_i2c *ir,
u32 *ir_key,
u32 *ir_raw)
400 return get_key_pinnacle(ir, ir_key, ir_raw, 1, 0xfe, 0xff);
408 static int get_key_pinnacle_color(
struct IR_i2c *ir,
u32 *ir_key,
u32 *ir_raw)
416 return get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88);
433 saa7134_raw_decode_irq(dev);
437 static void saa7134_input_timer(
unsigned long data)
446 static void ir_raw_decode_timer_end(
unsigned long data)
453 static int __saa7134_ir_start(
void *
priv)
467 switch (dev->
board) {
516 static void __saa7134_ir_stop(
void *priv)
539 return __saa7134_ir_start(dev);
547 __saa7134_ir_stop(dev);
550 static int saa7134_ir_open(
struct rc_dev *
rc)
555 return __saa7134_ir_start(dev);
558 static void saa7134_ir_close(
struct rc_dev *
rc)
564 __saa7134_ir_stop(dev);
571 char *ir_codes =
NULL;
572 u32 mask_keycode = 0;
573 u32 mask_keydown = 0;
575 unsigned polling = 0;
576 bool raw_decode =
false;
585 switch (dev->
board) {
592 mask_keycode = 0xEC00000;
593 mask_keydown = 0x0040000;
599 mask_keycode = 0x00003f;
600 mask_keyup = 0x040000;
605 mask_keycode = 0x00017c;
606 mask_keyup = 0x000002;
612 mask_keycode = 0x00001F;
613 mask_keyup = 0x000020;
629 mask_keycode = 0x0007C8;
630 mask_keydown = 0x000010;
636 mask_keydown = 0x0040000;
637 mask_keyup = 0x0040000;
638 mask_keycode = 0xffff;
643 mask_keydown = 0x0040000;
644 mask_keyup = 0x0040000;
645 mask_keycode = 0xffff;
651 mask_keycode = 0x02F200;
652 mask_keydown = 0x000400;
658 mask_keycode = 0x02F200;
659 mask_keydown = 0x000400;
665 mask_keycode = 0x00001f;
666 mask_keyup = 0x000060;
672 mask_keycode = 0x001f00;
673 mask_keyup = 0x004000;
692 mask_keycode = 0x003f00;
693 mask_keyup = 0x004000;
698 mask_keycode = 0x003f00;
699 mask_keyup = 0x004000;
704 mask_keycode = 0x001f00;
705 mask_keyup = 0x004000;
710 mask_keycode = 0x0003CC;
711 mask_keydown = 0x000010;
719 mask_keycode = 0x00003F;
720 mask_keyup = 0x400000;
725 mask_keycode = 0x00007F;
726 mask_keyup = 0x000080;
732 mask_keycode = 0x003F00;
733 mask_keyup = 0x040000;
739 mask_keycode = 0x0001F00;
740 mask_keydown = 0x0040000;
746 mask_keydown = 0x0040000;
747 mask_keyup = 0x0040000;
748 mask_keycode = 0xffff;
753 mask_keydown = 0x0040000;
754 mask_keyup = 0x0040000;
755 mask_keycode = 0xffff;
761 mask_keycode = 0x00007f;
762 mask_keyup = 0x040000;
768 mask_keydown = 0x0040000;
769 mask_keyup = 0x0040000;
770 mask_keycode = 0xffff;
775 mask_keycode = 0x5f80000;
776 mask_keyup = 0x8000000;
782 mask_keydown = 0xf00000;
787 mask_keycode = 0x3f00;
798 mask_keycode = 0x003f00;
799 mask_keydown = 0x040000;
803 mask_keycode = 0x5f00;
804 mask_keyup = 0x020000;
809 mask_keycode = 0x0ff00;
810 mask_keyup = 0x040000;
815 mask_keydown = 0x0040000;
816 mask_keyup = 0x0040000;
817 mask_keycode = 0xffff;
821 if (
NULL == ir_codes) {
822 printk(
"%s: Oops: IR config error [card=%d]\n",
851 rc->
open = saa7134_ir_open;
852 rc->
close = saa7134_ir_close;
860 if (dev->
pci->subsystem_vendor) {
867 rc->
dev.parent = &dev->
pci->dev;
907 dprintk(
"IR has been disabled, not probing for i2c remote\n");
915 switch (dev->
board) {
919 if (pinnacle_remote == 0) {
920 dev->
init_data.get_key = get_key_pinnacle_color;
924 dev->
init_data.get_key = get_key_pinnacle_grey;
931 dev->
init_data.get_key = get_key_purpletv;
936 dev->
init_data.name =
"MSI TV@nywhere Plus";
937 dev->
init_data.get_key = get_key_msi_tvanywhere_plus;
950 dprintk(
"probe 0x%02x @ %s: %s\n",
952 (1 == rc) ?
"yes" :
"no");
957 dev->
init_data.get_key = get_key_kworld_pc150u;
965 dprintk(
"probe 0x%02x @ %s: %s\n",
967 (1 == rc) ?
"yes" :
"no");
971 dev->
init_data.get_key = get_key_hvr1110;
991 dev->
init_data.get_key = get_key_beholdm6xx;
1002 dev->
init_data.get_key = get_key_flydvb_trio;
1007 dprintk(
"No I2C IR support for board %x\n", dev->
board);
1016 static int saa7134_raw_decode_irq(
struct saa7134_dev *dev)
1035 if (!timer_pending(&ir->
timer)) {