source: svn/trunk/newcon3bcm2_21bu/nexus/modules/surface/7552/include/nexus_surface.h

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 14.1 KB
Line 
1/***************************************************************************
2 *     (c)2007-2011 Broadcom Corporation
3 *
4 *  This program is the proprietary software of Broadcom Corporation and/or its licensors,
5 *  and may only be used, duplicated, modified or distributed pursuant to the terms and
6 *  conditions of a separate, written license agreement executed between you and Broadcom
7 *  (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants
8 *  no license (express or implied), right to use, or waiver of any kind with respect to the
9 *  Software, and Broadcom expressly reserves all rights in and to the Software and all
10 *  intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU
11 *  HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY
12 *  NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE.
13 *
14 *  Except as expressly set forth in the Authorized License,
15 *
16 *  1.     This program, including its structure, sequence and organization, constitutes the valuable trade
17 *  secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof,
18 *  and to use this information only in connection with your use of Broadcom integrated circuit products.
19 *
20 *  2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
21 *  AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
22 *  WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
23 *  THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
24 *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
25 *  LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
26 *  OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
27 *  USE OR PERFORMANCE OF THE SOFTWARE.
28 *
29 *  3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
30 *  LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
31 *  EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
32 *  USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
33 *  THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
34 *  ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
35 *  LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
36 *  ANY LIMITED REMEDY.
37 *
38 * $brcm_Workfile: nexus_surface.h $
39 * $brcm_Revision: 22 $
40 * $brcm_Date: 3/8/11 5:11p $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /nexus/modules/surface/7400/include/nexus_surface.h $
47 *
48 * 22   3/8/11 5:11p erickson
49 * SW7420-1575: add NEXUS_Surface_InitPlane for packet blit verification
50 *
51 * 21   2/3/11 6:37p vsilyaev
52 * SW7420-1441: Use local (non proxied) implementation for function that
53 *  flush CPU cache
54 *
55 * 20   10/22/10 2:47p erickson
56 * SW7420-1205: deprecate NEXUS_SurfaceSettings.autoFlush because of
57 *  inherent performance problems
58 *
59 * 19   10/7/10 11:04a erickson
60 * SW7420-1148: add destructor hint
61 *
62 * 18   8/6/10 1:08p erickson
63 * SW7420-703: NEXUS_Surface_GetCreateSettings
64 *
65 * 17   6/23/10 12:14p erickson
66 * SW7550-453: add nexus_striped_surface.h interface
67 *
68 * 16   1/21/10 9:54a erickson
69 * SW7405-3787: add comments to NEXUS_Surface_Flush re: cache coherency
70 *  problems caused by the RAC
71 *
72 * 15   3/31/09 10:05a erickson
73 * PR53661: remove NEXUS_SurfaceSettings.constantColor. it was unused. the
74 *  intended functionality can be accomplished using the constantColor in
75 *  NEXUS_Graphics2DBlitSettings.
76 *
77 * 14   1/30/09 4:26p erickson
78 * PR46300: removed NEXUS_Surface_CreateSpecial
79 *
80 * 13   1/13/09 6:11p erickson
81 * PR46300: added NEXUS_Surface_CreateSpecial
82 *
83 * 12   12/30/08 9:17a erickson
84 * PR50743: added NEXUS_SurfaceCreateSettings.pPaletteMemory
85 *
86 * 11   11/26/08 9:59a erickson
87 * PR49649: added NEXUS_SurfaceCreateSettings.heap option
88 *
89 * 10   10/31/08 12:26p erickson
90 * PR48586: update comment
91 *
92 * 9   8/28/08 10:42a erickson
93 * PR46111: add palettePixelFormat
94 *
95 * 8   8/21/08 5:14p erickson
96 * PR45941: added NEXUS_StripedSurface_GetStatus
97 *
98 * 7   4/30/08 10:52a erickson
99 * PR35457: improve Surface comments. move general items to nexus_types.h.
100 *
101 * 6   3/26/08 12:51p erickson
102 * PR40567: moved NEXUS_PixelFormat to nexus_types.h
103 *
104 * PR40567/2   3/26/08 6:23p dyzhang
105 * PR40567: move NEXUS_PixelFormat from nexus_surface.h to nexus_types.h
106 *
107 * PR40567/1   3/26/08 4:26p xhuang
108 * PR40567:add pixel format set in Nexus
109 *
110 * 5   2/21/08 1:44p erickson
111 * PR39786: add pixel format macros
112 *
113 * 4   1/30/08 4:59p erickson
114 * PR36808: move NEXUS_Pixel to Base
115 *
116 * 3   1/28/08 12:33p vsilyaev
117 * PR 38682: Added support for attribute tags applied to structure
118 *  members.
119 *
120 * 2   1/23/08 9:46a erickson
121 * PR35198: clarify comments
122 *
123 * 1   1/18/08 2:15p jgarrett
124 * PR 38808: Merging to main branch
125 *
126 **************************************************************************/
127#ifndef NEXUS_SURFACE_H__
128#define NEXUS_SURFACE_H__
129
130#include "nexus_types.h"
131#include "bm2mc_packet.h"
132
133#ifdef __cplusplus
134extern "C" {
135#endif
136
137/*=*******************************************
138The Surface module allows the creation and management of graphics surfaces in memory.
139These surfaces can be used by other Modules such as Graphics2D, Display, VideoDecoder and PictureDecoder.
140*********************************************/
141
142/**
143Summary:
144Handle for the Surface interface.
145
146Description:
147A graphics surface is a block of memory with various properties include width, height, pitch, and pixel format.
148
149See Also:
150NEXUS_Surface_GetMemory - used for host to write directly to memory
151NEXUS_Display_SetGraphicsFramebuffer - set the current graphics framebuffer
152NEXUS_Graphics2DFillSettings - fill a surface with a pixel
153NEXUS_Graphics2DBlitSettings - blit from one surface to another
154**/
155typedef struct NEXUS_Surface *NEXUS_SurfaceHandle;
156
157/*
158Summary:
159Information about the memory used by a surface.
160
161Description:
162Returned by NEXUS_Surface_GetMemory
163*/
164typedef struct NEXUS_SurfaceMemory
165{
166    void *buffer; /*  attr{memory=cached}  Pointer to cached memory. Directly accessible by the application.
167                        This must be typecasted to the correct pixel format. For example
168                        (unsigned short *) for a 16 bit pixel format or (unsigned long *) for a 32 bit pixel format. */
169    unsigned int pitch; /* The memory width of the surface in bytes.
170                            Pitch is based on the number of bytes used for all the pixels in one line along with an optional
171                            padding on the right side. This padding maybe required for a variety of reasons (e.g. word alignment).
172                            Pitch must be used to calculate the next line of the surface.
173                            See the example in the NEXUS_Surface_GetMemory documentation. */
174
175    NEXUS_Pixel *palette; /* attr{memory=cached}  This points to the palette memory for palette pixel formats. Otherwise NULL.
176                             The palette pixel format is always ARGB8888.
177                             The app can update the palette memory directly. After making a change, call NEXUS_Surface_Flush to
178                             flush cached memory. If this surface is the framebuffer, you must also call NEXUS_Display_SetGraphicsFramebuffer
179                             to read the updated palette into the graphics feeder. */
180    unsigned numPaletteEntries; /* number of entries in palette */
181    size_t  bufferSize;     /* size of the surface buffer */
182} NEXUS_SurfaceMemory;
183
184/*
185Summary:
186Settings needed to create a surface.
187
188Description:
189These cannot be changed after the surface has been created.
190For palettized surfaces, a default palette of all black will be created.
191*/
192typedef struct NEXUS_SurfaceCreateSettings
193{
194    NEXUS_PixelFormat pixelFormat; /* pixel format of the surface. */
195    NEXUS_PixelFormat palettePixelFormat; /* pixel format of NEXUS_SurfaceMemory.palette if pixelFormat is a palette format.
196                                             Typically NEXUS_PixelFormat_eA8_R8_G8_B8 or NEXUS_PixelFormat_eA8_Y8_Cb8_Cr8 are supported. */
197    uint16_t width;            /* visible width of the surface in pixels. */
198    uint16_t height;           /* visible height of the surface in pixels. */
199
200    unsigned int alignment;    /* optional buffer alignment specified as a power of 2, measured in bytes.
201                                  0 is no alignment (default), 1 is 2-byte aligned, 2 is 4-byte aligned, etc. */
202
203    unsigned int pitch;        /* optional buffer pitch, measured in bytes. 0 is the default pitch (width * sizeof(pixel)). */
204
205    void *pMemory;             /* attr{memory=cached} Device memory address to use for the surface. Must be allocated using NEXUS_Memory_Allocate().
206                                  If NULL, Nexus will allocate.
207                                  Size of user allocated buffer must be >= height * pitch, where pitch >= width * sizeof(pixel); otherwise there will be a memory overrun. */
208    void *pPaletteMemory;      /* attr{memory=cached} Device memory address to use for the palette. Must be allocated using NEXUS_Memory_Allocate().
209                                  If NULL, Nexus will allocate.
210                                  Size of user allocated buffer must be >= sizeof(NEXUS_Pixel) * expected NEXUS_SurfaceMemory.numPaletteEntries; otherwise there will be a memory overrun.
211                                  Palette memory must be 32 byte aligned. */
212
213    NEXUS_HeapHandle heap;     /* Optional handle for memory heap. If NULL, the surface and palette will be allocated from heap[0]. */
214    unsigned bitsPerPixel;
215} NEXUS_SurfaceCreateSettings;
216
217/*
218Summary:
219Get default settings for the structure.
220
221Description:
222This is required in order to make application code resilient to the addition of new strucutre members in the future.
223
224See Also:
225NEXUS_Surface_Create
226*/
227void NEXUS_Surface_GetDefaultCreateSettings(
228    NEXUS_SurfaceCreateSettings *pCreateSettings /* [out] */
229    );
230
231/**
232Summary:
233Creates a new surface using the create settings.
234
235Description:
236A surface is a block of memory with the properties of height, width, pitch and pixel format.
237
238The user is responsible for call NEXUS_Surface_Destroy for any surface which is created.
239Surfaces are not automatically freed by another Interface.
240
241Memory is allocated from the memory heap provided by the Core module.
242
243This function returns NULL if there is no enough memory for the surface.
244
245See Also:
246NEXUS_Surface_GetDefaultCreateSettings
247NEXUS_Surface_GetCreateSettings
248NEXUS_Surface_Destroy
249**/
250NEXUS_SurfaceHandle NEXUS_Surface_Create( /* attr{destructor=NEXUS_Surface_Destroy}  */
251    const NEXUS_SurfaceCreateSettings *pCreateSettings
252    );
253
254/**
255Summary:
256Destroy a surface and free its resources.
257
258Description:
259This surface should not be currently in use by another module.
260After calling NEXUS_Surface_Destroy, the handle is no longer valid and should not be used.
261
262If you have written to cached memory and have not flushed, you should call NEXUS_Surface_Flush
263before deleting this surface. This cannot be done manually without adversely impacting performance.
264
265See Also:
266NEXUS_Surface_Create
267**/
268void NEXUS_Surface_Destroy(
269    NEXUS_SurfaceHandle surface
270    );
271
272/*
273Summary:
274Get settings used to create the surface.
275
276Description:
277NEXUS_SurfaceCreateSettings.heap will be populated with the default heap if the user passed in NULL.
278*/
279void NEXUS_Surface_GetCreateSettings(
280    NEXUS_SurfaceHandle surface,
281    NEXUS_SurfaceCreateSettings *pCreateSettings /* [out] */
282    );
283
284/**
285Summary:
286Returns information needed for direct memory writes.
287
288Description:
289In order for direct memory writes to be successful, you must know the
290format specified by NEXUS_PixelFormat.
291You cannot assume that pitch == width * sizeof(pixelformat).
292
293Example:
294    //assuming 32bpp surface
295    NEXUS_Surface_GetCreateSettings(surface, &createSettings);
296    NEXUS_Surface_GetMemory(surface, &mem);
297    for (y=0;y<createSettings.height;y++) {
298        for (x=0;x<createSettings.width;x++) {
299            ((uint32_t*)mem.buffer)[y*mem.pitch + x] = value;
300        }
301    }
302    NEXUS_Surface_Flush(surface);
303
304See Also:
305NEXUS_Surface_Flush
306**/
307void NEXUS_Surface_GetMemory(
308    NEXUS_SurfaceHandle surface,
309    NEXUS_SurfaceMemory *pMemory /* [out] */
310    );
311
312/**
313Summary:
314Flush a surface's cached memory and palette
315
316Description:
317If you are doing direct memory writes to the surface, you should flush before doing any hardware read/write
318operations (e.g. Graphics2D blit/fill or setting the Display framebuffer).
319
320Also, if you are doing direct memory reads from a surface, you should also flush after doing any hardwware write
321operations. See the module overview in nexus_dma.h for a full discussion of cache coherency problems caused
322by the RAC (read-ahead cache).
323
324If you have updated the palette and this surface is the framebuffer, you must also call NEXUS_Display_SetGraphicsFramebuffer
325to read the updated palette into the graphics feeder.
326**/
327void NEXUS_Surface_Flush( /* attr{local=true}  */
328    NEXUS_SurfaceHandle surface
329    );
330
331/*
332Summary:
333Settings for a surface returned by NEXUS_Surface_GetSettings.
334*/
335typedef struct NEXUS_SurfaceSettings
336{
337    bool autoFlush; /* deprecated. Minimal cache flush is essential for performance; therefore app should call NEXUS_Surface_Flush manually
338                       and only when needed. See NEXUS_Surface_Flush for notes. */
339} NEXUS_SurfaceSettings;
340
341/**
342Summary:
343Apply NEXUS_SurfaceSettings to a surface.
344**/
345NEXUS_Error NEXUS_Surface_SetSettings(
346    NEXUS_SurfaceHandle surface,
347    const NEXUS_SurfaceSettings *pSettings
348    );
349
350/*
351Summary:
352Get NEXUS_SurfaceSettings for a surface.
353*/
354void NEXUS_Surface_GetSettings(
355    NEXUS_SurfaceHandle surface,
356    NEXUS_SurfaceSettings *pSettings /* [out] */
357    );
358
359/*
360Summary:
361Initialize a BM2MC_PACKET_Plane for use in NEXUS_Graphics2D packet blit\
362
363Description:
364This will set the required address, format and pitch for the blit.
365It will also set the optional width and height so that export NEXUS_GRAPHICS2D_VERIFY_PACKETS=y
366can verify the source, dest and output rectangle bounds.
367*/
368void NEXUS_Surface_InitPlane(
369    NEXUS_SurfaceHandle surface,
370    BM2MC_PACKET_Plane *pPlane /* [out] */
371    );
372
373#ifdef __cplusplus
374}
375#endif
376
377#endif
Note: See TracBrowser for help on using the repository browser.