Exemple #1
0
static int lightsensor_disable(struct al3006_info *lpi)
{
	int ret = 0;

    if(!lpi)
            return -1;

	mutex_lock(&als_disable_mutex);

    if(lpi->ps_enable)
        al3006_i2c_write(0x00,0x01); // both enable ps and als
    else{
        al3006_i2c_write(0x00,0x0b);//0x03); // only enable als
    }
	//D("[AL3006] %s\n", __func__);
	D("[AL3006] %s by pid[%d] thread [%s]\n", __func__,current->pid,current->comm);
	lpi->als_enable = 0;
	mutex_unlock(&als_disable_mutex);

#ifdef POLLING_PROXIMITY
    if(!lpi->ps_enable)
	    cancel_delayed_work(&polling_work);
#endif
	return ret;
}
Exemple #2
0
static void al3006_early_suspend(struct early_suspend *h)
{
	struct al3006_info *lpi = lp_info;

	D("[AL3006] %s\n", __func__);

#if 0
	if (lpi->als_enable)
		lightsensor_disable(lpi);
	if (lpi->ps_enable)
		psensor_disable(lpi);
#endif
    if(lpi->als_enable && !lpi->ps_enable)
    {
	    cancel_delayed_work(&polling_work);
    }
    if(lpi->ps_enable)/*Need ps interrupt to wake up phone*/{
        D("3006 suspend ps enabled\n");
        al3006_i2c_write(0x0,0x01);
#if 1
        if(!lpi->ps_irq_flag)
        {
            enable_irq(lpi->irq);
            lpi->ps_irq_flag = 1;
        }
#endif
    }
    else
        al3006_i2c_write(0x0,0x0b); //0x03 set chip to idle mode

}
Exemple #3
0
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;
}
Exemple #4
0
static int psensor_disable(struct al3006_info *lpi)
{
	int ret = -EIO;

	//lpi->ps_pocket_mode = 0;

	D("[AL3006] %s by pid[%d] thread [%s]\n", __func__,current->pid,current->comm);
	//D("[AL3006] %s\n", __func__);
#if 0
    if(lpi->ps_irq_flag){
    	disable_irq_nosync(lpi->irq);
        lpi->ps_irq_flag = 0;
    }
#endif
    if(lpi->als_enable)
        al3006_i2c_write(0x00,0x00); // both enable ps and als
    else
        al3006_i2c_write(0x00,0x0b);//0x03); // only enable als

    lpi->ps_enable = 0;

#ifdef POLLING_PROXIMITY
    if(!lpi->als_enable)
	    cancel_delayed_work(&polling_work);
	/* settng command code(0x01) = 0x03*/
#endif
	return ret;
}
static ssize_t test_mode_store(struct device *dev,
                struct device_attribute *attr,
                const char *buf, size_t count)
{
    int ts_en;
    struct al3006_info *lpi = lp_info;
    uint8_t value;

    ts_en = -1;
    sscanf(buf, "%d", &ts_en);

    if (ts_en != 0 && ts_en != 1)
        return -EINVAL;

    if (!lpi)
        return -EINVAL;

    if (ts_en) {
        D("[AL3006] %s: ts_en=%d\n",
            __func__, ts_en);
        al3006_i2c_write(0x08,0xE0); //write 0xe0-> 0x08 reg enter test mode
        lp_info->testmode = 1;
    } else{
        al3006_i2c_write(0x08,0x00); //write 0x00-> 0x08 reg leave test mode
        lp_info->testmode = 0;
    }

    D("[AL3006] %s\n", __func__);

    return count;
}
Exemple #6
0
static int psensor_enable(struct al3006_info *lpi)
{
	int ret = 0;

	D("[AL3006] %s by pid[%d] thread [%s]\n", __func__,current->pid,current->comm);
#if 0
	if (lpi->ps_enable) {
		D("[AL3006] %s: already enabled\n", __func__);
		return 0;
	}
#endif
	/* dummy report */
	input_report_abs(lpi->ps_input_dev, ABS_DISTANCE, -1);
	input_sync(lpi->ps_input_dev);

#if 0
    if(lpi->als_enable)
        al3006_i2c_write(0x00,0x02); // both enable ps and als
    else
#endif
        al3006_i2c_write(0x00,0x01); // only enable ps

	msleep(15);
	report_psensor_input_event(lpi);

    lpi->ps_enable = 1;
#if 0    
    if(!lpi->ps_irq_flag){
        enable_irq(lpi->irq);
        lpi->ps_irq_flag = 1;
    }
#endif
    //if(!lpi->als_enable)
	queue_delayed_work(lpi->lp_wq, &polling_work,
		msecs_to_jiffies(POLLING_DELAY));

	return ret;
}
Exemple #7
0
static int initial_al3006(struct al3006_info *lpi)
{
	int ret;
	uint8_t add,val;
    add = 0;    
    ret = al3006_i2c_read(add,&val);
    if((0x03 == val)||(!ret))
        printk("al3006 device found!! id = 0x%x\n",val);
    else
        return -1;

//	msleep(10);
#if 1 //dummy init
    al3006_i2c_write(0x00,0x0b);
    al3006_i2c_write(0x01,0x01);
    al3006_i2c_write(0x02,0xa0);
    al3006_i2c_write(0x04,0x4a);
    al3006_i2c_write(0x08,0x00);
    al3006_i2c_write(0x00,0x08);
    al3006_i2c_write(0x00,0x0b);//0x03);
#endif
	return 0;
}