verite3dio.h revision 1.1 1 /* $NetBSD: verite3dio.h,v 1.1 2026/07/15 20:53:22 rkujawa Exp $ */
2
3 /*
4 * Copyright (c) 2026 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Radoslaw Kujawa.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31
32 /*
33 * /dev/verite3d - expierimental 3D interface for veritefb(4)
34 *
35 * By design, it is completely independent of wsdisplay(4). It supports
36 * one exclusive client - opening the device stops the 2D microcode.
37 * Closing the device stops the 3D microcode and restores the console,
38 * in the state it was left behind.
39 *
40 * The client supplies its own RISC microcode (V3D_INIT) and owns
41 * the FIFO command stream. The kernel moves bytes (DMA) and tracks VRAM,
42 * but does NOT interpret the command stream. That is responsibility of
43 * the microcode (on the hardware side) and the userland process.
44 */
45
46 #ifndef VERITE3DIO_H
47 #define VERITE3DIO_H
48
49 #include <sys/ioccom.h>
50
51 #define V3D_RING_SLOTS 4
52 #define V3D_SLOT_SIZE 65536
53
54 #define V3D_VRAM_MMAP_OFF ((off_t)V3D_RING_SLOTS * V3D_SLOT_SIZE)
55
56 /* Load client microcode into the foreign slot and cold-start it. */
57 struct v3d_init {
58 uint64_t vi_ucode; /* in: user pointer to image */
59 uint32_t vi_size; /* in: bytes */
60 uint32_t vi_ctx_base; /* out: context save area (VRAM) */
61 uint32_t vi_memsize; /* out: total VRAM bytes */
62 uint32_t vi_pool_base; /* out: first V3D_ALLOC-managed byte */
63 };
64 #define V3D_INIT _IOWR('V', 0, struct v3d_init)
65
66 struct v3d_submit {
67 uint32_t vs_slot; /* 0 to V3D_RING_SLOTS-1 */
68 uint32_t vs_len; /* bytes, word multiple */
69 uint32_t vs_swap; /* descriptor swap code 0..3 */
70 };
71 #define V3D_SUBMIT _IOW('V', 1, struct v3d_submit)
72
73 /*
74 * Fence: send one word (the client microcode's sync command) and
75 * wait for the response word. In/out: word to send / word received.
76 */
77 #define V3D_SYNC _IOWR('V', 2, uint32_t)
78
79 struct v3d_alloc {
80 uint32_t va_size; /* in: bytes */
81 uint32_t va_align; /* in: byte alignment (0 = 4) */
82 uint32_t va_addr; /* out: VRAM byte address */
83 };
84 #define V3D_ALLOC _IOWR('V', 3, struct v3d_alloc)
85 #define V3D_FREE _IOW('V', 4, uint32_t)
86
87 struct v3d_mode {
88 uint32_t vm_depth; /* in: 8 or 16; 0 = query only */
89 uint32_t vm_frame_base; /* in: scanout base; 0 = keep */
90 uint32_t vm_width; /* out */
91 uint32_t vm_height; /* out */
92 uint32_t vm_stride; /* out: scanout line bytes */
93 uint32_t vm_pe_stride; /* out: PE Stride(3) dst encoding */
94 };
95 #define V3D_MODE _IOWR('V', 5, struct v3d_mode)
96
97 /*
98 * vsync-waited FRAMEBASE flip.
99 */
100 #define V3D_FLIP_NOWAIT 0x80000000U
101 #define V3D_FLIP _IOW('V', 6, uint32_t)
102
103 #endif /* VERITE3DIO_H */
104