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

Commit 3afbba8e authored by Shyam Kumar Thella's avatar Shyam Kumar Thella
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 810464bf
Loading
Loading
Loading
Loading
+36 −19
Original line number Diff line number Diff line
@@ -469,17 +469,16 @@ static void qti_flash_led_brightness_set(struct led_classdev *led_cdev,
	led = fnode->led;

	if (!brightness) {
		rc = qti_flash_led_disable(fnode);
		rc = qti_flash_led_strobe(fnode->led, NULL,
			FLASH_LED_ENABLE(fnode->id), 0);
		if (rc < 0) {
			pr_err("Failed to set brightness %d to LED\n",
				brightness);
			pr_err("Failed to destrobe LED, rc=%d\n", rc);
			return;
		}

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

		return;
	}
@@ -600,6 +599,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, NULL, 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
@@ -616,14 +630,12 @@ static int qti_flash_switch_disable(struct flash_switch_data *snode)
				&led->fnode[i].id);
			break;
		}

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

	snode->on_time_ms = 0;
	snode->off_time_ms = 0;

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

static void qti_flash_led_switch_brightness_set(
@@ -1108,21 +1120,26 @@ static int qti_flash_strobe_set(struct led_classdev_flash *fdev,
	if (fnode->enabled == state)
		return 0;

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

	return rc;
}