/*++ AT_Command[Flash mode] : [email protected]_20121012 ++*/ void camera_flash_on_off(int value) // Flash { if(value == POWER_ON) { Cam_Printk("Camera Flash ON..\n"); #if defined(CONFIG_LEDS_RT8547) #if defined(CONFIG_MACH_WILCOX) if(system_rev == 1){ rear_camera = TRUE; rt8547_set_led_low(); } else { rear_camera = TRUE; gpio_direction_output(camera_flash_en, 0); /*Enable */ gpio_direction_output(camera_flash_set, 1); } #else rear_camera = TRUE; rt8547_set_led_low(); #endif #else gpio_direction_output(camera_flash_en, 0); /*Enable */ gpio_direction_output(camera_flash_set, 1); #endif } else { Cam_Printk("Camera Flash OFF..\n"); #if defined(CONFIG_LEDS_RT8547) #if defined(CONFIG_MACH_WILCOX) if(system_rev == 1){ rear_camera = FALSE; rt8547_set_led_off(); } else { rear_camera = FALSE; gpio_direction_output(camera_flash_en, 0); /*Disable */ gpio_direction_output(camera_flash_set, 0); } #else rear_camera = FALSE; rt8547_set_led_off(); #endif #else gpio_direction_output(camera_flash_en, 0); /*Disable */ gpio_direction_output(camera_flash_set, 0); #endif } }
/*++ AT_Command[Flash mode] : [email protected]_20121012 ++*/ void camera_flash_on_off(int value) // Flash { #ifdef CONFIG_FLED_RT5033 rt_fled_info_t *rt5033_fled; rt5033_fled=rt_fled_get_info_by_name(NULL); #endif if(value == POWER_ON) { Cam_Printk("Camera Flash ON..\n"); #ifdef CONFIG_FLED_RT5033 rt5033_fled->hal->fled_set_mode(rt5033_fled,FLASHLIGHT_MODE_TORCH); #elif CONFIG_LEDS_RT8547 rt8547_set_led_low(); #endif rear_camera = TRUE; } else { Cam_Printk("Camera Flash OFF..\n"); #ifdef CONFIG_FLED_RT5033 rt5033_fled->hal->fled_set_mode(rt5033_fled,FLASHLIGHT_MODE_OFF); #elif CONFIG_LEDS_RT8547 rt8547_set_led_off(); #endif rear_camera = FALSE; } }
int msm_camera_flash_led( struct msm_camera_sensor_flash_external *external, unsigned led_state) { #ifdef CONFIG_IMX175 #if defined(CONFIG_MACH_MELIUS) int i = 0; #endif int rc = 0; if(Torch_On == true) { cam_err("[Assistive Light On!!\n"); return 0; } #if defined(CONFIG_MACH_MELIUS) /* FLASH IC : KTD2692 */ cam_err("[led_state::%d]\n", led_state); switch (led_state) { case MSM_CAMERA_LED_INIT: cam_err("[MSM_CAMERA_LED_INIT]\n"); #if defined(CONFIG_MACH_CRATER_CHN_CTC) || defined(CONFIG_MACH_MELIUS_VZW) || defined(CONFIG_MACH_MELIUS_SPR) || defined(CONFIG_MACH_MELIUS_USC) if (system_rev < 0X01) { #else if (system_rev < 0x07) { #endif set_gpio_ENF(external, false); } else { /* Disable Cutoff Low voltage */ KTD2692_ctrl_cmd(external, LVP_SETTING | 0x00); /*D2692_ctrl_cmd(external, MODE_CONTROL | 0x00);*/ } break; case MSM_CAMERA_LED_RELEASE: cam_err("[MSM_CAMERA_LED_RELEASE]\n"); gpio_set_value_cansleep(external->led_flash_en, 0); break; case MSM_CAMERA_LED_OFF: cam_err("[MSM_CAMERA_LED_OFF]\n"); #if defined(CONFIG_MACH_CRATER_CHN_CTC) || defined(CONFIG_MACH_MELIUS_VZW) || defined(CONFIG_MACH_MELIUS_SPR) || defined(CONFIG_MACH_MELIUS_USC) if (system_rev < 0X01) { #else if (system_rev < 0x07) { #endif set_gpio_ENF(external, false); } else { KTD2692_ctrl_cmd(external, MODE_CONTROL | 0x00); } break; case MSM_CAMERA_LED_LOW: /* Movie Current Setting : 0x64 (5/16) */ cam_err("[MSM_CAMERA_LED_LOW]\n"); #if defined(CONFIG_MACH_CRATER_CHN_CTC) || defined(CONFIG_MACH_MELIUS_VZW) || defined(CONFIG_MACH_MELIUS_SPR) || defined(CONFIG_MACH_MELIUS_USC) if (system_rev < 0X01) { #else if (system_rev < 0x07) { #endif for (i = 2; i > 0; i--) { set_gpio_ENF(external, false); ndelay(300); set_gpio_ENF(external, true); ndelay(300); } } else { /* Disable Cutoff Low voltage */ KTD2692_ctrl_cmd(external, LVP_SETTING | 0x00); /*KTD2692_ctrl_cmd(external, MOVIE_CURRENT | 0x04);*/ KTD2692_ctrl_cmd(external, MODE_CONTROL | 0x01); } break; case MSM_CAMERA_LED_HIGH: cam_err("[MSM_CAMERA_LED_HIGH]\n"); #if defined(CONFIG_MACH_CRATER_CHN_CTC) || defined(CONFIG_MACH_MELIUS_VZW) || defined(CONFIG_MACH_MELIUS_SPR) || defined(CONFIG_MACH_MELIUS_USC) if (system_rev < 0X01) { #else if (system_rev < 0x07) { #endif for (i = 16; i > 0; i--) { set_gpio_ENF(external, false); ndelay(300); set_gpio_ENF(external, true); ndelay(300); } } else { /* Disable Cutoff Low voltage */ KTD2692_ctrl_cmd(external, LVP_SETTING | 0x00); /*KTD2692_ctrl_cmd(external, FLASH_CURRENT | 0x0F);*/ KTD2692_ctrl_cmd(external, MODE_CONTROL | 0x02); } break; default: cam_err("[default]\n"); rc = -EFAULT; break; } #elif defined (CONFIG_MACH_SERRANO) || defined (CONFIG_MACH_CRATER) || defined (CONFIG_MACH_BAFFIN) /* FLASH IC : MIC2871YMK*/ cam_err("[led_state::%d]\n", led_state); switch (led_state) { case MSM_CAMERA_LED_INIT: cam_err("[MSM_CAMERA_LED_INIT][MIC2871YMK]\n"); gpio_tlmm_config(GPIO_CFG(GPIO_MSM_FLASH_CNTL_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG(GPIO_MSM_FLASH_NOW, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE); break; case MSM_CAMERA_LED_RELEASE: MIC2871YMK_set_flash_flash(0); cam_err("[MSM_CAMERA_LED_RELEASE][MIC2871YMK]\n"); break; case MSM_CAMERA_LED_OFF: cam_err("[MSM_CAMERA_LED_OFF][MIC2871YMK]\n"); MIC2871YMK_set_flash_flash(0); break; case MSM_CAMERA_LED_LOW: cam_err("[MSM_CAMERA_LED_LOW][MIC2871YMK]\n"); MIC2871YMK_set_flash_movie(1); break; case MSM_CAMERA_LED_HIGH: cam_err("[MSM_CAMERA_LED_HIGH][MIC2871YMK]\n"); MIC2871YMK_set_flash_flash(1); break; default: cam_err("[default][MIC2871YMK]\n"); rc = -EFAULT; break; } #elif defined (CONFIG_MACH_KS02) printk("[led_state::%d]\n", led_state); switch (led_state) { case MSM_CAMERA_LED_INIT: cam_err("[MSM_CAMERA_LED_INIT]\n"); break; case MSM_CAMERA_LED_RELEASE: cam_err("[MSM_CAMERA_LED_RELEASE]\n"); gpio_set_value_cansleep(GPIO_CAM_FLASH_EN, 0); gpio_set_value_cansleep(GPIO_CAM_FLASH_SET, 0); break; case MSM_CAMERA_LED_OFF: cam_err("[MSM_CAMERA_LED_OFF]\n"); gpio_set_value_cansleep(GPIO_CAM_FLASH_EN, 0); gpio_set_value_cansleep(GPIO_CAM_FLASH_SET, 0); break; case MSM_CAMERA_LED_LOW: cam_err("[MSM_CAMERA_LED_LOW]\n"); gpio_set_value_cansleep(GPIO_CAM_FLASH_SET, 1); break; case MSM_CAMERA_LED_HIGH: cam_err("[MSM_CAMERA_LED_HIGH]\n"); gpio_set_value_cansleep(GPIO_CAM_FLASH_EN, 1); break; default: cam_err("[default]\n"); rc = -EFAULT; break; } #endif return rc; #elif defined (CONFIG_S5K4ECGX) #if defined (CONFIG_MACH_CANE) || defined (CONFIG_MACH_LOGANRE) int rc = 0; printk("[led_state::%d]\n", led_state); switch (led_state) { case MSM_CAMERA_LED_INIT: cam_err("[MSM_CAMERA_LED_INIT][RT8547]\n"); gpio_tlmm_config(GPIO_CFG(GPIO_CAM_FLASH_SOURCE_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG(GPIO_CAM_FLASH_SET, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG(GPIO_CAM_FLASH_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE); /* LVP */ //RT8547_ctrl_cmd(external, 0x00); break; case MSM_CAMERA_LED_RELEASE: cam_err("[MSM_CAMERA_LED_RELEASE]\n"); break; case MSM_CAMERA_LED_OFF: printk("[Torch flash]OFF\n"); #if defined (CONFIG_LEDS_RT8547) rt8547_set_led_off(); #endif break; case MSM_CAMERA_LED_LOW: printk("[Torch flash]ON\n"); #if defined (CONFIG_LEDS_RT8547) rt8547_set_led_low(); #endif break; case MSM_CAMERA_LED_HIGH: printk("[Torch flash]ON\n"); #if defined (CONFIG_LEDS_RT8547) rt8547_set_led_high(); #endif break; default: rc = -EFAULT; break; } #endif return rc; #else int rc = 0; CDBG("msm_camera_flash_led: %d\n", led_state); switch (led_state) { case MSM_CAMERA_LED_INIT: rc = gpio_request(external->led_en, "sgm3141"); CDBG("MSM_CAMERA_LED_INIT: gpio_req: %d %d\n", external->led_en, rc); if (!rc) gpio_direction_output(external->led_en, 0); else return 0; rc = gpio_request(external->led_flash_en, "sgm3141"); CDBG("MSM_CAMERA_LED_INIT: gpio_req: %d %d\n", external->led_flash_en, rc); if (!rc) gpio_direction_output(external->led_flash_en, 0); break; case MSM_CAMERA_LED_RELEASE: CDBG("MSM_CAMERA_LED_RELEASE\n"); gpio_set_value_cansleep(external->led_en, 0); gpio_free(external->led_en); gpio_set_value_cansleep(external->led_flash_en, 0); gpio_free(external->led_flash_en); break; case MSM_CAMERA_LED_OFF: CDBG("MSM_CAMERA_LED_OFF\n"); gpio_set_value_cansleep(external->led_en, 0); gpio_set_value_cansleep(external->led_flash_en, 0); break; case MSM_CAMERA_LED_LOW: CDBG("MSM_CAMERA_LED_LOW\n"); gpio_set_value_cansleep(external->led_en, 1); gpio_set_value_cansleep(external->led_flash_en, 1); break; case MSM_CAMERA_LED_HIGH: CDBG("MSM_CAMERA_LED_HIGH\n"); gpio_set_value_cansleep(external->led_en, 1); gpio_set_value_cansleep(external->led_flash_en, 1); break; default: rc = -EFAULT; break; } return rc; #endif } static void flash_wq_function(struct work_struct *work) { if (tps61310_client) { i2c_client.client = tps61310_client; i2c_client.addr_type = MSM_CAMERA_I2C_BYTE_ADDR; msm_camera_i2c_write(&i2c_client, 0x01, 0x46, MSM_CAMERA_I2C_BYTE_DATA); } return; } void flash_timer_callback(unsigned long data) { queue_work(flash_wq, (struct work_struct *)work ); mod_timer(&flash_timer, jiffies + msecs_to_jiffies(10000)); } int msm_camera_flash_external( struct msm_camera_sensor_flash_external *external, unsigned led_state) { int rc = 0; switch (led_state) { case MSM_CAMERA_LED_INIT: if (external->flash_id == MAM_CAMERA_EXT_LED_FLASH_SC628A) { if (!sc628a_client) { rc = i2c_add_driver(&sc628a_i2c_driver); if (rc < 0 || sc628a_client == NULL) { pr_err("sc628a_i2c_driver add failed\n"); rc = -ENOTSUPP; return rc; } } } else if (external->flash_id == MAM_CAMERA_EXT_LED_FLASH_TPS61310) { if (!tps61310_client) { rc = i2c_add_driver(&tps61310_i2c_driver); if (rc < 0 || tps61310_client == NULL) { pr_err("tps61310_i2c_driver add failed\n"); rc = -ENOTSUPP; return rc; } } } else { pr_err("Flash id not supported\n"); rc = -ENOTSUPP; return rc; } #if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE) if (external->expander_info && !sx150x_client) { struct i2c_adapter *adapter = i2c_get_adapter(external->expander_info->bus_id); if (adapter) sx150x_client = i2c_new_device(adapter, external->expander_info->board_info); if (!sx150x_client || !adapter) { pr_err("sx150x_client is not available\n"); rc = -ENOTSUPP; if (sc628a_client) { i2c_del_driver(&sc628a_i2c_driver); sc628a_client = NULL; } if (tps61310_client) { i2c_del_driver(&tps61310_i2c_driver); tps61310_client = NULL; } return rc; } i2c_put_adapter(adapter); } #endif if (sc628a_client) rc = gpio_request(external->led_en, "sc628a"); if (tps61310_client) rc = gpio_request(external->led_en, "tps61310"); if (!rc) { gpio_direction_output(external->led_en, 0); } else { goto error; } if (sc628a_client) rc = gpio_request(external->led_flash_en, "sc628a"); if (tps61310_client) rc = gpio_request(external->led_flash_en, "tps61310"); if (!rc) { gpio_direction_output(external->led_flash_en, 0); break; } if (sc628a_client || tps61310_client) { gpio_set_value_cansleep(external->led_en, 0); gpio_free(external->led_en); } error: pr_err("%s gpio request failed\n", __func__); if (sc628a_client) { i2c_del_driver(&sc628a_i2c_driver); sc628a_client = NULL; } if (tps61310_client) { i2c_del_driver(&tps61310_i2c_driver); tps61310_client = NULL; } break; case MSM_CAMERA_LED_RELEASE: if (sc628a_client || tps61310_client) { gpio_set_value_cansleep(external->led_en, 0); gpio_free(external->led_en); gpio_set_value_cansleep(external->led_flash_en, 0); gpio_free(external->led_flash_en); if (sc628a_client) { i2c_del_driver(&sc628a_i2c_driver); sc628a_client = NULL; } if (tps61310_client) { if (timer_state) { del_timer(&flash_timer); kfree((void *)work); timer_state = 0; } i2c_del_driver(&tps61310_i2c_driver); tps61310_client = NULL; } } #if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE) if (external->expander_info && sx150x_client) { i2c_unregister_device(sx150x_client); sx150x_client = NULL; } #endif break; case MSM_CAMERA_LED_OFF: if (sc628a_client || tps61310_client) { if (sc628a_client) { i2c_client.client = sc628a_client; i2c_client.addr_type = MSM_CAMERA_I2C_BYTE_ADDR; rc = msm_camera_i2c_write(&i2c_client, 0x02, 0x00, MSM_CAMERA_I2C_BYTE_DATA); } if (tps61310_client) { i2c_client.client = tps61310_client; i2c_client.addr_type = MSM_CAMERA_I2C_BYTE_ADDR; rc = msm_camera_i2c_write(&i2c_client, 0x01, 0x00, MSM_CAMERA_I2C_BYTE_DATA); if (timer_state) { del_timer(&flash_timer); kfree((void *)work); timer_state = 0; } } gpio_set_value_cansleep(external->led_en, 0); gpio_set_value_cansleep(external->led_flash_en, 0); } break; case MSM_CAMERA_LED_LOW: if (sc628a_client || tps61310_client) { gpio_set_value_cansleep(external->led_en, 1); gpio_set_value_cansleep(external->led_flash_en, 1); usleep_range(2000, 3000); if (sc628a_client) { i2c_client.client = sc628a_client; i2c_client.addr_type = MSM_CAMERA_I2C_BYTE_ADDR; rc = msm_camera_i2c_write(&i2c_client, 0x02, 0x06, MSM_CAMERA_I2C_BYTE_DATA); } if (tps61310_client) { i2c_client.client = tps61310_client; i2c_client.addr_type = MSM_CAMERA_I2C_BYTE_ADDR; rc = msm_camera_i2c_write(&i2c_client, 0x01, 0x46, MSM_CAMERA_I2C_BYTE_DATA); flash_wq = create_workqueue("my_queue"); work = (struct flash_work *)kmalloc(sizeof(struct flash_work), GFP_KERNEL); INIT_WORK( (struct work_struct *)work, flash_wq_function ); setup_timer(&flash_timer, flash_timer_callback, 0); mod_timer(&flash_timer, jiffies + msecs_to_jiffies(10000)); timer_state = 1; } } break; case MSM_CAMERA_LED_HIGH: if (sc628a_client || tps61310_client) { gpio_set_value_cansleep(external->led_en, 1); gpio_set_value_cansleep(external->led_flash_en, 1); usleep_range(2000, 3000); if (sc628a_client) { i2c_client.client = sc628a_client; i2c_client.addr_type = MSM_CAMERA_I2C_BYTE_ADDR; rc = msm_camera_i2c_write(&i2c_client, 0x02, 0x49, MSM_CAMERA_I2C_BYTE_DATA); } if (tps61310_client) { i2c_client.client = tps61310_client; i2c_client.addr_type = MSM_CAMERA_I2C_BYTE_ADDR; rc = msm_camera_i2c_write(&i2c_client, 0x01, 0x8B, MSM_CAMERA_I2C_BYTE_DATA); } } break; default: rc = -EFAULT; break; } return rc; } static int msm_camera_flash_pwm( struct msm_camera_sensor_flash_pwm *pwm, unsigned led_state) { int rc = 0; int PWM_PERIOD = USEC_PER_SEC / pwm->freq; static struct pwm_device *flash_pwm; if (!flash_pwm) { flash_pwm = pwm_request(pwm->channel, "camera-flash"); if (flash_pwm == NULL || IS_ERR(flash_pwm)) { pr_err("%s: FAIL pwm_request(): flash_pwm=%p\n", __func__, flash_pwm); flash_pwm = NULL; return -ENXIO; } } switch (led_state) { case MSM_CAMERA_LED_LOW: rc = pwm_config(flash_pwm, (PWM_PERIOD/pwm->max_load)*pwm->low_load, PWM_PERIOD); if (rc >= 0) rc = pwm_enable(flash_pwm); break; case MSM_CAMERA_LED_HIGH: rc = pwm_config(flash_pwm, (PWM_PERIOD/pwm->max_load)*pwm->high_load, PWM_PERIOD); if (rc >= 0) rc = pwm_enable(flash_pwm); break; case MSM_CAMERA_LED_OFF: pwm_disable(flash_pwm); break; case MSM_CAMERA_LED_INIT: case MSM_CAMERA_LED_RELEASE: break; default: rc = -EFAULT; break; } 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->pmic_set_current(pmic->led_src_1, 0); if (pmic->num_of_src > 1) rc = pmic->pmic_set_current(pmic->led_src_2, 0); break; case MSM_CAMERA_LED_LOW: rc = pmic->pmic_set_current(pmic->led_src_1, pmic->low_current); if (pmic->num_of_src > 1) rc = pmic->pmic_set_current(pmic->led_src_2, 0); break; case MSM_CAMERA_LED_HIGH: rc = pmic->pmic_set_current(pmic->led_src_1, pmic->high_current); if (pmic->num_of_src > 1) rc = pmic->pmic_set_current(pmic->led_src_2, pmic->high_current); break; case MSM_CAMERA_LED_INIT: case MSM_CAMERA_LED_RELEASE: break; default: rc = -EFAULT; break; } CDBG("flash_set_led_state: return %d\n", rc); return rc; }