From 979b07b481aba62fd679c32aed1ade224b032e08 Mon Sep 17 00:00:00 2001 From: "haitao.liu" Date: Fri, 28 Jun 2024 21:44:25 +0800 Subject: [PATCH] vdin: support slt test [1/1] PD#SWPL-175137 Problem: Need to support slt test Solution: add debug code for slt Verify: t5m Change-Id: I8be64d27669e41a609cecdb2026104488f7a4c07 Signed-off-by: haitao.liu --- drivers/media/vin/tvin/vdin/vdin_ctl.c | 5 ++ drivers/media/vin/tvin/vdin/vdin_debug.c | 59 +++++++++++++++++++++++- drivers/media/vin/tvin/vdin/vdin_drv.c | 45 ++++++++++++++++++ drivers/media/vin/tvin/vdin/vdin_drv.h | 9 ++++ 4 files changed, 117 insertions(+), 1 deletion(-) diff --git a/drivers/media/vin/tvin/vdin/vdin_ctl.c b/drivers/media/vin/tvin/vdin/vdin_ctl.c index 9cb715e7a..05b5bcfc6 100644 --- a/drivers/media/vin/tvin/vdin/vdin_ctl.c +++ b/drivers/media/vin/tvin/vdin/vdin_ctl.c @@ -4482,6 +4482,11 @@ void vdin_calculate_duration(struct vdin_dev_s *devp) if (abs(duration_diff) > VDIN_DURATION_FILTER_VALUE) curr_wr_vf->duration = devp->duration; } + if (vdin_isr_monitor & VDIN_ISR_MONITOR_VF) + pr_info("vdin%d,[%d,%d] duration:%d %d,fps:%d %d,cycle:%d\n", + devp->index, devp->irq_cnt, devp->frame_cnt, + devp->duration, curr_wr_vf->duration, + devp->parm.info.fps, devp->prop.fps, devp->cycle); if (devp->index) curr_wr_vf->duration = devp->duration; diff --git a/drivers/media/vin/tvin/vdin/vdin_debug.c b/drivers/media/vin/tvin/vdin/vdin_debug.c index c84783a95..ae1bdf2cc 100644 --- a/drivers/media/vin/tvin/vdin/vdin_debug.c +++ b/drivers/media/vin/tvin/vdin/vdin_debug.c @@ -3426,7 +3426,9 @@ start_chk: pr_info("t3x vf crc:0x%x\n", rd(devp->addr_offset, VDIN0_PP_CRC_OUT)); else #endif - pr_info("vf crc:0x%x\n", rd(devp->addr_offset, VDIN_RO_CRC)); + pr_info("ro crc:0x%x\n", rd(devp->addr_offset, VDIN_RO_CRC)); + if (devp->vfp && devp->vfp->last_last_vfe) + pr_info("vf crc:0x%x\n", devp->vfp->last_last_vfe->vf.crc); } else if (!strcmp(parm[0], "game_mode")) { if (parm[1] && (kstrtouint(parm[1], 16, &temp) == 0)) { if (temp) { @@ -4194,6 +4196,59 @@ static ssize_t input_rate_show(struct device *dev, } static DEVICE_ATTR_RO(input_rate); +ssize_t slt_test_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + char *buf_orig, *parm[48] = {NULL}; + struct vdin_dev_s *devp = dev_get_drvdata(dev); + long val = 0; + + if (!buf) + return len; + + buf_orig = kstrdup(buf, GFP_KERNEL); + vdin_parse_param(buf_orig, (char **)&parm); + + if (!strcmp(parm[0], "set_crc")) { + if (!parm[1]) { + pr_err("miss parameters .\n"); + } else if (kstrtoul(parm[1], 0, &val) == 0) { + devp->debug.slt_test.vf_ori_crc = val; + pr_info("vdin%d:vf_ori_crc = 0x%x\n\n", devp->index, + devp->debug.slt_test.vf_ori_crc); + } + } else if (!strcmp(parm[0], "enable")) { + if (!parm[1]) { + pr_err("miss parameters .\n"); + } else if (kstrtoul(parm[1], 0, &val) == 0) { + devp->debug.slt_test.en = !!val; + pr_info("vdin%d:en:%d,vf_ori_crc = 0x%x\n\n", devp->index, + devp->debug.slt_test.en, devp->debug.slt_test.vf_ori_crc); + } + } else if (!strcmp(parm[0], "state")) { + pr_info("vdin%d:en:%d,vf_ori_crc = 0x%x,chk:%d,cnt:%d\n", devp->index, + devp->debug.slt_test.en, devp->debug.slt_test.vf_ori_crc, + devp->debug.slt_test.vf_check_result, devp->debug.slt_test.vf_pass_cnt); + } + + kfree(buf_orig); + + return len; +} + +static ssize_t slt_test_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct vdin_dev_s *devp = dev_get_drvdata(dev); + + if (devp->debug.slt_test.vf_check_result) + return sprintf(buf, "%s\n", "pass"); + else + return sprintf(buf, "%s\n", "fail"); +} +static DEVICE_ATTR_RW(slt_test); + static void vdin_dump_sct_state(struct vdin_dev_s *devp) { int i, sum = 0; @@ -4314,6 +4369,7 @@ int vdin_create_debug_files(struct device *dev) ret = device_create_file(dev, &dev_attr_crop); ret = device_create_file(dev, &dev_attr_snow_flag); ret = device_create_file(dev, &dev_attr_input_rate); + ret = device_create_file(dev, &dev_attr_slt_test); #endif return ret; } @@ -4334,6 +4390,7 @@ void vdin_remove_debug_files(struct device *dev) device_remove_file(dev, &dev_attr_crop); device_remove_file(dev, &dev_attr_snow_flag); device_remove_file(dev, &dev_attr_input_rate); + device_remove_file(dev, &dev_attr_slt_test); #endif device_remove_file(dev, &dev_attr_attr); device_remove_file(dev, &dev_attr_sig_det); diff --git a/drivers/media/vin/tvin/vdin/vdin_drv.c b/drivers/media/vin/tvin/vdin/vdin_drv.c index 6fe04fa23..cf10f0e40 100644 --- a/drivers/media/vin/tvin/vdin/vdin_drv.c +++ b/drivers/media/vin/tvin/vdin/vdin_drv.c @@ -1204,6 +1204,9 @@ static void vdin_start_param_init(struct vdin_dev_s *devp) devp->afbce_flag = devp->dts_config.afbce_flag_cfg; devp->bypass_tunnel = false; + devp->debug.slt_test.vf_check_result = false; + devp->debug.slt_test.vf_pass_cnt = 0; + //todo:more parameter initializations will be move here } @@ -1794,6 +1797,8 @@ void vdin_stop_dec(struct vdin_dev_s *devp) memset(&devp->pre_prop, 0, sizeof(devp->pre_prop)); memset(&devp->prop, 0, sizeof(devp->prop)); } + devp->debug.slt_test.vf_check_result = false; + devp->debug.slt_test.vf_pass_cnt = 0; if (vdin_time_en) pr_info("vdin.%d stop time %ums,run time:%ums.\n", @@ -3125,6 +3130,44 @@ static void vdin_handle_secure_content(struct vdin_dev_s *devp) } } +static void vdin_slt_test(struct vdin_dev_s *devp) +{ + u32 stable_cnt = 10; + + if (!devp->debug.slt_test.en) + return; + + if (devp->vfp->last_last_vfe) { + if (devp->debug.slt_test.vf_ori_crc) { + stable_cnt = 10; + if (devp->vfp->last_last_vfe->vf.crc == devp->debug.slt_test.vf_ori_crc) + devp->debug.slt_test.vf_pass_cnt++; + else + devp->debug.slt_test.vf_pass_cnt = 0; + } else { + stable_cnt = 30; + if (devp->debug.slt_test.vf_last_crc == devp->vfp->last_last_vfe->vf.crc) + devp->debug.slt_test.vf_pass_cnt++; + else + devp->debug.slt_test.vf_pass_cnt = 0; + + devp->debug.slt_test.vf_last_crc = devp->vfp->last_last_vfe->vf.crc; + } + } else { + devp->debug.slt_test.vf_pass_cnt = 0; + } + if (devp->debug.slt_test.vf_pass_cnt >= stable_cnt) + devp->debug.slt_test.vf_check_result = true; + else + devp->debug.slt_test.vf_check_result = false; + + if (vdin_isr_monitor & VDIN_ISR_MONITOR_INPUT) + pr_info("vdin%d,crc=[%#x %#x],cnt=[%d %d]\n", + devp->index, + devp->vfp->last_last_vfe->vf.crc, devp->debug.slt_test.vf_ori_crc, + devp->debug.slt_test.vf_pass_cnt, devp->debug.slt_test.vf_check_result); +} + /* *VDIN_FLAG_RDMA_ENABLE=1 * provider_vf_put(devp->last_wr_vfe, devp->vfp); @@ -3730,6 +3773,7 @@ irqreturn_t vdin_isr(int irq, void *dev_id) } devp->frame_cnt++; + vdin_slt_test(devp); irq_handled: //for debug @@ -4041,6 +4085,7 @@ irqreturn_t vdin_v4l2_isr(int irq, void *dev_id) VFRAME_EVENT_PROVIDER_VFRAME_READY, NULL); devp->frame_cnt++; + vdin_slt_test(devp); irq_handled: devp->vdin_irq_flag = 0; diff --git a/drivers/media/vin/tvin/vdin/vdin_drv.h b/drivers/media/vin/tvin/vdin/vdin_drv.h index 03975aa71..e320b065a 100644 --- a/drivers/media/vin/tvin/vdin/vdin_drv.h +++ b/drivers/media/vin/tvin/vdin/vdin_drv.h @@ -590,6 +590,14 @@ struct vdin_vf_info { /***vdin_dbg_en control for print***/ #define DBG_VDIN1_HIST (BIT(1)) /*print vdin1 HIST_IOC */ +struct vdin_slt_test_s { + bool en; + bool vf_check_result; + u32 vf_ori_crc; + u32 vf_last_crc; + u32 vf_pass_cnt; +}; + /*******for debug **********/ struct vdin_debug_s { struct tvin_cutwin_s cutwin; @@ -626,6 +634,7 @@ struct vdin_debug_s { /* bit0:scl_mode;bit1:bypass dsc;bit2:bypass sc */ unsigned int dbg_dv_hw5; unsigned int hconv_mode; + struct vdin_slt_test_s slt_test; }; struct vdin_dv_s {