vpp: merge the adapter pic mode function from 3.14
authorBrian Zhu <brian.zhu@amlogic.com>
Tue, 17 Apr 2018 08:03:40 +0000 (16:03 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Mon, 23 Apr 2018 04:25:45 +0000 (21:25 -0700)
PD#163892: vpp: merge the adapter pic mode function from 3.14
1.PD#159260: video: add new pic_mode interface in vframe
2.PD#157527: vpp: add new display mode, custom AR and AFD

Change-Id: I8714cd434001703a3c4a5aadeb4b18498cb16dc4
Signed-off-by: Brian Zhu <brian.zhu@amlogic.com>
drivers/amlogic/media/video_sink/video.c
drivers/amlogic/media/video_sink/vpp.c
include/linux/amlogic/media/vfm/vframe.h
include/linux/amlogic/media/video_sink/video.h

index e1a03a9..8a32217 100644 (file)
@@ -2068,6 +2068,7 @@ static void vsync_toggle_frame(struct vframe_s *vf)
        u32 first_picture = 0;
        unsigned long flags = 0;
        bool vf_with_el = false;
+       bool force_toggle = false;
 
        if (vf == NULL)
                return;
@@ -2375,20 +2376,31 @@ static void vsync_toggle_frame(struct vframe_s *vf)
                vf->type_backup = vf->type;
        }
 
+       if (cur_dispbuf && vf &&
+               (cur_dispbuf->ratio_control &
+               DISP_RATIO_ADAPTED_PICMODE) &&
+               (cur_dispbuf->ratio_control ==
+               vf->ratio_control) &&
+               memcmp(&cur_dispbuf->pic_mode, &vf->pic_mode,
+               sizeof(struct vframe_pic_mode_s)))
+               force_toggle = true;
+
+       if ((last_process_3d_type != process_3d_type)
+               || (last_el_status != vf_with_el))
+               force_toggle = true;
+
        /* enable new config on the new frames */
