1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * handle saa7134 IR remotes via linux kernel input layer.
8 #include "saa7134-reg.h"
10 #include <linux/module.h>
11 #include <linux/init.h>
12 #include <linux/delay.h>
13 #include <linux/interrupt.h>
14 #include <linux/slab.h>
16 #define MODULE_NAME "saa7134"
18 static unsigned int disable_ir
;
19 module_param(disable_ir
, int, 0444);
20 MODULE_PARM_DESC(disable_ir
,"disable infrared remote support");
22 static unsigned int ir_debug
;
23 module_param(ir_debug
, int, 0644);
24 MODULE_PARM_DESC(ir_debug
,"enable debug messages [IR]");
26 static int pinnacle_remote
;
27 module_param(pinnacle_remote
, int, 0644); /* Choose Pinnacle PCTV remote */
28 MODULE_PARM_DESC(pinnacle_remote
, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)");
30 #define input_dbg(fmt, arg...) do { \
32 printk(KERN_DEBUG pr_fmt("input: " fmt), ## arg); \
34 #define ir_dbg(ir, fmt, arg...) do { \
36 printk(KERN_DEBUG pr_fmt("ir %s: " fmt), ir->rc->device_name, \
40 /* Helper function for raw decoding at GPIO16 or GPIO18 */
41 static int saa7134_raw_decode_irq(struct saa7134_dev
*dev
);
43 /* -------------------- GPIO generic keycode builder -------------------- */
45 static int build_key(struct saa7134_dev
*dev
)
47 struct saa7134_card_ir
*ir
= dev
->remote
;
50 /* here comes the additional handshake steps for some cards */
52 case SAA7134_BOARD_GOTVIEW_7135
:
53 saa_setb(SAA7134_GPIO_GPSTATUS1
, 0x80);
54 saa_clearb(SAA7134_GPIO_GPSTATUS1
, 0x80);
57 /* rising SAA7134_GPIO_GPRESCAN reads the status */
58 saa_clearb(SAA7134_GPIO_GPMODE3
,SAA7134_GPIO_GPRESCAN
);
59 saa_setb(SAA7134_GPIO_GPMODE3
,SAA7134_GPIO_GPRESCAN
);
61 gpio
= saa_readl(SAA7134_GPIO_GPSTATUS0
>> 2);
63 if (ir
->last_gpio
== gpio
)
68 data
= ir_extract_bits(gpio
, ir
->mask_keycode
);
69 input_dbg("build_key gpio=0x%x mask=0x%x data=%d\n",
70 gpio
, ir
->mask_keycode
, data
);
73 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG
:
74 if (data
== ir
->mask_keycode
)
77 rc_keydown_notimeout(ir
->dev
, RC_PROTO_UNKNOWN
, data
,
83 if ((ir
->mask_keydown
&& (0 != (gpio
& ir
->mask_keydown
))) ||
84 (ir
->mask_keyup
&& (0 == (gpio
& ir
->mask_keyup
)))) {
85 rc_keydown_notimeout(ir
->dev
, RC_PROTO_UNKNOWN
, data
,
91 else { /* IRQ driven mode - handle key press and release in one go */
92 if ((ir
->mask_keydown
&& (0 != (gpio
& ir
->mask_keydown
))) ||
93 (ir
->mask_keyup
&& (0 == (gpio
& ir
->mask_keyup
)))) {
94 rc_keydown_notimeout(ir
->dev
, RC_PROTO_UNKNOWN
, data
,
103 /* --------------------- Chip specific I2C key builders ----------------- */
105 static int get_key_flydvb_trio(struct IR_i2c
*ir
, enum rc_proto
*protocol
,
106 u32
*scancode
, u8
*toggle
)
112 /* We need this to access GPI Used by the saa_readl macro. */
113 struct saa7134_dev
*dev
= ir
->c
->adapter
->algo_data
;
116 ir_dbg(ir
, "get_key_flydvb_trio: ir->c->adapter->algo_data is NULL!\n");
120 /* rising SAA7134_GPIGPRESCAN reads the status */
121 saa_clearb(SAA7134_GPIO_GPMODE3
, SAA7134_GPIO_GPRESCAN
);
122 saa_setb(SAA7134_GPIO_GPMODE3
, SAA7134_GPIO_GPRESCAN
);
124 gpio
= saa_readl(SAA7134_GPIO_GPSTATUS0
>> 2);
127 return 0; /* No button press */
130 /* weak up the IR chip */
133 while (1 != i2c_master_send(ir
->c
, &b
, 1)) {
134 if ((attempt
++) < 10) {
136 * wait a bit for next attempt -
137 * I don't know how make it better
142 ir_dbg(ir
, "send wake up byte to pic16C505 (IR chip)failed %dx\n",
146 rc
= i2c_master_recv(ir
->c
, &b
, 1);
148 ir_dbg(ir
, "read error\n");
154 *protocol
= RC_PROTO_UNKNOWN
;
160 static int get_key_msi_tvanywhere_plus(struct IR_i2c
*ir
,
161 enum rc_proto
*protocol
,
162 u32
*scancode
, u8
*toggle
)
167 /* <dev> is needed to access GPIO. Used by the saa_readl macro. */
168 struct saa7134_dev
*dev
= ir
->c
->adapter
->algo_data
;
170 ir_dbg(ir
, "get_key_msi_tvanywhere_plus: ir->c->adapter->algo_data is NULL!\n");
174 /* rising SAA7134_GPIO_GPRESCAN reads the status */
176 saa_clearb(SAA7134_GPIO_GPMODE3
, SAA7134_GPIO_GPRESCAN
);
177 saa_setb(SAA7134_GPIO_GPMODE3
, SAA7134_GPIO_GPRESCAN
);
179 gpio
= saa_readl(SAA7134_GPIO_GPSTATUS0
>> 2);
181 /* GPIO&0x40 is pulsed low when a button is pressed. Don't do
182 I2C receive if gpio&0x40 is not low. */
185 return 0; /* No button press */
187 /* GPIO says there is a button press. Get it. */
189 rc
= i2c_master_recv(ir
->c
, &b
, 1);
191 ir_dbg(ir
, "read error\n");
197 /* No button press */
204 input_dbg("get_key_msi_tvanywhere_plus: Key = 0x%02X\n", b
);
205 *protocol
= RC_PROTO_UNKNOWN
;
211 /* copied and modified from get_key_msi_tvanywhere_plus() */
212 static int get_key_kworld_pc150u(struct IR_i2c
*ir
, enum rc_proto
*protocol
,
213 u32
*scancode
, u8
*toggle
)
219 /* <dev> is needed to access GPIO. Used by the saa_readl macro. */
220 struct saa7134_dev
*dev
= ir
->c
->adapter
->algo_data
;
222 ir_dbg(ir
, "get_key_kworld_pc150u: ir->c->adapter->algo_data is NULL!\n");
226 /* rising SAA7134_GPIO_GPRESCAN reads the status */
228 saa_clearb(SAA7134_GPIO_GPMODE3
, SAA7134_GPIO_GPRESCAN
);
229 saa_setb(SAA7134_GPIO_GPMODE3
, SAA7134_GPIO_GPRESCAN
);
231 gpio
= saa_readl(SAA7134_GPIO_GPSTATUS0
>> 2);
233 /* GPIO&0x100 is pulsed low when a button is pressed. Don't do
234 I2C receive if gpio&0x100 is not low. */
237 return 0; /* No button press */
239 /* GPIO says there is a button press. Get it. */
241 rc
= i2c_master_recv(ir
->c
, &b
, 1);
243 ir_dbg(ir
, "read error\n");
249 /* No button press */
256 input_dbg("get_key_kworld_pc150u: Key = 0x%02X\n", b
);
257 *protocol
= RC_PROTO_UNKNOWN
;
263 static int get_key_purpletv(struct IR_i2c
*ir
, enum rc_proto
*protocol
,
264 u32
*scancode
, u8
*toggle
)
270 rc
= i2c_master_recv(ir
->c
, &b
, 1);
272 ir_dbg(ir
, "read error\n");
278 /* no button press */
286 *protocol
= RC_PROTO_UNKNOWN
;
292 static int get_key_beholdm6xx(struct IR_i2c
*ir
, enum rc_proto
*protocol
,
293 u32
*scancode
, u8
*toggle
)
296 unsigned char data
[12];
299 struct saa7134_dev
*dev
= ir
->c
->adapter
->algo_data
;
301 /* rising SAA7134_GPIO_GPRESCAN reads the status */
302 saa_clearb(SAA7134_GPIO_GPMODE3
, SAA7134_GPIO_GPRESCAN
);
303 saa_setb(SAA7134_GPIO_GPMODE3
, SAA7134_GPIO_GPRESCAN
);
305 gpio
= saa_readl(SAA7134_GPIO_GPSTATUS0
>> 2);
307 if (0x400000 & ~gpio
)
308 return 0; /* No button press */
310 ir
->c
->addr
= 0x5a >> 1;
312 rc
= i2c_master_recv(ir
->c
, data
, 12);
314 ir_dbg(ir
, "read error\n");
320 if (data
[9] != (unsigned char)(~data
[8]))
323 *protocol
= RC_PROTO_NECX
;
324 *scancode
= RC_SCANCODE_NECX(data
[11] << 8 | data
[10], data
[9]);
329 /* Common (grey or coloured) pinnacle PCTV remote handling
332 static int get_key_pinnacle(struct IR_i2c
*ir
, enum rc_proto
*protocol
,
333 u32
*scancode
, u8
*toggle
, int parity_offset
,
334 int marker
, int code_modulo
)
338 unsigned int start
= 0,parity
= 0,code
= 0;
341 rc
= i2c_master_recv(ir
->c
, b
, 4);
343 ir_dbg(ir
, "read error\n");
349 for (start
= 0; start
< ARRAY_SIZE(b
); start
++) {
350 if (b
[start
] == marker
) {
351 code
=b
[(start
+parity_offset
+ 1) % 4];
352 parity
=b
[(start
+parity_offset
) % 4];
361 if (ir
->old
== parity
)
366 /* drop special codes when a key is held down a long time for the grey controller
367 In this case, the second bit of the code is asserted */
368 if (marker
== 0xfe && (code
& 0x40))
373 *protocol
= RC_PROTO_UNKNOWN
;
377 ir_dbg(ir
, "Pinnacle PCTV key %02x\n", code
);
381 /* The grey pinnacle PCTV remote
383 * There are one issue with this remote:
384 * - I2c packet does not change when the same key is pressed quickly. The workaround
385 * is to hold down each key for about half a second, so that another code is generated
386 * in the i2c packet, and the function can distinguish key presses.
388 * Sylvain Pasche <sylvain.pasche@gmail.com>
390 static int get_key_pinnacle_grey(struct IR_i2c
*ir
, enum rc_proto
*protocol
,
391 u32
*scancode
, u8
*toggle
)
394 return get_key_pinnacle(ir
, protocol
, scancode
, toggle
, 1, 0xfe, 0xff);
398 /* The new pinnacle PCTV remote (with the colored buttons)
400 * Ricardo Cerqueira <v4l@cerqueira.org>
402 static int get_key_pinnacle_color(struct IR_i2c
*ir
, enum rc_proto
*protocol
,
403 u32
*scancode
, u8
*toggle
)
405 /* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE
407 * this is the only value that results in 42 unique
411 return get_key_pinnacle(ir
, protocol
, scancode
, toggle
, 2, 0x80, 0x88);
414 void saa7134_input_irq(struct saa7134_dev
*dev
)
416 struct saa7134_card_ir
*ir
;
418 if (!dev
|| !dev
->remote
)
425 if (!ir
->polling
&& !ir
->raw_decode
) {
427 } else if (ir
->raw_decode
) {
428 saa7134_raw_decode_irq(dev
);
432 static void saa7134_input_timer(struct timer_list
*t
)
434 struct saa7134_card_ir
*ir
= from_timer(ir
, t
, timer
);
435 struct saa7134_dev
*dev
= ir
->dev
->priv
;
438 mod_timer(&ir
->timer
, jiffies
+ msecs_to_jiffies(ir
->polling
));
441 int saa7134_ir_open(struct rc_dev
*rc
)
443 struct saa7134_dev
*dev
= rc
->priv
;
444 struct saa7134_card_ir
*ir
= dev
->remote
;
446 /* Moved here from saa7134_input_init1() because the latter
447 * is not called on device resume */
448 switch (dev
->board
) {
449 case SAA7134_BOARD_MD2819
:
450 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT
:
451 case SAA7134_BOARD_AVERMEDIA_305
:
452 case SAA7134_BOARD_AVERMEDIA_307
:
453 case SAA7134_BOARD_AVERMEDIA_505
:
454 case SAA7134_BOARD_AVERMEDIA_STUDIO_305
:
455 case SAA7134_BOARD_AVERMEDIA_STUDIO_505
:
456 case SAA7134_BOARD_AVERMEDIA_STUDIO_307
:
457 case SAA7134_BOARD_AVERMEDIA_STUDIO_507
:
458 case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA
:
459 case SAA7134_BOARD_AVERMEDIA_GO_007_FM
:
460 case SAA7134_BOARD_AVERMEDIA_M102
:
461 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS
:
462 /* Without this we won't receive key up events */
463 saa_setb(SAA7134_GPIO_GPMODE0
, 0x4);
464 saa_setb(SAA7134_GPIO_GPSTATUS0
, 0x4);
466 case SAA7134_BOARD_AVERMEDIA_777
:
467 case SAA7134_BOARD_AVERMEDIA_A16AR
:
468 /* Without this we won't receive key up events */
469 saa_setb(SAA7134_GPIO_GPMODE1
, 0x1);
470 saa_setb(SAA7134_GPIO_GPSTATUS1
, 0x1);
472 case SAA7134_BOARD_AVERMEDIA_A16D
:
473 /* Without this we won't receive key up events */
474 saa_setb(SAA7134_GPIO_GPMODE1
, 0x1);
475 saa_setb(SAA7134_GPIO_GPSTATUS1
, 0x1);
477 case SAA7134_BOARD_GOTVIEW_7135
:
478 saa_setb(SAA7134_GPIO_GPMODE1
, 0x80);
485 timer_setup(&ir
->timer
, saa7134_input_timer
, 0);
486 ir
->timer
.expires
= jiffies
+ HZ
;
487 add_timer(&ir
->timer
);
493 void saa7134_ir_close(struct rc_dev
*rc
)
495 struct saa7134_dev
*dev
= rc
->priv
;
496 struct saa7134_card_ir
*ir
= dev
->remote
;
499 del_timer_sync(&ir
->timer
);
504 int saa7134_input_init1(struct saa7134_dev
*dev
)
506 struct saa7134_card_ir
*ir
;
508 char *ir_codes
= NULL
;
509 u32 mask_keycode
= 0;
510 u32 mask_keydown
= 0;
512 unsigned polling
= 0;
513 bool raw_decode
= false;
516 if (dev
->has_remote
!= SAA7134_REMOTE_GPIO
)
521 /* detect & configure */
522 switch (dev
->board
) {
523 case SAA7134_BOARD_FLYVIDEO2000
:
524 case SAA7134_BOARD_FLYVIDEO3000
:
525 case SAA7134_BOARD_FLYTVPLATINUM_FM
:
526 case SAA7134_BOARD_FLYTVPLATINUM_MINI2
:
527 case SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM
:
528 ir_codes
= RC_MAP_FLYVIDEO
;
529 mask_keycode
= 0xEC00000;
530 mask_keydown
= 0x0040000;
532 case SAA7134_BOARD_CINERGY400
:
533 case SAA7134_BOARD_CINERGY600
:
534 case SAA7134_BOARD_CINERGY600_MK3
:
535 ir_codes
= RC_MAP_CINERGY
;
536 mask_keycode
= 0x00003f;
537 mask_keyup
= 0x040000;
539 case SAA7134_BOARD_ECS_TVP3XP
:
540 case SAA7134_BOARD_ECS_TVP3XP_4CB5
:
541 ir_codes
= RC_MAP_EZTV
;
542 mask_keycode
= 0x00017c;
543 mask_keyup
= 0x000002;
546 case SAA7134_BOARD_KWORLD_XPERT
:
547 case SAA7134_BOARD_AVACSSMARTTV
:
548 ir_codes
= RC_MAP_PIXELVIEW
;
549 mask_keycode
= 0x00001F;
550 mask_keyup
= 0x000020;
553 case SAA7134_BOARD_MD2819
:
554 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT
:
555 case SAA7134_BOARD_AVERMEDIA_305
:
556 case SAA7134_BOARD_AVERMEDIA_307
:
557 case SAA7134_BOARD_AVERMEDIA_505
:
558 case SAA7134_BOARD_AVERMEDIA_STUDIO_305
:
559 case SAA7134_BOARD_AVERMEDIA_STUDIO_505
:
560 case SAA7134_BOARD_AVERMEDIA_STUDIO_307
:
561 case SAA7134_BOARD_AVERMEDIA_STUDIO_507
:
562 case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA
:
563 case SAA7134_BOARD_AVERMEDIA_GO_007_FM
:
564 case SAA7134_BOARD_AVERMEDIA_M102
:
565 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS
:
566 ir_codes
= RC_MAP_AVERMEDIA
;
567 mask_keycode
= 0x0007C8;
568 mask_keydown
= 0x000010;
570 /* GPIO stuff moved to saa7134_ir_open() */
572 case SAA7134_BOARD_AVERMEDIA_M135A
:
573 ir_codes
= RC_MAP_AVERMEDIA_M135A
;
574 mask_keydown
= 0x0040000; /* Enable GPIO18 line on both edges */
575 mask_keyup
= 0x0040000;
576 mask_keycode
= 0xffff;
579 case SAA7134_BOARD_AVERMEDIA_M733A
:
580 ir_codes
= RC_MAP_AVERMEDIA_M733A_RM_K6
;
581 mask_keydown
= 0x0040000;
582 mask_keyup
= 0x0040000;
583 mask_keycode
= 0xffff;
586 case SAA7134_BOARD_AVERMEDIA_777
:
587 case SAA7134_BOARD_AVERMEDIA_A16AR
:
588 ir_codes
= RC_MAP_AVERMEDIA
;
589 mask_keycode
= 0x02F200;
590 mask_keydown
= 0x000400;
592 /* GPIO stuff moved to saa7134_ir_open() */
594 case SAA7134_BOARD_AVERMEDIA_A16D
:
595 ir_codes
= RC_MAP_AVERMEDIA_A16D
;
596 mask_keycode
= 0x02F200;
597 mask_keydown
= 0x000400;
598 polling
= 50; /* ms */
599 /* GPIO stuff moved to saa7134_ir_open() */
601 case SAA7134_BOARD_KWORLD_TERMINATOR
:
602 ir_codes
= RC_MAP_PIXELVIEW
;
603 mask_keycode
= 0x00001f;
604 mask_keyup
= 0x000060;
607 case SAA7134_BOARD_MANLI_MTV001
:
608 case SAA7134_BOARD_MANLI_MTV002
:
609 ir_codes
= RC_MAP_MANLI
;
610 mask_keycode
= 0x001f00;
611 mask_keyup
= 0x004000;
612 polling
= 50; /* ms */
614 case SAA7134_BOARD_BEHOLD_409FM
:
615 case SAA7134_BOARD_BEHOLD_401
:
616 case SAA7134_BOARD_BEHOLD_403
:
617 case SAA7134_BOARD_BEHOLD_403FM
:
618 case SAA7134_BOARD_BEHOLD_405
:
619 case SAA7134_BOARD_BEHOLD_405FM
:
620 case SAA7134_BOARD_BEHOLD_407
:
621 case SAA7134_BOARD_BEHOLD_407FM
:
622 case SAA7134_BOARD_BEHOLD_409
:
623 case SAA7134_BOARD_BEHOLD_505FM
:
624 case SAA7134_BOARD_BEHOLD_505RDS_MK5
:
625 case SAA7134_BOARD_BEHOLD_505RDS_MK3
:
626 case SAA7134_BOARD_BEHOLD_507_9FM
:
627 case SAA7134_BOARD_BEHOLD_507RDS_MK3
:
628 case SAA7134_BOARD_BEHOLD_507RDS_MK5
:
629 ir_codes
= RC_MAP_MANLI
;
630 mask_keycode
= 0x003f00;
631 mask_keyup
= 0x004000;
632 polling
= 50; /* ms */
634 case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM
:
635 ir_codes
= RC_MAP_BEHOLD_COLUMBUS
;
636 mask_keycode
= 0x003f00;
637 mask_keyup
= 0x004000;
640 case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS
:
641 ir_codes
= RC_MAP_PCTV_SEDNA
;
642 mask_keycode
= 0x001f00;
643 mask_keyup
= 0x004000;
646 case SAA7134_BOARD_GOTVIEW_7135
:
647 ir_codes
= RC_MAP_GOTVIEW7135
;
648 mask_keycode
= 0x0003CC;
649 mask_keydown
= 0x000010;
650 polling
= 5; /* ms */
651 /* GPIO stuff moved to saa7134_ir_open() */
653 case SAA7134_BOARD_VIDEOMATE_TV_PVR
:
654 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS
:
655 case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII
:
656 ir_codes
= RC_MAP_VIDEOMATE_TV_PVR
;
657 mask_keycode
= 0x00003F;
658 mask_keyup
= 0x400000;
661 case SAA7134_BOARD_PROTEUS_2309
:
662 ir_codes
= RC_MAP_PROTEUS_2309
;
663 mask_keycode
= 0x00007F;
664 mask_keyup
= 0x000080;
667 case SAA7134_BOARD_VIDEOMATE_DVBT_300
:
668 case SAA7134_BOARD_VIDEOMATE_DVBT_200
:
669 ir_codes
= RC_MAP_VIDEOMATE_TV_PVR
;
670 mask_keycode
= 0x003F00;
671 mask_keyup
= 0x040000;
673 case SAA7134_BOARD_FLYDVBS_LR300
:
674 case SAA7134_BOARD_FLYDVBT_LR301
:
675 case SAA7134_BOARD_FLYDVBTDUO
:
676 ir_codes
= RC_MAP_FLYDVB
;
677 mask_keycode
= 0x0001F00;
678 mask_keydown
= 0x0040000;
680 case SAA7134_BOARD_ASUSTeK_P7131_DUAL
:
681 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA
:
682 case SAA7134_BOARD_ASUSTeK_P7131_ANALOG
:
683 ir_codes
= RC_MAP_ASUS_PC39
;
684 mask_keydown
= 0x0040000; /* Enable GPIO18 line on both edges */
685 mask_keyup
= 0x0040000;
686 mask_keycode
= 0xffff;
689 case SAA7134_BOARD_ASUSTeK_PS3_100
:
690 ir_codes
= RC_MAP_ASUS_PS3_100
;
691 mask_keydown
= 0x0040000;
692 mask_keyup
= 0x0040000;
693 mask_keycode
= 0xffff;
696 case SAA7134_BOARD_ENCORE_ENLTV
:
697 case SAA7134_BOARD_ENCORE_ENLTV_FM
:
698 ir_codes
= RC_MAP_ENCORE_ENLTV
;
699 mask_keycode
= 0x00007f;
700 mask_keyup
= 0x040000;
703 case SAA7134_BOARD_ENCORE_ENLTV_FM53
:
704 case SAA7134_BOARD_ENCORE_ENLTV_FM3
:
705 ir_codes
= RC_MAP_ENCORE_ENLTV_FM53
;
706 mask_keydown
= 0x0040000; /* Enable GPIO18 line on both edges */
707 mask_keyup
= 0x0040000;
708 mask_keycode
= 0xffff;
711 case SAA7134_BOARD_10MOONSTVMASTER3
:
712 ir_codes
= RC_MAP_ENCORE_ENLTV
;
713 mask_keycode
= 0x5f80000;
714 mask_keyup
= 0x8000000;
717 case SAA7134_BOARD_GENIUS_TVGO_A11MCE
:
718 ir_codes
= RC_MAP_GENIUS_TVGO_A11MCE
;
720 mask_keydown
= 0xf00000;
721 polling
= 50; /* ms */
723 case SAA7134_BOARD_REAL_ANGEL_220
:
724 ir_codes
= RC_MAP_REAL_AUDIO_220_32_KEYS
;
725 mask_keycode
= 0x3f00;
727 polling
= 50; /* ms */
729 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG
:
730 ir_codes
= RC_MAP_KWORLD_PLUS_TV_ANALOG
;
732 polling
= 40; /* ms */
734 case SAA7134_BOARD_VIDEOMATE_S350
:
735 ir_codes
= RC_MAP_VIDEOMATE_S350
;
736 mask_keycode
= 0x003f00;
737 mask_keydown
= 0x040000;
739 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S
:
740 ir_codes
= RC_MAP_WINFAST
;
741 mask_keycode
= 0x5f00;
742 mask_keyup
= 0x020000;
743 polling
= 50; /* ms */
745 case SAA7134_BOARD_VIDEOMATE_M1F
:
746 ir_codes
= RC_MAP_VIDEOMATE_K100
;
747 mask_keycode
= 0x0ff00;
748 mask_keyup
= 0x040000;
750 case SAA7134_BOARD_HAUPPAUGE_HVR1150
:
751 case SAA7134_BOARD_HAUPPAUGE_HVR1120
:
752 ir_codes
= RC_MAP_HAUPPAUGE
;
753 mask_keydown
= 0x0040000; /* Enable GPIO18 line on both edges */
754 mask_keyup
= 0x0040000;
755 mask_keycode
= 0xffff;
758 case SAA7134_BOARD_LEADTEK_WINFAST_TV2100_FM
:
759 ir_codes
= RC_MAP_LEADTEK_Y04G0051
;
760 mask_keydown
= 0x0040000; /* Enable GPIO18 line on both edges */
761 mask_keyup
= 0x0040000;
762 mask_keycode
= 0xffff;
766 if (NULL
== ir_codes
) {
767 pr_err("Oops: IR config error [card=%d]\n", dev
->board
);
771 ir
= kzalloc(sizeof(*ir
), GFP_KERNEL
);
772 rc
= rc_allocate_device(RC_DRIVER_SCANCODE
);
781 /* init hardware-specific stuff */
782 ir
->mask_keycode
= mask_keycode
;
783 ir
->mask_keydown
= mask_keydown
;
784 ir
->mask_keyup
= mask_keyup
;
785 ir
->polling
= polling
;
786 ir
->raw_decode
= raw_decode
;
788 /* init input device */
789 snprintf(ir
->phys
, sizeof(ir
->phys
), "pci-%s/ir0",
793 rc
->open
= saa7134_ir_open
;
794 rc
->close
= saa7134_ir_close
;
796 rc
->driver_type
= RC_DRIVER_IR_RAW
;
797 rc
->allowed_protocols
= RC_PROTO_BIT_ALL_IR_DECODER
;
800 rc
->device_name
= saa7134_boards
[dev
->board
].name
;
801 rc
->input_phys
= ir
->phys
;
802 rc
->input_id
.bustype
= BUS_PCI
;
803 rc
->input_id
.version
= 1;
804 if (dev
->pci
->subsystem_vendor
) {
805 rc
->input_id
.vendor
= dev
->pci
->subsystem_vendor
;
806 rc
->input_id
.product
= dev
->pci
->subsystem_device
;
808 rc
->input_id
.vendor
= dev
->pci
->vendor
;
809 rc
->input_id
.product
= dev
->pci
->device
;
811 rc
->dev
.parent
= &dev
->pci
->dev
;
812 rc
->map_name
= ir_codes
;
813 rc
->driver_name
= MODULE_NAME
;
815 rc
->timeout
= IR_DEFAULT_TIMEOUT
;
816 rc
->max_timeout
= 10 * IR_DEFAULT_TIMEOUT
;
818 err
= rc_register_device(rc
);
831 void saa7134_input_fini(struct saa7134_dev
*dev
)
833 if (NULL
== dev
->remote
)
836 rc_unregister_device(dev
->remote
->dev
);
841 void saa7134_probe_i2c_ir(struct saa7134_dev
*dev
)
843 struct i2c_board_info info
;
844 struct i2c_msg msg_msi
= {
853 input_dbg("IR has been disabled, not probing for i2c remote\n");
857 memset(&info
, 0, sizeof(struct i2c_board_info
));
858 memset(&dev
->init_data
, 0, sizeof(dev
->init_data
));
859 strscpy(info
.type
, "ir_video", I2C_NAME_SIZE
);
861 switch (dev
->board
) {
862 case SAA7134_BOARD_PINNACLE_PCTV_110i
:
863 case SAA7134_BOARD_PINNACLE_PCTV_310i
:
864 dev
->init_data
.name
= "Pinnacle PCTV";
865 if (pinnacle_remote
== 0) {
866 dev
->init_data
.get_key
= get_key_pinnacle_color
;
867 dev
->init_data
.ir_codes
= RC_MAP_PINNACLE_COLOR
;
870 dev
->init_data
.get_key
= get_key_pinnacle_grey
;
871 dev
->init_data
.ir_codes
= RC_MAP_PINNACLE_GREY
;
875 case SAA7134_BOARD_UPMOST_PURPLE_TV
:
876 dev
->init_data
.name
= "Purple TV";
877 dev
->init_data
.get_key
= get_key_purpletv
;
878 dev
->init_data
.ir_codes
= RC_MAP_PURPLETV
;
881 case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS
:
882 dev
->init_data
.name
= "MSI TV@nywhere Plus";
883 dev
->init_data
.get_key
= get_key_msi_tvanywhere_plus
;
884 dev
->init_data
.ir_codes
= RC_MAP_MSI_TVANYWHERE_PLUS
;
886 * MSI TV@nyware Plus requires more frequent polling
887 * otherwise it will miss some keypresses
889 dev
->init_data
.polling_interval
= 50;
891 /* MSI TV@nywhere Plus controller doesn't seem to
892 respond to probes unless we read something from
893 an existing device. Weird...
894 REVISIT: might no longer be needed */
895 rc
= i2c_transfer(&dev
->i2c_adap
, &msg_msi
, 1);
896 input_dbg("probe 0x%02x @ %s: %s\n",
897 msg_msi
.addr
, dev
->i2c_adap
.name
,
898 (1 == rc
) ? "yes" : "no");
900 case SAA7134_BOARD_SNAZIO_TVPVR_PRO
:
901 dev
->init_data
.name
= "SnaZio* TVPVR PRO";
902 dev
->init_data
.get_key
= get_key_msi_tvanywhere_plus
;
903 dev
->init_data
.ir_codes
= RC_MAP_MSI_TVANYWHERE_PLUS
;
905 * MSI TV@nyware Plus requires more frequent polling
906 * otherwise it will miss some keypresses
908 dev
->init_data
.polling_interval
= 50;
911 * MSI TV@nywhere Plus controller doesn't seem to
912 * respond to probes unless we read something from
913 * an existing device. Weird...
914 * REVISIT: might no longer be needed
916 rc
= i2c_transfer(&dev
->i2c_adap
, &msg_msi
, 1);
917 input_dbg("probe 0x%02x @ %s: %s\n",
918 msg_msi
.addr
, dev
->i2c_adap
.name
,
919 (rc
== 1) ? "yes" : "no");
921 case SAA7134_BOARD_KWORLD_PC150U
:
922 /* copied and modified from MSI TV@nywhere Plus */
923 dev
->init_data
.name
= "Kworld PC150-U";
924 dev
->init_data
.get_key
= get_key_kworld_pc150u
;
925 dev
->init_data
.ir_codes
= RC_MAP_KWORLD_PC150U
;
927 /* MSI TV@nywhere Plus controller doesn't seem to
928 respond to probes unless we read something from
929 an existing device. Weird...
930 REVISIT: might no longer be needed */
931 rc
= i2c_transfer(&dev
->i2c_adap
, &msg_msi
, 1);
932 input_dbg("probe 0x%02x @ %s: %s\n",
933 msg_msi
.addr
, dev
->i2c_adap
.name
,
934 (1 == rc
) ? "yes" : "no");
936 case SAA7134_BOARD_HAUPPAUGE_HVR1110
:
937 dev
->init_data
.name
= saa7134_boards
[dev
->board
].name
;
938 dev
->init_data
.ir_codes
= RC_MAP_HAUPPAUGE
;
939 dev
->init_data
.type
= RC_PROTO_BIT_RC5
|
940 RC_PROTO_BIT_RC6_MCE
| RC_PROTO_BIT_RC6_6A_32
;
941 dev
->init_data
.internal_get_key_func
= IR_KBD_GET_KEY_HAUP_XVR
;
944 case SAA7134_BOARD_BEHOLD_607FM_MK3
:
945 case SAA7134_BOARD_BEHOLD_607FM_MK5
:
946 case SAA7134_BOARD_BEHOLD_609FM_MK3
:
947 case SAA7134_BOARD_BEHOLD_609FM_MK5
:
948 case SAA7134_BOARD_BEHOLD_607RDS_MK3
:
949 case SAA7134_BOARD_BEHOLD_607RDS_MK5
:
950 case SAA7134_BOARD_BEHOLD_609RDS_MK3
:
951 case SAA7134_BOARD_BEHOLD_609RDS_MK5
:
952 case SAA7134_BOARD_BEHOLD_M6
:
953 case SAA7134_BOARD_BEHOLD_M63
:
954 case SAA7134_BOARD_BEHOLD_M6_EXTRA
:
955 case SAA7134_BOARD_BEHOLD_H6
:
956 case SAA7134_BOARD_BEHOLD_X7
:
957 case SAA7134_BOARD_BEHOLD_H7
:
958 case SAA7134_BOARD_BEHOLD_A7
:
959 dev
->init_data
.name
= "BeholdTV";
960 dev
->init_data
.get_key
= get_key_beholdm6xx
;
961 dev
->init_data
.ir_codes
= RC_MAP_BEHOLD
;
962 dev
->init_data
.type
= RC_PROTO_BIT_NECX
;
965 case SAA7134_BOARD_AVERMEDIA_CARDBUS_501
:
966 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506
:
969 case SAA7134_BOARD_AVERMEDIA_A706
:
972 case SAA7134_BOARD_FLYDVB_TRIO
:
973 dev
->init_data
.name
= "FlyDVB Trio";
974 dev
->init_data
.get_key
= get_key_flydvb_trio
;
975 dev
->init_data
.ir_codes
= RC_MAP_FLYDVB
;
979 input_dbg("No I2C IR support for board %x\n", dev
->board
);
983 if (dev
->init_data
.name
)
984 info
.platform_data
= &dev
->init_data
;
985 i2c_new_client_device(&dev
->i2c_adap
, &info
);
988 static int saa7134_raw_decode_irq(struct saa7134_dev
*dev
)
990 struct saa7134_card_ir
*ir
= dev
->remote
;
993 /* Generate initial event */
994 saa_clearb(SAA7134_GPIO_GPMODE3
, SAA7134_GPIO_GPRESCAN
);
995 saa_setb(SAA7134_GPIO_GPMODE3
, SAA7134_GPIO_GPRESCAN
);
996 space
= saa_readl(SAA7134_GPIO_GPSTATUS0
>> 2) & ir
->mask_keydown
;
997 ir_raw_event_store_edge(dev
->remote
->dev
, !space
);