From patchwork Wed Jun 27 15:27:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 140341 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1026524ljj; Wed, 27 Jun 2018 08:30:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIXdABCPXTozKd7Xg9gB2+kZLJhvRUnPSFnmXdsVkRX9iwRTizYkaf76j0Lv0Ye/LENzm6W X-Received: by 2002:a63:8e41:: with SMTP id k62-v6mr5522477pge.187.1530113407996; Wed, 27 Jun 2018 08:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530113407; cv=none; d=google.com; s=arc-20160816; b=PoT4SVs2yYMa949iPnqoO7UG03me6Z3guHcVf+7G2X2LLv5GShVolWAOeYh3oKHgq7 7CNZMhvPb2To7MxZfStjzT/D7uzhPUMLYMBqECLyKmITK3y2wubRVJsCUcmoII0fzscD MoXSDFJG245WkQu7qG1TiXwzJp0GVcUip9jvcRvlJjDeQysxZ0AicvOjWrWOEBxeBEkn 9UmrIQymp7lbhfSxgO8JeRzgNgKmfmnZ/koi5G4wej6BZiWFLrG0Au0kYkJyENV8a+3P paKQZBRz/AVUuuQ3ZF3vb+2P6gwAg9swSXifgw8zVSkQbXR77cxCNUcFerOyxasQdb5G khtg== 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:arc-authentication-results; bh=p0G8Yudy2bn9cBtUbsHsFM3x/BJRUPhrcvGiJndn3GM=; b=yI/c6nITTmfDahf5be1qBHqxInxjn8/cc+sLWldwZL5+He6Y94NuIBXJnn+P8/DZ35 fAQv10vXA8LBlIa3NDPTR/5nSxCs2WdF+QqjPKrtQJMve6B8q/dfduEtTxvWHdrAZTYl JA34Lr2q88BWLG03ceh0+M1xrHH3E5ozWM6nN/TdW4ZkyMhGfD1IxeFKAKJ5/Bre2Ypr 7a+dzKTP2pirVyoqySC+0sRa+Uo52cdyv6MGpI2Zz9KBcw7ZOfeP/C3cI6ctltYVcH02 MhupuuoS1yfwy5T4QFweLDS7gjoDq8x6uxdm0akso06s+5oijX7SyHowZ+mDy1qJg0UH eqow== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="D2v2iX/q"; 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=fail (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 j10-v6si3940956pff.269.2018.06.27.08.30.07; Wed, 27 Jun 2018 08:30:07 -0700 (PDT) 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=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="D2v2iX/q"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965209AbeF0PaG (ORCPT + 13 others); Wed, 27 Jun 2018 11:30:06 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:45623 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965193AbeF0P2Z (ORCPT ); Wed, 27 Jun 2018 11:28:25 -0400 Received: by mail-wr0-f193.google.com with SMTP id u7-v6so2464321wrn.12 for ; Wed, 27 Jun 2018 08:28:24 -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=KGtopIdccvCWqxzw2Y/ssJlKU0JmcRx1SeA6otkSH9k=; b=D2v2iX/qgTJOgKhlxD0O+emIRCP1LIwORkb3L6rqjSzJaIIe0RsFkPUxyQhVJLQPwi fW9fVut1BZ0XJXlA+Vl+RRIMqrsEEO6shCo2APH2uRncfiPfIGnKaFaN10abdcDC0edV cxjW7rOzZd+p3qvviFntrOVrqsrxIUzIYFgss= 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=KGtopIdccvCWqxzw2Y/ssJlKU0JmcRx1SeA6otkSH9k=; b=Y3cYuhIgbF+9YzygP6yuGrxAOIL+MwMkAYZDyPX8YTmZK4jeLwaRSpRvRmHinPY1pf h4zKAAUQ/PyYFXZrN9gNHyzV+JpUWOIiwAMt+37h5/APcbK/QEJPTELl/ak5jqoRnvln I5mi7NMRRmyl7DZVMupDzj3rSbB86gzxuix4kxnsMZVtase8PtgXlOgnqtFslZFBy5PI ZFLhpoSsTMVdDX3H/+lLa2S4XQR3enP9E9fcE4Y1Gi7LcJPziMc9Lki2O3ZTjgkY7Kmp hCrpaCPvU54xmpZ8QVBdFxhdsIJ6Gq3vexeECHoOiB8P+GsBmuJK39Y6yF8NCj0tSTUA +TjQ== X-Gm-Message-State: APt69E3Ny1R/zFUCS6qif/Ta+zem63OIboMT1rJKWxhwi+VKSgnddnYz IVIsD/O1T4skYWEvepvbceYriQ== X-Received: by 2002:adf:86e9:: with SMTP id 38-v6mr6017182wry.232.1530113304170; Wed, 27 Jun 2018 08:28:24 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id o203-v6sm2916075wmd.30.2018.06.27.08.28.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 08:28:23 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Stanimir Varbanov Subject: [PATCH v4 22/27] venus: vdec: get required input buffers as well Date: Wed, 27 Jun 2018 18:27:20 +0300 Message-Id: <20180627152725.9783-23-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180627152725.9783-1-stanimir.varbanov@linaro.org> References: <20180627152725.9783-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 Rework and rename vdec_cap_num_buffers() to get the number of input buffers too. Signed-off-by: Stanimir Varbanov Reviewed-by: Tomasz Figa --- drivers/media/platform/qcom/venus/vdec.c | 41 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 5d8bf288bd2a..55213a8d55a3 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -603,19 +603,32 @@ static int vdec_init_session(struct venus_inst *inst) return ret; } -static int vdec_cap_num_buffers(struct venus_inst *inst, unsigned int *num) +static int vdec_num_buffers(struct venus_inst *inst, unsigned int *in_num, + unsigned int *out_num) { + enum hfi_version ver = inst->core->res->hfi_version; struct hfi_buffer_requirements bufreq; int ret; + *in_num = *out_num = 0; + ret = vdec_init_session(inst); if (ret) return ret; + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); + if (ret) + goto deinit; + + *in_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); + if (ret) + goto deinit; - *num = bufreq.count_actual; + *out_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); +deinit: hfi_session_deinit(inst); return ret; @@ -626,7 +639,7 @@ static int vdec_queue_setup(struct vb2_queue *q, unsigned int sizes[], struct device *alloc_devs[]) { struct venus_inst *inst = vb2_get_drv_priv(q); - unsigned int p, num; + unsigned int p, in_num, out_num; int ret = 0; if (*num_planes) { @@ -649,35 +662,29 @@ static int vdec_queue_setup(struct vb2_queue *q, return 0; } + ret = vdec_num_buffers(inst, &in_num, &out_num); + if (ret) + return ret; + switch (q->type) { case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: *num_planes = inst->fmt_out->num_planes; sizes[0] = get_framesize_compressed(inst->out_width, inst->out_height); inst->input_buf_size = sizes[0]; + *num_buffers = max(*num_buffers, in_num); inst->num_input_bufs = *num_buffers; - - ret = vdec_cap_num_buffers(inst, &num); - if (ret) - break; - - inst->num_output_bufs = num; + inst->num_output_bufs = out_num; break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: *num_planes = inst->fmt_cap->num_planes; - ret = vdec_cap_num_buffers(inst, &num); - if (ret) - break; - - *num_buffers = max(*num_buffers, num); - for (p = 0; p < *num_planes; p++) sizes[p] = get_framesize_uncompressed(p, inst->width, inst->height); - - inst->num_output_bufs = *num_buffers; inst->output_buf_size = sizes[0]; + *num_buffers = max(*num_buffers, out_num); + inst->num_output_bufs = *num_buffers; break; default: ret = -EINVAL;