#include <linux/amlogic/media/utils/vdec_reg.h>
#include <linux/amlogic/media/vout/lcd/lcd_unifykey.h>
-
#define AML_LDIM_DEV_NAME "aml_ldim"
+
+#ifndef MAX
+#define MAX(a, b) ((a > b) ? a:b)
+#endif
+#ifndef MIN
+#define MIN(a, b) ((a < b) ? a:b)
+#endif
+
+#ifndef ABS
+#define ABS(a) ((a < 0) ? (-a):a)
+#endif
+
+#define FRM_NUM_DBG 5
+
const char ldim_dev_id[] = "ldim-dev";
+unsigned char ldim_debug_print;
struct ldim_dev_s {
struct cdev cdev;
};
static struct ldim_dev_s ldim_dev;
static struct ldim_param_s ldim_db_para;
-static unsigned int LDIM_DATA_FROM_DB;
-static unsigned int print_db_flag;
-static int ldim_on_flag;
-static unsigned int ldim_func_en;
-static unsigned int ldim_remap_en;
-static unsigned int ldim_func_bypass;
-
struct LDReg nPRM;
struct FW_DAT FDat;
+static unsigned int ldim_hist_row = 1;
+static unsigned int ldim_hist_col = 1;
+static unsigned int ldim_blk_row = 1;
+static unsigned int ldim_blk_col = 1;
+static unsigned int ldim_data_min = LD_DATA_MIN;
+static unsigned int ldim_brightness_level;
+
+static unsigned char ldim_on_flag;
+static unsigned char LDIM_DATA_FROM_DB, db_print_flag;
+static unsigned char ldim_func_en, ldim_remap_en;
+static unsigned char ldim_func_bypass; /* for lcd bist pattern */
+static unsigned char ldim_brightness_bypass;
+static unsigned char ldim_level_update;
+static unsigned char ldim_test_en;
+
+static spinlock_t ldim_isr_lock;
+static spinlock_t rdma_ldim_isr_lock;
+
+static struct workqueue_struct *ldim_queue;
+static struct work_struct ldim_on_vs_work;
+static struct work_struct ldim_off_vs_work;
+
+static unsigned int ldim_irq_cnt;
+static unsigned int rdma_ldim_irq_cnt;
+
+/* ************************************************* */
static unsigned long val_1[16] = {512, 512, 512, 512, 546, 546,
585, 630, 745, 819, 910, 1170, 512, 512, 512, 512};
static unsigned long bin_1[16] = {4, 4, 4, 4, 4, 4,
static unsigned long bin_2[16] = {29, 29, 29, 29, 29, 29,
25, 22, 17, 15, 13, 28, 28, 27, 26, 25};
-unsigned int invalid_val_cnt;
-static unsigned int ldim_irq_cnt;
-static unsigned int rdma_ldim_irq_cnt;
-static unsigned int ldim_test_en;
-static unsigned int incr_con_en;
-static unsigned int ov_gain = 16;
-static unsigned int incr_dif_gain = 16;
-
-static spinlock_t ldim_isr_lock;
-static spinlock_t rdma_ldim_isr_lock;
-static struct workqueue_struct *ldim_queue;
-static struct work_struct ldim_on_vs_work;
-static struct work_struct ldim_off_vs_work;
+/* *************** alg parameters ******************* */
+#define LD_FW_ALG_FRM_V0 0 /* gxtvbb, txlx local dimming, 201806 */
+#define LD_FW_ALG_FRM_V1 1 /* txlx local contrast, 2017.10 round */
+#define LD_FW_ALG_FRM_SEL LD_FW_ALG_FRM_V0
-#define FRM_NUM_DBG 5
+#if (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V1)
static unsigned long fw_LD_ThSF_l = 1600;
-static unsigned long fw_LD_ThTF_l = 32;
-static unsigned long lpf_gain = 128; /* [0~128~256], norm 128 as 1*/
-static unsigned long lpf_res = 41; /* 1024/9 = 113*/
-static unsigned long rgb_base = 127;
-static unsigned long boost_gain = 2; /*256;*/
-static unsigned long alpha = 256; /*256;*/
-static unsigned long alpha_delta = 255;/* to fix flicker */
+static unsigned long fw_LD_ThTF_l = 32;/* note*/
+static unsigned long boost_gain = 2;
static unsigned long boost_gain_neg = 3;
-static unsigned long Dbprint_lv;
-static unsigned int db_cnt;
-static unsigned int bl_remap_curve[16] = {
- 436, 479, 551, 651, 780, 938, 1125, 1340,
- 1584, 1856, 2158, 2488, 2847, 3234, 3650, 4095
-};/*BL_matrix remap curve*/
-static unsigned long Sf_bypass, Boost_light_bypass;
-static unsigned long Lpf_bypass, Ld_remap_bypass;
-static unsigned long fw_LD_Whist[16] = {
- 32, 64, 96, 128, 160, 192, 224, 256,
- 288, 320, 352, 384, 416, 448, 480, 512
-};
-
-#define LD_DATA_MIN 10
-static unsigned int ldim_data_min;
-static unsigned int ldim_brightness_level;
-static unsigned long litgain = LD_DATA_DEPTH; /* 0xfff */
-static unsigned long avg_gain = LD_DATA_DEPTH; /* 0xfff */
-
-#ifndef MAX
-#define MAX(a, b) ((a > b) ? a:b)
-#endif
-#ifndef MIN
-#define MIN(a, b) ((a < b) ? a:b)
-#endif
+static unsigned long alpha_delta = 255;/* to fix flicker */
+#define LD_FW_ALG_FRM_VER "V1 - 20180612"
-#ifndef ABS
-#define ABS(a) ((a < 0) ? (-a):a)
-#endif
+#elif (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V0)
+static unsigned long fw_LD_ThSF_l = 1600;
+static unsigned long fw_LD_ThTF_l = 256;
+static unsigned long boost_gain = 456; /*norm 256 to 1,T960 finally use*/
+static unsigned long TF_alpha = 256; /*256;*/
+static unsigned long lpf_gain = 128; /* [0~128~256], norm 128 as 1*/
+#define LD_FW_ALG_FRM_VER "V0 - 20180628"
+#endif /* LD_FW_ALG_FRM_V0 */
-unsigned int ldim_fw_hist_print;/*20180525*/
-module_param(ldim_fw_hist_print, uint, 0664);
-MODULE_PARM_DESC(ldim_fw_hist_print, "ldim_fw_hist_print");
+/*LPF tap: 0-lpf_res 41,1-lpf_res 114,...*/
+static unsigned long lpf_res = 14; /* 1024/9*9 = 13,LPF_method=3 */
+static unsigned long rgb_base = 127;
-unsigned int ldim_fw_TF_sum_th = 32760;/*20180530*/
-module_param(ldim_fw_TF_sum_th, uint, 0664);
-MODULE_PARM_DESC(ldim_fw_TF_sum_th, "ldim_fw_TF_sum_th");
+static unsigned int ov_gain = 16;
+static unsigned int incr_dif_gain = 16;
-static unsigned int ldim_level_update;
-module_param(ldim_level_update, uint, 0664);
-MODULE_PARM_DESC(ldim_level_update, "ldim_level_update");
+static unsigned int LPF_method = 3;
+static unsigned int LD_TF_STEP_TH = 100;
+static unsigned int TF_step_method = 3;
+static unsigned int TF_FRESH_BL = 8;
+
+static unsigned int TF_BLK_FRESH_BL = 5;
+static unsigned int side_blk_diff_th = 100;
+static unsigned int bbd_th = 200;
+static unsigned char bbd_detect_en = 1;
+static unsigned char diff_blk_luma_en = 1;
+
+static unsigned int fw_rgb_diff_th = 32760;
+static unsigned int max_luma = 4060;
+static unsigned int lmh_avg_TH = 200;/*for woman flicker*/
+static unsigned int fw_TF_sum_th = 32760;/*20180530*/
+
+static unsigned long avg_gain = LD_DATA_MAX;
+static unsigned long litgain = LD_DATA_MAX;
+/* *************** alg parameters ******************* */
+
+/*BL_matrix remap curve*/
+static unsigned long bl_remap_curve[16] = {
+ 612, 654, 721, 851, 1001, 1181, 1339, 1516,
+ 1738, 1948, 2152, 2388, 2621, 2889, 3159, 3502
+};
+static unsigned long fw_LD_Whist[16] = {
+ 32, 64, 96, 128, 160, 192, 224, 256,
+ 288, 320, 352, 384, 416, 448, 480, 512
+};
+static unsigned char Sf_bypass, Boost_light_bypass;
+static unsigned char Lpf_bypass, Ld_remap_bypass;
+static unsigned char black_frm;
-unsigned int ldim_debug_print;
-module_param(ldim_debug_print, uint, 0664);
-MODULE_PARM_DESC(ldim_debug_print, "ldim_debug_print");
+static unsigned char fw_hist_print;/*20180525*/
+static unsigned char Debug;/*20180606*/
+static unsigned int db_cnt;
+static unsigned int fw_print_frequent = 8;/*20180606,print every 8 frame*/
+static unsigned int Dbprint_lv;
static unsigned int ldim_hist_en;
module_param(ldim_hist_en, uint, 0664);
MODULE_PARM_DESC(ldim_hist_en, "ldim_hist_en");
-static unsigned int ldim_hist_row = 1;
-module_param(ldim_hist_row, uint, 0664);
-MODULE_PARM_DESC(ldim_hist_row, "ldim_hist_row");
-
-static unsigned int ldim_hist_col = 1;
-module_param(ldim_hist_col, uint, 0664);
-MODULE_PARM_DESC(ldim_hist_col, "ldim_hist_col");
-
-static unsigned int ldim_blk_row = 1;
-module_param(ldim_blk_row, uint, 0664);
-MODULE_PARM_DESC(ldim_blk_row, "ldim_blk_row");
-
-static unsigned int ldim_blk_col = 1;
-module_param(ldim_blk_col, uint, 0664);
-MODULE_PARM_DESC(ldim_blk_col, "ldim_blk_col");
-
static unsigned int ldim_avg_update_en;
module_param(ldim_avg_update_en, uint, 0664);
MODULE_PARM_DESC(ldim_avg_update_en, "ldim_avg_update_en");
static void ldim_off_vs_brightness(void);
static void ldim_on_vs_arithmetic(void);
static void ldim_update_setting(void);
-static void ldim_get_matrix_info_6(void);
+static void ldim_get_matrix_info_max_rgb(void);
static void ldim_bl_remap_curve(int slop_gain);
static void ldim_bl_remap_curve_print(void);
static struct ldim_config_s ldim_config = {
pr_info("bl_remap_curve:\n");
len = 0;
for (i = 0; i < 16; i++)
- len += sprintf(buf+len, "\t%4d\n", bl_remap_curve[i]);
+ len += sprintf(buf+len, "\t%ld\n", bl_remap_curve[i]);
pr_info("%s\n", buf);
kfree(buf);
}
-#if 0
+#if (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V1)
static void ld_fw_alg_frm_txlx(struct LDReg *nPRM1, struct FW_DAT *FDat1,
unsigned int *max_matrix, unsigned int *hist_matrix)
{
int dif, blkRow, blkCol, k, m, n;
unsigned long sum;
int adpt_alp;
- unsigned int avg, Bmin, Bmax, bl_value;
+ unsigned int avg, alpha = 256, Bmin, Bmax, bl_value;
unsigned int Vnum = (nPRM1->reg_LD_BLK_Vnum);
unsigned int Hnum = (nPRM1->reg_LD_BLK_Hnum);
unsigned int *tBL_matrix;
nPRM1->reg_LD_pic_RowMax,
nPRM1->reg_LD_pic_ColMax,
ldim_hist_col);
- if (ldim_fw_hist_print) {
+ if (fw_hist_print) {
for (blkRow = 0; blkRow < Vnum; blkRow++) {
for (blkCol = 0; blkCol < Hnum;
blkCol++) {
= 4095;
if (FDat1->SF_BL_matrix[blkRow*Hnum + blkCol] < 0)
FDat1->SF_BL_matrix[blkRow*Hnum + blkCol]
- = 0; //clip
+ = 0; /*clip*/
}
}
for (blkRow = 0; blkRow < Vnum; blkRow++) {
pr_info("BL_boost_SF [%d * %d] info:\n",
Vnum, Hnum);
pr_info("boost_gain: %ld,%ld:\n"
- "luma_avg = %d, SF_sum= %d, TF_sum = %d\n [\n ",
+ "luma_avg = %d, SF_sum= %d, TF_sum = %d\n\n ",
boost_gain, boost_gain_neg,
avg, SF_sum, TF_sum);
for (blkRow = 0; blkRow < Vnum; blkRow++) {
blkRow*Hnum + blkCol]));
dif_sum = ABS(SF_sum - TF_sum);
- if (dif_sum > ldim_fw_TF_sum_th)
+ if (dif_sum > fw_TF_sum_th)
alpha = 256-alpha_delta;
else
alpha = MIN(256, fw_LD_ThTF);
if (Dbprint_lv == 1) {
if (pr_flag) {
- pr_info("BL_TF(final out)[%d*%d] info(alpha:%ld,): [\n",
+ pr_info("BL_TF(final out)[%d*%d] info(alpha:%d,): [\n",
Vnum, Hnum, alpha);
for (blkRow = 0; blkRow < Vnum; blkRow++) {
for (blkCol = 0; blkCol < Hnum; blkCol++) {
nPRM1->reg_BL_matrix_AVG = 1024;
nPRM1->reg_BL_matrix_Compensate = nPRM1->reg_BL_matrix_AVG;
}
-#endif
+#elif (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V0)
+static unsigned long black_time_cnt; /*black_display statue */
static void ld_fw_alg_frm_gxtvbb(struct LDReg *nPRM1, struct FW_DAT *FDat1,
unsigned int *max_matrix, unsigned int *hist_matrix)
{
/* Notes, nPRM will be set here in SW algorithm too */
- int dif, blkRow, blkCol, k, m, n, i;
+ int dif, blkRow, blkCol, k, m, n, i, tmp;
unsigned long sum;
- unsigned int avg, alpha, Bmin, Bmax;
+ unsigned int avg, alpha = 256, Bmin, Bmax; /*local here*/
unsigned int bl_value, bl_valuex128;
static unsigned int Map_bl_matrix[192];
static unsigned int Tf_bl_matrix_map[192];
+ static unsigned int TF_bl_matrix_t[384]; /*max=16*24*/
static unsigned int Map_bl_matrix_Compensate;
static unsigned int Map_bl_matrix_AVG;
+ /*consistent with ldim hist_row*/
unsigned int Vnum = (nPRM1->reg_LD_BLK_Vnum);
+ /*consistent with ldim hist_col*/
unsigned int Hnum = (nPRM1->reg_LD_BLK_Hnum);
unsigned int *tBL_matrix;
unsigned int BLmax = 4096;
- int stride = ldim_hist_col;
+ int stride = ldim_hist_col;/* inherit from ldim_hist_col */
int RGBmax, Histmx, maxNB, curNB = 0;
unsigned int fw_blk_num = Vnum * Hnum;
unsigned int fw_LD_Thist = ((fw_blk_num * 5) >> 2);
- unsigned int fw_LD_Whist[16] = {32, 64, 96, 128, 160, 192, 224, 256,
- 288, 320, 352, 384, 416, 448, 480, 512};
+ /*consistent with ldim picture size: ldim_pic_row * ldim_pic_col*/
unsigned int fw_pic_size =
(nPRM1->reg_LD_pic_RowMax) * (nPRM1->reg_LD_pic_ColMax);
int fw_LD_ThSF = 1600;
unsigned int fw_LD_ThTF = 32;
- unsigned long Debug = 0;
- unsigned int Tf_luma_avg_frm[FRM_NUM_DBG] = {0, 0, 0, 0, 0};
- unsigned int Tf_blkLuma_avg[FRM_NUM_DBG][16];
- unsigned int Tf_bl_matrix[FRM_NUM_DBG][16];
- unsigned int Tf_diff_frm_luma[FRM_NUM_DBG] = {0, 0, 0, 0, 0};
- unsigned int Tf_diff_blk_luma[FRM_NUM_DBG][16];
+ static unsigned int Tf_luma_avg_frm[FRM_NUM_DBG] = {0, 0, 0, 0, 0};
+ /* note! when Hnum,Vnum changed.
+ * make sure Hnum*Vnum<= 16 or change 16 to other num
+ */
+ static unsigned int Tf_blkLuma_avg[FRM_NUM_DBG][16];
+ static unsigned int Tf_bl_matrix[FRM_NUM_DBG][16];
+ static unsigned int Tf_diff_frm_luma[FRM_NUM_DBG] = {0, 0, 0, 0, 0};
+ static unsigned int Tf_diff_blk_luma[FRM_NUM_DBG][16];
unsigned int fw_LD_BLEst_ACmode = 1;
int num = 0, mm = 0, nn = 0;
unsigned int fw_hist_mx;
int tvalue = 0, min_diff = 0;
int Bmax_lpf = 0;
int frm_rgbmax = 0, black_blk_num = 0;
+ int tdiff = 0, mx_diff = 0;
+
+ /* for debug */
+ unsigned int pr_flag = 0;
+ static unsigned int frm_cnt;
- int SF_avg = 0;
- unsigned int SF_dif = 0;
+ /*patch for fast luma change. */
+ int step = 0;
+ static unsigned int TF_bl_matrix_t2[16]; /*>Vnum*Hnum*/
+ static unsigned int TF_bl_matrix_t3[16]; /*>Vnum*Hnum*/
+ int diff_blk_matrix_tf_avg = 0;
+ int Tf_diff_frm_luma_tf_avg = 0;
+ int side_blk_diff = 0;
fw_LD_ThSF = fw_LD_ThSF_l;
fw_LD_ThTF = fw_LD_ThTF_l;
- diff_frm_luma = 0;
- diff_blk_luma = 0;
- diff_blk_matrix = 0;
- remap_value = 0;
+
tBL_matrix = FDat1->TF_BL_matrix_2;
- /* Luma_avg transmit */
+
+ /* first 8 frame & every 8(fw_print_frequent) frames print once*/
+ pr_flag = (frm_cnt < 8) || (frm_cnt % fw_print_frequent == 0);
+
+ if ((Dbprint_lv == 1) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("input: Vnum = [%4d],Hnum = [%4d],\n"
+ "RowMax=[%4d],ColMax=[%4d],ldim_hist_col=[%4d]\n",
+ Vnum, Hnum,
+ nPRM1->reg_LD_pic_RowMax,
+ nPRM1->reg_LD_pic_ColMax,
+ ldim_hist_col);
+ if (fw_hist_print) {
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum;
+ blkCol++) {
+ pr_info("(%d,%d,%d)\n ",
+ max_matrix[blkRow*3*stride +
+ blkCol*3 + 0],
+ max_matrix[blkRow*3*stride +
+ blkCol*3 + 1],
+ max_matrix[blkRow*3*stride +
+ blkCol*3 + 2]);
+ }
+ pr_info(";\n");
+ }
+ pr_info("];\n");
+ }
+ }
+ }
+
+ /* store 5 frames Luma_avg */
for (i = 0; i < (FRM_NUM_DBG - 1); i++) {
for (blkRow = 0; blkRow < Vnum; blkRow++) {
for (blkCol = 0; blkCol < Hnum; blkCol++) {
- Tf_blkLuma_avg[i][blkRow * Hnum + blkCol] =
- Tf_blkLuma_avg[i+1][blkRow * Hnum + blkCol];
- Tf_bl_matrix[i][blkRow * Hnum + blkCol] =
- Tf_bl_matrix[i+1][blkRow * Hnum + blkCol];
- Tf_diff_blk_luma[i][blkRow * Hnum + blkCol] =
- Tf_diff_blk_luma[i+1][blkRow * Hnum + blkCol];
+ tmp = blkRow * Hnum + blkCol;
+ Tf_blkLuma_avg[i][tmp] =
+ Tf_blkLuma_avg[i+1][tmp];
+ Tf_bl_matrix[i][tmp] =
+ Tf_bl_matrix[i+1][tmp];
+ Tf_diff_blk_luma[i][tmp] =
+ Tf_diff_blk_luma[i+1][tmp];
}
}
Tf_luma_avg_frm[i] = Tf_luma_avg_frm[i+1];
Tf_diff_frm_luma[i] = Tf_diff_frm_luma[i+1];
}
+ if ((Dbprint_lv == 2) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step-pre:5 frames info:\n ");
+ for (i = 0; i < FRM_NUM_DBG; i++) {
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum;
+ blkCol++) {
+ tmp = blkRow * Hnum + blkCol;
+ pr_info("Tf_blkLuma_avg[%d][%4d],Tf_bl_matrix[%d][%4d],Tf_diff_blk_luma[%d][%4d]\n",
+ i,
+ Tf_blkLuma_avg[i][tmp],
+ i,
+ Tf_bl_matrix[i][tmp],
+ i,
+ Tf_diff_blk_luma[i][tmp]);
+ }
+ pr_info(" ;\n ");
+ }
+ pr_info("];\n ");
+ }
+ }
+ }
+
frm_rgbmax = 0; black_blk_num = 0;
for (blkRow = 0; blkRow < Vnum; blkRow++) {
for (blkCol = 0; blkCol < Hnum; blkCol++) {
sum = 0; Luma_avg = 0;
for (blkRow = 0; blkRow < Vnum; blkRow++) {
for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ tmp = blkRow * Hnum + blkCol;
RGBmax = MAX(MAX(max_matrix[blkRow * 3 * stride +
blkCol * 3], max_matrix[blkRow * 3 * stride +
blkCol * 3 + 1]), max_matrix[blkRow * 3 *
if (RGBmax < rgb_base)
RGBmax = rgb_base;
}
- /* Consider the sitrogram */
+ /* Consider the histogram */
Histmx = 0;
blkLuma_avg = 0;
blk_sum = 0;
LD_STA_BIN_NUM * stride + blkCol *
LD_STA_BIN_NUM + k] * k * 32;
}
- Tf_blkLuma_avg[FRM_NUM_DBG - 1][blkRow * Hnum +
- blkCol] = ((blkLuma_avg + (blk_sum >> 1)) /
+ Tf_blkLuma_avg[FRM_NUM_DBG - 1][tmp] =
+ ((blkLuma_avg + (blk_sum >> 1)) /
(blk_sum + 1));
- Luma_avg += Tf_blkLuma_avg[FRM_NUM_DBG - 1][
- blkRow * Hnum + blkCol];
+ Luma_avg += Tf_blkLuma_avg[FRM_NUM_DBG - 1][tmp];
fw_hist_mx = ((Histmx >> 8) * fw_LD_Thist * 2 /
(fw_pic_size >> 8));
/* further debug */
- tBL_matrix[blkRow * Hnum + blkCol] =
+ tBL_matrix[tmp] =
((BLmax * MIN(fw_hist_mx, RGBmax)) >> 10);
}
}
+ if ((Dbprint_lv == 3) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step-0: BL_0[%d * %d]:\n ", Vnum, Hnum);
+ pr_info(
+ " LD_STA_BIN_NUM=%d, rgb_base=%ld, frm_rgbmax=%d [\n ",
+ LD_STA_BIN_NUM,
+ rgb_base,
+ frm_rgbmax);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ tBL_matrix[blkRow*Hnum + blkCol]);
+ }
+ pr_info(" ;\n ");
+ }
+ pr_info("];\n ");
+ }
+ }
+
/*To solve black/white woman flicker*/
- lmh_avg = (Luma_avg / (Vnum * Hnum));
+ lmh_avg = (Luma_avg / (Vnum * Hnum));
Tf_luma_avg_frm[FRM_NUM_DBG - 1] = lmh_avg;
/* Spatial Filter the BackLits */
sum = 0;
for (blkRow = 0; blkRow < Vnum; blkRow++) {
for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ tmp = blkRow * Hnum + blkCol;
maxNB = 0;
for (m = -1; m < 2; m++) {
for (n = -1; n < 2; n++) {
if ((m == 0) && (n == 0)) {
- curNB =
- tBL_matrix[blkRow * Hnum + blkCol];
+ curNB = tBL_matrix[tmp];
} else if (((blkRow + m) >= 0) &&
((blkRow + m) < Vnum) &&
((blkCol + n) >= 0) &&
((blkCol+n) < Hnum)) {
- maxNB = MAX(maxNB, tBL_matrix[(
- blkRow + m) * Hnum
+ maxNB = MAX(maxNB,
+ tBL_matrix[(blkRow + m) * Hnum
+ blkCol + n]);
}
}
}
/* SF matrix */
if (Sf_bypass == 1) {
- FDat1->SF_BL_matrix[blkRow * Hnum + blkCol] =
- tBL_matrix[blkRow * Hnum + blkCol];
+ FDat1->SF_BL_matrix[tmp] = tBL_matrix[tmp];
} else {
- FDat1->SF_BL_matrix[blkRow * Hnum + blkCol] =
- MAX(curNB, (maxNB - fw_LD_ThSF));
+ FDat1->SF_BL_matrix[tmp] =
+ MAX(curNB, (maxNB - fw_LD_ThSF));
}
- sum += FDat1->SF_BL_matrix[blkRow * Hnum + blkCol];
+ sum += FDat1->SF_BL_matrix[tmp];
/* for SF_BL_matrix average calculation */
}
}
+ if ((Dbprint_lv == 4) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step-1: BL_SF:\n ");
+ pr_info("Sf_bypass=%d, fw_LD_ThSF=%d, sum=%ld [\n ",
+ Sf_bypass,
+ fw_LD_ThSF,
+ sum);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ FDat1->SF_BL_matrix[
+ blkRow * Hnum + blkCol]);
+ }
+ pr_info(" ;\n ");
+ }
+ pr_info("];\n ");
+ }
+ }
+
+ /*side black bar detect*/
+ avg = sum / fw_blk_num;
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ tmp = blkRow * Hnum + blkCol;
+ dif = avg - (FDat1->SF_BL_matrix[tmp]);
+ dif = ABS(dif);
+
+ if ((blkCol == 0) &&
+ (dif > bbd_th) &&
+ bbd_detect_en) {
+ /*1-0*/
+ side_blk_diff =
+ FDat1->SF_BL_matrix[tmp + 1] -
+ FDat1->SF_BL_matrix[tmp];
+ if (side_blk_diff > side_blk_diff_th) {
+ FDat1->SF_BL_matrix[tmp] =
+ FDat1->SF_BL_matrix[tmp + 1] -
+ side_blk_diff_th; /*8-9*/
+ }
+ }
+ if ((blkCol == (Hnum - 1)) &&
+ (dif > bbd_th) &&
+ bbd_detect_en) {
+ side_blk_diff = FDat1->SF_BL_matrix[tmp - 1] -
+ FDat1->SF_BL_matrix[tmp];
+ if (side_blk_diff > side_blk_diff_th) {
+ FDat1->SF_BL_matrix[tmp] =
+ FDat1->SF_BL_matrix[tmp - 1] -
+ side_blk_diff_th;
+ }
+ }
+ }
+ }
+
+ if ((Dbprint_lv == 13) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step-2.5: BL_SF_bbd:\n ");
+ pr_info(
+ " bbd_detect_en=%d, bbd_th=%d, side_blk_diff=%d,avg=%d\n ",
+ bbd_detect_en,
+ bbd_th,
+ side_blk_diff,
+ avg);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ FDat1->SF_BL_matrix[
+ blkRow * Hnum + blkCol]);
+ }
+ pr_info(";\n ");
+ }
+ pr_info(" ];\n ");
+ }
+ }
+
/* boost the bright region lights a little bit. */
avg = ((sum * 7 / fw_blk_num) >> 3);
for (blkRow = 0; blkRow < Vnum; blkRow++) {
for (blkCol = 0; blkCol < Hnum; blkCol++) {
- dif = (FDat1->SF_BL_matrix[blkRow * Hnum + blkCol]
- - avg);
+ tmp = blkRow * Hnum + blkCol;
+ dif = (FDat1->SF_BL_matrix[tmp] - avg);
- FDat1->SF_BL_matrix[blkRow * Hnum + blkCol] += 0;
+ FDat1->SF_BL_matrix[tmp] += 0;
if (Boost_light_bypass == 0) {
- FDat1->SF_BL_matrix[blkRow * Hnum + blkCol] =
- (FDat1->SF_BL_matrix[blkRow * Hnum +
- blkCol] * boost_gain + 64) >> 7;
+ FDat1->SF_BL_matrix[tmp] =
+ (FDat1->SF_BL_matrix[tmp] *
+ boost_gain + 64) >> 7;
}
- if (FDat1->SF_BL_matrix[blkRow * Hnum + blkCol] > 4095)
- FDat1->SF_BL_matrix[blkRow * Hnum + blkCol]
- = 4095;
+ if (FDat1->SF_BL_matrix[tmp] > 4095)
+ FDat1->SF_BL_matrix[tmp] = 4095;
+ }
+ }
+
+ if ((Dbprint_lv == 5) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step-2: BL_SF_boost:\n ");
+ pr_info(
+ " Boost_light_bypass=%d, boost_gain=%ld, avg=%d [\n ",
+ Boost_light_bypass,
+ boost_gain,
+ avg);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ FDat1->SF_BL_matrix[
+ blkRow * Hnum + blkCol]);
+ }
+ pr_info(";\n ");
+ }
+ pr_info(" ];\n ");
}
}
}
}
- SF_avg = SF_sum / fw_blk_num;
- for (blkRow = 0; blkRow < Vnum; blkRow++) {
- for (blkCol = 0; blkCol < Hnum; blkCol++) {
- if (Debug == 1) {
- SF_dif = FDat1->SF_BL_matrix[blkRow * Hnum
- + blkCol] - SF_avg;
- if (FDat1->SF_BL_matrix[blkRow * Hnum
- + blkCol] <= SF_avg) {
- FDat1->SF_BL_matrix[blkRow * Hnum +
- blkCol] = ((SF_avg + 64) >> 7);
- } else {
- /* need optimize */
- FDat1->SF_BL_matrix[blkRow * Hnum +
- blkCol] = ((SF_avg + 64) >> 7)
- + SF_dif;
- }
- if (FDat1->SF_BL_matrix[
- blkRow * Hnum + blkCol] >
- 4095) {
- FDat1->SF_BL_matrix[blkRow * Hnum +
- blkCol] = 4095;
- }
- }
- }
- }
-
/* LPF Only for Xiaomi 8 Led ,here Vnum = 1;*/
Bmin = 4096; Bmax_lpf = 0;
for (blkRow = 0; blkRow < Vnum; blkRow++) {
for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ tmp = blkRow * Hnum + blkCol;
sum = 0;
- for (m = -2; m < 3; m++) {
- for (n = -2; n < 3; n++) {
- /* be careful here */
- mm = MIN(MAX(blkRow + m, 0),
- Vnum-1);
- nn = MIN(MAX(blkCol + n, 0),
- Hnum-1);
- num = MIN(MAX((mm * Hnum + nn),
- 0), (Vnum * Hnum - 1));
- sum += FDat1->SF_BL_matrix[num];
+ if (LPF_method == 0) {/* 5*5 lpf_res=1024/25=41 */
+ for (m = -2; m < 3; m++) {
+ for (n = -2; n < 3; n++) {
+ /* be careful here */
+ mm = MIN(MAX(blkRow + m, 0),
+ Vnum-1);
+ nn = MIN(MAX(blkCol + n, 0),
+ Hnum-1);
+ num = MIN(MAX((mm * Hnum + nn),
+ 0), (Vnum * Hnum - 1));
+ sum += FDat1->SF_BL_matrix[num];
+ }
+ }
+ } else if (LPF_method == 1) {/*3*3,lpf_res=1024/9=114*/
+ for (m = -1; m < 2; m++) {
+ for (n = -1; n < 2; n++) {
+ /* be careful here */
+ mm = MIN(MAX(blkRow + m, 0),
+ Vnum-1);
+ nn = MIN(MAX(blkCol + n, 0),
+ Hnum-1);
+ num = MIN(MAX((mm * Hnum + nn),
+ 0),
+ (Vnum * Hnum - 1));
+ sum += FDat1->SF_BL_matrix[num];
+ }
+ }
+ } else if (LPF_method == 2) {/*7*7,lpf_res=1024/49=21*/
+ for (m = -3; m < 4; m++) {
+ for (n = -3; n < 4; n++) {
+ /* be careful here */
+ mm = MIN(MAX(blkRow + m, 0),
+ Vnum-1);
+ nn = MIN(MAX(blkCol + n, 0),
+ Hnum-1);
+ num = MIN(MAX((mm * Hnum + nn),
+ 0),
+ (Vnum * Hnum - 1));
+ sum += FDat1->SF_BL_matrix[num];
+ }
+ }
+ } else if (LPF_method == 3) {/*9*9,lpf_res=1024/81=13*/
+ for (m = -4; m < 5; m++) {
+ for (n = -4; n < 5; n++) {
+ /* be careful here */
+ mm = MIN(MAX(blkRow + m, 0),
+ Vnum-1);
+ nn = MIN(MAX(blkCol + n, 0),
+ Hnum-1);
+ num = MIN(MAX((mm * Hnum + nn),
+ 0),
+ (Vnum * Hnum - 1));
+ sum += FDat1->SF_BL_matrix[num];
+ }
}
}
- if (Lpf_bypass == 1) {
- FDat1->SF_BL_matrix[blkRow * Hnum +
- blkCol] = FDat1->SF_BL_matrix[
- blkRow * Hnum + blkCol];
- } else {
- FDat1->SF_BL_matrix[blkRow * Hnum +
- blkCol] = (((sum * lpf_res
- >> 10) * lpf_gain) >> 7);
+
+ if (Lpf_bypass == 0) {
+ FDat1->SF_BL_matrix[tmp] =
+ (((sum * lpf_res >> 10) * lpf_gain) >> 7);
}
- tvalue =
- FDat1->SF_BL_matrix[blkRow * Hnum + blkCol];
+ /*check if sum overflow*/
+ if (Dbprint_lv == 6)
+ pr_info("step 3.1: sum=%ld:\n ", sum);
+ tvalue = FDat1->SF_BL_matrix[tmp];
tvalue = (tvalue * ov_gain + 16) >> 4;
- min_diff = tvalue -
- FDat1->SF_BL_matrix[blkRow * Hnum + blkCol];
+ min_diff = tvalue - FDat1->SF_BL_matrix[tmp];
Bmin = MIN(Bmin, min_diff);
Bmax_lpf = MAX(Bmax_lpf,
- Tf_bl_matrix[FRM_NUM_DBG-2]
- [blkRow * Hnum + blkCol]);
+ Tf_bl_matrix[FRM_NUM_DBG-2][tmp]);
+
+ if (FDat1->SF_BL_matrix[tmp] > 4095)
+ FDat1->SF_BL_matrix[tmp] = 4095;
+ }
+ }
- if (FDat1->SF_BL_matrix[blkRow * Hnum + blkCol]
- > 4095) {
- FDat1->SF_BL_matrix[blkRow * Hnum +
- blkCol] = 4095;
+ if ((Dbprint_lv == 6) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step 3.1: BL_SF_lpf:\n ");
+ pr_info(" LPF_method=%d, Lpf_bypass=%d, lpf_res=%ld, lpf_gain=%ld\n",
+ LPF_method,
+ Lpf_bypass,
+ lpf_res,
+ lpf_gain);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ FDat1->SF_BL_matrix[
+ blkRow * Hnum + blkCol]);
+ }
+ pr_info(";\n ");
}
+ pr_info("];\n ");
+ pr_info("Bmax_lpf=%d, Bmin=%d\n ", Bmax_lpf, Bmin);
}
}
- if (incr_con_en == 1) {
+
+ /*hivicast00082*/
+ if (lmh_avg > lmh_avg_TH) {
for (blkRow = 0; blkRow < Vnum; blkRow++) {
for (blkCol = 0; blkCol < Hnum; blkCol++) {
- tvalue = FDat1->SF_BL_matrix[blkRow * Hnum +
- blkCol];
- tvalue = (tvalue * ov_gain + 16) >> 4;
- tvalue = tvalue - ((Bmin * incr_dif_gain +
- 8) >> 4);
- /* incr_dif_gain [1~16]*/
- FDat1->SF_BL_matrix[blkRow * Hnum + blkCol]
- = tvalue;
- if (FDat1->SF_BL_matrix[blkRow * Hnum +
- blkCol] > 4095)
- FDat1->SF_BL_matrix[blkRow * Hnum +
- blkCol] = 4095;
+ tmp = blkRow * Hnum + blkCol;
+ tdiff = max_luma - FDat1->SF_BL_matrix[tmp];
+ mx_diff = MAX(tdiff, 0);
+
+ FDat1->SF_BL_matrix[tmp] =
+ FDat1->SF_BL_matrix[tmp] +
+ ((mx_diff + 1) >> 1);
}
}
}
+ if ((Dbprint_lv == 7) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step-3.2:BL_SF(hivicast00082:\n ");
+ pr_info(" max_luma=%d, mx_diff=%d,lmh_avg_TH=%d\n ",
+ max_luma,
+ mx_diff,
+ lmh_avg_TH);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ FDat1->SF_BL_matrix[
+ blkRow * Hnum + blkCol]);
+ }
+ pr_info(";\n ");
+ }
+ pr_info("];\n ");
+ }
+ }
/* Temperary filter */
sum = 0; Bmin = 4096; Bmax = 0;
for (blkRow = 0; blkRow < Vnum; blkRow++) {
for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ tmp = blkRow * Hnum + blkCol;
/* Optimization needed here */
dif_r = FDat1->last_STA1_MaxRGB[blkRow * 3 * stride
+ blkCol * 3] - max_matrix[blkRow * 3 * stride
+ blkCol * 3 + 2] - max_matrix[blkRow * 3
* stride + blkCol * 3 + 2];
dif_b = ABS(dif_b);
- adpt_alp = (FDat1->SF_BL_matrix[blkRow * Hnum
- + blkCol]) - (FDat1->TF_BL_matrix[blkRow
- * Hnum + blkCol]);
+ adpt_alp = (FDat1->SF_BL_matrix[tmp]) -
+ (FDat1->TF_BL_matrix[tmp]);
adpt_alp = ABS(adpt_alp);
dif_sum = SF_sum - TF_sum;
dif_sum = ABS(dif_sum);
- if (dif_sum > 32760)
- alpha = 256;
+ /*note: T968&T960 only use current BL_matrix:
+ *TF_alpha =256,fw_LD_ThTF=256
+ *20180612
+ */
+ /*note: manual set TF_alpha no useful anymore*/
+ TF_alpha = 1 << TF_FRESH_BL;
+ if (dif_sum > fw_rgb_diff_th) /* 32760 */
+ alpha = TF_alpha; /* 256 */
else
- alpha = MIN(256, fw_LD_ThTF);
+ alpha = MIN(TF_alpha, fw_LD_ThTF);
bl_valuex128 = 0;
- FDat1->TF_BL_alpha[blkRow * Hnum + blkCol] = alpha;
+ FDat1->TF_BL_alpha[tmp] = alpha;
- /* get the temporary filtered BL_value */
- bl_value = (((256 - alpha) * (FDat1->TF_BL_matrix[
- blkRow * Hnum + blkCol]) + alpha
- * (FDat1->SF_BL_matrix[blkRow * Hnum
- + blkCol]) + 128) >> 8);
+ /*4.1: TF: get the temporary filtered BL_value */
+ bl_value = (((TF_alpha - alpha) *
+ (FDat1->TF_BL_matrix[tmp]) +
+ alpha * (FDat1->SF_BL_matrix[tmp]) +
+ (TF_alpha >> 1)) >> TF_FRESH_BL);
+ /*2^8 = TF_alpha*/
if (bl_value > 4095)
bl_value = 4095;
+ /* for debug */
+ TF_bl_matrix_t[tmp] = bl_value;
- /*ld_curve map*/
+ /*4.2: remap: ld_curve map*/
int_x = bl_value >> 8;
rmd_x = bl_value % 256;
norm = 256;
bl_value_map = (bl_value_map > 4095) ? 4095 :
bl_value_map;
- Tf_bl_matrix_map[blkRow * Hnum + blkCol] = bl_value_map;
+ Tf_bl_matrix_map[tmp] = bl_value_map;
+ /*4.3 tiir optimize */
diff_frm_luma = Tf_luma_avg_frm[FRM_NUM_DBG - 1] -
Tf_luma_avg_frm[FRM_NUM_DBG - 2];
diff_frm_luma = ABS(diff_frm_luma);
Tf_diff_frm_luma[FRM_NUM_DBG - 1] = diff_frm_luma;
if (Tf_luma_avg_frm[FRM_NUM_DBG - 1] <= 1) {
- Tf_bl_matrix[FRM_NUM_DBG - 2][blkRow*Hnum +
- blkCol] = Bmax_lpf>>1;
+ /* Tf_bl_matrix[FRM_NUM_DBG - 2][tmp] =
+ * Bmax_lpf>>1;
+ */
+ Tf_bl_matrix[FRM_NUM_DBG - 2][tmp] =
+ Tf_bl_matrix[FRM_NUM_DBG - 2][tmp];
+ /* do nothing. need to optimise */
}
if (diff_frm_luma < 10) {/*same video scene*/
- diff_blk_luma = Tf_blkLuma_avg[FRM_NUM_DBG
- - 1][blkRow * Hnum + blkCol] -
- Tf_blkLuma_avg[FRM_NUM_DBG - 2][blkRow
- * Hnum + blkCol];
+ diff_blk_luma =
+ Tf_blkLuma_avg[FRM_NUM_DBG - 1][tmp] -
+ Tf_blkLuma_avg[FRM_NUM_DBG - 2][tmp];
diff_blk_matrix = bl_value_map -
- Tf_bl_matrix[FRM_NUM_DBG-2][blkRow
- * Hnum + blkCol];
+ Tf_bl_matrix[FRM_NUM_DBG-2][tmp];
diff_blk_matrix = ABS(diff_blk_matrix);
- Tf_diff_blk_luma[FRM_NUM_DBG - 1][blkRow
- * Hnum + blkCol] = diff_blk_matrix;
+ Tf_diff_blk_luma[FRM_NUM_DBG - 1][tmp] =
+ diff_blk_matrix;
/*Debug print local value*/
- if (Dbprint_lv == 1) {
+ if (Dbprint_lv == 200) {
if ((db_cnt % 4) == 0) {
/*4 frames print once*/
pr_info(
- "diff_blk_matrix[%4d]\n"
- "bl_value_map[%4d]\n"
- "Tf_bl_matrix[%4d]\n"
- "frm_luma[%4d]\n\n",
- diff_blk_matrix,
- bl_value_map,
- Tf_bl_matrix[
- FRM_NUM_DBG - 2]
- [blkRow * Hnum +
- blkCol],
- Tf_luma_avg_frm[
- FRM_NUM_DBG -
- 1]);
+ "##4.3_tiir-1: diff_frm_luma <10\n"
+ "diff_blk_matrix[%4d]\n"
+ "bl_value_map[%4d]\n"
+ "Tf_bl_matrix[%4d]\n",
+ diff_blk_matrix,
+ bl_value_map,
+ Tf_bl_matrix[FRM_NUM_DBG - 2]
+ [tmp]);
}
}
- if ((diff_blk_matrix > 50)) {
- if (bl_value_map >= Tf_bl_matrix[
- FRM_NUM_DBG-2][
- blkRow*Hnum + blkCol]) {
- bl_value_map = Tf_bl_matrix[
- FRM_NUM_DBG-2][
- blkRow*Hnum + blkCol] +
- ((diff_blk_matrix +
- 16) >> 5);
- } else {
- bl_value_map = Tf_bl_matrix[
- FRM_NUM_DBG-2][
- blkRow*Hnum + blkCol] -
- ((diff_blk_matrix +
- 16) >> 5);
+ if ((diff_blk_matrix > 50) &&
+ (diff_blk_luma_en)) {
+ if (bl_value_map >=
+ Tf_bl_matrix[FRM_NUM_DBG-2][tmp]) {
+ bl_value_map =
+ Tf_bl_matrix[FRM_NUM_DBG-2]
+ [tmp] +
+ ((diff_blk_matrix + 16) >> 5);
+ } else { /* any difference ? */
+ bl_value_map =
+ Tf_bl_matrix[FRM_NUM_DBG-2]
+ [tmp] -
+ ((diff_blk_matrix + 16) >> 5);
+ }
+ if (Dbprint_lv == 2) {
+ /* just for confirm */
+ pr_info("##--2: diff_blk_matrix >50\n");
+ }
+
+ if ((Dbprint_lv == 200) &&
+ ((db_cnt % 4) == 0)) {
+ /*4 frames print once*/
+ pr_info(
+ "##4.3_tiir-2: diff_blk_matrix > 50\n"
+ "bl_value_map= [%4d]\n"
+ "blkRow * Hnum + blkCol = %d(cnt)\n"
+ "Tf_bl_matrix[FRM_NUM_DBG-1][cnt])= [%4d]\n"
+ "Tf_bl_matrix[FRM_NUM_DBG-2][cnt])= [%4d]\n"
+ "Tf_bl_matrix[FRM_NUM_DBG-3][cnt])= [%4d]\n"
+ "Tf_bl_matrix[FRM_NUM_DBG-4][cnt])= [%4d]\n"
+ "Tf_bl_matrix[FRM_NUM_DBG-5][cnt])= [%4d]\n",
+ bl_value_map,
+ tmp,
+ Tf_bl_matrix[FRM_NUM_DBG - 1]
+ [tmp],
+ Tf_bl_matrix[FRM_NUM_DBG - 2]
+ [tmp],
+ Tf_bl_matrix[FRM_NUM_DBG - 3]
+ [tmp],
+ Tf_bl_matrix[FRM_NUM_DBG - 4]
+ [tmp],
+ Tf_bl_matrix[FRM_NUM_DBG - 5]
+ [tmp]);
}
} else
bl_value_map = bl_value_map;
bl_value_map = 0;
}
- /*Debug print local value*/
- if (Dbprint_lv == 1) {
- if ((db_cnt%4) == 0) { /*4 frames print once*/
- pr_info("Aftert bl_value_map[%4d]\n",
- bl_value_map);
- }
+ /* for debug */
+ TF_bl_matrix_t3[tmp] = bl_value_map;
+
+ /*4.4 patch for fast luma change.20180621*/
+ diff_frm_luma = Tf_luma_avg_frm[FRM_NUM_DBG - 1] -
+ Tf_luma_avg_frm[FRM_NUM_DBG - 2];/*0~512*/
+ /*current*/
+ Tf_diff_frm_luma[FRM_NUM_DBG - 1] = diff_frm_luma;
+ Tf_diff_frm_luma_tf_avg =
+ (Tf_diff_frm_luma[FRM_NUM_DBG - 1] +
+ Tf_diff_frm_luma[FRM_NUM_DBG - 2] +
+ Tf_diff_frm_luma[FRM_NUM_DBG - 3] +
+ Tf_diff_frm_luma[FRM_NUM_DBG - 4]) * 2;
+ /*(/4*8,12bit)4 frames avg. note: FRM_NUM_DBG >=4*/
+
+ diff_blk_matrix = bl_value_map -
+ Tf_bl_matrix[FRM_NUM_DBG-2][tmp];
+ diff_blk_matrix_tf_avg =
+ (Tf_diff_blk_luma[FRM_NUM_DBG - 2][tmp] +
+ Tf_diff_blk_luma[FRM_NUM_DBG - 3][tmp] +
+ Tf_diff_blk_luma[FRM_NUM_DBG - 4][tmp] +
+ Tf_diff_blk_luma[FRM_NUM_DBG - 5][tmp]) >> 2;
+ /*make sure FRM_NUM_DBG > 5 */
+
+ if ((dif_sum < fw_rgb_diff_th) &&
+ (ABS(diff_frm_luma*8) > LD_TF_STEP_TH)) {
+
+ if (TF_step_method == 1) {
+ step = diff_frm_luma * 8;/*12bit*/
+ /* dark --> bright, limit increase step,u12*/
+ if (step > LD_TF_STEP_TH)
+ step = LD_TF_STEP_TH;/*12bit*/
+ /*bright --> dark, limit decrease step,u12*/
+ else if (step < (-LD_TF_STEP_TH))
+ step = -(LD_TF_STEP_TH);
+ bl_value_map =
+ (FDat1->TF_BL_matrix[tmp]) + step;
+ } else if (TF_step_method == 2) {
+ step =
+ (Tf_diff_frm_luma[FRM_NUM_DBG - 1] +
+ Tf_diff_frm_luma[FRM_NUM_DBG - 2] +
+ Tf_diff_frm_luma[FRM_NUM_DBG - 3] +
+ Tf_diff_frm_luma[FRM_NUM_DBG - 4]) * 2;
+ /*(/4*8,12bit)4 frames avg. note: FRM_NUM_DBG >=4*/
+
+ /* dark --> bright, limit increase step,u12*/
+ if (step > LD_TF_STEP_TH)
+ step = LD_TF_STEP_TH ;/*12bit*/
+ /*bright --> dark, limit decrease step,u12*/
+ else if (step < (-LD_TF_STEP_TH))
+ step = -(LD_TF_STEP_TH);
+
+ bl_value_map =
+ (FDat1->TF_BL_matrix[tmp]) + step;
+ } else if (TF_step_method == 3) {
+ diff_blk_matrix = bl_value_map -
+ Tf_bl_matrix[FRM_NUM_DBG-2][tmp];
+
+ if (diff_blk_matrix > 0) {
+ bl_value_map =
+ Tf_bl_matrix[FRM_NUM_DBG-2][tmp]
+ + ((diff_blk_matrix +
+ (1 << (TF_BLK_FRESH_BL-1))) >>
+ TF_BLK_FRESH_BL);
+ } else {
+ bl_value_map =
+ Tf_bl_matrix[FRM_NUM_DBG-2][tmp]
+ - ((ABS(diff_blk_matrix) +
+ (1 << (TF_BLK_FRESH_BL-1))) >>
+ TF_BLK_FRESH_BL);
+ }
+ } else
+ bl_value_map = bl_value_map;
}
+ if (Dbprint_lv == 100 && pr_flag) {
+ pr_info("new TF filter:row[%d],col[%d]:dif_sum=%d(th(%d))\n",
+ blkRow, blkCol, dif_sum,
+ fw_rgb_diff_th);
+ pr_info("diff_frm_luma:%4d,step:%4d, LD_TF_STEP_TH:%4d (pre_bl[%4d] => bl[%4d])\n\n",
+ diff_frm_luma,
+ step, LD_TF_STEP_TH,
+ (FDat1->TF_BL_matrix[tmp]),
+ bl_value_map);
+ }
+
+ if (Dbprint_lv == 100 && pr_flag &&
+ (TF_step_method == 3)) {
+ pr_info("new TF filter:row[%d],col[%d]:dif_sum=%d(th(%d))\n",
+ blkRow, blkCol, dif_sum,
+ fw_rgb_diff_th);
+ pr_info("diff_frm_luma:%4d,diff_blk_matrix:%4d, TF_BLK_FRESH_BL:%4d (pre_bl[%4d] => bl[%4d])\n\n",
+ diff_frm_luma,
+ diff_blk_matrix, TF_BLK_FRESH_BL,
+ Tf_bl_matrix[FRM_NUM_DBG-2][tmp],
+ bl_value_map);
+ }
+
+ /* debug */
+ TF_bl_matrix_t2[tmp] = bl_value_map;
+
remap_value = bl_value_map;
if (remap_value > 4095)
remap_value = 4095;
if (nPRM1->reg_LD_BackLit_mode == 1) {
- nPRM1->BL_matrix[blkCol * Vnum + blkRow] =
- bl_value_map;
- Map_bl_matrix[blkCol * Vnum + blkRow] = remap_value;
+ nPRM1->BL_matrix[blkCol * Vnum + blkRow] =
+ bl_value_map;
+ Map_bl_matrix[blkCol * Vnum + blkRow] =
+ remap_value;
} else {
- nPRM1->BL_matrix[blkRow * Hnum + blkCol] =
- bl_value_map;
- Map_bl_matrix[blkRow * Hnum + blkCol] = remap_value;
+ nPRM1->BL_matrix[tmp] = bl_value_map;
+ Map_bl_matrix[tmp] = remap_value;
}
/* Get the TF_BL_matrix */
- FDat1->TF_BL_matrix[blkRow * Hnum + blkCol]
- = bl_value_map;
- Tf_bl_matrix[FRM_NUM_DBG-1][blkRow * Hnum + blkCol]
- = bl_value_map;
+ FDat1->TF_BL_matrix[tmp] = bl_value_map;
+ Tf_bl_matrix[FRM_NUM_DBG-1][tmp] = bl_value_map;
/* leave the Delayed version for next frame */
for (k = 0; k < 3; k++) {
Bmax = MAX(Bmax, bl_value_map);
}
}
- /*Debug print local value*/
- if (Dbprint_lv == 1) {
- if ((db_cnt%4) == 0) { /*5 frames print once*/
- for (i = 0; i < 8; i++)
- pr_info("Tf_bl_matrix[blk_%d][%4d]\n", i,
- Tf_bl_matrix[FRM_NUM_DBG-1][i]);
+
+ if ((Dbprint_lv == 8) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step-4.1: BL_TF: [\n ");
+ pr_info("alpha =%d, dif_sum =%d\n ", alpha, dif_sum);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ TF_bl_matrix_t[blkRow * Hnum + blkCol]);
+ }
+ pr_info(";\n ");
+ }
+ pr_info("];\n");
}
}
- db_cnt++;
- if (db_cnt > 4095)
- db_cnt = 0;
-
- /* set the DC reduction for the BL_modeling */
- if (fw_LD_BLEst_ACmode == 0)
- nPRM1->reg_BL_matrix_AVG = 0;
- else if (fw_LD_BLEst_ACmode == 1) {
- /*nPRM->reg_BL_matrix_AVG = (sum/fw_blk_num);*/
- nPRM1->reg_BL_matrix_AVG = ((sum / fw_blk_num) *
- avg_gain + 2048) >> 12;
- Map_bl_matrix_AVG = ((sum / fw_blk_num) *
- avg_gain + 2048) >> 12;
- Map_bl_matrix_Compensate = ((sum / fw_blk_num) *
- avg_gain + 2048) >> 12;
- } else if (fw_LD_BLEst_ACmode == 2)
- nPRM1->reg_BL_matrix_AVG = Bmin;
- else if (fw_LD_BLEst_ACmode == 3)
- nPRM1->reg_BL_matrix_AVG = Bmax;
- else if (fw_LD_BLEst_ACmode == 4)
- nPRM1->reg_BL_matrix_AVG = 2048;
- else
- nPRM1->reg_BL_matrix_AVG = 1024;
-
- nPRM1->reg_BL_matrix_Compensate = nPRM1->reg_BL_matrix_AVG;
-}
-void LDIM_WR_BASE_LUT_DRT(int base, int *pData, int len)
-{
+ if ((Dbprint_lv == 9) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step-4.2: BL_remap: [\n ");
+ pr_info("Ld_remap_bypass =%d\n ", Ld_remap_bypass);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ Tf_bl_matrix_map[
+ blkRow * Hnum + blkCol]);
+ }
+ pr_info(";\n ");
+ }
+ pr_info("];\n ");
+ }
+ }
+
+ if ((Dbprint_lv == 10) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step-4.3: BL_remap_patch_old: [\n ");
+ pr_info(" diff_frm_luma=%d,\n ", diff_frm_luma);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ TF_bl_matrix_t3[
+ blkRow * Hnum + blkCol]);
+ }
+ pr_info(";\n ");
+ }
+ pr_info("];\n ");
+ }
+ }
+
+ if ((Dbprint_lv == 11) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step-4.4: BL_remap_patch_new: [\n ");
+ pr_info(" diff_frm_luma=%d, dif_sum=%d, LD_TF_STEP_TH=%d, TF_step_method=%d\n ",
+ diff_frm_luma,
+ dif_sum,
+ LD_TF_STEP_TH,
+ TF_step_method);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ TF_bl_matrix_t2
+ [blkRow * Hnum + blkCol]);
+ }
+ pr_info(";\n ");
+ }
+ pr_info("];\n ");
+ }
+ }
+ if ((Dbprint_lv == 12) || (Dbprint_lv == 1024)) {
+ if (pr_flag) {
+ pr_info("step 5: BL_TF_optimise(final BL_matrix):\n ");
+ pr_info("frm_print_cnt = %d, diff_frm_luma =%d, diff_blk_matrix =%d\n ",
+ fw_print_frequent,
+ diff_frm_luma,
+ diff_blk_matrix);
+ for (blkRow = 0; blkRow < Vnum; blkRow++) {
+ for (blkCol = 0; blkCol < Hnum; blkCol++) {
+ pr_info("(%4d)\n",
+ nPRM1->BL_matrix[
+ blkRow * Hnum + blkCol]);
+ }
+ pr_info(";\n ");
+ }
+ pr_info("];\n ");
+ }
+ }
+
+ db_cnt++;
+ if (db_cnt > 4095)
+ db_cnt = 0;
+
+ frm_cnt++;
+ if (frm_cnt > 4095)
+ frm_cnt = 0;
+
+ /* set the DC reduction for the BL_modeling */
+ if (fw_LD_BLEst_ACmode == 0)
+ nPRM1->reg_BL_matrix_AVG = 0;
+ else if (fw_LD_BLEst_ACmode == 1) {
+ /*nPRM->reg_BL_matrix_AVG = (sum/fw_blk_num);*/
+ nPRM1->reg_BL_matrix_AVG = ((sum / fw_blk_num) *
+ avg_gain + 2048) >> 12;
+ Map_bl_matrix_AVG = ((sum / fw_blk_num) *
+ avg_gain + 2048) >> 12;
+ Map_bl_matrix_Compensate = ((sum / fw_blk_num) *
+ avg_gain + 2048) >> 12;
+ } else if (fw_LD_BLEst_ACmode == 2)
+ nPRM1->reg_BL_matrix_AVG = Bmin;
+ else if (fw_LD_BLEst_ACmode == 3)
+ nPRM1->reg_BL_matrix_AVG = Bmax;
+ else if (fw_LD_BLEst_ACmode == 4)
+ nPRM1->reg_BL_matrix_AVG = 2048;
+ else
+ nPRM1->reg_BL_matrix_AVG = 1024;
+
+ nPRM1->reg_BL_matrix_Compensate = nPRM1->reg_BL_matrix_AVG;
+
+ /*black_display statue */
+ if (Hnum == 10) {
+ if (frm_rgbmax < 10) {
+ black_time_cnt++;
+ if (black_time_cnt > 120)
+ black_frm = 1;
+ } else {
+ black_time_cnt = 0;
+ black_frm = 0;
+ ldim_level_update = 1;
+ }
+ } else {
+ if (frm_rgbmax < 10) {
+ black_frm = 1;
+ } else {
+ black_frm = 0;
+ ldim_level_update = 1;
+ }
+ }
+ /*note: black_frm should co-work with brightness controlling(spi)*/
+}
+#endif
+
+void LDIM_WR_BASE_LUT_DRT(int base, int *pData, int len)
+{
int i;
int addr;
unsigned int row_start, col_start;
struct aml_bl_drv_s *bl_drv = aml_bl_get_driver();
+ BLK_Vnum = (BLK_Vnum == 0) ? 1 : BLK_Vnum;
+ BLK_Hnum = (BLK_Hnum == 0) ? 1 : BLK_Hnum;
LDIMPR("%s: %d %d %d %d\n", __func__, pic_h, pic_v, BLK_Vnum, BLK_Hnum);
resolution = (((pic_h - 1) & 0xffff) << 16) | ((pic_v - 1) & 0xffff);
case BL_CHIP_TXLX:
Wr(LDIM_STTS_CTRL0, 7 << 2);
ldim_set_matrix_ycbcr2rgb();
- ldim_stts_en(resolution, 0, 0, 3, 1, 1, 0);
+ ldim_stts_en(resolution, 0, 0, 1, 1, 1, 0);
break;
case BL_CHIP_GXTVBB:
Wr(LDIM_STTS_CTRL0, 3<<3);/*4 mux to vpp_dout*/
row_start, col_start, BLK_Hnum);
}
+static void ldim_db_para_print(struct LDReg *mLDReg)
+{
+ int i, len;
+ char *buf;
+
+ len = 32 * 10 + 10;
+ buf = kcalloc(len, sizeof(char), GFP_KERNEL);
+ if (buf == NULL) {
+ LDIMERR("print buf malloc error\n");
+ return;
+ }
+
+ LDIMPR("rgb_base = %ld\n"
+ "boost_gain = %ld\n"
+ "lpf_res = %ld\n"
+ "fw_LD_ThSF = %ld\n\n",
+ rgb_base,
+ boost_gain,
+ lpf_res,
+ fw_LD_ThSF_l);
+
+ LDIMPR("ld_vgain = %d\n"
+ "ld_hgain = %d\n"
+ "ld_litgain = %d\n\n",
+ mLDReg->reg_LD_Vgain,
+ mLDReg->reg_LD_Hgain,
+ mLDReg->reg_LD_Litgain);
+
+ LDIMPR("ld_lut_vdg_lext = %d\n"
+ "ld_lut_hdg_lext = %d\n"
+ "ld_lut_vhk_lext = %d\n\n",
+ mLDReg->reg_LD_LUT_Vdg_LEXT,
+ mLDReg->reg_LD_LUT_Hdg_LEXT,
+ mLDReg->reg_LD_LUT_VHk_LEXT);
+
+ len = 0;
+ LDIMPR("ld_lut_hdg:\n");
+ for (i = 0; i < 32; i++) {
+ len += sprintf(buf+len, "\t%d",
+ mLDReg->reg_LD_LUT_Hdg[i]);
+ if (i % 8 == 7)
+ len += sprintf(buf+len, "\n");
+ }
+ pr_info("%s\n", buf);
+
+ len = 0;
+ LDIMPR("ld_lut_vdg:\n");
+ for (i = 0; i < 32; i++) {
+ len += sprintf(buf+len, "\t%d",
+ mLDReg->reg_LD_LUT_Vdg[i]);
+ if (i % 8 == 7)
+ len += sprintf(buf+len, "\n");
+ }
+ pr_info("%s\n", buf);
+
+ len = 0;
+ LDIMPR("ld_lut_vhk:\n");
+ for (i = 0; i < 32; i++) {
+ len += sprintf(buf+len, "\t%d",
+ mLDReg->reg_LD_LUT_VHk[i]);
+ if (i % 8 == 7)
+ len += sprintf(buf+len, "\n");
+ }
+ pr_info("%s\n", buf);
+
+ len = 0;
+ LDIMPR("ld_lut_vhk_pos:\n");
+ for (i = 0; i < 32; i++) {
+ len += sprintf(buf+len, "\t%d",
+ mLDReg->reg_LD_LUT_VHk_pos[i]);
+ if (i % 8 == 7)
+ len += sprintf(buf+len, "\n");
+ }
+ pr_info("%s\n", buf);
+
+ len = 0;
+ LDIMPR("ld_lut_vhk_neg:\n");
+ for (i = 0; i < 32; i++) {
+ len += sprintf(buf+len, "\t%d",
+ mLDReg->reg_LD_LUT_VHk_neg[i]);
+ if (i % 8 == 7)
+ len += sprintf(buf+len, "\n");
+ }
+ pr_info("%s\n", buf);
+
+ len = 0;
+ LDIMPR("ld_lut_hhk:\n");
+ for (i = 0; i < 32; i++) {
+ len += sprintf(buf+len, "\t%d",
+ mLDReg->reg_LD_LUT_HHk[i]);
+ if (i % 8 == 7)
+ len += sprintf(buf+len, "\n");
+ }
+ pr_info("%s\n", buf);
+
+ len = 0;
+ LDIMPR("ld_lut_vho_pos:\n");
+ for (i = 0; i < 32; i++) {
+ len += sprintf(buf+len, "\t%d",
+ mLDReg->reg_LD_LUT_VHo_pos[i]);
+ if (i % 8 == 7)
+ len += sprintf(buf+len, "\n");
+ }
+ pr_info("%s\n", buf);
+
+ len = 0;
+ LDIMPR("ld_lut_vho_neg:\n");
+ for (i = 0; i < 32; i++) {
+ len += sprintf(buf+len, "\t%d",
+ mLDReg->reg_LD_LUT_VHo_neg[i]);
+ if (i % 8 == 7)
+ len += sprintf(buf+len, "\n");
+ }
+ pr_info("%s\n", buf);
+
+ kfree(buf);
+}
+
static void ldim_db_load_update(struct LDReg *mLDReg)
{
int i;
ldim_db_para.ld_lut_vho_pos[i];
mLDReg->reg_LD_LUT_VHo_neg[i] =
ldim_db_para.ld_lut_vho_neg[i];
- }
+ }
/* remapping */
/*ldim_db_para.lit_idx_th;*/
/*ldim_db_para.comp_gain;*/
}
- if (print_db_flag == 1) {
- LDIMPR("rgb_base = %ld\n", rgb_base);
- LDIMPR("\n");
- LDIMPR("boost_gain = %ld\n", boost_gain);
- LDIMPR("\n");
- LDIMPR("lpf_res = %ld\n", lpf_res);
- LDIMPR("\n");
- LDIMPR("fw_LD_ThSF = %ld\n", fw_LD_ThSF_l);
- LDIMPR("\n");
-
- LDIMPR("ld_vgain = %d\n", mLDReg->reg_LD_Vgain);
- LDIMPR("\n");
- LDIMPR("ld_hgain = %d\n", mLDReg->reg_LD_Hgain);
- LDIMPR("\n");
- LDIMPR("ld_litgain = %d\n", mLDReg->reg_LD_Litgain);
- LDIMPR("\n");
-
- LDIMPR("ld_lut_vdg_lext = %d\n", mLDReg->reg_LD_LUT_Vdg_LEXT);
- LDIMPR("\n");
- LDIMPR("ld_lut_hdg_lext = %d\n", mLDReg->reg_LD_LUT_Hdg_LEXT);
- LDIMPR("\n");
- LDIMPR("ld_lut_vhk_lext = %d\n", mLDReg->reg_LD_LUT_VHk_LEXT);
- LDIMPR("\n");
-
- for (i = 0; i < 32; i++)
- LDIMPR("ld_lut_hdg = %d\n", mLDReg->reg_LD_LUT_Hdg[i]);
- LDIMPR("\n");
- for (i = 0; i < 32; i++)
- LDIMPR("ld_lut_vdg = %d\n", mLDReg->reg_LD_LUT_Vdg[i]);
- LDIMPR("\n");
- for (i = 0; i < 32; i++)
- LDIMPR("ld_lut_vhk = %d\n", mLDReg->reg_LD_LUT_VHk[i]);
- LDIMPR("\n");
-
- for (i = 0; i < 32; i++)
- LDIMPR("ld_lut_vhk_pos = %d\n",
- mLDReg->reg_LD_LUT_VHk_pos[i]);
- LDIMPR("\n");
- for (i = 0; i < 32; i++)
- LDIMPR("ld_lut_vhk_neg = %d\n",
- mLDReg->reg_LD_LUT_VHk_neg[i]);
- LDIMPR("\n");
- for (i = 0; i < 32; i++)
- LDIMPR("ld_lut_hhk = %d\n",
- mLDReg->reg_LD_LUT_HHk[i]);
- LDIMPR("\n");
- for (i = 0; i < 32; i++)
- LDIMPR("ld_lut_vho_pos = %d\n",
- mLDReg->reg_LD_LUT_VHo_pos[i]);
- LDIMPR("\n");
- for (i = 0; i < 32; i++)
- LDIMPR("ld_lut_vho_neg = %d\n",
- mLDReg->reg_LD_LUT_VHo_neg[i]);
- LDIMPR("\n");
- }
+ if (db_print_flag == 1)
+ ldim_db_para_print(mLDReg);
}
static void LDIM_Initial_GXTVBB(unsigned int ldim_bl_en,
/* ldim_param_misc_ctrl0; */
LDIM_WR_32Bits(REG_LD_MISC_CTRL0, data);
kfree(arrayTmp);
-
}
static int LDIM_Update_Matrix(int NewBlMatrix[], int BlMatrixNum)
LDIM_Update_Matrix(nPRM.BL_matrix, 16 * 24);
kfree(arrayTmp);
-
}
static void LDIM_Initial(unsigned int pic_h, unsigned int pic_v,
default:
break;
}
-
}
static int ldim_open(struct inode *inode, struct file *file)
#endif
static const struct file_operations ldim_fops = {
- .owner = THIS_MODULE,
- .open = ldim_open,
- .release = ldim_release,
- .unlocked_ioctl = ldim_ioctl,
+ .owner = THIS_MODULE,
+ .open = ldim_open,
+ .release = ldim_release,
+ .unlocked_ioctl = ldim_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ldim_compat_ioctl,
#endif
static irqreturn_t rdma_ldim_intr(int irq, void *dev_id)
{
ulong flags;
+
/*LDIMPR("*********rdma_ldim_intr start*********\n");*/
spin_lock_irqsave(&rdma_ldim_isr_lock, flags);
ldim_driver.device_bri_update(ldim_driver.ldim_matrix_buf,
size);
if (ldim_driver.static_pic_flag == 1) {
- ldim_get_matrix_info_6();
+ ldim_get_matrix_info_max_rgb();
ldim_dump_histgram();
}
} else {
if (ldim_level_update) {
ldim_level_update = 0;
- if (ldim_debug_print) {
- LDIMPR("%s: level update: 0x%lx\n",
- __func__, litgain);
- }
+ if (ldim_debug_print)
+ LDIMPR("%s: level update: 0x%lx\n", __func__, litgain);
for (i = 0; i < size; i++) {
ldim_driver.local_ldim_matrix[i] =
(unsigned short)nPRM.BL_matrix[i];
ldim_driver.device_bri_update(ldim_driver.ldim_matrix_buf,
size);
if (ldim_driver.static_pic_flag == 1) {
- ldim_get_matrix_info_6();
+ ldim_get_matrix_info_max_rgb();
ldim_dump_histgram();
}
} else {
static inline void ld_fw_alg_frm(struct LDReg *nPRM1, struct FW_DAT *FDat1,
unsigned int *max_matrix, unsigned int *hist_matrix)
{
-#if 0
- struct aml_bl_drv_s *bl_drv = aml_bl_get_driver();
-
- switch (bl_drv->data->chip_type) {
- case BL_CHIP_TXLX:
- ld_fw_alg_frm_txlx(nPRM1, FDat1, max_matrix, hist_matrix);
- break;
- case BL_CHIP_GXTVBB:
- ld_fw_alg_frm_gxtvbb(nPRM1, FDat1, max_matrix, hist_matrix);
- break;
- default:
- break;
- }
-#else
+#if (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V1)
+ ld_fw_alg_frm_txlx(nPRM1, FDat1, max_matrix, hist_matrix);
+#elif (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V0)
ld_fw_alg_frm_gxtvbb(nPRM1, FDat1, max_matrix, hist_matrix);
#endif
}
kfree(local_ldim_max_rgb);
}
-static void ldim_get_matrix_info_2(void)
+static void ldim_get_matrix_info_TF(void)
{
unsigned int i, j, len;
- unsigned int *local_ldim_matrix_t = NULL;
+ unsigned int *ldim_matrix_t = NULL;
char *buf;
- local_ldim_matrix_t = kcalloc(ldim_hist_row*ldim_hist_col,
+ ldim_matrix_t = kcalloc(ldim_hist_row*ldim_hist_col,
sizeof(unsigned int), GFP_KERNEL);
- if (local_ldim_matrix_t == NULL) {
+ if (ldim_matrix_t == NULL) {
LDIMERR("ldim_matrix_t malloc error\n");
return;
}
buf = kcalloc(len, sizeof(char), GFP_KERNEL);
if (buf == NULL) {
LDIMERR("print buf malloc error\n");
- kfree(local_ldim_matrix_t);
+ kfree(ldim_matrix_t);
return;
}
- memcpy(local_ldim_matrix_t, &FDat.TF_BL_matrix[0],
+ memcpy(ldim_matrix_t, &FDat.TF_BL_matrix[0],
ldim_blk_col*ldim_blk_row*sizeof(unsigned int));
pr_info("%s:\n", __func__);
for (i = 0; i < ldim_blk_row; i++) {
len = 0;
for (j = 0; j < ldim_blk_col; j++) {
- len += sprintf(buf+len, "\t0x%x",
- local_ldim_matrix_t[ldim_blk_col*i+j]);
+ len += sprintf(buf+len, "\t%4d",
+ ldim_matrix_t[ldim_blk_col*i+j]);
}
pr_info("%s\n", buf);
msleep(20);
}
kfree(buf);
- kfree(local_ldim_matrix_t);
+ kfree(ldim_matrix_t);
}
-static void ldim_get_matrix_info_3(void)
+static void ldim_get_matrix_info_SF(void)
{
unsigned int i, j, len;
- unsigned int *local_ldim_matrix_t = NULL;
+ unsigned int *ldim_matrix_t = NULL;
char *buf;
- local_ldim_matrix_t = kcalloc(ldim_hist_row*ldim_hist_col,
+ ldim_matrix_t = kcalloc(ldim_hist_row*ldim_hist_col,
sizeof(unsigned int), GFP_KERNEL);
- if (local_ldim_matrix_t == NULL) {
+ if (ldim_matrix_t == NULL) {
LDIMERR("ldim_matrix_t malloc error\n");
return;
}
buf = kcalloc(len, sizeof(char), GFP_KERNEL);
if (buf == NULL) {
LDIMERR("print buf malloc error\n");
- kfree(local_ldim_matrix_t);
+ kfree(ldim_matrix_t);
return;
}
- memcpy(local_ldim_matrix_t, &FDat.SF_BL_matrix[0],
+ memcpy(ldim_matrix_t, &FDat.SF_BL_matrix[0],
ldim_blk_col*ldim_blk_row*sizeof(unsigned int));
pr_info("%s:\n", __func__);
for (i = 0; i < ldim_blk_row; i++) {
len = 0;
for (j = 0; j < ldim_blk_col; j++) {
- len += sprintf(buf+len, "\t0x%x",
- local_ldim_matrix_t[ldim_blk_col*i+j]);
+ len += sprintf(buf+len, "\t%4d",
+ ldim_matrix_t[ldim_blk_col*i+j]);
}
pr_info("%s\n", buf);
msleep(20);
}
kfree(buf);
- kfree(local_ldim_matrix_t);
+ kfree(ldim_matrix_t);
}
static void ldim_get_matrix_info_4(void)
{
unsigned int i, j, k, len;
- unsigned int *local_ldim_matrix_t = NULL;
+ unsigned int *ldim_matrix_t = NULL;
char *buf;
- local_ldim_matrix_t = kcalloc(ldim_hist_row*ldim_hist_col,
+ ldim_matrix_t = kcalloc(ldim_hist_row*ldim_hist_col,
16*sizeof(unsigned int), GFP_KERNEL);
- if (local_ldim_matrix_t == NULL) {
+ if (ldim_matrix_t == NULL) {
LDIMERR("ldim_matrix_t malloc error\n");
return;
}
buf = kcalloc(len, sizeof(char), GFP_KERNEL);
if (buf == NULL) {
LDIMERR("print buf malloc error\n");
- kfree(local_ldim_matrix_t);
+ kfree(ldim_matrix_t);
return;
}
- memcpy(local_ldim_matrix_t, &FDat.last_STA1_MaxRGB[0],
+ memcpy(ldim_matrix_t, &FDat.last_STA1_MaxRGB[0],
ldim_blk_col*ldim_blk_row*3*sizeof(unsigned int));
pr_info("%s:\n", __func__);
for (j = 0; j < ldim_blk_col; j++) {
len += sprintf(buf+len, "\tcol %d:", ldim_blk_col);
for (k = 0; k < 3; k++) {
- len += sprintf(buf+len, "\t0x%x",
- local_ldim_matrix_t[3*ldim_blk_col*i+j*3+k]);
+ len += sprintf(buf+len, "\t%4d",
+ ldim_matrix_t[3*ldim_blk_col*i+j*3+k]);
}
len += sprintf(buf+len, "\n");
}
}
kfree(buf);
- kfree(local_ldim_matrix_t);
+ kfree(ldim_matrix_t);
}
-static void ldim_get_matrix_info_5(void)
+static void ldim_get_matrix_info_alpha(void)
{
unsigned int i, j, len;
- unsigned int *local_ldim_matrix_t = NULL;
+ unsigned int *ldim_matrix_t = NULL;
char *buf;
- local_ldim_matrix_t = kcalloc(ldim_hist_row*ldim_hist_col,
+ ldim_matrix_t = kcalloc(ldim_hist_row*ldim_hist_col,
sizeof(unsigned int), GFP_KERNEL);
- if (local_ldim_matrix_t == NULL) {
+ if (ldim_matrix_t == NULL) {
LDIMERR("ldim_matrix_t malloc error\n");
return;
}
buf = kcalloc(len, sizeof(char), GFP_KERNEL);
if (buf == NULL) {
LDIMERR("print buf malloc error\n");
- kfree(local_ldim_matrix_t);
+ kfree(ldim_matrix_t);
return;
}
- memcpy(local_ldim_matrix_t, &FDat.TF_BL_alpha[0],
+ memcpy(ldim_matrix_t, &FDat.TF_BL_alpha[0],
ldim_blk_col*ldim_blk_row*sizeof(unsigned int));
pr_info("%s:\n", __func__);
for (i = 0; i < ldim_blk_row; i++) {
len = 0;
for (j = 0; j < ldim_blk_col; j++) {
- len += sprintf(buf+len, "\t0x%x",
- local_ldim_matrix_t[ldim_blk_col*i+j]);
+ len += sprintf(buf+len, "\t%4d",
+ ldim_matrix_t[ldim_blk_col*i+j]);
}
pr_info("%s\n", buf);
msleep(20);
}
kfree(buf);
- kfree(local_ldim_matrix_t);
+ kfree(ldim_matrix_t);
}
-static void ldim_get_matrix_info_6(void)
+static void ldim_get_matrix_info_max_rgb(void)
{
unsigned int i, j, len;
unsigned int *p = NULL;
if (reg_sel == 0)
LDIM_RD_BASE_LUT(REG_LD_BLK_VIDX_BASE, data, 16, 32);
else if (reg_sel == 3)
- ldim_get_matrix_info_2();
+ ldim_get_matrix_info_TF();
else if (reg_sel == 4)
- ldim_get_matrix_info_3();
+ ldim_get_matrix_info_SF();
else if (reg_sel == 5)
ldim_get_matrix_info_4();
else if (reg_sel == 6)
- ldim_get_matrix_info_5();
+ ldim_get_matrix_info_alpha();
else if (reg_sel == 7)
- ldim_get_matrix_info_6();
+ ldim_get_matrix_info_max_rgb();
else if (reg_sel == REG_LD_LUT_HDG_BASE)
LDIM_RD_BASE_LUT_2(REG_LD_LUT_HDG_BASE, data, 10, 32);
else if (reg_sel == REG_LD_LUT_VHK_BASE)
static void ldim_get_matrix_info(void)
{
unsigned int i, j, len;
- unsigned short *local_ldim_matrix_t = NULL;
- unsigned short *local_ldim_matrix_spi_t = NULL;
+ unsigned short *ldim_matrix_t = NULL;
+ unsigned short *ldim_matrix_spi_t = NULL;
char *buf;
- local_ldim_matrix_t = kcalloc(ldim_hist_row*ldim_hist_col,
+ ldim_matrix_t = kcalloc(ldim_hist_row*ldim_hist_col,
sizeof(unsigned int), GFP_KERNEL);
- if (local_ldim_matrix_t == NULL) {
+ if (ldim_matrix_t == NULL) {
LDIMERR("ldim_matrix_t malloc error\n");
return;
}
- local_ldim_matrix_spi_t = kcalloc(ldim_hist_row*ldim_hist_col,
+ ldim_matrix_spi_t = kcalloc(ldim_hist_row*ldim_hist_col,
sizeof(unsigned int), GFP_KERNEL);
- if (local_ldim_matrix_spi_t == NULL) {
+ if (ldim_matrix_spi_t == NULL) {
LDIMERR("ldim_matrix_spi_t malloc error\n");
- kfree(local_ldim_matrix_t);
+ kfree(ldim_matrix_t);
return;
}
buf = kcalloc(len, sizeof(char), GFP_KERNEL);
if (buf == NULL) {
LDIMERR("print buf malloc error\n");
- kfree(local_ldim_matrix_t);
- kfree(local_ldim_matrix_spi_t);
+ kfree(ldim_matrix_t);
+ kfree(ldim_matrix_spi_t);
return;
}
- memcpy(local_ldim_matrix_t, &ldim_driver.local_ldim_matrix[0],
+ memcpy(ldim_matrix_t, &ldim_driver.local_ldim_matrix[0],
ldim_blk_col*ldim_blk_row*sizeof(unsigned short));
- memcpy(local_ldim_matrix_spi_t,
+ memcpy(ldim_matrix_spi_t,
&ldim_driver.ldim_matrix_buf[0],
ldim_blk_col*ldim_blk_row*sizeof(unsigned short));
for (i = 0; i < ldim_blk_row; i++) {
len = 0;
for (j = 0; j < ldim_blk_col; j++) {
- len += sprintf(buf+len, "\t0x%x",
- local_ldim_matrix_t[ldim_blk_col*i+j]);
+ len += sprintf(buf+len, "\t%4d",
+ ldim_matrix_t[ldim_blk_col*i+j]);
}
pr_info("%s\n", buf);
msleep(20);
}
+ pr_info("current black_frm: %d\n", black_frm);
pr_info("spi transfer_matrix:\n");
for (i = 0; i < ldim_blk_row; i++) {
len = 0;
for (j = 0; j < ldim_blk_col; j++) {
- len += sprintf(buf+len, "\t0x%x",
- local_ldim_matrix_spi_t[ldim_blk_col*i+j]);
+ len += sprintf(buf+len, "\t%4d",
+ ldim_matrix_spi_t[ldim_blk_col*i+j]);
}
pr_info("%s\n", buf);
msleep(20);
pr_info("\n");
kfree(buf);
- kfree(local_ldim_matrix_t);
- kfree(local_ldim_matrix_spi_t);
+ kfree(ldim_matrix_t);
+ kfree(ldim_matrix_spi_t);
}
static void ldim_nPRM_bl_matrix_info(void)
{
unsigned int i, j, len;
- unsigned int local_ldim_matrix_t[LD_BLKREGNUM] = {0};
+ unsigned int ldim_matrix_t[LD_BLKREGNUM] = {0};
char *buf;
len = ldim_blk_col * 10 + 20;
return;
}
- memcpy(&local_ldim_matrix_t[0], &nPRM.BL_matrix[0],
+ memcpy(&ldim_matrix_t[0], &nPRM.BL_matrix[0],
ldim_blk_col*ldim_blk_row*sizeof(unsigned short));
pr_info("%s and spi info:\n", __func__);
for (i = 0; i < ldim_blk_row; i++) {
len = 0;
for (j = 0; j < ldim_blk_col; j++) {
- len += sprintf(buf+len, "\t0x%x", local_ldim_matrix_t
- [ldim_blk_col*i+j]);
+ len += sprintf(buf+len, "\t0x%x",
+ ldim_matrix_t[ldim_blk_col*i+j]);
}
pr_info("%s\n", buf);
msleep(20);
LDIM_WR_BASE_LUT(REG_LD_LUT_VDG_BASE, data, 16, cnt);
}
-static void ldim_remap_ctrl(int status)
+static void ldim_remap_ctrl(unsigned char status)
{
unsigned int temp;
LDIMPR("%s: %d\n", __func__, status);
}
-static void ldim_func_ctrl(int status)
+static void ldim_func_ctrl(unsigned char status)
{
if (status) {
/* enable other flag */
static int ldim_set_level(unsigned int level)
{
- int ret = 0;
struct aml_bl_drv_s *bl_drv = aml_bl_get_driver();
unsigned int level_max, level_min;
ldim_brightness_level = level;
+
+ if (ldim_brightness_bypass)
+ return 0;
+
level_max = bl_drv->bconf->level_max;
level_min = bl_drv->bconf->level_min;
litgain = (unsigned long)level;
ldim_level_update = 1;
- return ret;
+ return 0;
}
static void ldim_test_ctrl(int flag)
ssize_t len = 0;
len += sprintf(buf+len,
- "\necho histgram_ldim > /sys/class/aml_ldim/attr\n");
+ "\necho hist > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
- "echo ldim_init 1920 1080 8 2 0 1 0 > /sys/class/aml_ldim/attr\n");
+ "echo maxrgb > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo matrix > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo histgram_ldim > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo ldim_matrix_get 7 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo ldim_matrix_info > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
"echo ldim_matrix_get 0/1/2/3 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
len += sprintf(buf+len,
"echo info > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
+ "echo alg_para > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
"echo test_mode 0 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
"echo test_set 0 0xfff > /sys/class/aml_ldim/attr\n");
"echo fw_LD_ThSF_l 1600 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
"echo fw_LD_ThTF_l 32 > /sys/class/aml_ldim/attr\n");
-
+ len += sprintf(buf+len,
+ "echo boost_gain 4 > /sys/class/aml_ldim/attr\n");
+#if (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V1)
+ len += sprintf(buf+len,
+ "echo alpha_delta 0 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo boost_gain_neg 4 > /sys/class/aml_ldim/attr\n");
+#elif (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V0)
+ len += sprintf(buf+len,
+ "echo TF_alpha 256 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo lpf_gain 0 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo lpf_res 0 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
"echo rgb_base 128 > /sys/class/aml_ldim/attr\n");
+#endif
len += sprintf(buf+len,
- "echo Dbprint_lv 128 > /sys/class/aml_ldim/attr\n");
+ "echo ov_gain 16 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo incr_dif_gain 16 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo avg_gain 2048 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo litgain 4096 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
- "echo lpf_gain 0 > /sys/class/aml_ldim/attr\n");
+ "echo LPF_method 3 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
- "echo lpf_res 0 > /sys/class/aml_ldim/attr\n");
+ "echo LD_TF_STEP_TH 100 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo TF_step_method 3 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo TF_FRESH_BL 8 > /sys/class/aml_ldim/attr\n");
+
+ len += sprintf(buf+len,
+ "echo TF_BLK_FRESH_BL 5 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo side_blk_diff_th 100 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo bbd_th 200 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo bbd_detect_en 1 > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo diff_blk_luma_en 1 > /sys/class/aml_ldim/attr\n");
+
+ len += sprintf(buf+len,
+ "echo bl_remap_curve > /sys/class/aml_ldim/attr\n");
+ len += sprintf(buf+len,
+ "echo fw_LD_Whist > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
"echo Sf_bypass 0 > /sys/class/aml_ldim/attr\n");
"echo Ld_remap_bypass 0 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
- "echo litgain 4096 > /sys/class/aml_ldim/attr\n");
+ "echo fw_hist_print 1 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
- "echo boost_gain 4 > /sys/class/aml_ldim/attr\n");
+ "echo Debug 1 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
- "echo alpha 256 > /sys/class/aml_ldim/attr\n");
+ "echo fw_print_frequent 8 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
- "echo alpha_delta 0 > /sys/class/aml_ldim/attr\n");
- len += sprintf(buf+len,
- "echo boost_gain_neg 4 > /sys/class/aml_ldim/attr\n");
+ "echo Dbprint_lv 1 > /sys/class/aml_ldim/attr\n");
+
len += sprintf(buf+len,
- "echo avg_gain 2048 > /sys/class/aml_ldim/attr\n");
+ "echo ldim_init 1920 1080 8 2 0 1 0 > /sys/class/aml_ldim/attr\n");
len += sprintf(buf+len,
"echo curve_0 512 4 3712 29 > /sys/class/aml_ldim/attr\n");
unsigned long blk_vnum = 0, blk_hnum = 0, hist_row = 0, hist_col = 0;
unsigned long backlit_mod = 0, ldim_bl_en = 0, ldim_hvcnt_bypass = 0;
unsigned long val1 = 0, val2 = 0;
- unsigned long db_data;
if (!buf)
return len;
if (!strcmp(parm[0], "histgram_ldim")) {
ldim_dump_histgram();
- } else if (!strcmp(parm[0], "data_db_enable")) {
+ } else if (!strcmp(parm[0], "maxrgb")) {
+ ldim_get_matrix_info_max_rgb();
+ } else if (!strcmp(parm[0], "hist")) {
+ ldim_dump_histgram();
+ } else if (!strcmp(parm[0], "matrix")) {
+ ldim_get_matrix_info();
+ } else if (!strcmp(parm[0], "db_en")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &db_data) < 0)
- return -EINVAL;
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ LDIM_DATA_FROM_DB = (unsigned char)val1;
+ ldim_db_load_update(&nPRM);
}
- LDIM_DATA_FROM_DB = (unsigned int)db_data;
- pr_info("set LDIM_DATA_FROM_DB=%lu\n", db_data);
- } else if (!strcmp(parm[0], "print_db_flag")) {
- print_db_flag = 1;
- ldim_db_load_update(&nPRM);
+ pr_info("LDIM_DATA_FROM_DB = %d\n", LDIM_DATA_FROM_DB);
+ } else if (!strcmp(parm[0], "db_print")) {
+ db_print_flag = 1;
+ } else if (!strcmp(parm[0], "dump_db")) {
+ ldim_db_para_print(&nPRM);
} else if (!strcmp(parm[0], "ldim_init")) {
if (parm[7] != NULL) {
if (kstrtoul(parm[1], 10, &pic_h) < 0)
return -EINVAL;
if (kstrtoul(parm[7], 10, &ldim_hvcnt_bypass) < 0)
goto ldim_attr_store_end;
+
+ pr_info("ldim init param:%lu,%lu,%lu,%lu,%lu,%lu,%lu\n",
+ pic_h, pic_v, blk_vnum, blk_hnum,
+ backlit_mod, ldim_bl_en, ldim_hvcnt_bypass);
+ ldim_blk_row = blk_vnum;
+ ldim_blk_col = blk_hnum;
+ ldim_config.row = ldim_blk_row;
+ ldim_config.col = ldim_blk_col;
+ ldim_config.bl_mode = (unsigned char)backlit_mod;
+ LDIM_Initial(pic_h, pic_v, blk_vnum, blk_hnum,
+ backlit_mod, ldim_bl_en, ldim_hvcnt_bypass);
+ pr_info("**************ldim init ok*************\n");
}
- pr_info("****ldim init param:%lu,%lu,%lu,%lu,%lu,%lu,%lu****\n",
- pic_h, pic_v, blk_vnum, blk_hnum,
- backlit_mod, ldim_bl_en, ldim_hvcnt_bypass);
- ldim_blk_row = blk_vnum;
- ldim_blk_col = blk_hnum;
- ldim_config.row = ldim_blk_row;
- ldim_config.col = ldim_blk_col;
- ldim_config.bl_mode = (unsigned char)backlit_mod;
- LDIM_Initial(pic_h, pic_v, blk_vnum, blk_hnum,
- backlit_mod, ldim_bl_en, ldim_hvcnt_bypass);
- pr_info("**************ldim init ok*************\n");
} else if (!strcmp(parm[0], "ldim_stts_init")) {
if (parm[4] != NULL) {
if (kstrtoul(parm[1], 10, &pic_h) < 0)
goto ldim_attr_store_end;
if (kstrtoul(parm[4], 10, &hist_col) < 0)
goto ldim_attr_store_end;
+
+ pr_info("****ldim init param:%lu,%lu,%lu,%lu********\n",
+ pic_h, pic_v, hist_row, hist_col);
+ ldim_hist_row = hist_row;
+ ldim_hist_col = hist_col;
+ ldim_stts_initial(pic_h, pic_v, hist_row, hist_col);
+ pr_info("************ldim stts init ok*************\n");
}
- pr_info("****ldim init param:%lu,%lu,%lu,%lu*********\n",
- pic_h, pic_v, hist_row, hist_col);
- ldim_hist_row = hist_row;
- ldim_hist_col = hist_col;
- ldim_stts_initial(pic_h, pic_v, hist_row, hist_col);
- pr_info("**************ldim stts init ok*************\n");
} else if (!strcmp(parm[0], "remap")) {
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
- }
- if (val1) {
- if (ldim_func_en) {
- ldim_remap_en = 1;
- ldim_remap_ctrl(1);
+ if (val1) {
+ if (ldim_func_en) {
+ ldim_remap_en = 1;
+ ldim_remap_ctrl(1);
+ } else {
+ pr_info(
+ "error: ldim_func is disabled\n");
+ }
} else {
- pr_info("error: ldim_func is disabled\n");
+ ldim_remap_en = 0;
+ ldim_remap_ctrl(0);
}
- } else {
- ldim_remap_en = 0;
- ldim_remap_ctrl(0);
}
pr_info("ldim_remap_en: %d\n", ldim_remap_en);
- } else if (!strcmp(parm[0], "remap_get")) {
- pr_info("ldim_remap_en: %d\n", ldim_remap_en);
} else if (!strcmp(parm[0], "ldim_matrix_get")) {
unsigned int data[32] = {0};
- unsigned int k, g;
- unsigned long reg_sel = 0;
+ unsigned int k, g, reg_sel = 0;
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, ®_sel) < 0)
- goto ldim_attr_store_end;
- }
- pr_buf = kzalloc(sizeof(char) * 200, GFP_KERNEL);
- if (!pr_buf) {
- LDIMERR("buf malloc error\n");
- goto ldim_attr_store_end;
- }
- ldim_get_matrix(&data[0], reg_sel);
- if ((reg_sel == 0) || (reg_sel == 1)) {
- pr_info("**********ldim matrix info start**********\n");
- for (k = 0; k < 4; k++) {
- pr_len = 0;
- for (g = 0; g < 8; g++) {
- pr_len += sprintf(pr_buf+pr_len,
- "\t%d", data[8*k+g]);
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ reg_sel = (unsigned int)val1;
+
+ pr_buf = kzalloc(sizeof(char) * 200, GFP_KERNEL);
+ if (!pr_buf) {
+ LDIMERR("buf malloc error\n");
+ goto ldim_attr_store_end;
+ }
+ ldim_get_matrix(&data[0], reg_sel);
+ if ((reg_sel == 0) || (reg_sel == 1)) {
+ pr_info("******ldim matrix info start******\n");
+ for (k = 0; k < 4; k++) {
+ pr_len = 0;
+ for (g = 0; g < 8; g++) {
+ pr_len += sprintf(pr_buf+pr_len,
+ "\t%d", data[8*k+g]);
+ }
+ pr_info("%s\n", pr_buf);
}
- pr_info("%s\n", pr_buf);
+ pr_info("*******ldim matrix info end*******\n");
}
- pr_info("**********ldim matrix info end***********\n");
+ kfree(pr_buf);
}
- kfree(pr_buf);
} else if (!strcmp(parm[0], "ldim_matrix_set")) {
unsigned int data_set[32] = {0};
- unsigned long reg_sel_1 = 0, k1, cnt1 = 0;
+ unsigned int reg_sel_1 = 0, k1, cnt1 = 0;
unsigned long temp_set[32] = {0};
- if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, ®_sel_1) < 0)
- goto ldim_attr_store_end;
- }
if (parm[2] != NULL) {
- if (kstrtoul(parm[1], 10, &cnt1) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
- }
- for (k1 = 0; k1 < cnt1; k1++) {
- if (parm[k1+2] != NULL) {
- temp_set[k1] =
- kstrtoul(parm[k1+2], 10, &temp_set[k1]);
- data_set[k1] = (unsigned int)temp_set[k1];
+ if (kstrtoul(parm[2], 10, &val2) < 0)
+ goto ldim_attr_store_end;
+
+ reg_sel_1 = val1;
+ cnt1 = val2;
+ for (k1 = 0; k1 < cnt1; k1++) {
+ if (parm[k1+2] != NULL) {
+ temp_set[k1] = kstrtoul(parm[k1+2],
+ 10, &temp_set[k1]);
+ data_set[k1] =
+ (unsigned int)temp_set[k1];
+ }
}
+ ldim_set_matrix(&data_set[0], reg_sel_1, cnt1);
+ pr_info("***********ldim matrix set over***********\n");
}
- ldim_set_matrix(&data_set[0], (unsigned int)reg_sel_1, cnt1);
- pr_info("**************ldim matrix set over*************\n");
} else if (!strcmp(parm[0], "ldim_matrix_info")) {
ldim_get_matrix_info();
pr_info("**************ldim matrix info over*************\n");
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+
+ ldim_data_min = (unsigned int)val1;
+ ldim_set_level(ldim_brightness_level);
+ pr_info("*****ldim brightness data_min update******\n");
}
- ldim_data_min = (unsigned int)val1;
- ldim_set_level(ldim_brightness_level);
- pr_info("**********ldim brightness data_min update*********\n");
} else if (!strcmp(parm[0], "test_mode")) {
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ ldim_test_en = (unsigned char)val1;
}
- ldim_test_en = (unsigned int)val1;
LDIMPR("test_mode: %d\n", ldim_test_en);
} else if (!strcmp(parm[0], "test_set")) {
if (parm[2] != NULL) {
goto ldim_attr_store_end;
if (kstrtoul(parm[2], 16, &val2) < 0)
goto ldim_attr_store_end;
- }
- size = ldim_blk_row * ldim_blk_col;
- if (val1 < size) {
- ldim_driver.ldim_test_matrix[val1] =
- (unsigned short)val2;
- LDIMPR("set test_matrix[%d] = 0x%03x\n",
- (unsigned int)val1, (unsigned int)val2);
- } else {
- LDIMERR("invalid index for test_matrix: %d\n",
- (unsigned int)val1);
+
+ size = ldim_blk_row * ldim_blk_col;
+ if (val1 < size) {
+ ldim_driver.ldim_test_matrix[val1] =
+ (unsigned short)val2;
+ LDIMPR("set test_matrix[%d] = 0x%03x\n",
+ (unsigned int)val1, (unsigned int)val2);
+ } else {
+ LDIMERR("invalid index for test_matrix: %d\n",
+ (unsigned int)val1);
+ }
}
} else if (!strcmp(parm[0], "test_set_all")) {
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 16, &val1) < 0)
goto ldim_attr_store_end;
+
+ for (i = 0; i < ldim_blk_row * ldim_blk_col; i++) {
+ ldim_driver.ldim_test_matrix[i] =
+ (unsigned short)val1;
+ }
+ LDIMPR("set all test_matrix to 0x%03x\n",
+ (unsigned int)val1);
}
- for (i = 0; i < ldim_blk_row * ldim_blk_col; i++)
- ldim_driver.ldim_test_matrix[i] = (unsigned short)val1;
- LDIMPR("set all test_matrix to 0x%03x\n", (unsigned int)val1);
} else if (!strcmp(parm[0], "test_get")) {
LDIMPR("get test_mode: %d, test_matrix:\n", ldim_test_en);
size = ldim_blk_row * ldim_blk_col;
pr_info("0x%03x\t", ldim_driver.ldim_test_matrix[i]);
pr_info("\n");
} else if (!strcmp(parm[0], "rs")) {
- unsigned long reg_addr = 0, reg_val;
+ unsigned int reg_addr = 0, reg_val;
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 16, ®_addr) < 0)
+ if (kstrtoul(parm[1], 16, &val1) < 0)
goto ldim_attr_store_end;
+ reg_addr = (unsigned int)val1;
+
+ reg_val = LDIM_RD_32Bits(reg_addr);
+ pr_info("reg_addr: 0x%x=0x%x\n", reg_addr, reg_val);
}
- reg_val = LDIM_RD_32Bits(reg_addr);
- pr_info("reg_addr:0x%x=0x%x\n",
- (unsigned int)reg_addr, (unsigned int)reg_val);
} else if (!strcmp(parm[0], "ws")) {
- unsigned long reg_addr = 0, reg_val = 0;
+ unsigned int reg_addr = 0, reg_val = 0;
- if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 16, ®_addr) < 0)
- goto ldim_attr_store_end;
- }
if (parm[2] != NULL) {
- if (kstrtoul(parm[2], 16, ®_val) < 0)
+ if (kstrtoul(parm[1], 16, &val1) < 0)
+ goto ldim_attr_store_end;
+ if (kstrtoul(parm[2], 16, &val2) < 0)
goto ldim_attr_store_end;
+ reg_addr = (unsigned int)val1;
+ reg_val = (unsigned int)val2;
+
+ LDIM_WR_32Bits(reg_addr, reg_val);
+ pr_info("reg_addr: 0x%x=0x%x, readback: 0x%x\n",
+ reg_addr, reg_val, LDIM_RD_32Bits(reg_addr));
}
- LDIM_WR_32Bits(reg_addr, reg_val);
- pr_info("reg_addr:0x%x=0x%x\n",
- (unsigned int)reg_addr, (unsigned int)reg_val);
} else if (!strcmp(parm[0], "update_matrix")) {
- unsigned long mode = 0;
+ unsigned int mode = 0;
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &mode) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ mode = (unsigned int)val1;
+
+ ldim_update_matrix(mode);
+ pr_info("mode: %d\n", mode);
}
- ldim_update_matrix(mode);
- pr_info("mode:%d\n", (unsigned int)mode);
+ } else if (!strcmp(parm[0], "bl_remap_curve")) {
+ ldim_bl_remap_curve_print();
} else if (!strcmp(parm[0], "fw_LD_Whist")) {
for (i = 0; i < 16; i++)
pr_info("(%d),", (unsigned int)fw_LD_Whist[i]);
if (parm[16] != NULL) {
if (kstrtoul(parm[1], 10, &fw_LD_Whist[0]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[2], 10, &fw_LD_Whist[1]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[3], 10, &fw_LD_Whist[2]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[4], 10, &fw_LD_Whist[3]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[5], 10, &fw_LD_Whist[4]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[6], 10, &fw_LD_Whist[5]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[7], 10, &fw_LD_Whist[6]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[8], 10, &fw_LD_Whist[7]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[9], 10, &fw_LD_Whist[8]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[10], 10, &fw_LD_Whist[9]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[11], 10, &fw_LD_Whist[10]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[12], 10, &fw_LD_Whist[11]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[13], 10, &fw_LD_Whist[12]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[14], 10, &fw_LD_Whist[13]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[15], 10, &fw_LD_Whist[14]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
if (kstrtoul(parm[16], 10, &fw_LD_Whist[15]) < 0)
- return -EINVAL;
+ goto ldim_attr_store_end;
+
+ for (i = 0; i < 16; i++)
+ pr_info("(%d),", (unsigned int)fw_LD_Whist[i]);
+ pr_info("\n********fw_LD_Whist ok*********\n");
}
- for (i = 0; i < 16; i++)
- pr_info("(%d),", (unsigned int)fw_LD_Whist[i]);
- pr_info("\n********fw_LD_Whist ok*********\n");
+ } else if (!strcmp(parm[0], "Sf_bypass")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ Sf_bypass = (unsigned char)val1;
+ }
+ pr_info("Sf_bypass = %d\n", Sf_bypass);
+ } else if (!strcmp(parm[0], "Boost_light_bypass")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ Boost_light_bypass = (unsigned char)val1;
+ }
+ pr_info("Boost_light_bypass = %d\n", Boost_light_bypass);
+ } else if (!strcmp(parm[0], "Lpf_bypass")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ Lpf_bypass = (unsigned char)val1;
+ }
+ pr_info("Lpf_bypass = %d\n", Lpf_bypass);
+ } else if (!strcmp(parm[0], "Ld_remap_bypass")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ Ld_remap_bypass = (unsigned char)val1;
+ }
+ pr_info("Ld_remap_bypass = %d\n", Ld_remap_bypass);
+ } else if (!strcmp(parm[0], "slp_gain")) {
+ unsigned int slop_gain = 0;
+
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+
+ slop_gain = (unsigned int)val1;
+ ldim_bl_remap_curve(slop_gain);
+ pr_info("slp_gain = %d\n", slop_gain);
+ ldim_bl_remap_curve_print();
+ }
+ } else if (!strcmp(parm[0], "ov_gain")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ ov_gain = (unsigned int)val1;
+ }
+ pr_info("ov_gain = %d\n", ov_gain);
+ } else if (!strcmp(parm[0], "incr_dif_gain")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ incr_dif_gain = (unsigned int)val1;
+ }
+ pr_info("incr_dif_gain = %d\n", incr_dif_gain);
+ } else if (!strcmp(parm[0], "litgain")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &litgain) < 0)
+ goto ldim_attr_store_end;
+ }
+ pr_info("litgain = %ld\n", litgain);
+ } else if (!strcmp(parm[0], "brightness_bypass")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ ldim_brightness_bypass = (unsigned char)val1;
+ if (ldim_brightness_bypass == 0)
+ ldim_set_level(ldim_brightness_level);
+ }
+ pr_info("brightness_bypass = %d\n", ldim_brightness_bypass);
} else if (!strcmp(parm[0], "fw_LD_ThSF_l")) {
- pr_info("now fw_LD_ThSF_1 = %ld\n", fw_LD_ThSF_l);
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &fw_LD_ThSF_l) < 0)
goto ldim_attr_store_end;
}
- pr_info("set fw_LD_ThSF_l=%ld\n", fw_LD_ThSF_l);
+ pr_info("fw_LD_ThSF_l = %ld\n", fw_LD_ThSF_l);
} else if (!strcmp(parm[0], "fw_LD_ThTF_l")) {
- pr_info("now fw_LD_ThTF_l = %ld\n", fw_LD_ThTF_l);
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &fw_LD_ThTF_l) < 0)
goto ldim_attr_store_end;
}
- pr_info("set fw_LD_ThTF_l=%ld\n", fw_LD_ThTF_l);
- } else if (!strcmp(parm[0], "rgb_base")) {
+ pr_info("fw_LD_ThTF_l = %ld\n", fw_LD_ThTF_l);
+ } else if (!strcmp(parm[0], "boost_gain")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &rgb_base) < 0)
+ if (kstrtoul(parm[1], 10, &boost_gain) < 0)
+ goto ldim_attr_store_end;
+ }
+ pr_info("boost_gain = %ld\n", boost_gain);
+#if (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V1)
+ } else if (!strcmp(parm[0], "boost_gain_neg")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &boost_gain_neg) < 0)
goto ldim_attr_store_end;
}
- pr_info("set rgb_base=%ld\n", rgb_base);
+ pr_info("boost_gain_neg = %ld\n", boost_gain_neg);
+ } else if (!strcmp(parm[0], "alpha_delta")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &alpha_delta) < 0)
+ goto ldim_attr_store_end;
+ }
+ pr_info("alpha_delta = %ld\n", alpha_delta);
+#elif (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V0)
+ } else if (!strcmp(parm[0], "TF_alpha")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &TF_alpha) < 0)
+ goto ldim_attr_store_end;
+ }
+ pr_info("TF_alpha = %ld\n", TF_alpha);
} else if (!strcmp(parm[0], "lpf_gain")) {
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &lpf_gain) < 0)
goto ldim_attr_store_end;
}
- pr_info("set lpf_gain=%ld\n", lpf_gain);
+ pr_info("lpf_gain = %ld\n", lpf_gain);
} else if (!strcmp(parm[0], "lpf_res")) {
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &lpf_res) < 0)
goto ldim_attr_store_end;
}
- pr_info("set lpf_res=%ld\n", lpf_res);
- } else if (!strcmp(parm[0], "Sf_bypass")) {
+ pr_info("lpf_res = %ld\n", lpf_res);
+ } else if (!strcmp(parm[0], "rgb_base")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &Sf_bypass) < 0)
+ if (kstrtoul(parm[1], 10, &rgb_base) < 0)
goto ldim_attr_store_end;
}
- pr_info("set Sf_bypass=%ld\n", Sf_bypass);
- } else if (!strcmp(parm[0], "Boost_light_bypass")) {
+ pr_info("rgb_base = %ld\n", rgb_base);
+#endif
+ } else if (!strcmp(parm[0], "avg_gain")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &Boost_light_bypass) < 0)
+ if (kstrtoul(parm[1], 10, &avg_gain) < 0)
goto ldim_attr_store_end;
}
- pr_info("set Boost_light_bypass=%ld\n", Boost_light_bypass);
- } else if (!strcmp(parm[0], "Lpf_bypass")) {
+ pr_info("avg_gain = %ld\n", avg_gain);
+ } else if (!strcmp(parm[0], "fw_rgb_diff_th")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &Lpf_bypass) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ fw_rgb_diff_th = (unsigned int)val1;
}
- pr_info("set Lpf_bypass=%ld\n", Lpf_bypass);
- } else if (!strcmp(parm[0], "Ld_remap_bypass")) {
+ pr_info("fw_rgb_diff_th = %d\n", fw_rgb_diff_th);
+ } else if (!strcmp(parm[0], "max_luma")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &Ld_remap_bypass) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ max_luma = (unsigned int)val1;
}
- pr_info("set Ld_remap_bypass=%ld\n", Ld_remap_bypass);
- } else if (!strcmp(parm[0], "slp_gain")) {
- unsigned int slop_gain;
-
+ pr_info("max_luma = %d\n", max_luma);
+ } else if (!strcmp(parm[0], "lmh_avg_TH")) {
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ lmh_avg_TH = (unsigned int)val1;
}
- slop_gain = (unsigned int)val1;
- ldim_bl_remap_curve(slop_gain);
- ldim_bl_remap_curve_print();
- pr_info("set slp_gain=%d\n", slop_gain);
- } else if (!strcmp(parm[0], "incr_con_en")) {
+ pr_info("lmh_avg_TH = %d\n", lmh_avg_TH);
+ } else if (!strcmp(parm[0], "fw_TF_sum_th")) {
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ fw_TF_sum_th = (unsigned int)val1;
}
- incr_con_en = (unsigned int)val1;
- pr_info("set incr_con_en=%d\n", incr_con_en);
- } else if (!strcmp(parm[0], "ov_gain")) {
+ pr_info("fw_TF_sum_th = %d\n", fw_TF_sum_th);
+ } else if (!strcmp(parm[0], "LPF_method")) {
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ LPF_method = (unsigned int)val1;
}
- ov_gain = (unsigned int)val1;
- pr_info("set ov_gain=%d\n", ov_gain);
- } else if (!strcmp(parm[0], "incr_dif_gain")) {
+ pr_info("LPF_method = %d\n", LPF_method);
+ } else if (!strcmp(parm[0], "LD_TF_STEP_TH")) {
if (parm[1] != NULL) {
if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ LD_TF_STEP_TH = (unsigned int)val1;
}
- incr_dif_gain = (unsigned int)val1;
- pr_info("set incr_dif_gain=%d\n", incr_dif_gain);
- } else if (!strcmp(parm[0], "litgain")) {
+ pr_info("LD_TF_STEP_TH = %d\n", LD_TF_STEP_TH);
+ } else if (!strcmp(parm[0], "TF_step_method")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &litgain) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ TF_step_method = (unsigned int)val1;
}
- pr_info("set litgain=%ld\n", litgain);
- } else if (!strcmp(parm[0], "boost_gain")) {
- pr_info("now boost_gain = %ld\n", boost_gain);
+ pr_info("TF_step_method = %d\n", TF_step_method);
+ } else if (!strcmp(parm[0], "TF_FRESH_BL")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &boost_gain) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ TF_FRESH_BL = (unsigned int)val1;
}
- pr_info("set boost_gain=%ld\n", boost_gain);
- } else if (!strcmp(parm[0], "alpha")) {
- pr_info("now alpha = %ld\n", alpha);
+ pr_info("TF_FRESH_BL = %d\n", TF_FRESH_BL);
+ } else if (!strcmp(parm[0], "TF_BLK_FRESH_BL")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &alpha) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ TF_BLK_FRESH_BL = (unsigned int)val1;
}
- pr_info("set alpha = %ld\n", alpha);
- } else if (!strcmp(parm[0], "alpha_delta")) {
- pr_info("now alpha_delta = %ld\n", alpha_delta);
+ pr_info("TF_BLK_FRESH_BL = %d\n", TF_BLK_FRESH_BL);
+ } else if (!strcmp(parm[0], "bbd_detect_en")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &alpha_delta) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ bbd_detect_en = (unsigned char)val1;
}
- pr_info("set alpha_delta = %ld\n", alpha_delta);
- } else if (!strcmp(parm[0], "boost_gain_neg")) {
- pr_info("now boost_gain_neg = %ld\n", boost_gain_neg);
+ pr_info("bbd_detect_en = %d\n", bbd_detect_en);
+ } else if (!strcmp(parm[0], "side_blk_diff_th")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &boost_gain_neg) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ side_blk_diff_th = (unsigned int)val1;
}
- pr_info("set boost_gain_neg = %ld\n", boost_gain_neg);
- } else if (!strcmp(parm[0], "Dbprint_lv")) {
+ pr_info("side_blk_diff_th = %d\n", side_blk_diff_th);
+ } else if (!strcmp(parm[0], "bbd_th")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &Dbprint_lv) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ bbd_th = (unsigned int)val1;
}
- pr_info("set Dbprint_lv=%ld\n", Dbprint_lv);
- } else if (!strcmp(parm[0], "avg_gain")) {
+ pr_info("bbd_th = %d\n", bbd_th);
+ } else if (!strcmp(parm[0], "diff_blk_luma_en")) {
if (parm[1] != NULL) {
- if (kstrtoul(parm[1], 10, &avg_gain) < 0)
+ if (kstrtoul(parm[1], 10, &val1) < 0)
goto ldim_attr_store_end;
+ diff_blk_luma_en = (unsigned char)val1;
}
- pr_info("set avg_gain=%ld\n", avg_gain);
+ pr_info("diff_blk_luma_en = %d\n", diff_blk_luma_en);
+ } else if (!strcmp(parm[0], "fw_hist_print")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ fw_hist_print = (unsigned char)val1;
+ }
+ pr_info("fw_hist_print = %d\n", fw_hist_print);
+ } else if (!strcmp(parm[0], "Debug")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ Debug = (unsigned char)val1;
+ }
+ pr_info("Debug = %d\n", Debug);
+ } else if (!strcmp(parm[0], "fw_print_frequent")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ fw_print_frequent = (unsigned int)val1;
+ }
+ pr_info("fw_print_frequent = %d\n", fw_print_frequent);
+ } else if (!strcmp(parm[0], "Dbprint_lv")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ Dbprint_lv = (unsigned int)val1;
+ }
+ pr_info("Dbprint_lv = %d\n", Dbprint_lv);
+ } else if (!strcmp(parm[0], "alg_para")) {
+ pr_info("ldim_alg_ver = %s\n",
+ LD_FW_ALG_FRM_VER);
+#if (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V1)
+ pr_info("fw_LD_ThSF_l = %ld\n"
+ "fw_LD_ThTF_l = %ld\n"
+ "boost_gain = %ld\n"
+ "boost_gain_neg = %ld\n"
+ "alpha_delta = %ld\n\n",
+ fw_LD_ThSF_l,
+ fw_LD_ThTF_l,
+ boost_gain,
+ boost_gain_neg,
+ alpha_delta);
+#elif (LD_FW_ALG_FRM_SEL == LD_FW_ALG_FRM_V0)
+ pr_info("fw_LD_ThSF_l = %ld\n"
+ "fw_LD_ThTF_l = %ld\n"
+ "boost_gain = %ld\n"
+ "TF_alpha = %ld\n"
+ "lpf_gain = %ld\n"
+ "lpf_res = %ld\n"
+ "rgb_base = %ld\n\n",
+ fw_LD_ThSF_l,
+ fw_LD_ThTF_l,
+ boost_gain,
+ TF_alpha,
+ lpf_gain,
+ lpf_res,
+ rgb_base);
+#endif
+ pr_info("fw_rgb_diff_th = %d\n"
+ "max_luma = %d\n"
+ "lmh_avg_TH = %d\n"
+ "fw_TF_sum_th = %d\n"
+ "LPF_method = %d\n"
+ "LD_TF_STEP_TH = %d\n"
+ "TF_step_method = %d\n"
+ "TF_FRESH_BL = %d\n\n",
+ fw_rgb_diff_th,
+ max_luma,
+ lmh_avg_TH,
+ fw_TF_sum_th,
+ LPF_method,
+ LD_TF_STEP_TH,
+ TF_step_method,
+ TF_FRESH_BL);
+ pr_info("TF_BLK_FRESH_BL = %d\n"
+ "side_blk_diff_th = %d\n"
+ "bbd_th = %d\n"
+ "bbd_detect_en = %d\n"
+ "diff_blk_luma_en = %d\n\n",
+ TF_BLK_FRESH_BL,
+ side_blk_diff_th,
+ bbd_th,
+ bbd_detect_en,
+ diff_blk_luma_en);
+ pr_info("ov_gain = %d\n"
+ "incr_dif_gain = %d\n"
+ "avg_gain = %ld\n"
+ "litgain = %ld\n\n",
+ ov_gain,
+ incr_dif_gain,
+ avg_gain,
+ litgain);
+ pr_info("Sf_bypass = %d\n"
+ "Boost_light_bypass = %d\n"
+ "Lpf_bypass = %d\n"
+ "Ld_remap_bypass = %d\n\n",
+ Sf_bypass,
+ Boost_light_bypass,
+ Lpf_bypass,
+ Ld_remap_bypass);
+ pr_info("fw_hist_print = %d\n"
+ "Debug = %d\n"
+ "fw_print_frequent = %d\n"
+ "Dbprint_lv = %d\n\n",
+ fw_hist_print,
+ Debug,
+ fw_print_frequent,
+ Dbprint_lv);
} else if (!strcmp(parm[0], "info")) {
+ pr_info("ldim_drv_ver = %s\n",
+ LDIM_DRV_VER);
ldim_driver.config_print();
pr_info("\nldim_blk_row = %d\n"
"ldim_blk_col = %d\n"
"ldim_hist_row = %d\n"
"ldim_hist_col = %d\n"
"ldim_bl_mode = %d\n"
- "dev_index = %d\n",
+ "dev_index = %d\n\n",
ldim_blk_row, ldim_blk_col,
ldim_hist_row, ldim_hist_col,
ldim_config.bl_mode,
ldim_driver.dev_index);
- pr_info("\nldim_on_flag = %d\n"
+ pr_info("ldim_on_flag = %d\n"
"ldim_func_en = %d\n"
"ldim_remap_en = %d\n"
"ldim_func_bypass = %d\n"
"nPRM.reg_LD_pic_ColMax = %d\n",
nPRM.reg_LD_BLK_Hnum, nPRM.reg_LD_BLK_Vnum,
nPRM.reg_LD_pic_RowMax, nPRM.reg_LD_pic_ColMax);
+ } else if (!strcmp(parm[0], "print")) {
+ if (parm[1] != NULL) {
+ if (kstrtoul(parm[1], 10, &val1) < 0)
+ goto ldim_attr_store_end;
+ ldim_debug_print = (unsigned char)val1;
+ }
+ pr_info("ldim_debug_print = %d\n", ldim_debug_print);
} else
pr_info("no support cmd!!!\n");
kfree(ldim_driver.ldim_matrix_buf);
err0:
return -1;
-
}
int aml_ldim_probe(struct platform_device *pdev)
{
int ret = 0;
unsigned int i;
- unsigned int ldim_irq = 0, rdma_irq = 0;
+ unsigned int ldim_vsync_irq = 0, ldim_rdma_irq = 0;
struct ldim_dev_s *devp = &ldim_dev;
struct aml_bl_drv_s *bl_drv = aml_bl_get_driver();
ldim_test_en = 0;
ldim_brightness_level = 0;
- ldim_data_min = LD_DATA_MIN;
ldim_level_update = 0;
/* alg flag */
ldim_alg_en = 0;
ldim_top_en = 0;
ldim_hist_en = 0;
- avg_gain = LD_DATA_MAX;
- invalid_val_cnt = 0;
Dbprint_lv = 0;
db_cnt = 0;
spin_lock_init(&ldim_isr_lock);
spin_lock_init(&rdma_ldim_isr_lock);
- bl_drv->res_ldim_irq = platform_get_resource(pdev,
- IORESOURCE_IRQ, 0);
- if (!bl_drv->res_ldim_irq) {
+ bl_drv->res_ldim_vsync_irq =
+ platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ if (!bl_drv->res_ldim_vsync_irq) {
ret = -ENODEV;
+ LDIMERR("ldim_vsync_irq resource error\n");
goto err;
- } else {
- ldim_irq = bl_drv->res_ldim_irq->start;
- LDIMPR("ldim_irq: %d\n", ldim_irq);
- if (request_irq(ldim_irq, ldim_vsync_isr, IRQF_SHARED,
- "ldim_vsync", (void *)"ldim_vsync"))
- LDIMERR("can't request ldim_irq\n");
- else
- LDIMPR("request ldim_irq successful\n");
}
+ ldim_vsync_irq = bl_drv->res_ldim_vsync_irq->start;
+ LDIMPR("ldim_vsync_irq: %d\n", ldim_vsync_irq);
+ if (request_irq(ldim_vsync_irq, ldim_vsync_isr, IRQF_SHARED,
+ "ldim_vsync", (void *)"ldim_vsync"))
+ LDIMERR("can't request ldim_vsync_irq\n");
+ else
+ LDIMPR("request ldim_vsync_irq successful\n");
switch (bl_drv->data->chip_type) {
case BL_CHIP_GXTVBB:
- bl_drv->res_rdma_irq = platform_get_resource(pdev,
+ bl_drv->res_ldim_rdma_irq = platform_get_resource(pdev,
IORESOURCE_IRQ, 1);
- if (!bl_drv->res_rdma_irq) {
+ if (!bl_drv->res_ldim_rdma_irq) {
ret = -ENODEV;
+ LDIMERR("ldim_rdma_irq resource error\n");
goto err;
- } else {
- rdma_irq = bl_drv->res_rdma_irq->start;
- LDIMPR("rdma_irq: %d\n", rdma_irq);
-
- if (request_irq(rdma_irq, rdma_ldim_intr, IRQF_SHARED,
- "rdma_ldim", (void *)"rdma_ldim"))
- LDIMERR("can't request rdma_ldim\n");
- else
- LDIMPR("request rdma_ldim successful\n");
}
+ ldim_rdma_irq = bl_drv->res_ldim_rdma_irq->start;
+ LDIMPR("ldim_rdma_irq: %d\n", ldim_rdma_irq);
+ if (request_irq(ldim_rdma_irq, rdma_ldim_intr, IRQF_SHARED,
+ "ldim_rdma", (void *)"ldim_rdma"))
+ LDIMERR("can't request ldim_rdma_irq\n");
+ else
+ LDIMPR("request ldim_rdma_irq successful\n");
break;
- case BL_CHIP_TXLX:
default:
break;
}
kfree(ldim_driver.ldim_test_matrix);
kfree(ldim_driver.local_ldim_matrix);
- free_irq(bl_drv->res_rdma_irq->start, (void *)"rdma_ldim");
- free_irq(bl_drv->res_ldim_irq->start, (void *)"ldim_vsync");
+ free_irq(bl_drv->res_ldim_rdma_irq->start, (void *)"ldim_rdma");
+ free_irq(bl_drv->res_ldim_vsync_irq->start, (void *)"ldim_vsync");
cdev_del(devp->aml_ldim_cdevp);
kfree(devp->aml_ldim_cdevp);