From patchwork Tue Apr 24 12:44:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 10359505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A4B8D601BE for ; Tue, 24 Apr 2018 12:48:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 963F828DB2 for ; Tue, 24 Apr 2018 12:48:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B07A28DB4; Tue, 24 Apr 2018 12:48:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A7DA26E69 for ; Tue, 24 Apr 2018 12:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933100AbeDXMql (ORCPT ); Tue, 24 Apr 2018 08:46:41 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:51233 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757873AbeDXMpe (ORCPT ); Tue, 24 Apr 2018 08:45:34 -0400 Received: by mail-wm0-f68.google.com with SMTP id j4so694039wme.1 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=gRfy8zfpOYw35p40nNIdr0Urv5NYT8+tfpMxyfLYyHGNNZqNAEPMj7MMxYVP3OkwCN MBhqfwfcPNuYB2aBEykHAwhyRKLIz8dXt55KMkb6XHBKx+YPZ/CDdkdgzNTYr3GADvUR pgCzwy1L+XMH/aT7v4/ppjntfv6jwsw9VU/rY9GjMpRtoJSQoQsoZmYi16YXuI7Dg3mL GE1E3+yq525yaGWoYWDUrkJa9nBm/U7gIcCgqhnozigyHHXvFXZ61qbFmlp00ygaBrEq KDBLvov1WEAaknuzMsCwy0OibgS9WqIeFLTybHstBdjPNkp8odGNs05DOOv70mTck5/a p80Q== X-Gm-Message-State: ALQs6tBZx4C+D0aoAceA0KjriiuaAvkBSEaBEFeCV7Kgtn5iq4HgxGhd xr+cXbUnNsPycmug/tuIRZstZ9gV4+k= X-Google-Smtp-Source: AB8JxZppJnljB+tTTEbfQPG0cxdljvzdcc+6pkj2E3EYlAnjtqEpU1YymQ/8gXVUvZMk8TKD45h/eA== 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-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;