#define ALS_2T_200MS (1<<2)\r
#define ALS_4T_400MS (2<<2)\r
#define ALS_8T_800MS (3<<2)\r
-#define ALS_RANGE_57671 (0<<5)\r
-#define ALS_RANGE_28836 (1<<5)\r
+#define ALS_RANGE_57671 (0<<6)\r
+#define ALS_RANGE_28836 (1<<6)\r
\r
//PS_CMD\r
#define PS_SD_ENABLE (0<<0)\r
#define PS_15T_3MS (1<<2)\r
#define PS_20T_4MS (2<<2)\r
#define PS_25T_5MS (3<<2)\r
-#define PS_CUR_100MA (0<<3)\r
-#define PS_CUR_200MA (1<<3)\r
-#define PS_SLP_10MS (0<<4)\r
-#define PS_SLP_30MS (1<<4)\r
-#define PS_SLP_90MS (2<<4)\r
-#define PS_SLP_270MS (3<<4)\r
-#define TRIG_PS_OR_LS (0<<5)\r
-#define TRIG_PS_AND_LS (1<<5)\r
+#define PS_CUR_100MA (0<<4)\r
+#define PS_CUR_200MA (1<<4)\r
+#define PS_SLP_10MS (0<<5)\r
+#define PS_SLP_30MS (1<<5)\r
+#define PS_SLP_90MS (2<<5)\r
+#define PS_SLP_270MS (3<<5)\r
+#define TRIG_PS_OR_LS (0<<7)\r
+#define TRIG_PS_AND_LS (1<<7)\r
\r
//STA_TUS\r
-#define STA_PS_INT (1<<4)\r
-#define STA_ALS_INT (1<<3)\r
+#define STA_PS_INT (1<<5)\r
+#define STA_ALS_INT (1<<4)\r
+\r
\r
\r
/****************operate according to sensor chip:start************/\r
if(result)\r
printk("%s:fail to active sensor\n",__func__);\r
\r
+ if(enable)\r
+ sensor->ops->report(sensor->client);\r
+ \r
return result;\r
\r
}\r
return result;\r
}\r
\r
+ result = sensor_write_reg(client, ALS_THDH1, 0);//it is important,if not then als can not trig intterupt\r
+ if(result)\r
+ {\r
+ printk("%s:line=%d,error\n",__func__,__LINE__);\r
+ return result;\r
+ }\r
\r
- sensor->ops->ctrl_data |= (ALS_1T_100MS | ALS_RANGE_28836);\r
+ result = sensor_write_reg(client, ALS_THDH2, 0);\r
+ if(result)\r
+ {\r
+ printk("%s:line=%d,error\n",__func__,__LINE__);\r
+ return result;\r
+ } \r
+\r
+ sensor->ops->ctrl_data |= ALS_1T_100MS;\r
\r
if(sensor->pdata->irq_enable)\r
sensor->ops->ctrl_data |= ALS_INT_ENABLE;\r
static int light_report_value(struct input_dev *input, int data)\r
{\r
unsigned char index = 0;\r
- if(data <= 10){\r
+ if(data <= 100){\r
index = 0;goto report;\r
}\r
else if(data <= 1600){\r
\r
memset(buffer, 0, 2);\r
\r
- result = sensor_rx_data(client, buffer, sensor->ops->read_len);\r
+ buffer[0] = sensor->ops->read_reg;\r
+ result = sensor_rx_data(client, buffer, sensor->ops->read_len); \r
+ if(result)\r
{\r
printk("%s:line=%d,error\n",__func__,__LINE__);\r
return result;\r
}\r
\r
- value = (short) (((buffer[1]) << 8) | buffer[0]);\r
+ value = (buffer[0] << 8) | buffer[1];\r
+\r
\r
index = light_report_value(sensor->input_dev, value);\r
+\r
+ DBG("%s:%s result=0x%x,index=%d\n",__func__,sensor->ops->name, value,index);\r
\r
if(sensor->pdata->irq_enable)\r
{\r
}\r
}\r
\r
- DBG("%s:%s result=0x%x,index=%d\n",__func__,sensor->ops->name, value,index);\r
\r
return result;\r
}\r
#define ALS_2T_200MS (1<<2)\r
#define ALS_4T_400MS (2<<2)\r
#define ALS_8T_800MS (3<<2)\r
-#define ALS_RANGE_57671 (0<<5)\r
-#define ALS_RANGE_28836 (1<<5)\r
+#define ALS_RANGE_57671 (0<<6)\r
+#define ALS_RANGE_28836 (1<<6)\r
\r
//PS_CMD\r
#define PS_SD_ENABLE (0<<0)\r
#define PS_15T_3MS (1<<2)\r
#define PS_20T_4MS (2<<2)\r
#define PS_25T_5MS (3<<2)\r
-#define PS_CUR_100MA (0<<3)\r
-#define PS_CUR_200MA (1<<3)\r
-#define PS_SLP_10MS (0<<4)\r
-#define PS_SLP_30MS (1<<4)\r
-#define PS_SLP_90MS (2<<4)\r
-#define PS_SLP_270MS (3<<4)\r
-#define TRIG_PS_OR_LS (0<<5)\r
-#define TRIG_PS_AND_LS (1<<5)\r
+#define PS_CUR_100MA (0<<4)\r
+#define PS_CUR_200MA (1<<4)\r
+#define PS_SLP_10MS (0<<5)\r
+#define PS_SLP_30MS (1<<5)\r
+#define PS_SLP_90MS (2<<5)\r
+#define PS_SLP_270MS (3<<5)\r
+#define TRIG_PS_OR_LS (0<<7)\r
+#define TRIG_PS_AND_LS (1<<7)\r
\r
//STA_TUS\r
-#define STA_PS_INT (1<<4)\r
-#define STA_ALS_INT (1<<3)\r
+#define STA_PS_INT (1<<5)\r
+#define STA_ALS_INT (1<<4)\r
\r
\r
/****************operate according to sensor chip:start************/\r
if(result)\r
printk("%s:fail to active sensor\n",__func__);\r
\r
+ if(enable)\r
+ sensor->ops->report(sensor->client);\r
+\r
return result;\r
\r
}\r
}\r
\r
\r
- sensor->ops->ctrl_data |= (PS_15T_3MS| PS_SLP_90MS | TRIG_PS_OR_LS);\r
+ sensor->ops->ctrl_data |= PS_15T_3MS| PS_SLP_90MS;\r
+ sensor->ops->ctrl_data &= ~TRIG_PS_AND_LS;\r
\r
if(sensor->pdata->irq_enable)\r
sensor->ops->ctrl_data |= PS_INT_ENABLE;\r
\r
memset(buffer, 0, 1);\r
\r
- result = sensor_rx_data(client, buffer, sensor->ops->read_len);\r
+ buffer[0] = sensor->ops->read_reg;\r
+ result = sensor_rx_data(client, buffer, sensor->ops->read_len); \r
+ if(result)\r
{\r
printk("%s:line=%d,error\n",__func__,__LINE__);\r
return result;\r
}\r
\r
+\r
value = buffer[0];\r
\r
- input_report_abs(sensor->input_dev, ABS_DISTANCE, value?0:1);\r
+ input_report_abs(sensor->input_dev, ABS_DISTANCE, (value>>2)?0:1);\r
input_sync(sensor->input_dev);\r
- DBG("%s:%s result=0x%x,index=%d\n",__func__,sensor->ops->name, value,value?0:1); \r
+ DBG("%s:%s result=0x%x,index=%d\n",__func__,sensor->ops->name, value,(value>>2)?0:1); \r
\r
if(sensor->pdata->irq_enable)\r
{\r
\r
gpio_pull_updown(client->irq, PullEnable);\r
irq = gpio_to_irq(client->irq);\r
- //result = request_irq(irq, sensor_interrupt, sensor->ops->trig, client->dev.driver->name, sensor);\r
- result = request_threaded_irq(irq, NULL, sensor_interrupt, sensor->ops->trig, client->dev.driver->name, sensor);\r
+ //result = request_irq(irq, sensor_interrupt, sensor->ops->trig, sensor->ops->name, sensor);\r
+ result = request_threaded_irq(irq, NULL, sensor_interrupt, sensor->ops->trig, sensor->ops->name, sensor);\r
if (result) {\r
printk(KERN_ERR "%s:fail to request irq = %d, ret = 0x%x\n",__func__, irq, result); \r
goto error; \r
/*light sensor*/\r
{"lightsensor", LIGHT_ID_ALL}, \r
{"light_al3006", LIGHT_ID_AL3006},\r
+ {"ls_stk3171", LIGHT_ID_STK3171},\r
/*proximity sensor*/\r
{"psensor", PROXIMITY_ID_ALL},\r
{"proximity_al3006", PROXIMITY_ID_AL3006}, \r
+ {"ps_stk3171", PROXIMITY_ID_STK3171},\r
/*temperature*/\r
{"temperature", TEMPERATURE_ID_ALL},\r
{},\r