hal_gfx_cmdlist.h
Go to the documentation of this file.
1 
2 /** @addtogroup GRAPHICS_SDK Graphics
3  * @{
4  */
5 
6 /** @defgroup HAL_GFX_CMDLIST Hal gfx cmdlist
7  * @brief GPU management interfaces of command list.
8  * @{
9  */
10 
11 #ifndef HAL_GFX_CMDLIST_H__
12 #define HAL_GFX_CMDLIST_H__
13 
14 #include "hal_gfx_sys_defs.h"
15 #include "hal_gfx_hal.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /**
22  * @defgroup HAL_GFX_CMDLIST_MACRO Defines
23  * @{
24  */
25 #define CL_NOP 0x010000U /**< No operation. */
26 #define CL_PUSH 0x020000U /**< Push command to currently command list. */
27 #define CL_RETURN 0x040000U /**< Return from current command list. */
28 #define CL_ABORT 0x080000U /**< Abort current command list. */
29 #define CL_BATCH_SHIFT 12 /**< TODO. */
30 #define CL_BATCH_LOOP 0x8000 /**< TODO. */
31 #define SUBMISSION_ID_MASK 0xffffff /**< Mask. */
32 /** @} */
33 
34 /**
35  * @defgroup HAL_GFX_CMDLIST_STRUCT Structures
36  * @{
37  */
38 /**@brief Command list structure. */
39 typedef struct hal_gfx_cmdlist_t_
40 {
41  hal_gfx_buffer_t bo; /**< Buffer of command list*/
42  int size; /**< Number of entries in the command list */
43  int offset; /**< Points to the next address to write */
44  uint32_t flags; /**< Flags */
45  int32_t submission_id; /**< Command list id. */
46  struct hal_gfx_cmdlist_t_ *next; /**< Points to next command list */
47  struct hal_gfx_cmdlist_t_ *root; /**< Points to the head of the list */
49 /** @} */
50 
51 /**
52  * @defgroup HAL_GFX_CMDLIST_FUNCTION Functions
53  * @{
54  */
55 /**
56  *****************************************************************************************
57  * @brief Create a new Command List into a preallocated space
58  *
59  * @param[in] bo: Command List buffer (preallocated)
60  *
61  * @return The instance of the new Command List
62  *****************************************************************************************
63  */
65 
66 /**
67  *****************************************************************************************
68  * @brief Create a new, non expandable Command List of specific size
69  *
70  * @param[in] size_bytes: Command List's size in bytes
71  *
72  * @return instance of the new Command List
73  *****************************************************************************************
74  */
76 
77 /**
78  *****************************************************************************************
79  * @brief Create a new expandable Command List
80  *
81  * @return instance of the new Command List
82  *****************************************************************************************
83  */
85 
86 
87 /**
88  *****************************************************************************************
89  * @brief Create a new expandable Command List with power management mode
90  *
91  * @return instance of the new Command List
92  *****************************************************************************************
93  */
95 
96 /**
97  *****************************************************************************************
98  * @brief Destroy/Free a Command List
99  *
100  * @param[in] cl: Pointer to the Command List
101  *****************************************************************************************
102  */
104 
105 
106 /**
107  *****************************************************************************************
108  * @brief Destroy/Free a Command List with power management mode
109  *
110  * @param[in] cl: Pointer to the Command List
111  *****************************************************************************************
112  */
114 
115 /**
116  *****************************************************************************************
117  * @brief Reset position of next command to be written to the beginning. Doesn't clear the List's contents.
118  *
119  * @param[in] cl: Pointer to the Command List
120  *****************************************************************************************
121  */
123 
124 /**
125  *****************************************************************************************
126  * @brief Define in which Command List each subsequent commands are going to be inserted.
127  *
128  * @param[in] cl: Pointer to the Command List
129  *****************************************************************************************
130  */
132 
133 /**
134  *****************************************************************************************
135  * @brief Define in which Command List each subsequent commands are going to be inserted.
136  * Bind this command list as Circular. It never gets full, it never expands,
137  * it may get implicitly submitted, it cannot be reused.
138  *
139  * @param[in] cl: Pointer to the Command List
140  *****************************************************************************************
141  */
143 
144 /**
145  *****************************************************************************************
146  * @brief Unbind current bound Command List, if any.
147  * @return None
148  *****************************************************************************************
149  */
150 void hal_gfx_cl_unbind(void);
151 
152 /**
153  *****************************************************************************************
154  * @brief Get bound Command List
155  *
156  * @return Pointer to the bound Command List
157  *****************************************************************************************
158  */
160 
161 /**
162  *****************************************************************************************
163  * @brief Push command to command list, but do not trigger interrupt.
164  *
165  * @param[in] cl: command list
166  *****************************************************************************************
167  */
169 
170 /**
171  *****************************************************************************************
172  * @brief Enqueue Command List to the Ring Buffer for execution
173  *
174  * @param[in] cl: Pointer to the Command List
175  *****************************************************************************************
176  */
178 
179 /**
180  *****************************************************************************************
181  * @brief Wait for Command List to finish
182  *
183  * @param[in] cl: Pointer to the Command List
184  *
185  * @return 0 if no error has occurred
186  *****************************************************************************************
187  */
189 
190 /**
191  *****************************************************************************************
192  * @brief Add a command to the bound Command List
193  *
194  * @param[in] reg: Hardware register to be written
195  * @param[in] data: Data to be written
196  *****************************************************************************************
197  */
198 void hal_gfx_cl_add_cmd(uint32_t reg, uint32_t data);
199 
200 /**
201  *****************************************************************************************
202  * @brief Add multiple commands to the bound Command List
203  *
204  * @param[in] cmd_no: Numbers of commands to add
205  * @param[in] cmd: Pointer to the commands to be added
206  *
207  * @return 0 if no error has occurred
208  *****************************************************************************************
209  */
210 int hal_gfx_cl_add_multiple_cmds(int cmd_no, uint32_t *cmd);
211 
212 /**
213  *****************************************************************************************
214  * @brief Request free space from command list.
215  *
216  * @param[in] cmd_no: Number of commands to write
217  *
218  * @return Return pointer in bound_cl to directly add commands
219  *****************************************************************************************
220  */
221 uint32_t * hal_gfx_cl_get_space(int cmd_no);
222 
223 /**
224  *****************************************************************************************
225  * @brief Branch from the bound Command List to a different one. Return is implied.
226  *
227  * @param[in] cl: Pointer to the Command List to branch to
228  *****************************************************************************************
229  */
231 
232 /**
233  *****************************************************************************************
234  * @brief Jump from the bound Command List to a different one. No return is implied.
235  *
236  * @param[in] cl: Pointer to the Command List to jump to
237  *****************************************************************************************
238  */
240 
241 /**
242  *****************************************************************************************
243  * @brief Add an explicit return command to the bound Command List
244  *****************************************************************************************
245  */
246 void hal_gfx_cl_return(void);
247 
248 /**
249  *****************************************************************************************
250  * @brief Returns positive number if the Command List is almost full, otherwise returns 0.
251  *
252  * @param[in] cl: Pointer to the Command List
253  *****************************************************************************************
254  */
256 
257 /**
258  *****************************************************************************************
259  * @brief Check if there is enough space or expansion can be performed for
260  * required commands.
261  *
262  * @param[in] cmd_no: Numbers of commands to be checked if they fit
263  *
264  * @return zero is commands fit or expansion xan be performed else return negative
265  *****************************************************************************************
266  */
267 int hal_gfx_cl_enough_space(int cmd_no);
268 /** @} */
269 #ifdef __cplusplus
270 }
271 #endif
272 
273 #endif
274 /** @} */
275 /** @} */
276 
hal_gfx_cl_unbind
void hal_gfx_cl_unbind(void)
Unbind current bound Command List, if any.
hal_gfx_cl_jump
void hal_gfx_cl_jump(hal_gfx_cmdlist_t *cl)
Jump from the bound Command List to a different one. No return is implied.
hal_gfx_cl_get_bound
hal_gfx_cmdlist_t * hal_gfx_cl_get_bound(void)
Get bound Command List.
hal_gfx_cmdlist_t_::bo
hal_gfx_buffer_t bo
Definition: hal_gfx_cmdlist.h:41
hal_gfx_cl_le_create
hal_gfx_cmdlist_t hal_gfx_cl_le_create(void)
Create a new expandable Command List with power management mode.
hal_gfx_cmdlist_t_::next
struct hal_gfx_cmdlist_t_ * next
Definition: hal_gfx_cmdlist.h:46
hal_gfx_cl_bind
void hal_gfx_cl_bind(hal_gfx_cmdlist_t *cl)
Define in which Command List each subsequent commands are going to be inserted.
hal_gfx_cl_destroy
void hal_gfx_cl_destroy(hal_gfx_cmdlist_t *cl)
Destroy/Free a Command List.
hal_gfx_cl_wait
int hal_gfx_cl_wait(hal_gfx_cmdlist_t *cl)
Wait for Command List to finish.
hal_gfx_cl_get_space
uint32_t * hal_gfx_cl_get_space(int cmd_no)
Request free space from command list.
hal_gfx_cl_add_cmd
void hal_gfx_cl_add_cmd(uint32_t reg, uint32_t data)
Add a command to the bound Command List.
hal_gfx_cmdlist_t_
Command list structure.
Definition: hal_gfx_cmdlist.h:40
hal_gfx_cmdlist_t_::submission_id
int32_t submission_id
Definition: hal_gfx_cmdlist.h:45
hal_gfx_sys_defs.h
hal_gfx_cl_enough_space
int hal_gfx_cl_enough_space(int cmd_no)
Check if there is enough space or expansion can be performed for required commands.
hal_gfx_buffer_t_
The base structure of gpu memory.
Definition: hal_gfx_hal.h:36
hal_gfx_cl_le_destroy
void hal_gfx_cl_le_destroy(hal_gfx_cmdlist_t *cl)
Destroy/Free a Command List with power management mode.
hal_gfx_cl_submit
void hal_gfx_cl_submit(hal_gfx_cmdlist_t *cl)
Enqueue Command List to the Ring Buffer for execution.
hal_gfx_cmdlist_t_::offset
int offset
Definition: hal_gfx_cmdlist.h:43
hal_gfx_cmdlist_t
struct hal_gfx_cmdlist_t_ hal_gfx_cmdlist_t
Command list structure.
hal_gfx_cl_return
void hal_gfx_cl_return(void)
Add an explicit return command to the bound Command List.
hal_gfx_cl_almost_full
int hal_gfx_cl_almost_full(hal_gfx_cmdlist_t *cl)
Returns positive number if the Command List is almost full, otherwise returns 0.
hal_gfx_cl_create
hal_gfx_cmdlist_t hal_gfx_cl_create(void)
Create a new expandable Command List.
hal_gfx_cl_bind_circular
void hal_gfx_cl_bind_circular(hal_gfx_cmdlist_t *cl)
Define in which Command List each subsequent commands are going to be inserted. Bind this command lis...
hal_gfx_cmdlist_t_::flags
uint32_t flags
Definition: hal_gfx_cmdlist.h:44
hal_gfx_cl_add_multiple_cmds
int hal_gfx_cl_add_multiple_cmds(int cmd_no, uint32_t *cmd)
Add multiple commands to the bound Command List.
hal_gfx_cmdlist_t_::root
struct hal_gfx_cmdlist_t_ * root
Definition: hal_gfx_cmdlist.h:47
hal_gfx_cl_create_sized
hal_gfx_cmdlist_t hal_gfx_cl_create_sized(int size_bytes)
Create a new, non expandable Command List of specific size.
hal_gfx_cmdlist_t_::size
int size
Definition: hal_gfx_cmdlist.h:42
hal_gfx_cl_rewind
void hal_gfx_cl_rewind(hal_gfx_cmdlist_t *cl)
Reset position of next command to be written to the beginning. Doesn't clear the List's contents.
hal_gfx_cl_create_prealloc
hal_gfx_cmdlist_t hal_gfx_cl_create_prealloc(hal_gfx_buffer_t *bo)
Create a new Command List into a preallocated space.
hal_gfx_cl_submit_no_irq
void hal_gfx_cl_submit_no_irq(hal_gfx_cmdlist_t *cl)
Push command to command list, but do not trigger interrupt.
hal_gfx_cl_branch
void hal_gfx_cl_branch(hal_gfx_cmdlist_t *cl)
Branch from the bound Command List to a different one. Return is implied.
hal_gfx_hal.h