xref: /linux/drivers/gpu/drm/imagination/pvr_stream.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2 /* Copyright (c) 2023 Imagination Technologies Ltd. */
3 
4 #ifndef PVR_STREAM_H
5 #define PVR_STREAM_H
6 
7 #include <linux/bits.h>
8 #include <linux/limits.h>
9 #include <linux/types.h>
10 
11 struct pvr_device;
12 
13 struct pvr_job;
14 
15 enum pvr_stream_type {
16 	PVR_STREAM_TYPE_GEOM = 0,
17 	PVR_STREAM_TYPE_FRAG,
18 	PVR_STREAM_TYPE_COMPUTE,
19 	PVR_STREAM_TYPE_TRANSFER,
20 	PVR_STREAM_TYPE_STATIC_RENDER_CONTEXT,
21 	PVR_STREAM_TYPE_STATIC_COMPUTE_CONTEXT,
22 
23 	PVR_STREAM_TYPE_MAX
24 };
25 
26 enum pvr_stream_size {
27 	PVR_STREAM_SIZE_8 = 0,
28 	PVR_STREAM_SIZE_16,
29 	PVR_STREAM_SIZE_32,
30 	PVR_STREAM_SIZE_64,
31 	PVR_STREAM_SIZE_ARRAY,
32 };
33 
34 #define PVR_FEATURE_NOT  BIT(31)
35 #define PVR_FEATURE_NONE U32_MAX
36 
37 struct pvr_stream_def {
38 	u32 offset;
39 	enum pvr_stream_size size;
40 	u32 array_size;
41 	u32 feature;
42 };
43 
44 struct pvr_stream_ext_def {
45 	const struct pvr_stream_def *stream;
46 	u32 stream_len;
47 	u32 header_mask;
48 	u32 quirk;
49 };
50 
51 struct pvr_stream_ext_header {
52 	const struct pvr_stream_ext_def *ext_streams;
53 	u32 ext_streams_num;
54 	u32 valid_mask;
55 };
56 
57 struct pvr_stream_cmd_defs {
58 	enum pvr_stream_type type;
59 
60 	const struct pvr_stream_def *main_stream;
61 	u32 main_stream_len;
62 
63 	u32 ext_nr_headers;
64 	const struct pvr_stream_ext_header *ext_headers;
65 
66 	size_t dest_size;
67 };
68 
69 int
70 pvr_stream_process(struct pvr_device *pvr_dev, const struct pvr_stream_cmd_defs *cmd_defs,
71 		   void *stream, u32 stream_size, void *dest_out);
72 void
73 pvr_stream_create_musthave_masks(struct pvr_device *pvr_dev);
74 
75 #endif /* PVR_STREAM_H */
76