mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-24 21:54:34 -04:00
Rhodep: add flash current ma control
details: add flash current ma control Change-Id: Ic3c89657ac568cf56fc2f402c90211fb433b6212 Signed-off-by: huaqin78 <huaqin78@motorola.com> Signed-off-by: luozhq15 <luozhq15@motorola.com> Reviewed-on: https://gerrit.mot.com/2142725 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Reviewed-by: Long Cheng <chengl1@motorola.com> Reviewed-by: <huaqin90@motorola.com> Reviewed-by: Zhichao Chen <chenzc2@motorola.com> Tested-by: Jira Key Submit-Approved: Jira Key
This commit is contained in:
parent
0e977529ef
commit
8c97d184f6
3 changed files with 75 additions and 42 deletions
|
|
@ -556,7 +556,7 @@ int cam_flash_off(struct cam_flash_ctrl *flash_ctrl)
|
|||
CAM_ERR(CAM_SENSOR,"cam_flash_off");
|
||||
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;
|
||||
}
|
||||
|
|
@ -589,14 +589,16 @@ static int cam_flash_low(
|
|||
CAM_ERR(CAM_FLASH, "Fire Torch failed: %d", rc);
|
||||
|
||||
#ifdef CONFIG_CAMERA_FLASH_PWM
|
||||
CAM_ERR(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);
|
||||
return rc;
|
||||
}
|
||||
cam_res_mgr_gpio_set_value(soc_private->flash_gpio_enable, 0);
|
||||
pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE_ACTIVE, (u64)flash_data->led_current_ma[0]*10000/1500);
|
||||
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;
|
||||
|
|
@ -630,14 +632,14 @@ static int cam_flash_high(
|
|||
CAM_ERR(CAM_FLASH, "Fire Flash Failed: %d", rc);
|
||||
|
||||
#ifdef CONFIG_CAMERA_FLASH_PWM
|
||||
CAM_ERR(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);
|
||||
return rc;
|
||||
}
|
||||
cam_res_mgr_gpio_set_value(soc_private->flash_gpio_enable, 1);
|
||||
pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE_ACTIVE, (u64)flash_data->led_current_ma[0]*10000/1500);
|
||||
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,28 +35,55 @@ struct pwm_device *pwm;
|
|||
* Function
|
||||
*****************************************************************************/
|
||||
|
||||
void pm6125_flash_gpio_select_state(PM6125_FLASH_GPIO_STATE s, u64 flash_current){
|
||||
struct pwm_state pstate;
|
||||
int rc = 0;
|
||||
pwm_get_state(pwm, &pstate);
|
||||
pstate.period = 50000;
|
||||
pstate.duty_cycle = 500000*flash_current/10000;
|
||||
switch(s){
|
||||
case PM6125_FLASH_GPIO_STATE_ACTIVE:
|
||||
pstate.enabled = true;
|
||||
rc = pwm_apply_state(pwm, &pstate);
|
||||
break;
|
||||
case PM6125_FLASH_GPIO_STATE_SUSPEND:
|
||||
pstate.enabled = false;
|
||||
rc = pwm_apply_state(pwm, &pstate);
|
||||
break;
|
||||
default:
|
||||
PM6125_FLASH_PRINT("[pm6125_flash_gpio]Failed to control PWM use a err state!\n");
|
||||
}
|
||||
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;
|
||||
|
||||
if(rc < 0) {
|
||||
PM6125_FLASH_PRINT("[pm6125_flash_gpio]Apply PWM state fail, rc = %d", rc);
|
||||
}
|
||||
pwm_get_state(pwm, &pstate);
|
||||
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");
|
||||
}
|
||||
|
||||
if(rc < 0) {
|
||||
PM6125_FLASH_PRINT("[pm6125_flash_gpio]Apply PWM state fail, rc = %d", rc);
|
||||
}
|
||||
}
|
||||
|
||||
static int pm6125_flash_pwm_probe(struct platform_device *pdev)
|
||||
|
|
@ -69,30 +96,30 @@ static int pm6125_flash_pwm_probe(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
static const struct of_device_id gpio_of_match[] = {
|
||||
{ .compatible = "qualcomm,pm6125_flash_gpio", },
|
||||
{},
|
||||
{ .compatible = "qualcomm,pm6125_flash_gpio", },
|
||||
{},
|
||||
};
|
||||
|
||||
static struct platform_driver pm6125_flash_gpio_platform_driver = {
|
||||
.probe = pm6125_flash_pwm_probe,
|
||||
.driver = {
|
||||
.name = "PM6125_FLASH_GPIO_DTS",
|
||||
.of_match_table = gpio_of_match,
|
||||
},
|
||||
.probe = pm6125_flash_pwm_probe,
|
||||
.driver = {
|
||||
.name = "PM6125_FLASH_GPIO_DTS",
|
||||
.of_match_table = gpio_of_match,
|
||||
},
|
||||
};
|
||||
|
||||
int pm6125_flash_gpio_init_module(void)
|
||||
{
|
||||
if (platform_driver_register(&pm6125_flash_gpio_platform_driver)) {
|
||||
PM6125_FLASH_PRINT("[pm6125_flash_gpio]Failed to register pm6125_flash_gpio_platform_driver!\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
if (platform_driver_register(&pm6125_flash_gpio_platform_driver)) {
|
||||
PM6125_FLASH_PRINT("[pm6125_flash_gpio]Failed to register pm6125_flash_gpio_platform_driver!\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pm6125_flash_gpio_exit_module(void)
|
||||
{
|
||||
platform_driver_unregister(&pm6125_flash_gpio_platform_driver);
|
||||
platform_driver_unregister(&pm6125_flash_gpio_platform_driver);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("liyang <liyang14@huaqin.com>");
|
||||
|
|
|
|||
|
|
@ -12,10 +12,14 @@ 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);
|
||||
int pm6125_flash_gpio_init_module(void);
|
||||
void pm6125_flash_gpio_exit_module(void);
|
||||
#endif /* _PM6125_FLASH_GPIO_H_*/
|
||||
#endif /* _PM6125_FLASH_GPIO_H_*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue