summaryrefslogtreecommitdiff
authorSong Zhao <song.zhao@amlogic.com>2020-04-27 06:33:08 (GMT)
committer Hui Zhang <hui.zhang@amlogic.com>2020-04-30 02:35:28 (GMT)
commit6d5f19368e24dc658977b8ef06af3243735edbb8 (patch)
tree1fc838499f129c8f12e4ffd755ff5f4bb8bf25df
parentb39d60ee00946c97b8f1e9e3a900ec05650964c7 (diff)
downloadmedia_modules-6d5f19368e24dc658977b8ef06af3243735edbb8.zip
media_modules-6d5f19368e24dc658977b8ef06af3243735edbb8.tar.gz
media_modules-6d5f19368e24dc658977b8ef06af3243735edbb8.tar.bz2
v4l2: fill all fields in S_FMT [1/1]
PD#SWPL-23981 Problem: Application will use the w/h returned by S_FMT for resolution change. Solution: When decoder has correct information after PROBE state, fill all format fields Verify: U212 Cobalt Change-Id: I7f68b3dd608a6b5d429312f10f2006404b6daa81 Signed-off-by: Song Zhao <song.zhao@amlogic.com>
Diffstat
-rw-r--r--drivers/amvdec_ports/aml_vcodec_dec.c75
-rw-r--r--drivers/frame_provider/decoder/vp9/vvp9.c2
2 files changed, 42 insertions, 35 deletions
diff --git a/drivers/amvdec_ports/aml_vcodec_dec.c b/drivers/amvdec_ports/aml_vcodec_dec.c
index 8856bf8..83cc40d 100644
--- a/drivers/amvdec_ports/aml_vcodec_dec.c
+++ b/drivers/amvdec_ports/aml_vcodec_dec.c
@@ -1652,6 +1652,40 @@ static int vidioc_vdec_s_selection(struct file *file, void *priv,
return 0;
}
+static void copy_v4l2_format_dimention(struct v4l2_pix_format_mplane *pix_mp,
+ struct aml_q_data *q_data, u32 type)
+{
+ if (!pix_mp || !q_data)
+ return;
+
+ if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+ pix_mp->width = q_data->visible_width;
+ pix_mp->height = q_data->visible_height;
+ } else {
+ /*
+ * Width and height are set to the dimensions
+ * of the movie, the buffer is bigger and
+ * further processing stages should crop to this
+ * rectangle.
+ */
+ pix_mp->width = q_data->coded_width;
+ pix_mp->height = q_data->coded_height;
+ }
+
+ /*
+ * Set pixelformat to the format in which mt vcodec
+ * outputs the decoded frame
+ */
+ pix_mp->num_planes = q_data->fmt->num_planes;
+ pix_mp->pixelformat = q_data->fmt->fourcc;
+ pix_mp->plane_fmt[0].bytesperline = q_data->bytesperline[0];
+ pix_mp->plane_fmt[0].sizeimage = q_data->sizeimage[0];
+ if (type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+ pix_mp->plane_fmt[1].bytesperline = q_data->bytesperline[1];
+ pix_mp->plane_fmt[1].sizeimage = q_data->sizeimage[1];
+ }
+}
+
static int vidioc_vdec_s_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
@@ -1732,8 +1766,11 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
mutex_unlock(&ctx->state_lock);
}
- if (!V4L2_TYPE_IS_OUTPUT(f->type))
+ if (!V4L2_TYPE_IS_OUTPUT(f->type)) {
ctx->cap_pix_fmt = pix_mp->pixelformat;
+ if (ctx->state >= AML_STATE_PROBE)
+ copy_v4l2_format_dimention(pix_mp, q_data, f->type);
+ }
return 0;
}
@@ -1863,25 +1900,7 @@ static int vidioc_vdec_g_fmt(struct file *file, void *priv,
q_data->bytesperline[0] = ctx->picinfo.coded_width;
q_data->bytesperline[1] = ctx->picinfo.coded_width;
- /*
- * Width and height are set to the dimensions
- * of the movie, the buffer is bigger and
- * further processing stages should crop to this
- * rectangle.
- */
- pix_mp->width = q_data->coded_width;
- pix_mp->height = q_data->coded_height;
-
- /*
- * Set pixelformat to the format in which mt vcodec
- * outputs the decoded frame
- */
- pix_mp->num_planes = q_data->fmt->num_planes;
- pix_mp->pixelformat = q_data->fmt->fourcc;
- pix_mp->plane_fmt[0].bytesperline = q_data->bytesperline[0];
- pix_mp->plane_fmt[0].sizeimage = q_data->sizeimage[0];
- pix_mp->plane_fmt[1].bytesperline = q_data->bytesperline[1];
- pix_mp->plane_fmt[1].sizeimage = q_data->sizeimage[1];
+ copy_v4l2_format_dimention(pix_mp, q_data, f->type);
} else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
/*
* This is run on OUTPUT
@@ -1889,21 +1908,9 @@ static int vidioc_vdec_g_fmt(struct file *file, void *priv,
* so width and height have no meaning.
* Assign value here to pass v4l2-compliance test
*/
- pix_mp->width = q_data->visible_width;
- pix_mp->height = q_data->visible_height;
- pix_mp->plane_fmt[0].bytesperline = q_data->bytesperline[0];
- pix_mp->plane_fmt[0].sizeimage = q_data->sizeimage[0];
- pix_mp->pixelformat = q_data->fmt->fourcc;
- pix_mp->num_planes = q_data->fmt->num_planes;
+ copy_v4l2_format_dimention(pix_mp, q_data, f->type);
} else {
- pix_mp->width = q_data->coded_width;
- pix_mp->height = q_data->coded_height;
- pix_mp->num_planes = q_data->fmt->num_planes;
- pix_mp->pixelformat = q_data->fmt->fourcc;
- pix_mp->plane_fmt[0].bytesperline = q_data->bytesperline[0];
- pix_mp->plane_fmt[0].sizeimage = q_data->sizeimage[0];
- pix_mp->plane_fmt[1].bytesperline = q_data->bytesperline[1];
- pix_mp->plane_fmt[1].sizeimage = q_data->sizeimage[1];
+ copy_v4l2_format_dimention(pix_mp, q_data, f->type);
v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO,
"type=%d state=%d Format information could not be read, not ready yet!\n",
diff --git a/drivers/frame_provider/decoder/vp9/vvp9.c b/drivers/frame_provider/decoder/vp9/vvp9.c
index 2f4eb08..c9aee91 100644
--- a/drivers/frame_provider/decoder/vp9/vvp9.c
+++ b/drivers/frame_provider/decoder/vp9/vvp9.c
@@ -9966,7 +9966,7 @@ static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask)
if (ctx->param_sets_from_ucode) {
if (pbi->v4l_params_parsed) {
- if ((ctx->cap_pool.in < ctx->dpb_size) &&
+ if ((ctx->cap_pool.in < pbi->used_buf_num) &&
v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx) <
run_ready_min_buf_num)
ret = 0;