Esempio n. 1
0
static void msm_led_cci_test_off(void)
{
    int rc;

    //fctrl.led_info->status = MSM_CAMERA_LED_OFF;
    if (fctrl.led_info->test_mode == 2) {
        cancel_delayed_work_sync(&fctrl.led_info->dwork);
    }
    msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_OFF);

    /*release cci*/
    rc = fctrl.flash_i2c_client->i2c_func_tbl->i2c_util(
        fctrl.flash_i2c_client, MSM_CCI_RELEASE);
    if (rc < 0) {
        pr_err("cci release failed\n");
    }
    
    msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_RELEASE);

    /*disable power*/
    rc = regulator_disable(fctrl.led_info->retulator);
    if (rc < 0) {
        pr_err("regulator_disable failed\n");
        regulator_put(fctrl.led_info->retulator);
        return;
    }
    regulator_put(fctrl.led_info->retulator);

    return;
}
Esempio n. 2
0
static ssize_t msm_led_cci_test_store(struct device *dev, struct device_attribute *attr,
			 const char *buf, size_t count)
{
	int new_mode = simple_strtoul(buf, NULL, 10);
    int *pold_mode = &fctrl.led_info->test_mode;
    if (new_mode == *pold_mode) {
        pr_err("the same mode as old\n");
        return count;
    }

    if (*pold_mode!=0 && new_mode!=0) {
        fctrl.led_info->test_status = 0;
        msm_led_cci_test_off();
        *pold_mode = 0;
    }

    switch (new_mode) {
    case 0:
        if (*pold_mode==1 || *pold_mode==2 || *pold_mode==3) {
            fctrl.led_info->test_status = 0;
            msm_led_cci_test_off();
            *pold_mode = 0;
        }
        break;
    case 1:
        if (*pold_mode==0) {
            fctrl.led_info->test_status = 1;
            msm_led_cci_test_init();
            msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_LOW);
            *pold_mode = 1;
        }
        break;
    case 2:
        if (*pold_mode==0) {
            fctrl.led_info->test_status = 1;
            msm_led_cci_test_init();
            INIT_DELAYED_WORK(&fctrl.led_info->dwork, msm_led_cci_test_blink_work);
            schedule_delayed_work(&fctrl.led_info->dwork, msecs_to_jiffies(50));
            *pold_mode = 2;
        }
        break;
    case 3:
        if (*pold_mode==0) {
            fctrl.led_info->test_status = 1;
            msm_led_cci_test_init();
            msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_HIGH);
            *pold_mode = 3;
        }
        break;
    default:
        pr_err("invalid mode\n");
        break;
    }
	
	return count;
}
static ssize_t msm_led_cci_test_store(struct device *dev, struct device_attribute *attr,
			 const char *buf, size_t count)
{
	int new_mode = simple_strtoul(buf, NULL, 10);
    int *pold_mode = &fctrl.led_info->test_mode;
    bool need_off = 0;
    bool need_on = 0;

    if (new_mode == *pold_mode) {
        pr_err("the same mode as old %d\n", *pold_mode);
        return count;
    } else {
        pr_err("the old mode is %d, new mode is %d\n", *pold_mode, new_mode);
    }

    if (fctrl.led_info->test_status)
        need_off = 1;
    if (new_mode >= 1 && new_mode <= 3)
        need_on = 1;

    if (need_off) {
        msm_led_cci_test_off();
        fctrl.led_info->test_status = 0;
    }

    switch (new_mode) {
    case 1:
        msm_led_cci_test_init();
        msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_LOW);
        fctrl.led_info->test_status = 1;
        break;
    case 2:
        fctrl.led_info->blink_status = 1;
        msm_led_cci_test_init();
        INIT_DELAYED_WORK(&fctrl.led_info->dwork, msm_led_cci_test_blink_work);
        schedule_delayed_work(&fctrl.led_info->dwork, msecs_to_jiffies(50));
        fctrl.led_info->test_status = 1;
        break;
    case 3:
        msm_led_cci_test_init();
        msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_HIGH);
        fctrl.led_info->test_status = 1;
        break;
    default:
        pr_err("other mode %d\n", new_mode);
        break;
    }

    *pold_mode = new_mode;
	pr_err("the mode is %d now\n", *pold_mode);

	return count;
}
Esempio n. 4
0
static void msm_led_cci_test_blink_work(struct work_struct *work)
{
    struct delayed_work *dwork = to_delayed_work(work);
    msm_led_cci_set_brightness(&fctrl, fctrl.led_info->test_status);
    fctrl.led_info->test_status = !fctrl.led_info->test_status;
    schedule_delayed_work(dwork, msecs_to_jiffies(1100));
}
Esempio n. 5
0
static void msm_led_cci_test_init(void)
{
    int rc;
	struct msm_camera_i2c_client *cci_i2c_client = NULL;

    /*get power*/
    fctrl.led_info->retulator = regulator_get(&fctrl.pdev->dev, fctrl.led_info->regulator_name);
    if (IS_ERR_OR_NULL(fctrl.led_info->retulator)) {
        pr_err("regulator_get failed\n");
        return;
    }
    /*enable power*/
    rc = regulator_enable(fctrl.led_info->retulator);
    if (rc < 0) {
        pr_err("regulator_enable failed\n");
        regulator_put(fctrl.led_info->retulator);
        return;
    }

    msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_INIT);
    
    /*init cci*/
    fctrl.flash_i2c_client->cci_client->sid = fctrl.led_info->slave_id;
    fctrl.flash_i2c_client->cci_client->cci_i2c_master =
        fctrl.led_info->cci_master;
    cci_i2c_client = fctrl.flash_i2c_client;
    rc = cci_i2c_client->i2c_func_tbl->i2c_util(
            cci_i2c_client, MSM_CCI_INIT);
    if (rc < 0) {
        pr_err("cci init failed\n");
    }

    return;
}
Esempio n. 6
0
static int32_t msm_led_cci_config(struct msm_led_cci_ctrl_t *fctrl,
	void *data)
{
	int rc = 0;
	struct msm_camera_led_cfg_t *cfg = (struct msm_camera_led_cfg_t *)data;

	CDBG("called, set to %d\n", cfg->cfgtype);

	if (!fctrl) {
		pr_err("failed\n");
		return -EINVAL;
	}

    msm_led_cci_set_brightness(fctrl, cfg->cfgtype);

	return rc;
}
static int flash_proc_write(struct file *filp, const char __user *buff,
    unsigned long len, void *data)
{
	char temp[1] = {0};
    int new_mode = simple_strtoul(buff, NULL, 10);
    int *pold_mode = &fctrl.led_info->test_mode;
    bool need_off = 0;
    bool need_on = 0;
    int ret = -EINVAL;

	if (copy_from_user(temp, buff, 1))
		return -EFAULT;
    ret = sscanf(temp, "%d", &new_mode);
    if (ret <= 0)
        return len;

    if (new_mode == *pold_mode) {
        pr_err("the same mode as old %d\n", *pold_mode);
        return len;
    } else {
        pr_err("the old mode is %d, new mode is %d\n", *pold_mode, new_mode);
    }

    if (fctrl.led_info->test_status)
        need_off = 1;
    if (new_mode >= 1 && new_mode <= 3)
        need_on = 1;

    if (need_off) {
        msm_led_cci_test_off();
        fctrl.led_info->test_status = 0;
    }

    switch (new_mode) {
    case 1:
        msm_led_cci_test_init();
        msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_LOW);
        fctrl.led_info->test_status = 1;
        break;
    case 2:
        fctrl.led_info->blink_status = 1;
        msm_led_cci_test_init();
        INIT_DELAYED_WORK(&fctrl.led_info->dwork, msm_led_cci_test_blink_work);
        schedule_delayed_work(&fctrl.led_info->dwork, msecs_to_jiffies(50));
        fctrl.led_info->test_status = 1;
        break;
    case 3:
        msm_led_cci_test_init();
        msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_HIGH);
        fctrl.led_info->test_status = 1;
        break;
    default:
        pr_err("other mode %d\n", new_mode);
        break;
    }

    *pold_mode = new_mode;
    pr_err("the mode is %d now\n", *pold_mode);

    return len;
}