Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21f706fe authored by Shyam Kumar Thella's avatar Shyam Kumar Thella Committed by Kavya Nunna
Browse files

leds: qti-flash: Disable flash LED channel after De-strobe



Currently when a flash/torch device is disabled, ITARGET of the channel
is programmed to 0 by qti_flash_led_disable() before the channel is
de-strobed. This is causing a ramp down of the flash LED channel during
disable. Fix this by programming target current to 0 only after channel
is de-strobed.

Change-Id: Ie566f4e75b8af8c27b7b9a828823a9bfddc48bb6
Signed-off-by: default avatarShyam Kumar Thella <sthella@codeaurora.org>
parent 9ff7a030
Loading
Loading
Loading
Loading
+35 −13
Original line number Diff line number Diff line
@@ -512,18 +512,15 @@ static void qti_flash_led_brightness_set(struct led_classdev *led_cdev,
	led = fnode->led;

	if (!brightness) {
		rc = qti_flash_led_disable(fnode);
		if (rc < 0) {
			pr_err("Failed to set brightness %d to LED\n",
				brightness);
			return;
		}

		rc = qti_flash_led_strobe(fnode->led,
			FLASH_LED_ENABLE(fnode->id), 0);
		if (rc < 0)
			pr_err("Failed to destrobe LED, rc=%d\n", rc);

		rc = qti_flash_led_disable(fnode);
		if (rc < 0)
			pr_err("Failed to disable %d LED\n",
				brightness);
		return;
	}

@@ -643,6 +640,21 @@ static int qti_flash_switch_disable(struct flash_switch_data *snode)
	int rc = 0, i;
	u8 led_dis = 0;

	for (i = 0; i < led->num_fnodes; i++) {
		if (!(snode->led_mask & BIT(led->fnode[i].id)) ||
				!led->fnode[i].configured)
			continue;

		led_dis |= BIT(led->fnode[i].id);
	}

	rc = qti_flash_led_strobe(led, led_dis, ~led_dis);
	if (rc < 0) {
		pr_err("Failed to destrobe LEDs under with switch, rc=%d\n",
					rc);
		return rc;
	}

	for (i = 0; i < led->num_fnodes; i++) {
		/*
		 * Do not turn OFF flash/torch device if
@@ -660,10 +672,9 @@ static int qti_flash_switch_disable(struct flash_switch_data *snode)
			break;
		}

		led_dis |= (1 << led->fnode[i].id);
	}

	return qti_flash_led_strobe(led, led_dis, ~led_dis);
	return rc;
}

static void qti_flash_led_switch_brightness_set(
@@ -1040,14 +1051,25 @@ static int qti_flash_strobe_set(struct led_classdev_flash *fdev,
	if (fnode->enabled == state)
		return 0;

	if (state && !fnode->configured)
		return -EINVAL;

	mask = FLASH_LED_ENABLE(fnode->id);
	value = state ? FLASH_LED_ENABLE(fnode->id) : 0;

	rc = qti_flash_led_strobe(fnode->led, mask, value);
	if (!rc) {
	if (rc < 0) {
		pr_err("Failed to %s LED, rc=%d\n",
			state ? "strobe" : "desrobe", rc);
		return rc;
	}

	fnode->enabled = state;
		if (!state)
			fnode->configured = false;

	if (!state) {
		rc = qti_flash_led_disable(fnode);
		if (rc < 0)
			pr_err("Failed to disable LED %u\n", fnode->id);
	}

	return rc;