From patchwork Fri Jun 28 12:59:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 168081 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3670002ilk; Fri, 28 Jun 2019 06:00:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBSanfQDteXhXKy+zy8jQloWGGGqxS8LIvSgp/7GOzWyp7BXdYMGEzEpbhPRgUuGnQVrTF X-Received: by 2002:a17:90a:8c92:: with SMTP id b18mr12823882pjo.97.1561726832332; Fri, 28 Jun 2019 06:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561726832; cv=none; d=google.com; s=arc-20160816; b=PQqW79mZNC+f4RdJmr7+BQ3fxIdh5D83IGqsWz5WMf3cSZhd1kJ2LmQidZfbdaB+S7 v/ZZyb/p2rv8Iwxdzmq8ou6GBteao+OjRl9cKaNC3OzsEzhZV2LNBz/cRLdpanntzrjP oLMHFR+8PYqOGMIpec7SKYJEiVQJ8UEsHk7n0IzFFOz/fw3E6TLa2h+KUQ0tiCOXCZGR DVOaRWcz9UfQOGKZoxDNki6+TWV66KzP88+PB+3wFVNWhzk/6LTELf+vWSvBbylVPxLE b3+zRAZ5DdKF3VhtYUqlNDaIbsb8U2aAH2nI8EVXfz+QJKV/e8NzEDOgGk4v66YH/Rd7 MlYQ== 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=GusbBynaCqv/R7PuXUh9f4fYgooqYn7QcUElwV3IoHw=; b=YZjyMJl11dhncqOal0+pd7kOg2YB7wfui33h5Va0JKyz2SNnSzAWgCgE2nwHA3cwFW W0xU22rIGenXH4KFnDd4rFGO/ZEGX+Nj+ZBNrd3oKC6wofdFaxEhFhT4N+ZjwPeNJmjI hhR9Wv/8iD1epnTAHpspTSw1Ul1/HscSnylDlhdPBQsE7jwbROlFfGC7DbDTRKAgm2Ch xYY38V2l4u4CkUmc/6CiP5HTLWQIbAoZG5aR5ppNZz6CV8RT+gSso939p4y6pZ450/lP l+YUhVqK7qN2E+mvkWtv79sK1zLU3Cf13MNHaWeqSDMPt8oKcgMpELSNm5lLzS8L1GSa RPkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=De101qpt; 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 i97si2227196plb.50.2019.06.28.06.00.32; Fri, 28 Jun 2019 06:00:32 -0700 (PDT) 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=De101qpt; 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 S1727162AbfF1NAa (ORCPT + 3 others); Fri, 28 Jun 2019 09:00:30 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53955 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727142AbfF1NA3 (ORCPT ); Fri, 28 Jun 2019 09:00:29 -0400 Received: by mail-wm1-f66.google.com with SMTP id x15so9039878wmj.3 for ; Fri, 28 Jun 2019 06:00:28 -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=GusbBynaCqv/R7PuXUh9f4fYgooqYn7QcUElwV3IoHw=; b=De101qptdsYL0UicblH+0MmEOsOwGd+uz5zS5yDQ7qsD6kvBZYe/p2vCHilDdo/kyW roUJ+dw0+3tBeymz8w0ZRPrYuVgOrzi6pyZIQxUNmXVcIk8xpLw3jSoGeopa9+5zPPTK P+xdVmMx4llnfrZUDtUnH3UFf24VDmU/TJ9j5hDHt4KxdL1RWUT9hmIY8H4UbOF6ivvj 0QnmGV476jPRt2QNUNKPUEGCBL2F5/VOc9oO8703SM5fNxwZHRIe9q93+mDVsBzlcp4o 7y6NXhMXdWhEh/oXqp0bTX0dNoRp0RTEEN2h+gvNgEmTwfFBpEP3lxHToapNIdFg1p+V MMww== 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=GusbBynaCqv/R7PuXUh9f4fYgooqYn7QcUElwV3IoHw=; b=YydnXWscK2ktAA5wH5s2UIxKlFRJvAW00bQ23y+MHqZx1+OgdM65caj98ksTXS5QNM UXBfabpTkUkl5c35mbZwQ4L4eufSHSScin3uQkZBsV4N1RtH6DDeT9QPi3jiCwHO/a5p 85BHex/iZT0Y6eUV2PqMWCAq/aNrOrM10GW5smMCUoVn+HBwwPr2wg6joDvHuKF48EZV vaaypqy1KxWRaG8xZTwlFH+aKOD6Gff4nmg1yVM8ZuzybxbPGYWlEhiLvZfzPe/YrI28 5YgbEEOBv9q+k3l13Upx3O++dJ7B7uDOZA7ymzJLfLP3ksXEbIRLUYZ4WYY7Md7s01Jg 4gLw== X-Gm-Message-State: APjAAAVPS6k5xenz6k++oGWx5YioGAlEeLIOg2lZz4prpK396MmnwQuI zcmJc6vF2en8Vf7NctnyVAUp8NTjnJ8= X-Received: by 2002:a1c:407:: with SMTP id 7mr7658444wme.113.1561726827460; Fri, 28 Jun 2019 06:00:27 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id w20sm3717174wra.96.2019.06.28.06.00.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 06:00:26 -0700 (PDT) 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 , Stanimir Varbanov Subject: [PATCH v2 02/11] venus: helpers: export few helper functions Date: Fri, 28 Jun 2019 15:59:53 +0300 Message-Id: <20190628130002.24293-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190628130002.24293-1-stanimir.varbanov@linaro.org> References: <20190628130002.24293-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Here we export few helper function to use them from decoder to implement more granular control needed for stateful Codec API compliance. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 29 ++++++++++++--------- drivers/media/platform/qcom/venus/helpers.h | 6 +++++ 2 files changed, 23 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 71b06dfc6dc4..63af69acc068 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -79,7 +79,7 @@ bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt) } EXPORT_SYMBOL_GPL(venus_helper_check_codec); -static int venus_helper_queue_dpb_bufs(struct venus_inst *inst) +int venus_helper_queue_dpb_bufs(struct venus_inst *inst) { struct intbuf *buf; int ret = 0; @@ -100,6 +100,7 @@ static int venus_helper_queue_dpb_bufs(struct venus_inst *inst) fail: return ret; } +EXPORT_SYMBOL_GPL(venus_helper_queue_dpb_bufs); int venus_helper_free_dpb_bufs(struct venus_inst *inst) { @@ -278,7 +279,7 @@ static const unsigned int intbuf_types_4xx[] = { HFI_BUFFER_INTERNAL_PERSIST_1, }; -static int intbufs_alloc(struct venus_inst *inst) +int venus_helper_intbufs_alloc(struct venus_inst *inst) { const unsigned int *intbuf; size_t arr_sz, i; @@ -304,11 +305,13 @@ static int intbufs_alloc(struct venus_inst *inst) intbufs_unset_buffers(inst); return ret; } +EXPORT_SYMBOL_GPL(venus_helper_intbufs_alloc); -static int intbufs_free(struct venus_inst *inst) +int venus_helper_intbufs_free(struct venus_inst *inst) { return intbufs_unset_buffers(inst); } +EXPORT_SYMBOL_GPL(venus_helper_intbufs_free); static u32 load_per_instance(struct venus_inst *inst) { @@ -339,7 +342,7 @@ static u32 load_per_type(struct venus_core *core, u32 session_type) return mbs_per_sec; } -static int load_scale_clocks(struct venus_core *core) +int venus_helper_load_scale_clocks(struct venus_core *core) { const struct freq_tbl *table = core->res->freq_tbl; unsigned int num_rows = core->res->freq_tbl_size; @@ -388,6 +391,7 @@ static int load_scale_clocks(struct venus_core *core) dev_err(dev, "failed to set clock rate %lu (%d)\n", freq, ret); return ret; } +EXPORT_SYMBOL_GPL(venus_helper_load_scale_clocks); static void fill_buffer_desc(const struct venus_buffer *buf, struct hfi_buffer_desc *bd, bool response) @@ -472,7 +476,7 @@ static bool is_dynamic_bufmode(struct venus_inst *inst) return caps->cap_bufs_mode_dynamic; } -static int session_unregister_bufs(struct venus_inst *inst) +int venus_helper_unregister_bufs(struct venus_inst *inst) { struct venus_buffer *buf, *n; struct hfi_buffer_desc bd; @@ -489,6 +493,7 @@ static int session_unregister_bufs(struct venus_inst *inst) return ret; } +EXPORT_SYMBOL_GPL(venus_helper_unregister_bufs); static int session_register_bufs(struct venus_inst *inst) { @@ -1009,8 +1014,8 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) if (inst->streamon_out & inst->streamon_cap) { ret = hfi_session_stop(inst); ret |= hfi_session_unload_res(inst); - ret |= session_unregister_bufs(inst); - ret |= intbufs_free(inst); + ret |= venus_helper_unregister_bufs(inst); + ret |= venus_helper_intbufs_free(inst); ret |= hfi_session_deinit(inst); if (inst->session_error || core->sys_error) @@ -1021,7 +1026,7 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) venus_helper_free_dpb_bufs(inst); - load_scale_clocks(core); + venus_helper_load_scale_clocks(core); INIT_LIST_HEAD(&inst->registeredbufs); } @@ -1041,7 +1046,7 @@ int venus_helper_vb2_start_streaming(struct venus_inst *inst) struct venus_core *core = inst->core; int ret; - ret = intbufs_alloc(inst); + ret = venus_helper_intbufs_alloc(inst); if (ret) return ret; @@ -1049,7 +1054,7 @@ int venus_helper_vb2_start_streaming(struct venus_inst *inst) if (ret) goto err_bufs_free; - load_scale_clocks(core); + venus_helper_load_scale_clocks(core); ret = hfi_session_load_res(inst); if (ret) @@ -1070,9 +1075,9 @@ int venus_helper_vb2_start_streaming(struct venus_inst *inst) err_unload_res: hfi_session_unload_res(inst); err_unreg_bufs: - session_unregister_bufs(inst); + venus_helper_unregister_bufs(inst); err_bufs_free: - intbufs_free(inst); + venus_helper_intbufs_free(inst); return ret; } EXPORT_SYMBOL_GPL(venus_helper_vb2_start_streaming); diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 153783687a0c..70288dc860ff 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -9,6 +9,7 @@ #include struct venus_inst; +struct venus_core; bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt); struct vb2_v4l2_buffer *venus_helper_find_buf(struct venus_inst *inst, @@ -53,4 +54,9 @@ int venus_helper_alloc_dpb_bufs(struct venus_inst *inst); int venus_helper_free_dpb_bufs(struct venus_inst *inst); int venus_helper_power_enable(struct venus_core *core, u32 session_type, bool enable); +int venus_helper_intbufs_alloc(struct venus_inst *inst); +int venus_helper_intbufs_free(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); #endif From patchwork Fri Jun 28 12:59:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 168090 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3671120ilk; Fri, 28 Jun 2019 06:01:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyynRfRQts8vhJ4Zc22l0wxQtSjVfCpHW+wMYQpk3eCjVt5o4ON2nbcBPX+ha+SDXiRdXeR X-Received: by 2002:a17:902:341:: with SMTP id 59mr11444805pld.20.1561726878449; Fri, 28 Jun 2019 06:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561726878; cv=none; d=google.com; s=arc-20160816; b=hlzblsG2/OOFAzJwrYi/O9nlC3Ti/CVwZwWQnIDZbeFCynbJNuRe8zujIYenIau5xZ mzVimQij417prWFmsPUwY75ut/4RilXxmKB9DuLNl2b/iG4cpTLdwUuX9Yscb/yeuhjG ks6hauyY5W86yZkJ2S1EBog8q/wrSi6ysnkpqcmeI0tr7apg8sWxBXEwQ9WMtj9PGrvr gKWp0Xcyu4zTkqUAGC8bM/0YbmRNtVseBMJhud0pf/9QobVFNrJHFXOEtJXEGFtTTAqx Lyd0SfJq2bVFrNgxXh0Fdke+TCY2Rwc14giNf1azhA3ctuyp3c0vN3soxnfKfoAxwUl3 cvmw== 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=iIPMb9M330BFTKiYEMbJPjGasEIFSJBAqHuplkfgTXU=; b=LfXCDauqKylKrNMLQfjDCgjbjXq59vMveHQQjgOt/3jPuv6aEIw6mhwiaxJLIG2vLC T4/XLAIhXo0gUTtpFDdn3ZbKBKkQurTnM1reYLnx/6C15+dXNwiol4l9sjO4fmFXzP6G WF5wdolmnjIfEBEdobNvz6jl+r5tgqzg6eDsv6x5SxHqUZlyYrYseBlvKl1zM6SBMXeZ LPWk5Il9RiwT+jK4eet0DxExZxsVeFOu9Hk9BzqvfAKwis+90beuGg7V0iMJQILwMJmM Lp0d435ZDKE9iy23g2+bYjQcfl3u0T0dkFYA2r6uu23aoLCmWu/JP70g1VMBCfKY4zi8 /+/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ahTFGj2k; 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 j10si2097651plg.71.2019.06.28.06.01.17; Fri, 28 Jun 2019 06:01:18 -0700 (PDT) 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=ahTFGj2k; 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 S1727363AbfF1NBI (ORCPT + 3 others); Fri, 28 Jun 2019 09:01:08 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:38929 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727194AbfF1NAg (ORCPT ); Fri, 28 Jun 2019 09:00:36 -0400 Received: by mail-wr1-f68.google.com with SMTP id x4so6214575wrt.6 for ; Fri, 28 Jun 2019 06:00:35 -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=iIPMb9M330BFTKiYEMbJPjGasEIFSJBAqHuplkfgTXU=; b=ahTFGj2kh3K11SbQbt7t2A+bOhVM9w7V1NcNq7xDZlfsEqailhNG8GwipjuTM9zFZo Ab9hlm4ctVySSs3wPGHrFFYLROgYEshCp0EbdilgEcVO00YkcM5bt8SpLK63K62z/5FZ KCndSQxmExgpFcmUsxIODF3yN8T7zQjTApuNnIh0ON++b0vdXhjtM6ICR4Hc6hajNYtb 7vtbOVqqydLF6SFYhKZXf6uBazVsYQwAedP7Go1lUnE0cTqUhWayJADTI8SYdt7ZnYbq lUmxhYWzooWpLiAoAHU9y4+VDoOb8A/kzkU4Z+Ch9dKVgZlYVrX0Vfzrbe0pn4lvn8du q2xQ== 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=iIPMb9M330BFTKiYEMbJPjGasEIFSJBAqHuplkfgTXU=; b=nch1Bz3mjZOiyzFI0Np+QSf1W8/SQ05hIa51piwpWV8FtOpQGRGED9LeybsDRB5AB3 bQVxJE/0FsKWBGHh93LoTvxIQy13XSLwHjDNjVuju3hZui7fHSEp6iVOq2OJF8vg2/4a JTZr7bC4+x5t09ymTcuYY3eCYx5PeSZ9MWVFD7C2VE4G7WeuHlk5ai8XnvI28p8VMDrt anQ6mfZ5Mt+0iC9OwFoSn6tGQDVmsK6GFWA1R9Nyt3WGIjYTTCO0PLMWEmJhs20YjEYf kQ/ibj6NYEtTV63H2LGNvvYDTAlCIaca/alesC2NZXY8bpvL8hAexM4eSorWyTqH2Otj mqag== X-Gm-Message-State: APjAAAWqbIqdbsKRHebK9fEpAg5ohIoYKANm4pqVvRb4I6fX03tnM17i EisMy9DUpVE1Ywb8FGEPOeW0TGj+k20= X-Received: by 2002:a5d:4950:: with SMTP id r16mr7982736wrs.136.1561726834250; Fri, 28 Jun 2019 06:00:34 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id w20sm3717174wra.96.2019.06.28.06.00.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 06:00:33 -0700 (PDT) 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 , Stanimir Varbanov Subject: [PATCH v2 06/11] venus: helpers: add three more helper functions Date: Fri, 28 Jun 2019 15:59:57 +0300 Message-Id: <20190628130002.24293-7-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190628130002.24293-1-stanimir.varbanov@linaro.org> References: <20190628130002.24293-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 | 3 + 2 files changed, 85 insertions(+) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 63af69acc068..ab20fd3b36d9 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -313,6 +313,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; @@ -1041,6 +1087,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 70288dc860ff..486598d52811 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -56,7 +56,10 @@ int venus_helper_power_enable(struct venus_core *core, u32 session_type, bool enable); int venus_helper_intbufs_alloc(struct venus_inst *inst); int venus_helper_intbufs_free(struct venus_inst *inst); +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