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

Commit 8d42cf0c authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "backlight: qcom-spmi-wled: Fix compilation error"

parents 772d3f86 7dafa542
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -1510,7 +1510,8 @@ static int wled_get_max_avail_current(struct led_classdev *led_cdev,
					int *max_current)
{
	struct wled *wled;
	int rc, ocv_mv, r_bat_mohms, i_bat_ma, i_sink_ma = 0, max_fsc_ma;
	int rc, ocv_mv, r_bat_mohms, i_bat_ma;
	int64_t max_fsc_ma, i_sink_ma = 0;
	int64_t p_out_string, p_out, p_in, v_safe_mv, i_flash_ma, v_ph_mv;

	if (!strcmp(led_cdev->name, "wled_switch"))
@@ -1556,7 +1557,7 @@ static int wled_get_max_avail_current(struct led_classdev *led_cdev,
	p_out_string = ((wled->leds_per_string * V_LED_MV) + V_HDRM_MV) *
			I_FLASH_MAX_MA;
	p_out = p_out_string * wled->num_strings;
	p_in = (p_out * 1000) / EFF_FACTOR;
	p_in = div_s64(p_out * 1000, EFF_FACTOR);

	pr_debug("p_out_string: %lld, p_out: %lld, p_in: %lld\n", p_out_string,
		p_out, p_in);
@@ -1568,8 +1569,9 @@ static int wled_get_max_avail_current(struct led_classdev *led_cdev,
		return 0;
	}

	i_flash_ma = p_in / v_safe_mv;
	v_ph_mv = ocv_mv - ((i_bat_ma + i_flash_ma) * r_bat_mohms) / 1000;
	i_flash_ma = div_s64(p_in, v_safe_mv);
	v_ph_mv = ocv_mv - div_s64(((i_bat_ma + i_flash_ma) * r_bat_mohms),
							1000);

	pr_debug("v_safe: %lld, i_flash: %lld, v_ph: %lld\n", v_safe_mv,
		i_flash_ma, v_ph_mv);
@@ -1578,19 +1580,22 @@ static int wled_get_max_avail_current(struct led_classdev *led_cdev,
	if (wled->num_strings == 3 && wled->leds_per_string == 8) {
		if (v_ph_mv < 3410) {
			/* For 8s3p, I_sink(mA) = 25.396 * Vph(V) - 26.154 */
			i_sink_ma = (((25396 * v_ph_mv) / 1000) - 26154) / 1000;
			i_sink_ma = div_s64((div_s64((25396 * v_ph_mv),
					1000) - 26154), 1000);
			i_sink_ma *= wled->num_strings;
		}
	} else if (wled->num_strings == 3 && wled->leds_per_string == 6) {
		if (v_ph_mv < 2800) {
			/* For 6s3p, I_sink(mA) = 41.311 * Vph(V) - 52.334 */
			i_sink_ma = (((41311 * v_ph_mv) / 1000) - 52334) / 1000;
			i_sink_ma = div_s64((div_s64((41311 * v_ph_mv),
					1000) - 52334), 1000);
			i_sink_ma *= wled->num_strings;
		}
	} else if (wled->num_strings == 4 && wled->leds_per_string == 6) {
		if (v_ph_mv < 3400) {
			/* For 6s4p, I_sink(mA) = 26.24 * Vph(V) - 24.834 */
			i_sink_ma = (((26240 * v_ph_mv) / 1000) - 24834) / 1000;
			i_sink_ma = div_s64((div_s64((26240 * v_ph_mv),
					1000) - 24834), 1000);
			i_sink_ma *= wled->num_strings;
		}
	} else if (v_ph_mv < 3200) {