Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2099934imu; Thu, 17 Jan 2019 08:22:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN7haDWLFnHGzhXiHtRz/Gd5uuuC9+I3PmqQLN6GXBEIpV5eruZXXdKI+VuunEgl+RI9vcGi X-Received: by 2002:a17:902:6b09:: with SMTP id o9mr15530701plk.208.1547742174868; Thu, 17 Jan 2019 08:22:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547742174; cv=none; d=google.com; s=arc-20160816; b=bqPh894uFMjS3tYK+gi8FG5ryDC9KTnBkAv4pZuM8RNXhkX9gbhbQClMxHyT4pKZuY 3jQgb/6D10Ia8DViJ0M5U0sWBYZmqieO+Qm+0taKrh9zRyqtWGuDSxlqFaeD6QpVpHT+ 5aBGViVgp9JWwLRj04WaGdb8gpvL/fRmjyYe2jr8vvBuOdUAmH4iXsG2rJwa8f1y0zL1 l3TpaVpTs4LWSnlMr8KzSuDfUEC0c6WA3YLd6oH9gWjq/wxK02sgdLt0UmPyT7+HjzSo cHEv8vl3kFkcKepHs9A4pTrjwLOO/91kB0ocPwvUJ9xjaIvNpDJl/IQO8bA20PghZ0p6 bxsQ== 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=Eds9q4xw0orhjML+0+08fLpuvqhD4jaXgEhoAH0/UpF9SOFbesHV62nWvQW3uCx+bT q2p5AyUOQlO+YaXdpTM3F77Uh3KULYWxGV5Ft3kBePU2EzltzjQRAbj3WNZchk9JaGAq cGPLxwMe0C5w8+SClYLMMeOKZsiHetxz3yDsix6LJvDllC54o8cOhQofOnoWwKjBvcqz BzPAa4vvuSGseEG648wwDadXDbLi0qI30DJrAM0qgeZPW/eB+6F3wATjCeFHI7sf5nIo gATzQA1C+QjTWxKJZ3ce/wr9VrUzd3Tk8teUuz8IPsHnbPbw5spznY7soRQ7UY0j5Nsw Kcvg== 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-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 f90si2027538plb.362.2019.01.17.08.22.39; Thu, 17 Jan 2019 08:22:54 -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=WhA+Lag5; 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 S1729226AbfAQQVS (ORCPT + 99 others); Thu, 17 Jan 2019 11:21:18 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35071 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729158AbfAQQVO (ORCPT ); Thu, 17 Jan 2019 11:21:14 -0500 Received: by mail-wr1-f66.google.com with SMTP id 96so11703054wrb.2 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=Z+J4l0mx9ZbCtStB6mUKOJhjZeG7asjqOUonIEZIG7T0irLwkk+WrMhYO5EuqFqbRW /D11FDK+HVcpAW35M0MNQ6vdllpp8Oc/TuAYZgHHCfRDTDoaXjMZSY7Pye9vdreKpnUR fxc/p5+1+PiCpUC1D5y7sAnmlkSw0RQN+p7KOwanc3/sL02Zw705xnO/Hr8a++rHBEE3 J8pLq49knYHoAbHwUVwE2I3NdEpH7AkKJe5oQici+9+vMry3p82BzcgkxQxsJAX8LSmO EPc8A2qvcL4gsN6vhnFFQ/RYwMDFeJmeZJHS+95qQgnHoA11AucLATh2j3gzh8D7BQLW BQyA== X-Gm-Message-State: AJcUukf8ivjzZru2ogRfdAeU1tuKUfvnWnYRj8DKHcjHjt29zNEwXcYu IG8F35C9o7lGbl0vsdNa3uhVWg== 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-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 | 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].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; -- 2.17.1