vpp: support 3D with afbc format [1/1]
authorBrian Zhu <brian.zhu@amlogic.com>
Thu, 7 Mar 2019 09:35:36 +0000 (17:35 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Mon, 11 Mar 2019 06:59:23 +0000 (22:59 -0800)
PD#TV-3042

Problem:
3D function did not support afbc format before

Solution:
Add the support case which format is afbc.

Verify:
x301

Change-Id: I38189bfa78eec6ac811fb81631514d7d7b8b3d62
Signed-off-by: Brian Zhu <brian.zhu@amlogic.com>
drivers/amlogic/media/video_sink/video.c
drivers/amlogic/media/video_sink/vpp.c

index d7916b8..443591c 100644 (file)
@@ -1193,6 +1193,7 @@ static inline struct vframe_s *video_vf_peek(void)
 static inline struct vframe_s *video_vf_get(void)
 {
        struct vframe_s *vf = NULL;
+       int frame_width, frame_height;
 
        vf = vf_get(RECEIVER_NAME);
 
@@ -1203,6 +1204,13 @@ static inline struct vframe_s *video_vf_get(void)
                        vf->disp_pts = 0;
                        vf->disp_pts_us64 = 0;
                }
+               if (vf->type & VIDTYPE_COMPRESS) {
+                       frame_width = vf->compWidth;
+                       frame_height = vf->compHeight;
+               } else {
+                       frame_width = vf->width;
+                       frame_height = vf->height;
+               }
                video_notify_flag |= VIDEO_NOTIFY_PROVIDER_GET;
                atomic_set(&vf->use_cnt, 1);
                /*always to 1,for first get from vfm provider */
@@ -1224,36 +1232,35 @@ static inline struct vframe_s *video_vf_get(void)
                }
                if (((process_3d_type & MODE_FORCE_3D_TO_2D_LR)
                || (process_3d_type & MODE_FORCE_3D_LR)
-               || (process_3d_type & MODE_FORCE_3D_FA_LR)
-               )
+               || (process_3d_type & MODE_FORCE_3D_FA_LR))
                && (!(vf->type & VIDTYPE_MVC))
                && (vf->trans_fmt != TVIN_TFMT_3D_FP)) {
                        vf->trans_fmt = TVIN_TFMT_3D_DET_LR;
                        vf->left_eye.start_x = 0;
                        vf->left_eye.start_y = 0;
-                       vf->left_eye.width = vf->width / 2;
-                       vf->left_eye.height = vf->height;
+                       vf->left_eye.width = frame_width / 2;
+                       vf->left_eye.height = frame_height;
 
-                       vf->right_eye.start_x = vf->width / 2;
+                       vf->right_eye.start_x = frame_width / 2;
                        vf->right_eye.start_y = 0;
-                       vf->right_eye.width = vf->width / 2;
+                       vf->right_eye.width = frame_width / 2;
+                       vf->right_eye.height = frame_height;
                }
                if (((process_3d_type & MODE_FORCE_3D_TO_2D_TB)
                || (process_3d_type & MODE_FORCE_3D_TB)
-               || (process_3d_type & MODE_FORCE_3D_FA_TB)
-               )
+               || (process_3d_type & MODE_FORCE_3D_FA_TB))
                && (!(vf->type & VIDTYPE_MVC))
                && (vf->trans_fmt != TVIN_TFMT_3D_FP)) {
                        vf->trans_fmt = TVIN_TFMT_3D_TB;
                        vf->left_eye.start_x = 0;
                        vf->left_eye.start_y = 0;
-                       vf->left_eye.width = vf->width;
-                       vf->left_eye.height = vf->height/2;
+                       vf->left_eye.width = frame_width;
+                       vf->left_eye.height = frame_height/2;
 
                        vf->right_eye.start_x = 0;
-                       vf->right_eye.start_y = vf->height/2;
-                       vf->right_eye.width = vf->width;
-                       vf->right_eye.height = vf->height/2;
+                       vf->right_eye.start_y = frame_height/2;
+                       vf->right_eye.width = frame_width;
+                       vf->right_eye.height = frame_height/2;
                }
                receive_frame_count++;
 #endif
