From patchwork Thu Jan 17 16:20:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 155841 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2158803jaa; Thu, 17 Jan 2019 08:21:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN5m8FVsllyBsRo+bIyI/KIM5ayVqfDpzrYWmmsClnLeU60An4rEFeXSkC39R3UhIApKMxr4 X-Received: by 2002:a63:e156:: with SMTP id h22mr14041521pgk.255.1547742075139; Thu, 17 Jan 2019 08:21:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547742075; cv=none; d=google.com; s=arc-20160816; b=DDApu+uJv39sgadeaeuT1um7khcXjRE1qqa0Bo0feDzbYoP3xmr2QbKjc1MtmKE52C 8WV9g/4yM/FubQy9L+JN1PyiTV0Z7Q6n9/o1DTXHLHCeKoRzutoqijjjhNCSLRmX+gi7 ChUOe2ULL/3BDQ0Prxi0d2AOecLz/Kog78MHva6VLTyaKC/N5jNfFPe/2B83jgUK5U6+ 3gTqpgLRfuqPWeVymUtMrDtRjsFI+KiOGYy/l/XKbWyMyR8KnXcIuskqpTeOylqxxSqC 1OIxbrzEdCfpTDGa5V491oSjn+5xsRMxca/59gjS6cYJSDH/Qr6mFgpe0+1HbtvIPsvH +cmA== 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; bh=rqq2iTJQ0mjQYAqKv+ITvoSKpjYT4Sn2iEPmLEqQ1y8=; b=itUoZ/qrYMzAxZk2C3xsrik7jxz/2saNWecshSGOlOadsT5oJBia4JKI9NV9KD1A1u XyC54wKn44WnXIBFDSNOqGf/Lj6TVnkThfWMJ9uMHnZSc+9+IzqyBOFob16z6KzuyNWg A+vj3uKZl8Gzwl5+1DY9nTNxSpFivH4gL0ThhuDd0QjFHne570boDI+qHEl5imXjz4/r hooLPdTO3SWySY51R2krXpSFjiKY8cpVQqrXkBbzyb0qY7fO3WcykPvetTAmbl4CbqJP ypn30TDgfEGYPHC2A/RNa8+a8vql8lmS4tht7CPNQtzZKVdrROIPV4EyufJnwSSOB5tP UYJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fpaoJNuE; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-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 r17si1958855pls.380.2019.01.17.08.21.14; Thu, 17 Jan 2019 08:21:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-media-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=fpaoJNuE; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-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 S1729134AbfAQQVN (ORCPT + 4 others); Thu, 17 Jan 2019 11:21:13 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:56058 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729125AbfAQQVM (ORCPT ); Thu, 17 Jan 2019 11:21:12 -0500 Received: by mail-wm1-f66.google.com with SMTP id y139so1664961wmc.5 for ; Thu, 17 Jan 2019 08:21:10 -0800 (PST) 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=rqq2iTJQ0mjQYAqKv+ITvoSKpjYT4Sn2iEPmLEqQ1y8=; b=fpaoJNuEYdX6Q0gc/SsxQ6igfVQvhHken4mff/K5Ft8HGQFDwRbdfnWWzHgsruKouG ElA8aeaDwJxzOvfvsBw7co33LD4k2mu/57A348xKulDYFWcUCYFJFdqtfNFV4FDh4kbp Jh+QuhbhdI3mohfZsg01luVG6YLvIpqntHI4Y= 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=rqq2iTJQ0mjQYAqKv+ITvoSKpjYT4Sn2iEPmLEqQ1y8=; b=YKL9lM7AwqZad1VZp/aQj46DSRf8B9ETs4O6bTaeOll+54/3SBlFXxNAo3pOapmaTO etUhtY9YgxX6WFchXLNG4zFEBIh2a4N+N/PVMxPcfubeDl2lN3vV2lgK9vgnQwkplm/7 94xtyvkxEnRLNhdsYK5i4FXdT6hnxTZff0i7AEf+EWebACM5K1VlIcqIbl/IRpDIQYdi heGd/4XlwQT87j00lWD9z81cOLrZ3tssz3H+r2uEuBBoCDv90HrnEX81SbfsDm7fGnRN bMxG/fhVGZ37mAGQh/d/M3gJ39ltKv9d2Op0mrmqEelK4ZZ9eimOjNKzg6KRpup4qM4B Hnyw== X-Gm-Message-State: AJcUukfYdVZxxU3jLs5B9Ym38WPoPzVmoUP9Rc+qgkdsDiU6euRYiCWU iqNbpk1I6czIrrKxMst/B5ymDEyZZeE= X-Received: by 2002:a1c:de57:: with SMTP id v84mr12264913wmg.55.1547742069669; Thu, 17 Jan 2019 08:21:09 -0800 (PST) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id v133sm31124734wmf.19.2019.01.17.08.21.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 08:21:09 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Malathi Gottam , Stanimir Varbanov Subject: [PATCH 07/10] venus: helpers: add three more helper functions Date: Thu, 17 Jan 2019 18:20:05 +0200 Message-Id: <20190117162008.25217-8-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190117162008.25217-1-stanimir.varbanov@linaro.org> References: <20190117162008.25217-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This adds three more helper functions: * for internal buffers reallocation, applicable when we are doing dynamic resolution change * for initial buffer processing of capture and output queue buffer types All of them will be needed for stateful Codec API support. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 82 +++++++++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 2 + 2 files changed, 84 insertions(+) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index f33bbfea3576..637ce7b82d94 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -322,6 +322,52 @@ int venus_helper_intbufs_free(struct venus_inst *inst) } EXPORT_SYMBOL_GPL(venus_helper_intbufs_free); +int venus_helper_intbufs_realloc(struct venus_inst *inst) +{ + enum hfi_version ver = inst->core->res->hfi_version; + struct hfi_buffer_desc bd; + struct intbuf *buf, *n; + int ret; + + list_for_each_entry_safe(buf, n, &inst->internalbufs, list) { + if (buf->type == HFI_BUFFER_INTERNAL_PERSIST || + buf->type == HFI_BUFFER_INTERNAL_PERSIST_1) + continue; + + memset(&bd, 0, sizeof(bd)); + bd.buffer_size = buf->size; + bd.buffer_type = buf->type; + bd.num_buffers = 1; + bd.device_addr = buf->da; + bd.response_required = true; + + ret = hfi_session_unset_buffers(inst, &bd); + + dma_free_attrs(inst->core->dev, buf->size, buf->va, buf->da, + buf->attrs); + + list_del_init(&buf->list); + kfree(buf); + } + + ret = intbufs_set_buffer(inst, HFI_BUFFER_INTERNAL_SCRATCH(ver)); + if (ret) + goto err; + + ret = intbufs_set_buffer(inst, HFI_BUFFER_INTERNAL_SCRATCH_1(ver)); + if (ret) + goto err; + + ret = intbufs_set_buffer(inst, HFI_BUFFER_INTERNAL_SCRATCH_2(ver)); + if (ret) + goto err; + + return 0; +err: + return ret; +} +EXPORT_SYMBOL_GPL(venus_helper_intbufs_realloc); + static u32 load_per_instance(struct venus_inst *inst) { u32 mbs; @@ -1050,6 +1096,42 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) } EXPORT_SYMBOL_GPL(venus_helper_vb2_stop_streaming); +int venus_helper_process_initial_cap_bufs(struct venus_inst *inst) +{ + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; + struct v4l2_m2m_buffer *buf, *n; + int ret; + + v4l2_m2m_for_each_dst_buf_safe(m2m_ctx, buf, n) { + ret = session_process_buf(inst, &buf->vb); + if (ret) { + return_buf_error(inst, &buf->vb); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(venus_helper_process_initial_cap_bufs); + +int venus_helper_process_initial_out_bufs(struct venus_inst *inst) +{ + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; + struct v4l2_m2m_buffer *buf, *n; + int ret; + + v4l2_m2m_for_each_src_buf_safe(m2m_ctx, buf, n) { + ret = session_process_buf(inst, &buf->vb); + if (ret) { + return_buf_error(inst, &buf->vb); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(venus_helper_process_initial_out_bufs); + int venus_helper_vb2_start_streaming(struct venus_inst *inst) { struct venus_core *core = inst->core; diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 24faae5abd93..2ec1c1a8b416 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -69,4 +69,6 @@ int venus_helper_intbufs_realloc(struct venus_inst *inst); int venus_helper_queue_dpb_bufs(struct venus_inst *inst); int venus_helper_unregister_bufs(struct venus_inst *inst); int venus_helper_load_scale_clocks(struct venus_core *core); +int venus_helper_process_initial_cap_bufs(struct venus_inst *inst); +int venus_helper_process_initial_out_bufs(struct venus_inst *inst); #endif