From patchwork Fri Jun 28 12:59:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 168089 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3670899ilk; Fri, 28 Jun 2019 06:01:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2u7Bau4hr5onVbJltmq3uHNo+d5YIYTu9RIlK5klh0SKoSaN0lFEypTS8inTsVM/dkYf/ X-Received: by 2002:a17:902:a411:: with SMTP id p17mr11626125plq.104.1561726869934; Fri, 28 Jun 2019 06:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561726869; cv=none; d=google.com; s=arc-20160816; b=I+UDenpYmN0BqGNy90bqdyv2+1x3ikDZ+DHi8uaQu97fb16AOt5BLsBJZUpbgCnH+8 kBQ9iJqQW9xKH/kuLCu1d0h09iKcOouCcINbin9hgYWa+SQZSZ3BZBHH60DEig98xmxG wucR1RINp2nFygtQiWnFxZqfUBVrxnKZD+3Q78NJ2ACqwJ8JfcwiWwD+h1IaalOBOfmN BBjGXvE9oqs2q67WghaWI8R5HYm5ncvUYhkSeT7nvc7ctaYVb1txnWo7PtJvSBSFAJYz EtIr+DglflFNQSWB6gv1O/KeVSHKiIx0Qch8GFBXaB++hK8z6Vm2/d0+1DSmCkX6VcHN a4Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=FBLKO27dHaQrao2r2KD0kPHzW+2HdrGXpaJBaZnrR7A=; b=JEYDjtU2v7Yd/Zx+vgjndC4eSNO7hvGAadmHpgz9Xyg1H0rd0g6QtiwfW4iTBwbz29 wYeWkEUou9SdQOTPQOxyB5PgTEHFwTYtrKBL7Y35kjeu6uijxb/TuoWDc1vX/vSH7IOS DA58Zdirg/mMBlJJsFntK9I5TfCbORbfKIPoAy3oqBH7Oy6W/ipVlWxn2WeEOjxLfGLl 4/2Ztyr126O3ylkerWNitnbwdvQzCUxsbvFr0jnBGVbgiubMgVEvOof25w0v+1WI43au c4XnpLEorAV43Iht3lRw3jVtl/pj3X8sI95CdTPD5KLnZpbYlIdW3UDPJffQ7GouHcZ/ k5OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZAzZ4lAo; 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 j10si2097651plg.71.2019.06.28.06.01.05; Fri, 28 Jun 2019 06:01:09 -0700 (PDT) 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=ZAzZ4lAo; 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 S1727359AbfF1NBC (ORCPT + 30 others); Fri, 28 Jun 2019 09:01:02 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:32979 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727230AbfF1NAj (ORCPT ); Fri, 28 Jun 2019 09:00:39 -0400 Received: by mail-wm1-f67.google.com with SMTP id h19so9322320wme.0 for ; Fri, 28 Jun 2019 06:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FBLKO27dHaQrao2r2KD0kPHzW+2HdrGXpaJBaZnrR7A=; b=ZAzZ4lAoYkAvxfaNWBiUuUnyQCQbbNKsMpfDtAC8redcT2OJnWdYZ5zLYRV7OxhU0M cTvnN9rKm0edBhzNW9YvVCIQfxKH1oCMLpqOI9D0kamX1Q+OxtfE/rRgXdoOfqDORyb2 vo271veLtKQtd02Alrb9H2WZE3BF+ts+V99Qc9+pjEAoC5QzJqRgx5ykA6hd81UQ75dB BQF+FFDizh+8du1kybPRkxbff3Znk4xJz/0hhnoODYbwrd9hvmfJ/A1ommLfNWXLsbtA cEV4z2oRMm33vpwCmMFwuicwduGxtF7d03NUcgpzs+7xA/eeTwYATtYAaZI8gbHrVCrO Y9yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FBLKO27dHaQrao2r2KD0kPHzW+2HdrGXpaJBaZnrR7A=; b=CKfp7uF63y5gHyRg0juHpMUUHm8CGcRWtUCFhy6p00gH7jGNuKoc/5EqcPN8tg/kRc inQpPahiSgr53FzNzxjM/PqjaQ5AorYhbHqIwqPNpZy2np2TCCAb+fArAImwo2NFsG3m jqMEYIWGsuhIgEcJL1zvT6ZCEvGaWv1vFaLMR4+WuTQ8HOUZu+jwoOXvCIACkhOZa7YZ 7iPWqDZ4UjfXjbp82UpF0RqwU1tK7U0/ASci543Z/G/2hDFj8+LpszZnCohgutmjr1f9 9q2gh9cMalQKUC1/5g8P9tO56zQ4Jf7p1XyDLXwQNELgeWU70YUgp+vlw+Of0mDmy8Da FR9w== X-Gm-Message-State: APjAAAXQAteLJExZA24W2EnLO238Pm0/W8sWa9x376yLbng1Ozwit2EP J1S5b9BoV1EtY0nWlccIYZJiQg== X-Received: by 2002:a1c:9a03:: with SMTP id c3mr7324818wme.101.1561726837254; Fri, 28 Jun 2019 06:00:37 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id w20sm3717174wra.96.2019.06.28.06.00.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 06:00:36 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v2 08/11] venus: vdec: allow bigger sizeimage set by clients Date: Fri, 28 Jun 2019 15:59:59 +0300 Message-Id: <20190628130002.24293-9-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190628130002.24293-1-stanimir.varbanov@linaro.org> References: <20190628130002.24293-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index e1f998656c07..fb9afee76793 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -133,6 +133,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)); @@ -161,14 +162,17 @@ 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_8M); + pfmt[0].sizeimage = max(pfmt[0].sizeimage, szimage); pfmt[0].bytesperline = 0; + } return fmt; } @@ -266,6 +270,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)); @@ -728,6 +733,7 @@ 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); + 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;