author | Nanxin Qin <nanxin.qin@amlogic.com> | 2020-01-12 09:08:17 (GMT) |
---|---|---|
committer | Nanxin Qin <nanxin.qin@amlogic.com> | 2020-01-17 07:42:37 (GMT) |
commit | 0fbadf023b5f11c49b07a1723fdc5253ce9e7c3b (patch) | |
tree | ee78cae633f0b556ed552b326f79d210537b5e5c | |
parent | 4443fc37b2b7439cef3fe9ed80347f5061a0e552 (diff) | |
download | media_modules-0fbadf023b5f11c49b07a1723fdc5253ce9e7c3b.zip media_modules-0fbadf023b5f11c49b07a1723fdc5253ce9e7c3b.tar.gz media_modules-0fbadf023b5f11c49b07a1723fdc5253ce9e7c3b.tar.bz2 |
v4l: fixed video blurred when resolution change. [2/2]
PD#SWPL-19709
Problem:
Playback youtube 360vr video blurred screen when switch
Solution:
need to check the inst is valid when the res change.
Verify:
u212
Change-Id: I8d9f65a320e62568f470d0ed17621f9cfd5b6dd5
Signed-off-by: Nanxin Qin <nanxin.qin@amlogic.com>
-rw-r--r-- | drivers/amvdec_ports/aml_vcodec_dec.c | 86 | ||||
-rw-r--r-- | drivers/amvdec_ports/aml_vcodec_dec_drv.c | 16 | ||||
-rw-r--r-- | drivers/frame_provider/decoder/vp9/vvp9.c | 3 |
3 files changed, 75 insertions, 30 deletions
diff --git a/drivers/amvdec_ports/aml_vcodec_dec.c b/drivers/amvdec_ports/aml_vcodec_dec.c index ec6d6e3..d15cfe7 100644 --- a/drivers/amvdec_ports/aml_vcodec_dec.c +++ b/drivers/amvdec_ports/aml_vcodec_dec.c @@ -281,29 +281,66 @@ static void aml_vdec_pic_info_update(struct aml_vcodec_ctx *ctx) ctx->picinfo = ctx->last_decoded_picinfo; } +static bool aml_check_inst_quit(struct aml_vcodec_dev *dev, + struct aml_vcodec_ctx * inst, u32 id) +{ + struct aml_vcodec_ctx *ctx = NULL; + bool ret = true; + + if (dev == NULL) + return false; + + mutex_lock(&dev->dev_mutex); + + if (list_empty(&dev->ctx_list)) { + pr_info("v4l inst list is empty.\n"); + ret = true; + goto out; + } + + list_for_each_entry(ctx, &dev->ctx_list, list) { + if ((ctx == inst) && (ctx->id == id)) { + ret = ctx->receive_cmd_stop ? true : false; + goto out; + } + } +out: + mutex_unlock(&dev->dev_mutex); + + return ret; +} + void vdec_frame_buffer_release(void *data) { struct file_private_data *priv_data = (struct file_private_data *) data; - struct vframe_s *vf = &priv_data->vf; + struct aml_vcodec_dev *dev = (struct aml_vcodec_dev *) + priv_data->v4l_dev_handle; + struct aml_vcodec_ctx *inst = (struct aml_vcodec_ctx *) + priv_data->v4l_inst_handle; + u32 id = priv_data->v4l_inst_id; + + if (aml_check_inst_quit(dev, inst, id)) { + struct vframe_s *vf = &priv_data->vf; + + if (decoder_bmmu_box_valide_check(vf->mm_box.bmmu_box)) { + decoder_bmmu_box_free_idx(vf->mm_box.bmmu_box, + vf->mm_box.bmmu_idx); + decoder_bmmu_try_to_release_box(vf->mm_box.bmmu_box); + } - if (decoder_bmmu_box_valide_check(vf->mm_box.bmmu_box)) { - decoder_bmmu_box_free_idx(vf->mm_box.bmmu_box, - vf->mm_box.bmmu_idx); - decoder_bmmu_try_to_release_box(vf->mm_box.bmmu_box); - } + if (decoder_mmu_box_valide_check(vf->mm_box.mmu_box)) { + decoder_mmu_box_free_idx(vf->mm_box.mmu_box, + vf->mm_box.mmu_idx); + decoder_mmu_try_to_release_box(vf->mm_box.mmu_box); + } - if (decoder_mmu_box_valide_check(vf->mm_box.mmu_box)) { - decoder_mmu_box_free_idx(vf->mm_box.mmu_box, - vf->mm_box.mmu_idx); - decoder_mmu_try_to_release_box(vf->mm_box.mmu_box); + aml_v4l2_debug(2, "%s vf idx: %d, bmmu idx: %d, bmmu_box: %lx", + __func__, vf->index, vf->mm_box.bmmu_idx, (ulong) vf->mm_box.bmmu_box); + aml_v4l2_debug(2, "%s vf idx: %d, mmu_idx: %d, mmu_box: %lx", + __func__, vf->index, vf->mm_box.mmu_idx, (ulong) vf->mm_box.mmu_box); } - aml_v4l2_debug(2, "%s vf idx: %d, bmmu idx: %d, bmmu_box: %p", - __func__, vf->index, vf->mm_box.bmmu_idx, vf->mm_box.bmmu_box); - aml_v4l2_debug(2, "%s vf idx: %d, mmu_idx: %d, mmu_box: %p", - __func__, vf->index, vf->mm_box.mmu_idx, vf->mm_box.mmu_box); - memset(data, 0, sizeof(struct file_private_data)); kfree(data); } @@ -454,10 +491,10 @@ void trans_vframe_to_user(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer *f struct aml_video_dec_buf *dstbuf = NULL; struct vframe_s *vf = (struct vframe_s *)fb->vf_handle; - aml_v4l2_debug(3, "[%d] FROM (%s %s) vf: %p, ts: %llx, idx: %d", + aml_v4l2_debug(3, "[%d] FROM (%s %s) vf: %lx, ts: %llx, idx: %d", ctx->id, vf_get_provider(ctx->ada_ctx->recv_name)->name, ctx->ada_ctx->vfm_path != FRAME_BASE_PATH_V4L_VIDEO ? "OSD" : "VIDEO", - vf, vf->timestamp, vf->index); + (ulong) vf, vf->timestamp, vf->index); aml_v4l2_debug(4, "[%d] FROM Y:(%lx, %u) C/U:(%lx, %u) V:(%lx, %u)", ctx->id, fb->m.mem[0].addr, fb->m.mem[0].size, @@ -1219,6 +1256,9 @@ static int vidioc_vdec_dqbuf(struct file *file, void *priv, vq = v4l2_m2m_get_vq(ctx->m2m_ctx, buf->type); vb2_v4l2 = to_vb2_v4l2_buffer(vq->bufs[buf->index]); aml_buf = container_of(vb2_v4l2, struct aml_video_dec_buf, vb); + aml_buf->privdata.v4l_dev_handle = (ulong) ctx->dev; + aml_buf->privdata.v4l_inst_handle = (ulong) ctx; + aml_buf->privdata.v4l_inst_id = ctx->id; file = fget(vb2_v4l2->private); if (is_v4l2_buf_file(file)) { @@ -1226,9 +1266,9 @@ static int vidioc_vdec_dqbuf(struct file *file, void *priv, (void*)&aml_buf->privdata, sizeof(struct file_private_data)); ATRACE_COUNTER("v4l2_dqout_ok", aml_buf->privdata.vf.index_disp); - aml_v4l2_debug(4, "[%d] %s, disp: %d, vf: %p\n", ctx->id, + aml_v4l2_debug(4, "[%d] %s, disp: %d, vf: %lx\n", ctx->id, __func__, aml_buf->privdata.vf.index_disp, - v4l_get_vf_handle(vb2_v4l2->private)); + (ulong) v4l_get_vf_handle(vb2_v4l2->private)); } fput(file); mutex_unlock(&ctx->lock); @@ -1754,8 +1794,8 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb) vb2_v4l2 = to_vb2_v4l2_buffer(vb); buf = container_of(vb2_v4l2, struct aml_video_dec_buf, vb); - aml_v4l2_debug(3, "[%d] %s(), vb: %p, type: %d, idx: %d, state: %d, used: %d", - ctx->id, __func__, vb, vb->vb2_queue->type, + aml_v4l2_debug(3, "[%d] %s(), vb: %lx, type: %d, idx: %d, state: %d, used: %d", + ctx->id, __func__, (ulong) vb, vb->vb2_queue->type, vb->index, vb->state, buf->used); /* * check if this buffer is ready to be used after decode @@ -1772,8 +1812,8 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb) } if (!buf->que_in_m2m) { - aml_v4l2_debug(2, "[%d] enque capture buf idx %d, vf: %p", - ctx->id, vb->index, v4l_get_vf_handle(vb2_v4l2->private)); + aml_v4l2_debug(2, "[%d] enque capture buf idx %d, vf: %lx", + ctx->id, vb->index, (ulong) v4l_get_vf_handle(vb2_v4l2->private)); v4l2_m2m_buf_queue(ctx->m2m_ctx, vb2_v4l2); buf->que_in_m2m = true; diff --git a/drivers/amvdec_ports/aml_vcodec_dec_drv.c b/drivers/amvdec_ports/aml_vcodec_dec_drv.c index 43ff0c5..ca35086 100644 --- a/drivers/amvdec_ports/aml_vcodec_dec_drv.c +++ b/drivers/amvdec_ports/aml_vcodec_dec_drv.c @@ -117,7 +117,7 @@ static int fops_vcodec_open(struct file *file) list_add(&ctx->list, &dev->ctx_list); mutex_unlock(&dev->dev_mutex); - pr_info("[%d] %s decoder\n", ctx->id, dev_name(&dev->plat_dev->dev)); + pr_info("[%d] %s decoder %lx\n", ctx->id, dev_name(&dev->plat_dev->dev), (ulong)ctx); return ret; @@ -141,7 +141,7 @@ static int fops_vcodec_release(struct file *file) struct aml_vcodec_dev *dev = video_drvdata(file); struct aml_vcodec_ctx *ctx = fh_to_ctx(file->private_data); - pr_info("[%d] release decoder\n", ctx->id); + pr_info("[%d] release decoder %lx\n", ctx->id, (ulong) ctx); mutex_lock(&dev->dev_mutex); /* @@ -168,8 +168,8 @@ static int fops_vcodec_release(struct file *file) static int v4l2video_file_release(struct inode *inode, struct file *file) { - aml_v4l2_debug(2,"%s: file: 0x%p, data: %p", - __func__, file, file->private_data); + aml_v4l2_debug(2,"%s: file: %lx, data: %lx", + __func__, (ulong) file, (ulong) file->private_data); if (file->private_data) vdec_frame_buffer_release(file->private_data); @@ -205,7 +205,8 @@ int v4l2_alloc_fd(int *fd) return -ENOMEM; } - aml_v4l2_debug(2, "%s: fd %d, file %p", __func__, file_fd, file); + aml_v4l2_debug(2, "%s: fd %d, file %lx, data: %lx", __func__, + file_fd, (ulong) file, (ulong) file->private_data); fd_install(file_fd, file); *fd = file_fd; @@ -290,8 +291,11 @@ void* v4l_get_vf_handle(int fd) } data = (struct file_private_data*) file->private_data; - if (data) + if (data) { vf_handle = &data->vf; + aml_v4l2_debug(2, "%s: file: %lx, data: %lx", + __func__, (ulong) file, (ulong) data); + } fput(file); diff --git a/drivers/frame_provider/decoder/vp9/vvp9.c b/drivers/frame_provider/decoder/vp9/vvp9.c index 1334935..1089c75 100644 --- a/drivers/frame_provider/decoder/vp9/vvp9.c +++ b/drivers/frame_provider/decoder/vp9/vvp9.c @@ -9836,7 +9836,7 @@ static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask) !ctx->v4l_codec_ready && pbi->v4l_params_parsed) { ret = 0; /*the params has parsed.*/ - } else if (!ctx->v4l_codec_dpb_ready) { + } else if (ctx->cap_pool.in < ctx->dpb_size) { if (v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx) < run_ready_min_buf_num) ret = 0; @@ -10159,6 +10159,7 @@ static void init_frame_bufs(struct VP9Decoder_s *pbi) frame_bufs[i].buf.decode_idx = 0; frame_bufs[i].buf.cma_alloc_addr = 0; frame_bufs[i].buf.index = i; + frame_bufs[i].buf.vframe_bound = 0; } if (vdec->parallel_dec == 1) { |