]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - qnx/src/ipc3x_dev/tiler/resmgr/tiler/tiler.h
Moved files from the ipc3x_dev branch in syslink_qnx repository into direct
[ipc/ipcdev.git] / qnx / src / ipc3x_dev / tiler / resmgr / tiler / tiler.h
1 /*
2  * Copyright (c) 2010, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * */
32 /*
33  * tiler.h
34  *
35  * TILER driver support functions for TI OMAP processors.
36  *
37  * Copyright (C) 2009-2010 Texas Instruments, Inc.
38  */
40 #ifndef TILER_H
41 #define TILER_H
43 #include <errno.h>
44 #include <stdio.h>
45 #include <stddef.h>
46 #include <stdlib.h>
47 #include <unistd.h>
48 #include <string.h>
49 #include <atomic.h>
50 #include <stdbool.h>
51 #include <devctl.h>
52 #include <fcntl.h>
53 #include <stdint.h>
54 #include <hw/inout.h>
55 #include <sys/iofunc.h>
56 #include <sys/dispatch.h>
57 #include <sys/procmgr.h>
58 #include <sys/mman.h>
59 #include <sys/neutrino.h>
60 #include <sys/siginfo.h>
61 #include <sys/ioctl.h>
63 #include "proto.h"
65 #include "tiler/tiler_devctl.h"
67 #define PAGE_SIZE 0x1000
68 #define TILER_PAGE 0x1000
69 #define TILER_WIDTH    256
70 #define TILER_HEIGHT   128
71 #define TILER_BLOCK_WIDTH  64
72 #define TILER_BLOCK_HEIGHT 64
73 #define TILER_LENGTH (TILER_WIDTH * TILER_HEIGHT * TILER_PAGE)
76 /* utility functions */
77 static inline u32 tilfmt_bpp(enum tiler_fmt fmt)
78 {
79         return  fmt == TILFMT_8BIT ? 1 :
80                 fmt == TILFMT_16BIT ? 2 :
81                 fmt == TILFMT_32BIT ? 4 : 0;
82 }
84 /**
85  * Prototype for notifier callback.
86  *
87  * @param event_type    type of event that happened
88  *
89  * @param arg                   user private data
90  *
91  * @return error status
92  */
93 typedef s32 (*tiler_notifier_cb) (int event_type, void *data, void *arg);
95 /**
96  * Registers a notifier block with TILER driver.
97  *
98  * @param nb            notifier_block
99  *
100  * @return error status
101  */
102 int tiler_reg_notifier(tiler_notifier_cb cb_ptr, void * arg);
104 /**
105  * Un-registers a notifier block with TILER driver.
106  *
107  * @param nb            notifier_block
108  *
109  * @return error status
110  */
111 int tiler_unreg_notifier(tiler_notifier_cb cb_ptr, void * arg);
113 /**
114  * Reserves a 1D or 2D TILER block area and memory for the
115  * current process with group ID 0.
116  *
117  * @param fmt           TILER bit mode
118  * @param width         block width
119  * @param height        block height (must be 1 for 1D)
120  * @param sys_addr      pointer where system space (L3) address
121  *                      will be stored.
122  *
123  * @return error status
124  */
125 s32 tiler_alloc(enum tiler_fmt fmt, u32 width, u32 height, u32 *sys_addr);
127 /**
128  * Reserves a 1D or 2D TILER block area and memory with extended
129  * arguments.
130  *
131  * @param fmt           TILER bit mode
132  * @param width         block width
133  * @param height        block height (must be 1 for 1D)
134  * @param align         block alignment (default: PAGE_SIZE)
135  * @param offs          block offset
136  * @param gid           group ID
137  * @param pi            process information
138  * @param sys_addr      pointer where system space (L3) address
139  *                      will be stored.
140  *
141  * @return error status
142  */
143 s32 tiler_allocx(enum tiler_fmt fmt, u32 width, u32 height,
144                         u32 align, u32 offs, u32 gid, void *pi, u32 *sys_addr);
146 /**
147  * Maps an existing buffer to a 1D or 2D TILER area for the
148  * current process with group ID 0.
149  *
150  * Currently, only 1D area mapping is supported.
151  *
152  * @param fmt           TILER bit mode
153  * @param width         block width
154  * @param height        block height (must be 1 for 1D)
155  * @param sys_addr      pointer where system space (L3) address
156  *                      will be stored.
157  * @param usr_addr      user space address of existing buffer.
158  *
159  * @return error status
160  */
161 s32 tiler_map(enum tiler_fmt fmt, u32 width, u32 height, u32 *sys_addr,
162                                                                 u32 usr_addr);
164 /**
165  * Maps an existing buffer to a 1D or 2D TILER area with
166  * extended arguments.
167  *
168  * Currently, only 1D area mapping is supported.
169  *
170  * NOTE: alignment is always PAGE_SIZE and offset is 0
171  *
172  * @param fmt           TILER bit mode
173  * @param width         block width
174  * @param height        block height (must be 1 for 1D)
175  * @param gid           group ID
176  * @param pid           process information
177  * @param sys_addr      pointer where system space (L3) address
178  *                      will be stored.
179  * @param usr_addr      user space address of existing buffer.
180  *
181  * @return error status
182  */
183 s32 tiler_mapx(enum tiler_fmt fmt, u32 width, u32 height,
184                         u32 gid, void *pi, u32 *sys_addr, u32 usr_addr);
186 /**
187  * Free TILER memory.
188  *
189  * @param sys_addr system space (L3) address.
190  *
191  * @return an error status.
192  */
193 s32 tiler_free(u32 sys_addr);
195 /**
196  * Reserves tiler area for n identical set of blocks (buffer)
197  * for the current process.  Use this method to get optimal
198  * placement of multiple related tiler blocks; however, it may
199  * not reserve area if tiler_alloc is equally efficient.
200  *
201  * @param n     number of identical set of blocks
202  * @param b     information on the set of blocks (ptr, ssptr and
203  *              stride fields are ignored)
204  *
205  * @return error status
206  */
207 s32 tiler_reserve(u32 n, struct tiler_buf_info *b);
209 /**
210  * Reserves tiler area for n identical set of blocks (buffer) fo
211  * a given process. Use this method to get optimal placement of
212  * multiple related tiler blocks; however, it may not reserve
213  * area if tiler_alloc is equally efficient.
214  *
215  * @param n     number of identical set of blocks
216  * @param b     information on the set of blocks (ptr, ssptr and
217  *              stride fields are ignored)
218  * @param pid   process ID
219  *
220  * @return error status
221  */
222 s32 tiler_reservex(u32 n, struct tiler_buf_info *b, pid_t pid);
224 u32 tiler_reorient_addr(u32 tsptr, struct tiler_view_orient orient);
226 u32 tiler_get_natural_addr(void *sys_ptr);
228 u32 tiler_reorient_topleft(u32 tsptr, struct tiler_view_orient orient,
229                                 u32 width, u32 height);
231 u32 tiler_stride(u32 tsptr);
233 void tiler_rotate_view(struct tiler_view_orient *orient, u32 rotation);
235 void tiler_alloc_packed(s32 *count, enum tiler_fmt fmt, u32 width, u32 height,
236                         void **sysptr, void **allocptr, s32 aligned, void *pi);
238 void tiler_alloc_packed_nv12(s32 *count, u32 width, u32 height, void **y_sysptr,
239                                 void **uv_sysptr, void **y_allocptr,
240                                 void **uv_allocptr, s32 aligned, void *pi );
242 /**
243  * Reserves a 1D or 2D TILER block area with extended
244  * arguments.
245  *
246  * @param fmt           TILER bit mode
247  * @param width         block width
248  * @param height        block height (must be 1 for 1D)
249  * @param gid           group ID
250  * @param pi            process information
251  * @param sys_addr      pointer where system space (L3) address
252  *                      will be stored.
253  * @param num_pages     pointer where the number of pages required to
254  *                      program this area will be stored.
255  *
256  * @return error status
257  */
258 s32 tiler_alloc_block_area(enum tiler_fmt fmt, u32 width, u32 height, u32 gid,
259                                 void *pi, u32 *sys_addr, u32 *num_pages);
261 /**
262  * Maps an array of physical pages to a 1D or 2D TILER area.
263  *
264  * @param sys_addr      The system space (L3) address, previously
265  *                              allocated with tiler_alloc_block_area, to which
266  *                              the array of pages will be mapped.
267  * @param num_pages     number of pages in the pages array
268  * @param pages         array of pages to be mapped to sys_addr
269  *
270  * @return error status
271  */
272 s32 tiler_map_block(u32 sys_addr, u32 num_pages, u32 *pages);
274 /**
275  * Unmaps a block previously mapped with tiler_map_block.
276  *
277  * @param sys_addr      The system space (L3) address, previously
278  *                              mapped with tiler_map_block, that is to be unmapped.
279  *
280  * @return error status
281  */
282 s32 tiler_unmap_block(u32 sys_addr);
284 #endif