From: gert.wollny@collabora.com
To: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>,
Russell King <linux+etnaviv@armlinux.org.uk>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Gert Wollny <gert.wollny@collabora.com>
Subject: [PATCH v4 2/5] drm/etnaviv: move some functions to a header to be able to use them externally
Date: Mon, 10 Nov 2025 15:37:48 +0100 [thread overview]
Message-ID: <20251110144625.18653-3-gert.wollny@collabora.com> (raw)
In-Reply-To: <20251110144625.18653-1-gert.wollny@collabora.com>
From: Gert Wollny <gert.wollny@collabora.com>
v2: Add license info to header
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
---
drivers/gpu/drm/etnaviv/etnaviv_buffer.c | 71 +------------------
drivers/gpu/drm/etnaviv/etnaviv_buffer.h | 86 ++++++++++++++++++++++++
2 files changed, 87 insertions(+), 70 deletions(-)
create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_buffer.h
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_buffer.c b/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
index d4f1307d574f..5be9978e34d9 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
@@ -10,6 +10,7 @@
#include "etnaviv_gpu.h"
#include "etnaviv_gem.h"
#include "etnaviv_mmu.h"
+#include "etnaviv_buffer.h"
#include "common.xml.h"
#include "state.xml.h"
@@ -18,76 +19,6 @@
#include "state_3d.xml.h"
#include "cmdstream.xml.h"
-/*
- * Command Buffer helper:
- */
-
-
-static inline void OUT(struct etnaviv_cmdbuf *buffer, u32 data)
-{
- u32 *vaddr = (u32 *)buffer->vaddr;
-
- BUG_ON(buffer->user_size >= buffer->size);
-
- vaddr[buffer->user_size / 4] = data;
- buffer->user_size += 4;
-}
-
-static inline void CMD_LOAD_STATE(struct etnaviv_cmdbuf *buffer,
- u32 reg, u32 value)
-{
- u32 index = reg >> VIV_FE_LOAD_STATE_HEADER_OFFSET__SHR;
-
- buffer->user_size = ALIGN(buffer->user_size, 8);
-
- /* write a register via cmd stream */
- OUT(buffer, VIV_FE_LOAD_STATE_HEADER_OP_LOAD_STATE |
- VIV_FE_LOAD_STATE_HEADER_COUNT(1) |
- VIV_FE_LOAD_STATE_HEADER_OFFSET(index));
- OUT(buffer, value);
-}
-
-static inline void CMD_END(struct etnaviv_cmdbuf *buffer)
-{
- buffer->user_size = ALIGN(buffer->user_size, 8);
-
- OUT(buffer, VIV_FE_END_HEADER_OP_END);
-}
-
-static inline void CMD_WAIT(struct etnaviv_cmdbuf *buffer,
- unsigned int waitcycles)
-{
- buffer->user_size = ALIGN(buffer->user_size, 8);
-
- OUT(buffer, VIV_FE_WAIT_HEADER_OP_WAIT | waitcycles);
-}
-
-static inline void CMD_LINK(struct etnaviv_cmdbuf *buffer,
- u16 prefetch, u32 address)
-{
- buffer->user_size = ALIGN(buffer->user_size, 8);
-
- OUT(buffer, VIV_FE_LINK_HEADER_OP_LINK |
- VIV_FE_LINK_HEADER_PREFETCH(prefetch));
- OUT(buffer, address);
-}
-
-static inline void CMD_STALL(struct etnaviv_cmdbuf *buffer,
- u32 from, u32 to)
-{
- buffer->user_size = ALIGN(buffer->user_size, 8);
-
- OUT(buffer, VIV_FE_STALL_HEADER_OP_STALL);
- OUT(buffer, VIV_FE_STALL_TOKEN_FROM(from) | VIV_FE_STALL_TOKEN_TO(to));
-}
-
-static inline void CMD_SEM(struct etnaviv_cmdbuf *buffer, u32 from, u32 to)
-{
- CMD_LOAD_STATE(buffer, VIVS_GL_SEMAPHORE_TOKEN,
- VIVS_GL_SEMAPHORE_TOKEN_FROM(from) |
- VIVS_GL_SEMAPHORE_TOKEN_TO(to));
-}
-
static void etnaviv_cmd_select_pipe(struct etnaviv_gpu *gpu,
struct etnaviv_cmdbuf *buffer, u8 pipe)
{
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_buffer.h b/drivers/gpu/drm/etnaviv/etnaviv_buffer.h
new file mode 100644
index 000000000000..ae1ba1db6c8a
--- /dev/null
+++ b/drivers/gpu/drm/etnaviv/etnaviv_buffer.h
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2014-2025 Etnaviv Project
+ */
+
+#ifndef etnaviv_buffer_h
+#define etnaviv_buffer_h
+
+#include "etnaviv_cmdbuf.h"
+#include "etnaviv_gpu.h"
+#include "etnaviv_gem.h"
+#include "etnaviv_mmu.h"
+
+#include "common.xml.h"
+#include "linux/printk.h"
+#include "state.xml.h"
+#include "state_blt.xml.h"
+#include "state_hi.xml.h"
+#include "state_3d.xml.h"
+#include "cmdstream.xml.h"
+
+static inline void OUT(struct etnaviv_cmdbuf *buffer, u32 data)
+{
+ u32 *vaddr = (u32 *)buffer->vaddr;
+
+ BUG_ON(buffer->user_size >= buffer->size);
+
+ vaddr[buffer->user_size / 4] = data;
+ buffer->user_size += 4;
+}
+
+static inline void CMD_LOAD_STATE(struct etnaviv_cmdbuf *buffer, u32 reg,
+ u32 value)
+{
+ u32 index = reg >> VIV_FE_LOAD_STATE_HEADER_OFFSET__SHR;
+
+ buffer->user_size = ALIGN(buffer->user_size, 8);
+
+ /* write a register via cmd stream */
+ OUT(buffer, VIV_FE_LOAD_STATE_HEADER_OP_LOAD_STATE |
+ VIV_FE_LOAD_STATE_HEADER_COUNT(1) |
+ VIV_FE_LOAD_STATE_HEADER_OFFSET(index));
+ OUT(buffer, value);
+}
+
+static inline void CMD_END(struct etnaviv_cmdbuf *buffer)
+{
+ buffer->user_size = ALIGN(buffer->user_size, 8);
+
+ OUT(buffer, VIV_FE_END_HEADER_OP_END);
+}
+
+static inline void CMD_WAIT(struct etnaviv_cmdbuf *buffer,
+ unsigned int waitcycles)
+{
+ buffer->user_size = ALIGN(buffer->user_size, 8);
+
+ OUT(buffer, VIV_FE_WAIT_HEADER_OP_WAIT | waitcycles);
+}
+
+static inline void CMD_LINK(struct etnaviv_cmdbuf *buffer, u16 prefetch,
+ u32 address)
+{
+ buffer->user_size = ALIGN(buffer->user_size, 8);
+
+ OUT(buffer,
+ VIV_FE_LINK_HEADER_OP_LINK | VIV_FE_LINK_HEADER_PREFETCH(prefetch));
+ OUT(buffer, address);
+}
+
+static inline void CMD_STALL(struct etnaviv_cmdbuf *buffer, u32 from, u32 to)
+{
+ buffer->user_size = ALIGN(buffer->user_size, 8);
+
+ OUT(buffer, VIV_FE_STALL_HEADER_OP_STALL);
+ OUT(buffer, VIV_FE_STALL_TOKEN_FROM(from) | VIV_FE_STALL_TOKEN_TO(to));
+}
+
+static inline void CMD_SEM(struct etnaviv_cmdbuf *buffer, u32 from, u32 to)
+{
+ CMD_LOAD_STATE(buffer, VIVS_GL_SEMAPHORE_TOKEN,
+ VIVS_GL_SEMAPHORE_TOKEN_FROM(from) |
+ VIVS_GL_SEMAPHORE_TOKEN_TO(to));
+}
+
+#endif
--
2.51.0
next prev parent reply other threads:[~2025-11-10 14:43 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-18 20:43 drm/etnaviv: Add support for running a PPU flop reset Gert Wollny
2025-06-18 20:43 ` [PATCH v2 1/6] drm/etnaviv: Add command stream definitions required for " Gert Wollny
2025-06-18 20:43 ` [PATCH v2 2/6] drm/etnaviv: move some functions to a header to be able to use them externally Gert Wollny
2025-06-18 20:43 ` [PATCH v2 3/6] drm/etnaviv: Add a new function to emit a series of states to cmd stream Gert Wollny
2025-06-18 20:43 ` [PATCH v2 4/6] drm/etnaviv: Identify GPU already when binding Gert Wollny
2025-06-20 20:11 ` Lucas Stach
2025-06-18 20:43 ` [PATCH v2 5/6] drm/etnaviv: Add PPU flop reset Gert Wollny
2025-06-20 20:22 ` Lucas Stach
2025-06-23 12:05 ` Gert Wollny
2025-06-23 12:25 ` Lucas Stach
2025-06-18 20:43 ` [PATCH v2 6/6] drm/etnaviv: Add module parameter to force " Gert Wollny
2025-06-20 20:24 ` Lucas Stach
2025-06-30 20:26 ` [PATCH v3 0/5] drm/etnaviv: Add support for running a " Gert Wollny
2025-06-30 20:26 ` [PATCH v3 1/5] drm/etnaviv: Add command stream definitions required for " Gert Wollny
2025-06-30 20:26 ` [PATCH v3 2/5] drm/etnaviv: move some functions to a header to be able to use them externally Gert Wollny
2025-06-30 20:26 ` [PATCH v3 3/5] drm/etnaviv: Add a new function to emit a series of states to cmd stream Gert Wollny
2025-06-30 20:26 ` [PATCH v3 4/5] drm/etnaviv: Add PPU flop reset Gert Wollny
2025-10-09 21:40 ` Christian Gmeiner
2025-06-30 20:26 ` [PATCH v3 5/5] drm/etnaviv: Add module parameter to force " Gert Wollny
2025-11-10 14:37 ` [PATCH v4 0/5] drm/etnaviv: Add support for running a " gert.wollny
2025-11-10 14:37 ` [PATCH v4 1/5] drm/etnaviv: Add command stream definitions required for " gert.wollny
2025-11-10 15:54 ` Christian Gmeiner
2025-11-10 14:37 ` gert.wollny [this message]
2025-11-10 15:53 ` [PATCH v4 2/5] drm/etnaviv: move some functions to a header to be able to use them externally Christian Gmeiner
2025-11-10 14:37 ` [PATCH v4 3/5] drm/etnaviv: Add a new function to emit a series of states to cmd stream gert.wollny
2025-11-17 8:27 ` Christian Gmeiner
2025-11-10 14:37 ` [PATCH v4 4/5] drm/etnaviv: Add PPU flop reset gert.wollny
2025-11-17 8:57 ` Christian Gmeiner
2025-11-10 14:37 ` [PATCH v4 5/5] drm/etnaviv: Add module parameter to force " gert.wollny
2025-11-19 15:30 ` Christian Gmeiner
2025-11-19 16:45 ` [PATCH v5 0/5] drm/etnaviv: Add support for running a " gert.wollny
2025-11-19 16:45 ` [PATCH v5 1/5] drm/etnaviv: Add command stream definitions required for " gert.wollny
2025-11-19 16:45 ` [PATCH v5 2/5] drm/etnaviv: move some functions to a header to be able to use them externally gert.wollny
2025-11-28 8:56 ` Christian Gmeiner
2025-11-28 13:39 ` Gert Wollny
2025-11-19 16:45 ` [PATCH v5 3/5] drm/etnaviv: Add a new function to emit a series of states to cmd stream gert.wollny
2025-11-19 16:45 ` [PATCH v5 4/5] drm/etnaviv: Add PPU flop reset gert.wollny
2025-11-28 8:53 ` Christian Gmeiner
2025-11-19 16:45 ` [PATCH v5 5/5] drm/etnaviv: Add module parameter to force " gert.wollny
2025-11-21 20:47 ` [PATCH v5 0/5] drm/etnaviv: Add support for running a " Marek Vasut
2026-01-06 15:48 ` Christian Gmeiner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251110144625.18653-3-gert.wollny@collabora.com \
--to=gert.wollny@collabora.com \
--cc=airlied@gmail.com \
--cc=christian.gmeiner@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=etnaviv@lists.freedesktop.org \
--cc=l.stach@pengutronix.de \
--cc=linux+etnaviv@armlinux.org.uk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®