Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6496170imm; Wed, 27 Jun 2018 08:32:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKKXW1chfa6NQYtJCPMZso/ou9fKQzk337W76zpcMLaS7EL9SEKFvsSEusCT1Z4KlCWQ5d5 X-Received: by 2002:a17:902:4101:: with SMTP id e1-v6mr6665146pld.205.1530113569016; Wed, 27 Jun 2018 08:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530113568; cv=none; d=google.com; s=arc-20160816; b=dh0J22/0XbX5oCQNYy0HemBFaCGROMgzNH7clhALqXovSBW8cEsCRb6d34LC3DE4Ee E2oFAcPzF29q9FFqpYrUlK9cjYpnns9+xZmtgCgR1GaqCceKUc4+0POnYs8LGTF8ny6G IzaeIjWx8Xc5dkvpPx7RQ0Aa/4nDWlaGilDcHtufajPsKYz06tfCzZY8acEFjya/h72c LKz6dGgdjgQvJmXsR1WsgfrYcqH2VXhfQOtReuSHhfAWhx2a8Dkmf1+kE+IniJvJPUz2 j0+wkQupk+OE/3qniz+q+0JVPH3mdXraZNMSNdaO+gKXDHZ/mxP8C2zVUiGSPiuhhdJo tWMg== 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=KGtopIdccvCWqxzw2Y/ssJlKU0JmcRx1SeA6otkSH9k=; b=eIZwWtZ4TR1BuWo+jcal4k8Qiv6n9PndrS6shLM8c7vUmZI+CEWCOCHXv5oxjKlEUx goKTkzMfP9b+6BqMDJD9czcEClWdzj/T6JK9LNNKs6S8sOz39JFll2/j3NoSdHgHGAvS /McCgHRaP3vw2tZfzXl7LjbCRe8WdT96boQ28YXNXKx+Fy1I/1gPIsbsqUCxNEz70sPA hHp1g9qqkIusr1/n5FFziFThdPks8DQapu/s+PfragZJby36qZud16cvh0X1I33cYJSH yPLDfrdKsqIr1M5qNYnQGAAPktWEi42cW/yORloywY5MbALEwx5ZLIrCM2noXa8GhM/1 u31Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="D2v2iX/q"; 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 13-v6si4538484ple.274.2018.06.27.08.32.35; Wed, 27 Jun 2018 08:32:48 -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="D2v2iX/q"; 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 S965535AbeF0PaG (ORCPT + 99 others); Wed, 27 Jun 2018 11:30:06 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:34173 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965209AbeF0P2Z (ORCPT ); Wed, 27 Jun 2018 11:28:25 -0400 Received: by mail-wr0-f193.google.com with SMTP id a12-v6so2487824wro.1 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=fWkKGq+fTnnufZoeJZzbNi6uI1kkJL9mvhj5dzPg+Lz+xeMBYeDJ8SXdCeWfAiW8hz m/NvX1uvziMplKS3afi5EweCBFmALDwSe5tqir7L2I/prE+4kj6lAwKAdiQB0NSdPEP0 zqyktJm/oq4YwPxhGm1PoFpAMAOgAyAw1dQXKY3Ir0hRDol7v/npKXq2ejslTFDDd/3p ZPoLtc7OL8Y3QpgPvOElACCkO9MuBLMf1CzwFwtRQCWlk0KuPsU2l+CSs+oQSop7osc5 IYbJ578w3WGayIx3aFzhi67Kwc9UwxOsczoy8TLkkXhwGcESQmmkVZno4sr19iIhOShS C5Jg== X-Gm-Message-State: APt69E1JCmOkaEIOrErCN+jV9QNRBE4mqDymC9PEleBH+hhaCEX3XNwk Hhsh9rQ/a7qzGZMqtI2TvNZynQ== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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; -- 2.14.1