Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1802813imu; Thu, 24 Jan 2019 02:06:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN6jAD2R4+q2ObOBWZidEIkr8/VnPBGDFWZRfxnUZaR9Wvs8mEt6BGPWWdc+wzg7j4iZ/wNH X-Received: by 2002:a65:500c:: with SMTP id f12mr5313478pgo.226.1548324381664; Thu, 24 Jan 2019 02:06:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548324381; cv=none; d=google.com; s=arc-20160816; b=pAkW4K3dkWHC1b//2uYEPUIeduyUUQZiC/wkrhm1baEgNal8CAFIA/Lr1lBGmXIfQs PMF54lrDIAJs5T9da9fUjqZ0hKzzQlJQEaW8wOEPFDZdpqC58V0NtAlOqag8aoRMz2+f J9oJfjAI78frAysDoghIEf7HISXHU+/hhQlgc4nn/C1NqHiHHUmpsjxVNpm4MqiVEvg5 fnku8l6bEkpRH5miyv0aqY63LUelBsHQ9AYuF2Ar3pw5JUjUd7MULmtz8g+GJ/t8V7ql Yl9wZdfHO38T42UjeG1zAynCeycwLEZhaWCbqQ6TX0cskWGb41lUVPEW0OyZ+zAA/gnD XuOg== 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=QAPHQPCNfLb16lyoGdiMrr4PvrUtI4vmLTnDYhA4gvg=; b=cAs3IIa7K5FKjOue/3SjR10fKVF/czmJVlX7mDAXyCnGtc/RALo61KXPvLz7AplPTY XZJPcWMQVcJk7aodFSKiGKmlV73g6DT2yBWt0ZNVz8ZmHkAIA7690EkmPcCszmas1Vra MBhP0q1by9yNvC4amBhpIjYTkBuHn1dcQbLyBrsVsNRCk041odW9KUjdvOUyqQjH9Y+b 2C/48zvWY8ZgIlD8IxQWeREj08bV9e5nT+xK1AgtzVbo4eRMkXlbrcsXE+7SEhlFbeLG mLZD8hxvMwLECQud/FHrO0qmpKszainymU14ibHBSQF0mhx6+gLcYwOX/uP6RoaPPOkV 0Mgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PIpm1oQw; 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 3si21535427plv.258.2019.01.24.02.06.06; Thu, 24 Jan 2019 02:06: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=PIpm1oQw; 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 S1726140AbfAXKFS (ORCPT + 99 others); Thu, 24 Jan 2019 05:05:18 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36964 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbfAXKFR (ORCPT ); Thu, 24 Jan 2019 05:05:17 -0500 Received: by mail-wr1-f65.google.com with SMTP id s12so5770821wrt.4 for ; Thu, 24 Jan 2019 02:05:15 -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=QAPHQPCNfLb16lyoGdiMrr4PvrUtI4vmLTnDYhA4gvg=; b=PIpm1oQwmFSOTlRI3NN/pysAGQdyqEOzYsk6OTCh06kd9So62WhSkGDu9qPjgJRDN2 ZAJFdGg5bKIiaD2LSNo2bRpNjy11TRhS0aR0lwu80AzhK93uZyeZOwFJlZmC2GG21g4x Nkq0IdlbVro73GL6Fm/tqSF4o/+Sjg1vVoUVU= 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=QAPHQPCNfLb16lyoGdiMrr4PvrUtI4vmLTnDYhA4gvg=; b=bBsezj8qhlP1XfCDnGLmCJQ7FHD7SdWfMvofrd+NIgXwKIvYj457ziqyMCqXLTmzla nmTl21Jf06g+ecWyaRTAQkMHGapWGGCYNAuiAJjHWDiOdKpUQkzJLGEY+AiBHvS50hxl NEUFOmUnpu7m+K+ak5nICIbbK5c/09n+ErS6d3h1N6p/P6BlQI1kXz8s5bFybRGLCq8K QKdKXxkhInwMkGCLKHz6pr5JjrPUE3Pnc3sEPziog4JPqHJkZwV+j8seQAHOk9YYa1wv nmoQDlDYTTrvX6yw1iZCQ8tvU2fupcNuXGhfaCydDKpXNiOv1vsFMscu3exEi/LgE68e gV8g== X-Gm-Message-State: AJcUukedyWpT8fyMMBJzmld4yZwXEjRJieR/XUV6NKqxMhLRuOpZM9As g/XBOGlrYnmc2+lNjG8TsooRZqkXdTc= X-Received: by 2002:adf:891a:: with SMTP id s26mr6436027wrs.44.1548324315099; Thu, 24 Jan 2019 02:05:15 -0800 (PST) Received: from [192.168.27.209] ([37.157.136.206]) by smtp.googlemail.com with ESMTPSA id a8sm32941117wme.23.2019.01.24.02.05.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 02:05:14 -0800 (PST) Subject: Re: [PATCH 09/10] venus: vdec: allow bigger sizeimage set by clients To: Alexandre Courbot Cc: Linux Media Mailing List , Mauro Carvalho Chehab , Hans Verkuil , LKML , linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Malathi Gottam References: <20190117162008.25217-1-stanimir.varbanov@linaro.org> <20190117162008.25217-10-stanimir.varbanov@linaro.org> From: Stanimir Varbanov Message-ID: <580839ce-c98b-8b88-8868-e5df8171923b@linaro.org> Date: Thu, 24 Jan 2019 12:05:08 +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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); > >> 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); > > > >> inst->input_buf_size = sizes[0]; >> *num_buffers = max(*num_buffers, in_num); >> inst->num_input_bufs = *num_buffers; >> -- >> 2.17.1 >> -- regards, Stan