leds: qti-flash: set switch enabled state for precision control properly

Currently, for precision flash control, switch device's enabled
state is set to true when the brightness is set to 1 and on_timer
is started. However, it can be set to false only when the
brightness is set to 0. For camera flash use cases like turning
on pre-flash/torch immediately following the timed flash event,
this needs to be changed i.e. set the enabled state to false when
the off_timer callback is invoked to disable switch device.

Change-Id: Ib99ef1e93a21645a816555cc44c66957b5d2a43b
Suggested-by: Depeng Shao <quic_depengs@quicinc.com>
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
This commit is contained in:
Subbaraman Narayanamurthy 2022-06-21 14:15:47 -07:00
parent bc54901994
commit 3fa44c01e4

View File

@ -799,7 +799,6 @@ static void qti_flash_led_switch_brightness_set(
hrtimer_start(&snode->on_timer,
ms_to_ktime(snode->on_time_ms),
HRTIMER_MODE_REL);
snode->enabled = state;
return;
}
@ -841,6 +840,8 @@ static enum hrtimer_restart off_timer_function(struct hrtimer *timer)
if (rc < 0)
pr_err("Failed to disable flash LED switch %s, rc=%d\n",
snode->cdev.name, rc);
else
snode->enabled = false;
return HRTIMER_NORESTART;
}
@ -856,6 +857,8 @@ static enum hrtimer_restart on_timer_function(struct hrtimer *timer)
snode->enabled = false;
pr_err("Failed to enable flash LED switch %s, rc=%d\n",
snode->cdev.name, rc);
} else {
snode->enabled = true;
}
return HRTIMER_NORESTART;