tvafe: wss: add aspect ratio function[5/5]
authorxuhua zhang <xuhua.zhang@amlogic.com>
Fri, 22 Jun 2018 09:01:39 +0000 (17:01 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Wed, 11 Jul 2018 06:54:11 +0000 (23:54 -0700)
PD#165626: add wss function at LitvTV

Change-Id: Ic95bb761b9de45dc35094ed8d1b4e1cee0c25ac8
Signed-off-by: xuhua zhang <xuhua.zhang@amlogic.com>
drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c
drivers/amlogic/media/vin/tvin/tvin_global.c
drivers/amlogic/media/vin/tvin/tvin_global.h
drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c
drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c
drivers/amlogic/media/vin/tvin/vdin/vdin_vf.c
include/linux/amlogic/media/frame_provider/tvin/tvin.h

index 7fa710b..24172bc 100644 (file)
@@ -2648,14 +2648,29 @@ enum tvin_aspect_ratio_e tvafe_cvd2_get_wss(void)
        enum tvin_aspect_ratio_e aspect_ratio = TVIN_ASPECT_NULL;
 
        full_format = R_APB_BIT(CVD2_VBI_WSS_DATA1, 0, 4);
-       if (full_format == 0x8)
-               aspect_ratio = TVIN_ASPECT_4x3;
-       else if (full_format == 0x7)
-               aspect_ratio = TVIN_ASPECT_16x9;
+
+       if (full_format == TVIN_AR_14x9_LB_CENTER_VAL)
+               aspect_ratio = TVIN_ASPECT_14x9_LB_CENTER;
+       else if (full_format == TVIN_AR_14x9_LB_TOP_VAL)
+               aspect_ratio = TVIN_ASPECT_14x9_LB_TOP;
+       else if (full_format == TVIN_AR_16x9_LB_TOP_VAL)
+               aspect_ratio = TVIN_ASPECT_16x9_LB_TOP;
+       else if (full_format == TVIN_AR_16x9_FULL_VAL)
+               aspect_ratio = TVIN_ASPECT_16x9_FULL;
+       else if (full_format == TVIN_AR_4x3_FULL_VAL)
+               aspect_ratio = TVIN_ASPECT_4x3_FULL;
+       else if (full_format == TVIN_AR_16x9_LB_CENTER_VAL)
+               aspect_ratio = TVIN_ASPECT_16x9_LB_CENTER;
+       else if (full_format == TVIN_AR_16x9_LB_CENTER1_VAL)
+               aspect_ratio = TVIN_ASPECT_16x9_LB_CENTER;
+       else if (full_format == TVIN_AR_14x9_FULL_VAL)
+               aspect_ratio = TVIN_ASPECT_14x9_FULL;
        else
                aspect_ratio = TVIN_ASPECT_NULL;
+
        return aspect_ratio;
 }
+
 /*only for develop debug*/
 #ifdef TVAFE_CVD_DEBUG
 module_param(hs_adj_th_level0, uint, 0664);
index 6f23b2c..86ccf4b 100644 (file)
@@ -60,10 +60,20 @@ const char *tvin_aspect_ratio_str(enum tvin_aspect_ratio_e aspect_ratio)
        switch (aspect_ratio) {
        case TVIN_ASPECT_1x1:
                return "TVIN_ASPECT_1x1";
-       case TVIN_ASPECT_4x3:
-               return "TVIN_ASPECT_4x3";
-       case TVIN_ASPECT_16x9:
-               return "TVIN_ASPECT_16x9";
+       case TVIN_ASPECT_4x3_FULL:
+               return "TVIN_ASPECT_4x3_FULL";
+       case TVIN_ASPECT_14x9_FULL:
+               return "TVIN_ASPECT_14x9_FULL";
+       case TVIN_ASPECT_14x9_LB_CENTER:
+               return "TVIN_ASPECT_14x9_LETTERBOX_CENTER";
+       case TVIN_ASPECT_14x9_LB_TOP:
+               return "TVIN_ASPECT_14x9_LETTERBOX_TOP";
+       case TVIN_ASPECT_16x9_FULL:
+               return "TVIN_ASPECT_16x9_FULL";
+       case TVIN_ASPECT_16x9_LB_CENTER:
+               return "TVIN_ASPECT_16x9_LETTERBOX_CENTER";
+       case TVIN_ASPECT_16x9_LB_TOP:
+               return "TVIN_ASPECT_16x9_LETTERBOX_TOP";
        default:
                return "TVIN_ASPECT_NULL";
        }
