From patchwork Wed Jun 13 15:07:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 138493 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp850969lji; Wed, 13 Jun 2018 08:11:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLOYMxw1BThHPjKOVg4S3yQ++0WJ5JrTrYIrQYC1WwCXP7Ah/C5wsf7CzHQ5Om1LfQRO2jn X-Received: by 2002:a17:902:b40f:: with SMTP id x15-v6mr5661425plr.270.1528902698152; Wed, 13 Jun 2018 08:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528902698; cv=none; d=google.com; s=arc-20160816; b=y5Cf5Rpi0fYURZbVdapa/6ytKWurKC3TzvrCnmSUlznr3PfzgAiDt3wcJ+WxlmD3xZ rrCYmeexDvtPkHkN6WPWi0xWlKq3+FZxOHKr7zurCUoErmJu40+eDUKmqFWNV34M9jGV KSdTYBdGeeXS3YJxM7MM55A55QPT1qz4r7dYxAyGaA1gzAZG6mPwrsp9BRE9BkSZhNFx QJPOIb6sR0QVpW10chSwi5H1sR7v7pn5aNGM9Di8EwrPPI346tbyOJDsj++xsNdav7BQ nL5n+hKgbxy8rKBImVywHv/gbG/dlhvUHpybwEpn2guC7pMfg3ga25Qr9feWZv3OKtHk Nl4g== 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=hhSvjIZ7Q/A4eBZrp3KYX20vsbNdS+kixHVIaQBfZbYNf9UATK+VpN58PXMQDU8iSv dWXL3XxWaQzwEH04HR7lc5/BMrNUSMP/5LAjL5GXsIQK3t/LknPnoWftByvJkNJvok7q WKk5GbSmkRrRCI3ReRK4Zrcf5imroB8ed4ouVXI4u3m3h8uC1pwETrFNnyq/tbtKRJQv 2Un1WcD7u8vp3R6iFNoMOI8ZlhfYt8y0XI2fVaV3vgbuQj3gNja+IyrmMtMbvB7ktEvn dbvS8aw6TOb3x5kKHadiRqwvUo3WoqSOgWOaD/jFXxqAhYTT3wibKTMaljjaBaYDx1jC UJZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VLaWf1fY; 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 x6-v6si3018090plv.315.2018.06.13.08.11.37; Wed, 13 Jun 2018 08:11:38 -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=VLaWf1fY; 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 S935869AbeFMPLc (ORCPT + 13 others); Wed, 13 Jun 2018 11:11:32 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37345 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935714AbeFMPJj (ORCPT ); Wed, 13 Jun 2018 11:09:39 -0400 Received: by mail-wm0-f65.google.com with SMTP id r125-v6so6101282wmg.2 for ; Wed, 13 Jun 2018 08:09:38 -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=VLaWf1fY9HIjzDFPTtNjqGiIPhWbh5+bvSYbDHF9zFah94z277RF6En+CBGFOmG7Ug WattPOxTOpRnYixcIgz+cYlxehw0InIYlAEjavYTMl/ofmyTqFEsZ7bJKx1YrzK1iVOr nuqqCCBn5aCWGOmVpBczGq2Ct+TLf5NSY9msw= 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=mCwd96at/Q9tArc9lEBt/BFFEuKsXmIx4xVZizd6qtrOMsZAgMNo1xSe9eNbqar/On tmR9jFQh6eW3rXAFHjqnyFpT9F/GbEOiBHPOL/cU9cv2RAs1nDoUAEb03idRxEnlKhlK EzB7BMRrq/GbocTeyaZeNpRQlWOfdNINTjBQnhNQkLsGMpTk60yG0AgVvBcb0FsEb9dE A+UfeTvvoW1hg+fEWQxsSUQurnqlr6tIGov8zFJGDzf9Iiha2HLQLfEZ9hNzM6MFbZgj +4gxfOucaoYkjy5sjXn89GXJVS6ZWtwM/bjjgy3dd9yqYHeswfno1mFRN7gc9Ly6PmnH JkUA== X-Gm-Message-State: APt69E3l7SBOXYKCgBKHhvktJ0B9vKdpzUnLRNtiKuXi859u2QRBjm9f 3Z9xYhKyBQWtDWMvJm6jL0knuw== X-Received: by 2002:a1c:6d85:: with SMTP id b5-v6mr3558349wmi.135.1528902578264; Wed, 13 Jun 2018 08:09:38 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id e13-v6sm2886548wrm.45.2018.06.13.08.09.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 08:09:37 -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 v3 22/27] venus: vdec: get required input buffers as well Date: Wed, 13 Jun 2018 18:07:56 +0300 Message-Id: <20180613150801.11702-23-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180613150801.11702-1-stanimir.varbanov@linaro.org> References: <20180613150801.11702-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;