]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/common/ir-functions.c
Merge branch 'features' of git://farnsworth.org/dale/linux-2.6-mv643xx_eth into upstream
[linux-2.6-omap-h63xx.git] / drivers / media / common / ir-functions.c
index cbf7c05648896776e4a60b1bfd01c83956730051..e7c3ab951a44a25e9b37e06ea7eba22226e80725 100644 (file)
@@ -21,7 +21,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/string.h>
 #include <linux/jiffies.h>
 #include <media/ir-common.h>
@@ -107,21 +106,20 @@ void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
 }
 
 /* -------------------------------------------------------------------------- */
-
+/* extract mask bits out of data and pack them into the result */
 u32 ir_extract_bits(u32 data, u32 mask)
 {
-       int mbit, vbit;
-       u32 value;
+       u32 vbit = 1, value = 0;
+
+       do {
+           if (mask&1) {
+               if (data&1)
+                       value |= vbit;
+               vbit<<=1;
+           }
+           data>>=1;
+       } while (mask>>=1);
 
-       value = 0;
-       vbit  = 0;
-       for (mbit = 0; mbit < 32; mbit++) {
-               if (!(mask & ((u32)1 << mbit)))
-                       continue;
-               if (data & ((u32)1 << mbit))
-                       value |= (1 << vbit);
-               vbit++;
-       }
        return value;
 }
 
@@ -310,13 +308,15 @@ void ir_rc5_timer_end(unsigned long data)
                    tv.tv_usec - ir->base_time.tv_usec;
        }
 
-       /* Allow some timmer jitter (RC5 is ~24ms anyway so this is ok) */
+       /* signal we're ready to start a new code */
+       ir->active = 0;
+
+       /* Allow some timer jitter (RC5 is ~24ms anyway so this is ok) */
        if (gap < 28000) {
                dprintk(1, "ir-common: spurious timer_end\n");
                return;
        }
 
-       ir->active = 0;
        if (ir->last_bit < 20) {
                /* ignore spurious codes (caused by light/other remotes) */
                dprintk(1, "ir-common: short code: %x\n", ir->code);
@@ -344,8 +344,8 @@ void ir_rc5_timer_end(unsigned long data)
                        }
 
                        /* Set/reset key-up timer */
-                       timeout = current_jiffies + (500 + ir->rc5_key_timeout
-                                                    * HZ) / 1000;
+                       timeout = current_jiffies +
+                                 msecs_to_jiffies(ir->rc5_key_timeout);
                        mod_timer(&ir->timer_keyup, timeout);
 
                        /* Save code for repeat test */