From 09849e0f33c1dafb23de20d6d48b6ca98abbc179 Mon Sep 17 00:00:00 2001 From: MingLiang Dong Date: Sat, 16 Feb 2019 02:10:38 -0500 Subject: [PATCH] amvecm: remove driver lc setting by timing [1/1] PD#SWPL-5248 Problem: lc setting load from db Solution: remove driver lc setting by timing Verify: verify on TL1 Change-Id: I7dac2429220d31f7930087ffb01176863cd74453 Signed-off-by: MingLiang Dong --- .../media/enhancement/amvecm/local_contrast.c | 139 ++++++++++++++++----- .../media/enhancement/amvecm/local_contrast.h | 2 + 2 files changed, 111 insertions(+), 30 deletions(-) diff --git a/drivers/amlogic/media/enhancement/amvecm/local_contrast.c b/drivers/amlogic/media/enhancement/amvecm/local_contrast.c index cb792d8..39a36af 100644 --- a/drivers/amlogic/media/enhancement/amvecm/local_contrast.c +++ b/drivers/amlogic/media/enhancement/amvecm/local_contrast.c @@ -80,30 +80,41 @@ struct ve_lc_curve_parm_s lc_curve_parm_load; struct lc_alg_param_s lc_alg_parm; /*lc saturation gain, low parameters*/ -static unsigned int lc_satur_gain[63] = { - 51, 104, 158, 213, 269, 325, 382, 440, 498, - 556, 615, 674, 734, 794, 854, 915, 976, 1037, - 1099, 1161, 1223, 1286, 1348, 1411, 1475, 1538, - 1602, 1666, 1730, 1795, 1859, 1924, 1989, 2054, - 2120, 2186, 2251, 2318, 2384, 2450, 2517, 2584, - 2651, 2718, 2785, 2853, 2921, 2988, 3057, 3125, - 3193, 3262, 3330, 3399, 3468, 3537, 3607, 3676, - 3746, 3815, 3885, 3955, 4026 +/*static unsigned int lc_satur_gain[63] = { + * 51, 104, 158, 213, 269, 325, 382, 440, 498, + * 556, 615, 674, 734, 794, 854, 915, 976, 1037, + * 1099, 1161, 1223, 1286, 1348, 1411, 1475, 1538, + * 1602, 1666, 1730, 1795, 1859, 1924, 1989, 2054 + * 2120, 2186, 2251, 2318, 2384, 2450, 2517, 2584, + * 2651, 2718, 2785, 2853, 2921, 2988, 3057, 3125, + * 3193, 3262, 3330, 3399, 3468, 3537, 3607, 3676, + * 3746, 3815, 3885, 3955, 4026 + *}; + */ + +/*lc saturation gain, off parameters*/ +static unsigned int lc_satur_off[63] = { + 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, + 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, + 1280, 1344, 1408, 1472, 1536, 1600, 1664, 1728, + 1792, 1856, 1920, 1984, 2048, 2112, 2176, 2240, + 2304, 2368, 2432, 2496, 2560, 2624, 2688, 2752, + 2816, 2880, 2944, 3008, 3072, 3136, 3200, 3264, + 3328, 3392, 3456, 3520, 3584, 3648, 3712, 3776, + 3840, 3904, 3968, 4032 }; /*lc saturation gain, low parameters*/ -/* - *static unsigned int lc_satur_off[63] = { - * 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, - * 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, - * 1280, 1344, 1408, 1472, 1536, 1600, 1664, 1728, - * 1792, 1856, 1920, 1984, 2048, 2112, 2176, 2240, - * 2304, 2368, 2432, 2496, 2560, 2624, 2688, 2752, - * 2816, 2880, 2944, 3008, 3072, 3136, 3200, 3264, - * 3328, 3392, 3456, 3520, 3584, 3648, 3712, 3776, - * 3840, 3904, 3968, 4032 - *}; - */ +/*static unsigned int lc_satur_low[63] = {*/ +/* 84, 167, 249, 330, 411, 490, 568, 646, 723, 798,*/ +/* 873, 947, 1020, 1092, 1163, 1234, 1303, 1372, 1440,*/ +/* 1506, 1572, 1638, 1702, 1766, 1828, 1890, 1951,*/ +/* 2011, 2071, 2130, 2187, 2245, 2301, 2356, 2411,*/ +/* 2465, 2518, 2571, 2623, 2674, 2724, 2774, 2822,*/ +/* 2871, 2919, 2967, 3016, 3065, 3115, 3165, 3217,*/ +/* 3271, 3326, 3384, 3443, 3506, 3571, 3639, 3710,*/ +/* 3785, 3863, 3945, 4032*/ +/*};*/ /*local contrast begin*/ static void lc_mtx_set(enum lc_mtx_sel_e mtx_sel, @@ -164,7 +175,7 @@ static void lc_mtx_set(enum lc_mtx_sel_e mtx_sel, return; switch (mtx_csc) { - case LC_MTX_RGB_YUV709L: + case LC_MTX_RGB_YUV601L: if (mtx_sel & (INP_MTX | OUTP_MTX)) { WRITE_VPP_REG(matrix_coef00_01, 0x1070204); WRITE_VPP_REG(matrix_coef02_10, 0x640f68); @@ -184,7 +195,7 @@ static void lc_mtx_set(enum lc_mtx_sel_e mtx_sel, WRITE_VPP_REG(matrix_pre_offset2, 0x0); } break; - case LC_MTX_YUV709L_RGB: + case LC_MTX_YUV601L_RGB: if (mtx_sel & (INP_MTX | OUTP_MTX)) { WRITE_VPP_REG(matrix_coef00_01, 0x012a0000); WRITE_VPP_REG(matrix_coef02_10, 0x198012a); @@ -204,6 +215,46 @@ static void lc_mtx_set(enum lc_mtx_sel_e mtx_sel, WRITE_VPP_REG(matrix_pre_offset2, 0x00000600); } break; + case LC_MTX_RGB_YUV709L: + if (mtx_sel & (INP_MTX | OUTP_MTX)) { + WRITE_VPP_REG(matrix_coef00_01, 0xba0273); + WRITE_VPP_REG(matrix_coef02_10, 0x3f0f9a); + WRITE_VPP_REG(matrix_coef11_12, 0xea701c0); + WRITE_VPP_REG(matrix_coef20_21, 0x1c00e6a); + WRITE_VPP_REG(matrix_coef22, 0xfd7); + WRITE_VPP_REG(matrix_offset0_1, 0x00400200); + } else if (mtx_sel & STAT_MTX) { + WRITE_VPP_REG(matrix_coef00_01, 0x00bb0275); + WRITE_VPP_REG(matrix_coef02_10, 0x003f1f99); + WRITE_VPP_REG(matrix_coef11_12, 0x1ea601c2); + WRITE_VPP_REG(matrix_coef20_21, 0x01c21e67); + WRITE_VPP_REG(matrix_coef22, 0x00001fd7); + WRITE_VPP_REG(matrix_offset0_1, 0x00400200); + WRITE_VPP_REG(matrix_offset2, 0x00000200); + WRITE_VPP_REG(matrix_pre_offset0_1, 0x0); + WRITE_VPP_REG(matrix_pre_offset2, 0x0); + } + break; + case LC_MTX_YUV709L_RGB: + if (mtx_sel & (INP_MTX | OUTP_MTX)) { + WRITE_VPP_REG(matrix_coef00_01, 0x12b0000); + WRITE_VPP_REG(matrix_coef02_10, 0x1cc012b); + WRITE_VPP_REG(matrix_coef11_12, 0xfc90f77); + WRITE_VPP_REG(matrix_coef20_21, 0x12b021f); + WRITE_VPP_REG(matrix_coef22, 0x0); + WRITE_VPP_REG(matrix_pre_offset0_1, 0x00400200); + } else if (mtx_sel & STAT_MTX) { + WRITE_VPP_REG(matrix_coef00_01, 0x04A80000); + WRITE_VPP_REG(matrix_coef02_10, 0x072C04A8); + WRITE_VPP_REG(matrix_coef11_12, 0x1F261DDD); + WRITE_VPP_REG(matrix_coef20_21, 0x04A80876); + WRITE_VPP_REG(matrix_coef22, 0x0); + WRITE_VPP_REG(matrix_offset0_1, 0x0); + WRITE_VPP_REG(matrix_offset2, 0x0); + WRITE_VPP_REG(matrix_pre_offset0_1, 0x7c00600); + WRITE_VPP_REG(matrix_pre_offset2, 0x00000600); + } + break; case LC_MTX_NULL: if (mtx_sel & (INP_MTX | OUTP_MTX)) { WRITE_VPP_REG(matrix_coef00_01, 0x04000000); @@ -213,7 +264,15 @@ static void lc_mtx_set(enum lc_mtx_sel_e mtx_sel, WRITE_VPP_REG(matrix_coef22, 0x400); WRITE_VPP_REG(matrix_offset0_1, 0x0); } else if (mtx_sel & STAT_MTX) { - + WRITE_VPP_REG(matrix_coef00_01, 0x04000000); + WRITE_VPP_REG(matrix_coef02_10, 0x0); + WRITE_VPP_REG(matrix_coef11_12, 0x04000000); + WRITE_VPP_REG(matrix_coef20_21, 0x0); + WRITE_VPP_REG(matrix_coef22, 0x400); + WRITE_VPP_REG(matrix_offset0_1, 0x0); + WRITE_VPP_REG(matrix_offset2, 0x0); + WRITE_VPP_REG(matrix_pre_offset0_1, 0x0); + WRITE_VPP_REG(matrix_pre_offset2, 0x0); } break; default: @@ -469,6 +528,14 @@ static void lc_config(int enable, vf_height = vf->height; vf_width = vf->width; + if (vf_height < 720) { + lc_mtx_set(INP_MTX, LC_MTX_YUV709L_RGB, 1); + lc_mtx_set(OUTP_MTX, LC_MTX_RGB_YUV709L, 1); + } else { + lc_mtx_set(INP_MTX, LC_MTX_YUV709L_RGB, 1); + lc_mtx_set(OUTP_MTX, LC_MTX_RGB_YUV709L, 1); + } + lc_top_config(enable, h_num, v_num, height, width); if (sps_h_en == 1) @@ -1182,18 +1249,30 @@ void lc_init(void) WRITE_VPP_REG(LC_CURVE_CONTRAST_LH, 0x000b000b); WRITE_VPP_REG(LC_CURVE_CONTRAST_SCL_LH, 0x00000b0b); WRITE_VPP_REG(LC_CURVE_MISC0, 0x00023028); - WRITE_VPP_REG(LC_CURVE_YPKBV_RAT, 0x3e69443c); - WRITE_VPP_REG(LC_CURVE_YPKBV_SLP_LMT, 0x00000b33); - WRITE_VPP_REG(LC_CURVE_YPKBV_YMAXVAL_LMT_0_1, 0x00440088); + WRITE_VPP_REG(LC_CURVE_YPKBV_RAT, 0x8cc0c060); + WRITE_VPP_REG(LC_CURVE_YPKBV_SLP_LMT, 0x00000b3a); + + WRITE_VPP_REG(LC_CURVE_YMINVAL_LMT_0_1, 0x0030005d); + WRITE_VPP_REG(LC_CURVE_YMINVAL_LMT_2_3, 0x00830091); + WRITE_VPP_REG(LC_CURVE_YMINVAL_LMT_4_5, 0x00a000c4); + WRITE_VPP_REG(LC_CURVE_YMINVAL_LMT_6_7, 0x00e00100); + WRITE_VPP_REG(LC_CURVE_YMINVAL_LMT_8_9, 0x01200140); + WRITE_VPP_REG(LC_CURVE_YMINVAL_LMT_10_11, 0x01600190); + + WRITE_VPP_REG(LC_CURVE_YPKBV_YMAXVAL_LMT_0_1, 0x004400b4); + WRITE_VPP_REG(LC_CURVE_YPKBV_YMAXVAL_LMT_2_3, 0x00fb0123); + WRITE_VPP_REG(LC_CURVE_YPKBV_YMAXVAL_LMT_4_5, 0x015901a2); + WRITE_VPP_REG(LC_CURVE_YPKBV_YMAXVAL_LMT_6_7, 0x01d90208); + WRITE_VPP_REG(LC_CURVE_YPKBV_YMAXVAL_LMT_8_9, 0x02400280); WRITE_VPP_REG(LC_CURVE_YPKBV_YMAXVAL_LMT_10_11, 0x02d70310); for (i = 0; i < 31 ; i++) { - tmp1 = *(lc_satur_gain + 2 * i); - tmp2 = *(lc_satur_gain + 2 * i + 1); + tmp1 = *(lc_satur_off + 2 * i); + tmp2 = *(lc_satur_off + 2 * i + 1); tmp = ((tmp1 & 0xfff)<<16) | (tmp2 & 0xfff); WRITE_VPP_REG(SRSHARP1_LC_SAT_LUT_0_1 + i, tmp); } - tmp = (*(lc_satur_gain + 62)) & 0xfff; + tmp = (*(lc_satur_off + 62)) & 0xfff; WRITE_VPP_REG(SRSHARP1_LC_SAT_LUT_62, tmp); /*end*/ diff --git a/drivers/amlogic/media/enhancement/amvecm/local_contrast.h b/drivers/amlogic/media/enhancement/amvecm/local_contrast.h index 9a27ace..3dcf9b8 100644 --- a/drivers/amlogic/media/enhancement/amvecm/local_contrast.h +++ b/drivers/amlogic/media/enhancement/amvecm/local_contrast.h @@ -36,6 +36,8 @@ enum lc_mtx_csc_e { LC_MTX_NULL = 0, LC_MTX_YUV709L_RGB = 0x1, LC_MTX_RGB_YUV709L = 0x2, + LC_MTX_YUV601L_RGB = 0x3, + LC_MTX_RGB_YUV601L = 0x4, LC_MTX_MAX }; -- 2.7.4