V4L/DVB (13531): ir-common: rename the debug routine to allow exporting it
[safe/jmp/linux-2.6] / drivers / media / common / ir-functions.c
index a3292e9..b111a0d 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>
@@ -35,11 +34,8 @@ static int repeat = 1;
 module_param(repeat, int, 0444);
 MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)");
 
-static int debug = 0;    /* debug level (0,1,2) */
-module_param(debug, int, 0644);
-
-#define dprintk(level, fmt, arg...)    if (debug >= level) \
-       printk(KERN_DEBUG fmt , ## arg)
+int media_ir_debug;    /* media_ir_debug level (0,1,2) */
+module_param_named(debug, media_ir_debug, int, 0644);
 
 /* -------------------------------------------------------------------------- */
 
@@ -50,7 +46,7 @@ static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
                       dev->name,ir->ir_key,ir->ir_raw,ir->keypressed);
                return;
        }
-       dprintk(1,"%s: key event code=%d down=%d\n",
+       IR_dprintk(1,"%s: key event code=%d down=%d\n",
                dev->name,ir->keycode,ir->keypressed);
        input_report_key(dev,ir->keycode,ir->keypressed);
        input_sync(dev);
@@ -59,14 +55,24 @@ static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
 /* -------------------------------------------------------------------------- */
 
 void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
-                  int ir_type, IR_KEYTAB_TYPE *ir_codes)
+                  int ir_type, struct ir_scancode_table *ir_codes)
 {
        int i;
 
        ir->ir_type = ir_type;
-       if (ir_codes)
-               memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes));
 
+       memset(ir->ir_codes, 0, sizeof(ir->ir_codes));
+
+       /*
+        * FIXME: This is a temporary workaround to use the new IR tables
+        * with the old approach. Later patches will replace this to a
+        * proper method
+        */
+
+       if (ir_codes)
+               for (i = 0; i < ir_codes->size; i++)
+                       if (ir_codes->scan[i].scancode < IR_KEYTAB_SIZE)
+                               ir->ir_codes[ir_codes->scan[i].scancode] = ir_codes->scan[i].keycode;
 
        dev->keycode     = ir->ir_codes;
        dev->keycodesize = sizeof(IR_KEYTAB_TYPE);
@@ -79,6 +85,7 @@ void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
        if (repeat)
                set_bit(EV_REP, dev->evbit);
 }
+EXPORT_SYMBOL_GPL(ir_input_init);
 
 void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir)
 {
@@ -87,6 +94,7 @@ void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir)
                ir_input_key_event(dev,ir);
        }
 }
+EXPORT_SYMBOL_GPL(ir_input_nokey);
 
 void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
                      u32 ir_key, u32 ir_raw)
@@ -105,6 +113,7 @@ void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
                ir_input_key_event(dev,ir);
        }
 }
+EXPORT_SYMBOL_GPL(ir_input_keydown);
 
 /* -------------------------------------------------------------------------- */
 /* extract mask bits out of data and pack them into the result */
@@ -123,6 +132,7 @@ u32 ir_extract_bits(u32 data, u32 mask)
 
        return value;
 }
+EXPORT_SYMBOL_GPL(ir_extract_bits);
 
 static int inline getbit(u32 *samples, int bit)
 {
@@ -147,6 +157,7 @@ int ir_dump_samples(u32 *samples, int count)
        printk("\n");
        return 0;
 }
+EXPORT_SYMBOL_GPL(ir_dump_samples);
 
 /* decode raw samples, pulse distance coding used by NEC remotes */
 int ir_decode_pulsedistance(u32 *samples, int count, int low, int high)
@@ -213,6 +224,7 @@ int ir_decode_pulsedistance(u32 *samples, int count, int low, int high)
 
        return value;
 }
+EXPORT_SYMBOL_GPL(ir_decode_pulsedistance);
 
 /* decode raw samples, biphase coding, used by rc5 for example */
 int ir_decode_biphase(u32 *samples, int count, int low, int high)
@@ -254,6 +266,7 @@ int ir_decode_biphase(u32 *samples, int count, int low, int high)
        }
        return value;
 }
