| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2009-2011, 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.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/29 $ |
|---|
| 12 | * $brcm_Date: 11/29/11 4:22p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: GRC Packet header |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/grc/7405/bgrc_packet.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/29 11/29/11 4:22p nissen |
|---|
| 21 | * SW7425-1795: Changed to BMEM_Handle. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/28 11/22/11 6:26p nissen |
|---|
| 24 | * SW7425-1795: Added heap field to BGRC_PacketContext_CreateSettings |
|---|
| 25 | * structure for packet memory allocations. |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/27 12/6/10 12:49p nissen |
|---|
| 28 | * SW7420-1138: Added support for validating memory bounds used by blits. |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/26 11/11/10 5:36p nissen |
|---|
| 31 | * SW7420-1200: Added support for storing packets before submitting, |
|---|
| 32 | * through a field in the context's create settings structure. |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/25 9/3/10 4:21p nissen |
|---|
| 35 | * SW7405-4810: Added BGRC_Packet_GetStatus function. |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/24 7/21/10 4:30p nissen |
|---|
| 38 | * SW7405-3671: Added support for user supplying private data ptr during |
|---|
| 39 | * context creation which gets passed back when getting status. |
|---|
| 40 | * |
|---|
| 41 | * Hydra_Software_Devel/23 7/15/10 9:06p nissen |
|---|
| 42 | * SW7405-3671: Added more interrupt support. |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/22 7/12/10 2:36p nissen |
|---|
| 45 | * SW7405-3671: Updated api functions. |
|---|
| 46 | * |
|---|
| 47 | * Hydra_Software_Devel/21 6/30/10 9:29p nissen |
|---|
| 48 | * SW7405-3671: Updated color matrix and filter conversion functions. |
|---|
| 49 | * |
|---|
| 50 | * Hydra_Software_Devel/20 6/30/10 7:53p nissen |
|---|
| 51 | * SW7405-3671: Updated pixel format conversion function and removed blend |
|---|
| 52 | * conversion function. |
|---|
| 53 | * |
|---|
| 54 | * Hydra_Software_Devel/19 6/24/10 2:18p nissen |
|---|
| 55 | * SW7405-3671: Added source feeder destripe packet function. |
|---|
| 56 | * |
|---|
| 57 | * Hydra_Software_Devel/18 6/21/10 2:25p nissen |
|---|
| 58 | * SW7405-3671: Fixed packet settings. |
|---|
| 59 | * |
|---|
| 60 | * Hydra_Software_Devel/17 6/21/10 12:41p nissen |
|---|
| 61 | * SW7405-3671: Added context support. Switched to M2MC packets. |
|---|
| 62 | * |
|---|
| 63 | * Hydra_Software_Devel/16 3/19/10 2:33p nissen |
|---|
| 64 | * SW7405-3671: Fixed alpha premultiply. |
|---|
| 65 | * |
|---|
| 66 | * Hydra_Software_Devel/15 3/11/10 1:14p nissen |
|---|
| 67 | * SW7405-3671: Added support for alpha premultiply. |
|---|
| 68 | * |
|---|
| 69 | * Hydra_Software_Devel/14 3/10/10 2:50p nissen |
|---|
| 70 | * SW7405-3671: Added offset buffer pointers to batch packet blits. |
|---|
| 71 | * |
|---|
| 72 | * Hydra_Software_Devel/13 2/10/10 2:16p nissen |
|---|
| 73 | * SW7405-3671: Fixed palette to palette blits. |
|---|
| 74 | * |
|---|
| 75 | * Hydra_Software_Devel/12 2/9/10 4:35p nissen |
|---|
| 76 | * SW7405-3671: Updated batch blits. |
|---|
| 77 | * |
|---|
| 78 | * Hydra_Software_Devel/11 2/8/10 6:00p nissen |
|---|
| 79 | * SW7405-3671: Updated batching to submit as many blits as possible. |
|---|
| 80 | * |
|---|
| 81 | * Hydra_Software_Devel/10 2/5/10 8:20p nissen |
|---|
| 82 | * SW7405-3671: Fixed palette to palette blits. |
|---|
| 83 | * |
|---|
| 84 | * Hydra_Software_Devel/9 2/5/10 12:08p nissen |
|---|
| 85 | * SW7405-3671: Fixed problem with init packet. |
|---|
| 86 | * |
|---|
| 87 | * Hydra_Software_Devel/8 2/5/10 10:50a nissen |
|---|
| 88 | * SW7405-3671: Moved packet function. |
|---|
| 89 | * |
|---|
| 90 | * Hydra_Software_Devel/7 2/3/10 2:01p nissen |
|---|
| 91 | * SW7405-3671: Added batch packets. |
|---|
| 92 | * |
|---|
| 93 | * Hydra_Software_Devel/6 1/29/10 7:20p nissen |
|---|
| 94 | * SW7405-3671: Added support for using packets in any order. |
|---|
| 95 | * |
|---|
| 96 | * Hydra_Software_Devel/5 1/19/10 4:45p nissen |
|---|
| 97 | * SW7405-3671: Added support for different M2MC cores. |
|---|
| 98 | * |
|---|
| 99 | * Hydra_Software_Devel/4 1/19/10 12:31p nissen |
|---|
| 100 | * SW7405-3671: Added support for sync'ing and 420 destriping. |
|---|
| 101 | * |
|---|
| 102 | * Hydra_Software_Devel/3 1/8/10 2:26p nissen |
|---|
| 103 | * SW7405-3671: Removed buffer size parameters when opening packet module. |
|---|
| 104 | * |
|---|
| 105 | * Hydra_Software_Devel/2 12/31/09 10:17p nissen |
|---|
| 106 | * SW7405-3671: Added palette support and software striping while scaling |
|---|
| 107 | * support. |
|---|
| 108 | * |
|---|
| 109 | * Hydra_Software_Devel/1 12/24/09 1:10a nissen |
|---|
| 110 | * SW7405-3671: Packet blits |
|---|
| 111 | * |
|---|
| 112 | ***************************************************************************/ |
|---|
| 113 | |
|---|
| 114 | #ifndef BGRC_PACKET_H__ |
|---|
| 115 | #define BGRC_PACKET_H__ |
|---|
| 116 | |
|---|
| 117 | #ifdef __cplusplus |
|---|
| 118 | extern "C" { |
|---|
| 119 | #endif |
|---|
| 120 | |
|---|
| 121 | #include "bm2mc_packet.h" |
|---|
| 122 | #include "berr_ids.h" |
|---|
| 123 | |
|---|
| 124 | /***************************************************************************/ |
|---|
| 125 | typedef struct BGRC_P_PacketContext *BGRC_PacketContext_Handle; |
|---|
| 126 | |
|---|
| 127 | /***************************************************************************/ |
|---|
| 128 | #define BGRC_PACKET_MSG_PACKETS_INCOMPLETE BERR_MAKE_CODE(BERR_GRC_ID, 0x0100) |
|---|
| 129 | #define BGRC_PACKET_MSG_BLITS_COMPLETE BERR_MAKE_CODE(BERR_GRC_ID, 0x0101) |
|---|
| 130 | |
|---|
| 131 | /***************************************************************************/ |
|---|
| 132 | typedef struct |
|---|
| 133 | { |
|---|
| 134 | BMEM_Handle packet_buffer_heap; /* heap for packet buffer allocations */ |
|---|
| 135 | size_t packet_buffer_size; /* size of packet ring buffer to allocate */ |
|---|
| 136 | size_t packet_buffer_store; /* size of packet buffer to store before submitting */ |
|---|
| 137 | void *private_data; /* ptr passed back to the user when getting status */ |
|---|
| 138 | struct { |
|---|
| 139 | uint32_t offset; /* bounded memory offset (0=no bounds check) */ |
|---|
| 140 | size_t size; /* bounded memory size (0=no bounds check)*/ |
|---|
| 141 | } memory_bounds; /* verify blits do not violate memory bounds */ |
|---|
| 142 | } |
|---|
| 143 | BGRC_PacketContext_CreateSettings; |
|---|
| 144 | |
|---|
| 145 | /***************************************************************************/ |
|---|
| 146 | typedef struct |
|---|
| 147 | { |
|---|
| 148 | BGRC_PacketContext_Handle hContext; |
|---|
| 149 | void *private_data; /* ptr to user's private data */ |
|---|
| 150 | size_t packet_buffer_available; /* size of available packet memory */ |
|---|
| 151 | bool sync; /* indicates blit sync */ |
|---|
| 152 | } |
|---|
| 153 | BGRC_Packet_ContextStatus; |
|---|
| 154 | |
|---|
| 155 | /***************************************************************************/ |
|---|
| 156 | typedef struct |
|---|
| 157 | { |
|---|
| 158 | bool m2mc_busy; /* indicates m2mc is busy */ |
|---|
| 159 | } |
|---|
| 160 | BGRC_Packet_Status; |
|---|
| 161 | |
|---|
| 162 | /*************************************************************************** |
|---|
| 163 | PACKET API - MAIN FUNCTIONS |
|---|
| 164 | ***************************************************************************/ |
|---|
| 165 | /*************************************************************************** |
|---|
| 166 | Set one callback for all contexts, which overrides any context callbacks. |
|---|
| 167 | Either a single callback will be called for all interrupts, or context's |
|---|
| 168 | can get their own callbacks using BGRC_Packet_SetContextCallbacks. |
|---|
| 169 | ***************************************************************************/ |
|---|
| 170 | BERR_Code BGRC_Packet_SetCallback( |
|---|
| 171 | BGRC_Handle hGrc, |
|---|
| 172 | BGRC_Callback callback_isr, /* general callback for all contexts */ |
|---|
| 173 | void *callback_data /* ptr to user's data */ |
|---|
| 174 | ); |
|---|
| 175 | |
|---|
| 176 | /***************************************************************************/ |
|---|
| 177 | BERR_Code BGRC_Packet_GetDefaultCreateContextSettings( |
|---|
| 178 | BGRC_Handle hGrc, |
|---|
| 179 | BGRC_PacketContext_CreateSettings *pSettings |
|---|
| 180 | ); |
|---|
| 181 | |
|---|
| 182 | /***************************************************************************/ |
|---|
| 183 | BERR_Code BGRC_Packet_CreateContext( |
|---|
| 184 | BGRC_Handle hGrc, |
|---|
| 185 | BGRC_PacketContext_Handle *phContext, |
|---|
| 186 | BGRC_PacketContext_CreateSettings *pSettings |
|---|
| 187 | ); |
|---|
| 188 | |
|---|
| 189 | /***************************************************************************/ |
|---|
| 190 | BERR_Code BGRC_Packet_DestroyContext( |
|---|
| 191 | BGRC_Handle hGrc, |
|---|
| 192 | BGRC_PacketContext_Handle hContext |
|---|
| 193 | ); |
|---|
| 194 | |
|---|
| 195 | /*************************************************************************** |
|---|
| 196 | Set Advance and Sync callbacks per context. These callbacks will not be used |
|---|
| 197 | if setting a general callback through BGRC_Packet_SetCallback. |
|---|
| 198 | ***************************************************************************/ |
|---|
| 199 | BERR_Code BGRC_Packet_SetContextCallbacks( |
|---|
| 200 | BGRC_Handle hGrc, |
|---|
| 201 | BGRC_PacketContext_Handle hContext, |
|---|
| 202 | BGRC_Callback advance_callback_isr, /* callback indicating packet procssing can be */ |
|---|
| 203 | void *advance_callback_data, /* advanced because device fifo memory is available */ |
|---|
| 204 | BGRC_Callback sync_callback_isr, /* callback indicating blits are complete */ |
|---|
| 205 | void *sync_callback_data /* up to the point of the sync */ |
|---|
| 206 | ); |
|---|
| 207 | |
|---|
| 208 | /*************************************************************************** |
|---|
| 209 | Gets packet memory from the packet ring buffer. If the specified minimum |
|---|
| 210 | size is not available, then the ring buffer will wrap if possible and |
|---|
| 211 | return memory from the front of the buffer, otherwise a size of zero will |
|---|
| 212 | be returned. The returned size will be the maximium amount available. |
|---|
| 213 | ***************************************************************************/ |
|---|
| 214 | BERR_Code BGRC_Packet_GetPacketMemory( |
|---|
| 215 | BGRC_Handle hGrc, |
|---|
| 216 | BGRC_PacketContext_Handle hContext, /* cannot be null */ |
|---|
| 217 | void **buffer, /* [out] ptr to packet buffer ptr */ |
|---|
| 218 | size_t *size_out, /* [out] ptr to size of buffer */ |
|---|
| 219 | size_t size_in /* minimum size requested (4-bytes or greater) */ |
|---|
| 220 | ); |
|---|
| 221 | |
|---|
| 222 | /*************************************************************************** |
|---|
| 223 | Submit packets for processing to a context. If all packets cannot be |
|---|
| 224 | processed, then _MSG_PACKETS_INCOMPLETE is returned, and the callback is |
|---|
| 225 | called when packet processing becomes possible again. If there is no |
|---|
| 226 | callback specified, remaining packets still need to be advanced. |
|---|
| 227 | ***************************************************************************/ |
|---|
| 228 | BERR_Code BGRC_Packet_SubmitPackets( |
|---|
| 229 | BGRC_Handle hGrc, |
|---|
| 230 | BGRC_PacketContext_Handle hContext, /* cannot be null */ |
|---|
| 231 | size_t size /* size of packet buffer submitted */ |
|---|
| 232 | ); |
|---|
| 233 | |
|---|
| 234 | /*************************************************************************** |
|---|
| 235 | Advances the context's uncompleted packet processing. If all the packets |
|---|
| 236 | cannot be finished, then _MSG_PACKETS_INCOMPLETE is returned, and the |
|---|
| 237 | callback is called when packet processing becomes possible again. If there |
|---|
| 238 | is no callback specified, then all packets will have finished processing |
|---|
| 239 | upon return. |
|---|
| 240 | ***************************************************************************/ |
|---|
| 241 | BERR_Code BGRC_Packet_AdvancePackets( |
|---|
| 242 | BGRC_Handle hGrc, |
|---|
| 243 | BGRC_PacketContext_Handle hContext /* set to null to advance all contexts */ |
|---|
| 244 | ); |
|---|
| 245 | |
|---|
| 246 | /*************************************************************************** |
|---|
| 247 | Synchronizes the context's blits. If there are any remaining packets that |
|---|
| 248 | still need to be Advanced, then _MSG_PACKETS_INCOMPLETE is returned. If all |
|---|
| 249 | the context's blits are already complete, then _MSG_BLITS_COMPLETE is |
|---|
| 250 | returned, otherwise the callback will be called when the blits are complete. |
|---|
| 251 | If there is no callback specified, then all outstanding blits will be |
|---|
| 252 | complete upon return. Sync can be called once per context, and cannot be |
|---|
| 253 | called again until the callback is called. |
|---|
| 254 | ***************************************************************************/ |
|---|
| 255 | BERR_Code BGRC_Packet_SyncPackets( |
|---|
| 256 | BGRC_Handle hGrc, |
|---|
| 257 | BGRC_PacketContext_Handle hContext /* cannot be null */ |
|---|
| 258 | ); |
|---|
| 259 | |
|---|
| 260 | /*************************************************************************** |
|---|
| 261 | Returns the how much packet memory is available for contexts with packets |
|---|
| 262 | that need advancing, and the blit sync status of contexts that have synced |
|---|
| 263 | since the last call to this function. |
|---|
| 264 | ***************************************************************************/ |
|---|
| 265 | BERR_Code BGRC_Packet_GetContextStatus( |
|---|
| 266 | BGRC_Handle hGrc, |
|---|
| 267 | BGRC_Packet_ContextStatus *status_array, /* [out] context status array */ |
|---|
| 268 | size_t *size_out, /* [out] size of array*/ |
|---|
| 269 | size_t size_in /* size of array */ |
|---|
| 270 | ); |
|---|
| 271 | |
|---|
| 272 | /*************************************************************************** |
|---|
| 273 | Returns the M2MC device status. |
|---|
| 274 | ***************************************************************************/ |
|---|
| 275 | BERR_Code BGRC_Packet_GetStatus( |
|---|
| 276 | BGRC_Handle hGrc, |
|---|
| 277 | BGRC_Packet_Status *status /* [out] status */ |
|---|
| 278 | ); |
|---|
| 279 | |
|---|
| 280 | /*************************************************************************** |
|---|
| 281 | PACKET API - STATE DATA CONVERSION |
|---|
| 282 | ***************************************************************************/ |
|---|
| 283 | BERR_Code BGRC_Packet_ConvertPixelFormat( |
|---|
| 284 | BM2MC_PACKET_PixelFormat *format, /* [out] packet pixel format */ |
|---|
| 285 | BPXL_Format pxl_format /* BPXL pixel format */ |
|---|
| 286 | ); |
|---|
| 287 | |
|---|
| 288 | /***************************************************************************/ |
|---|
| 289 | BERR_Code BGRC_Packet_ConvertFilter( |
|---|
| 290 | BM2MC_PACKET_FilterCoeffs *coeffs, /* [out] packet filter coeffs */ |
|---|
| 291 | BGRC_FilterCoeffs filter, /* BGRC filter enum */ |
|---|
| 292 | size_t src_size, /* source width or height */ |
|---|
| 293 | size_t out_size /* output width or height */ |
|---|
| 294 | ); |
|---|
| 295 | |
|---|
| 296 | /***************************************************************************/ |
|---|
| 297 | BERR_Code BGRC_Packet_ConvertColorMatrix( |
|---|
| 298 | BM2MC_PACKET_ColorMatrix *matrix_out, /* [out] packet colormatrix */ |
|---|
| 299 | const int32_t *matrix_in, /* BGRC color matrix */ |
|---|
| 300 | size_t shift /* BGRC matrix element shift */ |
|---|
| 301 | ); |
|---|
| 302 | |
|---|
| 303 | /***************************************************************************/ |
|---|
| 304 | |
|---|
| 305 | #ifdef __cplusplus |
|---|
| 306 | } |
|---|
| 307 | #endif |
|---|
| 308 | |
|---|
| 309 | #endif /* #ifndef BGRC_PACKET_H__ */ |
|---|
| 310 | |
|---|
| 311 | /* end of file */ |
|---|