From 7b74102a17cdca96a386da90177e8c10147341a2 Mon Sep 17 00:00:00 2001 From: "renjiang.han" Date: Tue, 24 Dec 2019 22:17:44 +0800 Subject: [PATCH] video_composer: window position is abnormal. [1/1] PD#SWPL-18923 Problem: window position is abnormal. Solution: axis and crop need to be done at the same time. Verify: on U212 Change-Id: I9c3e2d16588b83734fa2d7d1dcf7acee21d0af02 Signed-off-by: renjiang.han --- .../video_composer/video_composer.c | 122 ++++++++++++------ drivers/amlogic/media/video_sink/video_hw.c | 10 +- 2 files changed, 82 insertions(+), 50 deletions(-) diff --git a/drivers/amlogic/media/video_processor/video_composer/video_composer.c b/drivers/amlogic/media/video_processor/video_composer/video_composer.c index ec9ddef9febd..ac47f08a5f0e 100644 --- a/drivers/amlogic/media/video_processor/video_composer/video_composer.c +++ b/drivers/amlogic/media/video_processor/video_composer/video_composer.c @@ -102,6 +102,14 @@ static u32 close_black; MODULE_PARM_DESC(close_black, "\n close_black\n"); module_param(close_black, uint, 0664); +static u32 debug_axis_pip; +MODULE_PARM_DESC(debug_axis_pip, "\n close_black\n"); +module_param(debug_axis_pip, uint, 0664); + +static u32 debug_crop_pip; +MODULE_PARM_DESC(debug_crop_pip, "\n close_black\n"); +module_param(debug_crop_pip, uint, 0664); + static struct class *video_composer_dev_class; static struct class_attribute video_composer_class_attrs[] = { @@ -573,45 +581,54 @@ static struct output_axis output_axis_adjust( struct frame_info_t *vframe_info, struct ge2d_composer_para *ge2d_comp_para) { - int input_width = 0, input_height = 0; - int output_w = 0, output_h = 0; + int vf_width = 0, vf_height = 0; + int render_w = 0, render_h = 0; int disp_w, disp_h; struct output_axis axis; - input_width = vframe_info->crop_w; - input_height = vframe_info->crop_h; + vf_width = vframe_info->crop_w; + vf_height = vframe_info->crop_h; disp_w = ge2d_comp_para->position_width; disp_h = ge2d_comp_para->position_height; if (ge2d_comp_para->angle & 1) { - output_h = disp_h; - output_w = - (input_height * disp_h) / input_width; - if (output_w > disp_w) { - output_h = - (output_h * disp_w) / output_w; - output_w = disp_w; + if (vf_height < disp_w) { + render_h = disp_w; + render_w = render_h * vf_height / vf_width; + } else { + render_w = vf_height; + render_h = (vf_width * vf_height) / render_w; + } + if (render_w > disp_w) { + render_h = (render_h * disp_w) / render_w; + render_w = disp_w; + } + if (render_h > disp_h) { + render_w = (render_w * disp_h) / render_h; + render_h = disp_h; } } else { - output_w = disp_w; - output_h = disp_w * input_height / input_width; - if (output_h > disp_h) { - output_h = disp_h; - output_w = disp_h * input_width / input_height; + render_w = disp_w; + render_h = disp_w * vf_height / vf_width; + if (render_h > disp_h) { + render_h = disp_h; + render_w = disp_h * vf_width / vf_height; } } - axis.left = ge2d_comp_para->position_left + - (ge2d_comp_para->position_width - output_w) / 2; - axis.top = ge2d_comp_para->position_top + - (ge2d_comp_para->position_height - output_h) / 2; - axis.width = output_w; - axis.height = output_h; - - axis.left = axis.left * dev->composer_buf_w / dev->vinfo_w; - axis.top = axis.top * dev->composer_buf_h / dev->vinfo_h; - axis.width = axis.width * dev->composer_buf_w / dev->vinfo_w; - axis.height = axis.height * dev->composer_buf_h / dev->vinfo_h; - + axis.left = ge2d_comp_para->position_left + (disp_w - render_w) / 2; + axis.top = ge2d_comp_para->position_top + (disp_h - render_h) / 2; + axis.width = render_w; + axis.height = render_h; + vc_print(dev->index, PRINT_AXIS, + "position left top width height: %d %d %d %d\n", + ge2d_comp_para->position_left, + ge2d_comp_para->position_top, + ge2d_comp_para->position_width, + ge2d_comp_para->position_height); + + vc_print(dev->index, PRINT_AXIS, + "frame out data axis left top width height: %d %d %d %d\n", + axis.left, axis.top, axis.width, axis.height); return axis; } @@ -798,10 +815,15 @@ static void vframe_composer(struct composer_dev *dev) dst_axis = output_axis_adjust(dev, vframe_info[vf_dev[i]], &dev->ge2d_para); - dev->ge2d_para.position_left = dst_axis.left; - dev->ge2d_para.position_top = dst_axis.top; - dev->ge2d_para.position_width = dst_axis.width; - dev->ge2d_para.position_height = dst_axis.height; + dev->ge2d_para.position_left = + dst_axis.left * dst_buf->buf_w / dev->vinfo_w; + dev->ge2d_para.position_top = + dst_axis.top * dst_buf->buf_h / dev->vinfo_h; + dev->ge2d_para.position_width = + dst_axis.width * dst_buf->buf_w / dev->vinfo_w; + dev->ge2d_para.position_height = dst_axis.height + * dst_buf->buf_h / dev->vinfo_h; + if (min_left > dst_axis.left) min_left = dst_axis.left; if (min_top > dst_axis.top) @@ -839,15 +861,33 @@ static void vframe_composer(struct composer_dev *dev) VIDTYPE_VIU_444 | VIDTYPE_VIU_SINGLE_PLANE | VIDTYPE_VIU_FIELD; - - dst_vf->axis[0] = 0; - dst_vf->axis[1] = 0; - dst_vf->axis[2] = 0; - dst_vf->axis[3] = 0; - dst_vf->crop[0] = min_top; - dst_vf->crop[1] = min_left; - dst_vf->crop[2] = dst_buf->buf_h - max_bottom; - dst_vf->crop[3] = dst_buf->buf_w - max_right; + if (debug_axis_pip) { + dst_vf->axis[0] = 0; + dst_vf->axis[1] = 0; + dst_vf->axis[2] = 0; + dst_vf->axis[3] = 0; + } else { + dst_vf->axis[0] = min_left; + dst_vf->axis[1] = min_top; + dst_vf->axis[2] = max_right; + dst_vf->axis[3] = max_bottom; + } + if (debug_crop_pip) { + dst_vf->crop[0] = 0; + dst_vf->crop[1] = 0; + dst_vf->crop[2] = 0; + dst_vf->crop[3] = 0; + } else { + dst_vf->crop[0] = min_top * dst_buf->buf_h / dev->vinfo_h; + dst_vf->crop[1] = min_left * dst_buf->buf_w / dev->vinfo_w; + dst_vf->crop[2] = dst_buf->buf_h - + max_bottom * dst_buf->buf_h / dev->vinfo_h; + dst_vf->crop[3] = dst_buf->buf_w - + max_right * dst_buf->buf_w / dev->vinfo_w; + } + vc_print(dev->index, PRINT_AXIS, + "min_top,min_left,max_bottom,max_right: %d %d %d %d\n", + min_top, min_left, max_bottom, max_right); dst_vf->zorder = frames_info->disp_zorder; dst_vf->canvas0_config[0].phy_addr = dst_buf->phy_addr; diff --git a/drivers/amlogic/media/video_sink/video_hw.c b/drivers/amlogic/media/video_sink/video_hw.c index 3ec1cc734eae..7aa94f810895 100644 --- a/drivers/amlogic/media/video_sink/video_hw.c +++ b/drivers/amlogic/media/video_sink/video_hw.c @@ -2548,7 +2548,6 @@ static void disable_vd1_blend(struct video_layer_s *layer) if (!layer) return; - misc_off = layer->misc_reg_offt; vd_off = layer->vd_reg_offt; afbc_off = layer->afbc_reg_offt; @@ -2562,9 +2561,6 @@ static void disable_vd1_blend(struct video_layer_s *layer) gvideo_recv[1] ? &gvideo_recv[1]->local_buf : NULL); VSYNC_WR_MPEG_REG(AFBC_ENABLE + afbc_off, 0); VSYNC_WR_MPEG_REG(VD1_IF0_GEN_REG + vd_off, 0); - if (!legacy_vpp) - VSYNC_WR_MPEG_REG( - VD1_BLEND_SRC_CTRL + misc_off, 0); if (is_dolby_vision_enable()) { if (is_meson_txlx_cpu() || @@ -2600,12 +2596,11 @@ static void disable_vd1_blend(struct video_layer_s *layer) static void disable_vd2_blend(struct video_layer_s *layer) { - u32 misc_off, vd_off, afbc_off; + u32 vd_off, afbc_off; if (!layer) return; - misc_off = layer->misc_reg_offt; vd_off = layer->vd_reg_offt; afbc_off = layer->afbc_reg_offt; if (layer->global_debug & DEBUG_FLAG_BLACKOUT) @@ -2618,9 +2613,6 @@ static void disable_vd2_blend(struct video_layer_s *layer) gvideo_recv[1] ? &gvideo_recv[1]->local_buf : NULL); VSYNC_WR_MPEG_REG(VD2_AFBC_ENABLE + afbc_off, 0); VSYNC_WR_MPEG_REG(VD2_IF0_GEN_REG + vd_off, 0); - if (!legacy_vpp) - VSYNC_WR_MPEG_REG( - VD2_BLEND_SRC_CTRL + misc_off, 0); if (layer->dispbuf && is_local_vf(layer->dispbuf)) -- 2.20.1