瑞芯的Android 4.4的SDK中kernel的补丁例如以下:

  1. diff --git a/arch/arm/boot/dts/rk3288-tb_8846.dts b/arch/arm/boot/dts/rk3288-tb_8846.dts
  2. index c92d973..850fd42 100644
  3. --- a/arch/arm/boot/dts/rk3288-tb_8846.dts
  4. +++ b/arch/arm/boot/dts/rk3288-tb_8846.dts
  5. @@ -533,6 +533,15 @@
  6. status = "okay";
  7. };
  8.  
  9. + sensor@48 {
  10. + compatible = "light_cm3218";
  11. + reg = <0x48>;
  12. + type = <SENSOR_TYPE_LIGHT>;
  13. + irq-gpio = <&gpio8 GPIO_A3 IRQ_TYPE_EDGE_FALLING>;
  14. + irq_enable = <0>;
  15. + poll_delay_ms = <30>;
  16. + layout = <1>;
  17. + };
  18. };
  19.  
  20. &i2c2 {
  21. diff --git a/drivers/i2c/busses/i2c-rockchip.c b/drivers/i2c/busses/i2c-rockchip.c
  22. index 3f64ff0..db28071 100644
  23. --- a/drivers/i2c/busses/i2c-rockchip.c
  24. +++ b/drivers/i2c/busses/i2c-rockchip.c
  25. @@ -716,12 +716,17 @@ static int rockchip_i2c_doxfer(struct rockchip_i2c *i2c,
  26.  
  27. i2c_writel(I2C_IPD_ALL_CLEAN, i2c->regs + I2C_IPD);
  28. rockchip_i2c_disable_irq(i2c);
  29. - rockchip_i2c_disable(i2c);
  30. spin_unlock_irqrestore(&i2c->lock, flags);
  31.  
  32. - if (error == -EAGAIN)
  33. - i2c_dbg(i2c->dev, "No ack(complete_what: 0x%x), Maybe slave(addr: 0x%04x) not exist or abnormal power-on\n",
  34. + if (error == -EAGAIN){
  35. + i2c_dbg(i2c->dev,
  36. + "No ack(complete_what: 0x%x), Maybe slave(addr: 0x%04x) not exist or abnormal power-on\n",
  37. i2c->complete_what, i2c->addr);
  38. + rockchip_i2c_send_stop(i2c);
  39. + msleep(5);
  40. + }
  41. +
  42. + rockchip_i2c_disable(i2c);
  43. return error;
  44. }
  45.  
  46. diff --git a/drivers/input/sensors/lsensor/cm3218.c b/drivers/input/sensors/lsensor/cm3218.c
  47. index b6201d6..8eee009 100644
  48. --- a/drivers/input/sensors/lsensor/cm3218.c
  49. +++ b/drivers/input/sensors/lsensor/cm3218.c
  50. @@ -119,39 +119,46 @@ static int cm3218_read(struct i2c_client *client, u8 reg)
  51. }
  52.  
  53. /****************operate according to sensor chip:start************/
  54. +static int cm3218_read_lux(struct i2c_client *client, int *lux)
  55. +{
  56. + int lux_data;
  57. +
  58. + lux_data = cm3218_read(client, CM3218_REG_ADDR_ALS);
  59. + if (lux_data < 0) {
  60. + dev_err(&client->dev, "Error in reading Lux DATA\n");
  61. + return lux_data;
  62. + }
  63. +
  64. + dev_vdbg(&client->dev, "lux = %u\n", lux_data);
  65. +
  66. + if (lux_data < 0)
  67. + return lux_data;
  68. +
  69. + *lux = lux_data * LENSFACTOR;
  70. + *lux /= 1000;
  71. +
  72. + return 0;
  73. +}
  74.  
  75. static int sensor_active(struct i2c_client *client, int enable, int rate)
  76. {
  77. - struct sensor_private_data *sensor =
  78. - (struct sensor_private_data *) i2c_get_clientdata(client);
  79. - int result = 0;
  80. - int status = 0;
  81. -
  82. - sensor->client->addr = sensor->ops->ctrl_reg;
  83. - sensor->ops->ctrl_data = cm3218_read(client,sensor->client->addr);
  84. -
  85. - //register setting according to chip datasheet
  86. - if(!enable)
  87. - {
  88. - status = CM3218_CMD_ALS_SD; //cm3218
  89. - sensor->ops->ctrl_data |= status;
  90. - }
  91. - else
  92. - {
  93. - status = ~CM3218_CMD_ALS_SD; //cm3218
  94. - sensor->ops->ctrl_data &= status;
  95. + int status;
  96. +
  97. + if (!enable) {
  98. + status = cm3218_write(client, CM3218_REG_ADDR_CMD,0x0001);
  99. + } else {
  100. + status = cm3218_write(client, CM3218_REG_ADDR_CMD,0x0000);
  101. }
  102.  
  103. - DBG("%s:reg=0x%x,reg_ctrl=0x%x,enable=%d\n",__func__,sensor->ops->ctrl_reg, sensor->ops->ctrl_data, enable);
  104. - result = cm3218_write(client,sensor->client->addr, sensor->ops->ctrl_data);
  105. - if(result)
  106. + if (status)
  107. printk("%s:fail to active sensor\n",__func__);
  108. -
  109. - return result;
  110.  
  111. + return status;
  112. }
  113.  
  114. -
  115. +/*
  116. + * cm3218 device initialization.
  117. + */
  118. static int sensor_init(struct i2c_client *client)
  119. {
  120. int status, i;
  121. @@ -159,21 +166,24 @@ static int sensor_init(struct i2c_client *client)
  122. (struct sensor_private_data *) i2c_get_clientdata(client);
  123.  
  124. for (i = 0; i < 5; i++) {
  125. - status = cm3218_write(client, CM3218_REG_ADDR_CMD,
  126. - CM3218_CMD_ALS_SD);
  127. + /* shut down */
  128. + status = cm3218_write(client, CM3218_REG_ADDR_CMD, CM3218_CMD_ALS_SD);
  129. if (status >= 0)
  130. break;
  131. + /* Clear interrupt */
  132. cm3218_read_ara(client);
  133. }
  134.  
  135. + /* power on (1T, HS, interrupt disable) */
  136. status = cm3218_write(client, CM3218_REG_ADDR_CMD, CM3218_DEFAULT_CMD);
  137. if (status < 0) {
  138. dev_err(&client->dev, "Init CM3218 CMD fails\n");
  139. return status;
  140. }
  141.  
  142. - if(sensor->pdata->irq_enable)
  143. - {
  144. + /* enable interrupt */
  145. + if(sensor->pdata->irq_enable){
  146. +
  147. status = cm3218_write(client, CM3218_REG_ADDR_CMD, CM3218_DEFAULT_CMD | CM3218_CMD_ALS_INT_EN);
  148. if (status < 0) {
  149. dev_err(&client->dev, "Init CM3218 CMD fails\n");
  150. @@ -181,9 +191,7 @@ static int sensor_init(struct i2c_client *client)
  151. }
  152. }
  153.  
  154. - /* Clean interrupt status */
  155. - cm3218_read(client, CM3218_REG_ADDR_STATUS);
  156. -
  157. +
  158. return status;
  159. }
  160.  
  161. @@ -224,25 +232,7 @@ report:
  162. return index;
  163. }
  164.  
  165. -static int cm3218_read_lux(struct i2c_client *client, int *lux)
  166. -{
  167. - int lux_data;
  168. -
  169. - lux_data = cm3218_read(client, CM3218_REG_ADDR_ALS);
  170. - if (lux_data < 0) {
  171. - dev_err(&client->dev, "Error in reading Lux DATA\n");
  172. - return lux_data;
  173. - }
  174. -
  175. - dev_vdbg(&client->dev, "lux = %u\n", lux_data);
  176.  
  177. - if (lux_data < 0)
  178. - return lux_data;
  179. -
  180. - *lux = lux_data * LENSFACTOR;
  181. - *lux /= 1000;
  182. - return 0;
  183. -}
  184.  
  185. static int sensor_report_value(struct i2c_client *client)
  186. {
  187. @@ -254,14 +244,14 @@ static int sensor_report_value(struct i2c_client *client)
  188. cm3218_read_lux(client,&result);
  189.  
  190. index = light_report_value(sensor->input_dev, result);
  191. +
  192. DBG("%s:%s result=0x%x,index=%d\n",__func__,sensor->ops->name, result,index);
  193.  
  194. - if((sensor->pdata->irq_enable)&& (sensor->ops->int_status_reg >= 0)) //read sensor intterupt status register
  195. - {
  196. -
  197. + /* read sensor intterupt status register */
  198. + if((sensor->pdata->irq_enable)&& (sensor->ops->int_status_reg >= 0)){
  199. +
  200. result= sensor_read_reg(client, sensor->ops->int_status_reg);
  201. - if(result)
  202. - {
  203. + if(result){
  204. printk("%s:fail to clear sensor int status,ret=0x%x\n",__func__,result);
  205. }
  206. }
  207. @@ -272,17 +262,17 @@ static int sensor_report_value(struct i2c_client *client)
  208.  
  209. struct sensor_operate light_cm3218_ops = {
  210. .name = "cm3218",
  211. - .type = SENSOR_TYPE_LIGHT, //sensor type and it should be correct
  212. - .id_i2c = LIGHT_ID_CM3218, //i2c id number
  213. - .read_reg = CM3218_REG_ADDR_ALS, //read data
  214. - .read_len = 2, //data length
  215. - .id_reg = SENSOR_UNKNOW_DATA, //read device id from this register
  216. - .id_data = SENSOR_UNKNOW_DATA, //device id
  217. - .precision = 16, //8 bits
  218. - .ctrl_reg = CM3218_REG_ADDR_CMD, //enable or disable
  219. - .int_status_reg = CM3218_REG_ADDR_STATUS, //intterupt status register
  220. - .range = {0,65535}, //range
  221. - .brightness ={10,255}, // brightness
  222. + .type = SENSOR_TYPE_LIGHT, /* sensor type and it should be correct */
  223. + .id_i2c = LIGHT_ID_CM3218, /* i2c id number */
  224. + .read_reg = CM3218_REG_ADDR_ALS, /* read data */
  225. + .read_len = 2, /* data length */
  226. + .id_reg = SENSOR_UNKNOW_DATA, /* read device id from this register */
  227. + .id_data = SENSOR_UNKNOW_DATA, /* device id */
  228. + .precision = 16, /* 8 bits */
  229. + .ctrl_reg = CM3218_REG_ADDR_CMD, /* enable or disable */
  230. + .int_status_reg = SENSOR_UNKNOW_DATA, /* intterupt status register */
  231. + .range = {0,65535}, /* range */
  232. + .brightness ={10,255}, /* brightness */
  233. .trig = SENSOR_UNKNOW_DATA,
  234. .active = sensor_active,
  235. .init = sensor_init,
  236. @@ -291,7 +281,7 @@ struct sensor_operate light_cm3218_ops = {
  237.  
  238. /****************operate according to sensor chip:end************/
  239.  
  240. -//function name should not be changed
  241. +/* function name should not be changed */
  242. static struct sensor_operate *light_get_ops(void)
  243. {
  244. return &light_cm3218_ops;
  245. @@ -317,5 +307,3 @@ static void __exit light_cm3218_exit(void)
  246.  
  247. module_init(light_cm3218_init);
  248. module_exit(light_cm3218_exit);
  249. -
  250. -
  251. diff --git a/drivers/input/sensors/sensor-dev.c b/drivers/input/sensors/sensor-dev.c
  252. index 960d44f..68ab664 100755
  253. --- a/drivers/input/sensors/sensor-dev.c
  254. +++ b/drivers/input/sensors/sensor-dev.c
  255. @@ -2113,9 +2113,9 @@ static const struct i2c_device_id sensor_id[] = {
  256. /*light sensor*/
  257. {"lightsensor", LIGHT_ID_ALL},
  258. {"light_cm3217", LIGHT_ID_CM3217},
  259. - {"light_cm3218", LIGHT_ID_CM3218},
  260. - {"light_cm3232", LIGHT_ID_CM3232},
  261. - {"light_al3006", LIGHT_ID_AL3006},
  262. + {"light_cm3218", LIGHT_ID_CM3218},
  263. + {"light_cm3232", LIGHT_ID_CM3232},
  264. + {"light_al3006", LIGHT_ID_AL3006},
  265. {"ls_stk3171", LIGHT_ID_STK3171},
  266. {"ls_isl29023", LIGHT_ID_ISL29023},
  267. {"ls_ap321xx", LIGHT_ID_AP321XX},
  268. @@ -2162,8 +2162,9 @@ static struct of_device_id sensor_dt_ids[] = {
  269. ^M
  270. /*light sensor*/
  271. { .compatible = "light_cm3217" },
  272. - { .compatible = "light_cm3232" },
  273. - { .compatible = "light_al3006" },
  274. + { .compatible = "light_cm3218" },
  275. + { .compatible = "light_cm3232" },
  276. + { .compatible = "light_al3006" },
  277. { .compatible = "ls_stk3171" },
  278. { .compatible = "ls_ap321xx" },
  279. ^M
  280. diff --git a/include/linux/sensor-dev.h b/include/linux/sensor-dev.h
  281. index 16e916f..6c21fcd 100755
  282. --- a/include/linux/sensor-dev.h
  283. +++ b/include/linux/sensor-dev.h
  284. @@ -80,7 +80,7 @@ enum sensor_id {
  285. ^M
  286. LIGHT_ID_ALL,
  287. LIGHT_ID_CM3217,
  288. - LIGHT_ID_CM3218,
  289. + LIGHT_ID_CM3218, /* ID = 46 */^M
  290. LIGHT_ID_CM3232,
  291. LIGHT_ID_AL3006,
  292. LIGHT_ID_STK3171,

rk3288的SDK修复cm3218光敏驱动bug的更多相关文章

  1. 服务器cpu过高修复:操作系统内核bug导致

    服务器cpu过高修复:操作系统内核bug导致修改系统内核参数/etc/sysctl.conf添加下面2条参数:vm.dirty_background_ratio=5vm.dirty_ratio=10

  2. 解决由于显卡驱动BUG导致桌面右键卡顿的问题:bat文件源码

    @ ECHO OFF%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe&q ...

  3. 一个MySQL-JDBC驱动bug引起的血案……

    问题背景 公司是做电商系统的,整个系统搭建在华为云上.系统设计的时候,考虑到后续的用户和订单数量比较大,需要使用一些大数据库的组件.关系型数据库这块,考虑到后续数据量的快速增长,不是直接写入MySQL ...

  4. 一个MySQL JDBC驱动bug引起的血案

    1.1      问题背景 公司是做电商系统的,整个系统搭建在华为云上.系统设计的时候,考虑到后续的用户和订单数量比较大,需要使用一些大数据库的组件.关系型数据库这块,考虑到后续数据量的快速增长,不是 ...

  5. ux.form.field.TreePicker 扩展,修复火狐不能展开bug

    /** * A Picker field that contains a tree panel on its popup, enabling selection of tree nodes. * 动态 ...

  6. duilib修复ActiveXUI控件bug,以支持flash透明动态背景

    转载请说明原出处,谢谢~~ 昨天在QQ控件里和同学说起QQ2013登陆窗体的开发,从界面角度考虑,单单一个登陆界面是很容易做出来的.腾讯公司为了 防止各种盗号行为可谓煞费苦心,QQ2013采用了动态背 ...

  7. mac系统下修复第三方Python包bug

    发现问题 今天在github上fork了CI 3.x的中文手册,按照README文档一步步进行Sphinx和相关工具的安装,最终build生成html版手册.操作到第6步执行`make html`的时 ...

  8. Scrum立会报告+燃尽图(十一月十九日总第二十七次):功能开发与修复上一阶段bug

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2284 项目地址:https://git.coding.net/zhang ...

  9. Scrum立会报告+燃尽图(十一月十七日总第二十五次):设计调查问卷;修复上一阶段bug

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2284 项目地址:https://git.coding.net/zhang ...

随机推荐

  1. hibernate实体的几种状态:

    hibernate实体的几种状态: 实体的生命周期中,实体主要经过瞬时(Transient),托管(Attatched或Managed),游离(Detached)和销毁(Removed)四个状态. 瞬 ...

  2. bzoj1453

    这是一道好题,按行建线段树,每个点维护上下边界的连通性,详细见代码注释 网上写法不一,自认为比较简单,就放出来相出来献丑吧 ..,..] of longint; //u[]上边界,d[]下边界 s,f ...

  3. POJ 2728 Desert King ★(01分数规划介绍 && 应用の最优比率生成树)

    [题意]每条路径有一个 cost 和 dist,求图中 sigma(cost) / sigma(dist) 最小的生成树. 标准的最优比率生成树,楼教主当年开场随手1YES然后把别人带错方向的题Orz ...

  4. (五)学习JavaScript之firstChild 属性

    参考:http://www.w3school.com.cn/jsref/prop_node_firstchild.asp 定义和用法 firstChild 属性返回指定节点的首个子节点,以 Node ...

  5. ECSHOP:首页实现显示子分类商品,并实现点击Tab页切换分类商品

    例子:首页实现显示子分类商品,并实现点击Tab页切换分类商品(非AJAX) 开始:    1. 打开调试开关     文件地址:include/cls_template.php 找到 : functi ...

  6. gdi写的2048

    //-------------------------------------------[头文件及引用]----------------------------------------------- ...

  7. delphi通过OLE对word进行单元格合并操作

    uses comobj, word2000procedure TForm1.Button2Click(Sender: TObject);var WordApp, WordDoc,table: OleV ...

  8. Windbg源码调试

    Windbg提供比VS2008丰富很多的调试命令,尤其是调试多线程程序. 今天试着怎么使用源代码方式调试.为了说明调试命令,<C++标准库>一书里的例子做示范. // testcast.c ...

  9. getsockopt/setsockopt 函数说明

    [ getsockopt/setsockopt系统调用]       功能描述: 获取或者设置与某个套接字关联的选 项.选项可能存在于多层协议中,它们总会出现在最上面的套接字层.当操作套接字选项时,选 ...

  10. Android Activity 生命周期中onStart()和onResume()的区别

    首先了解Activity的四种状态 Running状态:一个新的Activity启动入栈后,它在屏幕最前端,处于栈的最顶端,此时它处于可见并可和用户交互的激活状态.Paused状态:当Activity ...