diff options
author | Daniel Solomon <daniels@nvidia.com> | 2014-04-17 21:15:01 -0700 |
---|---|---|
committer | Harry Hong <hhong@nvidia.com> | 2014-07-08 01:19:16 -0700 |
commit | 65af72747df736eac26f60d00e27b2d9550f54f4 (patch) | |
tree | 21d1b8ae5022485e7e358c8df756921857c77dbd | |
parent | 23acda5406e6419d6c40c55197e4974204c08354 (diff) |
video: tegra: dc: fix nvsd smooth_k handling
When smooth_k is enabled, the NVSD driver determines
that hardware pixel gain and brightness calculations
are complete when it sees to consecutive and equal
brightness values. However, since multiple raw K
values are mapped to a single brightness value,
this check can be misleading.
To fix this, we continue checking for new brightness
values for a few additional frames after seeing repeating
brightness results. The number of frames is calculated
from smooth_k_incr.
Bug 1502587
Change-Id: I97f2ecd77398cf441ac720b6e306e0a1c89eed5d
Signed-off-by: Daniel Solomon <daniels@nvidia.com>
Reviewed-on: http://git-master/r/423871
(cherry picked from commit ce039a7a6d0f0b3764dc1e719b297fc37e343f45)
Reviewed-on: http://git-master/r/435077
Reviewed-by: Harry Hong <hhong@nvidia.com>
Tested-by: Harry Hong <hhong@nvidia.com>
-rw-r--r-- | drivers/video/tegra/dc/nvsd.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/drivers/video/tegra/dc/nvsd.c b/drivers/video/tegra/dc/nvsd.c index b4b57693ddab..fa86835d522f 100644 --- a/drivers/video/tegra/dc/nvsd.c +++ b/drivers/video/tegra/dc/nvsd.c @@ -1,7 +1,7 @@ /* * drivers/video/tegra/dc/nvsd.c * - * Copyright (c) 2010-2013, NVIDIA CORPORATION, All rights reserved. + * Copyright (c) 2010-2014, NVIDIA CORPORATION, All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -110,6 +110,9 @@ static atomic_t *sd_brightness; /* shared boolean for manual K workaround */ static atomic_t man_k_until_blank = ATOMIC_INIT(0); +static u16 smooth_k_frames_left; +static u16 smooth_k_duration_frames; + static u8 nvsd_get_bw_idx(struct tegra_dc_sd_settings *settings) { u8 bw; @@ -541,10 +544,26 @@ void nvsd_init(struct tegra_dc *dc, struct tegra_dc_sd_settings *settings) } if (settings->smooth_k_enable) { + fixed20_12 smooth_k_incr; + fixed20_12 num; + /* Write K incr value */ val = SD_SMOOTH_K_INCR(settings->smooth_k_incr); tegra_dc_writel(dc, val, DC_DISP_SD_SMOOTH_K); dev_dbg(&dc->ndev->dev, " SMOOTH_K: 0x%08x\n", val); + + /* Convert 8.6 fixed-point to 20.12 fixed-point */ + smooth_k_incr.full = val << 6; + + /* In the BL_TF LUT, raw K is specified in steps of 8 */ + num.full = dfixed_const(8); + + num.full = dfixed_div(num, smooth_k_incr); + num.full = dfixed_ceil(num); + smooth_k_frames_left = dfixed_trunc(num); + smooth_k_duration_frames = smooth_k_frames_left; + dev_dbg(&dc->ndev->dev, " Smooth K duration (frames): %d\n", + smooth_k_frames_left); } #endif @@ -708,6 +727,7 @@ bool nvsd_update_brightness(struct tegra_dc *dc) 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) && @@ -735,19 +755,30 @@ bool nvsd_update_brightness(struct tegra_dc *dc) * compensated according to histogram for soft-clipping * if hw output is used to update brightness. */ if (settings->phase_in_adjustments) { - return nvsd_phase_in_adjustments(dc, settings); + nvsd_updated = nvsd_phase_in_adjustments(dc, settings); } else if (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); - return true; + 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. */ |