atom.h revision 1.1 1 /* $NetBSD: atom.h,v 1.1 2021/12/18 20:15:36 riastradh Exp $ */
2
3 #ifndef __NV50_KMS_ATOM_H__
4 #define __NV50_KMS_ATOM_H__
5 #define nv50_atom(p) container_of((p), struct nv50_atom, state)
6 #include <drm/drm_atomic.h>
7
8 struct nv50_atom {
9 struct drm_atomic_state state;
10
11 struct list_head outp;
12 bool lock_core;
13 bool flush_disable;
14 };
15
16 #define nv50_head_atom(p) container_of((p), struct nv50_head_atom, state)
17
18 struct nv50_head_atom {
19 struct drm_crtc_state state;
20
21 struct {
22 u32 mask;
23 u32 olut;
24 } wndw;
25
26 struct {
27 u16 iW;
28 u16 iH;
29 u16 oW;
30 u16 oH;
31 } view;
32
33 struct nv50_head_mode {
34 bool interlace;
35 u32 clock;
36 struct {
37 u16 active;
38 u16 synce;
39 u16 blanke;
40 u16 blanks;
41 } h;
42 struct {
43 u32 active;
44 u16 synce;
45 u16 blanke;
46 u16 blanks;
47 u16 blank2s;
48 u16 blank2e;
49 u16 blankus;
50 } v;
51 } mode;
52
53 struct {
54 bool visible;
55 u32 handle;
56 u64 offset:40;
57 u8 buffer:1;
58 u8 mode:4;
59 u16 size:11;
60 u8 range:2;
61 u8 output_mode:2;
62 void (*load)(struct drm_color_lut *, int size, void __iomem *);
63 } olut;
64
65 struct {
66 bool visible;
67 u32 handle;
68 u64 offset:40;
69 u8 format;
70 u8 kind:7;
71 u8 layout:1;
72 u8 blockh:4;
73 u16 blocks:12;
74 u32 pitch:20;
75 u16 x;
76 u16 y;
77 u16 w;
78 u16 h;
79 } core;
80
81 struct {
82 bool visible;
83 u32 handle;
84 u64 offset:40;
85 u8 layout:2;
86 u8 format:8;
87 } curs;
88
89 struct {
90 u8 depth;
91 u8 cpp;
92 u16 x;
93 u16 y;
94 u16 w;
95 u16 h;
96 } base;
97
98 struct {
99 u8 cpp;
100 } ovly;
101
102 struct {
103 bool enable:1;
104 u8 bits:2;
105 u8 mode:4;
106 } dither;
107
108 struct {
109 struct {
110 u16 cos:12;
111 u16 sin:12;
112 } sat;
113 } procamp;
114
115 struct {
116 u8 nhsync:1;
117 u8 nvsync:1;
118 u8 depth:4;
119 u8 bpc;
120 } or;
121
122 /* Currently only used for MST */
123 struct {
124 int pbn;
125 u8 tu:6;
126 } dp;
127
128 union nv50_head_atom_mask {
129 struct {
130 bool olut:1;
131 bool core:1;
132 bool curs:1;
133 bool view:1;
134 bool mode:1;
135 bool base:1;
136 bool ovly:1;
137 bool dither:1;
138 bool procamp:1;
139 bool or:1;
140 };
141 u16 mask;
142 } set, clr;
143 };
144
145 static inline struct nv50_head_atom *
146 nv50_head_atom_get(struct drm_atomic_state *state, struct drm_crtc *crtc)
147 {
148 struct drm_crtc_state *statec = drm_atomic_get_crtc_state(state, crtc);
149 if (IS_ERR(statec))
150 return (void *)statec;
151 return nv50_head_atom(statec);
152 }
153
154 #define nv50_wndw_atom(p) container_of((p), struct nv50_wndw_atom, state)
155
156 struct nv50_wndw_atom {
157 struct drm_plane_state state;
158
159 struct drm_property_blob *ilut;
160 bool visible;
161
162 struct {
163 u32 handle;
164 u16 offset:12;
165 bool awaken:1;
166 } ntfy;
167
168 struct {
169 u32 handle;
170 u16 offset:12;
171 u32 acquire;
172 u32 release;
173 } sema;
174
175 struct {
176 u32 handle;
177 struct {
178 u64 offset:40;
179 u8 buffer:1;
180 u8 enable:2;
181 u8 mode:4;
182 u16 size:11;
183 u8 range:2;
184 u8 output_mode:2;
185 void (*load)(struct drm_color_lut *, int size,
186 void __iomem *);
187 } i;
188 } xlut;
189
190 struct {
191 u32 matrix[12];
192 bool valid;
193 } csc;
194
195 struct {
196 u8 mode:2;
197 u8 interval:4;
198
199 u8 colorspace:2;
200 u8 format;
201 u8 kind:7;
202 u8 layout:1;
203 u8 blockh:4;
204 u16 blocks[3];
205 u32 pitch[3];
206 u16 w;
207 u16 h;
208
209 u32 handle[6];
210 u64 offset[6];
211 } image;
212
213 struct {
214 u16 sx;
215 u16 sy;
216 u16 sw;
217 u16 sh;
218 u16 dw;
219 u16 dh;
220 } scale;
221
222 struct {
223 u16 x;
224 u16 y;
225 } point;
226
227 struct {
228 u8 depth;
229 u8 k1;
230 u8 src_color:4;
231 u8 dst_color:4;
232 } blend;
233
234 union nv50_wndw_atom_mask {
235 struct {
236 bool ntfy:1;
237 bool sema:1;
238 bool xlut:1;
239 bool csc:1;
240 bool image:1;
241 bool scale:1;
242 bool point:1;
243 bool blend:1;
244 };
245 u8 mask;
246 } set, clr;
247 };
248 #endif
249