@@ -1689,6 +1696,7 @@ static void zoom_get_horz_pos(struct vframe_s *vf, u32 vpp_3d_mode, u32 *ls,
                              u32 *le, u32 *rs, u32 *re)
 {
        u32 crop_sx, crop_ex, crop_sy, crop_ey;
+       int frame_width, frame_height;
        struct disp_info_s *layer = &glayer_info[0];
 
        if (!vf)
@@ -1699,18 +1707,26 @@ static void zoom_get_horz_pos(struct vframe_s *vf, u32 vpp_3d_mode, u32 *ls,
        crop_ey = layer->crop_bottom;
        crop_ex = layer->crop_right;
 
+       if (vf->type & VIDTYPE_COMPRESS) {
+               frame_width = vf->compWidth;
+               frame_height = vf->compHeight;
+       } else {
+               frame_width = vf->width;
+               frame_height = vf->height;
+       }
+
        switch (vpp_3d_mode) {
        case VPP_3D_MODE_LR:
                /*half width,double height */
                *ls = zoom_start_x_lines;
                *le = zoom_end_x_lines;
-               *rs = *ls + (vf->width >> 1);
-               *re = *le + (vf->width >> 1);
+               *rs = *ls + (frame_width >> 1);
+               *re = *le + (frame_width >> 1);
                if (process_3d_type & MODE_3D_OUT_LR) {
                        *ls = zoom_start_x_lines;
                        *le = zoom_end_x_lines >> 1;
-                       *rs = *ls + (vf->width >> 1);
-                       *re = *le + (vf->width >> 1);
+                       *rs = *ls + (frame_width >> 1);
+                       *re = *le + (frame_width >> 1);
                }
                break;
        case VPP_3D_MODE_TB:
@@ -1743,17 +1759,29 @@ static void zoom_get_vert_pos(struct vframe_s *vf, u32 vpp_3d_mode, u32 *ls,
                        u32 *le, u32 *rs, u32 *re)
 {
        u32 crop_sx, crop_ex, crop_sy, crop_ey, height;
+       int frame_width, frame_height;
        struct disp_info_s *layer = &glayer_info[0];
 
+       if (!vf)
+               return;
+
        crop_sy = layer->crop_top;
        crop_sx = layer->crop_left;
        crop_ey = layer->crop_bottom;
        crop_ex = layer->crop_right;
 
+       if (vf->type & VIDTYPE_COMPRESS) {
+               frame_width = vf->compWidth;
+               frame_height = vf->compHeight;
+       } else {
+               frame_width = vf->width;
+               frame_height = vf->height;
+       }
+
        if (vf->type & VIDTYPE_INTERLACE)
-               height = vf->height >> 1;
+               height = frame_height >> 1;
        else
-               height = vf->height;
+               height = frame_height;
 
        switch (vpp_3d_mode) {
        case VPP_3D_MODE_TB:
@@ -1939,17 +1967,22 @@ static void zoom_display_horz(struct vframe_s *vf, int hscale)
 #ifdef TV_REVERSE
                if (reverse) {
                        content_w = zoom_end_x_lines - zoom_start_x_lines + 1;
-                       content_l = (r_aligned - zoom_end_x_lines - 1) +
-                       (zoom_start_x_lines - l_aligned);
+                       content_l = (r_aligned - zoom_end_x_lines - 1);
                        content_r = content_l + content_w - 1;
                        VSYNC_WR_MPEG_REG(AFBC_PIXEL_HOR_SCOPE,
                                  (((content_l << 16)) | content_r) / h_skip);
                } else
 #endif
                {
-                       VSYNC_WR_MPEG_REG(AFBC_PIXEL_HOR_SCOPE,
-                                 (((zoom_start_x_lines - l_aligned) << 16) |
-                                 (zoom_end_x_lines - l_aligned)) / h_skip);
+                       if (((process_3d_type & MODE_3D_FA)
+                               || (process_3d_type & MODE_FORCE_3D_FA_LR))
+                               && (cur_frame_par->vpp_3d_mode == 1)) {
+                               /* do nothing*/
+                       } else {
+                               VSYNC_WR_MPEG_REG(AFBC_PIXEL_HOR_SCOPE,
+                               (((zoom_start_x_lines - l_aligned) << 16) |
+                               (zoom_end_x_lines - l_aligned)) / h_skip);
+                       }
                }
                VSYNC_WR_MPEG_REG(AFBC_SIZE_IN,
                         (VSYNC_RD_MPEG_REG(AFBC_SIZE_IN) & 0xffff) |
@@ -2081,7 +2114,7 @@ static void vd2_zoom_display_horz(struct vframe_s *vf, int hscale)
 static void zoom_display_vert(struct vframe_s *vf)
 {
 
-       u32 ls, le, rs, re;
+       u32 ls = 0, le = 0, rs = 0, re = 0;
 
        if (process_3d_type & MODE_3D_ENABLE) {
                zoom_get_vert_pos(vf,
@@ -2203,10 +2236,27 @@ static void zoom_display_vert(struct vframe_s *vf)
                VSYNC_WR_MPEG_REG(AFBC_VD_CFMT_H,
                    (b_aligned - t_aligned) / c_skip / v_skip);
 
-               VSYNC_WR_MPEG_REG(AFBC_MIF_VER_SCOPE,
-                   ((t_aligned / 4) << 16) |
-                   ((b_aligned / 4) - 1));
-
+               if (((process_3d_type & MODE_3D_FA)
+                       || (process_3d_type & MODE_FORCE_3D_FA_TB))
+                       && (cur_frame_par->vpp_3d_mode == 2)) {
+                       int block_h;
+
+                       block_h = ori_b_aligned - ori_t_aligned;
+                       block_h = block_h / 8;
+                       if (toggle_3d_fa_frame == OUT_FA_B_FRAME) {
+                               VSYNC_WR_MPEG_REG(AFBC_MIF_VER_SCOPE,
+                               (((ori_t_aligned / 4) +  block_h) << 16) |
+                               ((ori_b_aligned / 4)  - 1));
+                       } else {
+                               VSYNC_WR_MPEG_REG(AFBC_MIF_VER_SCOPE,
+                               ((ori_t_aligned / 4) << 16) |
+                               ((ori_t_aligned / 4)  + block_h - 1));
+                       }
+               } else {
+                       VSYNC_WR_MPEG_REG(AFBC_MIF_VER_SCOPE,
+                           ((t_aligned / 4) << 16) |
+                           ((b_aligned / 4) - 1));
+               }
                VSYNC_WR_MPEG_REG(AFBC_PIXEL_VER_SCOPE,
                    ((zoom_start_y_lines - t_aligned) << 16) |
                    (zoom_end_y_lines - t_aligned));
@@ -5923,6 +5973,132 @@ static int vpp_zorder_check(void)
        return force_flush;
 }
 
+#ifdef TV_3D_FUNCTION_OPEN
+inline void switch_3dView_per_vsync(void)
+{
+       u32 start_aligned, end_aligned, block_len;
+       u32 FA_enable = process_3d_type & MODE_3D_OUT_FA_MASK;
+
+       if (FA_enable && (toggle_3d_fa_frame == OUT_FA_A_FRAME)) {
+               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
+                       cur_dev->vpp_off, 1, 14, 1);
+                       /* VPP_VD1_PREBLEND disable */
+               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
+                       cur_dev->vpp_off, 1, 10, 1);
+                       /* VPP_VD1_POSTBLEND disable */
+               VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL +
+                       cur_dev->viu_off, 0x4000000);
+               VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL +
+                       cur_dev->viu_off, 0x4000000);
+               VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL +
+                       cur_dev->viu_off, 0x4000000);
+               VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL +
+                       cur_dev->viu_off, 0x4000000);
+               if (cur_dispbuf->type & VIDTYPE_COMPRESS) {
+                       if ((process_3d_type & MODE_FORCE_3D_FA_LR)
+                               && (cur_frame_par->vpp_3d_mode == 1)) {
+                               start_aligned = ori_start_x_lines;
+                               end_aligned = ori_end_x_lines + 1;
+                               block_len =
+                                       (end_aligned - start_aligned) / 2;
+                               block_len = block_len /
+                                       (cur_frame_par->hscale_skip_count + 1);
+                               VSYNC_WR_MPEG_REG(AFBC_PIXEL_HOR_SCOPE,
+                                       (start_aligned << 16) |
+                                       (start_aligned + block_len - 1));
+                       }
+                       if ((process_3d_type & MODE_FORCE_3D_FA_TB)
+                               && (cur_frame_par->vpp_3d_mode == 2)) {
+                               start_aligned =
+                                       round_down(ori_start_y_lines, 4);
+                               end_aligned =
+                                       round_up(ori_end_y_lines + 1, 4);
+                               block_len = end_aligned - start_aligned;
+                               block_len = block_len / 8;
+                               VSYNC_WR_MPEG_REG(AFBC_MIF_VER_SCOPE,
+                                       ((start_aligned / 4) << 16) |
+                                       ((start_aligned / 4)  + block_len - 1));
+                       }
+               }
+       } else if (FA_enable &&
+               (toggle_3d_fa_frame == OUT_FA_B_FRAME)) {
+               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
+                       cur_dev->vpp_off, 1, 14, 1);
+                       /* VPP_VD1_PREBLEND disable */
+               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
+                       cur_dev->vpp_off, 1, 10, 1);
+                       /* VPP_VD1_POSTBLEND disable */
+               VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL +
+                       cur_dev->viu_off, 0);
+               VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL +
+                       cur_dev->viu_off, 0);
+               VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL +
+                       cur_dev->viu_off, 0);
+               VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL +
+                       cur_dev->viu_off, 0);
+               if (cur_dispbuf->type & VIDTYPE_COMPRESS) {
+                       if ((process_3d_type & MODE_FORCE_3D_FA_LR)
+                               && (cur_frame_par->vpp_3d_mode == 1)) {
+                               start_aligned = ori_start_x_lines;
+                               end_aligned = ori_end_x_lines + 1;
+                               block_len =
+                                       (end_aligned - start_aligned) / 2;
+                               block_len = block_len /
+                                       (cur_frame_par->hscale_skip_count + 1);
+                               VSYNC_WR_MPEG_REG(AFBC_PIXEL_HOR_SCOPE,
+                                       ((start_aligned + block_len) << 16) |
+                                       (end_aligned - 1));
+                       }
+                       if ((process_3d_type & MODE_FORCE_3D_FA_TB)
+                               && (cur_frame_par->vpp_3d_mode == 2)) {
+                               start_aligned =
+                                       round_down(ori_start_y_lines, 4);
+                               end_aligned =
+                                       round_up(ori_end_y_lines + 1, 4);
+                               block_len = end_aligned - start_aligned;
+                               block_len = block_len / 8;
+                               VSYNC_WR_MPEG_REG(AFBC_MIF_VER_SCOPE,
+                               (((start_aligned / 4) + block_len) << 16) |
+                               ((end_aligned / 4)  - 1));
+                       }
+               }
+       } else if (FA_enable &&
+               (toggle_3d_fa_frame == OUT_FA_BANK_FRAME)) {
+               /* output a banking frame */
+               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
+                       cur_dev->vpp_off, 0, 14, 1);
+                       /* VPP_VD1_PREBLEND disable */
+               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
+                       cur_dev->vpp_off, 0, 10, 1);
+                       /* VPP_VD1_POSTBLEND disable */
+       }
+
+       if ((process_3d_type & MODE_3D_OUT_TB)
+               || (process_3d_type & MODE_3D_OUT_LR)) {
+               if (cur_frame_par->vpp_2pic_mode &
+                       VPP_PIC1_FIRST) {
+                       VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL +
+                               cur_dev->viu_off, 0x4000000);
+                       VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL +
+                               cur_dev->viu_off, 0x4000000);
+                       VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL +
+                               cur_dev->viu_off, 0);
+                       VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL +
+                               cur_dev->viu_off, 0);
+               } else {
+                       VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL +
+                               cur_dev->viu_off, 0);
+                       VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL +
+                               cur_dev->viu_off, 0);
+                       VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL +
+                               cur_dev->viu_off, 0x4000000);
+                       VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL +
+                               cur_dev->viu_off, 0x4000000);
+               }
+       }
+}
+#endif
+
 #ifdef FIQ_VSYNC
 void vsync_fisr_in(void)
 #else
