From: Jihong Sui Date: Wed, 12 Dec 2018 09:02:09 +0000 (+0800) Subject: deinterlace: pq: add scene change detection for tl1 [1/1] X-Git-Tag: hardkernel-4.9.236-104~1979 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=92eb8a32b613524b9711e3eb9eb5d0a5d33d3ebe;p=platform%2Fkernel%2Flinux-amlogic.git deinterlace: pq: add scene change detection for tl1 [1/1] PD#TV-1361 Problem: Add scene change detection for DM (read part), start from TL1 by VLSI(Zheng.Bao). Solution: 1. add control in function noise_meter_process; 2. add debug information: cat /sys/class/deinterlace/di0/nr4_param 3. set NR2_CUE_MODE[11:10] as 3; (by feijun) Verify: tl1 Change-Id: Ib34d1b403539ba5fe5135d6608bfa2cf27490826 Signed-off-by: Jihong Sui --- diff --git a/drivers/amlogic/media/deinterlace/deinterlace.c b/drivers/amlogic/media/deinterlace/deinterlace.c index 8039a08..3fece28 100644 --- a/drivers/amlogic/media/deinterlace/deinterlace.c +++ b/drivers/amlogic/media/deinterlace/deinterlace.c @@ -6210,6 +6210,7 @@ static void di_reg_process_irq(void) vframe->sig_fmt); di_patch_post_update_mc_sw(DI_MC_SW_REG, true); + cue_int(); if (de_devp->flags & DI_LOAD_REG_FLAG) up(&di_sema); init_flag = 1; diff --git a/drivers/amlogic/media/deinterlace/nr_drv.c b/drivers/amlogic/media/deinterlace/nr_drv.c index b1d7275..73c91cf 100644 --- a/drivers/amlogic/media/deinterlace/nr_drv.c +++ b/drivers/amlogic/media/deinterlace/nr_drv.c @@ -510,6 +510,18 @@ static void noise_meter_process(struct NR4_PARM_s *nr4_param_p, } else val1 = 64; DI_Wr_reg_bits(NR4_MCNR_MV_CTRL_REG, val1, 4, 8); + /*add for TL1------*/ + if (nr4_param_p->sw_nr4_noise_ctrl_dm_en == 1) { + if (nr4_param_p->sw_nr4_noise_sel == 0) { + val2 = val1 >= nr4_param_p->sw_nr4_noise_thd ? 1 : 0; + } else { + val2 = + field_sad >= nr4_param_p->sw_nr4_noise_thd ? 1 : 0; + } + + DI_Wr_reg_bits(DNR_DM_NR_BLND, val2, 24, 1); + } + /*------------------*/ /* scene change processing */ nr4_param_p->sw_nr4_scene_change_flg[0] = nr4_param_p->sw_nr4_scene_change_flg[1]; @@ -530,6 +542,16 @@ static void noise_meter_process(struct NR4_PARM_s *nr4_param_p, DI_Wr_reg_bits(NR4_TOP_CTRL, 1, 0, 1); else DI_Wr_reg_bits(NR4_TOP_CTRL, 0, 0, 1); + + /*fot TL1 **************/ + if (nr4_param_p->sw_dm_scene_change_en == 1) { + val = field_sad >= nr4_param_p->sw_nr4_scene_change_thd2 + && nr4_param_p->sw_nr4_field_sad[1] + >= nr4_param_p->sw_nr4_scene_change_thd2; + + DI_Wr_reg_bits(DNR_DM_CTRL, val, 12, 1); + } + /***********************/ nr4_param_p->sw_nr4_field_sad[0] = nr4_param_p->sw_nr4_field_sad[1]; nr4_param_p->sw_nr4_field_sad[1] = field_sad; } @@ -573,15 +595,24 @@ static void dnr_process(struct DNR_PARM_s *pDnrPrm) #ifdef DNR_HV_SHIFT int ro_hbof_stat_cnt[32], ro_vbof_stat_cnt[32], i = 0; #endif + int ll, lr; + + if (is_meson_tl1_cpu()) { + ll = Rd(DNR_RO_GBS_STAT_LR); + lr = Rd(DNR_RO_GBS_STAT_LL); + } else { + ll = Rd(DNR_RO_GBS_STAT_LL); + lr = Rd(DNR_RO_GBS_STAT_LR); - if (ro_gbs_stat_lr != Rd(DNR_RO_GBS_STAT_LR) || - ro_gbs_stat_ll != Rd(DNR_RO_GBS_STAT_LL) || + } + if (ro_gbs_stat_lr != lr || + ro_gbs_stat_ll != ll || ro_gbs_stat_rr != Rd(DNR_RO_GBS_STAT_RR) || ro_gbs_stat_dif != Rd(DNR_RO_GBS_STAT_DIF) || ro_gbs_stat_cnt != Rd(DNR_RO_GBS_STAT_CNT)) { - ro_gbs_stat_lr = Rd(DNR_RO_GBS_STAT_LR); - ro_gbs_stat_ll = Rd(DNR_RO_GBS_STAT_LL); + ro_gbs_stat_lr = lr; + ro_gbs_stat_ll = ll; ro_gbs_stat_rr = Rd(DNR_RO_GBS_STAT_RR); ro_gbs_stat_dif = Rd(DNR_RO_GBS_STAT_DIF); ro_gbs_stat_cnt = Rd(DNR_RO_GBS_STAT_CNT); @@ -694,7 +725,13 @@ static void cue_process_irq(void) if (nr_param.frame_count == 5) Wr_reg_bits(NR2_CUE_MODE, 7, 0, 4); } - +void cue_int(void) +{ + if (cpu_after_eq(MESON_CPU_MAJOR_ID_G12A)) { + if (cue_en) + Wr_reg_bits(NR2_CUE_MODE, 3, 10, 2); + } +} static bool glb_fieldck_en = true; module_param_named(glb_fieldck_en, glb_fieldck_en, bool, 0644); @@ -942,6 +979,17 @@ static void nr4_params_init(struct NR4_PARM_s *nr4_parm_p) nr4_params[24].name = "nr4_debug"; nr4_params[24].addr = &(nr4_parm_p->nr4_debug); + nr4_params[25].name = "sw_nr4_noise_thd"; + nr4_params[25].addr = &(nr4_parm_p->sw_nr4_noise_thd); + nr4_params[26].name = "sw_nr4_noise_sel"; + nr4_params[26].addr = &(nr4_parm_p->sw_nr4_noise_sel); + nr4_params[27].name = "sw_nr4_noise_ctrl_dm_en"; + nr4_params[27].addr = &(nr4_parm_p->sw_nr4_noise_ctrl_dm_en); + nr4_params[28].name = "sw_nr4_scene_change_thd2"; + nr4_params[28].addr = &(nr4_parm_p->sw_nr4_scene_change_thd2); + nr4_params[29].name = "sw_dm_scene_change_en"; + nr4_params[29].addr = &(nr4_parm_p->sw_dm_scene_change_en); + }; static ssize_t nr4_param_store(struct device *dev, @@ -1020,6 +1068,20 @@ static void nr4_param_init(struct NR4_PARM_s *nr4_parm_p) nr4_parm_p->sw_nr4_sad2gain_lut[13] = 16; nr4_parm_p->sw_nr4_sad2gain_lut[14] = 14; nr4_parm_p->sw_nr4_sad2gain_lut[15] = 9; + + if (is_meson_tl1_cpu()) { + nr4_parm_p->sw_nr4_noise_thd = 32; + nr4_parm_p->sw_nr4_noise_sel = 0; + nr4_parm_p->sw_nr4_noise_ctrl_dm_en = 0; + nr4_parm_p->sw_nr4_scene_change_thd2 = 80; + nr4_parm_p->sw_dm_scene_change_en = 0; + } else { + nr4_parm_p->sw_nr4_noise_thd = 32; + nr4_parm_p->sw_nr4_noise_sel = 0; + nr4_parm_p->sw_nr4_noise_ctrl_dm_en = 0; + nr4_parm_p->sw_nr4_scene_change_thd2 = 80; + nr4_parm_p->sw_dm_scene_change_en = 0; + } } static void cue_param_init(struct CUE_PARM_s *cue_parm_p) diff --git a/drivers/amlogic/media/deinterlace/nr_drv.h b/drivers/amlogic/media/deinterlace/nr_drv.h index 0ec80d60..0d0c714 100644 --- a/drivers/amlogic/media/deinterlace/nr_drv.h +++ b/drivers/amlogic/media/deinterlace/nr_drv.h @@ -24,7 +24,7 @@ struct nr_param_s { int *addr; }; -#define NR4_PARAMS_NUM 25 +#define NR4_PARAMS_NUM (30) //25 #define dnr_param_t struct nr_param_s #define nr4_param_t struct nr_param_s @@ -68,6 +68,16 @@ struct NR4_PARM_s { unsigned short width; unsigned short height; unsigned short border_offset; + + unsigned int sw_nr4_noise_thd;//u8 + /*u1, 0: use nr4 global gain, 1: use field sad;*/ + unsigned int sw_nr4_noise_sel; + unsigned int sw_nr4_noise_ctrl_dm_en;//u1 + + /*u8, threshold for scene change*/ + unsigned int sw_nr4_scene_change_thd2; + /*u1, enable dm scene change check*/ + unsigned int sw_dm_scene_change_en; }; struct CUE_PARM_s { @@ -170,5 +180,8 @@ void nr_process_in_irq(void); void nr_all_config(unsigned short nCol, unsigned short nRow, unsigned short type); bool set_nr_ctrl_reg_table(unsigned int addr, unsigned int value); + +extern void cue_int(void); + #endif