* Copyright (C) 2010 Google, Inc.
* Author: Erik Gilling <konkers@android.com>
*
- * Copyright (c) 2010-2012, 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
#define SD_ENABLE_ONESHOT (2 << 0)
#define SD_USE_VID_LUMA (1 << 2)
#define SD_BIN_WIDTH(x) (((x) & 0x3) << 3)
+#define SD_BIN_WIDTH_VAL(val) (((val) & (0x3 << 3)) >> 3)
#define SD_BIN_WIDTH_ONE (0 << 3)
#define SD_BIN_WIDTH_TWO (1 << 3)
#define SD_BIN_WIDTH_FOUR (2 << 3)
NVSD_ATTR(sd_window);
NVSD_ATTR(soft_clipping_enable);
NVSD_ATTR(soft_clipping_threshold);
+NVSD_ATTR(soft_clipping_correction);
NVSD_ATTR(smooth_k_enable);
NVSD_ATTR(smooth_k_incr);
NVSD_ATTR(use_vpulse2);
NVSD_ATTRS_ENTRY(sd_window),
NVSD_ATTRS_ENTRY(soft_clipping_enable),
NVSD_ATTRS_ENTRY(soft_clipping_threshold),
+ NVSD_ATTRS_ENTRY(soft_clipping_correction),
NVSD_ATTRS_ENTRY(smooth_k_enable),
NVSD_ATTRS_ENTRY(smooth_k_incr),
NVSD_ATTRS_ENTRY(use_vpulse2),
fixed20_12 nonhisto_gain; /* gain of pixels not in histogram */
fixed20_12 est_achieved_gain; /* final gain of pixels */
fixed20_12 histo_gain = dfixed_init(0); /* gain of pixels */
- fixed20_12 k, threshold;
+ fixed20_12 k, threshold; /* k is the fractional part of HW_K */
fixed20_12 den, num, out;
fixed20_12 pix_avg, pix_avg_softclip;
}
val = tegra_dc_readl(dc, DC_DISP_SD_HW_K_VALUES);
- k.full = SD_HW_K_R(val) << 2;
+ k.full = dfixed_const(SD_HW_K_R(val));
+ den.full = dfixed_const(1024);
+ k.full = dfixed_div(k, den);
val = tegra_dc_readl(dc, DC_DISP_SD_SOFT_CLIPPING);
threshold.full = dfixed_const(SD_SOFT_CLIPPING_THRESHOLD(val));
val = tegra_dc_readl(dc, DC_DISP_SD_CONTROL);
- bin_width = SD_BIN_WIDTH(val)>>3;
+ bin_width = SD_BIN_WIDTH_VAL(val);
incr = 1 << bin_width;
base = 256 - 32 * incr;
* if hw output is used to update brightness. */
if (settings->phase_in_adjustments) {
return nvsd_phase_in_adjustments(dc, settings);
- } else if (settings->soft_clipping_correction) {
+ } 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);
else if (IS_NVSD_ATTR(soft_clipping_threshold))
res = snprintf(buf, PAGE_SIZE, "%d\n",
sd_settings->soft_clipping_threshold);
+ else if (IS_NVSD_ATTR(soft_clipping_correction))
+ res = snprintf(buf, PAGE_SIZE, "%d\n",
+ sd_settings->soft_clipping_correction);
else if (IS_NVSD_ATTR(smooth_k_enable))
res = snprintf(buf, PAGE_SIZE, "%d\n",
sd_settings->smooth_k_enable);
nvsd_check_and_update(0, 1, soft_clipping_enable);
} else if (IS_NVSD_ATTR(soft_clipping_threshold)) {
nvsd_check_and_update(0, 255, soft_clipping_threshold);
+ } else if (IS_NVSD_ATTR(soft_clipping_correction)) {
+ nvsd_check_and_update(0, 1, soft_clipping_correction);
} else if (IS_NVSD_ATTR(smooth_k_enable)) {
nvsd_check_and_update(0, 1, smooth_k_enable);
} else if (IS_NVSD_ATTR(smooth_k_incr)) {