int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
{
	struct pm8x41_mpp mpp;
	int rc;

	if (bl->bl_interface_type == BL_DCS)
		return 0;

	mpp.base = PM8x41_MMP4_BASE;
	mpp.vin = MPP_VIN0;
	if (enable) {
		pm_pwm_enable(false);
		rc = pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US);
		if (rc < 0)
			mpp.mode = MPP_HIGH;
		else {
			mpp.mode = MPP_DTEST1;
			pm_pwm_enable(true);
		}
		pm8x41_config_output_mpp(&mpp);
		pm8x41_enable_mpp(&mpp, MPP_ENABLE);
	} else {
		pm_pwm_enable(false);
		pm8x41_enable_mpp(&mpp, MPP_DISABLE);
	}
	mdelay(20);
	return 0;
}
Esempio n. 2
0
int panel_set_backlight(uint8_t bt_level)
{
	int rc = -1;
	uint32_t duty_us, period_us;

	if((bt_level <= 0) || (bt_level > 15))
	{
		dprintf(CRITICAL, "Error in brightness level (1-15 allowed)\n");
		goto bail_out;
	}

	duty_us = bt_level*PWM_DUTY_LEVEL;
	period_us = PWM_PERIOD_USEC;
	rc = pm_pwm_config(0, duty_us, period_us);
	if(rc)
	{
		dprintf(CRITICAL, "Error in pwm_config0\n");
		goto bail_out;
	}

	duty_us = PWM_PERIOD_USEC - (bt_level*PWM_DUTY_LEVEL);
	period_us = PWM_PERIOD_USEC;
	rc = pm_pwm_config(1, duty_us, period_us);
	if(rc)
	{
		dprintf(CRITICAL, "Error in pwm_config1\n");
		goto bail_out;
	}

	rc = pm_pwm_enable(0);
	if(rc)
	{
		dprintf(CRITICAL, "Error in pwm_enable0\n");
		goto bail_out;
	}

	rc = pm_pwm_enable(1);
	if(rc)
		dprintf(CRITICAL, "Error in pwm_enable1\n");

bail_out:
	return rc;
}