Received: by 10.192.165.148 with SMTP id m20csp4732727imm; Tue, 24 Apr 2018 07:34:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx48rH7IGlXO0T07HxQjjRssgxO27R6nsiT7tCwsBkgrQdMGzuDTJXQSPboQQrmQAqYaOoDmH X-Received: by 2002:a17:902:6986:: with SMTP id l6-v6mr25129807plk.209.1524580496550; Tue, 24 Apr 2018 07:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524580496; cv=none; d=google.com; s=arc-20160816; b=nH07zU+0Amh2MOvlJZpzc17eBZE3ePsoweWf5fmc6EyImvVFJNLvjrzf41b8FU544i 7jhUH08a4KX/Nm/xUZpdYe0xhUo+eyl/vXevi5eYfZ1G3za623BR1VT1M2Qg8mFP1yvr zeTpJFBAeLKHgmYC3yfK9ipdN+D4tBlDWDvg3MrI+TM77xyPuDV7Hph4bxK0jL5atH9g 16cmqgT6dLKpdNUxpXihv99cweXzQnxf5KFnMnMm79eCJk/9EclAFkwLGVbqmqm4OKMK RjRZWDy8/W8M9P4Z9j+KXZfGNoKfoo1sdSSLrgeWgvSrVd98jFWy34Eb+PN48y48oFaS 2E3A== 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=8CZJg6udtDDseCPTSDGO7vUnuY2+DnlG9mgSuAiZvt4=; b=e8Y8o730nOH10vS0qgipK0Tp4FLGFRBV708VVG3Ka+i5c9rmjniNji1PTdnMdluc1y GGcbpNupAkNCPhi6kvsrLRjZBzc7sJvKx0agvDHuRg/z2mi8ZwVOWQQm8dFCvSXETds2 bTIALPO0Dm+RceCtDlMKF3FWuHlAq2GHn+5fc2jpZmKKzosafmcruryIe5RudL4ajPZn 3S6FzAXcafH+/hQU5zjm7zLy8XZwjNWUQ90ugzRu939qZotmJ55HuM1qXMyIyIw9lrFL rNQyjhNeQWS68hWjxnCU50z/BWkuvP/1bi3tjErPnbnEPzljJuAcgncEU3nxNJlnqAct ZvmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FN0DOURu; 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 d9si11857604pfm.226.2018.04.24.07.34.41; Tue, 24 Apr 2018 07:34:56 -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=FN0DOURu; 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 S933128AbeDXMqs (ORCPT + 99 others); Tue, 24 Apr 2018 08:46:48 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:55579 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757872AbeDXMpd (ORCPT ); Tue, 24 Apr 2018 08:45:33 -0400 Received: by mail-wm0-f65.google.com with SMTP id a8so694951wmg.5 for ; Tue, 24 Apr 2018 05:45:33 -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=8CZJg6udtDDseCPTSDGO7vUnuY2+DnlG9mgSuAiZvt4=; b=FN0DOURub0h0fNLy/jmYInJXVOK0zdju6mSwya06yvL0GIXo+MZ7i8QWrD+owQf7QL zm2wZBzvO/J+JhzWEefKGokgBtQQcl2qU/zm8sObSHfIjxscRcQPHw7jACRSy5cn3euy BelotzjX1W2lDmL54RfDCjVkOnQtBGbABfTQc= 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=8CZJg6udtDDseCPTSDGO7vUnuY2+DnlG9mgSuAiZvt4=; b=ZKp9BcMKlZdLcH9FL1pKvGnTOOf1N3iO7SVrE7tF/nxNZ1oZFdTpu9hz0g/nafDADv U+E/WzUKuEedd9qk53wJ0xcFjJFjqlV+j62VcYMvTlvGWPRzp0FI3bON6O9XUMaL3chz +HJH8tCDuEyIQg8cERFrpswoURMWFEqB+6EMVVMI2QZPSWarQIuzfa46tI70i7sdm4Xm ZKuDqsHSpqkka3OtvH95je0RgcBFviNl6Rwa4C9tgZFrGW4ZubJi7bfIds60R54wo9Fy +ldGdYQlcN8X2RAzPS7CeO+Fgln3bPAol78AwiK4Kwm72CmIUy7xYXyr5hxpGeUjpAA0 Qe4Q== X-Gm-Message-State: ALQs6tBdvHgncrm4TVmu8RJndnVKvMSLbzOoYz6j8MXiDLpfq+2keyUL ZQdYGhEbNeuEyOXs857wtcL/8w== X-Received: by 10.28.237.11 with SMTP id l11mr13352230wmh.160.1524573931933; Tue, 24 Apr 2018 05:45:31 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:31 -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 23/28] venus: vdec: get required input buffers as well Date: Tue, 24 Apr 2018 15:44:31 +0300 Message-Id: <20180424124436.26955-24-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 8d188b11b85a..6ed9b7c4bd6e 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