180 | | There exist two methods to access the ''vci_framebuffer'': |
181 | | * The _sys_fbf_sync_write() and _sys_fbf_sync_read() functions use a memcpy strategy to implement the transfer between a data buffer (user space) and the frame buffer (kernel space). They are blocking until completion of the transfer. |
182 | | * The _sys_fbf_cma_alloc(), _sys_fbf_cma_start(), _sys_fbf_cma_display(), and _sys_fbf_cma_stop() functions use the ''vci_chbuf_dma'' component to transfer a stream of images from an user space chained buffer (two buffers) to the frame buffer. |
183 | | |
184 | | === 1) int '''_sys_fbf_cma_alloc'''() === |
185 | | This function allocates a private CMA channel to the calling task, and register the channel index in the task context. |
186 | | Return -1 if no CMA channel available. |
187 | | |
188 | | === 2) int '''_sys_fbf_cma_start'''( void* vbase0, void* vbase1, unsigned int length ) === |
189 | | This function initializes the CMA channel to start the transfer of a stream of images from an user chbuf (two buffers) to the frame buffer chbuf (one single buffer). The user buffers must be aligned on a word boundary. The CMA component is configured in IN_ORDER transfer mode (blocking when the expected source or destination buffer is not available). |
190 | | * '''vbase0''' : virtual base address of the first user buffer. |
191 | | * '''vbase1''' : virtual base address of the second user buffer. |
192 | | * '''length''' : buffer length (bytes) |
193 | | It uses the _fbf_chbuf[] and _fbf_chbuf_paddr[] arrays, that are both indexed by the channel index, and makes the following actions: |
194 | | 1. it computes the physical addresses for the two source user buffers, for the destination frame buffer, and initializes the channel descriptor _fbf_chbuf[i]. |
195 | | 2. it computes the physical address for the chbuf descriptor and register it in the _fbf_chbuf_paddr[i]. |
196 | | 3. it makes a SYNC request to L2 cache for channel descriptor if the IOB is used, because the channel descriptor is directly accessed in XRAM by the CMA component. |
197 | | 4. it Starts the CMA hardware channel, that will poll the channel descriptor to fransfer an user buffer to the frame buffer as soon as the source user buffer is marked valid. |
198 | | Return 0 in case of success. |
199 | | Return -1 if no CMA channel allocated to the calling task, or if user buffers not aligned on a word boundary. |
200 | | |
201 | | === 3) int '''_sys_fbf_cma_display'''( unsigned int buffer_index ) === |
202 | | This function is used in conjunction with the _fbf_cma_start() function, and must be called each time a new user buffer is available for display, to set the user buffer status in the chbuf descriptor. |
203 | | The '''buffer_index''' argument define the user buffer index (0 => buf0 / not 0 => buf1). |
204 | | It makes the following actions if the IO Bridge component is used: |
205 | | 1. it makes an INVAL request for the channel descriptor, before testing the source buffer status, because it is modified in XRAM by the CMA component. |
206 | | 2. it makes a SYNC request for the source user buffer before activating the CMA transfer, because the data will be read from XRAM by the CMA component. |
207 | | 3. it makes a SYNC request for the channel descriptor after modification of the SRC and DST status, because these descriptors will be read from XRAM by the CMA component. |
208 | | Return 0 in case of success. Return -1 if no CMA channel allocated to the calling task. |
209 | | |
210 | | === 4) int '''_sys_fbf_cma_stop'''() === |
| 180 | === 1) int '''_sys_fbf_size'''( unsigned int* width , unsigned int* height ) === |
| 181 | This function returns in the <width> and <height> buffers the Frame Buffer size. |
| 182 | It returns always SYSCALL_OK. |
| 183 | |
| 184 | === 2) int '''_sys_fbf_alloc'''() === |
| 185 | This function takes the exclusive ownership of the frame buffer for the calling thread application. |
| 186 | It must be called by a single thread. It register the number of potential users : all threads in the same space as the calling thread. |
| 187 | It returns SYSCALL_OK in case of success. |
| 188 | It returns SYSCALL_SHARED_PERIPHERAL_BUSY if the frame buffer is already allocated. |
| 189 | |
| 190 | === 3) int '''_sys_fbf_release'''() === |
| 191 | This function decrement the number of registered users for the frame buffer. It must be called by all the threads of a given application to completely release the frame buffer. |
| 192 | It returns SYSCALL_OK in case of success. |
| 193 | It returns SYCALL_CHANNEL_NON_ALLOCATED if the frame buffer was not allocated. |
| 194 | |
| 195 | |
| 196 | === 4) int '''_sys_fbf_cma_alloc'''( unsigned int nbufs ) === |
| 197 | This function allocates a private CMA channel, that can be used by all threads in the same space as the calling thread. It must be called by a single thread, but the channel index is registered in all threads contexts in the same vspace. |
| 198 | The <nbufs> argument define the CMA length (number of chained buffers). |
| 199 | Ir returns SYSCALL_OK in case of success. |
| 200 | It returns SYSCALL_NO_CHANNEL_AVAILABLE if no CMA channel available. |
| 201 | It returns SYSCALL_CHANNEL_ALREADY_ALLOCATED if CMA already allocated. |
| 202 | It returns SYSCALL_ILLEGAL_ARGUMENT if <nbufs> is larger than 256. |
| 203 | |
| 204 | === 5) int '''_sys_fbf_cma_release'''() === |
| 205 | This function decrement the number of registered users for the allocated CMA channel. It must be called by all the threads of a given application to completely release the CMA channel. It stops the CMA transfer, when the last thread in the space releases the CMA channel. |
| 206 | It returns SYSCALL_OK in case of success. |
| 207 | It returns SYCALL_CHANNEL_NON_ALLOCATED if the CMA channel was not allocated. |
| 208 | |
| 209 | === 6) int _sys_fbf_cma_init_buf'''( unsigned int index , void* buf_vaddr , void* sts_vaddr ) === |
| 210 | This function register an user buffer and a buffer status in the the CHBUF descriptor associated to the |
| 211 | frame buffer. The <index> argument is the buffer index in the CHBUF. The <buf_vaddr> and <sts_vaddr> arguments are the pointers on the user buffer and status. Both the user buffer and the user status must be 64 bytes aligned. |
| 212 | It returns SYSCALL_OK in case of success. |
| 213 | It returns SYCALL_CHANNEL_NON_ALLOCATED if the CMA channel was not allocated. |
| 214 | It returns SYSCALL_ADDRESS_NON_ALIGNED if the buffer or status are not 64 bytes aligned. |
| 215 | It returns SYSCALL_ADDRESS_NON_USER_ACCESSIBLE if addresses are protected. |
| 216 | |
| 217 | === 7) int '''_sys_fbf_cma_start'''( ) === |
| 218 | This function activates the CMA channel to transfer of a stream of images from the user buffers to the frame buffer. The user buffers musThe CMA component is configured in IN_ORDER transfer mode (blocking when the expected source buffer is not available). |
| 219 | It returns SYSCALL_OK in case of success. |
| 220 | It returns SYCALL_CHANNEL_NON_ALLOCATED if the CMA channel was not allocated. |
| 221 | It returns SYSCALL_MISSING_INITIALISATION if the CHBUF was not initialized. |
| 222 | |
| 223 | === 8) int '''_sys_fbf_cma_check'''( unsigned int index ) === |
| 224 | This blocking function checks that the user buffer identified by the <index> argument is empty, and can be reused by the application. It makes an INVAL request to the L2 cache, before testing the source buffer status, because it is modified in XRAM by the CMA component. |
| 225 | It returns SYSCALL_OK when the buffer is empty. |
| 226 | It returns SYCALL_CHANNEL_NON_ALLOCATED if the CMA channel was not allocated. |
| 227 | |
| 228 | === 9) int '''_sys_fbf_cma_display'''( unsigned int index ) === |
| 229 | This function must be used to signal that the user buffer identified by the <index> argument is full and can be transferred to the frame buffer. |
| 230 | It makes a SYNC request to the L2 cache, for both the source user buffer the status, because these data will be read from XRAM by the CMA component. |
| 231 | It returns SYSCALL_OK in case of success. |
| 232 | It returns SYCALL_CHANNEL_NON_ALLOCATED if the CMA channel was not allocated. |
| 233 | |
| 234 | === 10) int '''_sys_fbf_cma_stop'''() === |