Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5070780imu; Tue, 13 Nov 2018 00:13:21 -0800 (PST) X-Google-Smtp-Source: AJdET5cW9ehmgOf5q6LRy1YHyax9D0/070K+wJL3q06vTc3xWWQvNR9Vmh/fpfF3D4SLuDlrty6w X-Received: by 2002:a65:610d:: with SMTP id z13mr3898817pgu.427.1542096801697; Tue, 13 Nov 2018 00:13:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542096801; cv=none; d=google.com; s=arc-20160816; b=K3WVFsSRfxoM4vqrXCpZycX+CLzfQ8hFblT9s1sdUU4p2r7YKHV+tFuHVqdMiiBYVj cHAoCpGcW7QtFkkO3lm7OVCQGWSpE4UT37wOLpoh8No0dtRaagFo+beX9ahbZfbGTt0e ceBEKPMCMwTOEulEtrcwJdTVDF90Rbm8QivjQ3Re5NW/NgxewaAfFMuDDNXGixFW3mf4 EEusj2PyEyz23RS04vfhcDFTcoYm5g2v5Xj4cxKRRExNBxzCQyhjYCd8saOSv3sg8ErA 0bgvhydAX/6yjF1OFvkimzlOQ1hJd+K/qQRj6H8CvBXOFQWPsq+wHJC204P4D8Toa/yl NW1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=3guUA5MzgU4ZBZDtUKaMxOTVGRJneH+l42/+21nWs4M=; b=G/PAR96vnKvMhXFOfVeIR+cB6sTE8BS6PaT9FY7YtdXjMS0/nYBqVvlGJSS7WEjfzI XWyQyJSk4ttmdyi4Z5oWsUMZ6UzzMvJkzEhs12POj+CgGyRAFDMixcVcrMu4R+9RGV1w cRPrZDZ6nXkPB1P78+n5bwkf/GvHMT5P8NMFEUIAkGmdkJokMfToC8mDg3jVjRWE/8xP kbFXWrq8C8vBfS2qjKlauoTJUEG9m4LOBbW6CizClz0xgVWJrDp+TcsmT3wrznjwS0bW q9WcmupBls1iFUjxgUqjuWPkTFsP8evAGxR00lBe9Fas9DbfsQPrP7bzPNfwezeMYwyn E+vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZdjusBXG; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z21si18432373pgv.363.2018.11.13.00.13.07; Tue, 13 Nov 2018 00:13:21 -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=@linaro.org header.s=google header.b=ZdjusBXG; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731225AbeKMSJS (ORCPT + 99 others); Tue, 13 Nov 2018 13:09:18 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:56064 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730998AbeKMSJS (ORCPT ); Tue, 13 Nov 2018 13:09:18 -0500 Received: by mail-wm1-f67.google.com with SMTP id i73-v6so5592533wmd.5 for ; Tue, 13 Nov 2018 00:12:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=3guUA5MzgU4ZBZDtUKaMxOTVGRJneH+l42/+21nWs4M=; b=ZdjusBXGQHm9B6iY9AGlSASHdFAV6Onpydb3ca4ThdMTfjWJjkMEB5iYgBrycX4pXT kQSOcXp6I5726geTT4B9AUn0JN3C/FcU4dziMlO4FKJudOcZiETsIOwNZ9YXXeOAqEJZ QgyqlkoV/Q+alSUxBdAU0/DWkmVT21mL5pQCg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3guUA5MzgU4ZBZDtUKaMxOTVGRJneH+l42/+21nWs4M=; b=oqwgKPAJ+tEmztqGdw0hqD9a2531b+Z1Ek3bZBhQvkAkwK59afb+scu9ZUMMkWj1FR MqYBjQY1alheN1tq3l0xg4u7FxFjziiBEXs8zQuKUyN9Br9ge8WWvrpov6b6yrFmD8lX 2A9WDvrQ0L/+UGn8vyGDkausR/ocNOQe10t8JmFqKnMLdLvgH1rSEZ4pGdgFZLkqKUdd iAZHJo2PYy59SFkVA96RztO1xXkPDqSRgBBSThqr4ax/1aYXzRvvat6MEwzkUsTndPpD C0EkniuOnZL4Dxn82wnyqOATCxnzgxfL8xLM99+BiAe6RUkY2Dcu5IzkbrkwbTv8Kd+j g5bA== X-Gm-Message-State: AGRZ1gJq2ybp2yuGEppLjNPgYqcC6MwT31mVzQc0m3ICk4V1v0kBUd+x CnA7SuMOuNrdGtY5K2T3rOvkTg== X-Received: by 2002:a1c:c902:: with SMTP id f2-v6mr2423672wmb.80.1542096738695; Tue, 13 Nov 2018 00:12:18 -0800 (PST) Received: from [192.168.27.209] ([37.157.136.206]) by smtp.googlemail.com with ESMTPSA id 78-v6sm3153122wma.30.2018.11.13.00.12.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Nov 2018 00:12:17 -0800 (PST) Subject: Re: [PATCH] media: venus: amend buffer size for bitstream plane To: mgottam@codeaurora.org Cc: Tomasz Figa , Hans Verkuil , Mauro Carvalho Chehab , Linux Media Mailing List , Linux Kernel Mailing List , linux-arm-msm , Alexandre Courbot , vgarodia@codeaurora.org References: <1539071530-1441-1-git-send-email-mgottam@codeaurora.org> <8fe1d205-c5e7-01a0-9569-d3268911cddd@linaro.org> <38dfc098517b3ddb5d96195f2e27429d@codeaurora.org> From: Stanimir Varbanov Message-ID: <86714c89-20ec-07c8-2569-65e78e8d584d@linaro.org> Date: Tue, 13 Nov 2018 10:12:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <38dfc098517b3ddb5d96195f2e27429d@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Malathi, On 11/13/18 9:28 AM, mgottam@codeaurora.org wrote: > On 2018-11-12 18:04, Stanimir Varbanov wrote: >> Hi Tomasz, >> >> On 10/23/2018 05:50 AM, Tomasz Figa wrote: >>> Hi Malathi, >>> >>> On Tue, Oct 9, 2018 at 4:58 PM Malathi Gottam >>> wrote: >>>> >>>> For lower resolutions, incase of encoder, the compressed >>>> frame size is more than half of the corresponding input >>>> YUV. Keep the size as same as YUV considering worst case. >>>> >>>> Signed-off-by: Malathi Gottam >>>> --- >>>>  drivers/media/platform/qcom/venus/helpers.c | 2 +- >>>>  1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/media/platform/qcom/venus/helpers.c >>>> b/drivers/media/platform/qcom/venus/helpers.c >>>> index 2679adb..05c5423 100644 >>>> --- a/drivers/media/platform/qcom/venus/helpers.c >>>> +++ b/drivers/media/platform/qcom/venus/helpers.c >>>> @@ -649,7 +649,7 @@ u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 >>>> width, u32 height) >>>>         } >>>> >>>>         if (compressed) { >>>> -               sz = ALIGN(height, 32) * ALIGN(width, 32) * 3 / 2 / 2; >>>> +               sz = ALIGN(height, 32) * ALIGN(width, 32) * 3 / 2; >>>>                 return ALIGN(sz, SZ_4K); >>>>         } >>> >>> Note that the driver should not enforce one particular buffer size for >>> bitstream buffers unless it's a workaround for broken firmware or >>> hardware. The userspace should be able to select the desired size. >> >> Good point! Yes, we have to extend set_fmt to allow bigger sizeimage for >> the compressed buffers (not only for encoder). > > So Stan you meant to say that we should allow s_fmt to accept client > specified size? yes but I do expect: new_sizeimage = max(user_sizeimage, venus_helper_get_framesz) and also user_sizeimage should be sanitized. > If so should we set the inst->input_buf_size here in venc_s_fmt? > > @@ -333,10 +333,10 @@static const struct venus_format * > 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); > +       if (!pfmt[0].sizeimage) > +               pfmt[0].sizeimage = > venus_helper_get_framesz(pixmp->pixelformat, > +                                                            pixmp->width, > +                                                            > pixmp->height); yes, but please make pfmt[0].sizeimage = max(pfmt[0].sizeimage, venus_helper_get_framesz) and IMO this should be only for CAPTURE queue i.e. inst->output_buf_size I'm still not sure do we need it for OUTPUT encoder queue. > >         if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) >                 pfmt[0].bytesperline = ALIGN(pixmp->width, 128); > @@ -387,6 +387,7 @@ static int venc_s_fmt(struct file *file, void *fh, > struct v4l2_format *f) >         venc_try_fmt_common(inst, &format); > >         if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { > +               inst->input_buf_size = pixmp->plane_fmt[0].sizeimage; >                 inst->out_width = format.fmt.pix_mp.width; >                 inst->out_height = format.fmt.pix_mp.height; > > Similar implementation is already handled in case of decoder. > > Then in queue setup, we can compare this against calculated size to > obtain final buffer size > > @@ -899,7 +900,8 @@ static int venc_queue_setup(struct vb2_queue *q, >                 sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt, >                                                     inst->width, >                                                     inst->height); > -               inst->input_buf_size = sizes[0]; > +               if(inst->input_buf_size < sizes[0]) > +                       inst->input_buf_size = sizes[0]; >                 break; > > I hope this meets are requirements. -- regards, Stan