| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-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: bsur.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/28 $ |
|---|
| 12 | * $brcm_Date: 3/18/11 1:38p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/commonutils/sur/7422/bsur.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/28 3/18/11 1:38p nissen |
|---|
| 21 | * SW7420-1200: Added function to get all the packet blit info. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/27 2/26/09 4:24p nissen |
|---|
| 24 | * PR 47303: Added prediction mode field to settings structure. |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/26 10/3/08 10:45a yuxiaz |
|---|
| 27 | * PR47303: More TestFeature1 support in BSUR. |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/25 10/1/08 5:47p nissen |
|---|
| 30 | * PR 47303: Added functions to get default surface settings and |
|---|
| 31 | * TestFeature1 settings. Added settings structure parameter to surface |
|---|
| 32 | * create function. |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/24 4/4/08 11:22a nissen |
|---|
| 35 | * PR 40122: Added support for 10-bit 422 40-bit packed formats. |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/23 11/15/06 10:52a nissen |
|---|
| 38 | * PR 25683: Added function to set surface ID. |
|---|
| 39 | * |
|---|
| 40 | * Hydra_Software_Devel/22 11/8/06 10:53a nissen |
|---|
| 41 | * PR 25683: Added support for a surface ID. |
|---|
| 42 | * |
|---|
| 43 | * Hydra_Software_Devel/21 8/25/06 11:11a nissen |
|---|
| 44 | * PR 18990: Added support for 10-bit YCbCr 422 alignment. |
|---|
| 45 | * |
|---|
| 46 | * Hydra_Software_Devel/20 3/21/06 12:49p nissen |
|---|
| 47 | * PR 20331: Added functions to return offsets for surfaces and palettes. |
|---|
| 48 | * |
|---|
| 49 | * Hydra_Software_Devel/19 3/15/06 11:54a nissen |
|---|
| 50 | * PR 15840: Added support for creating YCbCr 420 surfaces. |
|---|
| 51 | * |
|---|
| 52 | * Hydra_Software_Devel/18 11/10/05 5:03p syang |
|---|
| 53 | * PR 12244: move alpha-only pixel constant color setting from BSUR to |
|---|
| 54 | * BVDC |
|---|
| 55 | * |
|---|
| 56 | * Hydra_Software_Devel/17 10/8/04 3:27p yuxiaz |
|---|
| 57 | * PR9076: Change isr functions to _isr. |
|---|
| 58 | * |
|---|
| 59 | * Hydra_Software_Devel/16 8/11/04 6:27p syang |
|---|
| 60 | * PR 12244: added alpha only pixel format support for gfx feeder (new B0 |
|---|
| 61 | * feature) |
|---|
| 62 | * |
|---|
| 63 | * Hydra_Software_Devel/15 6/11/04 4:50p syang |
|---|
| 64 | * PR 11299: changed func name BSUR_Palette_GetEntryFormat to |
|---|
| 65 | * BSUR_Palette_GetFormat |
|---|
| 66 | * |
|---|
| 67 | * Hydra_Software_Devel/14 6/1/04 3:54p jasonh |
|---|
| 68 | * PR 11215: Updated documentation for surface creation. |
|---|
| 69 | * |
|---|
| 70 | * Hydra_Software_Devel/13 10/28/03 1:53p syang |
|---|
| 71 | * added BSUR_Palette_GetEntryFormat |
|---|
| 72 | * |
|---|
| 73 | * Hydra_Software_Devel/12 8/21/03 1:22p nissen |
|---|
| 74 | * Added constraints for width and height being a power of 2. |
|---|
| 75 | * |
|---|
| 76 | * Hydra_Software_Devel/11 8/20/03 4:27p nissen |
|---|
| 77 | * Removed open and close functions. Replaced usage mask functions and |
|---|
| 78 | * parameters with constraint mask functions and parameters. Replaced |
|---|
| 79 | * surface module handle parameters with memory module handle. |
|---|
| 80 | * |
|---|
| 81 | * Hydra_Software_Devel/10 8/19/03 10:09a nissen |
|---|
| 82 | * Removed usage mask functions and parameters and added alignment |
|---|
| 83 | * parameter to surface and palette creation functions. |
|---|
| 84 | * |
|---|
| 85 | * Hydra_Software_Devel/9 8/6/03 2:25p nissen |
|---|
| 86 | * Changed all references to "unsigned int" to "uint32_t". |
|---|
| 87 | * |
|---|
| 88 | * Hydra_Software_Devel/8 6/5/03 11:39a nissen |
|---|
| 89 | * Added entry point function to get surface format. |
|---|
| 90 | * |
|---|
| 91 | * Hydra_Software_Devel/7 4/25/03 3:42p nissen |
|---|
| 92 | * Removed breg.h include. |
|---|
| 93 | * |
|---|
| 94 | * Hydra_Software_Devel/6 4/11/03 3:54p jasonh |
|---|
| 95 | * Changed palette creation to work similar to surface creation, requring |
|---|
| 96 | * a format. Fixed out of memory errors. |
|---|
| 97 | * |
|---|
| 98 | * Hydra_Software_Devel/5 3/21/03 1:15p jasonh |
|---|
| 99 | * Fixed module overview section. |
|---|
| 100 | * |
|---|
| 101 | * Hydra_Software_Devel/4 3/19/03 5:16p jasonh |
|---|
| 102 | * Added changes requested in first internal code review. |
|---|
| 103 | * |
|---|
| 104 | * Hydra_Software_Devel/3 3/12/03 4:27p pntruong |
|---|
| 105 | * Added the include bchp.h, so thing will compile. |
|---|
| 106 | * |
|---|
| 107 | ***************************************************************************/ |
|---|
| 108 | #ifndef BSUR_H__ |
|---|
| 109 | #define BSUR_H__ |
|---|
| 110 | |
|---|
| 111 | #include "bchp.h" |
|---|
| 112 | #include "bmem.h" |
|---|
| 113 | #include "bpxl.h" |
|---|
| 114 | |
|---|
| 115 | #ifdef __cplusplus |
|---|
| 116 | extern "C" { |
|---|
| 117 | #endif |
|---|
| 118 | |
|---|
| 119 | /*=Module Overview: ******************************************************** |
|---|
| 120 | The purpose of the surface module is to allocate surfaces for use with |
|---|
| 121 | other modules. The video display control module uses surfaces for |
|---|
| 122 | hardware cursor support, the graphics compositor module uses surfaces as |
|---|
| 123 | a standard input for many of its operations, and the graphics feeder uses |
|---|
| 124 | surfaces to represent frame buffers. |
|---|
| 125 | |
|---|
| 126 | This module contains functions to create, destroy and modify surfaces |
|---|
| 127 | and palettes. Palettes are associated with surfaces which specify a |
|---|
| 128 | format that requires a palette. |
|---|
| 129 | |
|---|
| 130 | Supported features: |
|---|
| 131 | o Can create surface with any pixel format. |
|---|
| 132 | o Can create palettes with 4, 16, and 256 entries. |
|---|
| 133 | o TODO: Complete list of specific features that are supported and unit |
|---|
| 134 | tested for this module. |
|---|
| 135 | ****************************************************************************/ |
|---|
| 136 | |
|---|
| 137 | #define BSUR_SURFACE_CREATE_HAS_SETTINGS |
|---|
| 138 | |
|---|
| 139 | /*************************************************************************** |
|---|
| 140 | Summary: |
|---|
| 141 | A handle representing a surface. |
|---|
| 142 | |
|---|
| 143 | Description: |
|---|
| 144 | This handle is used by surface module functions to store a two |
|---|
| 145 | dimensional array of pixels. |
|---|
| 146 | |
|---|
| 147 | See Also: |
|---|
| 148 | BSUR_Surface_Create |
|---|
| 149 | ****************************************************************************/ |
|---|
| 150 | typedef struct BSUR_P_Surface_Handle *BSUR_Surface_Handle; |
|---|
| 151 | |
|---|
| 152 | /*************************************************************************** |
|---|
| 153 | Summary: |
|---|
| 154 | A handle representing a palette. |
|---|
| 155 | |
|---|
| 156 | Description: |
|---|
| 157 | This handle is used by surface module functions to store a |
|---|
| 158 | one dimensional array of colors. This handle is used with a surface |
|---|
| 159 | handle when the format of a surface requires a palette. |
|---|
| 160 | |
|---|
| 161 | See Also: |
|---|
| 162 | BSUR_Palette_Create, |
|---|
| 163 | BSUR_Surface_Handle |
|---|
| 164 | ****************************************************************************/ |
|---|
| 165 | typedef struct BSUR_P_Palette_Handle *BSUR_Palette_Handle; |
|---|
| 166 | |
|---|
| 167 | /*************************************************************************** |
|---|
| 168 | Summary: |
|---|
| 169 | Surface TestFeature1 settings structure. |
|---|
| 170 | |
|---|
| 171 | Description: |
|---|
| 172 | This structure is a field in the BSUR_Surface_Settings structure, and |
|---|
| 173 | is used to set the TestFeature1 settings of a surface when creating it. |
|---|
| 174 | |
|---|
| 175 | bEnable: Enables/disables TestFeature1. (default=false) |
|---|
| 176 | ulBitsPerPixel: Bits per pixel in units of 0.5 bits per pixel. |
|---|
| 177 | Range from 14 to 64. Note this is in U31.1 fixed point |
|---|
| 178 | format, with 31 bit integer and 1 bit fraction. |
|---|
| 179 | The greater BitsPerPixel is, the better picture quality. |
|---|
| 180 | (default=14,minimum) |
|---|
| 181 | ulPredicationMode: Predication mode, 0=Normal, 1=NOLEFT, 2=NO2LEFT |
|---|
| 182 | (default=0,Normal) |
|---|
| 183 | |
|---|
| 184 | See Also: |
|---|
| 185 | BSUR_Surface_Settings, |
|---|
| 186 | BSUR_Surface_Create, |
|---|
| 187 | BSUR_Surface_GetTestFeature1, |
|---|
| 188 | BSUR_Surface_GetDefaultSettings |
|---|
| 189 | ****************************************************************************/ |
|---|
| 190 | typedef struct |
|---|
| 191 | { |
|---|
| 192 | bool bEnable; /* Enables TestFeature1 */ |
|---|
| 193 | uint32_t ulBitsPerPixel; /* Bits per pixel in units of 0.5 */ |
|---|
| 194 | uint32_t ulPredictionMode; /* Predication mode, 0=Normal, 1=NOLEFT, 2=NO2LEFT */ |
|---|
| 195 | } |
|---|
| 196 | BSUR_TestFeature1_Settings; |
|---|
| 197 | |
|---|
| 198 | /*************************************************************************** |
|---|
| 199 | Summary: |
|---|
| 200 | TestFeature1 settings structure. |
|---|
| 201 | |
|---|
| 202 | Description: |
|---|
| 203 | This structure is used to set the extended settings of a surface |
|---|
| 204 | when creating it. |
|---|
| 205 | |
|---|
| 206 | stTestFeature1Settings: TestFeature1 settings. |
|---|
| 207 | |
|---|
| 208 | See Also: |
|---|
| 209 | BSUR_TestFeature1_Settings, |
|---|
| 210 | BSUR_Surface_Create, |
|---|
| 211 | BSUR_Surface_GetDefaultSettings |
|---|
| 212 | ****************************************************************************/ |
|---|
| 213 | typedef struct |
|---|
| 214 | { |
|---|
| 215 | BSUR_TestFeature1_Settings stTestFeature1Settings; |
|---|
| 216 | } |
|---|
| 217 | BSUR_Surface_Settings; |
|---|
| 218 | |
|---|
| 219 | /*************************************************************************** |
|---|
| 220 | Summary: |
|---|
| 221 | Constraint masks. |
|---|
| 222 | |
|---|
| 223 | Description: |
|---|
| 224 | The constraint mask is a bit mask describing which restrictions |
|---|
| 225 | should be put on the properties of a palette or surface when |
|---|
| 226 | creating it. |
|---|
| 227 | |
|---|
| 228 | See Also: |
|---|
| 229 | BSUR_Palette_Create, |
|---|
| 230 | BSUR_Surface_Create |
|---|
| 231 | ****************************************************************************/ |
|---|
| 232 | #define BSUR_CONSTRAINT_ADDRESS_PIXEL_ALIGNED 0x1 /* address and pitch must be pixel aligned */ |
|---|
| 233 | #define BSUR_CONSTRAINT_WIDTH_POWER_2 0x2 /* width in pixels must be a power of 2 */ |
|---|
| 234 | #define BSUR_CONSTRAINT_HEIGHT_POWER_2 0x4 /* height in pixels must be a power of 2 */ |
|---|
| 235 | #define BSUR_CONSTRAINT_YCbCr420_FORMAT 0x8 /* address and pitch must be YCbCr420 aligned (16 dwords) */ |
|---|
| 236 | #define BSUR_CONSTRAINT_YCbCr422_10BIT_FORMAT 0x10 /* address and pitch must be YCbCr422 10-bit aligned (4 dwords) */ |
|---|
| 237 | #define BSUR_CONSTRAINT_YCbCr422_10BIT_PACKED_FORMAT 0x20 /* address and pitch must be YCbCr422 10-bit packed aligned (5 dwords) */ |
|---|
| 238 | #define BSUR_CONSTRAINT_DCX_TESTFEATURE1_FORMAT 0x40 /* address must be DCX TestFeature1 aligned (64 bytes) */ |
|---|
| 239 | |
|---|
| 240 | /*************************************************************************** |
|---|
| 241 | Summary: |
|---|
| 242 | Checks if surface has required constraints. |
|---|
| 243 | |
|---|
| 244 | Description: |
|---|
| 245 | This macro is used to determine which contraints a surface has. |
|---|
| 246 | Possible contraints include BSUR_CONSTRAINT_ADDRESS_PIXEL_ALIGNED, |
|---|
| 247 | BSUR_CONSTRAINT_WIDTH_POWER_2, and BSUR_CONSTRAINT_HEIGHT_POWER_2. |
|---|
| 248 | |
|---|
| 249 | ****************************************************************************/ |
|---|
| 250 | #define BSUR_CONSTRAINT_MATCH(surface_constraint, required_constraint) \ |
|---|
| 251 | (((surface_constraint) & (required_constraint)) == (required_constraint)) |
|---|
| 252 | |
|---|
| 253 | /*************************************************************************** |
|---|
| 254 | Summary: |
|---|
| 255 | Creates a palette. |
|---|
| 256 | |
|---|
| 257 | Description: |
|---|
| 258 | Palettes are created and used by surfaces that need them. They are |
|---|
| 259 | attached to a surface and may be shared between surfaces. |
|---|
| 260 | Surfaces which require palettes must have one associated with it. |
|---|
| 261 | |
|---|
| 262 | There are two ways to create a palette: |
|---|
| 263 | |
|---|
| 264 | o Module allocated palette: The user doesn't provide a palette |
|---|
| 265 | address, flagging this function to allocate memory from the |
|---|
| 266 | surface module's memory heap. When the palette is destroyed, |
|---|
| 267 | this memory will be freed by the module. This memory is |
|---|
| 268 | considered to be uninitialized after creation. |
|---|
| 269 | |
|---|
| 270 | o User allocated palette: The user provides a palette address, |
|---|
| 271 | flagging the function that this given memory should be used for |
|---|
| 272 | the palette and that no additional memory should be allocated to |
|---|
| 273 | store the palette. When the palette is destroyed the provided memory |
|---|
| 274 | will not be freed. Checks will be made by this function to |
|---|
| 275 | insure that the provided memory can be used for a palette. |
|---|
| 276 | |
|---|
| 277 | The user must provide the format of the pixels stored in the palette. |
|---|
| 278 | This user must know what this format is in order to load the palette |
|---|
| 279 | with appropriate color values. Currently, all palettes must use a |
|---|
| 280 | format of BPXL_eA8_Y8_Cb8_Cr8 or BPXL_eA8_R8_G8_B8. |
|---|
| 281 | |
|---|
| 282 | The constraint mask is a bit mask describing which restrictions |
|---|
| 283 | should be put on the properties of the palette when creating it. |
|---|
| 284 | Currently the only valid constraint for this function is |
|---|
| 285 | BSUR_CONSTRAINT_ADDRESS_PIXEL_ALIGNED. |
|---|
| 286 | |
|---|
| 287 | Returns: |
|---|
| 288 | BERR_SUCCESS - Palette was successfully created. |
|---|
| 289 | BERR_INVALID_PARAMETER - Input parameter value was invalid. |
|---|
| 290 | BERR_OUT_OF_SYSTEM_MEMORY - Unable to allocate memory for the handle. |
|---|
| 291 | BERR_OUT_OF_DEVICE_MEMORY - Unable to allocate memory for the |
|---|
| 292 | palette entries themselves. |
|---|
| 293 | |
|---|
| 294 | See Also: |
|---|
| 295 | BSUR_Palette_Destroy |
|---|
| 296 | BSUR_Surface_Create |
|---|
| 297 | ****************************************************************************/ |
|---|
| 298 | BERR_Code BSUR_Palette_Create( |
|---|
| 299 | BMEM_Handle hMem, /* [in] Handle to BMEM module */ |
|---|
| 300 | uint32_t ulNumEntries, /* [in] Number of palette entries */ |
|---|
| 301 | void *pvPaletteAddress, /* [in] Pointer to first palette entry */ |
|---|
| 302 | BPXL_Format eFormat, /* [in] Format of palette */ |
|---|
| 303 | uint32_t ulConstraintMask, /* [in] Constraint mask */ |
|---|
| 304 | BSUR_Palette_Handle *phPalette /* [out] Pointer to palette handle */ |
|---|
| 305 | ); |
|---|
| 306 | |
|---|
| 307 | /*************************************************************************** |
|---|
| 308 | Summary: |
|---|
| 309 | Destroys a created palette. |
|---|
| 310 | |
|---|
| 311 | Description: |
|---|
| 312 | If the palette memory was allocated by the surface module it will be |
|---|
| 313 | freed. |
|---|
| 314 | |
|---|
| 315 | The user should call this function only after all modules are no |
|---|
| 316 | longer using this palette. |
|---|
| 317 | |
|---|
| 318 | Failing to destroy all created palettes will result in an error when |
|---|
| 319 | the module is closed with BSUR_Close. |
|---|
| 320 | |
|---|
| 321 | Returns: |
|---|
| 322 | BERR_SUCCESS - Palette was successfully destroyed. |
|---|
| 323 | |
|---|
| 324 | See Also: |
|---|
| 325 | BSUR_Palette_Create |
|---|
| 326 | BSUR_Close |
|---|
| 327 | ****************************************************************************/ |
|---|
| 328 | BERR_Code BSUR_Palette_Destroy( |
|---|
| 329 | BSUR_Palette_Handle hPalette /* [in] Handle of palette to destroy */ |
|---|
| 330 | ); |
|---|
| 331 | |
|---|
| 332 | /*************************************************************************** |
|---|
| 333 | Summary: |
|---|
| 334 | Returns the constraint mask associated with the palette. |
|---|
| 335 | |
|---|
| 336 | Description: |
|---|
| 337 | The constraint mask is a bit mask describing which restrictions |
|---|
| 338 | were put on the properties of the palette when it was created. |
|---|
| 339 | |
|---|
| 340 | Returns: |
|---|
| 341 | BERR_SUCCESS - Returned Constraint mask is valid. |
|---|
| 342 | |
|---|
| 343 | See Also: |
|---|
| 344 | BSUR_Palette_Create |
|---|
| 345 | ****************************************************************************/ |
|---|
| 346 | BERR_Code BSUR_Palette_GetConstraintMask( |
|---|
| 347 | BSUR_Palette_Handle hSurface, /* [in] Handle to palette to examine */ |
|---|
| 348 | uint32_t *pulConstraintMask /* [out] Pointer to constraint mask */ |
|---|
| 349 | ); |
|---|
| 350 | |
|---|
| 351 | /*************************************************************************** |
|---|
| 352 | Summary: |
|---|
| 353 | Returns the number of entries in the specified palette. |
|---|
| 354 | |
|---|
| 355 | Description: |
|---|
| 356 | |
|---|
| 357 | Returns: |
|---|
| 358 | BERR_SUCCESS - Returned count is valid. |
|---|
| 359 | ****************************************************************************/ |
|---|
| 360 | BERR_Code BSUR_Palette_GetNumEntries( |
|---|
| 361 | BSUR_Palette_Handle hPalette, /* [in] Handle to palette to examine */ |
|---|
| 362 | uint32_t *pulNumEntries /* [out] Pointer to number of entries */ |
|---|
| 363 | ); |
|---|
| 364 | |
|---|
| 365 | /*************************************************************************** |
|---|
| 366 | Summary: |
|---|
| 367 | Returns the address of the palette entries. |
|---|
| 368 | |
|---|
| 369 | Description: |
|---|
| 370 | The address returned will point to the actual location of the |
|---|
| 371 | palette. The user can use this data to fill in the palette |
|---|
| 372 | with appropriate values. The format of the palette determines |
|---|
| 373 | the type of entries pointed to by this address. |
|---|
| 374 | |
|---|
| 375 | Returns: |
|---|
| 376 | BERR_SUCCESS - Returned address is valid. |
|---|
| 377 | ****************************************************************************/ |
|---|
| 378 | BERR_Code BSUR_Palette_GetAddress( |
|---|
| 379 | BSUR_Palette_Handle hPalette, /* [in] Handle to palette to examine */ |
|---|
| 380 | void **ppvAddress /* [out] Pointer to palette address */ |
|---|
| 381 | ); |
|---|
| 382 | |
|---|
| 383 | /*************************************************************************** |
|---|
| 384 | Summary: |
|---|
| 385 | Returns the offset of the palette. |
|---|
| 386 | |
|---|
| 387 | Returns: |
|---|
| 388 | BERR_SUCCESS - Returned address is valid. |
|---|
| 389 | ****************************************************************************/ |
|---|
| 390 | BERR_Code BSUR_Palette_GetOffset( |
|---|
| 391 | BSUR_Palette_Handle hPalette, /* [in] Handle to palette to examine */ |
|---|
| 392 | uint32_t *pulOffset /* [out] Pointer to palette offset */ |
|---|
| 393 | ); |
|---|
| 394 | |
|---|
| 395 | #define BSUR_Palette_GetEntryFormat BSUR_Palette_GetFormat /* for back compatibility only */ |
|---|
| 396 | /*************************************************************************** |
|---|
| 397 | Summary: |
|---|
| 398 | Returns the pixel format of the palette entries. |
|---|
| 399 | |
|---|
| 400 | Description: |
|---|
| 401 | Currently, the supported pixel formats for palettes entries are |
|---|
| 402 | BPXL_eA8_Y8_Cb8_Cr8 and BPXL_eA8_R8_G8_B8. |
|---|
| 403 | |
|---|
| 404 | Returns: |
|---|
| 405 | BERR_SUCCESS - Returned entry pixel format is valid. |
|---|
| 406 | |
|---|
| 407 | See Also: |
|---|
| 408 | BSUR_Palette_Create |
|---|
| 409 | ****************************************************************************/ |
|---|
| 410 | BERR_Code BSUR_Palette_GetFormat( |
|---|
| 411 | BSUR_Palette_Handle hPalette, /* [in] Handle to palette to examine */ |
|---|
| 412 | BPXL_Format *peEntryFormat /* [out] Pointer to entry format */ |
|---|
| 413 | ); |
|---|
| 414 | |
|---|
| 415 | /*************************************************************************** |
|---|
| 416 | Summary: |
|---|
| 417 | Gets default surface settings. |
|---|
| 418 | |
|---|
| 419 | Description: |
|---|
| 420 | This function gets the default surface settings that can be modified |
|---|
| 421 | and used when creating a surface. The surface will adopt the specified |
|---|
| 422 | settings when created. |
|---|
| 423 | |
|---|
| 424 | Returns: |
|---|
| 425 | BERR_SUCCESS - Returned settings are valid. |
|---|
| 426 | |
|---|
| 427 | See Also: |
|---|
| 428 | BSUR_Surface_Create, |
|---|
| 429 | BSUR_Surface_Settings, |
|---|
| 430 | BSUR_TestFeature1_Settings |
|---|
| 431 | ****************************************************************************/ |
|---|
| 432 | BERR_Code BSUR_Surface_GetDefaultSettings( |
|---|
| 433 | BSUR_Surface_Settings *pDefSettings /* [out] Ptr to default settings */ |
|---|
| 434 | ); |
|---|
| 435 | |
|---|
| 436 | /*************************************************************************** |
|---|
| 437 | Summary: |
|---|
| 438 | Creates a surface. |
|---|
| 439 | |
|---|
| 440 | Description: |
|---|
| 441 | There are two ways to create a surface: |
|---|
| 442 | |
|---|
| 443 | o Module allocated pixels: The user doesn't provide a pixel address, |
|---|
| 444 | flagging the function to allocate memory from the surface module's |
|---|
| 445 | memory heap. The user may specify a pitch value to use for this |
|---|
| 446 | allocation or specify zero if they wish the function to calculate |
|---|
| 447 | the pitch. When the surface is destroyed this pixel memory will be |
|---|
| 448 | freed by the module. This memory is considered to be uninitialized |
|---|
| 449 | after creation. |
|---|
| 450 | |
|---|
| 451 | o User allocated pixels: The user provides a pixel address, flagging |
|---|
| 452 | that no memory should be allocated by the module. Instead, the |
|---|
| 453 | function should use the memory provided. When this option is |
|---|
| 454 | given the supplied pitch cannot be zero. When the surface is |
|---|
| 455 | destroyed the provided pixel memory will not be freed. |
|---|
| 456 | |
|---|
| 457 | If the surface format requires a palette, a handle to one must be |
|---|
| 458 | provided to this function. If the surface's format does not require |
|---|
| 459 | a palette handle, the provided palette handle must be NULL. |
|---|
| 460 | |
|---|
| 461 | The constraint mask is a bit mask describing which restrictions |
|---|
| 462 | should be put on the properties of the surface when creating it. |
|---|
| 463 | Currently the valid constraints for this function are |
|---|
| 464 | BSUR_CONSTRAINT_ADDRESS_PIXEL_ALIGNED, BSUR_CONSTRAINT_WIDTH_POWER_2, |
|---|
| 465 | and BSUR_CONSTRAINT_HEIGHT_POWER_2. |
|---|
| 466 | |
|---|
| 467 | Returns: |
|---|
| 468 | BERR_SUCCESS - Surface was successfully created. |
|---|
| 469 | BERR_INVALID_PARAMETER - Input parameter value was invalid. |
|---|
| 470 | BERR_OUT_OF_SYSTEM_MEMORY - Unable to allocate memory for the handle. |
|---|
| 471 | BERR_OUT_OF_DEVICE_MEMORY - Unable to allocate memory for the surface |
|---|
| 472 | itself. |
|---|
| 473 | |
|---|
| 474 | See Also: |
|---|
| 475 | BSUR_Surface_Destroy |
|---|
| 476 | ****************************************************************************/ |
|---|
| 477 | BERR_Code BSUR_Surface_Create( |
|---|
| 478 | BMEM_Handle hMem, /* [in] Handle to BMEM module */ |
|---|
| 479 | uint32_t ulWidth, /* [in] Width of surface in pixels */ |
|---|
| 480 | uint32_t ulHeight, /* [in] Height of surface in pixels */ |
|---|
| 481 | uint32_t ulPitch, /* [in] Pitch of surface in bytes */ |
|---|
| 482 | void *pvPixelAddress, /* [in] Pointer surface's first pixel */ |
|---|
| 483 | BPXL_Format eFormat, /* [in] Pixel format of surface */ |
|---|
| 484 | BSUR_Palette_Handle hPalette, /* [in] Palette to associate with */ |
|---|
| 485 | uint32_t ulConstraintMask, /* [in] Constraint mask */ |
|---|
| 486 | BSUR_Surface_Settings *pSettings,/* [in] Extended settings, can be NULL*/ |
|---|
| 487 | BSUR_Surface_Handle *phSurface /* [out] Pointer to surface handle */ |
|---|
| 488 | ); |
|---|
| 489 | |
|---|
| 490 | /*************************************************************************** |
|---|
| 491 | Summary: |
|---|
| 492 | Destroys the provided surface. |
|---|
| 493 | |
|---|
| 494 | Description: |
|---|
| 495 | If the pixel memory was allocated by the surface module it will be |
|---|
| 496 | freed. Associated palette handles are left untouched. |
|---|
| 497 | |
|---|
| 498 | The user should call this function only after all modules are no |
|---|
| 499 | longer using this surface. |
|---|
| 500 | |
|---|
| 501 | Failing to destroy all created surfaces will result in an error |
|---|
| 502 | when the module is closed with BSUR_Close. |
|---|
| 503 | |
|---|
| 504 | Returns: |
|---|
| 505 | BERR_SUCCESS - Palette was successfully destroyed. |
|---|
| 506 | |
|---|
| 507 | See Also: |
|---|
| 508 | BSUR_Surface_Create |
|---|
| 509 | ****************************************************************************/ |
|---|
| 510 | BERR_Code BSUR_Surface_Destroy( |
|---|
| 511 | BSUR_Surface_Handle hSurface /* [in] Handle to surface to destroy */ |
|---|
| 512 | ); |
|---|
| 513 | |
|---|
| 514 | /*************************************************************************** |
|---|
| 515 | Summary: |
|---|
| 516 | Sets the palette associated with a given surface. |
|---|
| 517 | |
|---|
| 518 | Description: |
|---|
| 519 | This will be allowed as long as the surface requires a palette and the |
|---|
| 520 | supplied palette contains at least the number of required entries. |
|---|
| 521 | |
|---|
| 522 | Returns: |
|---|
| 523 | BERR_SUCCESS - Surface's palette was successfully changed. |
|---|
| 524 | BERR_INVALID_PARAMETER - Input parameter value was invalid. |
|---|
| 525 | ****************************************************************************/ |
|---|
| 526 | BERR_Code BSUR_Surface_SetPalette( |
|---|
| 527 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface */ |
|---|
| 528 | BSUR_Palette_Handle hPalette /* [in] Handle to palette */ |
|---|
| 529 | ); |
|---|
| 530 | |
|---|
| 531 | /*************************************************************************** |
|---|
| 532 | Summary: |
|---|
| 533 | Returns the pixel width and height of a given surface. |
|---|
| 534 | |
|---|
| 535 | Description: |
|---|
| 536 | Gets the width and height of the supplied surface. |
|---|
| 537 | |
|---|
| 538 | Returns: |
|---|
| 539 | BERR_SUCCESS - Returned dimensions are valid.: |
|---|
| 540 | |
|---|
| 541 | See Also: |
|---|
| 542 | BSUR_Surface_Create |
|---|
| 543 | ****************************************************************************/ |
|---|
| 544 | BERR_Code BSUR_Surface_GetDimensions( |
|---|
| 545 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface to examine */ |
|---|
| 546 | uint32_t *pulWidth, /* [out] Pointer to width in pixels*/ |
|---|
| 547 | uint32_t *pulHeight /* [out] Pointer to height in pixels */ |
|---|
| 548 | ); |
|---|
| 549 | |
|---|
| 550 | /*************************************************************************** |
|---|
| 551 | Summary: |
|---|
| 552 | Returns the palette associated with a surface. |
|---|
| 553 | |
|---|
| 554 | Description: |
|---|
| 555 | If the surface does not have a palette associated with it, this |
|---|
| 556 | function will return an error. |
|---|
| 557 | |
|---|
| 558 | Returns: |
|---|
| 559 | BERR_SUCCESS - Returned palette handle is valid. |
|---|
| 560 | BERR_INVALID_PARAMETER - Surface does not contain a palette. |
|---|
| 561 | ****************************************************************************/ |
|---|
| 562 | BERR_Code BSUR_Surface_GetPalette( |
|---|
| 563 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface to examine */ |
|---|
| 564 | BSUR_Palette_Handle *phPalette /* [out] Pointer to palette handle */ |
|---|
| 565 | ); |
|---|
| 566 | |
|---|
| 567 | /*************************************************************************** |
|---|
| 568 | Summary: |
|---|
| 569 | Returns the Constraint mask associated with the surface. |
|---|
| 570 | |
|---|
| 571 | Description: |
|---|
| 572 | The constraint mask is a bit mask describing which restrictions |
|---|
| 573 | were put on the properties of the surface when it was created. |
|---|
| 574 | |
|---|
| 575 | Returns: |
|---|
| 576 | BERR_SUCCESS - Returned Constraint mask is valid. |
|---|
| 577 | ****************************************************************************/ |
|---|
| 578 | BERR_Code BSUR_Surface_GetConstraintMask( |
|---|
| 579 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface to examine */ |
|---|
| 580 | uint32_t *pulConstraintMask /* [out] Pointer to constraint mask */ |
|---|
| 581 | ); |
|---|
| 582 | |
|---|
| 583 | /*************************************************************************** |
|---|
| 584 | Summary: |
|---|
| 585 | Returns information about pixel memory. |
|---|
| 586 | |
|---|
| 587 | Description: |
|---|
| 588 | Returns pixel address and pitch of surface. |
|---|
| 589 | |
|---|
| 590 | Returns: |
|---|
| 591 | BERR_SUCCESS - Returned information is valid.: |
|---|
| 592 | ****************************************************************************/ |
|---|
| 593 | BERR_Code BSUR_Surface_GetAddress( |
|---|
| 594 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface to examine */ |
|---|
| 595 | void **ppvPixelAddress, /* [out] Pointer to pixel address */ |
|---|
| 596 | uint32_t *pulPitch /* [out] Pointer to pitch in bytes */ |
|---|
| 597 | ); |
|---|
| 598 | |
|---|
| 599 | /*************************************************************************** |
|---|
| 600 | Summary: |
|---|
| 601 | Returns information about pixel memory at isr. |
|---|
| 602 | |
|---|
| 603 | Description: |
|---|
| 604 | Returns pixel address and pitch of surface. |
|---|
| 605 | |
|---|
| 606 | Returns: |
|---|
| 607 | BERR_SUCCESS - Returned information is valid.: |
|---|
| 608 | |
|---|
| 609 | See Also: |
|---|
| 610 | BSUR_Surface_GetAddress |
|---|
| 611 | ****************************************************************************/ |
|---|
| 612 | #define BSUR_Surface_GetAddress_isr(hSurface, ppvPixelAddress, pulPitch) \ |
|---|
| 613 | BSUR_Surface_GetAddress(hSurface, ppvPixelAddress, pulPitch) |
|---|
| 614 | |
|---|
| 615 | /*************************************************************************** |
|---|
| 616 | Summary: |
|---|
| 617 | Returns the offset of the surface. |
|---|
| 618 | |
|---|
| 619 | Returns: |
|---|
| 620 | BERR_SUCCESS - Returned address is valid. |
|---|
| 621 | ****************************************************************************/ |
|---|
| 622 | BERR_Code BSUR_Surface_GetOffset( |
|---|
| 623 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface to examine */ |
|---|
| 624 | uint32_t *pulOffset /* [out] Pointer to surface offset */ |
|---|
| 625 | ); |
|---|
| 626 | |
|---|
| 627 | /*************************************************************************** |
|---|
| 628 | Summary: |
|---|
| 629 | Returns offset of surface at isr. |
|---|
| 630 | |
|---|
| 631 | Returns: |
|---|
| 632 | BERR_SUCCESS - Returned information is valid.: |
|---|
| 633 | ****************************************************************************/ |
|---|
| 634 | #define BSUR_Surface_GetOffset_isr(hSurface, pulOffset) \ |
|---|
| 635 | BSUR_Surface_GetOffset(hSurface, pulOffset) |
|---|
| 636 | |
|---|
| 637 | /*************************************************************************** |
|---|
| 638 | Summary: |
|---|
| 639 | Returns pixel format for the surface. |
|---|
| 640 | |
|---|
| 641 | Description: |
|---|
| 642 | |
|---|
| 643 | Returns: |
|---|
| 644 | BERR_SUCCESS - Returned information is valid.: |
|---|
| 645 | ****************************************************************************/ |
|---|
| 646 | BERR_Code BSUR_Surface_GetFormat( |
|---|
| 647 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface to examine */ |
|---|
| 648 | BPXL_Format *peFormat /* [out] Pointer to pixel format */ |
|---|
| 649 | ); |
|---|
| 650 | |
|---|
| 651 | /*************************************************************************** |
|---|
| 652 | Summary: |
|---|
| 653 | Returns packet blit information for the surface. |
|---|
| 654 | |
|---|
| 655 | Description: |
|---|
| 656 | |
|---|
| 657 | Returns: |
|---|
| 658 | BERR_SUCCESS - Returned information is valid.: |
|---|
| 659 | ****************************************************************************/ |
|---|
| 660 | BERR_Code BSUR_Surface_GetPacketBlitInfo( |
|---|
| 661 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface to examine */ |
|---|
| 662 | BPXL_Format *peFormat, /* [out] Pointer to pixel format */ |
|---|
| 663 | uint32_t *pulOffset, /* [out] Pointer to surface offset */ |
|---|
| 664 | uint32_t *pulPitch, /* [out] Pointer to pitch in bytes */ |
|---|
| 665 | uint32_t *pulWidth, /* [out] Pointer to width in pixels*/ |
|---|
| 666 | uint32_t *pulHeight /* [out] Pointer to height in pixels*/ |
|---|
| 667 | ); |
|---|
| 668 | |
|---|
| 669 | /*************************************************************************** |
|---|
| 670 | Summary: |
|---|
| 671 | Returns ID for the surface. |
|---|
| 672 | |
|---|
| 673 | Description: |
|---|
| 674 | |
|---|
| 675 | Returns: |
|---|
| 676 | BERR_SUCCESS - Returned information is valid.: |
|---|
| 677 | ****************************************************************************/ |
|---|
| 678 | BERR_Code BSUR_Surface_GetID( |
|---|
| 679 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface to examine */ |
|---|
| 680 | uint32_t *pulID /* [out] Pointer to ID */ |
|---|
| 681 | ); |
|---|
| 682 | |
|---|
| 683 | /*************************************************************************** |
|---|
| 684 | Summary: |
|---|
| 685 | Sets ID for the surface. |
|---|
| 686 | |
|---|
| 687 | Description: |
|---|
| 688 | Can only be set when current ID is zero (uninitialized). |
|---|
| 689 | |
|---|
| 690 | Returns: |
|---|
| 691 | BERR_SUCCESS - Returned information is valid.: |
|---|
| 692 | ****************************************************************************/ |
|---|
| 693 | BERR_Code BSUR_Surface_SetID( |
|---|
| 694 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface to examine */ |
|---|
| 695 | uint32_t ulID /* [in] Surface ID */ |
|---|
| 696 | ); |
|---|
| 697 | |
|---|
| 698 | /*************************************************************************** |
|---|
| 699 | Summary: |
|---|
| 700 | Gets surface TestFeature1 settings. |
|---|
| 701 | |
|---|
| 702 | Description: |
|---|
| 703 | This function gets the surface TestFeature1 settings that can be |
|---|
| 704 | specified through the BSUR_Surface_Settings structure when creating |
|---|
| 705 | a surface. |
|---|
| 706 | |
|---|
| 707 | Returns: |
|---|
| 708 | BERR_SUCCESS - Returned settings are valid. |
|---|
| 709 | |
|---|
| 710 | See Also: |
|---|
| 711 | BSUR_Surface_Create, |
|---|
| 712 | BSUR_Surface_Settings, |
|---|
| 713 | BSUR_TestFeature1_Settings, |
|---|
| 714 | BSUR_Surface_SetTestFeature1 |
|---|
| 715 | ****************************************************************************/ |
|---|
| 716 | BERR_Code BSUR_Surface_GetTestFeature1( |
|---|
| 717 | BSUR_Surface_Handle hSurface, /* [in] Handle to surface to examine */ |
|---|
| 718 | BSUR_TestFeature1_Settings *pTestFeature1Settings /* [out] Ptr to TestFeature1 settings */ |
|---|
| 719 | ); |
|---|
| 720 | |
|---|
| 721 | #ifdef __cplusplus |
|---|
| 722 | } |
|---|
| 723 | #endif |
|---|
| 724 | |
|---|
| 725 | #endif /* #ifndef BSUR_H__ */ |
|---|
| 726 | |
|---|
| 727 | /* end of file */ |
|---|