From patchwork Thu Jul 5 13:03: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: 141125 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1918964ljj; Thu, 5 Jul 2018 06:05:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcsOmRtztfQNN/p91qpIrwQBjjZwh8PhbQFM60h5daq7PPJo7vGQIYloxN0ygg9aig8VUU5 X-Received: by 2002:a62:403:: with SMTP id 3-v6mr6341465pfe.28.1530795941458; Thu, 05 Jul 2018 06:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530795941; cv=none; d=google.com; s=arc-20160816; b=gajNdJHd420e6B1/ZRahhjIygwkJKGUWH2d7XHixwqkobegHLjRP98aRWZUZN+daGw ODRjRsPgXC2LvPU9d5NHTZxXMRV8dBIZKIUzKVIidTFNzkg01D3WAZQm7Bvpsbpg2QZy cImsG8wzidITZ4tMx4LqA9M0RyiTE2BpLSHADb3Ah+rfbrLIkrYMLQoTsVKRvHUqBis/ n1uVCTEEL/FdqUDkhCuyztsF8RHXdqS0Zkp16+l35RZVHpqjhnFRQNjbY3U7BjPlv9L5 C3IJaomreWUeemAE0+dtCCh7nliYja7NnvESPstCsCRqwtdKSUwfus5YphPU9833gpTY dDUQ== 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=M+oHvhOxeajEleWqY/pKIr12AGkun8DctwS20UTRPoc=; b=ii0KACVEZW3tElaWWTcOXY845hrJ4Iyb1inUR4tokD+DuN3/gyF3LkqvOZN0z9S9Tt dS1oO40TkSXaV2IwlCDusTGdP8nJgWAvBh2KF05NZP3TC3GbyEwAdjBmzVAF1l10fMrB 6iyxcgPnRcXlxM38JyEyFNpBTpwB1zmLfeYcyuYw6ZfZowGccl2jg4Kl4OlqvZF54dmj 6SCGRydhcgS3UuzRrV4W0UDC2c6yOWD0vSUwy0fZB5cPg8dKV+FZeU5IhLaBjcH9hMVM 1VT60AFYfdNd09XzmPhzH7hjdqu7eh60PCxU1VVFsFkAQQ6piu8KhcSU+jw/eC4zHRzh q4vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G7xUd24f; 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 31-v6si5907304plj.216.2018.07.05.06.05.41; Thu, 05 Jul 2018 06:05:41 -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=G7xUd24f; 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 S1754562AbeGENFi (ORCPT + 31 others); Thu, 5 Jul 2018 09:05:38 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37867 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754503AbeGENFc (ORCPT ); Thu, 5 Jul 2018 09:05:32 -0400 Received: by mail-wm0-f65.google.com with SMTP id n17-v6so10744443wmh.2 for ; Thu, 05 Jul 2018 06:05:31 -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=M+oHvhOxeajEleWqY/pKIr12AGkun8DctwS20UTRPoc=; b=G7xUd24fjdUgudFXl/E7d+WwP7Gv/iBVmIZJppkl2QWAtWjvgmzBmAJ9EEOsbPmDX7 853YvZLoxHvtWdTj7R6NS0fstwbKzrleQSAb2DH0Fhn3vsZBsn1hhliXPlWoNN4Ttyjx bOw6+d2U1MK8Y+DMGZraWWjD4yLXlAWRuoRNU= 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=M+oHvhOxeajEleWqY/pKIr12AGkun8DctwS20UTRPoc=; b=py8/x6HmVXg6tLI4I3zIF0nAaJbS5Ld8iDHHgB73G5cBo1zy/2HpMwyrCyUYJtXS00 6PmNt1oZza7XoP8EmSH3yQ+/OJEG1vKcivuc5GrJzc7gluiVHPawsH6ThKtK6PqJdT8o 4fXjgvaIaCRpAQ8Fr/aQ9JhyVPuha/q3vGwz+LdCQ/RCZZsAknmQOppQI4vY6EqYtLdm Rrt00axgVmIHTuAL9azFS/urdFs4kAZcACpT2fti78gwGdDIZD+QWAa9ldnew304cFqD vv9J2djsaYjx1sxPh8DDsrte4Aoj81jZT1d9TbI4div+X5ICSWzhIX1lr88hcKCYYg/M Etyg== X-Gm-Message-State: APt69E1O2qgqylArMPhOTsgmuUy3HPvepkQgYEVGqjUt2LNQ+lE2unZN KeEycLhoqYxUkBLhVtjQ1YGolQ== X-Received: by 2002:a1c:818e:: with SMTP id c136-v6mr4214555wmd.107.1530795931291; Thu, 05 Jul 2018 06:05:31 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:30 -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 , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 22/27] venus: vdec: get required input buffers as well Date: Thu, 5 Jul 2018 16:03:56 +0300 Message-Id: <20180705130401.24315-23-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-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(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 3af1fb81cc32..c98084f51e5e 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;