Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1739942imu; Thu, 24 Jan 2019 00:44:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN5KEuSawNZcl9d03FjmvXxA+uT7O7/+Ig0YDcbmDtcQ8wvhR37X9Ft9mzNVFgWoHBnObEfw X-Received: by 2002:a17:902:6909:: with SMTP id j9mr5531231plk.196.1548319458599; Thu, 24 Jan 2019 00:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548319458; cv=none; d=google.com; s=arc-20160816; b=XI7DpUogGvt094rGx9eVqRh2D9jKrfFHr14SJQV70JWwTQLJPmu9GQW9kE3YOcMwFH 1Iz3/jTJwfTZIvFkW8XyZm2PU8M7iNQ6iCKsb5SqzpFWmiuqgDn6YIHMFIY3EiXH/Jw+ /u+rEtklCgC9okyXLkRUI8tu6qikYzAeWz3NN5iWR76TDVqqvS5PHBXyFoxPuK+TkrCZ uNFGVgPlErpJnijSXhUDg9R6pBT6OKL6EXStJulxvz6jRLnPa17ESqXZmclIJ1mQ93w1 gxp0eIbyEfX7st80VlYsS/YHQGt0SGxiX2dM0sw6j3hmwT13UylNtMTSay1l5nVDMzzb Q+CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0IHbjA+eWfsPVp3mqIPGqB0gvsgYr2/M02Hhjj1xngA=; b=oZudaIx8sxkHytag7pFTvttXYpGLTnaVmz4cS+tgjH0OSkYWzPEH2/e4WXDqV8Ii9V g2lWy6XV6mIcsMm4TtrEn60VTUwAVU11YfOE5RuIRM0/UyTWhX2gPFuk/v5/l5s+ogPm lfGu0x5qrDwGphP9GWHfZBasmPmH5NQ3cH+kYalcv36Y6V587MD9Wt/gCH4NxEfgNcVF Sxh+Ypm9gDbo9wA3Neg9pw1V0ArQoQ576dAbvft7Te78BqpLYql5u/+vAF0NWpXuo8iH EB75fQSk735gTQfNB1+GPryc2A2Tl+mBZNv5PBZVWDiltO8KJdwAepzBKdCHGu6X6BX4 7iqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FfTdq+XQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si22260227pgf.577.2019.01.24.00.44.03; Thu, 24 Jan 2019 00:44:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FfTdq+XQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727639AbfAXInr (ORCPT + 99 others); Thu, 24 Jan 2019 03:43:47 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:36982 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727628AbfAXInp (ORCPT ); Thu, 24 Jan 2019 03:43:45 -0500 Received: by mail-oi1-f196.google.com with SMTP id y23so4211153oia.4 for ; Thu, 24 Jan 2019 00:43:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0IHbjA+eWfsPVp3mqIPGqB0gvsgYr2/M02Hhjj1xngA=; b=FfTdq+XQZ4NWG8TH7qepr9aYPo7mEkzskhdaaPadSV4OuaP6Sy6C+jpk2Xb2g5ZfPv rqklvjpgb4jyY5+dyTb7m24XRZPuEXdYWReal2+c9kd3utZCVsOmiMIma9T9IiwDtHR4 Ie9he1TDbYp9RI3dS+vVsQy5vvvOSujgpf7sU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0IHbjA+eWfsPVp3mqIPGqB0gvsgYr2/M02Hhjj1xngA=; b=UX8nv0t/DJ4tdzKshOln0J6sF9sK3cLkgQrx3QoZErx+gq6A4O37qADWHdlgRdsqWw vPA1zYj3dxp706BAbdrj3CkSvCuUr487yZjzugH6AP83mMffaqw8Bqu4ta3kw3qi8FXF j4rWSoceuPsIVD8Pw2d8dLY56NB3V6AO5JadjA0PQFwM1KHUwxcG83Wp/O7t4WL3Swgv a/SR+0MDX/4FjzY6KoieFQPA7BZpGmc/LTnIZh453vrq0CPixmxJ6TAl/Jc1I4hM5XSP ZwuFsPOc2yqPoatC2BLmzUm1uln6QroSLQfvCZd4gTeEefzmBb2FjOZyIze0tKO/fkTc lR5w== X-Gm-Message-State: AJcUuke+OBav3lajEG1VCF+FL0NXhuMIazpMlmj/IxCuJBrj4P7ZirV/ i9BH4QgPGLBEY/plzJuQfl3OV5iy4lA= X-Received: by 2002:aca:53cd:: with SMTP id h196mr562870oib.355.1548319424528; Thu, 24 Jan 2019 00:43:44 -0800 (PST) Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com. [209.85.210.53]) by smtp.gmail.com with ESMTPSA id 30sm8969477ots.52.2019.01.24.00.43.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 00:43:43 -0800 (PST) Received: by mail-ot1-f53.google.com with SMTP id u16so4540142otk.8 for ; Thu, 24 Jan 2019 00:43:43 -0800 (PST) X-Received: by 2002:a05:6830:165a:: with SMTP id h26mr3906261otr.299.1548319423408; Thu, 24 Jan 2019 00:43:43 -0800 (PST) MIME-Version: 1.0 References: <20190117162008.25217-1-stanimir.varbanov@linaro.org> <20190117162008.25217-10-stanimir.varbanov@linaro.org> In-Reply-To: <20190117162008.25217-10-stanimir.varbanov@linaro.org> From: Alexandre Courbot Date: Thu, 24 Jan 2019 17:43:31 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 09/10] venus: vdec: allow bigger sizeimage set by clients To: Stanimir Varbanov Cc: Linux Media Mailing List , Mauro Carvalho Chehab , Hans Verkuil , LKML , linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Malathi Gottam Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 18, 2019 at 1:21 AM Stanimir Varbanov wrote: > > In most of the cases the client will know better what could be > the maximum size for compressed data buffers. Change the driver > to permit the user to set bigger size for the compressed buffer > but make reasonable sanitation. > > Signed-off-by: Stanimir Varbanov > --- > drivers/media/platform/qcom/venus/vdec.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c > index 282de21cf2e1..7a9370df7515 100644 > --- a/drivers/media/platform/qcom/venus/vdec.c > +++ b/drivers/media/platform/qcom/venus/vdec.c > @@ -142,6 +142,7 @@ vdec_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 szimage; > > memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved)); > memset(pixmp->reserved, 0, sizeof(pixmp->reserved)); > @@ -170,14 +171,18 @@ vdec_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); > + szimage = venus_helper_get_framesz(pixmp->pixelformat, pixmp->width, > + pixmp->height); > > - if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) > + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { > + pfmt[0].sizeimage = szimage; > pfmt[0].bytesperline = ALIGN(pixmp->width, 128); > - else > + } else { > + pfmt[0].sizeimage = clamp_t(u32, pfmt[0].sizeimage, 0, SZ_4M); > + if (szimage > pfmt[0].sizeimage) > + pfmt[0].sizeimage = szimage; pfmt[0].sizeimage = max(clamp_t(u32, pfmt[0].sizeimage, 0, SZ_4M), szimage)? > pfmt[0].bytesperline = 0; > + } > > return fmt; > } > @@ -275,6 +280,7 @@ static int vdec_s_fmt(struct file *file, void *fh, struct v4l2_format *f) > inst->ycbcr_enc = pixmp->ycbcr_enc; > inst->quantization = pixmp->quantization; > inst->xfer_func = pixmp->xfer_func; > + inst->input_buf_size = pixmp->plane_fmt[0].sizeimage; > } > > memset(&format, 0, sizeof(format)); > @@ -737,6 +743,8 @@ static int vdec_queue_setup(struct vb2_queue *q, > sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt, > inst->out_width, > inst->out_height); > + if (inst->input_buf_size > sizes[0]) > + sizes[0] = inst->input_buf_size; sizes[0] = max(venus_helper_get_framesz(inst->fmt_out->pixfmt, inst->out_width, inst->out_height), inst->input_buf_size)? > inst->input_buf_size = sizes[0]; > *num_buffers = max(*num_buffers, in_num); > inst->num_input_bufs = *num_buffers; > -- > 2.17.1 >