tvafe: fix wss issues
authorNian Jing <nian.jing@amlogic.com>
Wed, 11 Jul 2018 08:34:59 +0000 (16:34 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Wed, 18 Jul 2018 06:02:58 +0000 (23:02 -0700)
PD#169836: fix wss issues
wss detect slowly
aspect ratio unstable when set off on machine
aspect ratio 4:3 different with screen mode 4:3

Change-Id: I66d0aa393808513975885b86ee18e4c62bf10c88
Signed-off-by: Nian Jing <nian.jing@amlogic.com>
drivers/amlogic/media/video_sink/vpp.c
drivers/amlogic/media/vin/tvin/tvafe/tvafe.c
drivers/amlogic/media/vin/tvin/tvafe/tvafe.h
drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c
drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c
drivers/amlogic/media/vin/tvin/tvin_global.h
drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c
include/linux/amlogic/media/vfm/vframe.h

index 6c169820a978817fb4111d8bfb207c904e51e830..52cbe89ae83a1b33a9e0913831b526ac4bf36430 100644 (file)
@@ -2435,10 +2435,19 @@ vpp_set_filters(u32 process_3d_type, u32 wide_mode,
        if ((vf->ratio_control & DISP_RATIO_ADAPTED_PICMODE)
                && !disable_adapted) {
                wide_mode = vf->pic_mode.screen_mode;
-               video_source_crop_top = vf->pic_mode.vs;
-               video_source_crop_left = vf->pic_mode.hs;
-               video_source_crop_bottom = vf->pic_mode.ve;
-               video_source_crop_right = vf->pic_mode.he;
+               if (vf->pic_mode.provider == PIC_MODE_PROVIDER_WSS) {
+                       /* from wss, need add global setting */
+                       video_source_crop_top += vf->pic_mode.vs;
+                       video_source_crop_left += vf->pic_mode.hs;
+                       video_source_crop_bottom += vf->pic_mode.ve;
+                       video_source_crop_right += vf->pic_mode.he;
+               } else {
+                       /* from PQ database, final setting */
+                       video_source_crop_top = vf->pic_mode.vs;
+                       video_source_crop_left = vf->pic_mode.hs;
+                       video_source_crop_bottom = vf->pic_mode.ve;
+                       video_source_crop_right = vf->pic_mode.he;
+               }
                if (vf->pic_mode.AFD_enable
                        && (vf->ratio_control & DISP_RATIO_INFOFRAME_AVAIL))
                        wide_mode = VIDEO_WIDEOPTION_AFD;
index 142323dab2936dfc31d7cbcba3e487b08fce2396..f8abe63a6163fbb024e82853d51df065f9369849 100644 (file)
@@ -75,7 +75,7 @@ static struct class *tvafe_clsp;
 struct mutex pll_mutex;
 
 #define TVAFE_TIMER_INTERVAL    (HZ/100)   /* 10ms, #define HZ 100 */
-#define TVAFE_RATIO_CNT                        50
+#define TVAFE_RATIO_CNT                        40
 
 static struct am_regs_s tvaferegs;
 static struct tvafe_pin_mux_s tvafe_pinmux;
@@ -520,6 +520,8 @@ int tvafe_dec_isr(struct tvin_frontend_s *fe, unsigned int hcnt64)
        struct tvafe_info_s *tvafe = &devp->tvafe;
        enum tvin_port_e port = tvafe->parm.port;
        enum tvin_aspect_ratio_e aspect_ratio = TVIN_ASPECT_NULL;
+       static int count[10] = {0};
+       int i;
 
        if (!(devp->flags & TVAFE_FLAG_DEV_OPENED) ||
                (devp->flags & TVAFE_POWERDOWN_IN_IDLE)) {
@@ -559,16 +561,50 @@ int tvafe_dec_isr(struct tvin_frontend_s *fe, unsigned int hcnt64)
 
        if ((port >= TVIN_PORT_CVBS0) && (port <= TVIN_PORT_CVBS3)) {
                aspect_ratio = tvafe_cvd2_get_wss();
-               if (aspect_ratio != tvafe->aspect_ratio_last) {
-                       tvafe->aspect_ratio_last = aspect_ratio;
+               switch (aspect_ratio) {
+               case TVIN_ASPECT_NULL:
+                       count[TVIN_ASPECT_NULL]++;
+                       break;
+               case TVIN_ASPECT_1x1:
+                       count[TVIN_ASPECT_1x1]++;
+                       break;
+               case TVIN_ASPECT_4x3_FULL:
+                       count[TVIN_ASPECT_4x3_FULL]++;
+                       break;
+               case TVIN_ASPECT_14x9_FULL:
+                       count[TVIN_ASPECT_14x9_FULL]++;
+                       break;
+               case TVIN_ASPECT_14x9_LB_CENTER:
+                       count[TVIN_ASPECT_14x9_LB_CENTER]++;
+                       break;
+               case TVIN_ASPECT_14x9_LB_TOP:
+                       count[TVIN_ASPECT_14x9_LB_TOP]++;
+                       break;
+               case TVIN_ASPECT_16x9_FULL:
+                       count[TVIN_ASPECT_16x9_FULL]++;
+                       break;
+               case TVIN_ASPECT_16x9_LB_CENTER:
+                       count[TVIN_ASPECT_16x9_LB_CENTER]++;
+                       break;
+               case TVIN_ASPECT_16x9_LB_TOP:
+                       count[TVIN_ASPECT_16x9_LB_TOP]++;
+                       break;
+               case TVIN_ASPECT_MAX:
+                       break;
+               }
+               /*over 30/40 times,ratio is effective*/
+               if (++(tvafe->aspect_ratio_cnt) > TVAFE_RATIO_CNT) {
+                       for (i = 0; i < TVIN_ASPECT_MAX; i++) {
+                               if (count[i] > 30) {
+                                       tvafe->aspect_ratio = i;
+                                       break;
+                               }
+                       }
+                       for (i = 0; i < TVIN_ASPECT_MAX; i++)
+                               count[i] = 0;
                        tvafe->aspect_ratio_cnt = 0;
-               } else if (++(tvafe->aspect_ratio_cnt) > TVAFE_RATIO_CNT) {
-                       tvafe->aspect_ratio = aspect_ratio;
-                       /* avoid overflow */
-                       tvafe->aspect_ratio_cnt = TVAFE_RATIO_CNT;
                }
        }
-
        return TVIN_BUF_NULL;
 }
 
index 57f6afa3da65975f26f69126844eae66ea18dba5..7fe836ff993c1e3c81fa154523f41a91e626b317 100644 (file)
@@ -58,7 +58,6 @@ struct tvafe_info_s {
        struct tvafe_cvd2_s cvd2;
        /*WSS INFO for av/atv*/
        enum tvin_aspect_ratio_e aspect_ratio;
-       enum tvin_aspect_ratio_e aspect_ratio_last;
        unsigned int aspect_ratio_cnt;
 };
 
index 24172bc3cf08c006dffc4bd59fd232fe081f5114..aee1a1945c41cc33be9c275d81eee6e5ceecc1e0 100644 (file)
@@ -2647,7 +2647,7 @@ enum tvin_aspect_ratio_e tvafe_cvd2_get_wss(void)
        unsigned int full_format = 0;
        enum tvin_aspect_ratio_e aspect_ratio = TVIN_ASPECT_NULL;
 
-       full_format = R_APB_BIT(CVD2_VBI_WSS_DATA1, 0, 4);
+       full_format = R_APB_REG(CVD2_VBI_WSS_DATA1);
 
        if (full_format == TVIN_AR_14x9_LB_CENTER_VAL)
                aspect_ratio = TVIN_ASPECT_14x9_LB_CENTER;
index f4c07fee3609d6e866a35a2c7dcdf70dca367aae..44993fd201c9f07c3641dbd395468dfad1a2c32c 100644 (file)
@@ -60,8 +60,6 @@ static void tvafe_state(struct tvafe_dev_s *devp)
        #endif
        tvafe_pr_info("tvafe_info_s->aspect_ratio:%d\n",
                devp->tvafe.aspect_ratio);
-       tvafe_pr_info("tvafe_info_s->aspect_ratio_last:%d\n",
-               devp->tvafe.aspect_ratio_last);
        tvafe_pr_info("tvafe_info_s->aspect_ratio_cnt:%d\n",
                devp->tvafe.aspect_ratio_cnt);
        /* tvafe_dev_s->tvin_parm_s struct info */
index 5407df279e21f6f48b7f006092d8a1de55c09f30..c6d053b0641632aa6cc5fa9615e2fffd365d1ca2 100644 (file)
@@ -376,14 +376,14 @@ struct tvin_format_s {
 };
 
 enum tvin_ar_b3_b0_val_e {
-       TVIN_AR_14x9_LB_CENTER_VAL = 1,
-       TVIN_AR_14x9_LB_TOP_VAL = 2,
-       TVIN_AR_16x9_LB_TOP_VAL = 4,
-       TVIN_AR_16x9_FULL_VAL = 7,
-       TVIN_AR_4x3_FULL_VAL = 8,
-       TVIN_AR_16x9_LB_CENTER_VAL = 11,
-       TVIN_AR_16x9_LB_CENTER1_VAL = 13,
-       TVIN_AR_14x9_FULL_VAL = 14,
+       TVIN_AR_14x9_LB_CENTER_VAL = 0x11,
+       TVIN_AR_14x9_LB_TOP_VAL = 0x12,
+       TVIN_AR_16x9_LB_TOP_VAL = 0x14,
+       TVIN_AR_16x9_FULL_VAL = 0x17,
+       TVIN_AR_4x3_FULL_VAL = 0x18,
+       TVIN_AR_16x9_LB_CENTER_VAL = 0x1b,
+       TVIN_AR_16x9_LB_CENTER1_VAL = 0x1d,
+       TVIN_AR_14x9_FULL_VAL = 0x1e,
 };
 
 enum tvin_aspect_ratio_e {
index caab85a2a6bece31510574d3da9787deae8e898c..2b3bc89e1f55a7a762ec015b8c01f3198edd87db 100644 (file)
@@ -4165,9 +4165,10 @@ void vdin_set_display_ratio(struct vdin_dev_s *devp,
        switch (aspect_ratio) {
        case TVIN_ASPECT_4x3_FULL:
                vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.provider = PIC_MODE_PROVIDER_WSS;
                vf->pic_mode.hs = 0;
                vf->pic_mode.he = 0;
-               vf->pic_mode.vs = 1;
+               vf->pic_mode.vs = 0;
                vf->pic_mode.ve = 0;
                /* 3*256/4=0xc0 */
                vf->pic_mode.custom_ar = 0xc0;
@@ -4175,9 +4176,10 @@ void vdin_set_display_ratio(struct vdin_dev_s *devp,
                break;
        case TVIN_ASPECT_14x9_FULL:
                vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.provider = PIC_MODE_PROVIDER_WSS;
                vf->pic_mode.hs = 0;
                vf->pic_mode.he = 0;
-               vf->pic_mode.vs = 1;
+               vf->pic_mode.vs = 0;
                vf->pic_mode.ve = 0;
                /* 9*256/14=0xc0 */
                vf->pic_mode.custom_ar = 0xa4;
@@ -4185,9 +4187,10 @@ void vdin_set_display_ratio(struct vdin_dev_s *devp,
                break;
        case TVIN_ASPECT_16x9_FULL:
                vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.provider = PIC_MODE_PROVIDER_WSS;
                vf->pic_mode.hs = 0;
                vf->pic_mode.he = 0;
-               vf->pic_mode.vs = 1;
+               vf->pic_mode.vs = 0;
                vf->pic_mode.ve = 0;
                /* 9*256/16=0xc0 */
                vf->pic_mode.custom_ar = 0x90;
@@ -4195,17 +4198,20 @@ void vdin_set_display_ratio(struct vdin_dev_s *devp,
                break;
        case TVIN_ASPECT_14x9_LB_CENTER:
                /**720/462=14/9;(576-462)/2=57;57/2=28**/
+               /**need cut more**/
                vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.provider = PIC_MODE_PROVIDER_WSS;
                vf->pic_mode.hs = 0;
                vf->pic_mode.he = 0;
-               vf->pic_mode.vs = 28;
-               vf->pic_mode.ve = 28;
+               vf->pic_mode.vs = 36;
+               vf->pic_mode.ve = 36;
                vf->pic_mode.custom_ar = 0xa4;
                vf->ratio_control |= DISP_RATIO_ADAPTED_PICMODE;
                break;
        case TVIN_ASPECT_14x9_LB_TOP:
                /**720/462=14/9;(576-462)/2=57**/
                vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.provider = PIC_MODE_PROVIDER_WSS;
                vf->pic_mode.hs = 0;
                vf->pic_mode.he = 0;
                vf->pic_mode.vs = 0;
@@ -4217,6 +4223,7 @@ void vdin_set_display_ratio(struct vdin_dev_s *devp,
                /**720/405=16/9;(576-405)/2=85;85/2=42**/
                /**need cut more**/
                vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.provider = PIC_MODE_PROVIDER_WSS;
                vf->pic_mode.hs = 0;
                vf->pic_mode.he = 0;
                vf->pic_mode.vs = 70;
@@ -4227,6 +4234,7 @@ void vdin_set_display_ratio(struct vdin_dev_s *devp,
        case TVIN_ASPECT_16x9_LB_TOP:
                /**720/405=16/9;(576-405)/2=85**/
                vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.provider = PIC_MODE_PROVIDER_WSS;
                vf->pic_mode.hs = 0;
                vf->pic_mode.he = 0;
                vf->pic_mode.vs = 0;
index 8403e1abdd65dabe15f6a423943c67153cc0f89d..59cb9b600e8f4496d10ad68fed3c336ebab5de06 100644 (file)
@@ -210,6 +210,12 @@ enum vframe_disp_mode_e {
        VFRAME_DISP_MODE_OK,
 };
 
+enum pic_mode_provider_e {
+       PIC_MODE_PROVIDER_DB = 0,
+       PIC_MODE_PROVIDER_WSS,
+       PIC_MODE_UNKNOWN,
+};
+
 struct vframe_pic_mode_s {
        int hs;
        int he;
@@ -218,6 +224,7 @@ struct vframe_pic_mode_s {
        u32 screen_mode;
        u32 custom_ar;
        u32 AFD_enable;
+       enum pic_mode_provider_e provider;
 };
 
 #define BITDEPTH_Y_SHIFT 8