index f5f93e9..5407df2 100644 (file)
@@ -375,11 +375,27 @@ struct tvin_format_s {
        unsigned int           duration;
 };
 
+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,
+};
+
 enum tvin_aspect_ratio_e {
        TVIN_ASPECT_NULL = 0,
        TVIN_ASPECT_1x1,
-       TVIN_ASPECT_4x3,
-       TVIN_ASPECT_16x9,
+       TVIN_ASPECT_4x3_FULL,
+       TVIN_ASPECT_14x9_FULL,
+       TVIN_ASPECT_14x9_LB_CENTER,
+       TVIN_ASPECT_14x9_LB_TOP,
+       TVIN_ASPECT_16x9_FULL,
+       TVIN_ASPECT_16x9_LB_CENTER,
+       TVIN_ASPECT_16x9_LB_TOP,
        TVIN_ASPECT_MAX,
 };
 
index 9a6e5e9..caab85a 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/dma-contiguous.h>
+#include <linux/amlogic/media/video_sink/video.h>
 #include "../tvin_global.h"
 #include "../tvin_format_table.h"
 #include "vdin_ctl.h"
@@ -4161,10 +4162,81 @@ void vdin_set_display_ratio(struct vdin_dev_s *devp,
        else
                vf->ratio_control = 0x0 << DISP_RATIO_ASPECT_RATIO_BIT;
 
-       if (aspect_ratio == TVIN_ASPECT_4x3)
-               vf->ratio_control = 0xc0 << DISP_RATIO_ASPECT_RATIO_BIT;
-       else if (aspect_ratio == TVIN_ASPECT_16x9)
-               vf->ratio_control = 0x90 << DISP_RATIO_ASPECT_RATIO_BIT;
+       switch (aspect_ratio) {
+       case TVIN_ASPECT_4x3_FULL:
+               vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.hs = 0;
+               vf->pic_mode.he = 0;
+               vf->pic_mode.vs = 1;
+               vf->pic_mode.ve = 0;
+               /* 3*256/4=0xc0 */
+               vf->pic_mode.custom_ar = 0xc0;
+               vf->ratio_control |= DISP_RATIO_ADAPTED_PICMODE;
+               break;
+       case TVIN_ASPECT_14x9_FULL:
+               vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.hs = 0;
+               vf->pic_mode.he = 0;
+               vf->pic_mode.vs = 1;
+               vf->pic_mode.ve = 0;
+               /* 9*256/14=0xc0 */
+               vf->pic_mode.custom_ar = 0xa4;
+               vf->ratio_control |= DISP_RATIO_ADAPTED_PICMODE;
+               break;
+       case TVIN_ASPECT_16x9_FULL:
+               vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.hs = 0;
+               vf->pic_mode.he = 0;
+               vf->pic_mode.vs = 1;
+               vf->pic_mode.ve = 0;
+               /* 9*256/16=0xc0 */
+               vf->pic_mode.custom_ar = 0x90;
+               vf->ratio_control |= DISP_RATIO_ADAPTED_PICMODE;
+               break;
+       case TVIN_ASPECT_14x9_LB_CENTER:
+               /**720/462=14/9;(576-462)/2=57;57/2=28**/
+               vf->pic_mode.screen_mode = VIDEO_WIDEOPTION_CUSTOM;
+               vf->pic_mode.hs = 0;
+               vf->pic_mode.he = 0;
+               vf->pic_mode.vs = 28;
+               vf->pic_mode.ve = 28;
+               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.hs = 0;
+               vf->pic_mode.he = 0;
+               vf->pic_mode.vs = 0;
+               vf->pic_mode.ve = 57;
+               vf->pic_mode.custom_ar = 0xa4;
+               vf->ratio_control |= DISP_RATIO_ADAPTED_PICMODE;
+               break;
+       case TVIN_ASPECT_16x9_LB_CENTER:
+               /**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.hs = 0;
+               vf->pic_mode.he = 0;
+               vf->pic_mode.vs = 70;
+               vf->pic_mode.ve = 70;
+               vf->pic_mode.custom_ar = 0x90;
+               vf->ratio_control |= DISP_RATIO_ADAPTED_PICMODE;
+               break;
+       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.hs = 0;
+               vf->pic_mode.he = 0;
+               vf->pic_mode.vs = 0;
+               vf->pic_mode.ve = 85;
+               vf->pic_mode.custom_ar = 0x90;
+               vf->ratio_control |= DISP_RATIO_ADAPTED_PICMODE;
+               break;
+       default:
+               break;
+       }
 }
 
 /*function:set source bitdepth
index 0cc514f..e9840bd 100644 (file)
@@ -2204,6 +2204,19 @@ static long vdin_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                }
                pr_info("force color range-%d\n\n", color_range_force);
                break;
+       case TVIN_IOC_SET_AUTO_RATIO_EN:
+               if (devp->index != 0)
+                       break;
+               if (copy_from_user(&(devp->auto_ratio_en),
+                       argp, sizeof(unsigned int))) {
+                       ret = -EFAULT;
+                       break;
+               }
+               if (vdin_dbg_en) {
+                       pr_info("TVIN_IOC_SET_AUTO_RATIO_EN(%d) done\n\n",
+                               devp->auto_ratio_en);
+               }
+               break;
        default:
                ret = -ENOIOCTLCMD;
        /* pr_info("%s %d is not supported command\n", __func__, cmd); */
@@ -2211,6 +2224,7 @@ static long vdin_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        }
        return ret;
 }
