]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
V4L/DVB (9016): HVR3000/4000 Hauppauge related IR cleanups
authorDarron Broad <darron@kewl.org>
Mon, 22 Sep 2008 03:54:59 +0000 (00:54 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 12 Oct 2008 11:37:06 +0000 (09:37 -0200)
From the author:
This patch-set fixes remote control issues I have experienced
with hauppauge drivers in Linux since the PVR-350 and now
with both a NOVA-S+ and HVR-4000. It has also been confirmed
to work with an HVR-1300 user who had exactly the same issue.

Hauppage remote controls use RC5. RC5 has a bit-field which
represents the target device. The hauppauge windows drivers
have a registry key which can enable filtering, but the linux
drivers will accept any target device in this bit field for
internal processing.

This causes problems with setups such as mythtv where remote
control key presses destined for the TV (target = 0) are
interpreted by the kernel and subsequenctly LIRC then mythtv.

Of the remote controls I have to hand (wintv black, pvr/hvr
silver) the hauppauge remotes send one of two device targets
ids, these are interpreted by the patch which then filters
out any non hauppauge addresses.

Signed-off-by: Steven Toth <stoth@linuxtv.org>
Signed-off-by: Darron Broad <darron@kewl.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/cx88/cx88-input.c
drivers/media/video/ir-kbd-i2c.c

index 097081eb505f5c3c786046116879633739ae4ce6..13bc5d160761c89db5ca8edff44e0e8c0f0e41d8 100644 (file)
@@ -394,7 +394,7 @@ void cx88_ir_irq(struct cx88_core *core)
 {
        struct cx88_IR *ir = core->ir;
        u32 samples, ircode;
-       int i;
+       int i, start, range, toggle, dev, code;
 
        if (NULL == ir)
                return;
@@ -463,9 +463,35 @@ void cx88_ir_irq(struct cx88_core *core)
        case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
        case CX88_BOARD_HAUPPAUGE_HVR1100:
        case CX88_BOARD_HAUPPAUGE_HVR3000:
-       case CX88_BOARD_PINNACLE_PCTV_HD_800i:
        case CX88_BOARD_HAUPPAUGE_HVR4000:
        case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
+               ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
+               ir_dprintk("biphase decoded: %x\n", ircode);
+               /*
+                * RC5 has an extension bit which adds a new range
+                * of available codes, this is detected here. Also
+                * hauppauge remotes (black/silver) always use
+                * specific device ids. If we do not filter the
+                * device ids then messages destined for devices
+                * such as TVs (id=0) will get through to the
+                * device causing mis-fired events.
+                */
+               /* split rc5 data block ... */
+               start = (ircode & 0x2000) >> 13;
+               range = (ircode & 0x1000) >> 12;
+               toggle= (ircode & 0x0800) >> 11;
+               dev   = (ircode & 0x07c0) >> 6;
+               code  = (ircode & 0x003f) | ((range << 6) ^ 0x0040);
+               if( start != 1)
+                       /* no key pressed */
+                       break;
+               if ( dev != 0x1e && dev != 0x1f )
+                       /* not a hauppauge remote */
+                       break;
+               ir_input_keydown(ir->input, &ir->ir, code, ircode);
+               ir->release = jiffies + msecs_to_jiffies(120);
+               break;
+       case CX88_BOARD_PINNACLE_PCTV_HD_800i:
                ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
                ir_dprintk("biphase decoded: %x\n", ircode);
                if ((ircode & 0xfffff000) != 0x3000)
index a30254bed3119ed8483270d7f6e8cdb79624da6f..703195a5ad4ed75ac467a8a66e7f4a03d0513c64 100644 (file)
@@ -65,7 +65,7 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
                               int size, int offset)
 {
        unsigned char buf[6];
-       int start, range, toggle, dev, code;
+       int start, range, toggle, dev, code, ircode;
 
        /* poll IR chip */
        if (size != i2c_master_recv(&ir->c,buf,size))
@@ -85,6 +85,24 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
        if (!start)
                /* no key pressed */
                return 0;
+       /*
+        * Hauppauge remotes (black/silver) always use
+        * specific device ids. If we do not filter the
+        * device ids then messages destined for devices
+        * such as TVs (id=0) will get through causing
+        * mis-fired events.
+        *
+        * We also filter out invalid key presses which
+        * produce annoying debug log entries.
+        */
+       ircode= (start << 12) | (toggle << 11) | (dev << 6) | code;
+       if ((ircode & 0x1fff)==0x1fff)
+               /* invalid key press */
+               return 0;
+
+       if (dev!=0x1e && dev!=0x1f)
+               /* not a hauppauge remote */
+               return 0;
 
        if (!range)
                code += 64;
@@ -94,7 +112,7 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
 
        /* return key */
        *ir_key = code;
-       *ir_raw = (start << 12) | (toggle << 11) | (dev << 6) | code;
+       *ir_raw = ircode;
        return 1;
 }