From 307badab5492c28416fb825dc525ca270c820879 Mon Sep 17 00:00:00 2001 From: Nanxin Qin Date: Tue, 17 Dec 2019 17:04:06 +0800 Subject: [PATCH] v4l: fixed the problem of multi plane addr [1/1] PD#SWPL-13705 Problem: 1. HEBC/VP9 doesn't support multi planar buffer 2. revert limite the buffer number returned from REQBUFS as some issue on the mediahal will to be fixed. Solution: Configure canvas correctly according to vdec_v4l2_buffer Verify: U212 with VP9/HEVC streamer playback Change-Id: I0ba73005ae6e610d19eba7e8bed1b038022f7cd1 Signed-off-by: Nanxin Qin --- drivers/amvdec_ports/aml_vcodec_dec.c | 2 +- drivers/frame_provider/decoder/h265/vh265.c | 22 +++++++++++---------- drivers/frame_provider/decoder/vp9/vvp9.c | 18 +++++++++-------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/amvdec_ports/aml_vcodec_dec.c b/drivers/amvdec_ports/aml_vcodec_dec.c index 880f3a5..1a186d4 100644 --- a/drivers/amvdec_ports/aml_vcodec_dec.c +++ b/drivers/amvdec_ports/aml_vcodec_dec.c @@ -1179,7 +1179,7 @@ static int vidioc_decoder_reqbufs(struct file *file, void *priv, v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "reqbufs (st:%d) %d -> %d\n", ctx->state, rb->count, ctx->dpb_size); - rb->count = ctx->dpb_size; + //rb->count = ctx->dpb_size; } } diff --git a/drivers/frame_provider/decoder/h265/vh265.c b/drivers/frame_provider/decoder/h265/vh265.c index 04fa872..ceed425 100644 --- a/drivers/frame_provider/decoder/h265/vh265.c +++ b/drivers/frame_provider/decoder/h265/vh265.c @@ -1312,6 +1312,8 @@ struct BUF_s { u32 header_size; int used_flag; ulong v4l_ref_buf_addr; + ulong chroma_addr; + u32 chroma_size; } /*BUF_t */; /* level 6, 6.1 maximum slice number is 800; other is 200 */ @@ -3099,15 +3101,21 @@ static int v4l_alloc_buf(struct hevc_state_s *hevc, struct PIC_s *pic) pic->cma_alloc_addr = hevc->m_BUF[i].v4l_ref_buf_addr; if (fb->num_planes == 1) { hevc->m_BUF[i].start_adr = fb->m.mem[0].addr; - hevc->m_BUF[i].size = fb->m.mem[0].size; hevc->m_BUF[i].luma_size = fb->m.mem[0].offset; + hevc->m_BUF[i].size = fb->m.mem[0].size; fb->m.mem[0].bytes_used = fb->m.mem[0].size; + pic->dw_y_adr = hevc->m_BUF[i].start_adr; + pic->dw_u_v_adr = pic->dw_y_adr + hevc->m_BUF[i].luma_size; } else if (fb->num_planes == 2) { hevc->m_BUF[i].start_adr = fb->m.mem[0].addr; - hevc->m_BUF[i].size = fb->m.mem[0].size + fb->m.mem[1].size; hevc->m_BUF[i].luma_size = fb->m.mem[0].size; + hevc->m_BUF[i].chroma_addr = fb->m.mem[1].addr; + hevc->m_BUF[i].chroma_size = fb->m.mem[1].size; + hevc->m_BUF[i].size = fb->m.mem[0].size + fb->m.mem[1].size; fb->m.mem[0].bytes_used = fb->m.mem[0].size; fb->m.mem[1].bytes_used = fb->m.mem[1].size; + pic->dw_y_adr = hevc->m_BUF[i].start_adr; + pic->dw_u_v_adr = hevc->m_BUF[i].chroma_addr; } return ret; @@ -3332,16 +3340,10 @@ static int v4l_config_pic(struct hevc_state_s *hevc, struct PIC_s *pic) pic->mc_canvas_u_v = pic->index; if (dw_mode & 0x10) { - pic->mc_y_adr = hevc->m_BUF[i].start_adr; - pic->mc_u_v_adr = pic->mc_y_adr + hevc->m_BUF[i].luma_size; pic->mc_canvas_y = (pic->index << 1); pic->mc_canvas_u_v = (pic->index << 1) + 1; - - pic->dw_y_adr = pic->mc_y_adr; - pic->dw_u_v_adr = pic->mc_u_v_adr; - } else if (dw_mode) { - pic->dw_y_adr = hevc->m_BUF[i].start_adr; - pic->dw_u_v_adr = pic->dw_y_adr + hevc->m_BUF[i].luma_size; + pic->mc_y_adr = pic->dw_y_adr; + pic->mc_u_v_adr = pic->dw_u_v_adr; } return 0; diff --git a/drivers/frame_provider/decoder/vp9/vvp9.c b/drivers/frame_provider/decoder/vp9/vvp9.c index a8725bf..83efc23 100644 --- a/drivers/frame_provider/decoder/vp9/vvp9.c +++ b/drivers/frame_provider/decoder/vp9/vvp9.c @@ -295,6 +295,8 @@ struct BUF_s { ulong header_addr; u32 header_size; u32 luma_size; + ulong chroma_addr; + u32 chroma_size; } /*BUF_t */; struct MVBUF_s { @@ -4810,15 +4812,20 @@ static int v4l_alloc_and_config_pic(struct VP9Decoder_s *pbi, pic->cma_alloc_addr = fb->m.mem[0].addr; if (fb->num_planes == 1) { pbi->m_BUF[i].start_adr = fb->m.mem[0].addr; - pbi->m_BUF[i].size = fb->m.mem[0].size; pbi->m_BUF[i].luma_size = fb->m.mem[0].offset; + pbi->m_BUF[i].size = fb->m.mem[0].size; fb->m.mem[0].bytes_used = fb->m.mem[0].size; + pic->dw_y_adr = pbi->m_BUF[i].start_adr; + pic->dw_u_v_adr = pic->dw_y_adr + pbi->m_BUF[i].luma_size; } else if (fb->num_planes == 2) { pbi->m_BUF[i].start_adr = fb->m.mem[0].addr; - pbi->m_BUF[i].size = fb->m.mem[0].size + fb->m.mem[1].size; - pbi->m_BUF[i].luma_size = fb->m.mem[0].size; + pbi->m_BUF[i].size = fb->m.mem[0].size; + pbi->m_BUF[i].chroma_addr = fb->m.mem[1].addr; + pbi->m_BUF[i].chroma_size = fb->m.mem[1].size; fb->m.mem[0].bytes_used = fb->m.mem[0].size; fb->m.mem[1].bytes_used = fb->m.mem[1].size; + pic->dw_y_adr = pbi->m_BUF[i].start_adr; + pic->dw_u_v_adr = pbi->m_BUF[i].chroma_addr; } /* config frame buffer */ @@ -4831,13 +4838,8 @@ static int v4l_alloc_and_config_pic(struct VP9Decoder_s *pbi, pic->mc_canvas_u_v = pic->index; if (dw_mode & 0x10) { - pic->dw_y_adr = pbi->m_BUF[i].start_adr; - pic->dw_u_v_adr = pic->dw_y_adr + pbi->m_BUF[i].luma_size; pic->mc_canvas_y = (pic->index << 1); pic->mc_canvas_u_v = (pic->index << 1) + 1; - } else if (dw_mode) { - pic->dw_y_adr = pbi->m_BUF[i].start_adr; - pic->dw_u_v_adr = pic->dw_y_adr + pbi->m_BUF[i].luma_size; } #ifdef MV_USE_FIXED_BUF -- 2.20.1