]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: venus: venc: amend buffer size for bitstream plane
authorMalathi Gottam <mgottam@codeaurora.org>
Mon, 26 Nov 2018 10:12:53 +0000 (08:12 -0200)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 5 Aug 2019 13:49:59 +0000 (10:49 -0300)
Accept the buffer size requested by client and compare it
against driver calculated size and set the maximum to
bitstream plane.

Signed-off-by: Malathi Gottam <mgottam@codeaurora.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/qcom/venus/venc.c

index a5f3d2c46bea6ba8456397ac2eeef4e578f66765..1b7fb2d5887c6a07fcb425c40ec7356dd011e0f5 100644 (file)
@@ -294,6 +294,7 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
        struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp;
        struct v4l2_plane_pix_format *pfmt = pixmp->plane_fmt;
        const struct venus_format *fmt;
+       u32 sizeimage;
 
        memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved));
        memset(pixmp->reserved, 0, sizeof(pixmp->reserved));
@@ -325,9 +326,10 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
        pixmp->num_planes = fmt->num_planes;
        pixmp->flags = 0;
 
-       pfmt[0].sizeimage = venus_helper_get_framesz(pixmp->pixelformat,
-                                                    pixmp->width,
-                                                    pixmp->height);
+       sizeimage = venus_helper_get_framesz(pixmp->pixelformat,
+                                            pixmp->width,
+                                            pixmp->height);
+       pfmt[0].sizeimage = max(ALIGN(pfmt[0].sizeimage, SZ_4K), sizeimage);
 
        if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
                pfmt[0].bytesperline = ALIGN(pixmp->width, 128);
@@ -399,8 +401,10 @@ static int venc_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
 
        if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
                inst->fmt_out = fmt;
-       else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+       else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
                inst->fmt_cap = fmt;
+               inst->output_buf_size = pixmp->plane_fmt[0].sizeimage;
+       }
 
        return 0;
 }
@@ -918,6 +922,7 @@ static int venc_queue_setup(struct vb2_queue *q,
                sizes[0] = venus_helper_get_framesz(inst->fmt_cap->pixfmt,
                                                    inst->width,
                                                    inst->height);
+               sizes[0] = max(sizes[0], inst->output_buf_size);
                inst->output_buf_size = sizes[0];
                break;
        default: