static int apds9130_enable_ps_sensor(struct i2c_client *client, int val) { struct apds9130_data *data = i2c_get_clientdata(client); printk(KERN_INFO"enable ps sensor ( %d)\n", val); /* APDS9130_DISABLE_PS (0) = Disable PS */ /* APDS9130_ENABLE_PS_WITH_INT (1) = Enable PS with interrupt enabled */ if(val == APDS9130_ENABLE_PS_WITH_INT ) { #if defined(APDS9130_PROXIMITY_CAL) data->cross_talk = apds9130_read_crosstalk_data_fs(); #ifdef CONFIG_LEDS_LP5521 if(data->cross_talk <= 10 || data->cross_talk>870) #else if(data->cross_talk < 0 || data->cross_talk>870) #endif { printk(KERN_INFO"[%s] FROM FS data->crosstalk = %d", __func__, data->cross_talk); data->cross_talk = PS_DEFAULT_CROSS_TALK; } printk(KERN_INFO"%s Cross_talk : %d\n", __FUNCTION__, data->cross_talk); apds9130_Set_PS_Threshold_Adding_Cross_talk(client, data->cross_talk); printk(KERN_INFO"%s apds9130_Set_PS_Threshold_Adding_Cross_talk\n", __FUNCTION__); printk(KERN_INFO"%s apds9130_Set_PS_Threshold_Adding_Cross_talk = %d\n", __FUNCTION__,data->cross_talk); #endif //turn on p sensor data->enable_ps_sensor = val; apds9130_set_enable(client,0); /* Power Off */ apds9130_set_pilt(client, 0); // init threshold for proximity apds9130_set_piht(client, data->ps_threshold); //[LGSI_SP4_BSP][[email protected]] add calibrated threshold //[LGSI_SP4_BSP_BEGIN][[email protected]] Report the Far Detection evertytime when u enable the sensor 07-11-2012 input_report_abs(data->input_dev_ps, ABS_DISTANCE, PROX_INPUT_FAR);/* NEAR-to-FAR detection */ input_sync(data->input_dev_ps); //[LGSI_SP4_BSP_END][[email protected]] Report the Far Detection evertytime when u enable the sensor apds9130_set_enable(client, 0x2D); /* enable PS interrupt */ } else { apds9130_set_enable(client, 0); data->enable_ps_sensor = 0; } return 0; }
static int apds9130_enable_ps_sensor(struct i2c_client *client, int val) { struct apds9130_data *data = i2c_get_clientdata(client); printk(KERN_INFO"enable ps sensor ( %d)\n", val); /* APDS9130_DISABLE_PS (0) = Disable PS */ /* APDS9130_ENABLE_PS_WITH_INT (1) = Enable PS with interrupt enabled */ if(val == APDS9130_ENABLE_PS_WITH_INT ) { #if defined(APDS9130_PROXIMITY_CAL) data->cross_talk = apds9130_read_crosstalk_data_fs(); if(data->cross_talk < 0 || data->cross_talk>870) data->cross_talk = PS_DEFAULT_CROSS_TALK; printk(KERN_INFO"%s Cross_talk : %d\n", __FUNCTION__, data->cross_talk); apds9130_Set_PS_Threshold_Adding_Cross_talk(client, data->cross_talk); printk(KERN_INFO"%s apds9130_Set_PS_Threshold_Adding_Cross_talk\n", __FUNCTION__); printk(KERN_INFO"%s apds9130_Set_PS_Threshold_Adding_Cross_talk = %d\n", __FUNCTION__,data->cross_talk); #endif //turn on p sensor data->enable_ps_sensor = val; apds9130_set_enable(client,0); /* Power Off */ apds9130_set_pilt(client, 0); // init threshold for proximity apds9130_set_piht(client, data->ps_threshold); // // input_report_abs(data->input_dev_ps, ABS_DISTANCE, PROX_INPUT_FAR);/* NEAR-to-FAR detection */ input_sync(data->input_dev_ps); // apds9130_set_enable(client, 0x2D); /* enable PS interrupt */ } else { apds9130_set_enable(client, 0); data->enable_ps_sensor = 0; } return 0; }