diff options
author | Gerd Knorr <devnull@localhost> | 2005-02-16 13:11:55 +0000 |
---|---|---|
committer | Gerd Knorr <devnull@localhost> | 2005-02-16 13:11:55 +0000 |
commit | 95840cd6d7c62cbfcfeb413c75c0b7364ae03667 (patch) | |
tree | dca02285a9cad9bb00212c0536885d98897efc4d /linux/drivers/media/common | |
parent | e9ba68260349b4194b73b4f9871c7d285bd6a273 (diff) | |
download | mediapointer-dvb-s2-95840cd6d7c62cbfcfeb413c75c0b7364ae03667.tar.gz mediapointer-dvb-s2-95840cd6d7c62cbfcfeb413c75c0b7364ae03667.tar.bz2 |
- move some bits from cx88-input to ir-common.
- blackbird fixes, add new blackbird card.
Diffstat (limited to 'linux/drivers/media/common')
-rw-r--r-- | linux/drivers/media/common/ir-common.c | 125 |
1 files changed, 115 insertions, 10 deletions
diff --git a/linux/drivers/media/common/ir-common.c b/linux/drivers/media/common/ir-common.c index a640cf2a9..e99775e84 100644 --- a/linux/drivers/media/common/ir-common.c +++ b/linux/drivers/media/common/ir-common.c @@ -1,5 +1,5 @@ /* - * $Id: ir-common.c,v 1.6 2004/12/10 12:33:39 kraxel Exp $ + * $Id: ir-common.c,v 1.7 2005/02/16 13:11:55 kraxel Exp $ * * some common structs and functions to handle infrared remotes via * input layer ... @@ -24,12 +24,7 @@ #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/version.h> - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#include "ir-common.h" -#else #include <media/ir-common.h> -#endif /* -------------------------------------------------------------------------- */ @@ -50,6 +45,7 @@ module_param(debug, int, 0644); /* generic RC5 keytable */ /* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */ +/* used by old (black) Hauppauge remotes */ IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE] = { [ 0x00 ] = KEY_KP0, // 0 [ 0x01 ] = KEY_KP1, // 1 @@ -128,6 +124,49 @@ IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = { }; EXPORT_SYMBOL_GPL(ir_codes_empty); +/* Hauppauge: the newer, gray remotes (seems there are multiple + * slightly different versions), shipped with cx88+ivtv cards. + * almost rc5 coding, but some non-standard keys */ +IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE] = { + [ 0x00 ] = KEY_KP0, // 0 + [ 0x01 ] = KEY_KP1, // 1 + [ 0x02 ] = KEY_KP2, // 2 + [ 0x03 ] = KEY_KP3, // 3 + [ 0x04 ] = KEY_KP4, // 4 + [ 0x05 ] = KEY_KP5, // 5 + [ 0x06 ] = KEY_KP6, // 6 + [ 0x07 ] = KEY_KP7, // 7 + [ 0x08 ] = KEY_KP8, // 8 + [ 0x09 ] = KEY_KP9, // 9 + [ 0x0b ] = KEY_RED, // red button + [ 0x0c ] = KEY_OPTION, // black key without text + [ 0x0d ] = KEY_MENU, // menu + [ 0x0f ] = KEY_MUTE, // mute + [ 0x10 ] = KEY_VOLUMEUP, // volume + + [ 0x11 ] = KEY_VOLUMEDOWN, // volume - + [ 0x1e ] = KEY_NEXT, // skip >| + [ 0x1f ] = KEY_EXIT, // back/exit + [ 0x20 ] = KEY_CHANNELUP, // channel / program + + [ 0x21 ] = KEY_CHANNELDOWN, // channel / program - + [ 0x22 ] = KEY_CHANNEL, // source (old black remote) + [ 0x24 ] = KEY_PREVIOUS, // replay |< + [ 0x25 ] = KEY_ENTER, // OK + [ 0x26 ] = KEY_SLEEP, // minimize (old black remote) + [ 0x29 ] = KEY_BLUE, // blue key + [ 0x2e ] = KEY_GREEN, // green button + [ 0x30 ] = KEY_PAUSE, // pause + [ 0x32 ] = KEY_REWIND, // backward << + [ 0x34 ] = KEY_FASTFORWARD, // forward >> + [ 0x35 ] = KEY_PLAY, // play + [ 0x36 ] = KEY_STOP, // stop + [ 0x37 ] = KEY_RECORD, // recording + [ 0x38 ] = KEY_YELLOW, // yellow key + [ 0x3b ] = KEY_SELECT, // top right button + [ 0x3c ] = KEY_ZOOM, // full + [ 0x3d ] = KEY_POWER, // system power (green button) +}; +EXPORT_SYMBOL(ir_codes_hauppauge_new); + /* -------------------------------------------------------------------------- */ static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir) @@ -140,9 +179,7 @@ static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *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); -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) input_sync(dev); -#endif } /* -------------------------------------------------------------------------- */ @@ -156,9 +193,7 @@ void ir_input_init(struct input_dev *dev, struct ir_input_state *ir, if (ir_codes) memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes)); -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) init_input_dev(dev); -#endif dev->keycode = ir->ir_codes; dev->keycodesize = sizeof(IR_KEYTAB_TYPE); dev->keycodemax = IR_KEYTAB_SIZE; @@ -201,6 +236,8 @@ void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir, #endif } +/* -------------------------------------------------------------------------- */ + u32 ir_extract_bits(u32 data, u32 mask) { int mbit, vbit; @@ -218,10 +255,78 @@ u32 ir_extract_bits(u32 data, u32 mask) return value; } +static int inline getbit(u32 *samples, int bit) +{ + return (samples[bit/32] & (1 << (31-(bit%32)))) ? 1 : 0; +} + +/* sump raw samples for visual debugging ;) */ +int ir_dump_samples(u32 *samples, int count) +{ + int i, bit, start; + + printk(KERN_DEBUG "ir samples: "); + start = 0; + for (i = 0; i < count * 32; i++) { + bit = getbit(samples,i); + if (bit) + start = 1; + if (0 == start) + continue; + printk("%s", bit ? "#" : "_"); + } + printk("\n"); + return 0; +} + +/* decode raw samples, biphase coding, used by rc5 for example */ +int ir_decode_biphase(u32 *samples, int count, int low, int high) +{ + int i,last,bit,len,flips; + u32 value; + + /* find start bit (1) */ + for (i = 0; i < 32; i++) { + bit = getbit(samples,i); + if (bit) + break; + } + + /* go decoding */ + len = 0; + flips = 0; + value = 1; + for (; i < count * 32; i++) { + if (len > high) + break; + if (flips > 1) + break; + last = bit; + bit = getbit(samples,i); + if (last == bit) { + len++; + continue; + } + if (len < low) { + len++; + flips++; + continue; + } + value <<= 1; + value |= bit; + flips = 0; + len = 1; + } + return value; +} + 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); /* * Local variables: |