aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/common
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/common')
-rw-r--r--drivers/media/common/ir-common.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c
index ab7a1fba4427..a0e700d7a4a4 100644
--- a/drivers/media/common/ir-common.c
+++ b/drivers/media/common/ir-common.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * $Id: ir-common.c,v 1.11 2005/07/07 14:44:43 mchehab Exp $
3 * 2 *
4 * some common structs and functions to handle infrared remotes via 3 * some common structs and functions to handle infrared remotes via
5 * input layer ... 4 * input layer ...
@@ -335,6 +334,72 @@ int ir_dump_samples(u32 *samples, int count)
335 return 0; 334 return 0;
336} 335}
337 336
337/* decode raw samples, pulse distance coding used by NEC remotes */
338int ir_decode_pulsedistance(u32 *samples, int count, int low, int high)
339{
340 int i,last,bit,len;
341 u32 curBit;
342 u32 value;
343
344 /* find start burst */
345 for (i = len = 0; i < count * 32; i++) {
346 bit = getbit(samples,i);
347 if (bit) {
348 len++;
349 } else {
350 if (len >= 29)
351 break;
352 len = 0;
353 }
354 }
355
356 /* start burst to short */
357 if (len < 29)
358 return 0xffffffff;
359
360 /* find start silence */
361 for (len = 0; i < count * 32; i++) {
362 bit = getbit(samples,i);
363 if (bit) {
364 break;
365 } else {
366 len++;
367 }
368 }
369
370 /* silence to short */
371 if (len < 7)
372 return 0xffffffff;
373
374 /* go decoding */
375 len = 0;
376 last = 1;
377 value = 0; curBit = 1;
378 for (; i < count * 32; i++) {
379 bit = getbit(samples,i);
380 if (last) {
381 if(bit) {
382 continue;
383 } else {
384 len = 1;
385 }
386 } else {
387 if (bit) {
388 if (len > (low + high) /2)
389 value |= curBit;
390 curBit <<= 1;
391 if (curBit == 1)
392 break;
393 } else {
394 len++;
395 }
396 }
397 last = bit;
398 }
399
400 return value;
401}
402
338/* decode raw samples, biphase coding, used by rc5 for example */ 403/* decode raw samples, biphase coding, used by rc5 for example */
339int ir_decode_biphase(u32 *samples, int count, int low, int high) 404int ir_decode_biphase(u32 *samples, int count, int low, int high)
340{ 405{
@@ -383,6 +448,7 @@ EXPORT_SYMBOL_GPL(ir_input_keydown);
383EXPORT_SYMBOL_GPL(ir_extract_bits); 448EXPORT_SYMBOL_GPL(ir_extract_bits);
384EXPORT_SYMBOL_GPL(ir_dump_samples); 449EXPORT_SYMBOL_GPL(ir_dump_samples);
385EXPORT_SYMBOL_GPL(ir_decode_biphase); 450EXPORT_SYMBOL_GPL(ir_decode_biphase);
451EXPORT_SYMBOL_GPL(ir_decode_pulsedistance);
386 452
387/* 453/*
388 * Local variables: 454 * Local variables: