aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/common
diff options
context:
space:
mode:
authorHermann Pitton <hermann-pitton@arcor.de>2006-12-07 19:45:28 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:12 -0500
commit9160723ed620f31bf38332dee02041b1cb4c9967 (patch)
tree1e2bbbb78b98d9c21a769634f908874f79cbc7ba /drivers/media/common
parentc8f71b01a50597e298dc3214a2f2be7b8d31170c (diff)
V4L/DVB (4961): Add support for the ASUS P7131 remote control
Besides adding the board specific code, this patch moves the RC5 decoding code from bt8xx to ir-functions.c to make it available for all drivers. Signed-off-by: Marc Fargas <telenieko.telenieko.com> Signed-off-by: Hermann Pitton <hermann-pitton@arcor.de> Signed-off-by: Hartmut Hackmann <hartmut.hackmann@t-online.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/common')
-rw-r--r--drivers/media/common/ir-functions.c110
-rw-r--r--drivers/media/common/ir-keymaps.c54
2 files changed, 164 insertions, 0 deletions
diff --git a/drivers/media/common/ir-functions.c b/drivers/media/common/ir-functions.c
index 9a8dd8764c99..cbf7c0564889 100644
--- a/drivers/media/common/ir-functions.c
+++ b/drivers/media/common/ir-functions.c
@@ -256,6 +256,112 @@ int ir_decode_biphase(u32 *samples, int count, int low, int high)
256 return value; 256 return value;
257} 257}
258 258
259/* RC5 decoding stuff, moved from bttv-input.c to share it with
260 * saa7134 */
261
262/* decode raw bit pattern to RC5 code */
263u32 ir_rc5_decode(unsigned int code)
264{
265 unsigned int org_code = code;
266 unsigned int pair;
267 unsigned int rc5 = 0;
268 int i;
269
270 for (i = 0; i < 14; ++i) {
271 pair = code & 0x3;
272 code >>= 2;
273
274 rc5 <<= 1;
275 switch (pair) {
276 case 0:
277 case 2:
278 break;
279 case 1:
280 rc5 |= 1;
281 break;
282 case 3:
283 dprintk(1, "ir-common: ir_rc5_decode(%x) bad code\n", org_code);
284 return 0;
285 }
286 }
287 dprintk(1, "ir-common: code=%x, rc5=%x, start=%x, toggle=%x, address=%x, "
288 "instr=%x\n", rc5, org_code, RC5_START(rc5),
289 RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5));
290 return rc5;
291}
292
293void ir_rc5_timer_end(unsigned long data)
294{
295 struct card_ir *ir = (struct card_ir *)data;
296 struct timeval tv;
297 unsigned long current_jiffies, timeout;
298 u32 gap;
299 u32 rc5 = 0;
300
301 /* get time */
302 current_jiffies = jiffies;
303 do_gettimeofday(&tv);
304
305 /* avoid overflow with gap >1s */
306 if (tv.tv_sec - ir->base_time.tv_sec > 1) {
307 gap = 200000;
308 } else {
309 gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
310 tv.tv_usec - ir->base_time.tv_usec;
311 }
312
313 /* Allow some timmer jitter (RC5 is ~24ms anyway so this is ok) */
314 if (gap < 28000) {
315 dprintk(1, "ir-common: spurious timer_end\n");
316 return;
317 }
318
319 ir->active = 0;
320 if (ir->last_bit < 20) {
321 /* ignore spurious codes (caused by light/other remotes) */
322 dprintk(1, "ir-common: short code: %x\n", ir->code);
323 } else {
324 ir->code = (ir->code << ir->shift_by) | 1;
325 rc5 = ir_rc5_decode(ir->code);
326
327 /* two start bits? */
328 if (RC5_START(rc5) != ir->start) {
329 dprintk(1, "ir-common: rc5 start bits invalid: %u\n", RC5_START(rc5));
330
331 /* right address? */
332 } else if (RC5_ADDR(rc5) == ir->addr) {
333 u32 toggle = RC5_TOGGLE(rc5);
334 u32 instr = RC5_INSTR(rc5);
335
336 /* Good code, decide if repeat/repress */
337 if (toggle != RC5_TOGGLE(ir->last_rc5) ||
338 instr != RC5_INSTR(ir->last_rc5)) {
339 dprintk(1, "ir-common: instruction %x, toggle %x\n", instr,
340 toggle);
341 ir_input_nokey(ir->dev, &ir->ir);
342 ir_input_keydown(ir->dev, &ir->ir, instr,
343 instr);
344 }
345
346 /* Set/reset key-up timer */
347 timeout = current_jiffies + (500 + ir->rc5_key_timeout
348 * HZ) / 1000;
349 mod_timer(&ir->timer_keyup, timeout);
350
351 /* Save code for repeat test */
352 ir->last_rc5 = rc5;
353 }
354 }
355}
356
357void ir_rc5_timer_keyup(unsigned long data)
358{
359 struct card_ir *ir = (struct card_ir *)data;
360
361 dprintk(1, "ir-common: key released\n");
362 ir_input_nokey(ir->dev, &ir->ir);
363}
364
259EXPORT_SYMBOL_GPL(ir_input_init); 365EXPORT_SYMBOL_GPL(ir_input_init);
260EXPORT_SYMBOL_GPL(ir_input_nokey); 366EXPORT_SYMBOL_GPL(ir_input_nokey);
261EXPORT_SYMBOL_GPL(ir_input_keydown); 367EXPORT_SYMBOL_GPL(ir_input_keydown);
@@ -265,6 +371,10 @@ EXPORT_SYMBOL_GPL(ir_dump_samples);
265EXPORT_SYMBOL_GPL(ir_decode_biphase); 371EXPORT_SYMBOL_GPL(ir_decode_biphase);
266EXPORT_SYMBOL_GPL(ir_decode_pulsedistance); 372EXPORT_SYMBOL_GPL(ir_decode_pulsedistance);
267 373
374EXPORT_SYMBOL_GPL(ir_rc5_decode);
375EXPORT_SYMBOL_GPL(ir_rc5_timer_end);
376EXPORT_SYMBOL_GPL(ir_rc5_timer_keyup);
377
268/* 378/*
269 * Local variables: 379 * Local variables:
270 * c-basic-offset: 8 380 * c-basic-offset: 8
diff --git a/drivers/media/common/ir-keymaps.c b/drivers/media/common/ir-keymaps.c
index 0e948a5c5a03..4a54a559d81c 100644
--- a/drivers/media/common/ir-keymaps.c
+++ b/drivers/media/common/ir-keymaps.c
@@ -1606,3 +1606,57 @@ IR_KEYTAB_TYPE ir_codes_budget_ci_old[IR_KEYTAB_SIZE] = {
1606}; 1606};
1607 1607
1608EXPORT_SYMBOL_GPL(ir_codes_budget_ci_old); 1608EXPORT_SYMBOL_GPL(ir_codes_budget_ci_old);
1609
1610/*
1611 * Marc Fargas <telenieko@telenieko.com>
1612 * this is the remote control that comes with the asus p7131
1613 * which has a label saying is "Model PC-39"
1614 */
1615IR_KEYTAB_TYPE ir_codes_asus_pc39[IR_KEYTAB_SIZE] = {
1616 /* Keys 0 to 9 */
1617 [ 0x15 ] = KEY_0,
1618 [ 0x29 ] = KEY_1,
1619 [ 0x2d ] = KEY_2,
1620 [ 0x2b ] = KEY_3,
1621 [ 0x09 ] = KEY_4,
1622 [ 0x0d ] = KEY_5,
1623 [ 0x0b ] = KEY_6,
1624 [ 0x31 ] = KEY_7,
1625 [ 0x35 ] = KEY_8,
1626 [ 0x33 ] = KEY_9,
1627
1628 [ 0x3e ] = KEY_RADIO, /* radio */
1629 [ 0x03 ] = KEY_MENU, /* dvd/menu */
1630 [ 0x2a ] = KEY_VOLUMEUP,
1631 [ 0x19 ] = KEY_VOLUMEDOWN,
1632 [ 0x37 ] = KEY_UP,
1633 [ 0x3b ] = KEY_DOWN,
1634 [ 0x27 ] = KEY_LEFT,
1635 [ 0x2f ] = KEY_RIGHT,
1636 [ 0x25 ] = KEY_VIDEO, /* video */
1637 [ 0x39 ] = KEY_AUDIO, /* music */
1638
1639 [ 0x21 ] = KEY_TV, /* tv */
1640 [ 0x1d ] = KEY_EXIT, /* back */
1641 [ 0x0a ] = KEY_CHANNELUP, /* channel / program + */
1642 [ 0x1b ] = KEY_CHANNELDOWN, /* channel / program - */
1643 [ 0x1a ] = KEY_ENTER, /* enter */
1644
1645 [ 0x06 ] = KEY_PAUSE, /* play/pause */
1646 [ 0x1e ] = KEY_PREVIOUS, /* rew */
1647 [ 0x26 ] = KEY_NEXT, /* forward */
1648 [ 0x0e ] = KEY_REWIND, /* backward << */
1649 [ 0x3a ] = KEY_FASTFORWARD, /* forward >> */
1650 [ 0x36 ] = KEY_STOP,
1651 [ 0x2e ] = KEY_RECORD, /* recording */
1652 [ 0x16 ] = KEY_POWER, /* the button that reads "close" */
1653
1654 [ 0x11 ] = KEY_ZOOM, /* full screen */
1655 [ 0x13 ] = KEY_MACRO, /* recall */
1656 [ 0x23 ] = KEY_HOME, /* home */
1657 [ 0x05 ] = KEY_PVR, /* picture */
1658 [ 0x3d ] = KEY_MUTE, /* mute */
1659 [ 0x01 ] = KEY_DVD, /* dvd */
1660};
1661
1662EXPORT_SYMBOL_GPL(ir_codes_asus_pc39);