commit a0c4594
Michael Forney
·
2014-01-31 12:07:43 +0000 UTC
parent f63520e
nouveau: Add more flexible command interface
1 files changed,
+47,
-9
+47,
-9
1@@ -112,6 +112,18 @@ static inline bool ensure_space(struct nouveau_pushbuf * push, uint32_t count)
2 return nouveau_pushbuf_space(push, count, 0, 0) == 0;
3 }
4
5+static inline void nv_add_dword(struct nouveau_pushbuf * push, uint32_t dword)
6+{
7+ *push->cur++ = dword;
8+}
9+
10+static inline void nv_add_dwords_va(struct nouveau_pushbuf * push,
11+ uint16_t count, va_list dwords)
12+{
13+ while (count--)
14+ nv_add_dword(push, va_arg(dwords, uint32_t));
15+}
16+
17 static uint32_t nvc0_format(uint32_t format)
18 {
19 switch (format)
20@@ -124,22 +136,48 @@ static uint32_t nvc0_format(uint32_t format)
21 return 0;
22 }
23
24-static inline void nvc0_command(struct nouveau_pushbuf * push,
25- uint8_t subchannel, uint16_t method,
26- uint8_t count, ...)
27+enum
28+{
29+ NVC0_COMMAND_TYPE_INCREASING = 1,
30+ NVC0_COMMAND_TYPE_NON_INCREASING = 3,
31+ NVC0_COMMAND_TYPE_INLINE = 4
32+};
33+
34+enum
35+{
36+ NVC0_SUBCHANNEL_2D = 3,
37+};
38+
39+static inline uint32_t nvc0_command(uint8_t type, uint8_t subchannel,
40+ uint16_t method, uint16_t count_or_value)
41+{
42+ return type << 29 | count_or_value << 16 | subchannel << 13 | method >> 2;
43+}
44+
45+static inline void nvc0_inline(struct nouveau_pushbuf * push,
46+ uint8_t subchannel, uint16_t method,
47+ uint16_t value)
48+{
49+ nv_add_dword(push, nvc0_command(NVC0_COMMAND_TYPE_INLINE,
50+ subchannel, method, value));
51+}
52+
53+static inline void nvc0_methods(struct nouveau_pushbuf * push,
54+ uint8_t subchannel, uint16_t start_method,
55+ uint16_t count, ...)
56 {
57 va_list dwords;
58+ nv_add_dword(push, nvc0_command(NVC0_COMMAND_TYPE_INCREASING,
59+ subchannel, start_method, count));
60 va_start(dwords, count);
61- *push->cur++ = 0x20000000 | count << 16 | subchannel << 13 | method >> 2;
62- while (count--)
63- *push->cur++ = va_arg(dwords, uint32_t);
64+ nv_add_dwords_va(push, count, dwords);
65 va_end(dwords);
66 }
67
68-#define NVC0_SUBCHANNEL_2D 3
69-
70 #define nvc0_2d(push, method, count, ...) \
71- nvc0_command(push, NVC0_SUBCHANNEL_2D, method, count, __VA_ARGS__)
72+ nvc0_methods(push, NVC0_SUBCHANNEL_2D, method, count, __VA_ARGS__)
73+#define nvc0_2d_inline(push, method, value) \
74+ nvc0_inline(push, NVC0_SUBCHANNEL_2D, method, value)
75
76 static bool nvc0_2d_initialize(struct nouveau_renderer * renderer)
77 {