Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp80701imu; Thu, 24 Jan 2019 21:38:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN6CyXngGd+hErr17mUxMTOsfvsiUtvEkvyGFiIVlYT3C3saGrXd1mp/E+tWmwZDSaQRhdem X-Received: by 2002:aa7:81d0:: with SMTP id c16mr9502877pfn.153.1548394717527; Thu, 24 Jan 2019 21:38:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548394717; cv=none; d=google.com; s=arc-20160816; b=goRrxfgBC0xXHgvBgvqKHwCKISEJBzZnzgU+Fa0plPtvLGTmlz/ZtjoLSVpsGrLyLz x8Uz/YNAVYo3Pz5Z8sYkcTXh7grObglRHOpQ47nULTxqTgFIk2fjPlR47QwZFge3lrq3 cZQoes49txKpi8nUGd7a6LTtrXMXpelYmuTbSrbAobp/RBu9zk5zMZDbGaxlv/4Ny7K+ JKlCvEyjpBk+nCbdiUGzMzp99CF1NM2QDsg+dtCllBwGWimz1hoKllszx3b3cSyelgYN R3Xb6rI9Gjtx0r8LnU80tE24REszyrfNNH/dkujXjBX7KLO4Kyo29yzLq7ZvHUPKUJGU BNqA== 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=xSGOWldl7QkaG5faKqBMKqlpyKWAGBfLsQgLSNcpWLs=; b=pBqi2um0VSs3ubMIqnZHgidxL82l8ev9xCOoEgX4N4wrcYywCrH5O/6BJSoa9DuHVB sOdA6Hh67t//oULE0sprsXZ7mtDwLnv57qIFxZwm/WK3XzTBMKsQTs3KE2lPtT6mj3hb seDR4RoL6cM6OsmsCmJspI+N75MyK6sU5qfyq+ATMvxkWJ1wfetEX1AcUI58rCXlQJDY 4j2SLkrEF+0SFqRj7+QS/OcU0PqrpV/ZIcEE43sK8V4jopJA+GcA5VrthYf05jsB8yNM Vk8rvXqWX5fCDWG/HgvK9Osd6D+bn8NgWK8iRTsvGRXmYqrjxtp7w8GWBHFwc2dOx9ak YFNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fnGKJpAm; 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 v9si20205510pgo.23.2019.01.24.21.38.20; Thu, 24 Jan 2019 21:38:37 -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=fnGKJpAm; 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 S1726638AbfAYFg5 (ORCPT + 99 others); Fri, 25 Jan 2019 00:36:57 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:35308 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726257AbfAYFg5 (ORCPT ); Fri, 25 Jan 2019 00:36:57 -0500 Received: by mail-ot1-f67.google.com with SMTP id 81so7524839otj.2 for ; Thu, 24 Jan 2019 21:36:56 -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=xSGOWldl7QkaG5faKqBMKqlpyKWAGBfLsQgLSNcpWLs=; b=fnGKJpAmwwVU0Y5dKlG5+zbGsBMKo+LWAV3ustCc4VOFEm+PkgRBMvsQYgYzCb9Cze XeICRuXp61hMZ0AQj/5iYRKWmiWwOVU1MhYMrz1cLLjGVYvWfDVBiz3K8S261IHlfScf 6BL6oSXeiV/k42yBNZr/8FnHAb8obdb2cbU9g= 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=xSGOWldl7QkaG5faKqBMKqlpyKWAGBfLsQgLSNcpWLs=; b=dPwKO6ACPizSyu+NJOxGWjlzjPAt5NBv4anGcf3PCILp7hCYQDac8XLkfxvBHiIa9g ed7Ven3UOk60lmIQsYdVpEEbKDHZngyFO45Gds7cpQ+nOGUCRGONKUE38xmzBB6S3wmO aXzaFDVoiaLwiTOufLGCViI4hZte68vSb3buQccS+Z0TgKb86p8vPxDvWQP4SRcZZDUy MZBNspLgRHsU+bHrSO9Pr+p17FjoMchOF/u74i9Jy1oYAR+jlnPD9QvLjNwsym3gzz02 xHC7hjNv8eZ9QLkWAKqfa0kq3WIeH2QCGT/ETfX6Hcezq6IL4mNl7mmTSPN2cBpHmxfo Bgxg== X-Gm-Message-State: AJcUukflgzyr12W2oRuQ3l8U+JBBDTPBRzFvbyH9G4qCW+nOqW4nwmXU YH2kQorPV8ET49Q8dGq2z7jP5t0yd0uPGA== X-Received: by 2002:a9d:4682:: with SMTP id z2mr6568710ote.104.1548394615970; Thu, 24 Jan 2019 21:36:55 -0800 (PST) Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com. [209.85.167.177]) by smtp.gmail.com with ESMTPSA id j23sm867041oih.22.2019.01.24.21.36.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 21:36:55 -0800 (PST) Received: by mail-oi1-f177.google.com with SMTP id v6so6888325oif.2 for ; Thu, 24 Jan 2019 21:36:55 -0800 (PST) X-Received: by 2002:aca:af53:: with SMTP id y80mr461402oie.170.1548394614764; Thu, 24 Jan 2019 21:36:54 -0800 (PST) MIME-Version: 1.0 References: <20190117162008.25217-1-stanimir.varbanov@linaro.org> <20190117162008.25217-10-stanimir.varbanov@linaro.org> <580839ce-c98b-8b88-8868-e5df8171923b@linaro.org> In-Reply-To: <580839ce-c98b-8b88-8868-e5df8171923b@linaro.org> From: Alexandre Courbot Date: Fri, 25 Jan 2019 14:36:43 +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 Thu, Jan 24, 2019 at 7:05 PM Stanimir Varbanov wrote: > > Hi Alex, > > Thanks for the comments! > > On 1/24/19 10:43 AM, Alexandre Courbot wrote: > > 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)? > > I'm not a big fan to that calling of macro from macro :) > > What about this: > > pfmt[0].sizeimage = clamp_t(u32, pfmt[0].sizeimage, 0, SZ_4M); > pfmt[0].sizeimage = max(pfmt[0].sizeimage, szimage); Looks fine, I just wanted to make sure that we use the more expressive "max" instead of an if statement. > > > > >> 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)? > > I think it'd be more readable that way: > > sizes[0] = max(sizes[0], inst->input_buf_size); Ditto.