int32_t flash_set_led_state(enum msm_camera_led_state_t led_state) { int32_t rc; CDBG("flash_set_led_state: %d\n", led_state); switch (led_state) { case MSM_LED_OFF: rc = pmic_flash_led_set_current(0); break; case MSM_LED_LOW: rc = pmic_flash_led_set_current(30); break; case MSM_LED_HIGH: rc = pmic_flash_led_set_current(100); break; default: rc = -EFAULT; break; } CDBG("flash_set_led_state: return %d\n", rc); return rc; }
int msm_camera_flash_pmic( struct msm_camera_sensor_flash_pmic *pmic, unsigned led_state) { int rc = 0; switch (led_state) { case MSM_CAMERA_LED_OFF: rc = pmic_flash_led_set_current(0); break; case MSM_CAMERA_LED_LOW: rc = pmic_flash_led_set_current(pmic->low_current); break; case MSM_CAMERA_LED_HIGH: rc = pmic_flash_led_set_current(pmic->high_current); break; default: rc = -EFAULT; break; } CDBG("flash_set_led_state: return %d\n", rc); return rc; }
static void flash_on(struct work_struct *work) { if(!flash_state) { pmic_flash_led_set_current(FLASH_HIGH_DRIVE_CURRENT_MA); #ifdef CONFIG_HUAWEI_EVALUATE_POWER_CONSUMPTION huawei_rpc_current_consuem_notify(EVENT_CAMERA_FLASH_NOTIFY, (FLASH_HIGH_DRIVE_CURRENT_MA/CAMERA_FLASH_CUR_DIV)); #endif flash_state = 1; hrtimer_start(&flash_timer, ktime_set(FLASH_HIGH_DRIVE_CURRENT_MAX_MS / 1000, (FLASH_HIGH_DRIVE_CURRENT_MAX_MS % 1000) * 1000000), HRTIMER_MODE_REL); } else { pmic_flash_led_set_current(0); msm_camera_flash_disable_vreg(); flash_state = 0; } }
static int debug_flash_led_set_current(char *buf, int size) { int milliamps; int cnt; cnt = sscanf(buf, "%d", &milliamps); if (cnt < 1) { printk(KERN_ERR "%s: sscanf failed cnt=%d" , __func__, cnt); return -EINVAL; } if (pmic_flash_led_set_current(milliamps) < 0) return -EFAULT; return size; }
int32_t msm_camera_flash_set_led_state(unsigned led_state) { int32_t rc; #ifdef CONFIG_HUAWEI_CAMERA static int init = 0; if(!init) { init = 1; INIT_WORK(&flash_work, flash_on); hrtimer_init(&flash_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); flash_timer.function= flash_timer_func; } #endif CDBG("flash_set_led_state: %d\n", led_state); switch (led_state) { case MSM_CAMERA_LED_OFF: #ifdef CONFIG_HUAWEI_CAMERA hrtimer_cancel(&flash_timer); #endif rc = pmic_flash_led_set_current(0); rc = msm_camera_flash_disable_vreg(); break; case MSM_CAMERA_LED_LOW: #ifndef CONFIG_HUAWEI_CAMERA rc = pmic_flash_led_set_current(30); #else hrtimer_cancel(&flash_timer); rc = msm_camera_flash_enable_vreg(); if(machine_is_msm7x25_u8300()) { rc = pmic_flash_led_set_current(FLASH_HIGH_DRIVE_CURRENT_MA); } else { rc = pmic_flash_led_set_current(FLASH_LOW_DRIVE_CURRENT_MA); } #endif break; case MSM_CAMERA_LED_HIGH: #ifndef CONFIG_HUAWEI_CAMERA rc = pmic_flash_led_set_current(100); #else hrtimer_cancel(&flash_timer); flash_state = 0; //It takes time to eanble voltage regulator. So the voltage regulator should be enabled in advance before turning on flash LED. msm_camera_flash_enable_vreg(); hrtimer_start(&flash_timer, ktime_set(FLASH_HIGH_DRIVE_CURRENT_DELAY_MS / 1000, (FLASH_HIGH_DRIVE_CURRENT_DELAY_MS % 1000) * 1000000), HRTIMER_MODE_REL); rc = 0; #endif break; default: rc = -EFAULT; break; } CDBG("flash_set_led_state: return %d\n", rc); #ifdef CONFIG_HUAWEI_EVALUATE_POWER_CONSUMPTION switch (led_state) { case MSM_CAMERA_LED_OFF: huawei_rpc_current_consuem_notify(EVENT_CAMERA_FLASH_NOTIFY, 0); break; #ifndef CONFIG_HUAWEI_CAMERA case MSM_CAMERA_LED_LOW: huawei_rpc_current_consuem_notify(EVENT_CAMERA_FLASH_NOTIFY, (30/CAMERA_FLASH_CUR_DIV)); break; case MSM_CAMERA_LED_HIGH: huawei_rpc_current_consuem_notify(EVENT_CAMERA_FLASH_NOTIFY, (100/CAMERA_FLASH_CUR_DIV)); break; #else case MSM_CAMERA_LED_LOW: huawei_rpc_current_consuem_notify(EVENT_CAMERA_FLASH_NOTIFY, (FLASH_LOW_DRIVE_CURRENT_MA/CAMERA_FLASH_CUR_DIV)); break; case MSM_CAMERA_LED_HIGH: break; #endif default: break; } #endif return rc; }