static ssize_t ps_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int ps_en; struct al3006_info *lpi = lp_info; ps_en = -1; sscanf(buf, "%d", &ps_en); if (ps_en != 0 && ps_en != 1 && ps_en != 10 && ps_en != 13 && ps_en != 16) return -EINVAL; if (ps_en) { D("[AL3006] %s: ps_en=%d\n", __func__, ps_en); psensor_enable(lpi); } else psensor_disable(lpi); D("[AL3006] %s\n", __func__); return count; }
static void ltr558_late_resume(struct early_suspend *h) { struct ltr558_info *lpi = lp_info; D("[ltr558] %s\n", __func__); if (lpi->als_enable){ lpi->gainrange = ALS_RANGE2_64K; lightsensor_enable(lpi); } if (lpi->ps_enable){ D("[ltr558] resume ps enabled\n"); #if 1 if(lpi->ps_irq_flag) { disable_irq_nosync(lpi->irq); lpi->ps_irq_flag = 0; } #endif lpi->gainrange = ALS_RANGE2_64K; lpi->gainrange = PS_RANGE1; psensor_enable(lpi); } }
static long psensor_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int val; struct al3006_info *lpi = lp_info; D("[AL3006] %s cmd %d\n", __func__, _IOC_NR(cmd)); switch (cmd) { case DYNA_AL3006_PSENSOR_IOCTL_ENABLE: if (get_user(val, (unsigned long __user *)arg)) return -EFAULT; if (val) return psensor_enable(lpi); else return psensor_disable(lpi); break; case DYNA_AL3006_PSENSOR_IOCTL_GET_ENABLED: return put_user(lpi->ps_enable, (unsigned long __user *)arg); break; default: pr_err("[AL3006 error]%s: invalid cmd %d\n", __func__, _IOC_NR(cmd)); return -EINVAL; } }
static int ltr558_dev_init(struct ltr558_info *lpi) { int error; int init_ps_gain; int init_als_gain; mdelay(600); // Enable PS to Gain1 at startup init_ps_gain = PS_RANGE1; lpi->gainrange = init_ps_gain; error = psensor_enable(lpi); if (error < 0) goto out; // Enable ALS to Full Range at startup init_als_gain = ALS_RANGE2_64K; lpi->gainrange = init_als_gain; error = lightsensor_enable(lpi); if (error < 0) goto out; error = 0; out: return error; }
static void al3006_late_resume(struct early_suspend *h) { struct al3006_info *lpi = lp_info; D("[AL3006] %s\n", __func__); if (lpi->als_enable) lightsensor_enable(lpi); if (lpi->ps_enable){ D("3006 resume ps enabled\n"); #if 1 if(lpi->ps_irq_flag) { disable_irq_nosync(lpi->irq); lpi->ps_irq_flag = 0; } #endif psensor_enable(lpi); } }