Ejemplo n.º 1
0
static ssize_t accel_reactive_alert_store(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	int iRet = 0;
	char chTempBuf = 1;
	struct ssp_data *data = dev_get_drvdata(dev);

	struct ssp_msg *msg;

	if (sysfs_streq(buf, "1"))
		ssp_dbg("[SSP]: %s - on\n", __func__);
	else if (sysfs_streq(buf, "0"))
		ssp_dbg("[SSP]: %s - off\n", __func__);
	else if (sysfs_streq(buf, "2")) {
		ssp_dbg("[SSP]: %s - factory\n", __func__);

		data->bAccelAlert = 0;

		msg = kzalloc(sizeof(*msg), GFP_KERNEL);
		if (msg == NULL) {
			pr_err("[SSP] %s, failed to alloc memory for ssp_msg\n", __func__);
			return -ENOMEM;
		}
		msg->cmd = ACCELEROMETER_FACTORY;
		msg->length = 1;
		msg->options = AP2HUB_READ;
		msg->data = chTempBuf;
		msg->buffer = &chTempBuf;
		msg->free_buffer = 0;

		iRet = ssp_spi_sync(data, msg, 3000);
		data->bAccelAlert = chTempBuf;

		if (iRet != SUCCESS) {
			pr_err("[SSP]: %s - accel Selftest Timeout!!\n", __func__);
			goto exit;
		}

		ssp_dbg("[SSP]: %s factory test success!\n", __func__);
	} else {
		pr_err("[SSP]: %s - invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}
exit:
	return size;
}
Ejemplo n.º 2
0
static ssize_t bh1721fvc_light_enable_store(struct device *dev,
				  struct device_attribute *attr,
				  const char *buf, size_t size)
{
	int err = 0;
	bool new_value = false;
	struct bh1721fvc_data *bh1721fvc = dev_get_drvdata(dev);

	bh1721fvc_dbmsg("enable %s\n", buf);

	if (sysfs_streq(buf, "1")) {
		new_value = true;
	} else if (sysfs_streq(buf, "0")) {
		new_value = false;
	} else {
		pr_err("%s: invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}

	bh1721fvc_dbmsg("new_value = %d, old state = %d\n",
		    new_value, bh1721fvc_is_measuring(bh1721fvc));

	mutex_lock(&bh1721fvc->lock);
	if (new_value && (!bh1721fvc_is_measuring(bh1721fvc))) {
		err = bh1721fvc_enable(bh1721fvc);
		if (!err) {
			bh1721fvc->state = bh1721fvc->measure_mode;
		} else {
			pr_err("%s: couldn't enable", __func__);
			bh1721fvc->state = POWER_DOWN;
		}
		bh1721fvc->als_buf_initialized = false;
	} else if (!new_value && (bh1721fvc_is_measuring(bh1721fvc))) {
		err = bh1721fvc_disable(bh1721fvc);
		if (!err)
			bh1721fvc->state = POWER_DOWN;
		else
			pr_err("%s: couldn't enable", __func__);
	} else {
		bh1721fvc_dbmsg("no nothing\n");
	}

	mutex_unlock(&bh1721fvc->lock);

	return size;
}
Ejemplo n.º 3
0
static ssize_t ps_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
        struct ap3426_data *ps_data =  dev_get_drvdata(dev);
        uint8_t en;
        if (sysfs_streq(buf, "1"))
                en = 1;
        else if (sysfs_streq(buf, "0"))
                en = 0;
        else
        {
                printk(KERN_ERR "%s, invalid value %d\n", __func__, *buf);
                return -EINVAL;
        }
		LDBG("%s, en = %d\n", __func__, (u32)(en));
    ap3426_ps_enable(ps_data, en);
    return size;
}
Ejemplo n.º 4
0
static ssize_t mipi_novatek_auto_brightness_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	struct msm_fb_data_type *mfd;
	mfd = platform_get_drvdata(msd.msm_pdev);

	if (sysfs_streq(buf, "0"))
		msd.dstat.auto_brightness = 0;
	else if (sysfs_streq(buf, "1"))
		msd.dstat.auto_brightness = 1;
	else if (sysfs_streq(buf, "2"))
		msd.dstat.auto_brightness = 2;
	else if (sysfs_streq(buf, "3"))
		msd.dstat.auto_brightness = 3;
	else if (sysfs_streq(buf, "4"))
		msd.dstat.auto_brightness = 4;
	else if (sysfs_streq(buf, "5"))
		msd.dstat.auto_brightness = 5;
	else if (sysfs_streq(buf, "6"))
		msd.dstat.auto_brightness = 6;
	else
		pr_info("%s: Invalid argument!!", __func__);

	pr_info("%s : level (%d), bl_level (%d) \n", 
		__func__, msd.dstat.auto_brightness, mfd->bl_level);

#ifdef CONFIG_SAMSUNG_CMC624
	if (samsung_has_cmc624()) {
		cabc_onoff_ctrl(msd.dstat.auto_brightness);
	}
#endif
	return size;
}
Ejemplo n.º 5
0
static ssize_t state_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct arche_apb_ctrl_drvdata *apb = platform_get_drvdata(pdev);
	int ret = 0;
	bool is_disabled;

	if (sysfs_streq(buf, "off")) {
		if (apb->state == ARCHE_PLATFORM_STATE_OFF)
			return count;

		poweroff_seq(pdev);
	} else if (sysfs_streq(buf, "active")) {
		if (apb->state == ARCHE_PLATFORM_STATE_ACTIVE)
			return count;

		poweroff_seq(pdev);
		is_disabled = apb->init_disabled;
		apb->init_disabled = false;
		ret = coldboot_seq(pdev);
		if (ret)
			apb->init_disabled = is_disabled;
	} else if (sysfs_streq(buf, "standby")) {
		if (apb->state == ARCHE_PLATFORM_STATE_STANDBY)
			return count;

		ret = standby_boot_seq(pdev);
	} else if (sysfs_streq(buf, "fw_flashing")) {
		if (apb->state == ARCHE_PLATFORM_STATE_FW_FLASHING)
			return count;

		/*
		 * First we want to make sure we power off everything
		 * and then enter FW flashing state
		 */
		poweroff_seq(pdev);
		ret = fw_flashing_seq(pdev);
	} else {
		dev_err(dev, "unknown state\n");
		ret = -EINVAL;
	}

	return ret ? ret : count;
}
static ssize_t set_clock(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
	unsigned int clk = 0;
	int ret, i, policy_count;
	static bool cur_state;
	const struct kbase_pm_policy *const *policy_list;
	static const struct kbase_pm_policy *prev_policy;
	static bool prev_tmu_status = true;
#ifdef CONFIG_MALI_DVFS
	static bool prev_dvfs_status = true;
#endif /* CONFIG_MALI_DVFS */
	struct exynos_context *platform = (struct exynos_context *)pkbdev->platform_context;

	if (!platform)
		return -ENODEV;

	ret = kstrtoint(buf, 0, &clk);
	if (ret) {
		GPU_LOG(DVFS_WARNING, DUMMY, 0u, 0u, "%s: invalid value\n", __func__);
		return -ENOENT;
	}

	if (!cur_state) {
		prev_tmu_status = platform->tmu_status;
#ifdef CONFIG_MALI_DVFS
		prev_dvfs_status = platform->dvfs_status;
#endif /* CONFIG_MALI_DVFS */
		prev_policy = kbase_pm_get_policy(pkbdev);
	}

	if (clk == 0) {
		kbase_pm_set_policy(pkbdev, prev_policy);
		platform->tmu_status = prev_tmu_status;
#ifdef CONFIG_MALI_DVFS
		if (!platform->dvfs_status)
			gpu_dvfs_on_off(true);
#endif /* CONFIG_MALI_DVFS */
		cur_state = false;
	} else {
		policy_count = kbase_pm_list_policies(&policy_list);
		for (i = 0; i < policy_count; i++) {
			if (sysfs_streq(policy_list[i]->name, "always_on")) {
				kbase_pm_set_policy(pkbdev, policy_list[i]);
				break;
			}
		}
		platform->tmu_status = false;
#ifdef CONFIG_MALI_DVFS
		if (platform->dvfs_status)
			gpu_dvfs_on_off(false);
#endif /* CONFIG_MALI_DVFS */
		gpu_set_target_clk_vol(clk, false);
		cur_state = true;
	}

	return count;
}
Ejemplo n.º 7
0
static ssize_t set_dvfs(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
#ifdef CONFIG_MALI_T6XX_DVFS
	struct kbase_device *kbdev;
	kbdev = dev_get_drvdata(dev);

	if (!kbdev)
		return -ENODEV;

	if (sysfs_streq("0", buf))
		gpu_dvfs_handler_control(kbdev, GPU_HANDLER_DVFS_OFF, 0);
	else if (sysfs_streq("1", buf))
		gpu_dvfs_handler_control(kbdev, GPU_HANDLER_DVFS_ON, 0);
#else
	GPU_LOG(DVFS_WARNING, "G3D DVFS build config is disabled. You can not set\n");
#endif /* CONFIG_MALI_T6XX_DVFS */
	return count;
}
Ejemplo n.º 8
0
static ssize_t pwm_run_store(struct device *dev,
                             struct device_attribute *attr,
                             const char *buf, size_t len)
{
    struct pwm_device *p = dev_get_drvdata(dev);
    int ret;

    if (sysfs_streq(buf, "1"))
        ret = pwm_start(p);
    else if (sysfs_streq(buf, "0"))
        ret = pwm_stop(p);
    else
        ret = -EINVAL;

    if (ret < 0)
        return ret;
    return len;
}
Ejemplo n.º 9
0
static ssize_t cabc_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{

	unsigned char cabc;
	cabc = mdss_dsi_show_cabc();

	if (sysfs_streq(buf, "1") && !cabc)
		cabc = true;
	else if (sysfs_streq(buf, "0") && cabc)
		cabc = false;
	else
		pr_info("%s: Invalid argument!!", __func__);
	mdss_dsi_store_cabc(cabc);

	return size;

}
static ssize_t prox_cal_write(struct device *dev,
                              struct device_attribute *attr, const char *buf, size_t size)
{
    struct gp2a_data *gp2a = dev_get_drvdata(dev);
    u8 value;
    int err;

    if (sysfs_streq(buf, "1")) {
        gp2a->cal_mode = 1;
        nondetect = PROX_NONDETECT_MODE1;
        detect = PROX_DETECT_MODE1;
    } else if (sysfs_streq(buf, "2")) {
        gp2a->cal_mode = 2;
        nondetect = PROX_NONDETECT_MODE2;
        detect = PROX_DETECT_MODE2;
    } else if (sysfs_streq(buf, "0")) {
        gp2a->cal_mode = 0;
        nondetect = PROX_NONDETECT;
        detect = PROX_DETECT;
    } else {
        pr_err("%s: invalid value %d\n", __func__, *buf);
        return -EINVAL;
    }

    value = 0x08;
    gp2a_i2c_write(gp2a, REGS_GAIN, &value);
    value = nondetect;
    gp2a_i2c_write(gp2a, REGS_HYS, &value);
    value = 0x04;
    gp2a_i2c_write(gp2a, REGS_CYCLE, &value);
    value = 0x03;
    gp2a_i2c_write(gp2a, REGS_OPMOD, &value);
    value = 0x00;
    gp2a_i2c_write(gp2a, REGS_CON, &value);

    err = gp2a_cal_mode_save_file(gp2a->cal_mode);

    if (err < 0) {
        pr_err("%s: prox_cal_write() failed\n", __func__);
        return err;
    }

    return size;
}
Ejemplo n.º 11
0
static int dlpar_parse_id_type(char **cmd, struct pseries_hp_errorlog *hp_elog)
{
	char *arg;
	u32 count, index;

	arg = strsep(cmd, " ");
	if (!arg)
		return -EINVAL;

	if (sysfs_streq(arg, "index")) {
		hp_elog->id_type = PSERIES_HP_ELOG_ID_DRC_INDEX;
		arg = strsep(cmd, " ");
		if (!arg) {
			pr_err("No DRC Index specified.\n");
			return -EINVAL;
		}

		if (kstrtou32(arg, 0, &index)) {
			pr_err("Invalid DRC Index specified.\n");
			return -EINVAL;
		}

		hp_elog->_drc_u.drc_index = cpu_to_be32(index);
	} else if (sysfs_streq(arg, "count")) {
		hp_elog->id_type = PSERIES_HP_ELOG_ID_DRC_COUNT;
		arg = strsep(cmd, " ");
		if (!arg) {
			pr_err("No DRC count specified.\n");
			return -EINVAL;
		}

		if (kstrtou32(arg, 0, &count)) {
			pr_err("Invalid DRC count specified.\n");
			return -EINVAL;
		}

		hp_elog->_drc_u.drc_count = cpu_to_be32(count);
	} else {
		pr_err("Invalid id_type specified.\n");
		return -EINVAL;
	}

	return 0;
}
Ejemplo n.º 12
0
static ssize_t proximity_enable_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t size)
{
	int new_value;
	if (sysfs_streq(buf, "1"))
		new_value = 1;
	else if (sysfs_streq(buf, "0"))
		new_value = 0;
	else {
		pr_err("%s: invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}
	PR_DEB("SYSFS_EN_PROX %d\n", new_value);
	mutex_lock(&prox_lock);
	sysfs_enable_prox(new_value);
	mutex_unlock(&prox_lock);
	return size;
}
Ejemplo n.º 13
0
static ssize_t proximity_enable_store(struct device *dev,
				      struct device_attribute *attr,
				      const char *buf, size_t size)
{
	struct gp2a_data *gp2a = dev_get_drvdata(dev);
	bool new_value;

	if (sysfs_streq(buf, "1"))
		new_value = true;
	else if (sysfs_streq(buf, "0"))
		new_value = false;
	else {
		pr_err("%s: invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}
#ifdef CONFIG_TOUCH_WAKE
	if (!new_value)
	  proximity_off();
#endif
	mutex_lock(&gp2a->power_lock);
	gp2a_dbgmsg("new_value = %d, old state = %d\n",
		    new_value, (gp2a->power_state & PROXIMITY_ENABLED) ? 1 : 0);
	if (new_value && !(gp2a->power_state & PROXIMITY_ENABLED)) {
		if (!gp2a->power_state)
			gp2a->pdata->power(true);
		gp2a->power_state |= PROXIMITY_ENABLED;
		enable_irq(gp2a->irq);
		enable_irq_wake(gp2a->irq);
		gp2a_i2c_write(gp2a, REGS_GAIN, &reg_defaults[1]);
		gp2a_i2c_write(gp2a, REGS_HYS, &reg_defaults[2]);
		gp2a_i2c_write(gp2a, REGS_CYCLE, &reg_defaults[3]);
		gp2a_i2c_write(gp2a, REGS_OPMOD, &reg_defaults[4]);
	} else if (!new_value && (gp2a->power_state & PROXIMITY_ENABLED)) {
		disable_irq_wake(gp2a->irq);
		disable_irq(gp2a->irq);
		gp2a_i2c_write(gp2a, REGS_OPMOD, &reg_defaults[0]);
		gp2a->power_state &= ~PROXIMITY_ENABLED;
		if (!gp2a->power_state)
			gp2a->pdata->power(false);
	}
	mutex_unlock(&gp2a->power_lock);
	return size;
}
Ejemplo n.º 14
0
static int dlpar_parse_action(char **cmd, struct pseries_hp_errorlog *hp_elog)
{
	char *arg;

	arg = strsep(cmd, " ");
	if (!arg)
		return -EINVAL;

	if (sysfs_streq(arg, "add")) {
		hp_elog->action = PSERIES_HP_ELOG_ACTION_ADD;
	} else if (sysfs_streq(arg, "remove")) {
		hp_elog->action = PSERIES_HP_ELOG_ACTION_REMOVE;
	} else {
		pr_err("Invalid action specified.\n");
		return -EINVAL;
	}

	return 0;
}
Ejemplo n.º 15
0
static int dlpar_parse_resource(char **cmd, struct pseries_hp_errorlog *hp_elog)
{
	char *arg;

	arg = strsep(cmd, " ");
	if (!arg)
		return -EINVAL;

	if (sysfs_streq(arg, "memory")) {
		hp_elog->resource = PSERIES_HP_ELOG_RESOURCE_MEM;
	} else if (sysfs_streq(arg, "cpu")) {
		hp_elog->resource = PSERIES_HP_ELOG_RESOURCE_CPU;
	} else {
		pr_err("Invalid resource specified.\n");
		return -EINVAL;
	}

	return 0;
}
Ejemplo n.º 16
0
static ssize_t accel_reactive_alert_store(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	char chTempBuf[2] = {0, 10};
	int iRet, iDelayCnt = 0;
	struct ssp_data *data = dev_get_drvdata(dev);

	if (sysfs_streq(buf, "1"))
		ssp_dbg("[SSP]: %s - on\n", __func__);
	else if (sysfs_streq(buf, "0"))
		ssp_dbg("[SSP]: %s - off\n", __func__);
	else if (sysfs_streq(buf, "2")) {
		ssp_dbg("[SSP]: %s - factory\n", __func__);

		data->uFactorydataReady = 0;
		memset(data->uFactorydata, 0, sizeof(char) * FACTORY_DATA_MAX);

		data->bAccelAlert = false;
		iRet = send_instruction(data, FACTORY_MODE,
				ACCELEROMETER_FACTORY, chTempBuf, 2);

		while (!(data->uFactorydataReady & (1 << ACCELEROMETER_FACTORY))
			&& (iDelayCnt++ < 150)
			&& (iRet == SUCCESS))
			msleep(20);

		if ((iDelayCnt >= 150) || (iRet != SUCCESS)) {
			pr_err("[SSP]: %s - accel Selftest Timeout!!\n",
				__func__);
			goto exit;
		}

		mdelay(5);

		data->bAccelAlert = data->uFactorydata[0];
		ssp_dbg("[SSP]: %s factory test success!\n", __func__);
	} else {
		pr_err("[SSP]: %s - invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}
exit:
	return size;
}
static ssize_t hplana_gain_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)
{
	u32 usr;

	if (sysfs_streq(buf, "on")) {
		hplanagain_con = true;

		if (hpwidget)
			taiko_write(wcd9320_codec, TAIKO_A_RX_HPH_L_GAIN, hplanagain);

		return count;
	}

	if (sysfs_streq(buf, "off")) {
		hplanagain_con = false;

		taiko_write(wcd9320_codec, 
			TAIKO_A_RX_HPH_L_GAIN, 
			TAIKO_A_RX_HPH_L_GAIN_DEF);

		return count;
	}

	if (sscanf(buf, "reg=%x", &usr)) {
		taiko_write(wcd9320_codec, TAIKO_A_RX_HPH_L_GAIN, usr);

		return count;
	}

	if (sscanf(buf, "%u", &usr)) {
		if (usr > TAIKO_HPH_VOL_MASK)
			return -EINVAL;

		hplanagain = usr | TAIKO_HPH_GAIN_ENABLE;

		if (hpwidget && hplanagain_con)
			taiko_write(wcd9320_codec, TAIKO_A_RX_HPH_L_GAIN, hplanagain);

		return count;
	}

	return count;
}
Ejemplo n.º 18
0
static ssize_t qeth_dev_isolation_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{
	struct qeth_card *card = dev_get_drvdata(dev);
	enum qeth_ipa_isolation_modes isolation;
	int rc = 0;

	if (!card)
		return -EINVAL;

	mutex_lock(&card->conf_mutex);
	if (!IS_OSD(card) && !IS_OSX(card)) {
		rc = -EOPNOTSUPP;
		dev_err(&card->gdev->dev, "Adapter does not "
			"support QDIO data connection isolation\n");
		goto out;
	}

	/* parse input into isolation mode */
	if (sysfs_streq(buf, ATTR_QETH_ISOLATION_NONE)) {
		isolation = ISOLATION_MODE_NONE;
	} else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_FWD)) {
		isolation = ISOLATION_MODE_FWD;
	} else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_DROP)) {
		isolation = ISOLATION_MODE_DROP;
	} else {
		rc = -EINVAL;
		goto out;
	}
	rc = count;

	/* defer IP assist if device is offline (until discipline->set_online)*/
	card->options.prev_isolation = card->options.isolation;
	card->options.isolation = isolation;
	if (qeth_card_hw_is_reachable(card)) {
		int ipa_rc = qeth_set_access_ctrl_online(card, 1);
		if (ipa_rc != 0)
			rc = ipa_rc;
	}
out:
	mutex_unlock(&card->conf_mutex);
	return rc;
}
Ejemplo n.º 19
0
static ssize_t adis16130_bitsmode_write(struct device *dev,
		struct device_attribute *attr,
		const char *buf,
		size_t len)
{
	int ret;
	u8 val;

	if (sysfs_streq(buf, "s16"))
		val = 0;
	else if (sysfs_streq(buf, "s24"))
		val = 1;
	else
		return -EINVAL;

	ret = adis16130_spi_write(dev, ADIS16130_MODE, val);

	return ret ? ret : len;
}
Ejemplo n.º 20
0
static int lm3530_get_mode_from_str(const char *str)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(mode_map); i++)
		if (sysfs_streq(str, mode_map[i].mode))
			return mode_map[i].mode_val;

	return -EINVAL;
}
Ejemplo n.º 21
0
static ssize_t light_debug_enable_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t size)
{
	if (sysfs_streq(buf, "1"))
		light_enable_flag = 1;
	else 
		light_enable_flag = 0;
	return size;
}
Ejemplo n.º 22
0
static ssize_t ad5624r_write_powerdown_mode(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf, size_t len)
{
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	struct ad5624r_state *st = iio_dev_get_devdata(indio_dev);
	int ret;

	if (sysfs_streq(buf, "1kohm_to_gnd"))
		st->pwr_down_mode = AD5624R_LDAC_PWRDN_1K;
	else if (sysfs_streq(buf, "100kohm_to_gnd"))
		st->pwr_down_mode = AD5624R_LDAC_PWRDN_100K;
	else if (sysfs_streq(buf, "three_state"))
		st->pwr_down_mode = AD5624R_LDAC_PWRDN_3STATE;
	else
		ret = -EINVAL;

	return ret ? ret : len;
}
Ejemplo n.º 23
0
static ssize_t proximity_cal_store(struct device *dev,
							struct device_attribute *attr,
							const char *buf, size_t size)
{
	bool do_calib;

	if (sysfs_streq(buf, "1")) { /* calibrate cancelation value */
		do_calib = true;
	} else if (sysfs_streq(buf, "0")) { /* reset cancelation value */
		do_calib = false;
	} else {
		pr_err("%s: invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}

        printk(KERN_INFO "[CM3663] %s : do_calib=%d\n",__func__, do_calib);
    
	return size;
}
static ssize_t proximity_avg_store(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	struct cm36686_data *cm36686 = dev_get_drvdata(dev);
	bool new_value = false;

	if (sysfs_streq(buf, "1"))
		new_value = true;
	else if (sysfs_streq(buf, "0"))
		new_value = false;
	else {
		pr_err("%s, invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}

	pr_info("%s, average enable = %d\n", __func__, new_value);
	mutex_lock(&cm36686->power_lock);
	if (new_value) {
		if (!(cm36686->power_state & PROXIMITY_ENABLED)) {
			if (cm36686->pdata->cm36686_led_on) {
				cm36686->pdata->cm36686_led_on(true);
				msleep(20);
			}
			cm36686_i2c_write_word(cm36686, REG_PS_CONF1,
				ps_reg_init_setting[PS_CONF1][CMD]);
		}
		hrtimer_start(&cm36686->prox_timer, cm36686->prox_poll_delay,
			HRTIMER_MODE_REL);
	} else if (!new_value) {
		hrtimer_cancel(&cm36686->prox_timer);
		cancel_work_sync(&cm36686->work_prox);
		if (!(cm36686->power_state & PROXIMITY_ENABLED)) {
			cm36686_i2c_write_word(cm36686, REG_PS_CONF1,
				0x0001);
			if (cm36686->pdata->cm36686_led_on)
				cm36686->pdata->cm36686_led_on(false);
		}
	}
	mutex_unlock(&cm36686->power_lock);

	return size;
}
static ssize_t proximity_avg_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t size)
{
	struct gp2a_data *data = dev_get_drvdata(dev);
	bool new_value;

	if (sysfs_streq(buf, "1"))
		new_value = true;
	else if (sysfs_streq(buf, "0"))
		new_value = false;
	else {
		pr_err("%s: invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}

	if (new_value && !proximity_avg_on) {
		if (!(proximity_enable)) {
			/*data->pdata->gp2a_led_on(true);*/
			proximity_onoff(1);
		}
		hrtimer_start(&data->prox_timer, data->prox_poll_delay,
							HRTIMER_MODE_REL);
		proximity_avg_on = 1;
	} else if (!new_value && proximity_avg_on) {
		int i;

		cancel_work_sync(&data->work_prox);
		hrtimer_cancel(&data->prox_timer);
		proximity_avg_on = 0;

		if (!(proximity_enable)) {
			proximity_onoff(0);
			/*data->pdata->gp2a_led_on(false);*/
		}

		for (i = 0 ; i < 3 ; i++)
			data->average[i] = 0;
	}

	return size;
}
Ejemplo n.º 26
0
static ssize_t proximity_cal_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
       
	if (sysfs_streq(buf, "1")) 
		gp2a_data->cal_mode = 1;
        else if (sysfs_streq(buf, "2")) 
		gp2a_data->cal_mode = 2;
        else if (sysfs_streq(buf, "0")) 
		gp2a_data->cal_mode = 0;
        else  {
		pr_err("[GP2A] %s: invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}      

        printk(KERN_INFO "[GP2A] prox_cal_write =%d\n", gp2a_data->cal_mode); 
        
        gp2a_cal_mode_save_file(gp2a_data->cal_mode);
        
	return size;
}
Ejemplo n.º 27
0
static ssize_t mipi_novatek_disp_acl_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	struct msm_fb_data_type *mfd;

	mfd = platform_get_drvdata(msd.msm_pdev);

	if (!mfd->panel_power_on) {
		pr_info("%s: panel is off state. updating state value.\n",
			__func__);
		if (sysfs_streq(buf, "1") && !msd.dstat.acl_on)
			msd.dstat.acl_on = true;
		else if (sysfs_streq(buf, "0") && msd.dstat.acl_on)
			msd.dstat.acl_on = false;
		else
			pr_info("%s: Invalid argument!!", __func__);
	} else {

#ifdef CONFIG_ACL_FUNCTION /*temp*/
		if (sysfs_streq(buf, "1") && !msd.dstat.acl_on) {
			if (msd.mpd->set_acl(mfd->bl_level))
				mipi_novatek_disp_send_cmd(
					mfd, PANEL_ACL_OFF, true);
			else {
				mipi_novatek_disp_send_cmd(
					mfd, PANEL_ACL_ON, true);
				mipi_novatek_disp_send_cmd(
					mfd, PANEL_ACL_UPDATE, true);
			}
			msd.dstat.acl_on = true;
		} else if (sysfs_streq(buf, "0") && msd.dstat.acl_on) {
			mipi_novatek_disp_send_cmd(mfd, PANEL_ACL_OFF, true);
			msd.dstat.acl_on = false;
		} else {
			pr_info("%s: Invalid argument!!", __func__);
		}
#endif
	}

	return size;
}
Ejemplo n.º 28
0
static ssize_t calibration_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{
	bool do_calib;
	int ret;
	struct ssp_data *data = dev_get_drvdata(dev);

	if (sysfs_streq(buf, "1"))
		do_calib = true;
	else if (sysfs_streq(buf, "0"))
		do_calib = false;
	else {
		pr_info("[SSP]: %s - invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}

	ret = do_calibrate(data, do_calib);
	if (ret < 0) {
		pr_err("[SSP]: %s - do_calibrate fail(%d)\n",
			__func__, ret);
		goto exit;
	}

	ret = save_caldata(data);
	if (ret < 0) {
		pr_err("[SSP]: %s - save_caldata fail(%d)\n",
			__func__, ret);
		goto exit;
	}

	pr_info("[SSP]: %s - %u success!\n", __func__, do_calib);

exit:

	if (data->gripcal.cap_main && (ret >= 0))
		data->gripcal.calibrated = true;
	else
		data->gripcal.calibrated = false;

	return count;
}
Ejemplo n.º 29
0
static ssize_t irmotion_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
	int value;

	if (sysfs_streq(buf, "1"))
		value = true;
	else if (sysfs_streq(buf, "0"))
		value = false;
	else {
		printk(KERN_ERR "%s (%d) : invalid value %d\n", __func__, __LINE__,*buf);		
		return size;
	}

	if(value == 1){
		printk(KERN_INFO "%s (%d) : gesture enable\n", __func__, __LINE__);
		
#ifdef IRMOTION_TRACE_LOG
		if(LogON == 1){
			filp = file_open(IRMOTION_LOGFILE,O_CREAT | O_RDWR | O_APPEND | O_LARGEFILE,0777);		
			if(filp != NULL){
				TraceLogON = 1;
			}
		}
#endif

		pac7620_irmotion_enable();
	}else if(value == 0){
		printk(KERN_INFO "%s (%d) : gesture disable\n", __func__, __LINE__);
		pac7620_irmotion_disable();

#ifdef IRMOTION_TRACE_LOG	
		if(LogON == 1){
			file_write(filp, filp->f_pos, "========================================\n", 41);		
			file_close(filp);
	}
		TraceLogON = 0;
#endif
	}

	return size;
}
Ejemplo n.º 30
0
static ssize_t mmpfb_vsync_store(
		struct device *dev, struct device_attribute *attr,
		const char *buf, size_t size)
{
	struct mmpfb_info *fbi = dev_get_drvdata(dev);

	if (sysfs_streq(buf, "u1")) {
		fbi->vsync.en = 1;
		mmp_path_set_irq(fbi->path, VSYNC_IRQ, IRQ_ENA);
	} else if (sysfs_streq(buf, "u0")) {
		fbi->vsync.en = 0;
		mmp_path_set_irq(fbi->path, VSYNC_IRQ, IRQ_DIS);
	} else {
		dev_dbg(fbi->dev, "invalid input, please echo as follow:\n");
		dev_dbg(fbi->dev, "\tu1: enable vsync uevent\n");
		dev_dbg(fbi->dev, "\tu0: disable vsync uevent\n");
	}
	trace_vsync(fbi->vsync.en);
	dev_dbg(fbi->dev, "vsync_en = %d\n", fbi->vsync.en);
	return size;
}