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; }
static ssize_t msm_led_cci_hardware_test_op_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int operation = simple_strtoul(buf, NULL, 0); int rc; CDBG("operation %d\n", operation); switch (operation) { case 0x00:/*deinit*/ if (operation_state > 0) { msm_led_cci_test_off(); //msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_RELEASE); operation_state = operation; } break; case 0x01:/*init*/ if (operation_state == 0) { msm_led_cci_test_init(); //msm_led_cci_set_brightness(&fctrl, MSM_CAMERA_LED_INIT); operation_state = operation; } break; case 0x10:/*hardware torch off*/ if (operation_state > 0) { rc = gpio_direction_output(fctrl.led_info->gpio_torch_en, 0); if (rc < 0) pr_err("set gpio to 0 failed\n"); operation_state = operation; } break; case 0x11:/*hardware torch on*/ if (operation_state > 0) { rc = gpio_direction_output(fctrl.led_info->gpio_torch_en, 1); if (rc < 0) pr_err("set gpio to 1 failed\n"); operation_state = operation; } break; case 0x20:/*hardware strobe off*/ if (operation_state > 0) { rc = gpio_direction_output(fctrl.led_info->gpio_strobe_en, 0); if (rc < 0) pr_err("set gpio to 0 failed\n"); operation_state = operation; } break; case 0x21:/*hardware strobe on*/ if (operation_state > 0) { rc = gpio_direction_output(fctrl.led_info->gpio_strobe_en, 1); if (rc < 0) pr_err("set gpio to 1 failed\n"); operation_state = operation; } break; case 0x30:/* */ if (operation_state > 0) { operation_state = operation; } break; case 0x31:/* */ if (operation_state > 0) { operation_state = operation; } break; default: break; } return count; }
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; }