| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2009-2012, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bgrc_packet.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/100 $ |
|---|
| 12 | * $brcm_Date: 2/9/12 2:25p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: GRC Packet API |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/grc/7405/bgrc_packet.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/100 2/9/12 2:25p nissen |
|---|
| 21 | * SW7405-4810: Fixed BGRC_Packet_GetStatus function. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/99 2/8/12 11:24a nissen |
|---|
| 24 | * SW7405-3671: Moved device reset to AdvancePackets when there is a hang. |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/98 2/7/12 7:41p nissen |
|---|
| 27 | * SW7405-3671: Fixed build error. |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/97 2/7/12 5:04p nissen |
|---|
| 30 | * SW7405-3671: Added code to reset M2MC and restart packets when M2MC |
|---|
| 31 | * hangs. |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/95 1/6/12 1:35p nissen |
|---|
| 34 | * SW7435-13 : Fixed support for 7435 A0. |
|---|
| 35 | * |
|---|
| 36 | * Hydra_Software_Devel/94 12/21/11 5:27p nissen |
|---|
| 37 | * SW7360-5: Added support for the 7360 A0. |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/93 12/21/11 12:55p nissen |
|---|
| 40 | * SW7405-3671: Added better check for when the M2MC is hung. |
|---|
| 41 | * |
|---|
| 42 | * Hydra_Software_Devel/92 12/15/11 6:50p nissen |
|---|
| 43 | * SW7435-13 : Added support for 7435 A0. |
|---|
| 44 | * |
|---|
| 45 | * Hydra_Software_Devel/91 11/29/11 4:15p nissen |
|---|
| 46 | * SW7425-1795: Changed to BMEM_Handle. |
|---|
| 47 | * |
|---|
| 48 | * Hydra_Software_Devel/90 11/22/11 6:20p nissen |
|---|
| 49 | * SW7425-1795: Added heap field to BGRC_PacketContext_CreateSettings |
|---|
| 50 | * structure for packet memory allocations. |
|---|
| 51 | * |
|---|
| 52 | * Hydra_Software_Devel/89 11/3/11 4:56p nissen |
|---|
| 53 | * SWBLURAY-27238: Added support for 2nd M2MC for 7640 B0. |
|---|
| 54 | * |
|---|
| 55 | * Hydra_Software_Devel/88 10/5/11 5:34p nissen |
|---|
| 56 | * SW7425-248: Updated use of BDBG_OBJECTs. |
|---|
| 57 | * |
|---|
| 58 | * Hydra_Software_Devel/87 10/5/11 12:58p nissen |
|---|
| 59 | * SW7425-248: Removed BDBG_OBJECT support for the 7038. |
|---|
| 60 | * |
|---|
| 61 | * Hydra_Software_Devel/86 9/23/11 12:31p nissen |
|---|
| 62 | * SW7429-4: Added support for 7429. |
|---|
| 63 | * |
|---|
| 64 | * Hydra_Software_Devel/85 9/17/11 7:17p nissen |
|---|
| 65 | * SW7425-248: Added BDBG_OBJECT_SET. |
|---|
| 66 | * |
|---|
| 67 | * Hydra_Software_Devel/84 9/17/11 7:06p nissen |
|---|
| 68 | * SW7425-248: Added BDBG_OBJECT_ID. |
|---|
| 69 | * |
|---|
| 70 | * Hydra_Software_Devel/83 9/17/11 6:31p nissen |
|---|
| 71 | * SW7425-248: Added BDBG_OBJECT_ASSERT. |
|---|
| 72 | * |
|---|
| 73 | * Hydra_Software_Devel/82 9/17/11 4:12p nissen |
|---|
| 74 | * SW7335-1080: Added type conversion for parameter. |
|---|
| 75 | * |
|---|
| 76 | * Hydra_Software_Devel/81 9/12/11 2:15p nissen |
|---|
| 77 | * SWBLURAY-27238: Fixing support for 7640 B0. |
|---|
| 78 | * |
|---|
| 79 | * Hydra_Software_Devel/80 9/6/11 4:36p nissen |
|---|
| 80 | * SWBLURAY-27238: Added support for 7640 B0. |
|---|
| 81 | * |
|---|
| 82 | * Hydra_Software_Devel/79 7/27/11 6:04p nissen |
|---|
| 83 | * SW7405-3671: Added support for fixed scaling with 420 destriping. |
|---|
| 84 | * |
|---|
| 85 | * Hydra_Software_Devel/78 6/28/11 2:23p nissen |
|---|
| 86 | * SW7420-1893: Changed Sync so that it continues to try it's blit instead |
|---|
| 87 | * of reporting out of memory. |
|---|
| 88 | * |
|---|
| 89 | * Hydra_Software_Devel/77 6/23/11 10:18a nissen |
|---|
| 90 | * SW7420-1893: Prevented sync blit frin over writting packet memory. |
|---|
| 91 | * |
|---|
| 92 | * Hydra_Software_Devel/76 5/27/11 6:26p nissen |
|---|
| 93 | * SW7346-149: Added packet writing functions, and fixed syncing a context |
|---|
| 94 | * that has not been used yet. |
|---|
| 95 | * |
|---|
| 96 | * Hydra_Software_Devel/75 4/5/11 5:36p jhaberf |
|---|
| 97 | * SWDTV-5977: Added support for 35233 DTV chip |
|---|
| 98 | * |
|---|
| 99 | * Hydra_Software_Devel/74 3/28/11 5:31p nissen |
|---|
| 100 | * SW7420-1715: Fixed link list when creating context. |
|---|
| 101 | * |
|---|
| 102 | * Hydra_Software_Devel/73 3/18/11 7:37p nissen |
|---|
| 103 | * SW7038-3500: Fixing header size. |
|---|
| 104 | * |
|---|
| 105 | * Hydra_Software_Devel/72 3/18/11 1:22p nissen |
|---|
| 106 | * SW7420-1575: Added new width and height fields for surface planes. |
|---|
| 107 | * |
|---|
| 108 | * Hydra_Software_Devel/71 3/7/11 2:16p nissen |
|---|
| 109 | * SW7038-3500: Switched header size back. |
|---|
| 110 | * |
|---|
| 111 | * Hydra_Software_Devel/70 3/5/11 4:51p nissen |
|---|
| 112 | * SW7038-3500: Changed header size to fit filter table. |
|---|
| 113 | * |
|---|
| 114 | * Hydra_Software_Devel/69 3/4/11 1:42p nissen |
|---|
| 115 | * SW7038-3500: Fixed header size. |
|---|
| 116 | * |
|---|
| 117 | * Hydra_Software_Devel/68 3/3/11 4:49p nissen |
|---|
| 118 | * SW7038-3500: Fixed build error for 7038. |
|---|
| 119 | * |
|---|
| 120 | * Hydra_Software_Devel/67 12/6/10 12:43p nissen |
|---|
| 121 | * SW7420-1138: Added support for validating memory bounds used by blits. |
|---|
| 122 | * |
|---|
| 123 | * Hydra_Software_Devel/66 12/3/10 11:46a nissen |
|---|
| 124 | * SW7344-10: Added support for the 7344 and 7346. |
|---|
| 125 | * |
|---|
| 126 | * Hydra_Software_Devel/65 11/26/10 4:23p jhaberf |
|---|
| 127 | * SW35125-33: Added support for the 35125 DTV chip |
|---|
| 128 | * |
|---|
| 129 | * Hydra_Software_Devel/64 11/25/10 12:27p nissen |
|---|
| 130 | * SW7552-13: Fixed support for 7552. |
|---|
| 131 | * |
|---|
| 132 | * Hydra_Software_Devel/63 11/24/10 9:31p nissen |
|---|
| 133 | * SW7552-13: Added support for 7552. |
|---|
| 134 | * |
|---|
| 135 | * Hydra_Software_Devel/62 11/19/10 12:51p nissen |
|---|
| 136 | * SW7425-19: Fixed HW reset. |
|---|
| 137 | * |
|---|
| 138 | * Hydra_Software_Devel/61 11/11/10 5:40p nissen |
|---|
| 139 | * SW7420-1200: Added support for storing packets before submitting, |
|---|
| 140 | * through a field in the context's create settings structure. |
|---|
| 141 | * |
|---|
| 142 | * Hydra_Software_Devel/60 10/27/10 6:22p nissen |
|---|
| 143 | * SW7405-4810: Fixed GetContextStatus to notify contexts need advancing |
|---|
| 144 | * without an interrupt firing. |
|---|
| 145 | * |
|---|
| 146 | * Hydra_Software_Devel/59 10/12/10 1:18p nissen |
|---|
| 147 | * SW7231-9: Added support for the 7231. |
|---|
| 148 | * |
|---|
| 149 | * Hydra_Software_Devel/58 10/12/10 12:54p nissen |
|---|
| 150 | * SW7358-14: Added support for the 7358. |
|---|
| 151 | * |
|---|
| 152 | * Hydra_Software_Devel/57 10/7/10 2:39p nissen |
|---|
| 153 | * SW7425-19: Added support for the 7422 and 7425. |
|---|
| 154 | * |
|---|
| 155 | * Hydra_Software_Devel/56 9/21/10 10:44a nissen |
|---|
| 156 | * SW7405-3671: Fixed problem with size when getting packet memory. |
|---|
| 157 | * |
|---|
| 158 | * Hydra_Software_Devel/55 9/20/10 4:23p nissen |
|---|
| 159 | * SW7405-4869: Fixed Rop usage. |
|---|
| 160 | * |
|---|
| 161 | * Hydra_Software_Devel/54 9/15/10 5:39p nissen |
|---|
| 162 | * SW7420-1081: Switched to using BMEM_Alloc with cached memory when |
|---|
| 163 | * allocating user packets. |
|---|
| 164 | * |
|---|
| 165 | * Hydra_Software_Devel/53 9/3/10 4:16p nissen |
|---|
| 166 | * SW7405-4810: Added BGRC_Packet_GetStatus function. |
|---|
| 167 | * |
|---|
| 168 | * Hydra_Software_Devel/52 8/27/10 10:28a mward |
|---|
| 169 | * SW7405-3671: Initialize m2mc_format to avoid a warning from some |
|---|
| 170 | * compilers. |
|---|
| 171 | * |
|---|
| 172 | * Hydra_Software_Devel/51 8/18/10 10:19p nissen |
|---|
| 173 | * SW7405-3671: Only advancing and syncing packets when destroying a |
|---|
| 174 | * context, if no callbacks set. |
|---|
| 175 | * |
|---|
| 176 | * Hydra_Software_Devel/50 8/18/10 3:13p nissen |
|---|
| 177 | * SW7405-3671: Checking if user overwrote submited packet memory. |
|---|
| 178 | * |
|---|
| 179 | * Hydra_Software_Devel/49 8/9/10 11:29a nissen |
|---|
| 180 | * SW7405-3671: Fixed HW fifo memory allocation. |
|---|
| 181 | * |
|---|
| 182 | * Hydra_Software_Devel/48 8/4/10 8:35p nissen |
|---|
| 183 | * SW7405-3671: Added alignment for allocation of output sync memory. |
|---|
| 184 | * |
|---|
| 185 | * Hydra_Software_Devel/47 8/4/10 7:14p nissen |
|---|
| 186 | * SW7405-3671: Increased size of output sync memory to size of maximum |
|---|
| 187 | * palette. |
|---|
| 188 | * |
|---|
| 189 | * Hydra_Software_Devel/46 8/4/10 6:14p nissen |
|---|
| 190 | * SW7405-3671: Fixed reset state when creating context. |
|---|
| 191 | * |
|---|
| 192 | * Hydra_Software_Devel/45 7/31/10 8:01p nissen |
|---|
| 193 | * SW7405-3671: Added fix for checking if blits are complete when syncing. |
|---|
| 194 | * |
|---|
| 195 | * Hydra_Software_Devel/44 7/30/10 11:19a nissen |
|---|
| 196 | * SW7405-3671: Fixed available memory when returning context status. |
|---|
| 197 | * |
|---|
| 198 | * Hydra_Software_Devel/43 7/29/10 7:53p nissen |
|---|
| 199 | * SW7405-3671: Removed code to submit packets when getting status. |
|---|
| 200 | * |
|---|
| 201 | * Hydra_Software_Devel/42 7/27/10 2:35p nissen |
|---|
| 202 | * SW7405-3671: Fixed packet memory wrap. |
|---|
| 203 | * |
|---|
| 204 | * Hydra_Software_Devel/41 7/26/10 2:14p nissen |
|---|
| 205 | * SW7405-3671: Fixed packet memory allocation. |
|---|
| 206 | * |
|---|
| 207 | * Hydra_Software_Devel/40 7/21/10 10:43p nissen |
|---|
| 208 | * SW7405-3671: Added code to put last context to the top of the list |
|---|
| 209 | * after advancing them all. |
|---|
| 210 | * |
|---|
| 211 | * Hydra_Software_Devel/39 7/21/10 6:36p nissen |
|---|
| 212 | * SW7405-3671: Added code to free context structure when destroying |
|---|
| 213 | * context. |
|---|
| 214 | * |
|---|
| 215 | * Hydra_Software_Devel/38 7/21/10 4:34p nissen |
|---|
| 216 | * SW7405-3671: Added support for user supplying private data ptr during |
|---|
| 217 | * context creation which gets passed back when getting status. |
|---|
| 218 | * |
|---|
| 219 | * Hydra_Software_Devel/37 7/21/10 3:27p nissen |
|---|
| 220 | * SW7405-3671: Added code to validate buffer size when submitting |
|---|
| 221 | * packets. |
|---|
| 222 | * |
|---|
| 223 | * Hydra_Software_Devel/36 7/21/10 11:47a nissen |
|---|
| 224 | * SW7405-3671: Fixed setting buffer pointer and size out when getting |
|---|
| 225 | * packet memory. |
|---|
| 226 | * |
|---|
| 227 | * Hydra_Software_Devel/35 7/18/10 4:08p nissen |
|---|
| 228 | * SW7405-3671: Fixed context status. |
|---|
| 229 | * |
|---|
| 230 | * Hydra_Software_Devel/34 7/17/10 3:32p nissen |
|---|
| 231 | * SW7405-3671: Fixed memory allocation. |
|---|
| 232 | * |
|---|
| 233 | * Hydra_Software_Devel/33 7/15/10 9:01p nissen |
|---|
| 234 | * SW7405-3671: Added more interrupt support. |
|---|
| 235 | * |
|---|
| 236 | * Hydra_Software_Devel/32 7/12/10 2:31p nissen |
|---|
| 237 | * SW7405-3671: Rewrote to support sw fifo. |
|---|
| 238 | * |
|---|
| 239 | * Hydra_Software_Devel/31 6/30/10 9:27p nissen |
|---|
| 240 | * SW7405-3671: Updated color matrix and filter packets. |
|---|
| 241 | * |
|---|
| 242 | * Hydra_Software_Devel/30 6/30/10 7:50p nissen |
|---|
| 243 | * SW7405-3671: Added support for blending and pixel format enums. |
|---|
| 244 | * |
|---|
| 245 | * Hydra_Software_Devel/29 6/24/10 2:14p nissen |
|---|
| 246 | * SW7405-3671: Added source feeder destripe packet function. |
|---|
| 247 | * |
|---|
| 248 | * Hydra_Software_Devel/28 6/23/10 3:49p nissen |
|---|
| 249 | * SW7405-3671: Fixed problem with setting blit ctrl registers. |
|---|
| 250 | * |
|---|
| 251 | * Hydra_Software_Devel/27 6/23/10 12:33p nissen |
|---|
| 252 | * SW7405-3671: Fixed build error. |
|---|
| 253 | * |
|---|
| 254 | * Hydra_Software_Devel/26 6/21/10 2:20p nissen |
|---|
| 255 | * SW7405-3671: Fixed packet settings. |
|---|
| 256 | * |
|---|
| 257 | * Hydra_Software_Devel/25 6/21/10 12:37p nissen |
|---|
| 258 | * SW7405-3671: Added context support. Switched to M2MC packets. |
|---|
| 259 | * |
|---|
| 260 | * Hydra_Software_Devel/24 5/5/10 12:06p nissen |
|---|
| 261 | * SW7405-3671: Fixed problem with scaler striping size. |
|---|
| 262 | * |
|---|
| 263 | * Hydra_Software_Devel/23 3/19/10 3:14p nissen |
|---|
| 264 | * SW7405-3671: Fixed alpha premultiply define. |
|---|
| 265 | * |
|---|
| 266 | * Hydra_Software_Devel/22 3/19/10 2:29p nissen |
|---|
| 267 | * SW7405-3671: Fixed alpha premultiply. |
|---|
| 268 | * |
|---|
| 269 | * Hydra_Software_Devel/21 3/11/10 1:18p nissen |
|---|
| 270 | * SW7405-3671: Added support for alpha premultiply. |
|---|
| 271 | * |
|---|
| 272 | * Hydra_Software_Devel/20 3/10/10 2:54p nissen |
|---|
| 273 | * SW7405-3671: Added offset buffer pointers to batch packet blits. |
|---|
| 274 | * |
|---|
| 275 | * Hydra_Software_Devel/19 2/16/10 4:23p nissen |
|---|
| 276 | * SW7405-3671: Fixed warnings. |
|---|
| 277 | * |
|---|
| 278 | * Hydra_Software_Devel/18 2/11/10 5:51p nissen |
|---|
| 279 | * SW7405-3671: Fixed setting palette format. |
|---|
| 280 | * |
|---|
| 281 | * Hydra_Software_Devel/17 2/11/10 5:29p nissen |
|---|
| 282 | * SW7405-3671: Added support for cached packet memory. |
|---|
| 283 | * |
|---|
| 284 | * Hydra_Software_Devel/16 2/10/10 2:12p nissen |
|---|
| 285 | * SW7405-3671: Fixed palette to palette blits. |
|---|
| 286 | * |
|---|
| 287 | * Hydra_Software_Devel/15 2/9/10 4:39p nissen |
|---|
| 288 | * SW7405-3671: Updated batch blits. |
|---|
| 289 | * |
|---|
| 290 | * Hydra_Software_Devel/14 2/8/10 9:02p nissen |
|---|
| 291 | * SW7405-3671: Fixed problem with writing scale packet. |
|---|
| 292 | * |
|---|
| 293 | * Hydra_Software_Devel/13 2/8/10 5:56p nissen |
|---|
| 294 | * SW7405-3671: Updated batching to submit as many blits as possible. |
|---|
| 295 | * |
|---|
| 296 | * Hydra_Software_Devel/12 2/5/10 8:16p nissen |
|---|
| 297 | * SW7405-3671: Fixed palette to palette blits. |
|---|
| 298 | * |
|---|
| 299 | * Hydra_Software_Devel/11 2/5/10 12:12p nissen |
|---|
| 300 | * SW7405-3671: Fixed problem with init packet. |
|---|
| 301 | * |
|---|
| 302 | * Hydra_Software_Devel/10 2/5/10 10:54a nissen |
|---|
| 303 | * SW7405-3671: Moved packet function. |
|---|
| 304 | * |
|---|
| 305 | * Hydra_Software_Devel/9 2/3/10 1:57p nissen |
|---|
| 306 | * SW7405-3671: Added batch packets. |
|---|
| 307 | * |
|---|
| 308 | * Hydra_Software_Devel/8 1/29/10 7:15p nissen |
|---|
| 309 | * SW7405-3671: Added support for using packets in any order. |
|---|
| 310 | * |
|---|
| 311 | * Hydra_Software_Devel/7 1/19/10 4:49p nissen |
|---|
| 312 | * SW7405-3671: Added support for different M2MC cores. |
|---|
| 313 | * |
|---|
| 314 | * Hydra_Software_Devel/6 1/19/10 12:27p nissen |
|---|
| 315 | * SW7405-3671: Added support for sync'ing and 420 destriping. |
|---|
| 316 | * |
|---|
| 317 | * Hydra_Software_Devel/5 1/8/10 2:22p nissen |
|---|
| 318 | * SW7405-3671: Removed buffer size parameters when opening packet module. |
|---|
| 319 | * |
|---|
| 320 | * Hydra_Software_Devel/4 1/7/10 5:21p nissen |
|---|
| 321 | * SW7405-3671: Fixed functions that write SourceFeeder and FillBlit |
|---|
| 322 | * packets. Added debug printing. |
|---|
| 323 | * |
|---|
| 324 | * Hydra_Software_Devel/3 12/31/09 10:14p nissen |
|---|
| 325 | * SW7405-3671: Added palette support and software striping while scaling |
|---|
| 326 | * support. |
|---|
| 327 | * |
|---|
| 328 | * Hydra_Software_Devel/2 12/24/09 5:45p nissen |
|---|
| 329 | * SW7405-3671: Fixed build error. |
|---|
| 330 | * |
|---|
| 331 | * Hydra_Software_Devel/1 12/24/09 1:04a nissen |
|---|
| 332 | * SW7405-3671: Packet blits |
|---|
| 333 | * |
|---|
| 334 | ***************************************************************************/ |
|---|
| 335 | |
|---|
| 336 | #include "bstd.h" |
|---|
| 337 | #include "bstd_defs.h" |
|---|
| 338 | #include "berr.h" |
|---|
| 339 | #include "bkni.h" |
|---|
| 340 | #include "bint.h" |
|---|
| 341 | #include "bchp.h" |
|---|
| 342 | #include "bmem.h" |
|---|
| 343 | #include "bsur.h" |
|---|
| 344 | #include "bint.h" |
|---|
| 345 | #include "breg_mem.h" |
|---|
| 346 | #include "bgrc_errors.h" |
|---|
| 347 | |
|---|
| 348 | #if (BCHP_CHIP==7405) |
|---|
| 349 | #include "bchp_int_id_memc16_gfx_l2.h" |
|---|
| 350 | #else |
|---|
| 351 | #include "bchp_hif_cpu_intr1.h" |
|---|
| 352 | #endif |
|---|
| 353 | |
|---|
| 354 | #if ((BCHP_CHIP==7400) && (BCHP_VER >= BCHP_VER_B0)) |
|---|
| 355 | #include "bchp_memc16_gfx_l2.h" |
|---|
| 356 | #include "bchp_memc16_gfx_grb.h" |
|---|
| 357 | #elif (BCHP_CHIP==7405) |
|---|
| 358 | #include "bchp_memc16_gfx_l2.h" |
|---|
| 359 | #include "bchp_memc_gfx_grb.h" |
|---|
| 360 | #elif (BCHP_CHIP==7325) || (BCHP_CHIP==7335) || (BCHP_CHIP==7336) |
|---|
| 361 | #include "bchp_graphics_l2.h" |
|---|
| 362 | #include "bchp_graphics_grb.h" |
|---|
| 363 | #elif (BCHP_CHIP==3548) || (BCHP_CHIP==3556) || (BCHP_CHIP==35230) || (BCHP_CHIP==35125) || (BCHP_CHIP==35233) |
|---|
| 364 | #include "bchp_int_id_gfx_l2.h" |
|---|
| 365 | #include "bchp_gfx_rgrb.h" |
|---|
| 366 | #elif (BCHP_CHIP==7420) || (BCHP_CHIP==7125) |
|---|
| 367 | #include "bchp_gfx_l2.h" |
|---|
| 368 | #include "bchp_gfx_gr.h" |
|---|
| 369 | #elif (BCHP_CHIP==7344) || (BCHP_CHIP==7346) || (BCHP_CHIP==7340) || (BCHP_CHIP==7342) || (BCHP_CHIP==7408) || \ |
|---|
| 370 | (BCHP_CHIP==7422) || (BCHP_CHIP==7425) || (BCHP_CHIP==7135) || (BCHP_CHIP==7231) || (BCHP_CHIP==7429) |
|---|
| 371 | #include "bchp_int_id_gfx_l2.h" |
|---|
| 372 | #include "bchp_gfx_gr.h" |
|---|
| 373 | #elif (BCHP_CHIP==7468) |
|---|
| 374 | #include "bchp_m2mc_wrap_l2.h" |
|---|
| 375 | #include "bchp_m2mc_wrap_gr_bridge.h" |
|---|
| 376 | #elif (BCHP_CHIP==7552) || (BCHP_CHIP==7550) || (BCHP_CHIP==7358) || (BCHP_CHIP==7360) |
|---|
| 377 | #include "bchp_m2mc_top_l2.h" |
|---|
| 378 | #include "bchp_m2mc_top_gr_bridge.h" |
|---|
| 379 | #elif ((BCHP_CHIP==7640) && (BCHP_VER >= BCHP_VER_B0)) |
|---|
| 380 | #include "bchp_wrap_m2mc_l2.h" |
|---|
| 381 | #include "bchp_wrap_m2mc_grb.h" |
|---|
| 382 | #include "bchp_gfx_grb.h" |
|---|
| 383 | #elif (BCHP_CHIP==7435) |
|---|
| 384 | #include "bchp_m2mc_l2.h" |
|---|
| 385 | #include "bchp_m2mc1_l2.h" |
|---|
| 386 | #include "bchp_m2mc_gr.h" |
|---|
| 387 | #include "bchp_m2mc1_gr.h" |
|---|
| 388 | #else |
|---|
| 389 | #include "bchp_int_id_gfx_l2.h" |
|---|
| 390 | #include "bchp_gfx_grb.h" |
|---|
| 391 | #endif |
|---|
| 392 | |
|---|
| 393 | #if (BCHP_CHIP==7435) |
|---|
| 394 | #include "bchp_m2mc.h" |
|---|
| 395 | #include "bchp_m2mc1.h" |
|---|
| 396 | #else |
|---|
| 397 | #include "bchp_m2mc.h" |
|---|
| 398 | #endif |
|---|
| 399 | |
|---|
| 400 | #if ((BCHP_CHIP==7400) && (BCHP_VER == BCHP_VER_A0)) || (((BCHP_CHIP==7640) && (BCHP_VER >= BCHP_VER_B0)) || BCHP_CHIP==7440) |
|---|
| 401 | #include "bchp_m2mc_1.h" |
|---|
| 402 | #elif ((BCHP_CHIP==7438) && (BCHP_VER >= BCHP_VER_A0)) |
|---|
| 403 | #include "bchp_m2mc_1.h" |
|---|
| 404 | #include "bchp_m2mc_1_grb.h" |
|---|
| 405 | #include "bchp_int_id_m2mc_1_l2.h" |
|---|
| 406 | #endif |
|---|
| 407 | |
|---|
| 408 | #include "bchp_common.h" |
|---|
| 409 | |
|---|
| 410 | #include "bgrc.h" |
|---|
| 411 | #include "bgrc_packet.h" |
|---|
| 412 | #include "bgrc_packet_priv.h" |
|---|
| 413 | #include "bgrc_private.h" |
|---|
| 414 | |
|---|
| 415 | BDBG_MODULE(BGRC); |
|---|
| 416 | BDBG_OBJECT_ID(BGRC); |
|---|
| 417 | BDBG_OBJECT_ID(BGRC_PacketContext); |
|---|
| 418 | |
|---|
| 419 | /***************************************************************************/ |
|---|
| 420 | #if ((BCHP_CHIP==7400) && (BCHP_VER >= BCHP_VER_B0)) |
|---|
| 421 | BINT_Id BGRC_PACKET_P_M2MC_INT_ID = BCHP_INT_ID_CREATE(BCHP_MEMC16_GFX_L2_CPU_STATUS, BCHP_MEMC16_GFX_L2_CPU_STATUS_M2MC_INTR_SHIFT); |
|---|
| 422 | #elif (BCHP_CHIP==7438) |
|---|
| 423 | BINT_Id BGRC_PACKET_P_M2MC_INT_ID = BCHP_INT_ID_GFX_L2_M2MC_INTR; |
|---|
| 424 | #elif ((BCHP_CHIP==7405) && (BCHP_VER >= BCHP_VER_A0)) |
|---|
| 425 | BINT_Id BGRC_PACKET_P_M2MC_INT_ID = BCHP_INT_ID_M2MC_0_INTR; |
|---|
| 426 | #elif (BCHP_CHIP==7325) || (BCHP_CHIP==7335) || (BCHP_CHIP==7336) |
|---|
| 427 | BINT_Id BGRC_PACKET_P_M2MC_INT_ID = BCHP_INT_ID_CREATE(BCHP_GRAPHICS_L2_CPU_STATUS, BCHP_GRAPHICS_L2_CPU_STATUS_M2MC_0_INTR_SHIFT); |
|---|
| 428 | #elif (BCHP_CHIP==7420) || (BCHP_CHIP==7125) |
|---|
| 429 | BINT_Id BGRC_PACKET_P_M2MC_INT_ID = BCHP_INT_ID_CREATE(BCHP_GFX_L2_CPU_STATUS, BCHP_GFX_L2_CPU_STATUS_M2MC_INTR_SHIFT); |
|---|
| 430 | #elif (BCHP_CHIP==7468) |
|---|
| 431 | BINT_Id BGRC_PACKET_P_M2MC_INT_ID = BCHP_INT_ID_CREATE(BCHP_M2MC_WRAP_L2_CPU_STATUS, BCHP_M2MC_WRAP_L2_CPU_STATUS_M2MC_INTR_SHIFT); |
|---|
| 432 | #elif (BCHP_CHIP==7552) || (BCHP_CHIP==7550) || (BCHP_CHIP==7358) || (BCHP_CHIP==7360) |
|---|
| 433 | BINT_Id BGRC_PACKET_P_M2MC_INT_ID = BCHP_INT_ID_CREATE(BCHP_M2MC_TOP_L2_CPU_STATUS, BCHP_M2MC_TOP_L2_CPU_STATUS_M2MC_INTR_SHIFT); |
|---|
| 434 | #elif ((BCHP_CHIP==7640) && (BCHP_VER >= BCHP_VER_B0)) |
|---|
| 435 | BINT_Id BGRC_PACKET_P_M2MC_INT_ID = BCHP_INT_ID_CREATE(BCHP_WRAP_M2MC_L2_CPU_STATUS, BCHP_WRAP_M2MC_L2_CPU_STATUS_M2MC_0_INTR_SHIFT); |
|---|
| 436 | BINT_Id BGRC_PACKET_P_M2MC_1_INT_ID = BCHP_INT_ID_CREATE(BCHP_WRAP_M2MC_L2_CPU_STATUS, BCHP_WRAP_M2MC_L2_CPU_STATUS_M2MC_1_INTR_SHIFT); |
|---|
| 437 | #elif (BCHP_CHIP==7435) |
|---|
| 438 | BINT_Id BGRC_PACKET_P_M2MC0_INT_ID = BCHP_INT_ID_CREATE(BCHP_M2MC_L2_CPU_STATUS, BCHP_M2MC_L2_CPU_STATUS_M2MC_INTR_SHIFT); |
|---|
| 439 | BINT_Id BGRC_PACKET_P_M2MC1_INT_ID = BCHP_INT_ID_CREATE(BCHP_M2MC1_L2_CPU_STATUS, BCHP_M2MC_L2_CPU_STATUS_M2MC_INTR_SHIFT); |
|---|
| 440 | #else |
|---|
| 441 | BINT_Id BGRC_PACKET_P_M2MC_INT_ID = BCHP_INT_ID_M2MC_INTR; |
|---|
| 442 | #endif |
|---|
| 443 | |
|---|
| 444 | /***************************************************************************/ |
|---|
| 445 | #define BGRC_PACKET_MEMORY_MAX 131072 |
|---|
| 446 | #define BGRC_OPERATION_MAX 2048 |
|---|
| 447 | #define BGRC_WAIT_TIMEOUT 10 |
|---|
| 448 | |
|---|
| 449 | /***************************************************************************/ |
|---|
| 450 | static const BGRC_Settings BGRC_P_DEFAULT_SETTINGS = |
|---|
| 451 | { |
|---|
| 452 | BGRC_PACKET_MEMORY_MAX, /* ulPacketMemoryMax */ |
|---|
| 453 | BGRC_OPERATION_MAX, /* ulOperationMax */ |
|---|
| 454 | 0, /* ulDeviceNum */ |
|---|
| 455 | BGRC_WAIT_TIMEOUT, /* ulWaitTimeout */ |
|---|
| 456 | true /* bPreAllocMemory */ |
|---|
| 457 | }; |
|---|
| 458 | |
|---|
| 459 | /***************************************************************************/ |
|---|
| 460 | BERR_Code BGRC_GetDefaultSettings( |
|---|
| 461 | BGRC_Settings *pDefSettings ) |
|---|
| 462 | { |
|---|
| 463 | BDBG_ENTER(BGRC_GetDefaultSettings); |
|---|
| 464 | |
|---|
| 465 | if( pDefSettings ) |
|---|
| 466 | *pDefSettings = BGRC_P_DEFAULT_SETTINGS; |
|---|
| 467 | |
|---|
| 468 | BDBG_LEAVE(BGRC_GetDefaultSettings); |
|---|
| 469 | return BERR_SUCCESS; |
|---|
| 470 | } |
|---|
| 471 | |
|---|
| 472 | /***************************************************************************/ |
|---|
| 473 | void BGRC_P_ResetDevice( |
|---|
| 474 | BGRC_Handle hGrc ) |
|---|
| 475 | { |
|---|
| 476 | #if ((BCHP_CHIP==7400) && (BCHP_VER >= BCHP_VER_B0)) |
|---|
| 477 | BREG_Write32( hGrc->hRegister, BCHP_MEMC16_GFX_GRB_SW_RESET_0, BCHP_FIELD_ENUM(MEMC16_GFX_GRB_SW_RESET_0, M2MC_SW_RESET, ASSERT) ); |
|---|
| 478 | BREG_Write32( hGrc->hRegister, BCHP_MEMC16_GFX_GRB_SW_RESET_0, BCHP_FIELD_ENUM(MEMC16_GFX_GRB_SW_RESET_0, M2MC_SW_RESET, DEASSERT) ); |
|---|
| 479 | #elif ((BCHP_CHIP==7405) && (BCHP_VER >= BCHP_VER_A0)) |
|---|
| 480 | BREG_Write32( hGrc->hRegister, BCHP_MEMC_GFX_GRB_SW_RESET_0, BCHP_FIELD_ENUM(MEMC_GFX_GRB_SW_RESET_0, M2MC_SW_RESET, ASSERT) ); |
|---|
| 481 | BREG_Write32( hGrc->hRegister, BCHP_MEMC_GFX_GRB_SW_RESET_0, BCHP_FIELD_ENUM(MEMC_GFX_GRB_SW_RESET_0, M2MC_SW_RESET, DEASSERT) ); |
|---|
| 482 | #elif (BCHP_CHIP==7325) || (BCHP_CHIP==7335) || (BCHP_CHIP==7336) |
|---|
| 483 | BREG_Write32( hGrc->hRegister, BCHP_GRAPHICS_GRB_SW_RESET_0, BCHP_FIELD_ENUM(GRAPHICS_GRB_SW_RESET_0, M2MC_SW_RESET, ASSERT) ); |
|---|
| 484 | BREG_Write32( hGrc->hRegister, BCHP_GRAPHICS_GRB_SW_RESET_0, BCHP_FIELD_ENUM(GRAPHICS_GRB_SW_RESET_0, M2MC_SW_RESET, DEASSERT) ); |
|---|
| 485 | #elif (BCHP_CHIP==3548) || (BCHP_CHIP==3556) || (BCHP_CHIP==35230) || (BCHP_CHIP==35125) || (BCHP_CHIP==35233) |
|---|
| 486 | BREG_Write32( hGrc->hRegister, BCHP_GFX_RGRB_SW_RESET_0, BCHP_FIELD_ENUM(GFX_RGRB_SW_RESET_0, M2MC_SW_RESET, ASSERT) ); |
|---|
| 487 | BREG_Write32( hGrc->hRegister, BCHP_GFX_RGRB_SW_RESET_0, BCHP_FIELD_ENUM(GFX_RGRB_SW_RESET_0, M2MC_SW_RESET, DEASSERT) ); |
|---|
| 488 | #elif (BCHP_CHIP==7420) || (BCHP_CHIP==7340) || (BCHP_CHIP==7342) || (BCHP_CHIP==7125) || (BCHP_CHIP==7408) |
|---|
| 489 | BREG_Write32( hGrc->hRegister, BCHP_GFX_GR_SW_RESET_0, BCHP_FIELD_ENUM(GFX_GR_SW_RESET_0, M2MC_SW_RESET, ASSERT) ); |
|---|
| 490 | BREG_Write32( hGrc->hRegister, BCHP_GFX_GR_SW_RESET_0, BCHP_FIELD_ENUM(GFX_GR_SW_RESET_0, M2MC_SW_RESET, DEASSERT) ); |
|---|
| 491 | #elif (BCHP_CHIP==7468) |
|---|
| 492 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_WRAP_GR_BRIDGE_SW_RESET_0, BCHP_FIELD_ENUM(M2MC_WRAP_GR_BRIDGE_SW_RESET_0, M2MC_SW_RESET, ASSERT) ); |
|---|
| 493 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_WRAP_GR_BRIDGE_SW_RESET_0, BCHP_FIELD_ENUM(M2MC_WRAP_GR_BRIDGE_SW_RESET_0, M2MC_SW_RESET, DEASSERT) ); |
|---|
| 494 | #elif (BCHP_CHIP==7344) || (BCHP_CHIP==7346) || (BCHP_CHIP==7422) || (BCHP_CHIP==7425) || (BCHP_CHIP==7135) || (BCHP_CHIP==7231) || (BCHP_CHIP==7429) |
|---|
| 495 | BREG_Write32( hGrc->hRegister, BCHP_GFX_GR_SW_INIT_0, BCHP_FIELD_ENUM(GFX_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, ASSERT) ); |
|---|
| 496 | BREG_Write32( hGrc->hRegister, BCHP_GFX_GR_SW_INIT_0, BCHP_FIELD_ENUM(GFX_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, DEASSERT) ); |
|---|
| 497 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_CLK_GATE_AND_SW_INIT_CONTROL, BCHP_M2MC_CLK_GATE_AND_SW_INIT_CONTROL_START_SW_INIT_MASK ); |
|---|
| 498 | while( BREG_Read32(hGrc->hRegister, BCHP_M2MC_BLIT_STATUS) == 0 ); |
|---|
| 499 | BREG_Write32( hGrc->hRegister, BCHP_GFX_GR_SW_INIT_0, BCHP_FIELD_ENUM(GFX_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, ASSERT) ); |
|---|
| 500 | BREG_Write32( hGrc->hRegister, BCHP_GFX_GR_SW_INIT_0, BCHP_FIELD_ENUM(GFX_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, DEASSERT) ); |
|---|
| 501 | |
|---|
| 502 | #elif (BCHP_CHIP==7552) |
|---|
| 503 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_TOP_GR_BRIDGE_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_TOP_GR_BRIDGE_SW_INIT_0, M2MC_CLK_108_SW_INIT, ASSERT) ); |
|---|
| 504 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_TOP_GR_BRIDGE_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_TOP_GR_BRIDGE_SW_INIT_0, M2MC_CLK_108_SW_INIT, DEASSERT) ); |
|---|
| 505 | #elif (BCHP_CHIP==7550) |
|---|
| 506 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_TOP_GR_BRIDGE_SW_RESET_0, BCHP_FIELD_ENUM(M2MC_TOP_GR_BRIDGE_SW_RESET_0, M2MC_SW_RESET, ASSERT) ); |
|---|
| 507 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_TOP_GR_BRIDGE_SW_RESET_0, BCHP_FIELD_ENUM(M2MC_TOP_GR_BRIDGE_SW_RESET_0, M2MC_SW_RESET, DEASSERT) ); |
|---|
| 508 | #elif (BCHP_CHIP==7358) || (BCHP_CHIP==7360) |
|---|
| 509 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_TOP_GR_BRIDGE_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_TOP_GR_BRIDGE_SW_INIT_0, M2MC_CLK_108_SW_INIT, ASSERT) ); |
|---|
| 510 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_TOP_GR_BRIDGE_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_TOP_GR_BRIDGE_SW_INIT_0, M2MC_CLK_108_SW_INIT, DEASSERT) ); |
|---|
| 511 | #elif (BCHP_CHIP==7640) |
|---|
| 512 | if( hGrc->ulDeviceNum ) |
|---|
| 513 | { |
|---|
| 514 | BREG_Write32( hGrc->hRegister, BCHP_WRAP_M2MC_GRB_SW_RESET_0, BCHP_FIELD_ENUM(WRAP_M2MC_GRB_SW_RESET_0, M2MC1_SW_RESET, ASSERT) ); |
|---|
| 515 | BREG_Write32( hGrc->hRegister, BCHP_WRAP_M2MC_GRB_SW_RESET_0, BCHP_FIELD_ENUM(WRAP_M2MC_GRB_SW_RESET_0, M2MC1_SW_RESET, DEASSERT) ); |
|---|
| 516 | } |
|---|
| 517 | else |
|---|
| 518 | { |
|---|
| 519 | BREG_Write32( hGrc->hRegister, BCHP_WRAP_M2MC_GRB_SW_RESET_0, BCHP_FIELD_ENUM(WRAP_M2MC_GRB_SW_RESET_0, M2MC0_SW_RESET, ASSERT) ); |
|---|
| 520 | BREG_Write32( hGrc->hRegister, BCHP_WRAP_M2MC_GRB_SW_RESET_0, BCHP_FIELD_ENUM(WRAP_M2MC_GRB_SW_RESET_0, M2MC0_SW_RESET, DEASSERT) ); |
|---|
| 521 | } |
|---|
| 522 | #elif (BCHP_CHIP==7435) |
|---|
| 523 | if( hGrc->ulDeviceNum ) |
|---|
| 524 | { |
|---|
| 525 | BREG_Write32( hGrc->hRegister, BCHP_M2MC1_GR_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, ASSERT) ); |
|---|
| 526 | BREG_Write32( hGrc->hRegister, BCHP_M2MC1_GR_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, DEASSERT) ); |
|---|
| 527 | BREG_Write32( hGrc->hRegister, BCHP_M2MC1_CLK_GATE_AND_SW_INIT_CONTROL, BCHP_M2MC_CLK_GATE_AND_SW_INIT_CONTROL_START_SW_INIT_MASK ); |
|---|
| 528 | while( BREG_Read32(hGrc->hRegister, BCHP_M2MC1_BLIT_STATUS) == 0 ); |
|---|
| 529 | BREG_Write32( hGrc->hRegister, BCHP_M2MC1_GR_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, ASSERT) ); |
|---|
| 530 | BREG_Write32( hGrc->hRegister, BCHP_M2MC1_GR_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, DEASSERT) ); |
|---|
| 531 | } |
|---|
| 532 | else |
|---|
| 533 | { |
|---|
| 534 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_GR_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, ASSERT) ); |
|---|
| 535 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_GR_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, DEASSERT) ); |
|---|
| 536 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_CLK_GATE_AND_SW_INIT_CONTROL, BCHP_M2MC_CLK_GATE_AND_SW_INIT_CONTROL_START_SW_INIT_MASK ); |
|---|
| 537 | while( BREG_Read32(hGrc->hRegister, BCHP_M2MC_BLIT_STATUS) == 0 ); |
|---|
| 538 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_GR_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, ASSERT) ); |
|---|
| 539 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_GR_SW_INIT_0, BCHP_FIELD_ENUM(M2MC_GR_SW_INIT_0, M2MC_CLK_108_SW_INIT, DEASSERT) ); |
|---|
| 540 | } |
|---|
| 541 | #else |
|---|
| 542 | BREG_Write32( hGrc->hRegister, BCHP_GFX_GRB_SW_RESET_0, BCHP_FIELD_ENUM(GFX_GRB_SW_RESET_0, M2MC_SW_RESET, ASSERT) ); |
|---|
| 543 | BREG_Write32( hGrc->hRegister, BCHP_GFX_GRB_SW_RESET_0, BCHP_FIELD_ENUM(GFX_GRB_SW_RESET_0, M2MC_SW_RESET, DEASSERT) ); |
|---|
| 544 | #endif |
|---|
| 545 | } |
|---|
| 546 | |
|---|
| 547 | /***************************************************************************/ |
|---|
| 548 | BERR_Code BGRC_Open( |
|---|
| 549 | BGRC_Handle *phGrc, |
|---|
| 550 | BCHP_Handle hChip, |
|---|
| 551 | BREG_Handle hRegister, |
|---|
| 552 | BMEM_Handle hMemory, |
|---|
| 553 | BINT_Handle hInterrupt, |
|---|
| 554 | const BGRC_Settings *pDefSettings ) |
|---|
| 555 | { |
|---|
| 556 | BERR_Code err = BERR_SUCCESS; |
|---|
| 557 | |
|---|
| 558 | BGRC_Handle hGrc = (BGRC_Handle) BKNI_Malloc( sizeof (BGRC_P_Handle) ); |
|---|
| 559 | if( hGrc == 0 ) |
|---|
| 560 | return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); |
|---|
| 561 | |
|---|
| 562 | BKNI_Memset( (void *) hGrc, 0, sizeof (BGRC_P_Handle) ); |
|---|
| 563 | BDBG_OBJECT_SET(hGrc, BGRC); |
|---|
| 564 | |
|---|
| 565 | hGrc->hChip = hChip; |
|---|
| 566 | hGrc->hRegister = hRegister; |
|---|
| 567 | hGrc->hMemory = hMemory; |
|---|
| 568 | hGrc->hInterrupt = hInterrupt; |
|---|
| 569 | hGrc->ulPacketMemoryMax = pDefSettings ? pDefSettings->ulPacketMemoryMax : BGRC_P_DEFAULT_SETTINGS.ulPacketMemoryMax; |
|---|
| 570 | hGrc->ulOperationMax = pDefSettings ? pDefSettings->ulOperationMax : BGRC_P_DEFAULT_SETTINGS.ulOperationMax; |
|---|
| 571 | hGrc->ulDeviceNum = pDefSettings ? pDefSettings->ulDeviceNum : BGRC_P_DEFAULT_SETTINGS.ulDeviceNum; |
|---|
| 572 | hGrc->ulWaitTimeout = pDefSettings ? pDefSettings->ulWaitTimeout : BGRC_P_DEFAULT_SETTINGS.ulWaitTimeout; |
|---|
| 573 | |
|---|
| 574 | /* allocate device fifo memory */ |
|---|
| 575 | hGrc->fifo_memory_addr = BMEM_AllocAligned( hGrc->hMemory, hGrc->ulPacketMemoryMax + BGRC_PACKET_P_BLIT_GROUP_SIZE_MAX, |
|---|
| 576 | BGRC_PACKET_P_MEMORY_ALIGN_BITS, 0 ); |
|---|
| 577 | if( hGrc->fifo_memory_addr == NULL ) |
|---|
| 578 | { |
|---|
| 579 | BGRC_Close( hGrc ); |
|---|
| 580 | return BERR_TRACE(BERR_OUT_OF_DEVICE_MEMORY); |
|---|
| 581 | } |
|---|
| 582 | |
|---|
| 583 | err = BMEM_ConvertAddressToOffset( hGrc->hMemory, hGrc->fifo_memory_addr, &hGrc->fifo_base_offset ); |
|---|
| 584 | if( err != BERR_SUCCESS ) |
|---|
| 585 | { |
|---|
| 586 | BGRC_Close( hGrc ); |
|---|
| 587 | return BERR_TRACE(BERR_OUT_OF_DEVICE_MEMORY); |
|---|
| 588 | } |
|---|
| 589 | |
|---|
| 590 | err = BMEM_ConvertAddressToCached( hGrc->hMemory, hGrc->fifo_memory_addr, (void *) &hGrc->fifo_cached_addr ); |
|---|
| 591 | if( err != BERR_SUCCESS ) |
|---|
| 592 | { |
|---|
| 593 | BGRC_Close( hGrc ); |
|---|
| 594 | return BERR_TRACE(BERR_OUT_OF_DEVICE_MEMORY); |
|---|
| 595 | } |
|---|
| 596 | |
|---|
| 597 | hGrc->fifo_total_size = hGrc->ulPacketMemoryMax; |
|---|
| 598 | hGrc->fifo_base_addr = hGrc->fifo_cached_addr; |
|---|
| 599 | /* hGrc->fifo_base_addr = hGrc->fifo_memory_addr;*/ |
|---|
| 600 | hGrc->curr_fifo_addr = hGrc->fifo_base_addr; |
|---|
| 601 | hGrc->curr_fifo_offset = hGrc->fifo_base_offset; |
|---|
| 602 | hGrc->start_flush_addr = hGrc->curr_fifo_addr; |
|---|
| 603 | |
|---|
| 604 | /* init context list */ |
|---|
| 605 | BLST_D_INIT(&hGrc->context_list); |
|---|
| 606 | |
|---|
| 607 | /* reset m2mc */ |
|---|
| 608 | BGRC_P_ResetDevice( hGrc ); |
|---|
| 609 | |
|---|
| 610 | *phGrc = hGrc; |
|---|
| 611 | return BERR_SUCCESS; |
|---|
| 612 | } |
|---|
| 613 | |
|---|
| 614 | /***************************************************************************/ |
|---|
| 615 | void BGRC_Close( |
|---|
| 616 | BGRC_Handle hGrc ) |
|---|
| 617 | { |
|---|
| 618 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 619 | BDBG_ASSERT(BLST_D_EMPTY(&hGrc->context_list)); |
|---|
| 620 | |
|---|
| 621 | /* destroy callbacks */ |
|---|
| 622 | if( hGrc->hCallback ) |
|---|
| 623 | { |
|---|
| 624 | BINT_DisableCallback( hGrc->hCallback ); |
|---|
| 625 | BINT_DestroyCallback( hGrc->hCallback ); |
|---|
| 626 | } |
|---|
| 627 | |
|---|
| 628 | /* free memory */ |
|---|
| 629 | if( hGrc->fifo_memory_addr ) |
|---|
| 630 | BMEM_Free( hGrc->hMemory, hGrc->fifo_memory_addr ); |
|---|
| 631 | |
|---|
| 632 | BDBG_OBJECT_DESTROY(hGrc, BGRC); |
|---|
| 633 | BKNI_Free( (void *) hGrc ); |
|---|
| 634 | } |
|---|
| 635 | |
|---|
| 636 | /***************************************************************************/ |
|---|
| 637 | BERR_Code BGRC_PACKET_P_SetCallback_BINT( |
|---|
| 638 | BGRC_Handle hGrc, |
|---|
| 639 | BGRC_PacketContext_Handle hContext, |
|---|
| 640 | BINT_CallbackHandle *phCallback, |
|---|
| 641 | bool create ) |
|---|
| 642 | { |
|---|
| 643 | if( create ) |
|---|
| 644 | { |
|---|
| 645 | if( *phCallback == 0 ) |
|---|
| 646 | { |
|---|
| 647 | #ifdef BCHP_M2MC1_REVISION |
|---|
| 648 | uint32_t int_id = hGrc->ulDeviceNum ? BGRC_PACKET_P_M2MC1_INT_ID : BGRC_PACKET_P_M2MC0_INT_ID; |
|---|
| 649 | #else |
|---|
| 650 | #ifdef BCHP_M2MC_1_REVISION |
|---|
| 651 | uint32_t int_id = hGrc->ulDeviceNum ? BGRC_PACKET_P_M2MC_1_INT_ID : BGRC_PACKET_P_M2MC_INT_ID; |
|---|
| 652 | #else |
|---|
| 653 | uint32_t int_id = BGRC_PACKET_P_M2MC_INT_ID; |
|---|
| 654 | #endif |
|---|
| 655 | #endif |
|---|
| 656 | |
|---|
| 657 | BERR_Code err = BINT_CreateCallback( phCallback, hGrc->hInterrupt, int_id, BGRC_PACKET_P_Isr, hGrc, (int) hContext ); |
|---|
| 658 | if( err != BERR_SUCCESS ) |
|---|
| 659 | return BERR_TRACE(err); |
|---|
| 660 | |
|---|
| 661 | BINT_ClearCallback( *phCallback ); |
|---|
| 662 | BINT_EnableCallback( *phCallback ); |
|---|
| 663 | } |
|---|
| 664 | } |
|---|
| 665 | else if( *phCallback ) |
|---|
| 666 | { |
|---|
| 667 | BINT_DisableCallback( *phCallback ); |
|---|
| 668 | BINT_DestroyCallback( *phCallback ); |
|---|
| 669 | *phCallback = 0; |
|---|
| 670 | } |
|---|
| 671 | |
|---|
| 672 | return BERR_SUCCESS; |
|---|
| 673 | } |
|---|
| 674 | |
|---|
| 675 | /***************************************************************************/ |
|---|
| 676 | BERR_Code BGRC_Packet_SetCallback( |
|---|
| 677 | BGRC_Handle hGrc, |
|---|
| 678 | BGRC_Callback callback_isr, |
|---|
| 679 | void *callback_data ) |
|---|
| 680 | { |
|---|
| 681 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 682 | |
|---|
| 683 | BGRC_PACKET_P_SetCallback_BINT( hGrc, 0, &hGrc->hCallback, (bool) callback_isr ); |
|---|
| 684 | |
|---|
| 685 | hGrc->callback_isr = callback_isr; |
|---|
| 686 | hGrc->callback_data = callback_data; |
|---|
| 687 | |
|---|
| 688 | return BERR_SUCCESS; |
|---|
| 689 | } |
|---|
| 690 | |
|---|
| 691 | /***************************************************************************/ |
|---|
| 692 | #define BGRC_PACKET_P_DEFAULT_PACKET_BUFFER_SIZE (1024*64) |
|---|
| 693 | |
|---|
| 694 | static BGRC_PacketContext_CreateSettings BGRC_PACKET_P_DefaultSettings = |
|---|
| 695 | { |
|---|
| 696 | 0, /* packet memory heap */ |
|---|
| 697 | BGRC_PACKET_P_DEFAULT_PACKET_BUFFER_SIZE, /* packet_buffer_size */ |
|---|
| 698 | 0, /* packet_buffer_store */ |
|---|
| 699 | NULL, /* private_data */ |
|---|
| 700 | { |
|---|
| 701 | 0, /* bounded memory offset */ |
|---|
| 702 | 0 /* bounded memory size */ |
|---|
| 703 | } |
|---|
| 704 | }; |
|---|
| 705 | |
|---|
| 706 | /***************************************************************************/ |
|---|
| 707 | BERR_Code BGRC_Packet_GetDefaultCreateContextSettings( |
|---|
| 708 | BGRC_Handle hGrc, |
|---|
| 709 | BGRC_PacketContext_CreateSettings *pSettings ) |
|---|
| 710 | { |
|---|
| 711 | BSTD_UNUSED(hGrc); |
|---|
| 712 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 713 | |
|---|
| 714 | if( pSettings ) |
|---|
| 715 | *pSettings = BGRC_PACKET_P_DefaultSettings; |
|---|
| 716 | |
|---|
| 717 | return BERR_SUCCESS; |
|---|
| 718 | } |
|---|
| 719 | |
|---|
| 720 | /***************************************************************************/ |
|---|
| 721 | BERR_Code BGRC_Packet_CreateContext( |
|---|
| 722 | BGRC_Handle hGrc, |
|---|
| 723 | BGRC_PacketContext_Handle *phContext, |
|---|
| 724 | BGRC_PacketContext_CreateSettings *pSettings ) |
|---|
| 725 | { |
|---|
| 726 | BMEM_Handle packet_heap = (pSettings && pSettings->packet_buffer_heap) ? pSettings->packet_buffer_heap : hGrc->hMemory; |
|---|
| 727 | BERR_Code err = BERR_SUCCESS; |
|---|
| 728 | |
|---|
| 729 | BGRC_PacketContext_Handle hContext = (BGRC_PacketContext_Handle) BKNI_Malloc( sizeof (BGRC_P_PacketContext) ); |
|---|
| 730 | if( hContext == 0 ) |
|---|
| 731 | return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); |
|---|
| 732 | |
|---|
| 733 | BKNI_Memset( (void *) hContext, 0, sizeof (BGRC_P_PacketContext) ); |
|---|
| 734 | BDBG_OBJECT_SET(hContext, BGRC_PacketContext); |
|---|
| 735 | |
|---|
| 736 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 737 | BDBG_ASSERT(phContext); |
|---|
| 738 | |
|---|
| 739 | /* add context to list */ |
|---|
| 740 | BLST_D_INSERT_HEAD(&hGrc->context_list, hContext, context_link); |
|---|
| 741 | |
|---|
| 742 | /* create advance event */ |
|---|
| 743 | err = BKNI_CreateEvent( &hContext->advance_event ); |
|---|
| 744 | if( err != BERR_SUCCESS ) |
|---|
| 745 | { |
|---|
| 746 | BGRC_Packet_DestroyContext( hGrc, hContext ); |
|---|
| 747 | return BERR_TRACE(err); |
|---|
| 748 | } |
|---|
| 749 | BKNI_ResetEvent( hContext->advance_event ); |
|---|
| 750 | |
|---|
| 751 | /* create sync event */ |
|---|
| 752 | err = BKNI_CreateEvent( &hContext->sync_event ); |
|---|
| 753 | if( err != BERR_SUCCESS ) |
|---|
| 754 | { |
|---|
| 755 | BGRC_Packet_DestroyContext( hGrc, hContext ); |
|---|
| 756 | return BERR_TRACE(err); |
|---|
| 757 | } |
|---|
| 758 | BKNI_ResetEvent( hContext->sync_event ); |
|---|
| 759 | |
|---|
| 760 | BGRC_Packet_SetContextCallbacks( hGrc, hContext, NULL, NULL, NULL, NULL ); |
|---|
| 761 | |
|---|
| 762 | /* allocate packet buffer */ |
|---|
| 763 | hContext->buffer_total_size = pSettings ? pSettings->packet_buffer_size : BGRC_PACKET_P_DefaultSettings.packet_buffer_size; |
|---|
| 764 | hContext->buffer_alloc_addr = BMEM_AllocAligned( packet_heap, hContext->buffer_total_size + BGRC_PACKET_P_EXTRA_PACKET_SIZE, 2, 0 ); |
|---|
| 765 | if( hContext->buffer_alloc_addr == 0 ) |
|---|
| 766 | { |
|---|
| 767 | err = BERR_OUT_OF_SYSTEM_MEMORY; |
|---|
| 768 | BGRC_Packet_DestroyContext( hGrc, hContext ); |
|---|
| 769 | return BERR_TRACE(err); |
|---|
| 770 | } |
|---|
| 771 | |
|---|
| 772 | err = BMEM_ConvertAddressToCached( packet_heap, hContext->buffer_alloc_addr, (void *) &hContext->buffer_base_addr ); |
|---|
| 773 | if( err != BERR_SUCCESS ) |
|---|
| 774 | { |
|---|
| 775 | err = BERR_OUT_OF_SYSTEM_MEMORY; |
|---|
| 776 | BGRC_Packet_DestroyContext( hGrc, hContext ); |
|---|
| 777 | return BERR_TRACE(err); |
|---|
| 778 | } |
|---|
| 779 | |
|---|
| 780 | /* allocate sync blit output plane */ |
|---|
| 781 | hContext->sync_output_addr = BMEM_AllocAligned( hGrc->hMemory, 1024, BGRC_PACKET_P_MEMORY_ALIGN_BITS, 0 ); |
|---|
| 782 | if( hContext->sync_output_addr == NULL ) |
|---|
| 783 | { |
|---|
| 784 | err = BERR_OUT_OF_DEVICE_MEMORY; |
|---|
| 785 | BGRC_Packet_DestroyContext( hGrc, hContext ); |
|---|
| 786 | return BERR_TRACE(err); |
|---|
| 787 | } |
|---|
| 788 | hContext->sync_output_addr[0] = 0; |
|---|
| 789 | |
|---|
| 790 | err = BMEM_ConvertAddressToOffset( hGrc->hMemory, hContext->sync_output_addr, &hContext->sync_output_offset ); |
|---|
| 791 | if( err != BERR_SUCCESS ) |
|---|
| 792 | { |
|---|
| 793 | err = BERR_OUT_OF_DEVICE_MEMORY; |
|---|
| 794 | BGRC_Packet_DestroyContext( hGrc, hContext ); |
|---|
| 795 | return BERR_TRACE(err); |
|---|
| 796 | } |
|---|
| 797 | |
|---|
| 798 | /* reset state */ |
|---|
| 799 | BGRC_PACKET_P_ResetState( hContext ); |
|---|
| 800 | |
|---|
| 801 | /* disable 3-2 pulldown cadence detect */ |
|---|
| 802 | #if ((BCHP_CHIP==7038) && (BCHP_VER < BCHP_VER_C0)) || \ |
|---|
| 803 | ((BCHP_CHIP==3560) && (BCHP_VER >= BCHP_VER_B0)) || \ |
|---|
| 804 | ((BCHP_CHIP==3563) && (BCHP_VER >= BCHP_VER_A0)) |
|---|
| 805 | BREG_Write32( hGrc->hRegister, BCHP_M2MC_BLEND_PULLDOWN_COUNTER_ENABLE, BCHP_M2MC_BLEND_PULLDOWN_COUNTER_ENABLE_ENABLE_DISABLE ); |
|---|
| 806 | #endif |
|---|
| 807 | |
|---|
| 808 | /* store settings */ |
|---|
| 809 | if( pSettings ) |
|---|
| 810 | hContext->create_settings = *pSettings; |
|---|
| 811 | |
|---|
| 812 | *phContext = hContext; |
|---|
| 813 | return BERR_SUCCESS; |
|---|
| 814 | } |
|---|
| 815 | |
|---|
| 816 | /***************************************************************************/ |
|---|
| 817 | BERR_Code BGRC_Packet_DestroyContext( |
|---|
| 818 | BGRC_Handle hGrc, |
|---|
| 819 | BGRC_PacketContext_Handle hContext ) |
|---|
| 820 | { |
|---|
| 821 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 822 | BDBG_OBJECT_ASSERT(hContext, BGRC_PacketContext); |
|---|
| 823 | |
|---|
| 824 | if( hGrc->callback_isr == NULL ) |
|---|
| 825 | { |
|---|
| 826 | /* flush packet processing */ |
|---|
| 827 | if( hContext->advance_callback_isr == NULL ) |
|---|
| 828 | BGRC_Packet_AdvancePackets( hGrc, hContext ); |
|---|
| 829 | |
|---|
| 830 | /* flush blits */ |
|---|
| 831 | if( hContext->sync_callback_isr == NULL ) |
|---|
| 832 | BGRC_Packet_SyncPackets( hGrc, hContext ); |
|---|
| 833 | } |
|---|
| 834 | |
|---|
| 835 | /* remove context from list */ |
|---|
| 836 | BLST_D_REMOVE(&hGrc->context_list, hContext, context_link); |
|---|
| 837 | |
|---|
| 838 | /* destroy events */ |
|---|
| 839 | if( hContext->sync_event ) |
|---|
| 840 | BKNI_DestroyEvent( hContext->sync_event ); |
|---|
| 841 | |
|---|
| 842 | if( hContext->advance_event ) |
|---|
| 843 | BKNI_DestroyEvent( hContext->advance_event ); |
|---|
| 844 | |
|---|
| 845 | /* destroy callbacks */ |
|---|
| 846 | if( hContext->hCallback ) |
|---|
| 847 | { |
|---|
| 848 | BINT_DisableCallback( hContext->hCallback ); |
|---|
| 849 | BINT_DestroyCallback( hContext->hCallback ); |
|---|
| 850 | } |
|---|
| 851 | |
|---|
| 852 | /* free memory */ |
|---|
| 853 | if( hContext->sync_output_addr ) |
|---|
| 854 | BMEM_Free( hGrc->hMemory, hContext->sync_output_addr ); |
|---|
| 855 | |
|---|
| 856 | if( hContext->buffer_alloc_addr ) |
|---|
| 857 | { |
|---|
| 858 | BMEM_Handle packet_heap = hContext->create_settings.packet_buffer_heap ? hContext->create_settings.packet_buffer_heap : hGrc->hMemory; |
|---|
| 859 | BMEM_Free( packet_heap, hContext->buffer_alloc_addr ); |
|---|
| 860 | } |
|---|
| 861 | |
|---|
| 862 | if( hContext ) |
|---|
| 863 | { |
|---|
| 864 | BDBG_OBJECT_DESTROY(hContext, BGRC_PacketContext); |
|---|
| 865 | BKNI_Free( hContext ); |
|---|
| 866 | } |
|---|
| 867 | |
|---|
| 868 | return BERR_SUCCESS; |
|---|
| 869 | } |
|---|
| 870 | |
|---|
| 871 | /***************************************************************************/ |
|---|
| 872 | BERR_Code BGRC_Packet_SetContextCallbacks( |
|---|
| 873 | BGRC_Handle hGrc, |
|---|
| 874 | BGRC_PacketContext_Handle hContext, |
|---|
| 875 | BGRC_Callback advance_callback_isr, |
|---|
| 876 | void *advance_callback_data, |
|---|
| 877 | BGRC_Callback sync_callback_isr, |
|---|
| 878 | void *sync_callback_data ) |
|---|
| 879 | { |
|---|
| 880 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 881 | BDBG_OBJECT_ASSERT(hContext, BGRC_PacketContext); |
|---|
| 882 | |
|---|
| 883 | BGRC_PACKET_P_SetCallback_BINT( hGrc, hContext, &hContext->hCallback, hGrc->hCallback == 0 ); |
|---|
| 884 | |
|---|
| 885 | hContext->advance_callback_isr = advance_callback_isr; |
|---|
| 886 | hContext->advance_callback_data = advance_callback_data; |
|---|
| 887 | hContext->sync_callback_isr = sync_callback_isr; |
|---|
| 888 | hContext->sync_callback_data = sync_callback_data; |
|---|
| 889 | |
|---|
| 890 | return BERR_SUCCESS; |
|---|
| 891 | } |
|---|
| 892 | |
|---|
| 893 | /***************************************************************************/ |
|---|
| 894 | int BGRC_PACKET_P_GetPacketMemory( |
|---|
| 895 | BGRC_Handle hGrc, |
|---|
| 896 | BGRC_PacketContext_Handle hContext, |
|---|
| 897 | size_t size_in ) |
|---|
| 898 | { |
|---|
| 899 | int buffer_available = 0; |
|---|
| 900 | |
|---|
| 901 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 902 | BDBG_OBJECT_ASSERT(hContext, BGRC_PacketContext); |
|---|
| 903 | |
|---|
| 904 | /* get available buffer size */ |
|---|
| 905 | if( hContext->buffer_submit_size && (hContext->buffer_submit_offset >= hContext->buffer_alloc_offset) ) |
|---|
| 906 | { |
|---|
| 907 | buffer_available = hContext->buffer_submit_offset - hContext->buffer_alloc_offset; |
|---|
| 908 | } |
|---|
| 909 | else |
|---|
| 910 | { |
|---|
| 911 | buffer_available = hContext->buffer_total_size - hContext->buffer_alloc_offset; |
|---|
| 912 | if( buffer_available < (int) (size_in + BGRC_PACKET_P_EXTRA_PACKET_SIZE) ) |
|---|
| 913 | { |
|---|
| 914 | /* wrap buffer if less than needed */ |
|---|
| 915 | if( (hContext->buffer_submit_size == 0) || (hContext->buffer_submit_offset >= BGRC_PACKET_P_EXTRA_PACKET_SIZE) ) |
|---|
| 916 | { |
|---|
| 917 | /* submit end-of-buffer packet */ |
|---|
| 918 | BM2MC_PACKET_Header *header = (BM2MC_PACKET_Header *) ((uint8_t *) hContext->buffer_base_addr + hContext->buffer_alloc_offset); |
|---|
| 919 | header->type = 0; |
|---|
| 920 | header->size = sizeof (BM2MC_PACKET_Header) / sizeof (uint32_t); |
|---|
| 921 | header->execute = 0; |
|---|
| 922 | header->sync = 0; |
|---|
| 923 | hContext->last_size_out = sizeof (BM2MC_PACKET_Header); |
|---|
| 924 | BGRC_Packet_SubmitPackets( hGrc, hContext, sizeof (BM2MC_PACKET_Header) ); |
|---|
| 925 | |
|---|
| 926 | /* reset alloc offset and get available size */ |
|---|
| 927 | hContext->buffer_alloc_offset = 0; |
|---|
| 928 | buffer_available = hContext->buffer_submit_size ? hContext->buffer_submit_offset : hContext->buffer_total_size; |
|---|
| 929 | } |
|---|
| 930 | } |
|---|
| 931 | } |
|---|
| 932 | |
|---|
| 933 | return buffer_available; |
|---|
| 934 | } |
|---|
| 935 | /***************************************************************************/ |
|---|
| 936 | BERR_Code BGRC_Packet_GetPacketMemory( |
|---|
| 937 | BGRC_Handle hGrc, |
|---|
| 938 | BGRC_PacketContext_Handle hContext, |
|---|
| 939 | void **buffer, |
|---|
| 940 | size_t *size_out, |
|---|
| 941 | size_t size_in ) |
|---|
| 942 | { |
|---|
| 943 | int buffer_available = 0; |
|---|
| 944 | int alloc_size = 0; |
|---|
| 945 | |
|---|
| 946 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 947 | BDBG_OBJECT_ASSERT(hContext, BGRC_PacketContext); |
|---|
| 948 | BDBG_ASSERT(buffer); |
|---|
| 949 | BDBG_ASSERT(size_in >= sizeof (BM2MC_PACKET_Header)); |
|---|
| 950 | |
|---|
| 951 | /* get available packet buffer memory */ |
|---|
| 952 | buffer_available = BGRC_PACKET_P_GetPacketMemory( hGrc, hContext, size_in ); |
|---|
| 953 | |
|---|
| 954 | /* check if buffer is full */ |
|---|
| 955 | if( buffer_available < (int) (size_in + BGRC_PACKET_P_EXTRA_PACKET_SIZE) ) |
|---|
| 956 | { |
|---|
| 957 | /* check if packets need submitting */ |
|---|
| 958 | if( hContext->buffer_submit_size ) |
|---|
| 959 | { |
|---|
| 960 | BGRC_PACKET_P_SubmitPackets( hGrc, hContext ); |
|---|
| 961 | buffer_available = BGRC_PACKET_P_GetPacketMemory( hGrc, hContext, size_in ); |
|---|
| 962 | } |
|---|
| 963 | } |
|---|
| 964 | |
|---|
| 965 | /* check if buffer is full */ |
|---|
| 966 | if( buffer_available < (int) (size_in + BGRC_PACKET_P_EXTRA_PACKET_SIZE) ) |
|---|
| 967 | { |
|---|
| 968 | *buffer = NULL; |
|---|
| 969 | } |
|---|
| 970 | else |
|---|
| 971 | { |
|---|
| 972 | *buffer = (uint8_t *) hContext->buffer_base_addr + hContext->buffer_alloc_offset; |
|---|
| 973 | alloc_size = buffer_available - BGRC_PACKET_P_EXTRA_PACKET_SIZE; |
|---|
| 974 | } |
|---|
| 975 | |
|---|
| 976 | hContext->last_size_out = alloc_size; |
|---|
| 977 | |
|---|
| 978 | if( size_out ) |
|---|
| 979 | *size_out = alloc_size; |
|---|
| 980 | |
|---|
| 981 | return BERR_SUCCESS; |
|---|
| 982 | } |
|---|
| 983 | |
|---|
| 984 | /***************************************************************************/ |
|---|
| 985 | BERR_Code BGRC_Packet_SubmitPackets( |
|---|
| 986 | BGRC_Handle hGrc, |
|---|
| 987 | BGRC_PacketContext_Handle hContext, |
|---|
| 988 | size_t size ) |
|---|
| 989 | { |
|---|
| 990 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 991 | BDBG_OBJECT_ASSERT(hContext, BGRC_PacketContext); |
|---|
| 992 | |
|---|
| 993 | if( size > (size_t) hContext->last_size_out ) |
|---|
| 994 | { |
|---|
| 995 | BDBG_ERR(("BGRC_Packet_SubmitPackets %d bytes exceeds last BGRC_Packet_GetPacketMemory %d bytes. System memory is now corrupted.", size, hContext->last_size_out)); |
|---|
| 996 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 997 | } |
|---|
| 998 | hContext->last_size_out = 0; |
|---|
| 999 | hContext->packets_submitted = true; |
|---|
| 1000 | |
|---|
| 1001 | if( size >= sizeof (BM2MC_PACKET_Header) ) |
|---|
| 1002 | { |
|---|
| 1003 | /* increase size of submitted buffer */ |
|---|
| 1004 | hContext->buffer_submit_size += size; |
|---|
| 1005 | hContext->buffer_alloc_offset += size; |
|---|
| 1006 | |
|---|
| 1007 | /* submit packets */ |
|---|
| 1008 | if( hContext->buffer_submit_size > hContext->create_settings.packet_buffer_store ) |
|---|
| 1009 | BGRC_PACKET_P_SubmitPackets( hGrc, hContext ); |
|---|
| 1010 | } |
|---|
| 1011 | |
|---|
| 1012 | /* return message indicating packet processing is incomplete */ |
|---|
| 1013 | if( hContext->buffer_submit_size ) |
|---|
| 1014 | return BGRC_PACKET_MSG_PACKETS_INCOMPLETE; |
|---|
| 1015 | |
|---|
| 1016 | return BERR_SUCCESS; |
|---|
| 1017 | } |
|---|
| 1018 | |
|---|
| 1019 | /***************************************************************************/ |
|---|
| 1020 | #define BGRC_PACKET_P_RESTART_DEVICE( hGrc, hContext, int_type ) \ |
|---|
| 1021 | { \ |
|---|
| 1022 | BERR_Code err; \ |
|---|
| 1023 | void *packet_addr; \ |
|---|
| 1024 | uint32_t packet_offset = BGRC_P_ReadReg32( hGrc->hRegister, LIST_CURR_PKT_ADDR ); \ |
|---|
| 1025 | \ |
|---|
| 1026 | BGRC_P_ResetDevice( hGrc ); \ |
|---|
| 1027 | hGrc->int_type##_hung = false; \ |
|---|
| 1028 | hContext->int_type##_wait = false; \ |
|---|
| 1029 | hContext->int_type##_interrupt = false; \ |
|---|
| 1030 | \ |
|---|
| 1031 | err = BMEM_ConvertOffsetToAddress( hGrc->hMemory, packet_offset, &packet_addr ); \ |
|---|
| 1032 | if( err == BERR_SUCCESS ) \ |
|---|
| 1033 | { \ |
|---|
| 1034 | BGRC_P_WriteReg32( hGrc->hRegister, LIST_FIRST_PKT_ADDR, *((uint32_t *) packet_addr) ); \ |
|---|
| 1035 | BGRC_P_WriteReg32( hGrc->hRegister, LIST_CTRL, \ |
|---|
| 1036 | BCHP_FIELD_ENUM( M2MC_LIST_CTRL, WAKE, Ack ) | \ |
|---|
| 1037 | BCHP_FIELD_ENUM( M2MC_LIST_CTRL, RUN, Run ) | \ |
|---|
| 1038 | BCHP_FIELD_ENUM( M2MC_LIST_CTRL, WAKE_MODE, ResumeFromFirst ) ); \ |
|---|
| 1039 | } \ |
|---|
| 1040 | } |
|---|
| 1041 | |
|---|
| 1042 | /***************************************************************************/ |
|---|
| 1043 | BERR_Code BGRC_Packet_AdvancePackets( |
|---|
| 1044 | BGRC_Handle hGrc, |
|---|
| 1045 | BGRC_PacketContext_Handle hContext ) |
|---|
| 1046 | { |
|---|
| 1047 | BERR_Code err = BERR_SUCCESS; |
|---|
| 1048 | BGRC_PacketContext_Handle hLastContext = 0; |
|---|
| 1049 | BGRC_PacketContext_Handle hCurrContext; |
|---|
| 1050 | uint32_t curr_addr = 0; |
|---|
| 1051 | uint32_t prev_addr = 0; |
|---|
| 1052 | |
|---|
| 1053 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 1054 | |
|---|
| 1055 | hCurrContext = hContext ? hContext : BLST_D_FIRST(&hGrc->context_list); |
|---|
| 1056 | |
|---|
| 1057 | /* reset device if it is hung */ |
|---|
| 1058 | if( hGrc->advance_hung ) |
|---|
| 1059 | { |
|---|
| 1060 | BGRC_PACKET_P_RESTART_DEVICE( hGrc, hCurrContext, advance ); |
|---|
| 1061 | } |
|---|
| 1062 | else if( hGrc->sync_hung ) |
|---|
| 1063 | { |
|---|
| 1064 | BGRC_PACKET_P_RESTART_DEVICE( hGrc, hCurrContext, sync ); |
|---|
| 1065 | } |
|---|
| 1066 | |
|---|
| 1067 | /* loop through contexts */ |
|---|
| 1068 | while( hCurrContext ) |
|---|
| 1069 | { |
|---|
| 1070 | /* check if packets left to process */ |
|---|
| 1071 | if( hCurrContext->buffer_submit_size ) |
|---|
| 1072 | { |
|---|
| 1073 | /* loop until packet processing complete if using event */ |
|---|
| 1074 | do |
|---|
| 1075 | { |
|---|
| 1076 | /* submit packets */ |
|---|
| 1077 | BGRC_PACKET_P_SubmitPackets( hGrc, hCurrContext ); |
|---|
| 1078 | |
|---|
| 1079 | /* wait for advance event */ |
|---|
| 1080 | if( hCurrContext->advance_wait ) |
|---|
| 1081 | { |
|---|
| 1082 | while( BKNI_WaitForEvent( hContext->advance_event, hGrc->ulWaitTimeout * 1000 ) == BERR_TIMEOUT ) |
|---|
| 1083 | { |
|---|
| 1084 | curr_addr = BGRC_P_ReadReg32( hGrc->hRegister, BLIT_OUTPUT_ADDRESS ); |
|---|
| 1085 | if( curr_addr == prev_addr ) |
|---|
| 1086 | { |
|---|
| 1087 | hGrc->advance_hung = true; |
|---|
| 1088 | BGRC_PACKET_P_PrintRegisters( hGrc ); |
|---|
| 1089 | return BERR_TRACE(BGRC_ERR_M2MC_DEVICE_IS_HUNG); |
|---|
| 1090 | } |
|---|
| 1091 | prev_addr = curr_addr; |
|---|
| 1092 | } |
|---|
| 1093 | hCurrContext->advance_wait = false; |
|---|
| 1094 | } |
|---|
| 1095 | } |
|---|
| 1096 | while( BGRC_PACKET_P_USING_EVENT(hCurrContext, advance) && hCurrContext->buffer_submit_size ); |
|---|
| 1097 | } |
|---|
| 1098 | |
|---|
| 1099 | /* save error if a context's packets still need processing */ |
|---|
| 1100 | if( hCurrContext->buffer_submit_size ) |
|---|
| 1101 | err = BGRC_PACKET_MSG_PACKETS_INCOMPLETE; |
|---|
| 1102 | |
|---|
| 1103 | /* get next context */ |
|---|
| 1104 | hLastContext = hCurrContext; |
|---|
| 1105 | hCurrContext = hContext ? 0 : BLST_D_NEXT(hCurrContext, context_link); |
|---|
| 1106 | } |
|---|
| 1107 | |
|---|
| 1108 | /* put last context at the head of the list to give it first access to free memory */ |
|---|
| 1109 | if( (hContext == 0) && hLastContext ) |
|---|
| 1110 | { |
|---|
| 1111 | BLST_D_REMOVE(&hGrc->context_list, hLastContext, context_link); |
|---|
| 1112 | BLST_D_INSERT_HEAD(&hGrc->context_list, hLastContext, context_link); |
|---|
| 1113 | } |
|---|
| 1114 | |
|---|
| 1115 | return err; |
|---|
| 1116 | } |
|---|
| 1117 | |
|---|
| 1118 | /***************************************************************************/ |
|---|
| 1119 | BERR_Code BGRC_Packet_SyncPackets( |
|---|
| 1120 | BGRC_Handle hGrc, |
|---|
| 1121 | BGRC_PacketContext_Handle hContext ) |
|---|
| 1122 | { |
|---|
| 1123 | uint32_t curr_addr = 0; |
|---|
| 1124 | uint32_t prev_addr = 0; |
|---|
| 1125 | bool context_idle = false; |
|---|
| 1126 | BERR_Code err = BERR_SUCCESS; |
|---|
| 1127 | |
|---|
| 1128 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 1129 | BDBG_OBJECT_ASSERT(hContext, BGRC_PacketContext); |
|---|
| 1130 | |
|---|
| 1131 | /* return message indicating context's blits are complete */ |
|---|
| 1132 | if( !hContext->packets_submitted ) |
|---|
| 1133 | { |
|---|
| 1134 | return BGRC_PACKET_MSG_BLITS_COMPLETE; |
|---|
| 1135 | } |
|---|
| 1136 | |
|---|
| 1137 | /* check if context is busy */ |
|---|
| 1138 | if( hContext->buffer_submit_size == 0 ) |
|---|
| 1139 | { |
|---|
| 1140 | BGRC_Packet_Status status; |
|---|
| 1141 | err = BGRC_Packet_GetStatus( hGrc, &status ); |
|---|
| 1142 | if( err == BERR_SUCCESS ) |
|---|
| 1143 | context_idle = !status.m2mc_busy; |
|---|
| 1144 | } |
|---|
| 1145 | |
|---|
| 1146 | /* return message indicating context's blits are complete */ |
|---|
| 1147 | if( context_idle ) |
|---|
| 1148 | return BGRC_PACKET_MSG_BLITS_COMPLETE; |
|---|
| 1149 | |
|---|
| 1150 | /* do sync blit */ |
|---|
| 1151 | err = BGRC_PACKET_P_SyncBlit( hGrc, hContext ); |
|---|
| 1152 | while( err != BERR_SUCCESS ) |
|---|
| 1153 | { |
|---|
| 1154 | BGRC_Packet_AdvancePackets( hGrc, hContext ); |
|---|
| 1155 | err = BGRC_PACKET_P_SyncBlit( hGrc, hContext ); |
|---|
| 1156 | } |
|---|
| 1157 | |
|---|
| 1158 | /* advance processing for any remaining packets */ |
|---|
| 1159 | if( hContext->buffer_submit_size ) |
|---|
| 1160 | err = BGRC_Packet_AdvancePackets( hGrc, hContext ); |
|---|
| 1161 | |
|---|
| 1162 | /* wait for sync event */ |
|---|
| 1163 | if( hContext->sync_wait ) |
|---|
| 1164 | { |
|---|
| 1165 | while( BKNI_WaitForEvent( hContext->sync_event, hGrc->ulWaitTimeout * 1000 ) == BERR_TIMEOUT ) |
|---|
| 1166 | { |
|---|
| 1167 | curr_addr = BGRC_P_ReadReg32( hGrc->hRegister, BLIT_OUTPUT_ADDRESS ); |
|---|
| 1168 | if( curr_addr == prev_addr ) |
|---|
| 1169 | { |
|---|
| 1170 | hGrc->sync_hung = true; |
|---|
| 1171 | BGRC_PACKET_P_PrintRegisters( hGrc ); |
|---|
| 1172 | return BERR_TRACE(BGRC_ERR_M2MC_DEVICE_IS_HUNG); |
|---|
| 1173 | } |
|---|
| 1174 | prev_addr = curr_addr; |
|---|
| 1175 | } |
|---|
| 1176 | hContext->sync_wait = false; |
|---|
| 1177 | } |
|---|
| 1178 | |
|---|
| 1179 | return err; |
|---|
| 1180 | } |
|---|
| 1181 | |
|---|
| 1182 | /***************************************************************************/ |
|---|
| 1183 | BERR_Code BGRC_Packet_GetContextStatus( |
|---|
| 1184 | BGRC_Handle hGrc, |
|---|
| 1185 | BGRC_Packet_ContextStatus *status_array, |
|---|
| 1186 | size_t *size_out, |
|---|
| 1187 | size_t size_in ) |
|---|
| 1188 | { |
|---|
| 1189 | BGRC_PacketContext_Handle hContext; |
|---|
| 1190 | size_t context_index = 0; |
|---|
| 1191 | |
|---|
| 1192 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 1193 | BDBG_ASSERT(status_array); |
|---|
| 1194 | BDBG_ASSERT(size_out); |
|---|
| 1195 | BDBG_ASSERT(size_in); |
|---|
| 1196 | |
|---|
| 1197 | /* get first context */ |
|---|
| 1198 | hContext = BLST_D_FIRST(&hGrc->context_list); |
|---|
| 1199 | while( hContext ) |
|---|
| 1200 | { |
|---|
| 1201 | /* check if context sync'ed */ |
|---|
| 1202 | bool context_sync = hContext->sync_interrupt && hContext->sync_output_addr[0]; |
|---|
| 1203 | if( context_sync ) |
|---|
| 1204 | hContext->sync_interrupt = false; |
|---|
| 1205 | |
|---|
| 1206 | /* check if context sync'ed or packets still need processing */ |
|---|
| 1207 | if( context_sync || hContext->advance_interrupt || hContext->buffer_submit_size ) |
|---|
| 1208 | { |
|---|
| 1209 | uint32_t buffer_available = 0; |
|---|
| 1210 | |
|---|
| 1211 | if( hContext->advance_interrupt || hContext->buffer_submit_size ) |
|---|
| 1212 | { |
|---|
| 1213 | /* calculate available packer buffer size */ |
|---|
| 1214 | uint32_t end_offset = (hContext->buffer_submit_size && (hContext->buffer_submit_offset >= hContext->buffer_alloc_offset)) ? |
|---|
| 1215 | hContext->buffer_submit_offset : hContext->buffer_total_size; |
|---|
| 1216 | uint32_t extra_size = (end_offset == hContext->buffer_total_size) ? hContext->buffer_submit_offset : 0; |
|---|
| 1217 | |
|---|
| 1218 | buffer_available = end_offset - hContext->buffer_alloc_offset + extra_size; |
|---|
| 1219 | hContext->advance_interrupt = false; |
|---|
| 1220 | } |
|---|
| 1221 | |
|---|
| 1222 | /* fill status entry */ |
|---|
| 1223 | status_array[context_index].hContext = hContext; |
|---|
| 1224 | status_array[context_index].private_data = hContext->create_settings.private_data; |
|---|
| 1225 | status_array[context_index].sync = context_sync; |
|---|
| 1226 | status_array[context_index].packet_buffer_available = buffer_available; |
|---|
| 1227 | context_index++; |
|---|
| 1228 | } |
|---|
| 1229 | |
|---|
| 1230 | /* exit if size of array is not large enough */ |
|---|
| 1231 | if( context_index == size_in ) |
|---|
| 1232 | break; |
|---|
| 1233 | |
|---|
| 1234 | /* get next context */ |
|---|
| 1235 | hContext = BLST_D_NEXT(hContext, context_link); |
|---|
| 1236 | } |
|---|
| 1237 | |
|---|
| 1238 | *size_out = context_index; |
|---|
| 1239 | return BERR_SUCCESS; |
|---|
| 1240 | } |
|---|
| 1241 | |
|---|
| 1242 | /***************************************************************************/ |
|---|
| 1243 | BERR_Code BGRC_Packet_GetStatus( |
|---|
| 1244 | BGRC_Handle hGrc, |
|---|
| 1245 | BGRC_Packet_Status *status ) |
|---|
| 1246 | { |
|---|
| 1247 | BDBG_OBJECT_ASSERT(hGrc, BGRC); |
|---|
| 1248 | BDBG_ASSERT(status); |
|---|
| 1249 | |
|---|
| 1250 | status->m2mc_busy = true; |
|---|
| 1251 | if( !hGrc->advance_interrupt ) |
|---|
| 1252 | { |
|---|
| 1253 | uint32_t blit_status = BGRC_P_ReadReg32( hGrc->hRegister, BLIT_STATUS ); |
|---|
| 1254 | uint32_t list_status = BGRC_P_ReadReg32( hGrc->hRegister, LIST_STATUS ); |
|---|
| 1255 | uint32_t packet_addr = BGRC_P_ReadReg32( hGrc->hRegister, LIST_FIRST_PKT_ADDR ); |
|---|
| 1256 | |
|---|
| 1257 | if( (blit_status == BGRC_M2MC(BLIT_STATUS_STATUS_IDLE)) && ((packet_addr == 0) || |
|---|
| 1258 | (list_status == BGRC_M2MC(LIST_STATUS_FINISHED_MASK))) ) |
|---|
| 1259 | { |
|---|
| 1260 | status->m2mc_busy = false; |
|---|
| 1261 | } |
|---|
| 1262 | } |
|---|
| 1263 | |
|---|
| 1264 | return BERR_SUCCESS; |
|---|
| 1265 | } |
|---|
| 1266 | |
|---|
| 1267 | /***************************************************************************/ |
|---|
| 1268 | BERR_Code BGRC_Packet_ConvertPixelFormat( |
|---|
| 1269 | BM2MC_PACKET_PixelFormat *pformat, |
|---|
| 1270 | BPXL_Format pxl_format ) |
|---|
| 1271 | { |
|---|
| 1272 | BDBG_ASSERT(pformat); |
|---|
| 1273 | |
|---|
| 1274 | *pformat = BGRC_PACKET_P_ConvertPixelFormat( pxl_format ); |
|---|
| 1275 | return BERR_SUCCESS; |
|---|
| 1276 | } |
|---|
| 1277 | |
|---|
| 1278 | /***************************************************************************/ |
|---|
| 1279 | BERR_Code BGRC_Packet_ConvertFilter( |
|---|
| 1280 | BM2MC_PACKET_FilterCoeffs *coeffs, |
|---|
| 1281 | BGRC_FilterCoeffs filter, |
|---|
| 1282 | size_t src_size, |
|---|
| 1283 | size_t out_size ) |
|---|
| 1284 | { |
|---|
| 1285 | BDBG_ASSERT(coeffs); |
|---|
| 1286 | |
|---|
| 1287 | BGRC_PACKET_P_ConvertFilterCoeffs( coeffs, filter, src_size, out_size ); |
|---|
| 1288 | return BERR_SUCCESS; |
|---|
| 1289 | } |
|---|
| 1290 | |
|---|
| 1291 | /***************************************************************************/ |
|---|
| 1292 | BERR_Code BGRC_Packet_ConvertColorMatrix( |
|---|
| 1293 | BM2MC_PACKET_ColorMatrix *matrix_out, |
|---|
| 1294 | const int32_t *matrix_in, |
|---|
| 1295 | size_t shift ) |
|---|
| 1296 | { |
|---|
| 1297 | BDBG_ASSERT(matrix_out); |
|---|
| 1298 | BDBG_ASSERT(matrix_in); |
|---|
| 1299 | |
|---|
| 1300 | BGRC_PACKET_P_ConvertColorMatrix( matrix_out, matrix_in, shift ); |
|---|
| 1301 | return BERR_SUCCESS; |
|---|
| 1302 | } |
|---|
| 1303 | |
|---|
| 1304 | /*****************************************************************************/ |
|---|
| 1305 | BERR_Code BGRC_Packet_SetSourceSurfacePacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1306 | BSUR_Surface_Handle srcSurface0, BSUR_Surface_Handle srcSurface1, uint32_t color ) |
|---|
| 1307 | { |
|---|
| 1308 | BM2MC_PACKET_PixelFormat m2mc_format0 = BM2MC_PACKET_PixelFormat_eUnknown; |
|---|
| 1309 | BM2MC_PACKET_PixelFormat m2mc_format1 = BM2MC_PACKET_PixelFormat_eUnknown; |
|---|
| 1310 | uint32_t offset0, pitch0; |
|---|
| 1311 | uint32_t offset1, pitch1; |
|---|
| 1312 | BPXL_Format format = 0; |
|---|
| 1313 | void *pMemory; |
|---|
| 1314 | |
|---|
| 1315 | if( srcSurface0 ) |
|---|
| 1316 | { |
|---|
| 1317 | BSUR_Surface_GetAddress( srcSurface0, &pMemory, &pitch0 ); |
|---|
| 1318 | BSUR_Surface_GetOffset( srcSurface0, &offset0 ); |
|---|
| 1319 | BSUR_Surface_GetFormat( srcSurface0, &format ); |
|---|
| 1320 | BGRC_Packet_ConvertPixelFormat( &m2mc_format0, format ); |
|---|
| 1321 | } |
|---|
| 1322 | if( srcSurface1 ) |
|---|
| 1323 | { |
|---|
| 1324 | BSUR_Surface_GetAddress( srcSurface1, &pMemory, &pitch1 ); |
|---|
| 1325 | BSUR_Surface_GetOffset( srcSurface1, &offset1 ); |
|---|
| 1326 | BSUR_Surface_GetFormat( srcSurface1, &format ); |
|---|
| 1327 | BGRC_Packet_ConvertPixelFormat( &m2mc_format1, format ); |
|---|
| 1328 | } |
|---|
| 1329 | |
|---|
| 1330 | if( srcSurface0 && srcSurface1 ) |
|---|
| 1331 | { |
|---|
| 1332 | BM2MC_PACKET_PacketSourceFeeders *pPacket = (BM2MC_PACKET_PacketSourceFeeders *) (*ppPacket); |
|---|
| 1333 | BM2MC_PACKET_INIT( pPacket, SourceFeeders, false ); |
|---|
| 1334 | pPacket->plane0.address = offset0; |
|---|
| 1335 | pPacket->plane0.pitch = pitch0; |
|---|
| 1336 | pPacket->plane0.format = m2mc_format0; |
|---|
| 1337 | pPacket->plane0.width = 0; |
|---|
| 1338 | pPacket->plane0.height = 0; |
|---|
| 1339 | pPacket->plane1.address = offset1; |
|---|
| 1340 | pPacket->plane1.pitch = pitch1; |
|---|
| 1341 | pPacket->plane1.format = m2mc_format1; |
|---|
| 1342 | pPacket->plane1.width = 0; |
|---|
| 1343 | pPacket->plane1.height = 0; |
|---|
| 1344 | pPacket->color = color; |
|---|
| 1345 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1346 | *ppPacket = (void *) pPacket; |
|---|
| 1347 | } |
|---|
| 1348 | else if( srcSurface0 ) |
|---|
| 1349 | { |
|---|
| 1350 | BM2MC_PACKET_PacketSourceFeeder *pPacket = (BM2MC_PACKET_PacketSourceFeeder *) (*ppPacket); |
|---|
| 1351 | BM2MC_PACKET_INIT( pPacket, SourceFeeder, false ); |
|---|
| 1352 | pPacket->plane.address = offset0; |
|---|
| 1353 | pPacket->plane.pitch = pitch0; |
|---|
| 1354 | pPacket->plane.format = m2mc_format0; |
|---|
| 1355 | pPacket->plane.width = 0; |
|---|
| 1356 | pPacket->plane.height = 0; |
|---|
| 1357 | pPacket->color = color; |
|---|
| 1358 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1359 | *ppPacket = (void *) pPacket; |
|---|
| 1360 | } |
|---|
| 1361 | else |
|---|
| 1362 | { |
|---|
| 1363 | BM2MC_PACKET_PacketSourceColor *pPacket = (BM2MC_PACKET_PacketSourceColor *) (*ppPacket); |
|---|
| 1364 | BM2MC_PACKET_INIT( pPacket, SourceColor, false ); |
|---|
| 1365 | pPacket->color = color; |
|---|
| 1366 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1367 | *ppPacket = (void *) pPacket; |
|---|
| 1368 | } |
|---|
| 1369 | BSTD_UNUSED(hGrc); |
|---|
| 1370 | return BERR_SUCCESS; |
|---|
| 1371 | } |
|---|
| 1372 | |
|---|
| 1373 | /*****************************************************************************/ |
|---|
| 1374 | BERR_Code BGRC_Packet_SetSourcePlanePacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1375 | const BM2MC_PACKET_Plane *pSrcPlane0, const BM2MC_PACKET_Plane *pSrcPlane1, uint32_t color ) |
|---|
| 1376 | { |
|---|
| 1377 | if( pSrcPlane0 && pSrcPlane1 ) |
|---|
| 1378 | { |
|---|
| 1379 | BM2MC_PACKET_PacketSourceFeeders *pPacket = (BM2MC_PACKET_PacketSourceFeeders *) (*ppPacket); |
|---|
| 1380 | BM2MC_PACKET_INIT( pPacket, SourceFeeders, false ); |
|---|
| 1381 | pPacket->plane0 = *pSrcPlane0; |
|---|
| 1382 | pPacket->plane1 = *pSrcPlane1; |
|---|
| 1383 | pPacket->color = color; |
|---|
| 1384 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1385 | *ppPacket = (void *) pPacket; |
|---|
| 1386 | } |
|---|
| 1387 | else if( pSrcPlane0 ) |
|---|
| 1388 | { |
|---|
| 1389 | BM2MC_PACKET_PacketSourceFeeder *pPacket = (BM2MC_PACKET_PacketSourceFeeder *) (*ppPacket); |
|---|
| 1390 | BM2MC_PACKET_INIT( pPacket, SourceFeeder, false ); |
|---|
| 1391 | pPacket->plane = *pSrcPlane0; |
|---|
| 1392 | pPacket->color = color; |
|---|
| 1393 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1394 | *ppPacket = (void *) pPacket; |
|---|
| 1395 | } |
|---|
| 1396 | else |
|---|
| 1397 | { |
|---|
| 1398 | BM2MC_PACKET_PacketSourceColor *pPacket = (BM2MC_PACKET_PacketSourceColor *) (*ppPacket); |
|---|
| 1399 | BM2MC_PACKET_INIT( pPacket, SourceColor, false ); |
|---|
| 1400 | pPacket->color = color; |
|---|
| 1401 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1402 | *ppPacket = (void *) pPacket; |
|---|
| 1403 | } |
|---|
| 1404 | BSTD_UNUSED(hGrc); |
|---|
| 1405 | return BERR_SUCCESS; |
|---|
| 1406 | } |
|---|
| 1407 | |
|---|
| 1408 | /*****************************************************************************/ |
|---|
| 1409 | BERR_Code BGRC_Packet_SetSourceDestripePacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1410 | uint32_t lumaOffset, uint32_t chromaOffset, uint32_t pitch, uint32_t color ) |
|---|
| 1411 | { |
|---|
| 1412 | BM2MC_PACKET_PixelFormat m2mc_format0; |
|---|
| 1413 | BM2MC_PACKET_PixelFormat m2mc_format1; |
|---|
| 1414 | BM2MC_PACKET_PacketSourceFeeders *pPacket = (BM2MC_PACKET_PacketSourceFeeders *) (*ppPacket); |
|---|
| 1415 | |
|---|
| 1416 | BGRC_Packet_ConvertPixelFormat( &m2mc_format0, BPXL_eY8 ); |
|---|
| 1417 | BGRC_Packet_ConvertPixelFormat( &m2mc_format1, BPXL_eCb8_Cr8 ); |
|---|
| 1418 | |
|---|
| 1419 | BM2MC_PACKET_INIT( pPacket, SourceFeeders, false ); |
|---|
| 1420 | pPacket->plane0.address = lumaOffset; |
|---|
| 1421 | pPacket->plane0.pitch = pitch; |
|---|
| 1422 | pPacket->plane0.format = m2mc_format0; |
|---|
| 1423 | pPacket->plane0.width = 0; |
|---|
| 1424 | pPacket->plane0.height = 0; |
|---|
| 1425 | pPacket->plane1.address = chromaOffset; |
|---|
| 1426 | pPacket->plane1.pitch = pitch; |
|---|
| 1427 | pPacket->plane1.format = m2mc_format1; |
|---|
| 1428 | pPacket->plane1.width = 0; |
|---|
| 1429 | pPacket->plane1.height = 0; |
|---|
| 1430 | pPacket->color = color; |
|---|
| 1431 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1432 | *ppPacket = (void *) pPacket; |
|---|
| 1433 | |
|---|
| 1434 | BSTD_UNUSED(hGrc); |
|---|
| 1435 | return BERR_SUCCESS; |
|---|
| 1436 | } |
|---|
| 1437 | |
|---|
| 1438 | /*****************************************************************************/ |
|---|
| 1439 | BERR_Code BGRC_Packet_SetSourceControl( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1440 | bool zero_pad, bool chroma_filter, bool linear_destripe ) |
|---|
| 1441 | { |
|---|
| 1442 | BM2MC_PACKET_PacketSourceControl *pPacket = (BM2MC_PACKET_PacketSourceControl *) (*ppPacket); |
|---|
| 1443 | BM2MC_PACKET_INIT( pPacket, SourceControl, false ); |
|---|
| 1444 | pPacket->zero_pad = zero_pad; |
|---|
| 1445 | pPacket->chroma_filter = chroma_filter; |
|---|
| 1446 | pPacket->linear_destripe = linear_destripe; |
|---|
| 1447 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1448 | |
|---|
| 1449 | *ppPacket = (void *) pPacket; |
|---|
| 1450 | BSTD_UNUSED(hGrc); |
|---|
| 1451 | return BERR_SUCCESS; |
|---|
| 1452 | } |
|---|
| 1453 | |
|---|
| 1454 | /*****************************************************************************/ |
|---|
| 1455 | BERR_Code BGRC_Packet_SetDestinationSurfacePacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1456 | BSUR_Surface_Handle surface, uint32_t color ) |
|---|
| 1457 | { |
|---|
| 1458 | if( surface ) |
|---|
| 1459 | { |
|---|
| 1460 | BM2MC_PACKET_PixelFormat m2mc_format; |
|---|
| 1461 | BPXL_Format format; |
|---|
| 1462 | uint32_t offset; |
|---|
| 1463 | uint32_t pitch; |
|---|
| 1464 | void *pMemory; |
|---|
| 1465 | |
|---|
| 1466 | BM2MC_PACKET_PacketDestinationFeeder *pPacket = (BM2MC_PACKET_PacketDestinationFeeder *) (*ppPacket); |
|---|
| 1467 | BSUR_Surface_GetFormat( surface, &format ); |
|---|
| 1468 | BSUR_Surface_GetAddress( surface, &pMemory, &pitch ); |
|---|
| 1469 | BSUR_Surface_GetOffset( surface, &offset ); |
|---|
| 1470 | BGRC_Packet_ConvertPixelFormat( &m2mc_format, format ); |
|---|
| 1471 | |
|---|
| 1472 | BM2MC_PACKET_INIT( pPacket, DestinationFeeder, false ); |
|---|
| 1473 | pPacket->plane.address = offset; |
|---|
| 1474 | pPacket->plane.pitch = pitch; |
|---|
| 1475 | pPacket->plane.format = m2mc_format; |
|---|
| 1476 | pPacket->plane.width = 0; |
|---|
| 1477 | pPacket->plane.height = 0; |
|---|
| 1478 | pPacket->color = color; |
|---|
| 1479 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1480 | *ppPacket = (void *) pPacket; |
|---|
| 1481 | } |
|---|
| 1482 | else |
|---|
| 1483 | { |
|---|
| 1484 | BM2MC_PACKET_PacketDestinationNone *pPacket = (BM2MC_PACKET_PacketDestinationNone *) (*ppPacket); |
|---|
| 1485 | BM2MC_PACKET_INIT( pPacket, DestinationNone, false ); |
|---|
| 1486 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1487 | *ppPacket = (void *) pPacket; |
|---|
| 1488 | } |
|---|
| 1489 | BSTD_UNUSED(hGrc); |
|---|
| 1490 | return BERR_SUCCESS; |
|---|
| 1491 | } |
|---|
| 1492 | |
|---|
| 1493 | /*****************************************************************************/ |
|---|
| 1494 | BERR_Code BGRC_Packet_SetDestinationPlanePacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1495 | const BM2MC_PACKET_Plane *pPlane, uint32_t color ) |
|---|
| 1496 | { |
|---|
| 1497 | if( pPlane ) |
|---|
| 1498 | { |
|---|
| 1499 | BM2MC_PACKET_PacketDestinationFeeder *pPacket = (BM2MC_PACKET_PacketDestinationFeeder *) (*ppPacket); |
|---|
| 1500 | BM2MC_PACKET_INIT( pPacket, DestinationFeeder, false ); |
|---|
| 1501 | pPacket->plane = *pPlane; |
|---|
| 1502 | pPacket->color = color; |
|---|
| 1503 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1504 | *ppPacket = (void *) pPacket; |
|---|
| 1505 | } |
|---|
| 1506 | else |
|---|
| 1507 | { |
|---|
| 1508 | BM2MC_PACKET_PacketDestinationNone *pPacket = (BM2MC_PACKET_PacketDestinationNone *) (*ppPacket); |
|---|
| 1509 | BM2MC_PACKET_INIT( pPacket, DestinationNone, false ); |
|---|
| 1510 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1511 | *ppPacket = (void *) pPacket; |
|---|
| 1512 | } |
|---|
| 1513 | BSTD_UNUSED(hGrc); |
|---|
| 1514 | return BERR_SUCCESS; |
|---|
| 1515 | } |
|---|
| 1516 | |
|---|
| 1517 | /*****************************************************************************/ |
|---|
| 1518 | BERR_Code BGRC_Packet_SetDestinationControl( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1519 | bool zero_pad, bool chroma_filter ) |
|---|
| 1520 | { |
|---|
| 1521 | BM2MC_PACKET_PacketDestinationControl *pPacket = (BM2MC_PACKET_PacketDestinationControl *) (*ppPacket); |
|---|
| 1522 | BM2MC_PACKET_INIT( pPacket, DestinationControl, false ); |
|---|
| 1523 | pPacket->zero_pad = zero_pad; |
|---|
| 1524 | pPacket->chroma_filter = chroma_filter; |
|---|
| 1525 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1526 | |
|---|
| 1527 | *ppPacket = (void *) pPacket; |
|---|
| 1528 | BSTD_UNUSED(hGrc); |
|---|
| 1529 | return BERR_SUCCESS; |
|---|
| 1530 | } |
|---|
| 1531 | |
|---|
| 1532 | /*****************************************************************************/ |
|---|
| 1533 | BERR_Code BGRC_Packet_SetOutputSurfacePacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1534 | BSUR_Surface_Handle surface ) |
|---|
| 1535 | { |
|---|
| 1536 | BM2MC_PACKET_PixelFormat m2mc_format; |
|---|
| 1537 | BPXL_Format format; |
|---|
| 1538 | uint32_t offset; |
|---|
| 1539 | uint32_t pitch; |
|---|
| 1540 | void *pMemory; |
|---|
| 1541 | |
|---|
| 1542 | BM2MC_PACKET_PacketOutputFeeder *pPacket = (BM2MC_PACKET_PacketOutputFeeder *) (*ppPacket); |
|---|
| 1543 | BSUR_Surface_GetFormat( surface, &format ); |
|---|
| 1544 | BSUR_Surface_GetAddress( surface, &pMemory, &pitch ); |
|---|
| 1545 | BSUR_Surface_GetOffset( surface, &offset ); |
|---|
| 1546 | BGRC_Packet_ConvertPixelFormat( &m2mc_format, format ); |
|---|
| 1547 | |
|---|
| 1548 | BM2MC_PACKET_INIT( pPacket, OutputFeeder, false ); |
|---|
| 1549 | pPacket->plane.address = offset; |
|---|
| 1550 | pPacket->plane.pitch = pitch; |
|---|
| 1551 | pPacket->plane.format = m2mc_format; |
|---|
| 1552 | pPacket->plane.width = 0; |
|---|
| 1553 | pPacket->plane.height = 0; |
|---|
| 1554 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1555 | |
|---|
| 1556 | *ppPacket = (void *) pPacket; |
|---|
| 1557 | BSTD_UNUSED(hGrc); |
|---|
| 1558 | return BERR_SUCCESS; |
|---|
| 1559 | } |
|---|
| 1560 | |
|---|
| 1561 | /*****************************************************************************/ |
|---|
| 1562 | BERR_Code BGRC_Packet_SetOutputPlanePacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1563 | const BM2MC_PACKET_Plane *pPlane ) |
|---|
| 1564 | { |
|---|
| 1565 | BM2MC_PACKET_PacketOutputFeeder *pPacket = (BM2MC_PACKET_PacketOutputFeeder *) (*ppPacket); |
|---|
| 1566 | BM2MC_PACKET_INIT( pPacket, OutputFeeder, false ); |
|---|
| 1567 | pPacket->plane = *pPlane; |
|---|
| 1568 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1569 | |
|---|
| 1570 | *ppPacket = (void *) pPacket; |
|---|
| 1571 | BSTD_UNUSED(hGrc); |
|---|
| 1572 | return BERR_SUCCESS; |
|---|
| 1573 | } |
|---|
| 1574 | |
|---|
| 1575 | /*****************************************************************************/ |
|---|
| 1576 | BERR_Code BGRC_Packet_SetOutputOffsetPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1577 | BM2MC_PACKET_PixelFormat format, uint32_t offset, uint16_t pitch ) |
|---|
| 1578 | { |
|---|
| 1579 | BM2MC_PACKET_PacketOutputFeeder *pPacket = (BM2MC_PACKET_PacketOutputFeeder *) (*ppPacket); |
|---|
| 1580 | BM2MC_PACKET_INIT( pPacket, OutputFeeder, false ); |
|---|
| 1581 | pPacket->plane.address = offset; |
|---|
| 1582 | pPacket->plane.pitch = pitch; |
|---|
| 1583 | pPacket->plane.format = format; |
|---|
| 1584 | pPacket->plane.width = 0; |
|---|
| 1585 | pPacket->plane.height = 0; |
|---|
| 1586 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1587 | |
|---|
| 1588 | *ppPacket = (void *) pPacket; |
|---|
| 1589 | BSTD_UNUSED(hGrc); |
|---|
| 1590 | return BERR_SUCCESS; |
|---|
| 1591 | } |
|---|
| 1592 | |
|---|
| 1593 | /*****************************************************************************/ |
|---|
| 1594 | BERR_Code BGRC_Packet_SetOutputControl( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1595 | bool dither, bool chroma_filter ) |
|---|
| 1596 | { |
|---|
| 1597 | BM2MC_PACKET_PacketOutputControl *pPacket = (BM2MC_PACKET_PacketOutputControl *) (*ppPacket); |
|---|
| 1598 | BM2MC_PACKET_INIT( pPacket, OutputControl, false ); |
|---|
| 1599 | pPacket->dither = dither; |
|---|
| 1600 | pPacket->chroma_filter = chroma_filter; |
|---|
| 1601 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1602 | |
|---|
| 1603 | *ppPacket = (void *) pPacket; |
|---|
| 1604 | BSTD_UNUSED(hGrc); |
|---|
| 1605 | return BERR_SUCCESS; |
|---|
| 1606 | } |
|---|
| 1607 | |
|---|
| 1608 | /*****************************************************************************/ |
|---|
| 1609 | BERR_Code BGRC_Packet_SetBlendPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1610 | BM2MC_PACKET_Blend *pColor, BM2MC_PACKET_Blend *pAlpha, uint32_t color ) |
|---|
| 1611 | { |
|---|
| 1612 | BM2MC_PACKET_PacketBlend *pPacket = (BM2MC_PACKET_PacketBlend *) (*ppPacket); |
|---|
| 1613 | BM2MC_PACKET_INIT( pPacket, Blend, false ); |
|---|
| 1614 | pPacket->color_blend = *pColor; |
|---|
| 1615 | pPacket->alpha_blend = *pAlpha; |
|---|
| 1616 | pPacket->color = color; |
|---|
| 1617 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1618 | |
|---|
| 1619 | *ppPacket = (void *) pPacket; |
|---|
| 1620 | BSTD_UNUSED(hGrc); |
|---|
| 1621 | return BERR_SUCCESS; |
|---|
| 1622 | } |
|---|
| 1623 | |
|---|
| 1624 | /*****************************************************************************/ |
|---|
| 1625 | BERR_Code BGRC_Packet_SetRopPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1626 | uint8_t rop, uint32_t* pattern, uint32_t color0, uint32_t color1 ) |
|---|
| 1627 | { |
|---|
| 1628 | BM2MC_PACKET_PacketRop *pPacket = (BM2MC_PACKET_PacketRop *) (*ppPacket); |
|---|
| 1629 | BM2MC_PACKET_INIT( pPacket, Rop, false ); |
|---|
| 1630 | pPacket->rop = rop; |
|---|
| 1631 | pPacket->pattern0 = pattern ? pattern[0] : 0; |
|---|
| 1632 | pPacket->pattern1 = pattern ? pattern[1] : 0; |
|---|
| 1633 | pPacket->color0 = color0; |
|---|
| 1634 | pPacket->color1 = color1; |
|---|
| 1635 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1636 | |
|---|
| 1637 | *ppPacket = (void *) pPacket; |
|---|
| 1638 | BSTD_UNUSED(hGrc); |
|---|
| 1639 | return BERR_SUCCESS; |
|---|
| 1640 | } |
|---|
| 1641 | |
|---|
| 1642 | /*****************************************************************************/ |
|---|
| 1643 | BERR_Code BGRC_Packet_SetSourceColorkeyPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1644 | bool enable, uint32_t high, uint32_t low, uint32_t mask, uint32_t replacement, uint32_t replacement_mask ) |
|---|
| 1645 | { |
|---|
| 1646 | BM2MC_PACKET_PacketSourceColorkeyEnable *pPacket = (BM2MC_PACKET_PacketSourceColorkeyEnable *) (*ppPacket); |
|---|
| 1647 | BM2MC_PACKET_INIT( pPacket, SourceColorkeyEnable, false ); |
|---|
| 1648 | pPacket->enable = enable ? 1 : 0; |
|---|
| 1649 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1650 | *ppPacket = (void *) pPacket; |
|---|
| 1651 | |
|---|
| 1652 | if( enable ) |
|---|
| 1653 | { |
|---|
| 1654 | BM2MC_PACKET_PacketSourceColorkey *pPacket = (BM2MC_PACKET_PacketSourceColorkey *) (*ppPacket); |
|---|
| 1655 | BM2MC_PACKET_INIT( pPacket, SourceColorkey, false ); |
|---|
| 1656 | pPacket->high = high; |
|---|
| 1657 | pPacket->low = low; |
|---|
| 1658 | pPacket->mask = mask; |
|---|
| 1659 | pPacket->replacement = replacement; |
|---|
| 1660 | pPacket->replacement_mask = replacement_mask; |
|---|
| 1661 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1662 | *ppPacket = (void *) pPacket; |
|---|
| 1663 | } |
|---|
| 1664 | BSTD_UNUSED(hGrc); |
|---|
| 1665 | return BERR_SUCCESS; |
|---|
| 1666 | } |
|---|
| 1667 | |
|---|
| 1668 | /*****************************************************************************/ |
|---|
| 1669 | BERR_Code BGRC_Packet_SetDestinationColorkeyPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1670 | bool enable, uint32_t high, uint32_t low, uint32_t mask, uint32_t replacement, uint32_t replacement_mask ) |
|---|
| 1671 | { |
|---|
| 1672 | BM2MC_PACKET_PacketDestinationColorkeyEnable *pPacket = (BM2MC_PACKET_PacketDestinationColorkeyEnable *) (*ppPacket); |
|---|
| 1673 | BM2MC_PACKET_INIT( pPacket, DestinationColorkeyEnable, false ); |
|---|
| 1674 | pPacket->enable = enable ? 1 : 0; |
|---|
| 1675 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1676 | *ppPacket = (void *) pPacket; |
|---|
| 1677 | |
|---|
| 1678 | if( enable ) |
|---|
| 1679 | { |
|---|
| 1680 | BM2MC_PACKET_PacketDestinationColorkey *pPacket = (BM2MC_PACKET_PacketDestinationColorkey *) (*ppPacket); |
|---|
| 1681 | BM2MC_PACKET_INIT( pPacket, DestinationColorkey, false ); |
|---|
| 1682 | pPacket->high = high; |
|---|
| 1683 | pPacket->low = low; |
|---|
| 1684 | pPacket->mask = mask; |
|---|
| 1685 | pPacket->replacement = replacement; |
|---|
| 1686 | pPacket->replacement_mask = replacement_mask; |
|---|
| 1687 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1688 | *ppPacket = (void *) pPacket; |
|---|
| 1689 | } |
|---|
| 1690 | BSTD_UNUSED(hGrc); |
|---|
| 1691 | return BERR_SUCCESS; |
|---|
| 1692 | } |
|---|
| 1693 | |
|---|
| 1694 | /*****************************************************************************/ |
|---|
| 1695 | BERR_Code BGRC_Packet_SetFilterPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1696 | BGRC_FilterCoeffs hor, BGRC_FilterCoeffs ver, BM2MC_PACKET_Rectangle *pSrcRect, BM2MC_PACKET_Rectangle *pOutRect ) |
|---|
| 1697 | { |
|---|
| 1698 | bool enable = (hor != BGRC_FilterCoeffs_ePointSample) || (ver != BGRC_FilterCoeffs_ePointSample); |
|---|
| 1699 | |
|---|
| 1700 | BM2MC_PACKET_PacketFilterEnable *pPacket = (BM2MC_PACKET_PacketFilterEnable *) (*ppPacket); |
|---|
| 1701 | BM2MC_PACKET_INIT( pPacket, FilterEnable, false ); |
|---|
| 1702 | pPacket->enable = enable ? 1 : 0; |
|---|
| 1703 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1704 | *ppPacket = (void *) pPacket; |
|---|
| 1705 | |
|---|
| 1706 | { |
|---|
| 1707 | BM2MC_PACKET_PacketFilter *pPacket = (BM2MC_PACKET_PacketFilter *) (*ppPacket); |
|---|
| 1708 | BM2MC_PACKET_INIT( pPacket, Filter, false ); |
|---|
| 1709 | BGRC_Packet_ConvertFilter( &pPacket->hor, hor, pSrcRect->width, pOutRect->width ); |
|---|
| 1710 | BGRC_Packet_ConvertFilter( &pPacket->ver, ver, pSrcRect->height, pOutRect->height ); |
|---|
| 1711 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1712 | *ppPacket = (void *) pPacket; |
|---|
| 1713 | } |
|---|
| 1714 | BSTD_UNUSED(hGrc); |
|---|
| 1715 | return BERR_SUCCESS; |
|---|
| 1716 | } |
|---|
| 1717 | |
|---|
| 1718 | /*****************************************************************************/ |
|---|
| 1719 | BERR_Code BGRC_Packet_SetColorMatrixPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1720 | const int32_t matrix[], uint32_t shift ) |
|---|
| 1721 | { |
|---|
| 1722 | BM2MC_PACKET_PacketSourceColorMatrixEnable *pPacket = (BM2MC_PACKET_PacketSourceColorMatrixEnable *) (*ppPacket); |
|---|
| 1723 | BM2MC_PACKET_INIT( pPacket, SourceColorMatrixEnable, false ); |
|---|
| 1724 | pPacket->enable = matrix ? 1 : 0; |
|---|
| 1725 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1726 | *ppPacket = (void *) pPacket; |
|---|
| 1727 | |
|---|
| 1728 | if( matrix ) |
|---|
| 1729 | { |
|---|
| 1730 | BM2MC_PACKET_PacketSourceColorMatrix *pPacket = (BM2MC_PACKET_PacketSourceColorMatrix *) (*ppPacket); |
|---|
| 1731 | BM2MC_PACKET_INIT( pPacket, SourceColorMatrix, false ); |
|---|
| 1732 | BGRC_Packet_ConvertColorMatrix( &pPacket->matrix, matrix, shift ); |
|---|
| 1733 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1734 | *ppPacket = (void *) pPacket; |
|---|
| 1735 | } |
|---|
| 1736 | BSTD_UNUSED(hGrc); |
|---|
| 1737 | return BERR_SUCCESS; |
|---|
| 1738 | } |
|---|
| 1739 | |
|---|
| 1740 | /*****************************************************************************/ |
|---|
| 1741 | BERR_Code BGRC_Packet_SetSourcePalette( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1742 | BSUR_Surface_Handle surface ) |
|---|
| 1743 | { |
|---|
| 1744 | if( surface ) |
|---|
| 1745 | { |
|---|
| 1746 | BSUR_Palette_Handle palette = 0; |
|---|
| 1747 | BSUR_Surface_GetPalette( surface, &palette ); |
|---|
| 1748 | if( palette ) |
|---|
| 1749 | { |
|---|
| 1750 | uint32_t offset = 0; |
|---|
| 1751 | BSUR_Palette_GetOffset( palette, &offset ); |
|---|
| 1752 | if( offset ) |
|---|
| 1753 | { |
|---|
| 1754 | BM2MC_PACKET_PacketSourcePalette *pPacket = (BM2MC_PACKET_PacketSourcePalette *) (*ppPacket); |
|---|
| 1755 | BM2MC_PACKET_INIT( pPacket, SourcePalette, false ); |
|---|
| 1756 | pPacket->address = offset; |
|---|
| 1757 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1758 | *ppPacket = (void *) pPacket; |
|---|
| 1759 | } |
|---|
| 1760 | } |
|---|
| 1761 | } |
|---|
| 1762 | BSTD_UNUSED(hGrc); |
|---|
| 1763 | return BERR_SUCCESS; |
|---|
| 1764 | } |
|---|
| 1765 | |
|---|
| 1766 | /*****************************************************************************/ |
|---|
| 1767 | BERR_Code BGRC_Packet_SetAlphaPremultiply( BGRC_Handle hGrc, void **ppPacket, bool enable ) |
|---|
| 1768 | { |
|---|
| 1769 | BM2MC_PACKET_PacketAlphaPremultiply *pPacket = (BM2MC_PACKET_PacketAlphaPremultiply *) (*ppPacket); |
|---|
| 1770 | BM2MC_PACKET_INIT( pPacket, AlphaPremultiply, false ); |
|---|
| 1771 | pPacket->enable = enable ? 1 : 0; |
|---|
| 1772 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1773 | |
|---|
| 1774 | *ppPacket = (void *) pPacket; |
|---|
| 1775 | BSTD_UNUSED(hGrc); |
|---|
| 1776 | return BERR_SUCCESS; |
|---|
| 1777 | } |
|---|
| 1778 | |
|---|
| 1779 | /*****************************************************************************/ |
|---|
| 1780 | BERR_Code BGRC_Packet_SetMirrorPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1781 | bool srcHor, bool srcVer, bool dstHor, bool dstVer, bool outHor, bool outVer ) |
|---|
| 1782 | { |
|---|
| 1783 | BM2MC_PACKET_PacketMirror *pPacket = (BM2MC_PACKET_PacketMirror *) (*ppPacket); |
|---|
| 1784 | BM2MC_PACKET_INIT( pPacket, Mirror, false ); |
|---|
| 1785 | pPacket->src_hor = srcHor; |
|---|
| 1786 | pPacket->src_ver = srcVer; |
|---|
| 1787 | pPacket->dst_hor = dstHor; |
|---|
| 1788 | pPacket->dst_ver = dstVer; |
|---|
| 1789 | pPacket->out_hor = outHor; |
|---|
| 1790 | pPacket->out_ver = outVer; |
|---|
| 1791 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1792 | |
|---|
| 1793 | *ppPacket = (void *) pPacket; |
|---|
| 1794 | BSTD_UNUSED(hGrc); |
|---|
| 1795 | return BERR_SUCCESS; |
|---|
| 1796 | } |
|---|
| 1797 | |
|---|
| 1798 | /*****************************************************************************/ |
|---|
| 1799 | BERR_Code BGRC_Packet_SetFixedScalePacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1800 | int32_t hor_phase, int32_t ver_phase, uint32_t hor_step, uint32_t ver_step, uint32_t shift ) |
|---|
| 1801 | { |
|---|
| 1802 | BM2MC_PACKET_PacketFixedScale *pPacket = (BM2MC_PACKET_PacketFixedScale *) (*ppPacket); |
|---|
| 1803 | BM2MC_PACKET_INIT( pPacket, FixedScale, false ); |
|---|
| 1804 | pPacket->hor_phase = hor_phase; |
|---|
| 1805 | pPacket->ver_phase = ver_phase; |
|---|
| 1806 | pPacket->hor_step = hor_step; |
|---|
| 1807 | pPacket->ver_step = ver_step; |
|---|
| 1808 | pPacket->shift = shift; |
|---|
| 1809 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1810 | |
|---|
| 1811 | *ppPacket = (void *) pPacket; |
|---|
| 1812 | BSTD_UNUSED(hGrc); |
|---|
| 1813 | return BERR_SUCCESS; |
|---|
| 1814 | } |
|---|
| 1815 | |
|---|
| 1816 | /*****************************************************************************/ |
|---|
| 1817 | BERR_Code BGRC_Packet_SetDestripeFixedScalePacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1818 | BM2MC_PACKET_Rectangle *pChromaRect, int32_t hor_luma_phase, int32_t ver_luma_phase, int32_t hor_chroma_phase, int32_t ver_chroma_phase, |
|---|
| 1819 | uint32_t hor_luma_step, uint32_t ver_luma_step, uint32_t shift ) |
|---|
| 1820 | { |
|---|
| 1821 | BM2MC_PACKET_PacketDestripeFixedScale *pPacket = (BM2MC_PACKET_PacketDestripeFixedScale *) (*ppPacket); |
|---|
| 1822 | BM2MC_PACKET_INIT( pPacket, DestripeFixedScale, false ); |
|---|
| 1823 | pPacket->chroma_rect = *pChromaRect; |
|---|
| 1824 | pPacket->hor_luma_phase = hor_luma_phase; |
|---|
| 1825 | pPacket->ver_luma_phase = ver_luma_phase; |
|---|
| 1826 | pPacket->hor_chroma_phase = hor_chroma_phase; |
|---|
| 1827 | pPacket->ver_chroma_phase = ver_chroma_phase; |
|---|
| 1828 | pPacket->hor_luma_step = hor_luma_step; |
|---|
| 1829 | pPacket->ver_luma_step = ver_luma_step; |
|---|
| 1830 | pPacket->shift = shift; |
|---|
| 1831 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1832 | |
|---|
| 1833 | *ppPacket = (void *) pPacket; |
|---|
| 1834 | BSTD_UNUSED(hGrc); |
|---|
| 1835 | return BERR_SUCCESS; |
|---|
| 1836 | } |
|---|
| 1837 | |
|---|
| 1838 | /*****************************************************************************/ |
|---|
| 1839 | BERR_Code BGRC_Packet_SetBlitPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1840 | BM2MC_PACKET_Rectangle *pSrcRect, BM2MC_PACKET_Point *pOutPoint, BM2MC_PACKET_Point *pDstPoint ) |
|---|
| 1841 | { |
|---|
| 1842 | if( pDstPoint ) |
|---|
| 1843 | { |
|---|
| 1844 | BM2MC_PACKET_PacketBlendBlit *pPacket = (BM2MC_PACKET_PacketBlendBlit *) (*ppPacket); |
|---|
| 1845 | BM2MC_PACKET_INIT( pPacket, BlendBlit, true ); |
|---|
| 1846 | pPacket->src_rect = *pSrcRect; |
|---|
| 1847 | pPacket->out_point = *pOutPoint; |
|---|
| 1848 | pPacket->dst_point = *pDstPoint; |
|---|
| 1849 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1850 | *ppPacket = (void *) pPacket; |
|---|
| 1851 | } |
|---|
| 1852 | else if( pOutPoint ) |
|---|
| 1853 | { |
|---|
| 1854 | BM2MC_PACKET_PacketCopyBlit *pPacket = (BM2MC_PACKET_PacketCopyBlit *) (*ppPacket); |
|---|
| 1855 | BM2MC_PACKET_INIT( pPacket, CopyBlit, true ); |
|---|
| 1856 | pPacket->src_rect = *pSrcRect; |
|---|
| 1857 | pPacket->out_point = *pOutPoint; |
|---|
| 1858 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1859 | *ppPacket = (void *) pPacket; |
|---|
| 1860 | } |
|---|
| 1861 | else |
|---|
| 1862 | { |
|---|
| 1863 | BM2MC_PACKET_PacketFillBlit *pPacket = (BM2MC_PACKET_PacketFillBlit *) (*ppPacket); |
|---|
| 1864 | BM2MC_PACKET_INIT( pPacket, FillBlit, true ); |
|---|
| 1865 | pPacket->rect = *pSrcRect; |
|---|
| 1866 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1867 | *ppPacket = (void *) pPacket; |
|---|
| 1868 | } |
|---|
| 1869 | BSTD_UNUSED(hGrc); |
|---|
| 1870 | return BERR_SUCCESS; |
|---|
| 1871 | } |
|---|
| 1872 | |
|---|
| 1873 | /*****************************************************************************/ |
|---|
| 1874 | BERR_Code BGRC_Packet_SetScaleBlitPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1875 | BM2MC_PACKET_Rectangle *pSrcRect, BM2MC_PACKET_Rectangle *pOutRect, BM2MC_PACKET_Point *pDstPoint ) |
|---|
| 1876 | { |
|---|
| 1877 | if( pDstPoint ) |
|---|
| 1878 | { |
|---|
| 1879 | BM2MC_PACKET_PacketScaleBlendBlit *pPacket = (BM2MC_PACKET_PacketScaleBlendBlit *) (*ppPacket); |
|---|
| 1880 | BM2MC_PACKET_INIT( pPacket, ScaleBlendBlit, true ); |
|---|
| 1881 | pPacket->src_rect = *pSrcRect; |
|---|
| 1882 | pPacket->out_rect = *pOutRect; |
|---|
| 1883 | pPacket->dst_point = *pDstPoint; |
|---|
| 1884 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1885 | *ppPacket = (void *) pPacket; |
|---|
| 1886 | } |
|---|
| 1887 | else |
|---|
| 1888 | { |
|---|
| 1889 | BM2MC_PACKET_PacketScaleBlit *pPacket = (BM2MC_PACKET_PacketScaleBlit *) (*ppPacket); |
|---|
| 1890 | BM2MC_PACKET_INIT( pPacket, ScaleBlit, true ); |
|---|
| 1891 | pPacket->src_rect = *pSrcRect; |
|---|
| 1892 | pPacket->out_rect = *pOutRect; |
|---|
| 1893 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1894 | *ppPacket = (void *) pPacket; |
|---|
| 1895 | } |
|---|
| 1896 | BSTD_UNUSED(hGrc); |
|---|
| 1897 | return BERR_SUCCESS; |
|---|
| 1898 | } |
|---|
| 1899 | |
|---|
| 1900 | /*****************************************************************************/ |
|---|
| 1901 | BERR_Code BGRC_Packet_SetDestripeBlitPacket( BGRC_Handle hGrc, void **ppPacket, |
|---|
| 1902 | BM2MC_PACKET_Rectangle *pSrcRect, BM2MC_PACKET_Rectangle *pOutRect, |
|---|
| 1903 | uint32_t stripeWidth, uint32_t lumaStripeHeight, uint32_t chromaStripeHeight ) |
|---|
| 1904 | { |
|---|
| 1905 | BM2MC_PACKET_PacketDestripeBlit *pPacket = (BM2MC_PACKET_PacketDestripeBlit *) (*ppPacket); |
|---|
| 1906 | BM2MC_PACKET_INIT( pPacket, DestripeBlit, true ); |
|---|
| 1907 | pPacket->src_rect = *pSrcRect; |
|---|
| 1908 | pPacket->out_rect = *pOutRect; |
|---|
| 1909 | pPacket->dst_point = *((BM2MC_PACKET_Point *) pOutRect); |
|---|
| 1910 | pPacket->source_stripe_width = stripeWidth; |
|---|
| 1911 | pPacket->luma_stripe_height = lumaStripeHeight; |
|---|
| 1912 | pPacket->chroma_stripe_height = chromaStripeHeight; |
|---|
| 1913 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1914 | |
|---|
| 1915 | *ppPacket = (void *) pPacket; |
|---|
| 1916 | BSTD_UNUSED(hGrc); |
|---|
| 1917 | return BERR_SUCCESS; |
|---|
| 1918 | } |
|---|
| 1919 | |
|---|
| 1920 | /*****************************************************************************/ |
|---|
| 1921 | BERR_Code BGRC_Packet_SetResetState( BGRC_Handle hGrc, void **ppPacket ) |
|---|
| 1922 | { |
|---|
| 1923 | BM2MC_PACKET_PacketResetState *pPacket = (BM2MC_PACKET_PacketResetState *) (*ppPacket); |
|---|
| 1924 | BM2MC_PACKET_INIT( pPacket, ResetState, false ); |
|---|
| 1925 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1926 | |
|---|
| 1927 | *ppPacket = (void *) pPacket; |
|---|
| 1928 | BSTD_UNUSED(hGrc); |
|---|
| 1929 | return BERR_SUCCESS; |
|---|
| 1930 | } |
|---|
| 1931 | |
|---|
| 1932 | /*****************************************************************************/ |
|---|
| 1933 | BERR_Code BGRC_Packet_SetSaveState( BGRC_Handle hGrc, void **ppPacket ) |
|---|
| 1934 | { |
|---|
| 1935 | BM2MC_PACKET_PacketSaveState *pPacket = (BM2MC_PACKET_PacketSaveState *) (*ppPacket); |
|---|
| 1936 | BM2MC_PACKET_INIT( pPacket, SaveState, false ); |
|---|
| 1937 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1938 | |
|---|
| 1939 | *ppPacket = (void *) pPacket; |
|---|
| 1940 | BSTD_UNUSED(hGrc); |
|---|
| 1941 | return BERR_SUCCESS; |
|---|
| 1942 | } |
|---|
| 1943 | |
|---|
| 1944 | /*****************************************************************************/ |
|---|
| 1945 | BERR_Code BGRC_Packet_SetRestoreState( BGRC_Handle hGrc, void **ppPacket ) |
|---|
| 1946 | { |
|---|
| 1947 | BM2MC_PACKET_PacketRestoreState *pPacket = (BM2MC_PACKET_PacketRestoreState *) (*ppPacket); |
|---|
| 1948 | BM2MC_PACKET_INIT( pPacket, RestoreState, false ); |
|---|
| 1949 | BM2MC_PACKET_TERM( pPacket ); |
|---|
| 1950 | |
|---|
| 1951 | *ppPacket = (void *) pPacket; |
|---|
| 1952 | BSTD_UNUSED(hGrc); |
|---|
| 1953 | return BERR_SUCCESS; |
|---|
| 1954 | } |
|---|
| 1955 | |
|---|
| 1956 | /* End of File */ |
|---|