static void sensor_irq_do_work(struct work_struct *work) { struct ltr558_info *lpi = lp_info; uint8_t status = 0; int als_ps_status; int interrupt, newdata; als_ps_status = ltr558_i2c_read_reg(LTR558_ALS_PS_STATUS); interrupt = als_ps_status & 10; newdata = als_ps_status & 5; switch (interrupt){ case 2: // PS interrupt if ((newdata == 1) | (newdata == 5)){ //wake_up_interruptible(&ps_waitqueue); report_psensor_input_event(lpi); } break; case 8: // ALS interrupt if ((newdata == 4) | (newdata == 5)){ //wake_up_interruptible(&als_waitqueue); report_lsensor_input_event(lpi); } break; case 10: // Both interrupt if ((newdata == 1) | (newdata == 5)){ report_psensor_input_event(lpi); } //wake_up_interruptible(&als_waitqueue); if((newdata == 4) | (newdata == 5)){ report_lsensor_input_event(lpi); } break; } #if 0 /*check ALS or PS*/ ltr558_i2c_read(LTR558_ALS_PS_STATUS,&status); D("[ltr558] intr status[0x%x]\n",status); if(status & 0x02)/*ps trigger interrupt*/ { report_psensor_input_event(lpi); } #endif }
static int lightsensor_enable(struct al3006_info *lpi) { int ret = 0; if(!lpi) return -1; mutex_lock(&als_enable_mutex); D("[AL3006] %s by pid[%d] thread [%s]\n", __func__,current->pid,current->comm); if(lpi->ps_enable) al3006_i2c_write(0x00,0x01); //02 for both enable ps and als, not stable else al3006_i2c_write(0x00,0x00); // only enable als msleep(10); /* report an invalid value first to ensure we * trigger an event when adc_level is zero. */ lpi->als_enable = 1; input_report_abs(lpi->ls_input_dev, ABS_MISC, -1); input_sync(lpi->ls_input_dev); report_lsensor_input_event(lpi);/*resume, IOCTL and DEVICE_ATTR*/ mutex_unlock(&als_enable_mutex); #ifdef POLLING_PROXIMITY //if(!lpi->ps_enable) queue_delayed_work(lpi->lp_wq, &polling_work, msecs_to_jiffies(POLLING_DELAY)); /* settng command code(0x01) = 0x03*/ #endif return ret; }
static int lightsensor_enable(struct ltr558_info *lpi) { int ret = 0; if(!lpi) return -1; mutex_lock(&als_enable_mutex); D("[ltr558] %s by pid[%d] thread [%s]\n", __func__,current->pid,current->comm); if (lpi->gainrange == 1) ret = ltr558_i2c_write_reg(LTR558_ALS_CONTR, MODE_ALS_ON_Range1); else if (lpi->gainrange == 2) ret = ltr558_i2c_write_reg(LTR558_ALS_CONTR, MODE_ALS_ON_Range2); else ret = -1; msleep(10); /* report an invalid value first to ensure we * trigger an event when adc_level is zero. */ lpi->als_enable = 1; input_report_abs(lpi->ls_input_dev, ABS_MISC, -1); input_sync(lpi->ls_input_dev); report_lsensor_input_event(lpi);/*resume, IOCTL and DEVICE_ATTR*/ mutex_unlock(&als_enable_mutex); #ifdef POLLING_PROXIMITY //if(!lpi->ps_enable) queue_delayed_work(lpi->lp_wq, &polling_work, msecs_to_jiffies(POLLING_DELAY)); /* settng command code(0x01) = 0x03*/ #endif return ret; }
static void polling_do_work(struct work_struct *w) { struct al3006_info *lpi = lp_info; /*D("lpi->ps_enable = %d\n", lpi->ps_enable);*/ if (!lpi->ps_enable && !lpi->als_enable) return; if(lpi->ps_enable) report_psensor_input_event(lpi); if(lpi->als_enable) report_lsensor_input_event(lpi); queue_delayed_work(lpi->lp_wq, &polling_work, msecs_to_jiffies(POLLING_DELAY)); }