tvafe: fix wss issues

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>
This commit is contained in:
Nian Jing
2018-07-11 16:34:59 +08:00
committed by Yixun Lan
parent 9b63b94884
commit 86fbf24a70
8 changed files with 86 additions and 29 deletions

View 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;

View 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;
}

View 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;
};

View 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;

View 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 */

View 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 {

View 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;

View 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