1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2 /* Copyright (c) 2023 Imagination Technologies Ltd. */
3 
4 #ifndef PVR_ROGUE_FWIF_STREAM_H
5 #define PVR_ROGUE_FWIF_STREAM_H
6 
7 /**
8  * DOC: Streams
9  *
10  * Commands are submitted to the kernel driver in the form of streams.
11  *
12  * A command stream has the following layout :
13  *  - A 64-bit header containing:
14  *    * A u32 containing the length of the main stream inclusive of the length of the header.
15  *    * A u32 for padding.
16  *  - The main stream data.
17  *  - The extension stream (optional), which is composed of:
18  *    * One or more headers.
19  *    * The extension stream data, corresponding to the extension headers.
20  *
21  * The main stream provides the base command data. This has a fixed layout based on the features
22  * supported by a given GPU.
23  *
24  * The extension stream provides the command parameters that are required for BRNs & ERNs for the
25  * current GPU. This stream is comprised of one or more headers, followed by data for each given
26  * BRN/ERN.
27  *
28  * Each header is a u32 containing a bitmask of quirks & enhancements in the extension stream, a
29  * "type" field determining the set of quirks & enhancements the bitmask represents, and a
30  * continuation bit determining whether any more headers are present. The headers are then followed
31  * by command data; this is specific to each quirk/enhancement. All unused / reserved bits in the
32  * header must be set to 0.
33  *
34  * All parameters and headers in the main and extension streams must be naturally aligned.
35  *
36  * If a parameter appears in both the main and extension streams, then the extension parameter is
37  * used.
38  */
39 
40 /*
41  * Stream extension header definition
42  */
43 #define PVR_STREAM_EXTHDR_TYPE_SHIFT 29U
44 #define PVR_STREAM_EXTHDR_TYPE_MASK (7U << PVR_STREAM_EXTHDR_TYPE_SHIFT)
45 #define PVR_STREAM_EXTHDR_TYPE_MAX 8U
46 #define PVR_STREAM_EXTHDR_CONTINUATION BIT(28U)
47 
48 #define PVR_STREAM_EXTHDR_DATA_MASK ~(PVR_STREAM_EXTHDR_TYPE_MASK | PVR_STREAM_EXTHDR_CONTINUATION)
49 
50 /*
51  * Stream extension header - Geometry 0
52  */
53 #define PVR_STREAM_EXTHDR_TYPE_GEOM0 0U
54 
55 #define PVR_STREAM_EXTHDR_GEOM0_BRN49927 BIT(0U)
56 
57 #define PVR_STREAM_EXTHDR_GEOM0_VALID PVR_STREAM_EXTHDR_GEOM0_BRN49927
58 
59 /*
60  * Stream extension header - Fragment 0
61  */
62 #define PVR_STREAM_EXTHDR_TYPE_FRAG0 0U
63 
64 #define PVR_STREAM_EXTHDR_FRAG0_BRN47217 BIT(0U)
65 #define PVR_STREAM_EXTHDR_FRAG0_BRN49927 BIT(1U)
66 
67 #define PVR_STREAM_EXTHDR_FRAG0_VALID PVR_STREAM_EXTHDR_FRAG0_BRN49927
68 
69 /*
70  * Stream extension header - Compute 0
71  */
72 #define PVR_STREAM_EXTHDR_TYPE_COMPUTE0 0U
73 
74 #define PVR_STREAM_EXTHDR_COMPUTE0_BRN49927 BIT(0U)
75 
76 #define PVR_STREAM_EXTHDR_COMPUTE0_VALID PVR_STREAM_EXTHDR_COMPUTE0_BRN49927
77 
78 #endif /* PVR_ROGUE_FWIF_STREAM_H */
79