Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp261585imm; Tue, 15 May 2018 01:02:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqsDgSBa5+D7nsjm4Sk6kJtQN4Ire+y5w1opUF8U81OSiO/uo8GEVgMg6hLOWKdIz5l9DmU X-Received: by 2002:a17:902:8ec4:: with SMTP id x4-v6mr13203388plo.370.1526371373303; Tue, 15 May 2018 01:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526371373; cv=none; d=google.com; s=arc-20160816; b=AXKczYOEs6a1CEJaEc45VVkx8ajbgETuTaImBk54rG7hh+ID3KzaWc8VmQQ8OrGEii zuitGWtGrseoNej6dpqem1s/H1zo3lsVNxZliHJphWniC6vaF2ElZyruU/TqNeHdRaD1 ZHdKu+YORWvUkIC6lprNLe9CN4SELmg2AkWQkTHYZbRocP4yeepiJKgQdNl9lHPrkkGv Q8nswb8NsQAWDUyxx9yfE94W8qPKWXaVZxsCS4AtigGL8fawCo8IOtQJIDfBq9K4BBmH /2+6501gFUiHKrHuHgStD9jUJYpW0OOhfcAQOxDf7aecuh0Vja7LPtDLGwmmnTzPUMNh +WUw== 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=a98vy368Ek8kav7BscKJ5dhB9a5blZNgWY5G48n3VjI=; b=aIefbQ31y67Ft0SPfLDaUEeJ3DF/6PIhlWAh5eoM6wmUD3Sugh5oQQPu44TLGKRYvb /FCsOXGLRJtFSA6vEp+1tfocqWcnXEDAFvl/7k1SWFeMvxUGlKrRFuvCiFDFiPqrCAoH 8XPRoAnE3Vas1oHKfXUMo/1Fm/g3skhpy3F1V+jzN+ICllAFi/tpElty2AnreYWZdnSg sUzS2QlZ12UeYa7FXIXTCzgAS/3rotsj0ywufVL3L5E+MhHVTTH8mFrus3gZF4n5K3jy 4t/+wPAI7XMsW0SZzEvgxBFTzJeZMBixRO8OvrUWegmzVFniPNoPp7vQjYA6lGlW1Z0P H49w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R2I7QHdx; 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 69-v6si11459297pla.548.2018.05.15.01.02.39; Tue, 15 May 2018 01:02:53 -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=R2I7QHdx; 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 S1752663AbeEOIB6 (ORCPT + 99 others); Tue, 15 May 2018 04:01:58 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:46013 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752608AbeEOH7y (ORCPT ); Tue, 15 May 2018 03:59:54 -0400 Received: by mail-wr0-f196.google.com with SMTP id p5-v6so14886605wre.12 for ; Tue, 15 May 2018 00:59:53 -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=a98vy368Ek8kav7BscKJ5dhB9a5blZNgWY5G48n3VjI=; b=R2I7QHdxOmAk0EZqcE9a4UoK0Z72LVs85KMFxGAV5cXGmb6+Nwp3y9oOzcZAY7GGnO W61hP/ZHaV7FniqjHn2KdgHkQXsiDUi56W8KQI3Bwmzq9RtyD153hLiRtuqEOc6/Hfol pRfod6uxl3ibG0rH7lp+mKdfnpJ+OaRVPn3g4= 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=a98vy368Ek8kav7BscKJ5dhB9a5blZNgWY5G48n3VjI=; b=Qk4wNUNXt+vTNjP6T7T009aQKmr7heVqaL14MTybIMTFAOtLoeDJwm80KzoLV49b5F jPUSp1VjgHPWfZXWAasY7odaRpFZGXY9ahFpQA2mAagSBg6JvvcyfJKGqk9ZlTQymGmC jeANIf+oiCG6OUa8LSeSwd7UnrVwVttYS4wheLwCX57nTJRZFvOxik6W8cLmnWklarU8 EkIjJ2GTLOVtd7X3abKOhMKfudU5QxwXxY9aatMSNL94JbeslGP8K5h8UY4UM4n1qWLU KnLYghZi+T24p8jDn7EyMcOwNk7ft0yyoZdFL3cGXCEIEqQj6s7Ifm7AonFciieGOvsQ Ei0Q== X-Gm-Message-State: ALKqPwcGgVi1Bk+zoZqLqfganS9j+mEJm7NBXhuyJqDxqThAkBJUQNXa 2XPodCMo0fGw6dMU16Jm1edCpw== X-Received: by 2002:adf:93e5:: with SMTP id 92-v6mr9515965wrp.230.1526371192936; Tue, 15 May 2018 00:59:52 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 4-v6sm10918510wmg.40.2018.05.15.00.59.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 00:59:52 -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 , Stanimir Varbanov Subject: [PATCH v2 24/29] venus: vdec: get required input buffers as well Date: Tue, 15 May 2018 10:58:54 +0300 Message-Id: <20180515075859.17217-25-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180515075859.17217-1-stanimir.varbanov@linaro.org> References: <20180515075859.17217-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 --- 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 898c5edb91f5..5a5e3e2fece4 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