Skip to content

Commit 9934873

Browse files
gerddieChristian Gmeiner
authored andcommitted
drm/etnaviv: move some functions to a header to be able to use them externally
v2: Add license info to header v3: remove unused headers (Christian Gmainer) [cgmeiner: improve include guard] Signed-off-by: Gert Wollny <gert.wollny@collabora.com> Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com> Tested-by: Marek Vasut <marek.vasut@mailbox.org> # STM32MP255C DHCOS DHSBC Link: https://patch.msgid.link/20251119164624.9297-3-gert.wollny@collabora.com Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
1 parent a8fffbe commit 9934873

2 files changed

Lines changed: 80 additions & 70 deletions

File tree

drivers/gpu/drm/etnaviv/etnaviv_buffer.c

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "etnaviv_gpu.h"
1111
#include "etnaviv_gem.h"
1212
#include "etnaviv_mmu.h"
13+
#include "etnaviv_buffer.h"
1314

1415
#include "common.xml.h"
1516
#include "state.xml.h"
@@ -18,76 +19,6 @@
1819
#include "state_3d.xml.h"
1920
#include "cmdstream.xml.h"
2021

21-
/*
22-
* Command Buffer helper:
23-
*/
24-
25-
26-
static inline void OUT(struct etnaviv_cmdbuf *buffer, u32 data)
27-
{
28-
u32 *vaddr = (u32 *)buffer->vaddr;
29-
30-
BUG_ON(buffer->user_size >= buffer->size);
31-
32-
vaddr[buffer->user_size / 4] = data;
33-
buffer->user_size += 4;
34-
}
35-
36-
static inline void CMD_LOAD_STATE(struct etnaviv_cmdbuf *buffer,
37-
u32 reg, u32 value)
38-
{
39-
u32 index = reg >> VIV_FE_LOAD_STATE_HEADER_OFFSET__SHR;
40-
41-
buffer->user_size = ALIGN(buffer->user_size, 8);
42-
43-
/* write a register via cmd stream */
44-
OUT(buffer, VIV_FE_LOAD_STATE_HEADER_OP_LOAD_STATE |
45-
VIV_FE_LOAD_STATE_HEADER_COUNT(1) |
46-
VIV_FE_LOAD_STATE_HEADER_OFFSET(index));
47-
OUT(buffer, value);
48-
}
49-
50-
static inline void CMD_END(struct etnaviv_cmdbuf *buffer)
51-
{
52-
buffer->user_size = ALIGN(buffer->user_size, 8);
53-
54-
OUT(buffer, VIV_FE_END_HEADER_OP_END);
55-
}
56-
57-
static inline void CMD_WAIT(struct etnaviv_cmdbuf *buffer,
58-
unsigned int waitcycles)
59-
{
60-
buffer->user_size = ALIGN(buffer->user_size, 8);
61-
62-
OUT(buffer, VIV_FE_WAIT_HEADER_OP_WAIT | waitcycles);
63-
}
64-
65-
static inline void CMD_LINK(struct etnaviv_cmdbuf *buffer,
66-
u16 prefetch, u32 address)
67-
{
68-
buffer->user_size = ALIGN(buffer->user_size, 8);
69-
70-
OUT(buffer, VIV_FE_LINK_HEADER_OP_LINK |
71-
VIV_FE_LINK_HEADER_PREFETCH(prefetch));
72-
OUT(buffer, address);
73-
}
74-
75-
static inline void CMD_STALL(struct etnaviv_cmdbuf *buffer,
76-
u32 from, u32 to)
77-
{
78-
buffer->user_size = ALIGN(buffer->user_size, 8);
79-
80-
OUT(buffer, VIV_FE_STALL_HEADER_OP_STALL);
81-
OUT(buffer, VIV_FE_STALL_TOKEN_FROM(from) | VIV_FE_STALL_TOKEN_TO(to));
82-
}
83-
84-
static inline void CMD_SEM(struct etnaviv_cmdbuf *buffer, u32 from, u32 to)
85-
{
86-
CMD_LOAD_STATE(buffer, VIVS_GL_SEMAPHORE_TOKEN,
87-
VIVS_GL_SEMAPHORE_TOKEN_FROM(from) |
88-
VIVS_GL_SEMAPHORE_TOKEN_TO(to));
89-
}
90-
9122
static void etnaviv_cmd_select_pipe(struct etnaviv_gpu *gpu,
9223
struct etnaviv_cmdbuf *buffer, u8 pipe)
9324
{
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2014-2025 Etnaviv Project
4+
*/
5+
6+
#ifndef __ETNAVIV_BUFFER_H__
7+
#define __ETNAVIV_BUFFER_H__
8+
9+
#include "etnaviv_cmdbuf.h"
10+
11+
#include "common.xml.h"
12+
#include "state.xml.h"
13+
#include "cmdstream.xml.h"
14+
15+
static inline void OUT(struct etnaviv_cmdbuf *buffer, u32 data)
16+
{
17+
u32 *vaddr = (u32 *)buffer->vaddr;
18+
19+
BUG_ON(buffer->user_size >= buffer->size);
20+
21+
vaddr[buffer->user_size / 4] = data;
22+
buffer->user_size += 4;
23+
}
24+
25+
static inline void CMD_LOAD_STATE(struct etnaviv_cmdbuf *buffer, u32 reg,
26+
u32 value)
27+
{
28+
u32 index = reg >> VIV_FE_LOAD_STATE_HEADER_OFFSET__SHR;
29+
30+
buffer->user_size = ALIGN(buffer->user_size, 8);
31+
32+
/* write a register via cmd stream */
33+
OUT(buffer, VIV_FE_LOAD_STATE_HEADER_OP_LOAD_STATE |
34+
VIV_FE_LOAD_STATE_HEADER_COUNT(1) |
35+
VIV_FE_LOAD_STATE_HEADER_OFFSET(index));
36+
OUT(buffer, value);
37+
}
38+
39+
static inline void CMD_END(struct etnaviv_cmdbuf *buffer)
40+
{
41+
buffer->user_size = ALIGN(buffer->user_size, 8);
42+
43+
OUT(buffer, VIV_FE_END_HEADER_OP_END);
44+
}
45+
46+
static inline void CMD_WAIT(struct etnaviv_cmdbuf *buffer,
47+
unsigned int waitcycles)
48+
{
49+
buffer->user_size = ALIGN(buffer->user_size, 8);
50+
51+
OUT(buffer, VIV_FE_WAIT_HEADER_OP_WAIT | waitcycles);
52+
}
53+
54+
static inline void CMD_LINK(struct etnaviv_cmdbuf *buffer, u16 prefetch,
55+
u32 address)
56+
{
57+
buffer->user_size = ALIGN(buffer->user_size, 8);
58+
59+
OUT(buffer,
60+
VIV_FE_LINK_HEADER_OP_LINK | VIV_FE_LINK_HEADER_PREFETCH(prefetch));
61+
OUT(buffer, address);
62+
}
63+
64+
static inline void CMD_STALL(struct etnaviv_cmdbuf *buffer, u32 from, u32 to)
65+
{
66+
buffer->user_size = ALIGN(buffer->user_size, 8);
67+
68+
OUT(buffer, VIV_FE_STALL_HEADER_OP_STALL);
69+
OUT(buffer, VIV_FE_STALL_TOKEN_FROM(from) | VIV_FE_STALL_TOKEN_TO(to));
70+
}
71+
72+
static inline void CMD_SEM(struct etnaviv_cmdbuf *buffer, u32 from, u32 to)
73+
{
74+
CMD_LOAD_STATE(buffer, VIVS_GL_SEMAPHORE_TOKEN,
75+
VIVS_GL_SEMAPHORE_TOKEN_FROM(from) |
76+
VIVS_GL_SEMAPHORE_TOKEN_TO(to));
77+
}
78+
79+
#endif /* __ETNAVIV_BUFFER_H__ */

0 commit comments

Comments
 (0)