@@ -6706,75 +6882,10 @@ SET_FILTER:
                                cur_dev->viu_off, 1, 20, 1);
                        /* HFORMATTER_EN */
                }
-               if (process_3d_type & MODE_3D_OUT_FA_MASK) {
-                       if (toggle_3d_fa_frame == OUT_FA_A_FRAME) {
-                               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
-                                       cur_dev->vpp_off, 1, 14, 1);
-                               /* VPP_VD1_PREBLEND disable */
-                               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
-                                       cur_dev->vpp_off, 1, 10, 1);
-                               /* VPP_VD1_POSTBLEND disable */
-                               VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL +
-                                       cur_dev->viu_off, 0x4000000);
-                               VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL +
-                                       cur_dev->viu_off, 0x4000000);
-                               VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL +
-                                       cur_dev->viu_off, 0x4000000);
-                               VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL +
-                                       cur_dev->viu_off, 0x4000000);
-                       } else if (OUT_FA_B_FRAME ==
-                               toggle_3d_fa_frame) {
-                               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
-                                       cur_dev->vpp_off, 1, 14, 1);
-                               /* VPP_VD1_PREBLEND disable */
-                               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
-                                       cur_dev->vpp_off, 1, 10, 1);
-                               /* VPP_VD1_POSTBLEND disable */
-                               VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL +
-                                       cur_dev->viu_off, 0);
-                               VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL +
-                                       cur_dev->viu_off, 0);
-                               VSYNC_WR_MPEG_REG(
-                                       VD2_IF0_LUMA_PSEL +
-                                               cur_dev->viu_off, 0);
-                               VSYNC_WR_MPEG_REG(
-                                       VD2_IF0_CHROMA_PSEL +
-                                       cur_dev->viu_off, 0);
-                       } else if (toggle_3d_fa_frame ==
-                               OUT_FA_BANK_FRAME) {
-                               /* output a banking frame */
-                               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
-                                       cur_dev->vpp_off, 0, 14, 1);
-                               /* VPP_VD1_PREBLEND disable */
-                               VSYNC_WR_MPEG_REG_BITS(VPP_MISC +
-                                       cur_dev->vpp_off, 0, 10, 1);
-                               /* VPP_VD1_POSTBLEND disable */
-                       }
-               }
-               if ((process_3d_type & MODE_3D_OUT_TB)
-                       || (process_3d_type & MODE_3D_OUT_LR)) {
-                       if (cur_frame_par &&
-                               (cur_frame_par->vpp_2pic_mode &
-                               VPP_PIC1_FIRST)) {
-                               VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL +
-                                       cur_dev->viu_off, 0x4000000);
-                               VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL +
-                                       cur_dev->viu_off, 0x4000000);
-                               VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL +
-                                       cur_dev->viu_off, 0);
-                               VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL +
-                                       cur_dev->viu_off, 0);
-                       } else {
-                               VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL +
-                                       cur_dev->viu_off, 0);
-                               VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL +
-                                       cur_dev->viu_off, 0);
-                               VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL +
-                                       cur_dev->viu_off, 0x4000000);
-                               VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL +
-                                       cur_dev->viu_off, 0x4000000);
-                       }
-               }
+
+#ifdef TV_3D_FUNCTION_OPEN
+               switch_3dView_per_vsync();
+#endif
                /* vertical phase */
                vphase = &cur_frame_par->VPP_vf_ini_phase_
                        [vpp_phase_table[vin_type]
index 33a014f..4290494 100644 (file)
@@ -589,6 +589,9 @@ module_param(cur_skip_ratio, uint, 0444);
 static unsigned int cur_vf_type;
 MODULE_PARM_DESC(cur_vf_type, "cur_vf_type");
 module_param(cur_vf_type, uint, 0444);
+static unsigned int cur_freq_ratio;
+MODULE_PARM_DESC(cur_freq_ratio, "cur_freq_ratio");
+module_param(cur_freq_ratio, uint, 0444);
 
 static unsigned int custom_ar;
 MODULE_PARM_DESC(custom_ar, "custom_ar");
@@ -625,6 +628,8 @@ static int vpp_process_speed_check(
 {
        u32 cur_ratio, bpp = 1;
        int min_ratio_1000 = 0;
+       int freq_ratio = 1;
+       u32 sync_duration_den = 1;
        u32 vtotal, htotal = 0, clk_in_pps = 0, clk_vpu = 0, clk_temp;
        u32 input_time_us = 0, display_time_us = 0, dummy_time_us = 0;
        u32 width_out = 0;
@@ -643,6 +648,9 @@ static int vpp_process_speed_check(
        if (next_frame_par->vscale_skip_count < force_vskip_cnt)
                return SPEED_CHECK_VSKIP;
 
+       if (vinfo->sync_duration_den >  0)
+               sync_duration_den = vinfo->sync_duration_den;
+
        if (vf->type & VIDTYPE_PRE_INTERLACE) {
                if (is_meson_txlx_cpu())
                        clk_in_pps = 250000000;
@@ -690,13 +698,22 @@ static int vpp_process_speed_check(
                if (clk_temp)
                        dummy_time_us = (vtotal * htotal -
                        height_out * width_out) / clk_temp;
-               display_time_us = 1000000 * vinfo->sync_duration_den /
+               display_time_us = 1000000 * sync_duration_den /
                        vinfo->sync_duration_num;
                if (display_time_us > dummy_time_us)
                        display_time_us = display_time_us - dummy_time_us;
                if (input_time_us > display_time_us)
                        return SPEED_CHECK_VSKIP;
        }
+
+       if ((vinfo->sync_duration_num / sync_duration_den) > 60)
+               freq_ratio = vinfo->sync_duration_num /
+                       sync_duration_den / 60;
+
+       if (freq_ratio < 1)
+               freq_ratio = 1;
+       cur_freq_ratio = freq_ratio;
+
        /* #if (MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8) */
        if ((get_cpu_type() >= MESON_CPU_MAJOR_ID_M8) && !is_meson_mtvd_cpu()) {
                if ((width_in <= 0) || (height_in <= 0) || (height_out <= 0)
@@ -719,7 +736,7 @@ static int vpp_process_speed_check(
                                MESON_CPU_MAJOR_ID_GXBB) {
                                cur_ratio = div_u64((u64)height_in *
                                        (u64)vinfo->height *
-                                       1000,
+                                       1000 * freq_ratio,
                                        height_out * max_height);
                                /* di process first, need more a bit of ratio */
                                if (vf->type & VIDTYPE_PRE_INTERLACE)
@@ -748,7 +765,7 @@ static int vpp_process_speed_check(
                                        (u64)vinfo->sync_duration_num *
                                        (u64)vtotal,
                                        height_out *
-                                       vinfo->sync_duration_den *
+                                       sync_duration_den *
                                        bypass_ratio) > clk_in_pps)
                                        return SPEED_CHECK_VSKIP;
                                else
@@ -762,7 +779,7 @@ static int vpp_process_speed_check(
                                        (u64)vinfo->sync_duration_num *
                                        (u64)vtotal,
                                        height_out *
-                                       vinfo->sync_duration_den * 256)
+                                       sync_duration_den * 256)
                                        > clk_in_pps)
                                        return SPEED_CHECK_VSKIP;
                                /* 4K down scaling to non 4K > 30hz,*/
@@ -772,7 +789,7 @@ static int vpp_process_speed_check(
                                        && (height_in > 2048)
                                        && (height_out < 2048)
                                        && (vinfo->sync_duration_num >
-                                       (30 * vinfo->sync_duration_den))
+                                       (30 * sync_duration_den))
                                        && (get_cpu_type() !=
                                        MESON_CPU_MAJOR_ID_GXTVBB)
                                        && (get_cpu_type() !=
@@ -785,7 +802,7 @@ static int vpp_process_speed_check(
                        /*TODO vpu */
                        if (div_u64(VPP_SPEED_FACTOR * width_in *
                                vinfo->sync_duration_num * height_screen,
-                               vinfo->sync_duration_den * 256)
+                               sync_duration_den * 256)
                                > get_vpu_clk())
                                return SPEED_CHECK_HSKIP;
                        else
@@ -2243,7 +2260,15 @@ static void vpp_get_video_source_size(
        u32 process_3d_type, struct vframe_s *vf,
        struct vpp_frame_par_s *next_frame_par)
 {
+       int frame_width, frame_height;
 
+       if (vf->type & VIDTYPE_COMPRESS) {
+               frame_width = vf->compWidth;
+               frame_height = vf->compHeight;
+       } else {
+               frame_width = vf->width;
+               frame_height = vf->height;
+       }
        if ((process_3d_type & MODE_3D_AUTO) ||
                (((process_3d_type & MODE_3D_TO_2D_R) ||
                (process_3d_type & MODE_3D_TO_2D_L) ||
@@ -2287,8 +2312,8 @@ static void vpp_get_video_source_size(
                        break;
                case TVIN_TFMT_3D_DET_CHESSBOARD:
                default:
-                       *src_width = vf->width;
-                       *src_height = vf->height;
+                       *src_width = frame_width;
+                       *src_height = frame_height;
                        next_frame_par->vpp_3d_mode = VPP_3D_MODE_NULL;
                        next_frame_par->vpp_3d_scale = 0;
                        next_frame_par->vpp_2pic_mode = 0;
@@ -2299,15 +2324,15 @@ static void vpp_get_video_source_size(
                (process_3d_type & MODE_FORCE_3D_LR)) {
                next_frame_par->vpp_3d_mode = VPP_3D_MODE_LR;
                if (process_3d_type & MODE_3D_TO_2D_MASK) {
-                       *src_width = vf->width >> 1;
-                       *src_height = vf->height;
+                       *src_width = frame_width >> 1;
+                       *src_height = frame_height;
                } else if (process_3d_type & MODE_3D_OUT_LR) {
-                       *src_width = vf->width;
-                       *src_height = vf->height;
+                       *src_width = frame_width;
+                       *src_height = frame_height;
                        next_frame_par->vpp_2pic_mode = 1;
                } else {
-                       *src_width = vf->width >> 1;
-                       *src_height = vf->height << 1;
+                       *src_width = frame_width >> 1;
+                       *src_height = frame_height << 1;
                        next_frame_par->vpp_2pic_mode = 1;
                }
 
@@ -2315,38 +2340,38 @@ static void vpp_get_video_source_size(
                (process_3d_type & MODE_FORCE_3D_TB)) {
                next_frame_par->vpp_3d_mode = VPP_3D_MODE_TB;
                if (process_3d_type & MODE_3D_TO_2D_MASK) {
-                       *src_width = vf->width;
-                       *src_height = vf->height >> 1;
+                       *src_width = frame_width;
+                       *src_height = frame_height >> 1;
                } else if (process_3d_type & MODE_3D_OUT_LR) {
-                       *src_width = vf->width << 1;
-                       *src_height = vf->height >> 1;
+                       *src_width = frame_width << 1;
+                       *src_height = frame_height >> 1;
                        next_frame_par->vpp_2pic_mode = 1;
                } else {
-                       *src_width = vf->width;
-                       *src_height = vf->height;
+                       *src_width = frame_width;
+                       *src_height = frame_height;
                        next_frame_par->vpp_2pic_mode = 1;
                }
                if (process_3d_type & MODE_3D_MVC) {
-                       *src_width = vf->width;
-                       *src_height = vf->height << 1;
+                       *src_width = frame_width;
+                       *src_height = frame_height << 1;
                        next_frame_par->vpp_2pic_mode = 2;
                        next_frame_par->vpp_3d_mode = VPP_3D_MODE_FA;
                }
        } else if (process_3d_type & MODE_3D_LA) {
                next_frame_par->vpp_3d_mode = VPP_3D_MODE_LA;
-               *src_height = vf->height - 1;
-               *src_width = vf->width;
+               *src_height = frame_height - 1;
+               *src_width = frame_width;
                next_frame_par->vpp_2pic_mode = 0;
                next_frame_par->vpp_3d_scale = 1;
                if (process_3d_type & MODE_3D_TO_2D_MASK) {
                        next_frame_par->vscale_skip_count = 1;
                        next_frame_par->vpp_3d_scale = 0;
                } else if (process_3d_type & MODE_3D_OUT_TB) {
-                       *src_height = vf->height << 1;
+                       *src_height = frame_height << 1;
                        next_frame_par->vscale_skip_count = 1;
                        next_frame_par->vpp_3d_scale = 0;
                } else if (process_3d_type & MODE_3D_OUT_LR) {
-                       *src_width = vf->width << 1;
+                       *src_width = frame_width << 1;
                        next_frame_par->vscale_skip_count = 1;
                        next_frame_par->vpp_3d_scale = 0;
                }
@@ -2358,37 +2383,37 @@ static void vpp_get_video_source_size(
                if (process_3d_type & MODE_3D_TO_2D_MASK) {
                        if (process_3d_type & MODE_FORCE_3D_FA_TB) {
                                next_frame_par->vpp_3d_mode = VPP_3D_MODE_TB;
-                               *src_width = vf->width;
-                               *src_height = vf->height >> 1;
+                               *src_width = frame_width;
+                               *src_height = frame_height >> 1;
                        }
                        if (process_3d_type & MODE_FORCE_3D_FA_LR) {
                                next_frame_par->vpp_3d_mode = VPP_3D_MODE_LR;
-                               *src_width = vf->width >> 1;
-                               *src_height = vf->height;
+                               *src_width = frame_width >> 1;
+                               *src_height = frame_height;
                        }
                        if (process_3d_type & MODE_3D_MVC) {
-                               *src_width = vf->width;
-                               *src_height = vf->height;
+                               *src_width = frame_width;
+                               *src_height = frame_height;
                                next_frame_par->vpp_3d_mode = VPP_3D_MODE_FA;
                        }
                        if (vf->trans_fmt == TVIN_TFMT_3D_FP) {
                                next_frame_par->vpp_3d_mode = VPP_3D_MODE_TB;
-                               *src_width = vf->width;
+                               *src_width = frame_width;
                                *src_height = vf->left_eye.height;
                        }
                        next_frame_par->vpp_2pic_mode = 0;
                } else if (process_3d_type & MODE_3D_OUT_LR) {
-                       *src_width = vf->width << 1;
-                       *src_height = vf->height;
+                       *src_width = frame_width << 1;
+                       *src_height = frame_height;
                        next_frame_par->vpp_2pic_mode = 2;
                } else {
-                       *src_width = vf->width;
-                       *src_height = vf->height << 1;
+                       *src_width = frame_width;
+                       *src_height = frame_height << 1;
                        next_frame_par->vpp_2pic_mode = 2;
                }
        } else {
-               *src_width = vf->width;
-               *src_height = vf->height;
+               *src_width = frame_width;
+               *src_height = frame_height;
                next_frame_par->vpp_3d_mode = VPP_3D_MODE_NULL;
                next_frame_par->vpp_2pic_mode = 0;
                next_frame_par->vpp_3d_scale = 0;
@@ -2415,8 +2440,8 @@ static void vpp_get_video_source_size(
        }
        /*avoid dividing 0 error */
        if (*src_width == 0 || *src_height == 0) {
-               *src_width = vf->width;
-               *src_height = vf->height;
+               *src_width = frame_width;
+               *src_height = frame_height;
        }
 }
 #endif