-       if ((first_picture) ||  (cur_dispbuf &&
-           ((cur_dispbuf->bufWidth != vf->bufWidth) ||
-           (cur_dispbuf->width != vf->width) ||
-           (cur_dispbuf->height != vf->height) ||
-           (cur_dispbuf->bitdepth != vf->bitdepth) ||
-           (cur_dispbuf->trans_fmt != vf->trans_fmt) ||
-           (last_process_3d_type != process_3d_type) ||
-           (cur_dispbuf->ratio_control != vf->ratio_control) ||
-           ((cur_dispbuf->type_backup & VIDTYPE_INTERLACE) !=
-            (vf->type_backup & VIDTYPE_INTERLACE)) ||
-            (last_el_status != vf_with_el) ||
-           (cur_dispbuf->type != vf->type)
-           ))) {
+       if (first_picture || force_toggle ||
+               (cur_dispbuf &&
+               ((cur_dispbuf->bufWidth != vf->bufWidth) ||
+               (cur_dispbuf->width != vf->width) ||
+               (cur_dispbuf->height != vf->height) ||
+               (cur_dispbuf->bitdepth != vf->bitdepth) ||
+               (cur_dispbuf->trans_fmt != vf->trans_fmt) ||
+               (cur_dispbuf->ratio_control != vf->ratio_control) ||
+               ((cur_dispbuf->type_backup & VIDTYPE_INTERLACE) !=
+               (vf->type_backup & VIDTYPE_INTERLACE)) ||
+               (cur_dispbuf->type != vf->type)))) {
                last_process_3d_type = process_3d_type;
                atomic_inc(&video_sizechange);
                wake_up_interruptible(&amvideo_sizechange_wait);
@@ -7230,7 +7242,7 @@ static ssize_t video_screen_mode_show(struct class *cla,
                "normal-noscaleup",
                "4-3 ignore", "4-3 letter box", "4-3 pan scan", "4-3 combined",
                "16-9 ignore", "16-9 letter box", "16-9 pan scan",
-               "16-9 combined"
+               "16-9 combined", "Custom AR", "AFD"
        };
 
        if (wide_setting < ARRAY_SIZE(wide_str)) {
@@ -8532,6 +8544,39 @@ static ssize_t free_cma_buffer_store(struct class *cla,
        return count;
 }
 
+static ssize_t pic_mode_info_show(struct class *cla,
+                       struct class_attribute *attr, char *buf)
+{
+       int ret = 0;
+
+       if (cur_dispbuf) {
+               u32 adapted_mode = (cur_dispbuf->ratio_control
+                       & DISP_RATIO_ADAPTED_PICMODE) ? 1 : 0;
+               u32 info_frame = (cur_dispbuf->ratio_control
+                       & DISP_RATIO_INFOFRAME_AVAIL) ? 1 : 0;
+
+               ret += sprintf(buf + ret, "ratio_control=0x%x\n",
+                       cur_dispbuf->ratio_control);
+               ret += sprintf(buf + ret, "adapted_mode=%d\n",
+                       adapted_mode);
+               ret += sprintf(buf + ret, "info_frame=%d\n",
+                       info_frame);
+               ret += sprintf(buf + ret,
+                       "hs=%d, he=%d, vs=%d, ve=%d\n",
+                       cur_dispbuf->pic_mode.hs,
+                       cur_dispbuf->pic_mode.he,
+                       cur_dispbuf->pic_mode.vs,
+                       cur_dispbuf->pic_mode.ve);
+               ret += sprintf(buf + ret, "screen_mode=%d\n",
+                       cur_dispbuf->pic_mode.screen_mode);
+               ret += sprintf(buf + ret, "custom_ar=%d\n",
+                       cur_dispbuf->pic_mode.custom_ar);
+               ret += sprintf(buf + ret, "AFD_enable=%d\n",
+                       cur_dispbuf->pic_mode.AFD_enable);
+               return ret;
+       }
+       return sprintf(buf, "NA\n");
+}
 
 static struct class_attribute amvideo_class_attrs[] = {
        __ATTR(axis,
@@ -8681,6 +8726,7 @@ static struct class_attribute amvideo_class_attrs[] = {
        __ATTR_RO(video_state),
        __ATTR_RO(fps_info),
        __ATTR_RO(video_layer1_state),
+       __ATTR_RO(pic_mode_info),
        __ATTR_NULL
 };
 
index b45c16a..253184e 100644 (file)
@@ -453,6 +453,10 @@ unsigned int force_vskip_cnt;
 MODULE_PARM_DESC(force_vskip_cnt, "force_vskip_cnt");
 module_param(force_vskip_cnt, uint, 0664);
 
+unsigned int disable_adapted;
+MODULE_PARM_DESC(disable_adapted, "disable_adapted");
+module_param(disable_adapted, uint, 0664);
+
 #if 0
 #define DECL_PARM(name)\
 static int name;\
@@ -600,6 +604,10 @@ unsigned int cur_vf_type;
 MODULE_PARM_DESC(cur_vf_type, "cur_vf_type");
 module_param(cur_vf_type, uint, 0444);
 
+unsigned int custom_ar;
+MODULE_PARM_DESC(custom_ar, "custom_ar");
+module_param(custom_ar, uint, 0664);
+
 /*
  *test on txlx:
  *Time_out = (V_out/V_screen_total)/FPS_out;
@@ -915,6 +923,15 @@ RESTART:
 
                orig_aspect = aspect_factor;
                screen_aspect = 0x90;
+       } else if (wide_mode == VIDEO_WIDEOPTION_CUSTOM) {
+               if (custom_ar != 0)
+                       aspect_factor = custom_ar & 0x3ff;
+               wide_mode = VIDEO_WIDEOPTION_NORMAL;
+       } else if (wide_mode == VIDEO_WIDEOPTION_AFD) {
+               if (aspect_factor == 0x90)
+                       wide_mode = VIDEO_WIDEOPTION_FULL_STRETCH;
+               else
+                       wide_mode = VIDEO_WIDEOPTION_NORMAL;
        }
 
        if (super_debug)
@@ -2405,6 +2422,20 @@ vpp_set_filters(u32 process_3d_type, u32 wide_mode,
                video_source_crop_bottom = video_crop_bottom_resv;
                video_source_crop_right = video_crop_right_resv;
        }
+
+       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.AFD_enable
+                       && (vf->ratio_control & DISP_RATIO_INFOFRAME_AVAIL))
+                       wide_mode = VIDEO_WIDEOPTION_AFD;
+               if (wide_mode == VIDEO_WIDEOPTION_CUSTOM)
+                       custom_ar = vf->pic_mode.custom_ar;
+       }
        vpp_wide_mode = wide_mode;
        vpp_flags |= wide_mode | (aspect_ratio << VPP_FLAG_AR_BITS);
 
index 9b760de..363e2c0 100644 (file)
@@ -49,6 +49,8 @@
 #define DISP_RATIO_FORCECONFIG          0x80000000
 #define DISP_RATIO_FORCE_NORMALWIDE     0x40000000
 #define DISP_RATIO_FORCE_FULL_STRETCH   0x20000000
+#define DISP_RATIO_ADAPTED_PICMODE   0x10000000
+#define DISP_RATIO_INFOFRAME_AVAIL   0x08000000
 #define DISP_RATIO_CTRL_MASK            0x00000003
 #define DISP_RATIO_NO_KEEPRATIO         0x00000000
 #define DISP_RATIO_KEEPRATIO            0x00000001
@@ -205,6 +207,16 @@ enum vframe_disp_mode_e {
        VFRAME_DISP_MODE_OK,
 };
 
+struct vframe_pic_mode_s {
+       int hs;
+       int he;
+       int vs;
+       int ve;
+       u32 screen_mode;
+       u32 custom_ar;
+       u32 AFD_enable;
+};
+
 #define BITDEPTH_Y_SHIFT 8
 #define BITDEPTH_Y8    (0 << BITDEPTH_Y_SHIFT)
 #define BITDEPTH_Y9    (1 << BITDEPTH_Y_SHIFT)
@@ -327,6 +339,7 @@ struct vframe_s {
        void *mem_handle;
        /*for MMU H265/VP9 compress header*/
        void *mem_head_handle;
+       struct vframe_pic_mode_s pic_mode;
 } /*vframe_t */;
 
 #if 0
index 2d15922..548fcea 100644 (file)
@@ -34,7 +34,9 @@ enum {
        VIDEO_WIDEOPTION_16_9_LETTER_BOX = 11,
        VIDEO_WIDEOPTION_16_9_PAN_SCAN = 12,
        VIDEO_WIDEOPTION_16_9_COMBINED = 13,
-       VIDEO_WIDEOPTION_MAX = 14
+       VIDEO_WIDEOPTION_CUSTOM = 14,
+       VIDEO_WIDEOPTION_AFD = 15,
+       VIDEO_WIDEOPTION_MAX = 16
 };
 
 extern bool pre_scaler_en;