Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Gert Wollny and committed by
Christian Gmeiner
9934873b a8fffbe7

+80 -70
+1 -70
drivers/gpu/drm/etnaviv/etnaviv_buffer.c
··· 10 10 #include "etnaviv_gpu.h" 11 11 #include "etnaviv_gem.h" 12 12 #include "etnaviv_mmu.h" 13 + #include "etnaviv_buffer.h" 13 14 14 15 #include "common.xml.h" 15 16 #include "state.xml.h" ··· 18 17 #include "state_hi.xml.h" 19 18 #include "state_3d.xml.h" 20 19 #include "cmdstream.xml.h" 21 - 22 - /* 23 - * Command Buffer helper: 24 - */ 25 - 26 - 27 - static inline void OUT(struct etnaviv_cmdbuf *buffer, u32 data) 28 - { 29 - u32 *vaddr = (u32 *)buffer->vaddr; 30 - 31 - BUG_ON(buffer->user_size >= buffer->size); 32 - 33 - vaddr[buffer->user_size / 4] = data; 34 - buffer->user_size += 4; 35 - } 36 - 37 - static inline void CMD_LOAD_STATE(struct etnaviv_cmdbuf *buffer, 38 - u32 reg, u32 value) 39 - { 40 - u32 index = reg >> VIV_FE_LOAD_STATE_HEADER_OFFSET__SHR; 41 - 42 - buffer->user_size = ALIGN(buffer->user_size, 8); 43 - 44 - /* write a register via cmd stream */ 45 - OUT(buffer, VIV_FE_LOAD_STATE_HEADER_OP_LOAD_STATE | 46 - VIV_FE_LOAD_STATE_HEADER_COUNT(1) | 47 - VIV_FE_LOAD_STATE_HEADER_OFFSET(index)); 48 - OUT(buffer, value); 49 - } 50 - 51 - static inline void CMD_END(struct etnaviv_cmdbuf *buffer) 52 - { 53 - buffer->user_size = ALIGN(buffer->user_size, 8); 54 - 55 - OUT(buffer, VIV_FE_END_HEADER_OP_END); 56 - } 57 - 58 - static inline void CMD_WAIT(struct etnaviv_cmdbuf *buffer, 59 - unsigned int waitcycles) 60 - { 61 - buffer->user_size = ALIGN(buffer->user_size, 8); 62 - 63 - OUT(buffer, VIV_FE_WAIT_HEADER_OP_WAIT | waitcycles); 64 - } 65 - 66 - static inline void CMD_LINK(struct etnaviv_cmdbuf *buffer, 67 - u16 prefetch, u32 address) 68 - { 69 - buffer->user_size = ALIGN(buffer->user_size, 8); 70 - 71 - OUT(buffer, VIV_FE_LINK_HEADER_OP_LINK | 72 - VIV_FE_LINK_HEADER_PREFETCH(prefetch)); 73 - OUT(buffer, address); 74 - } 75 - 76 - static inline void CMD_STALL(struct etnaviv_cmdbuf *buffer, 77 - u32 from, u32 to) 78 - { 79 - buffer->user_size = ALIGN(buffer->user_size, 8); 80 - 81 - OUT(buffer, VIV_FE_STALL_HEADER_OP_STALL); 82 - OUT(buffer, VIV_FE_STALL_TOKEN_FROM(from) | VIV_FE_STALL_TOKEN_TO(to)); 83 - } 84 - 85 - static inline void CMD_SEM(struct etnaviv_cmdbuf *buffer, u32 from, u32 to) 86 - { 87 - CMD_LOAD_STATE(buffer, VIVS_GL_SEMAPHORE_TOKEN, 88 - VIVS_GL_SEMAPHORE_TOKEN_FROM(from) | 89 - VIVS_GL_SEMAPHORE_TOKEN_TO(to)); 90 - } 91 20 92 21 static void etnaviv_cmd_select_pipe(struct etnaviv_gpu *gpu, 93 22 struct etnaviv_cmdbuf *buffer, u8 pipe)
+79
drivers/gpu/drm/etnaviv/etnaviv_buffer.h
··· 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__ */