+EXPORT_SYMBOL_GPL(ir_decode_biphase);
 
 /* RC5 decoding stuff, moved from bttv-input.c to share it with
  * saa7134 */
@@ -279,15 +292,16 @@ u32 ir_rc5_decode(unsigned int code)
                        rc5 |= 1;
                        break;
                case 3:
-                       dprintk(1, "ir-common: ir_rc5_decode(%x) bad code\n", org_code);
+                       IR_dprintk(1, "ir-common: ir_rc5_decode(%x) bad code\n", org_code);
                        return 0;
                }
        }
-       dprintk(1, "ir-common: code=%x, rc5=%x, start=%x, toggle=%x, address=%x, "
+       IR_dprintk(1, "ir-common: code=%x, rc5=%x, start=%x, toggle=%x, address=%x, "
                "instr=%x\n", rc5, org_code, RC5_START(rc5),
                RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5));
        return rc5;
 }
+EXPORT_SYMBOL_GPL(ir_rc5_decode);
 
 void ir_rc5_timer_end(unsigned long data)
 {
@@ -314,20 +328,20 @@ void ir_rc5_timer_end(unsigned long data)
 
        /* Allow some timer jitter (RC5 is ~24ms anyway so this is ok) */
        if (gap < 28000) {
-               dprintk(1, "ir-common: spurious timer_end\n");
+               IR_dprintk(1, "ir-common: spurious timer_end\n");
                return;
        }
 
        if (ir->last_bit < 20) {
                /* ignore spurious codes (caused by light/other remotes) */
-               dprintk(1, "ir-common: short code: %x\n", ir->code);
+               IR_dprintk(1, "ir-common: short code: %x\n", ir->code);
        } else {
                ir->code = (ir->code << ir->shift_by) | 1;
                rc5 = ir_rc5_decode(ir->code);
 
                /* two start bits? */
                if (RC5_START(rc5) != ir->start) {
-                       dprintk(1, "ir-common: rc5 start bits invalid: %u\n", RC5_START(rc5));
+                       IR_dprintk(1, "ir-common: rc5 start bits invalid: %u\n", RC5_START(rc5));
 
                        /* right address? */
                } else if (RC5_ADDR(rc5) == ir->addr) {
@@ -337,7 +351,7 @@ void ir_rc5_timer_end(unsigned long data)
                        /* Good code, decide if repeat/repress */
                        if (toggle != RC5_TOGGLE(ir->last_rc5) ||
                            instr != RC5_INSTR(ir->last_rc5)) {
-                               dprintk(1, "ir-common: instruction %x, toggle %x\n", instr,
+                               IR_dprintk(1, "ir-common: instruction %x, toggle %x\n", instr,
                                        toggle);
                                ir_input_nokey(ir->dev, &ir->ir);
                                ir_input_keydown(ir->dev, &ir->ir, instr,
@@ -354,30 +368,13 @@ void ir_rc5_timer_end(unsigned long data)
                }
        }
 }
+EXPORT_SYMBOL_GPL(ir_rc5_timer_end);
 
 void ir_rc5_timer_keyup(unsigned long data)
 {
        struct card_ir *ir = (struct card_ir *)data;
 
-       dprintk(1, "ir-common: key released\n");
+       IR_dprintk(1, "ir-common: key released\n");
        ir_input_nokey(ir->dev, &ir->ir);
 }
-
-EXPORT_SYMBOL_GPL(ir_input_init);
-EXPORT_SYMBOL_GPL(ir_input_nokey);
-EXPORT_SYMBOL_GPL(ir_input_keydown);
-
-EXPORT_SYMBOL_GPL(ir_extract_bits);
-EXPORT_SYMBOL_GPL(ir_dump_samples);
-EXPORT_SYMBOL_GPL(ir_decode_biphase);
-EXPORT_SYMBOL_GPL(ir_decode_pulsedistance);
-
-EXPORT_SYMBOL_GPL(ir_rc5_decode);
-EXPORT_SYMBOL_GPL(ir_rc5_timer_end);
 EXPORT_SYMBOL_GPL(ir_rc5_timer_keyup);
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */