Example #1
0
static ssize_t als_enable_store(struct device *dev,
                struct device_attribute *attr,
                const char *buf, size_t count)
{
    int als_en;
    struct al3006_info *lpi = lp_info;

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

    if (als_en != 0 && als_en != 1
        && als_en != 10 && als_en != 13 && als_en != 16)
        return -EINVAL;

    if (als_en) {
        D("[AL3006] %s: ps_en=%d\n",
            __func__, als_en);
        lightsensor_enable(lpi);
    } else
        lightsensor_disable(lpi);

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

    return count;
}
Example #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

}
Example #3
0
static long lightsensor_ioctl(struct file *file, unsigned int cmd,
		unsigned long arg)
{
	int rc, val;
	struct al3006_info *lpi = lp_info;

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

	switch (cmd) {
	case DYNA_AL3006_AMBIENT_IOCTL_ENABLE:
		if (get_user(val, (unsigned long __user *)arg)) {
			rc = -EFAULT;
			break;
		}
		D("[AL3006] %s LIGHTSENSOR_IOCTL_ENABLE, value = %d\n",
			__func__, val);
		rc = val ? lightsensor_enable(lpi) : lightsensor_disable(lpi);
		break;
	case DYNA_AL3006_AMBIENT_IOCTL_GET_ENABLED:
		val = lpi->als_enable;
		D("[AL3006] %s LIGHTSENSOR_IOCTL_GET_ENABLED, enabled %d\n",
			__func__, val);
		rc = put_user(val, (unsigned long __user *)arg);
		break;
	default:
		pr_err("[AL3006 error]%s: invalid cmd %d\n",
			__func__, _IOC_NR(cmd));
		rc = -EINVAL;
	}

	return rc;
}
static void ltr558_early_suspend(struct early_suspend *h)
{
    struct ltr558_info *lpi = lp_info;
    int ret;

	  D("[ltr558] %s\n", __func__);
#ifdef POLLING_PROXIMITY
    if(lpi->als_enable && !lpi->ps_enable)
    {
	      cancel_delayed_work(&polling_work);
    }
#endif
    ret = psensor_disable(lpi);
	  if (ret == 0)
		    ret = lightsensor_disable(lpi);

	 // return ret;

}
static long lightsensor_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	int rc, val;
	struct lsensor_data* p = &the_data;

	mutex_lock(&api_lock);

	D("%s cmd %d\n", __func__, _IOC_NR(cmd));
	if (!the_data.opened)
	{
		return -EIO;
	}

	switch (cmd) 
	{
	case LIGHTSENSOR_IOCTL_ENABLE:
		if (get_user(val, (unsigned long __user *)arg)) 
		{
			rc = -EFAULT;
			break;
		}
		D("%s ls set to: %d\n", __func__, val);
		rc = val ? lightsensor_enable() : lightsensor_disable();
		break;
	case LIGHTSENSOR_IOCTL_GET_ENABLED:
		val = p->enabled;
		D("%s enabled %d\n", __func__, val);
		rc = put_user(val, (unsigned long __user *)arg);
		break;
	default:
		pr_err("%s: invalid cmd %d\n", __func__, _IOC_NR(cmd));
		rc = -EINVAL;
	}

	mutex_unlock(&api_lock);
	return rc;
}
static void lightsensor_suspend(struct early_suspend *h)
{
	lightsensor_disable();
}