From patchwork Thu Jan 17 16:20:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 155842 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2158863jaa; Thu, 17 Jan 2019 08:21:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN6zQsxMvvcbHq3MH4sfUK+9qJ2SsXJAg2LrKnUi6k9djCt1OzFOlOzRJ6gzvDFoEFKJEowU X-Received: by 2002:a17:902:ba8b:: with SMTP id k11mr15546271pls.177.1547742077598; Thu, 17 Jan 2019 08:21:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547742077; cv=none; d=google.com; s=arc-20160816; b=FWCAzslTzRC5Rn1SmlnwVZKfe0EPBmk/rC8WrG2zzLks1VEPZWOjYmwf7dOLJbZFts 7qjAhKPlzPk0MBYhoOJVIcx70BlW0KohnTmKJez4ErkTtW60mif5HQkQE2upT58xd72o FdMbVEx8wHYWrH2MwxmibKfTCAjQNdduNxZWDFk7Z4zsPJL7f+CatyhGfI0nuhTxpEHr bCH0two4Fyh06M1MrQ9EJ61t/WxhMNOaJjdlvVO703rpCAdfEFhmLZiYWziAg2OmVHne ZBZFn/TamyFBZgtMWGJCUI/05gGLj23oYvilsAOt6/kL5VQWkAlUIXXTsgCNh+N/+v5x Eb7A== 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=aHseR03KuZFgXQcyp39rH2RiSTCI0A/sA8/HyCR9OmI=; b=UMAKIUIIaqY8JtdMYfFPweK6a7khM4xU1LO2D+kidfyomWdYkG9+jmWnr7SVTWRvTg Q+IIS7D5/d17WSZ71XqcD7ZrLcyPSx/2r3G+dHzksH+rMAL/ylwGyUgqhUQK0Lx7GAqj /KywC2QqJW1IwUOwRDAlYy2o99zUVhiB8xlFDkAS6Vl0O4X4NI2GxPXWTzt/CJ93Gu/z f4mjTYiHLXiBW663hj4tDEkc4cfcvp8QMKUyT+vojo167H2bQgZs5Jlw6Fefx9GIBcLS p9bdCGQGAoHp6/JBXJ9qNHNhqJZqF+ImdpIyi6xk+6u5pXq/p/hzCcbnZhrtWhqOzkAx wanw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WhA+Lag5; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 r17si1958855pls.380.2019.01.17.08.21.17; Thu, 17 Jan 2019 08:21:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=WhA+Lag5; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1729106AbfAQQVQ (ORCPT + 15 others); Thu, 17 Jan 2019 11:21:16 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40914 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729194AbfAQQVO (ORCPT ); Thu, 17 Jan 2019 11:21:14 -0500 Received: by mail-wr1-f68.google.com with SMTP id p4so11676640wrt.7 for ; Thu, 17 Jan 2019 08:21:13 -0800 (PST) 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=aHseR03KuZFgXQcyp39rH2RiSTCI0A/sA8/HyCR9OmI=; b=WhA+Lag5SvO8FC2NrNMNujQMvxsP/XMPh4Yk/EVfTWU43kPdqeiCKqO9AuoEEsBrFK 3klZNo4hmA1AOlQvWfJ5MPj16vTdN/5KnAFQUu1LQEfJ/gk+79My0JClZ6JUYOTeV/RB /RX4vcslQoZYddkz8Ghpf1Edrq4b47zi582V4= 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=aHseR03KuZFgXQcyp39rH2RiSTCI0A/sA8/HyCR9OmI=; b=Ktw2lkJEKKabdio7ugZl1T4e0/8Z6HjH2etFcouhge8dM2lKngaH9N3j7wy8+sdpiq j2gNDexPkbMFim4lBNctQJ0pfh/lJyU0vdf4X31yveoTiyrZPY24caw/yGHnRLyKLerM FfqjfxM6S3yXBFxVmf5a5LzWiooP0UbjSEC/XsBIfeGJmAEdY/P3+Qr4Fm/F+LP9u7bb njuRkt6nrZEw3T3OtXe85YgflsQBLcCMxH0GhjA6kJFALH2l/ze+lL972b+XXo8D3o4O uOZ39M4lhxCa3yMQ3rVgRjuM0bc9N1F1qyV3OyafhM/yS+gVRngwI6Hn8AxtKcPfgbz2 hlIA== X-Gm-Message-State: AJcUukfIJ1MILIQAsiaX3egT95pLaQTN/KbHZO3C4mTUB0kNk+uZORvO 1EcrYNBKqhMBk9YUlstP/hbwkg== X-Received: by 2002:adf:9d08:: with SMTP id k8mr13422897wre.203.1547742072995; Thu, 17 Jan 2019 08:21:12 -0800 (PST) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id v133sm31124734wmf.19.2019.01.17.08.21.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 08:21:12 -0800 (PST) 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 , Malathi Gottam , Stanimir Varbanov Subject: [PATCH 09/10] venus: vdec: allow bigger sizeimage set by clients Date: Thu, 17 Jan 2019 18:20:07 +0200 Message-Id: <20190117162008.25217-10-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190117162008.25217-1-stanimir.varbanov@linaro.org> References: <20190117162008.25217-1-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 | 18 +++++++++++++----- 1 file changed, 13 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 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].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; inst->input_buf_size = sizes[0]; *num_buffers = max(*num_buffers, in_num); inst->num_input_bufs = *num_buffers;