Rhode: add flash current ma control
details: add flash current ma control Change-Id: Ic3c89657ac568cf56fc2f402c90211fb433b6212 Signed-off-by: huaqin78 <huaqin78@motorola.com> Reviewed-on: https://gerrit.mot.com/2142100 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: <huaqin90@motorola.com> Reviewed-by: Long Cheng <chengl1@motorola.com> Reviewed-by: Zhichao Chen <chenzc2@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
1 parent
39aa228086
commit
b56aeec82b
3 files changed
+42
-9
No files matched your search
@@ -541,7 +541,7 @@ int cam_flash_off(struct cam_flash_ctrl *flash_ctrl)
|
||||
|
||||
cam_res_mgr_gpio_set_value(soc_private->flash_gpio_enable, 0);
|
||||
cam_res_mgr_gpio_free(soc_info.dev, soc_private->flash_gpio_enable);
|
||||
pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE_SUSPEND, 1);
|
||||
pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE_SUSPEND, CAMERA_SENSOR_FLASH_OP_OFF, 0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@@ -574,7 +574,7 @@ static int cam_flash_low(
|
||||
CAM_ERR(CAM_FLASH, "Fire Torch failed: %d", rc);
|
||||
|
||||
#ifdef CONFIG_CAMERA_FLASH_PWM
|
||||
CAM_DBG(CAM_FLASH, "Flash low Triggered");
|
||||
CAM_DBG(CAM_FLASH, "Flash low Triggered flash_data->led_current_ma[0] = %u", flash_data->led_current_ma[0]);
|
||||
rc = cam_res_mgr_gpio_request(soc_info.dev, soc_private->flash_gpio_enable, 0, "CUSTOM_GPIO1");
|
||||
if(rc) {
|
||||
CAM_ERR(CAM_FLASH, "gpio %d request fails", soc_private->flash_gpio_enable);
|
||||
@@ -582,7 +582,9 @@ static int cam_flash_low(
|
||||
}
|
||||
|
||||
cam_res_mgr_gpio_set_value(soc_private->flash_gpio_enable, 0);
|
||||
pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE_ACTIVE, 10000);
|
||||
pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE_ACTIVE, CAMERA_SENSOR_FLASH_OP_FIRELOW, FLASH_FIRE_LOW_MAXCURRENT);
|
||||
usleep_range(5000,6000);
|
||||
pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE_ACTIVE, CAMERA_SENSOR_FLASH_OP_FIRELOW, flash_data->led_current_ma[0]);
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
@@ -615,7 +617,7 @@ static int cam_flash_high(
|
||||
CAM_ERR(CAM_FLASH, "Fire Flash Failed: %d", rc);
|
||||
|
||||
#ifdef CONFIG_CAMERA_FLASH_PWM
|
||||
CAM_DBG(CAM_FLASH, "Flash high Triggered");
|
||||
CAM_DBG(CAM_FLASH, "Flash high Triggered flash_data->led_current_ma[0] = %u", flash_data->led_current_ma[0]);
|
||||
rc = cam_res_mgr_gpio_request(soc_info.dev, soc_private->flash_gpio_enable, 0, "CUSTOM_GPIO1");
|
||||
if(rc) {
|
||||
CAM_ERR(CAM_FLASH, "gpio %d request fails", soc_private->flash_gpio_enable);
|
||||
@@ -623,7 +625,7 @@ static int cam_flash_high(
|
||||
}
|
||||
|
||||
cam_res_mgr_gpio_set_value(soc_private->flash_gpio_enable, 1);
|
||||
pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE_ACTIVE, 10000);
|
||||
pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE_ACTIVE, CAMERA_SENSOR_FLASH_OP_FIREHIGH, flash_data->led_current_ma[0]);
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
|
||||
@@ -35,20 +35,47 @@ struct pwm_device *pwm;
|
||||
* Function
|
||||
*****************************************************************************/
|
||||
|
||||
void pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE s, u64 flash_current){
|
||||
void pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE s, enum camera_flash_opcode opcode, u64 flash_current){
|
||||
struct pwm_state pstate;
|
||||
int rc = 0;
|
||||
u64 real_current = 0;
|
||||
|
||||
pwm_get_state(pwm, &pstate);
|
||||
pstate.period = 50000;
|
||||
pstate.duty_cycle = 50000 * flash_current / 10000;
|
||||
PM6125_FLASH_PRINT("[pm6125_flash_gpio]Status duty_cycle = %u, period = %u\n",
|
||||
pstate.duty_cycle, pstate.period);
|
||||
pstate.period = PM6125_PWM_PERIOD;
|
||||
switch (s) {
|
||||
case PM6125_FLASH_GPIO_STATE_ACTIVE:
|
||||
pstate.duty_cycle = 0;
|
||||
pstate.enabled = false;
|
||||
rc = pwm_apply_state(pwm, &pstate);
|
||||
PM6125_FLASH_PRINT("[pm6125_flash_gpio]Suspend before Active");
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case CAMERA_SENSOR_FLASH_OP_FIRELOW:
|
||||
real_current = (flash_current > FLASH_FIRE_LOW_MAXCURRENT?FLASH_FIRE_LOW_MAXCURRENT:flash_current);
|
||||
pstate.duty_cycle = PM6125_PWM_PERIOD * real_current / FLASH_FIRE_LOW_MAXCURRENT;
|
||||
break;
|
||||
case CAMERA_SENSOR_FLASH_OP_FIREHIGH:
|
||||
real_current = (flash_current > FLASH_FIRE_HIGH_MAXCURRENT?FLASH_FIRE_HIGH_MAXCURRENT:flash_current);
|
||||
pstate.duty_cycle = PM6125_PWM_PERIOD * real_current / FLASH_FIRE_HIGH_MAXCURRENT;
|
||||
break;
|
||||
default:
|
||||
pstate.duty_cycle = PM6125_PWM_PERIOD;
|
||||
break;
|
||||
}
|
||||
|
||||
pstate.enabled = true;
|
||||
rc = pwm_apply_state(pwm, &pstate);
|
||||
|
||||
PM6125_FLASH_PRINT("[pm6125_flash_gpio]Active duty_cycle = %u, period = %u, opcode = %u, real_current = %u\n",
|
||||
pstate.duty_cycle, pstate.period, opcode, real_current);
|
||||
break;
|
||||
case PM6125_FLASH_GPIO_STATE_SUSPEND:
|
||||
pstate.enabled = false;
|
||||
rc = pwm_apply_state(pwm, &pstate);
|
||||
PM6125_FLASH_PRINT("[pm6125_flash_gpio]Suspend");
|
||||
break;
|
||||
default:
|
||||
PM6125_FLASH_PRINT("[pm6125_flash_gpio]Failed to control PWM use a err state!\n");
|
||||
|
||||
@@ -12,8 +12,12 @@ typedef enum {
|
||||
PM6125_FLASH_GPIO_STATE_MAX, /* for array size */
|
||||
} PM6125_FLASH_GPIO_STATE;
|
||||
|
||||
#define PM6125_PWM_PERIOD 50000
|
||||
#define FLASH_FIRE_HIGH_MAXCURRENT 1200
|
||||
#define FLASH_FIRE_LOW_MAXCURRENT 150
|
||||
|
||||
/*****************************************************************************
|
||||
* Function Prototype
|
||||
*****************************************************************************/
|
||||
extern void pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE s, u64 flash_current);
|
||||
extern void pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE s, enum camera_flash_opcode opcode, u64 flash_current);
|
||||
#endif /* _PM6125_FLASH_GPIO_H_*/
|
||||
Reference in new issue
Block a user