Chinaunix首页 | 论坛 | 博客
  • 博客访问: 389992
  • 博文数量: 120
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 741
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-27 18:15
文章分类

全部博文(120)

文章存档

2016年(13)

2015年(41)

2014年(66)

我的朋友

分类: Android平台

2014-08-12 00:25:00

一. 让CT可以接收任意遥控器的键值
1. CubieTruck带了一个红外接收器,但是随便拿一个遥控器来用完全没有反应的.
这是因为在驱动中有对地址码的检查:
在lichee/linux-3.3/drivers/input/keyboard/sun7i-ir.c中(红外接收器的驱动)
  1. static int ir_code_valid(unsigned long code)
  2. {
  3.     unsigned long tmp1, tmp2;
  4. #ifdef IR_CHECK_ADDR_CODE
  5.     /* Check Address Value */
  6.     if ((code&0xffff) != (IR_ADDR_CODE&0xffff))
  7.         return 0; /* Address Error */

  8.     tmp1 = code & 0x00ff0000;
  9.     tmp2 = (code & 0xff000000)>>8;

  10.     return ((tmp1^tmp2)==0x00ff0000); /* Check User Code */
  11. #else
  12.     /* Do Not Check Address Value */
  13.     tmp1 = code & 0x00ff00ff;
  14.     tmp2 = (code & 0xff00ff00)>>8;

  15.     //return ((tmp1^tmp2)==0x00ff00ff);
  16.     return (((tmp1^tmp2) & 0x00ff0000)==0x00ff0000 );
  17. #endif /* #ifdef IR_CHECK_ADDR_CODE */
  18. }
这个地址码是: #define IR_ADDR_CODE            (0x9f00)
所以只要不是0x9f00的地址码都直接返回了,也就不再上报了.
2. 去掉检查
为了让所有的遥控器都能使用,需要将这个IR_CHECK_ADDR_CODE宏注掉即可
在./lichee/linux-3.3/drivers/input/keyboard/ir-keymap.h中
  1. //#define IR_CHECK_ADDR_CODE
3. 重新烧写boot.img就可以在getevent中接收到键值了.

二. 让遥控器好用
2.1 power关机
修改 /system/usr/keylayout/sun7i-ir.kl
  1. key 255 POWER WAKE
注: 这儿的255是从getevent中读取出来的,我的遥控器power键会发送键值255
改完就实现了关机.
2.2 power开机
a. power键只关机而不能开机,(其实:当按下power实际上是进入了休眠状态而不是关机状态)
不能开机的真正原因是:
内核中的sun7i-ir.c中对休眠进行了处理,把红外的时钟关闭了.
即在休眠状态下,红外不接收任何信号,所以也就不能唤醒了.
b. 解决方法:
把sun-7i-ir.c修改成如下形式: 即将suspend的处理的两个函数,改为空.
  1. #if 0 //add by cong start
  2. #ifdef CONFIG_HAS_EARLYSUSPEND
  3. static void sun7i_ir_suspend(struct early_suspend *h)
  4. {
  5.     /*    unsigned long tmp = 0;
  6.         int ret;
  7.         struct sun7i_ir_data *ts = container_of(h, struct sun7i_ir_data, early_suspend);

  8.         tmp = readl(IR_BASE+IR_CTRL_REG);
  9.         tmp &= 0xfffffffc;
  10.         writel(tmp, IR_BASE+IR_CTRL_REG);
  11.         */
  12.     dbmsg("EARLYSUSPEND:enter earlysuspend: sun7i_ir_suspend. \n");
  13.     if(NULL == ir_clk || IS_ERR(ir_clk)) {
  14.         printk("ir_clk handle is invalid, just return!\n");
  15.         return;
  16.     } else {
  17.         clk_disable(ir_clk);
  18.     }

  19.     if(NULL == apb_ir_clk || IS_ERR(ir_clk)) {
  20.         printk("ir_clk handle is invalid, just return!\n");
  21.         return;
  22.     } else {
  23.         clk_disable(apb_ir_clk);
  24.     }

  25. }
  26. static void sun7i_ir_resume(struct early_suspend *h)
  27. {

  28.     dbmsg("EARLYSUSPEND:enter laterresume: sun7i_ir_resume. \n");

  29.     ir_code = 0;
  30.     timer_used = 0;
  31.     ir_reset_rawbuffer();
  32.     ir_clk_cfg();
  33.     ir_reg_cfg();
  34. }
  35. #endif
  36. #endif //add by cong end

  37. static void sun7i_ir_suspend(struct early_suspend *h)
  38. {
  39. }

  40. static void sun7i_ir_resume(struct early_suspend *h)
  41. {
  42. }
这样就实现在power键开机(唤醒).
3.继续修改/system/usr/keylayout/sun7i-ir.kl就可以实现更多的功能了.

阅读(1127) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~