+
 #ifdef CONFIG_COMPAT
 static long vdin_compat_ioctl(struct file *file, unsigned int cmd,
        unsigned long arg)
@@ -2544,7 +2558,7 @@ static int vdin_drv_probe(struct platform_device *pdev)
        /*enable auto cutwindow for atv*/
        if (vdevp->index == 0) {
                vdevp->auto_cutwindow_en = 1;
-               vdevp->auto_ratio_en = 1;
+               vdevp->auto_ratio_en = 0;
                #ifdef CONFIG_CMA
                vdevp->cma_mem_mode = 1;
                #endif
index 7b9d511..73ad19f 100644 (file)
@@ -681,6 +681,8 @@ void receiver_vf_put(struct vframe_s *vf, struct vf_pool *p)
                spin_lock_irqsave(&p->wr_lock, flags);
                vf_pool_put(master, &p->wr_list);
                p->wr_list_size++;
+               memset(&(master->vf.pic_mode), 0, sizeof(master->vf.pic_mode));
+               master->vf.ratio_control = 0;
                spin_unlock_irqrestore(&p->wr_lock, flags);
                spin_lock_irqsave(&p->log_lock, flags);
                vf_log(p, VF_OPERATION_BPUT, true);
@@ -724,6 +726,9 @@ void receiver_vf_put(struct vframe_s *vf, struct vf_pool *p)
                        spin_lock_irqsave(&p->wr_lock, flags);
                        vf_pool_put(master, &p->wr_list);
                        p->wr_list_size++;
+                       memset(&(master->vf.pic_mode), 0,
+                               sizeof(master->vf.pic_mode));
+                       master->vf.ratio_control = 0;
                        spin_unlock_irqrestore(&p->wr_lock, flags);
                        slave->status = VF_STATUS_SL;
                        spin_lock_irqsave(&p->log_lock, flags);
index 2984c50..2127da5 100644 (file)
@@ -431,6 +431,8 @@ struct tvafe_pin_mux_s {
 #define TVIN_IOC_SET_COLOR_RANGE       _IOW(_TM_T, 0X4a,\
        enum tvin_force_color_range_e)
 #define TVIN_IOC_GAME_MODE          _IOW(_TM_T, 0x4b, unsigned int)
+#define TVIN_IOC_SET_AUTO_RATIO_EN  _IOW(_TM_T, 0x4c, unsigned int)
+
 /* TVAFE */
 #define TVIN_IOC_S_AFE_VGA_PARM     _IOW(_TM_T, 0x16, struct tvafe_vga_parm_s)
 #define TVIN_IOC_G_AFE_VGA_PARM     _IOR(_TM_T, 0x17, struct tvafe_vga_parm_s)