Ejemplo n.º 1
0
/* Periodic update */
bool nvsd_update_brightness(struct tegra_dc *dc)
{
	u32 val = 0;
	int cur_sd_brightness;
	struct tegra_dc_sd_settings *settings = dc->out->sd_settings;

	if (sd_brightness) {
		if (atomic_read(&man_k_until_blank) &&
					!settings->phase_in_adjustments) {
			val = tegra_dc_readl(dc, DC_DISP_SD_CONTROL);
			val &= ~SD_CORRECTION_MODE_MAN;
			tegra_dc_writel(dc, val, DC_DISP_SD_CONTROL);
			atomic_set(&man_k_until_blank, 0);
		}

		if (settings->cmd)
			nvsd_cmd_handler(settings, dc);

		/* nvsd_cmd_handler may turn off didim */
		if (!settings->enable)
			return true;

		cur_sd_brightness = atomic_read(sd_brightness);

		/* read brightness value */
		val = tegra_dc_readl(dc, DC_DISP_SD_BL_CONTROL);
		val = SD_BLC_BRIGHTNESS(val);

		if (settings->phase_in_adjustments) {
			return nvsd_phase_in_adjustments(dc, settings);
		} else if (val != (u32)cur_sd_brightness) {
			/* set brightness value and note the update */
			atomic_set(sd_brightness, (int)val);
			return true;
		}
	}

	/* No update needed. */
	return false;
}
Ejemplo n.º 2
0
/* Periodic update */
bool nvsd_update_brightness(struct tegra_dc *dc)
{
	u32 val = 0;
	int cur_sd_brightness;
	int sw_sd_brightness;
	struct tegra_dc_sd_settings *settings = dc->out->sd_settings;
	bool nvsd_updated = false;

	if (_sd_brightness) {
		if (atomic_read(&man_k_until_blank) &&
					!settings->phase_in_adjustments) {
			val = tegra_dc_readl(dc, DC_DISP_SD_CONTROL);
			val &= ~SD_CORRECTION_MODE_MAN;
			tegra_dc_writel(dc, val, DC_DISP_SD_CONTROL);
			atomic_set(&man_k_until_blank, 0);
		}

		if (settings->cmd)
			nvsd_cmd_handler(settings, dc);

		/* nvsd_cmd_handler may turn off didim */
		if (!settings->enable)
			return true;

		cur_sd_brightness = atomic_read(_sd_brightness);

		/* read brightness value */
		val = tegra_dc_readl(dc, DC_DISP_SD_BL_CONTROL);
		val = SD_BLC_BRIGHTNESS(val);

		/* PRISM is updated by hw or sw algorithm. Brightness is
		 * compensated according to histogram for soft-clipping
		 * if hw output is used to update brightness. */
		if (settings->phase_in_adjustments) {
			nvsd_updated = nvsd_phase_in_adjustments(dc, settings);
		} else if (settings->soft_clipping_enable &&
			settings->soft_clipping_correction) {
			sw_sd_brightness = nvsd_set_brightness(dc);
			if (sw_sd_brightness != cur_sd_brightness) {
				atomic_set(_sd_brightness, sw_sd_brightness);
				nvsd_updated = true;
			}
		} else if (val != (u32)cur_sd_brightness) {
			/* set brightness value and note the update */
			atomic_set(_sd_brightness, (int)val);
			nvsd_updated = true;
		}

		if (nvsd_updated) {
			smooth_k_frames_left = smooth_k_duration_frames;
			return true;
		}

		if (settings->smooth_k_enable) {
			if (smooth_k_frames_left--)
				return true;
			else
				smooth_k_frames_left = smooth_k_duration_frames;
		}
	}

	/* No update needed. */
	return false;
}