From 58edb173f038ed70191fa43512cffcf70d679e19 Mon Sep 17 00:00:00 2001 From: Yong Qin Date: Tue, 23 Jul 2019 17:02:34 +0800 Subject: [PATCH] vdin: dec stop port close vdin flag is not right [1/1] PD#TV-7934 Problem: when port not open complitly, needn't send event to tv server Solution: add a condition to pretect Verify: tl1 Change-Id: I4fb6d7d1d247381c9cb13acabeece56dd6b6d1bc Signed-off-by: Yong Qin --- drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c | 2 ++ drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c | 19 +++++++++++++++---- drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h | 2 +- drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c | 13 ++++++++++--- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c index 62a148d..2244524 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c @@ -719,6 +719,8 @@ static void vdin_dump_state(struct vdin_dev_s *devp) struct vframe_s *vf = &devp->curr_wr_vfe->vf; struct tvin_parm_s *curparm = &devp->parm; struct vf_pool *vfp = devp->vfp; + + pr_info("flags=0x%x\n", devp->flags); pr_info("h_active = %d, v_active = %d\n", devp->h_active, devp->v_active); pr_info("canvas_w = %d, canvas_h = %d\n", diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c index 7be5b3b..50d66e1 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c @@ -252,6 +252,8 @@ int vdin_open_fe(enum tvin_port_e port, int index, struct vdin_dev_s *devp) /* check open status */ if (ret) return 1; + + devp->flags |= VDIN_FLAG_DEC_OPENED; /* init vdin state machine */ tvin_smr_init(devp->index); init_timer(&devp->timer); @@ -291,6 +293,8 @@ void vdin_close_fe(struct vdin_dev_s *devp) devp->parm.info.fmt = TVIN_SIG_FMT_NULL; devp->parm.info.status = TVIN_SIG_STATUS_NULL; + devp->flags &= (~VDIN_FLAG_DEC_OPENED); + pr_info("%s ok\n", __func__); } static void vdin_game_mode_check(struct vdin_dev_s *devp) @@ -752,8 +756,10 @@ void vdin_stop_dec(struct vdin_dev_s *devp) int i = 0; /* avoid null pointer oops */ - if (!devp || !devp->frontend) + if (!devp || !devp->frontend) { + pr_info("vdin err no frontend\n"); return; + } #ifdef CONFIG_CMA if ((devp->cma_mem_alloc == 0) && devp->cma_config_en) { pr_info("%s:cma not alloc,don't need do others!\n", __func__); @@ -2221,6 +2227,11 @@ static void vdin_vlock_dwork(struct work_struct *work) struct vdin_dev_s *devp = container_of(dwork, struct vdin_dev_s, vlock_dwork); + if (!(devp->flags & VDIN_FLAG_DEC_OPENED)) { + cancel_delayed_work(&devp->vlock_dwork); + return; + } + if (!devp || !devp->frontend || !devp->curr_wr_vfe) { pr_info("%s, dwork error !!!\n", __func__); return; @@ -2318,7 +2329,6 @@ static int vdin_release(struct inode *inode, struct file *file) } if (devp->flags & VDIN_FLAG_DEC_OPENED) { vdin_close_fe(devp); - devp->flags &= (~VDIN_FLAG_DEC_OPENED); } devp->flags &= (~VDIN_FLAG_SNOW_FLAG); @@ -2399,7 +2409,7 @@ static long vdin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } - devp->flags |= VDIN_FLAG_DEC_OPENED; + /*devp->flags |= VDIN_FLAG_DEC_OPENED;*/ if (vdin_dbg_en) pr_info("TVIN_IOC_OPEN(%d) port %s opened ok\n\n", parm.index, tvin_port_str(devp->parm.port)); @@ -2549,7 +2559,7 @@ static long vdin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) pr_info("TVIN_IOC_CLOSE %ums.\n", jiffies_to_msecs(jiffies)); vdin_close_fe(devp); - devp->flags &= (~VDIN_FLAG_DEC_OPENED); + /*devp->flags &= (~VDIN_FLAG_DEC_OPENED);*/ if (vdin_dbg_en) pr_info("TVIN_IOC_CLOSE(%d) port %s closed ok\n\n", parm->index, @@ -2586,6 +2596,7 @@ static long vdin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (!(devp->flags & VDIN_FLAG_DEC_OPENED)) { ret = -EPERM; mutex_unlock(&devp->fe_lock); + pr_info("vdin get info fail, DEC_OPENED\n"); break; } memcpy(&info, &devp->parm.info, sizeof(struct tvin_info_s)); diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h index 9da8940..bed45b7 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h @@ -48,7 +48,7 @@ /* Ref.2019/04/25: tl1 vdin0 afbce dynamically switch support, * vpp also should support this function */ -#define VDIN_VER "Ref.2019/07/19:vf add hdr10 plus data" +#define VDIN_VER "Ref.2019/07/23: pretect dec top/start" /*the counter of vdin*/ #define VDIN_MAX_DEVS 2 diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c index 64cf78b..a78159f 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c @@ -324,6 +324,9 @@ void tvin_smr(struct vdin_dev_s *devp) (devp->flags & VDIN_FLAG_SUSPEND)) return; + if (!(devp->flags & VDIN_FLAG_DEC_OPENED)) + return; + sm_p = &sm_dev[devp->index]; fe = devp->frontend; sm_ops = devp->frontend->sm_ops; @@ -661,10 +664,14 @@ void tvin_smr(struct vdin_dev_s *devp) sm_p->state = TVIN_SM_STATUS_NOSIG; break; } - if (sm_p->sig_status != info->status) { - sm_p->sig_status = info->status; - wake_up(&devp->queue); + + if (devp->flags & VDIN_FLAG_DEC_OPENED) { + if (sm_p->sig_status != info->status) { + sm_p->sig_status = info->status; + wake_up(&devp->queue); + } } + signal_status = sm_p->sig_status; } -- 2.7.4