static void bttv_rc5_timer_end(unsigned long data) { struct bttv_ir *ir = (struct bttv_ir *)data; struct timeval tv; u32 gap; u32 rc5 = 0; /* get time */ do_gettimeofday(&tv); /* avoid overflow with gap >1s */ if (tv.tv_sec - ir->base_time.tv_sec > 1) { gap = 200000; } else { gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) + tv.tv_usec - ir->base_time.tv_usec; } /* signal we're ready to start a new code */ ir->active = false; /* Allow some timer jitter (RC5 is ~24ms anyway so this is ok) */ if (gap < 28000) { dprintk(KERN_INFO DEVNAME ": spurious timer_end\n"); return; } if (ir->last_bit < 20) { /* ignore spurious codes (caused by light/other remotes) */ dprintk(KERN_INFO DEVNAME ": short code: %x\n", ir->code); } else { ir->code = (ir->code << ir->shift_by) | 1; rc5 = bttv_rc5_decode(ir->code); /* two start bits? */ if (RC5_START(rc5) != ir->start) { printk(KERN_INFO DEVNAME ":" " rc5 start bits invalid: %u\n", RC5_START(rc5)); /* right address? */ } else if (RC5_ADDR(rc5) == ir->addr) { u32 toggle = RC5_TOGGLE(rc5); u32 instr = RC5_INSTR(rc5); /* Good code */ rc_keydown(ir->dev, instr, toggle); dprintk(KERN_INFO DEVNAME ":" " instruction %x, toggle %x\n", instr, toggle); } } }
static void bttv_rc5_timer_end(unsigned long data) { struct bttv_ir *ir = (struct bttv_ir *)data; ktime_t tv; u32 gap, rc5, scancode; u8 toggle, command, system; /* get time */ tv = ktime_get(); gap = ktime_to_us(ktime_sub(tv, ir->base_time)); /* avoid overflow with gap >1s */ if (gap > USEC_PER_SEC) { gap = 200000; } /* signal we're ready to start a new code */ ir->active = false; /* Allow some timer jitter (RC5 is ~24ms anyway so this is ok) */ if (gap < 28000) { dprintk("spurious timer_end\n"); return; } if (ir->last_bit < 20) { /* ignore spurious codes (caused by light/other remotes) */ dprintk("short code: %x\n", ir->code); return; } ir->code = (ir->code << ir->shift_by) | 1; rc5 = bttv_rc5_decode(ir->code); toggle = RC5_TOGGLE(rc5); system = RC5_ADDR(rc5); command = RC5_INSTR(rc5); switch (RC5_START(rc5)) { case 0x3: break; case 0x2: command += 0x40; break; default: return; } scancode = RC_SCANCODE_RC5(system, command); rc_keydown(ir->dev, RC_TYPE_RC5, scancode, toggle); dprintk("scancode %x, toggle %x\n", scancode, toggle); }