| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2006, 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: $ |
|---|
| 11 | * $brcm_Revision: $ |
|---|
| 12 | * $brcm_Date: $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: $ |
|---|
| 19 | * |
|---|
| 20 | ***************************************************************************/ |
|---|
| 21 | |
|---|
| 22 | #ifndef BSETTOP_GRAPHICS_H__ |
|---|
| 23 | #define BSETTOP_GRAPHICS_H__ |
|---|
| 24 | |
|---|
| 25 | #include "bsettop_types.h" |
|---|
| 26 | /* |
|---|
| 27 | Summary: |
|---|
| 28 | For non-palettized surfaces, this is a ARGB8888 pixel. When |
|---|
| 29 | used, it will be converted into the desired pixel for a surface. |
|---|
| 30 | For palettized surfaces, this is the palette index plus possible alpha value. |
|---|
| 31 | |
|---|
| 32 | Description: |
|---|
| 33 | For palette indexes, values should be packed into the least significant bits |
|---|
| 34 | of bgraphics_pixel. For instance, a8_palette8 uses byte[0] for the palette8 index, |
|---|
| 35 | byte[1] for alpha8 value and ignores byte[2] and byte[3]. |
|---|
| 36 | palette2 uses bits 0 and 1 of byte[0] and ignores the rest. |
|---|
| 37 | */ |
|---|
| 38 | typedef uint32_t bgraphics_pixel; |
|---|
| 39 | |
|---|
| 40 | /* |
|---|
| 41 | Summary: |
|---|
| 42 | Pixel format of a surface. |
|---|
| 43 | 75xx Note, to utilize dual HD,SD output the SD plane |
|---|
| 44 | has no color space converter and only supports 16bpp or |
|---|
| 45 | palette4 format. For the HD and SD display to share the same |
|---|
| 46 | graphics plane one of these two formats must be used for for |
|---|
| 47 | the HD OSD also. |
|---|
| 48 | */ |
|---|
| 49 | typedef enum bgraphics_pixel_format { |
|---|
| 50 | bgraphics_pixel_format_r5_g6_b5, /* 16-bit, no per-pixel alpha */ |
|---|
| 51 | bgraphics_pixel_format_a1_r5_g5_b5, /* 16-bit */ |
|---|
| 52 | bgraphics_pixel_format_r5_g5_b5_a1, /* 16-bit */ |
|---|
| 53 | bgraphics_pixel_format_a4_r4_g4_b4, /* 16-bit */ |
|---|
| 54 | bgraphics_pixel_format_r4_g4_b4_a4, /* 16-bit */ |
|---|
| 55 | bgraphics_pixel_format_a8_r8_g8_b8, /* 32-bit */ |
|---|
| 56 | |
|---|
| 57 | bgraphics_pixel_format_palette8, /* 8-bit Palette index */ |
|---|
| 58 | bgraphics_pixel_format_a8_palette8, /* A8 and 8-bit Palette index */ |
|---|
| 59 | |
|---|
| 60 | bgraphics_pixel_format_a0, /* 0-bit surface (constant color, constant alpha) */ |
|---|
| 61 | bgraphics_pixel_format_a8, /* 8-bit alpha-only surface (constant color) */ |
|---|
| 62 | |
|---|
| 63 | bgraphics_pixel_format_y08_cb8_y18_cr8, /* 32-bit Y0_8 Cb_8 Y1_8 Cr_8 */ |
|---|
| 64 | bgraphics_pixel_format_cr8_y18_cb8_y08, /* 32-bit Cr_8 Y1_8 Cb_8 Y0_8 */ |
|---|
| 65 | |
|---|
| 66 | bgraphics_pixel_format_video_tunnel, /* 0-bit tunnel to video. Use to allow video to show through graphics |
|---|
| 67 | without chromakey and without per-pixel alpha. */ |
|---|
| 68 | bgraphics_pixel_format_palette2, /* 2-bit palette index */ |
|---|
| 69 | bgraphics_pixel_format_palette4 /* 4-bit palette index */ |
|---|
| 70 | |
|---|
| 71 | } bgraphics_pixel_format; |
|---|
| 72 | |
|---|
| 73 | /* |
|---|
| 74 | Summary: |
|---|
| 75 | A palette of colors to be used with palettized surfaces. |
|---|
| 76 | */ |
|---|
| 77 | typedef struct bgraphics_palette { |
|---|
| 78 | const bgraphics_pixel *palette; /* [size_is(length)] */ |
|---|
| 79 | unsigned length; |
|---|
| 80 | } bgraphics_palette; |
|---|
| 81 | |
|---|
| 82 | /* |
|---|
| 83 | Summary: |
|---|
| 84 | Universal settings for a graphics engine. |
|---|
| 85 | */ |
|---|
| 86 | typedef struct bgraphics_settings{ |
|---|
| 87 | bgraphics_pixel_format format; /* OSD graphics format*/ |
|---|
| 88 | } bgraphics_settings; |
|---|
| 89 | |
|---|
| 90 | /* |
|---|
| 91 | Summary: |
|---|
| 92 | Graphics engine handle returned by bgraphics_open. |
|---|
| 93 | */ |
|---|
| 94 | typedef struct bgraphics *bgraphics_t; |
|---|
| 95 | |
|---|
| 96 | typedef enum bgraphics_id { |
|---|
| 97 | eGRAPHICS_HD = 0x01, |
|---|
| 98 | eGRAPHICS_SD = 0x02, |
|---|
| 99 | eGRAPHICS_BOTH = (eGRAPHICS_HD|eGRAPHICS_SD), |
|---|
| 100 | } bgraphics_id; |
|---|
| 101 | |
|---|
| 102 | #ifdef __cplusplus |
|---|
| 103 | extern "C" |
|---|
| 104 | { |
|---|
| 105 | #endif |
|---|
| 106 | |
|---|
| 107 | /** |
|---|
| 108 | Summary: |
|---|
| 109 | Open and enable a graphic output. Surfaces will be created |
|---|
| 110 | to support output in the currently configured graphics |
|---|
| 111 | format (see bgraphics_set). |
|---|
| 112 | */ |
|---|
| 113 | bgraphics_t bgraphics_open( |
|---|
| 114 | bobject_t id, /* not used */ |
|---|
| 115 | bdisplay_t display /* display on which the graphics are displayed */ |
|---|
| 116 | ); |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | /* |
|---|
| 120 | Summary: |
|---|
| 121 | Close and release resources. |
|---|
| 122 | */ |
|---|
| 123 | void bgraphics_close( |
|---|
| 124 | bgraphics_t graphics /* handle returned by bgraphics_open */ |
|---|
| 125 | ); |
|---|
| 126 | |
|---|
| 127 | /** |
|---|
| 128 | Summary: |
|---|
| 129 | Get current graphics settings. |
|---|
| 130 | **/ |
|---|
| 131 | void bgraphics_get( |
|---|
| 132 | bgraphics_settings *settings /* [out] */ |
|---|
| 133 | ); |
|---|
| 134 | |
|---|
| 135 | /** |
|---|
| 136 | Summary: |
|---|
| 137 | Set graphics settings. |
|---|
| 138 | **/ |
|---|
| 139 | bresult bgraphics_set( |
|---|
| 140 | const bgraphics_settings *settings |
|---|
| 141 | ); |
|---|
| 142 | |
|---|
| 143 | /** |
|---|
| 144 | Summary: |
|---|
| 145 | Block until vsync. |
|---|
| 146 | **/ |
|---|
| 147 | |
|---|
| 148 | bresult bgraphics_sync( |
|---|
| 149 | bgraphics_t g, /* handle returned by bgraphics_open */ |
|---|
| 150 | bool overlay /* overlay is popped or not */ |
|---|
| 151 | ); |
|---|
| 152 | |
|---|
| 153 | /** |
|---|
| 154 | * Summary: |
|---|
| 155 | * update HD or SD or both frame buffer |
|---|
| 156 | **/ |
|---|
| 157 | bresult bgraphics_sync_partial( |
|---|
| 158 | bgraphics_t g, /* handle returned by bgraphics_open */ |
|---|
| 159 | bgraphics_id id, |
|---|
| 160 | bool overlay /* overlay is popped or not */ |
|---|
| 161 | ); |
|---|
| 162 | |
|---|
| 163 | /* |
|---|
| 164 | Summary: |
|---|
| 165 | Get the graphics framebuffer parameters |
|---|
| 166 | */ |
|---|
| 167 | bresult bgraphics_get_framebuffer( |
|---|
| 168 | bgraphics_t graphics, /* handle returned by bgraphics_open */ |
|---|
| 169 | void **buffer, /* [out] address of framebuffer memory */ |
|---|
| 170 | unsigned int **palette, /* [out] address of palette */ |
|---|
| 171 | int *width, /* [out] width of the OSD surface */ |
|---|
| 172 | int *height, /* [out] height of the OSD surface */ |
|---|
| 173 | int *pitch /* [out] pitch of the OSD surface */ |
|---|
| 174 | ); |
|---|
| 175 | |
|---|
| 176 | |
|---|
| 177 | /* |
|---|
| 178 | Summary: |
|---|
| 179 | Reload the graphics palette |
|---|
| 180 | */ |
|---|
| 181 | bresult bgraphics_load_palette( |
|---|
| 182 | bgraphics_t g /* handle returned by bgraphics_open */ |
|---|
| 183 | ); |
|---|
| 184 | |
|---|
| 185 | |
|---|
| 186 | bresult bgraphics_get_osd_params(bgraphics_t graphics, |
|---|
| 187 | bsettop_surf_t *p_osd_surf, |
|---|
| 188 | void **osd_buffer, |
|---|
| 189 | bsettop_surf_t *p_overlay_surf, |
|---|
| 190 | void **overlay_mem); |
|---|
| 191 | |
|---|
| 192 | bresult bsurface_create_surface(uint32_t width, |
|---|
| 193 | uint32_t height, |
|---|
| 194 | bgraphics_pixel_format format, |
|---|
| 195 | uint8_t **mem, |
|---|
| 196 | uint32_t *pitch, |
|---|
| 197 | bsettop_surf_t *p_settop_surf); |
|---|
| 198 | bresult bsurface_fill(bsettop_surf_t surface, |
|---|
| 199 | bsettop_rect *rect, |
|---|
| 200 | bgraphics_pixel pixel); |
|---|
| 201 | bresult bsurface_blit_surface(bsettop_surf_t src_surf, bsettop_rect *src_r, |
|---|
| 202 | bsettop_surf_t dst_surf, bsettop_rect *dst_r, |
|---|
| 203 | bsettop_surf_t out_surf, bsettop_rect *out_r); |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | #ifdef __cplusplus |
|---|
| 207 | } |
|---|
| 208 | #endif |
|---|
| 209 | |
|---|
| 210 | #endif /* BSETTOP_GRAPHICS_H__ */ |
|---|