aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/saa7134')
-rw-r--r--drivers/media/video/saa7134/saa7134-i2c.c14
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c202
-rw-r--r--drivers/media/video/saa7134/saa7134.h5
3 files changed, 219 insertions, 2 deletions
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c
index 2577d03485b8..7575043f0874 100644
--- a/drivers/media/video/saa7134/saa7134-i2c.c
+++ b/drivers/media/video/saa7134/saa7134-i2c.c
@@ -335,6 +335,20 @@ static int attach_inform(struct i2c_client *client)
335 d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", 335 d1printk( "%s i2c attach [addr=0x%x,client=%s]\n",
336 client->driver->name, client->addr, client->name); 336 client->driver->name, client->addr, client->name);
337 337
338 /* Am I an i2c remote control? */
339
340 switch (client->addr) {
341 case 0x7a:
342 case 0x47:
343 {
344 struct IR_i2c *ir = i2c_get_clientdata(client);
345 d1printk("%s i2c IR detected (%s).\n",
346 client->driver->name,ir->phys);
347 saa7134_set_i2c_ir(dev,ir);
348 break;
349 }
350 }
351
338 if (!client->driver->command) 352 if (!client->driver->command)
339 return 0; 353 return 0;
340 354
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index f99dbb729555..6413a6e09873 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -39,6 +39,8 @@ MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
39 39
40#define dprintk(fmt, arg...) if (ir_debug) \ 40#define dprintk(fmt, arg...) if (ir_debug) \
41 printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) 41 printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
42#define i2cdprintk(fmt, arg...) if (ir_debug) \
43 printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg)
42 44
43/* ---------------------------------------------------------------------- */ 45/* ---------------------------------------------------------------------- */
44 46
@@ -443,7 +445,105 @@ static IR_KEYTAB_TYPE gotview7135_codes[IR_KEYTAB_SIZE] = {
443 [ 112] = KEY_F24, /* NORMAL TIMESHIFT */ 445 [ 112] = KEY_F24, /* NORMAL TIMESHIFT */
444}; 446};
445 447
446/* ---------------------------------------------------------------------- */ 448static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
449 [ 0x3 ] = KEY_POWER,
450 [ 0x6f ] = KEY_MUTE,
451 [ 0x10 ] = KEY_BACKSPACE, /* Recall */
452
453 [ 0x11 ] = KEY_KP0,
454 [ 0x4 ] = KEY_KP1,
455 [ 0x5 ] = KEY_KP2,
456 [ 0x6 ] = KEY_KP3,
457 [ 0x8 ] = KEY_KP4,
458 [ 0x9 ] = KEY_KP5,
459 [ 0xa ] = KEY_KP6,
460 [ 0xc ] = KEY_KP7,
461 [ 0xd ] = KEY_KP8,
462 [ 0xe ] = KEY_KP9,
463 [ 0x12 ] = KEY_KPDOT, /* 100+ */
464
465 [ 0x7 ] = KEY_VOLUMEUP,
466 [ 0xb ] = KEY_VOLUMEDOWN,
467 [ 0x1a ] = KEY_KPPLUS,
468 [ 0x18 ] = KEY_KPMINUS,
469 [ 0x15 ] = KEY_UP,
470 [ 0x1d ] = KEY_DOWN,
471 [ 0xf ] = KEY_CHANNELUP,
472 [ 0x13 ] = KEY_CHANNELDOWN,
473 [ 0x48 ] = KEY_ZOOM,
474
475 [ 0x1b ] = KEY_VIDEO, /* Video source */
476 [ 0x49 ] = KEY_LANGUAGE, /* MTS Select */
477 [ 0x19 ] = KEY_SEARCH, /* Auto Scan */
478
479 [ 0x4b ] = KEY_RECORD,
480 [ 0x46 ] = KEY_PLAY,
481 [ 0x45 ] = KEY_PAUSE, /* Pause */
482 [ 0x44 ] = KEY_STOP,
483 [ 0x40 ] = KEY_FORWARD, /* Forward ? */
484 [ 0x42 ] = KEY_REWIND, /* Backward ? */
485
486};
487
488static IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = {
489 [ 0x59 ] = KEY_MUTE,
490 [ 0x4a ] = KEY_POWER,
491
492 [ 0x18 ] = KEY_TEXT,
493 [ 0x26 ] = KEY_TV,
494 [ 0x3d ] = KEY_PRINT,
495
496 [ 0x48 ] = KEY_RED,
497 [ 0x04 ] = KEY_GREEN,
498 [ 0x11 ] = KEY_YELLOW,
499 [ 0x00 ] = KEY_BLUE,
500
501 [ 0x2d ] = KEY_VOLUMEUP,
502 [ 0x1e ] = KEY_VOLUMEDOWN,
503
504 [ 0x49 ] = KEY_MENU,
505
506 [ 0x16 ] = KEY_CHANNELUP,
507 [ 0x17 ] = KEY_CHANNELDOWN,
508
509 [ 0x20 ] = KEY_UP,
510 [ 0x21 ] = KEY_DOWN,
511 [ 0x22 ] = KEY_LEFT,
512 [ 0x23 ] = KEY_RIGHT,
513 [ 0x0d ] = KEY_SELECT,
514
515
516
517 [ 0x08 ] = KEY_BACK,
518 [ 0x07 ] = KEY_REFRESH,
519
520 [ 0x2f ] = KEY_ZOOM,
521 [ 0x29 ] = KEY_RECORD,
522
523 [ 0x4b ] = KEY_PAUSE,
524 [ 0x4d ] = KEY_REWIND,
525 [ 0x2e ] = KEY_PLAY,
526 [ 0x4e ] = KEY_FORWARD,
527 [ 0x53 ] = KEY_PREVIOUS,
528 [ 0x4c ] = KEY_STOP,
529 [ 0x54 ] = KEY_NEXT,
530
531 [ 0x69 ] = KEY_KP0,
532 [ 0x6a ] = KEY_KP1,
533 [ 0x6b ] = KEY_KP2,
534 [ 0x6c ] = KEY_KP3,
535 [ 0x6d ] = KEY_KP4,
536 [ 0x6e ] = KEY_KP5,
537 [ 0x6f ] = KEY_KP6,
538 [ 0x70 ] = KEY_KP7,
539 [ 0x71 ] = KEY_KP8,
540 [ 0x72 ] = KEY_KP9,
541
542 [ 0x74 ] = KEY_CHANNEL,
543 [ 0x0a ] = KEY_BACKSPACE,
544};
545
546/* -------------------- GPIO generic keycode builder -------------------- */
447 547
448static int build_key(struct saa7134_dev *dev) 548static int build_key(struct saa7134_dev *dev)
449{ 549{
@@ -474,7 +574,81 @@ static int build_key(struct saa7134_dev *dev)
474 return 0; 574 return 0;
475} 575}
476 576
477/* ---------------------------------------------------------------------- */ 577/* --------------------- Chip specific I2C key builders ----------------- */
578
579static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
580{
581 unsigned char b;
582
583 /* poll IR chip */
584 if (1 != i2c_master_recv(&ir->c,&b,1)) {
585 i2cdprintk("read error\n");
586 return -EIO;
587 }
588
589 /* no button press */
590 if (b==0)
591 return 0;
592
593 /* repeating */
594 if (b & 0x80)
595 return 1;
596
597 *ir_key = b;
598 *ir_raw = b;
599 return 1;
600}
601
602/* The new pinnacle PCTV remote (with the colored buttons)
603 *
604 * Ricardo Cerqueira <v4l@cerqueira.org>
605 */
606
607static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
608{
609 unsigned char b[4];
610 unsigned int start = 0,parity = 0,code = 0;
611
612 /* poll IR chip */
613 if (4 != i2c_master_recv(&ir->c,b,4)) {
614 i2cdprintk("read error\n");
615 return -EIO;
616 }
617
618 for (start = 0; start<4; start++) {
619 if (b[start] == 0x80) {
620 code=b[(start+3)%4];
621 parity=b[(start+2)%4];
622 }
623 }
624
625 /* Empty Request */
626 if (parity==0)
627 return 0;
628
629 /* Repeating... */
630 if (ir->old == parity)
631 return 0;
632
633
634 ir->old = parity;
635
636 /* Reduce code value to fit inside IR_KEYTAB_SIZE
637 *
638 * this is the only value that results in 42 unique
639 * codes < 128
640 */
641
642 code %= 0x88;
643
644 *ir_raw = code;
645 *ir_key = code;
646
647 i2cdprintk("Pinnacle PCTV key %02x\n", code);
648
649 return 1;
650}
651
478 652
479void saa7134_input_irq(struct saa7134_dev *dev) 653void saa7134_input_irq(struct saa7134_dev *dev)
480{ 654{
@@ -658,6 +832,30 @@ void saa7134_input_fini(struct saa7134_dev *dev)
658 dev->remote = NULL; 832 dev->remote = NULL;
659} 833}
660 834
835void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir)
836{
837 if (disable_ir) {
838 ir->get_key=NULL;
839 return;
840 }
841
842 switch (dev->board) {
843 case SAA7134_BOARD_PINNACLE_PCTV_110i:
844 snprintf(ir->c.name, sizeof(ir->c.name), "Pinnacle PCTV");
845 ir->get_key = get_key_pinnacle;
846 ir->ir_codes = ir_codes_pinnacle;
847 break;
848 case SAA7134_BOARD_UPMOST_PURPLE_TV:
849 snprintf(ir->c.name, sizeof(ir->c.name), "Purple TV");
850 ir->get_key = get_key_purpletv;
851 ir->ir_codes = ir_codes_purpletv;
852 break;
853 default:
854 dprintk("Shouldn't get here: Unknown board %x for I2C IR?\n",dev->board);
855 break;
856 }
857
858}
661/* ---------------------------------------------------------------------- 859/* ----------------------------------------------------------------------
662 * Local variables: 860 * Local variables:
663 * c-basic-offset: 8 861 * c-basic-offset: 8
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index d497fea5425f..99d000be095e 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -36,6 +36,7 @@
36#include <media/audiochip.h> 36#include <media/audiochip.h>
37#include <media/id.h> 37#include <media/id.h>
38#include <media/ir-common.h> 38#include <media/ir-common.h>
39#include <media/ir-kbd-i2c.h>
39#include <media/video-buf.h> 40#include <media/video-buf.h>
40#include <media/video-buf-dvb.h> 41#include <media/video-buf-dvb.h>
41 42
@@ -653,6 +654,10 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status);
653int saa7134_input_init1(struct saa7134_dev *dev); 654int saa7134_input_init1(struct saa7134_dev *dev);
654void saa7134_input_fini(struct saa7134_dev *dev); 655void saa7134_input_fini(struct saa7134_dev *dev);
655void saa7134_input_irq(struct saa7134_dev *dev); 656void saa7134_input_irq(struct saa7134_dev *dev);
657void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir);
658
659/* ----------------------------------------------------------- */
660/* saa7134-alsa.c */
656 661
657int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devnum); 662int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devnum);
658void alsa_card_saa7134_exit(void); 663void alsa_card_saa7134_exit(void);