vc: Add dump vframe flow in video_composer. [1/1]

PD#SWPL-142332

Problem:
Add dump vframe flow in video_composer.

Solution:
Add dump vframe flow in video_composer.

Verify:
t3x

Change-Id: I14580743172695c346dd4bfb619aa8afa611a1d4
Signed-off-by: qiyao.zhou <qiyao.zhou@amlogic.com>
This commit is contained in:
qiyao.zhou
2023-10-12 14:59:41 +08:00
committed by Luan Yuan
parent 201cd3794c
commit b44ecba034
2 changed files with 35 additions and 41 deletions
@@ -29,6 +29,7 @@ static unsigned int dewarp_print;
MODULE_PARM_DESC(dewarp_print, "\n dewarp_print\n");
module_param(dewarp_print, uint, 0664);
static unsigned int dewarp_com_dump_last;
int get_dewarp_format(int vc_index, struct vframe_s *vf)
{
int format = NV12;
@@ -448,7 +449,7 @@ int config_dewarp_vframe(struct composer_vf_para *vframe_para,
int dewarp_data_composer(struct dewarp_composer_para *param, bool is_tvp)
{
int ret, dump_num = 1;
int ret;
struct gdc_phy_setting gdc_config;
char dump_name[32];
@@ -503,7 +504,7 @@ int dewarp_data_composer(struct dewarp_composer_para *param, bool is_tvp)
if (ret < 0) {
pr_info("vc:[%d] %s: dewrap process failed.\n", param->vc_index, __func__);
} else {
if (dewarp_com_dump != dump_num) {
if (dewarp_com_dump != dewarp_com_dump_last) {
sprintf(dump_name, "/data/src_%d.yuv", dewarp_com_dump);
dump_dewarp_vframe(dump_name,
param->vf_para->src_vf_width,
@@ -517,7 +518,7 @@ int dewarp_data_composer(struct dewarp_composer_para *param, bool is_tvp)
param->vf_para->dst_vf_height,
gdc_config.out_paddr[0],
gdc_config.out_paddr[1]);
dump_num = dewarp_com_dump;
dewarp_com_dump_last = dewarp_com_dump;
}
}
return ret;
@@ -127,7 +127,7 @@ u32 dewarp_load_flag; /*0 dynamic load, 1 load bin file*/
#define to_dst_buf(vf) \
container_of(vf, struct dst_buf_t, frame)
static void vd_dump_afbc_vf(u8 *data_y, u8 *data_uv, struct vframe_s *vf)
static void vd_dump_afbc_vf(u8 *data_y, u8 *data_uv, struct vframe_s *vf, int flag)
{
#ifdef CONFIG_AMLOGIC_ENABLE_VIDEO_PIPELINE_DUMP_DATA
struct file *fp = NULL;
@@ -138,7 +138,12 @@ static void vd_dump_afbc_vf(u8 *data_y, u8 *data_uv, struct vframe_s *vf)
if (!vf)
return;
snprintf(name_buf, sizeof(name_buf), "/sdcard/dst_afbc_vframe.yuv");
/*use flag to distinguish src and dst vframe*/
if (flag == 0)
snprintf(name_buf, sizeof(name_buf), "/sdcard/src_afbc_vframe.yuv");
else
snprintf(name_buf, sizeof(name_buf), "/sdcard/dst_afbc_vframe.yuv");
fp = filp_open(name_buf, O_CREAT | O_RDWR, 0644);
if (IS_ERR(fp))
return;
@@ -207,7 +212,7 @@ static void vd_dump_vf(struct vframe_s *vf)
#endif
}
static int vd_vframe_afbc_soft_decode(struct vframe_s *vf)
static int vd_vframe_afbc_soft_decode(struct vframe_s *vf, int flag)
{
int ret, i, j, y_size, free_cnt;
short *planes[4];
@@ -316,7 +321,7 @@ static int vd_vframe_afbc_soft_decode(struct vframe_s *vf)
y_dst = p;
vu_dst = p + vf->compWidth * vf->compHeight;
vd_dump_afbc_vf(y_dst, vu_dst, vf);
vd_dump_afbc_vf(y_dst, vu_dst, vf, flag);
vfree(p);
for (i = 0; i < free_cnt; i++)
vfree(planes[i]);
@@ -331,7 +336,7 @@ free:
void ext_controls(void)
{
if (current_display_vf->type & VIDTYPE_COMPRESS) {
vd_vframe_afbc_soft_decode(current_display_vf);
vd_vframe_afbc_soft_decode(current_display_vf, 1);
} else {
vd_dump_vf(current_display_vf);
}
@@ -1843,32 +1848,6 @@ static void dump_dma(int vc_index, struct frame_info_t *vframe_info_cur,
#endif
}
static void dump_fbc_out_data(ulong addr, u32 data_size)
{
#ifdef CONFIG_AMLOGIC_ENABLE_VIDEO_PIPELINE_DUMP_DATA
struct file *fp = NULL;
loff_t pos;
u8 *virt_addr = NULL;
pr_info("%s: addr is 0x%lx.\n", __func__, addr);
fp = filp_open("/data/fbc_out.bin", O_CREAT | O_RDWR, 0644);
if (IS_ERR(fp))
return;
virt_addr = codec_mm_phys_to_virt(addr);
if (IS_ERR_OR_NULL(virt_addr)) {
pr_info("%s: vmap failed.\n", __func__);
return;
}
pos = fp->f_pos;
kernel_write(fp, virt_addr, data_size, &pos);
fp->f_pos = pos;
pr_info("%s: read %u size from addr:%p\n", __func__, data_size, virt_addr);
filp_close(fp, NULL);
#endif
}
static bool check_dewarp_support_status(struct composer_dev *dev,
struct received_frames_t *received_frames)
{
@@ -2994,17 +2973,23 @@ static void vframe_composer(struct composer_dev *dev)
dev->fake_vf = *dev->last_dst_vf;
if (dump_vframe != dev->vframe_dump_flag) {
dump_vf(dev->index, src_vf, 0);
if (!(is_dec_vf || is_v4l_vf))
if (is_dec_vf || is_v4l_vf) {
if (src_vf->type & VIDTYPE_COMPRESS)
vd_vframe_afbc_soft_decode(src_vf, 0);
else
dump_vf(dev->index, src_vf, 0);
} else {
dump_dma(dev->index, vframe_info_cur, addr);
dump_vf(dev->index, dst_vf, 1);
if (fbcout_en && dev->dev_choice == COMPOSER_WITH_VICP) {
dump_fbc_out_data(dst_buf->afbc_head_addr, dst_buf->afbc_head_size);
dump_fbc_out_data(dst_buf->afbc_body_addr, dst_buf->afbc_body_size);
dump_fbc_out_data(dst_buf->afbc_table_addr, dst_buf->afbc_table_size);
}
if (dst_vf->type & VIDTYPE_COMPRESS)
vd_vframe_afbc_soft_decode(dst_vf, 1);
else
dump_vf(dev->index, dst_vf, 1);
dev->vframe_dump_flag = dump_vframe;
}
if (!kfifo_put(&dev->ready_q, (const struct vframe_s *)dst_vf))
vc_print(dev->index, PRINT_ERROR, "ready_q is full\n");
@@ -3703,6 +3688,14 @@ static void video_composer_task(struct composer_dev *dev)
"ready len=%d\n", kfifo_len(&dev->ready_q));
}
dev->fake_vf = *vf;
if (dump_vframe != dev->vframe_dump_flag) {
if (vf->type & VIDTYPE_COMPRESS)
vd_vframe_afbc_soft_decode(vf, 0);
else
dump_vf(dev->index, vf, 0);
dev->vframe_dump_flag = dump_vframe;
}
atomic_set(&received_frames->on_use, false);
if (use_low_latency && dev->index == 0)
proc_lowlatency_frame(0);