| 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_graphics2d_destripe.c $ |
|---|
| 39 | * $brcm_Revision: 44 $ |
|---|
| 40 | * $brcm_Date: 5/23/11 4:50p $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Revision History: |
|---|
| 45 | * |
|---|
| 46 | * $brcm_Log: /nexus/modules/graphics2d/7400/src/nexus_graphics2d_destripe.c $ |
|---|
| 47 | * |
|---|
| 48 | * 44 5/23/11 4:50p erickson |
|---|
| 49 | * SW7420-1200: refactor grclib for optimal nexus use |
|---|
| 50 | * |
|---|
| 51 | * 43 10/19/10 12:48p erickson |
|---|
| 52 | * SW35230-1411: fix bottom field destripe |
|---|
| 53 | * |
|---|
| 54 | * 42 8/17/10 4:22p erickson |
|---|
| 55 | * SW7420-928: use NEXUS_VideoBufferType for striped surface |
|---|
| 56 | * |
|---|
| 57 | * 41 8/16/10 11:08a erickson |
|---|
| 58 | * SW7405-3671: add packet blit API. switch to packet-based GRC |
|---|
| 59 | * implementation. |
|---|
| 60 | * |
|---|
| 61 | * 40 6/23/10 12:14p erickson |
|---|
| 62 | * SW7550-453: refactor to use nexus_striped_surface.h interface |
|---|
| 63 | * |
|---|
| 64 | * 39 2/16/10 4:45p nissen |
|---|
| 65 | * SW7405-3671: Fixed build warnings. |
|---|
| 66 | * |
|---|
| 67 | * 38 2/3/10 2:09p nissen |
|---|
| 68 | * SW7405-3671: Added power down to packet destripe blit. |
|---|
| 69 | * |
|---|
| 70 | * 37 1/19/10 4:45p nissen |
|---|
| 71 | * SW7405-3671: Added support for GRC packet blits. |
|---|
| 72 | * |
|---|
| 73 | * 36 11/26/09 3:15p jhaberf |
|---|
| 74 | * SW35230-1: Added 35230 DTV chip support |
|---|
| 75 | * |
|---|
| 76 | * 35 11/19/09 4:21p gmohile |
|---|
| 77 | * SW7408-1 : Add 7408 support |
|---|
| 78 | * |
|---|
| 79 | * 34 10/2/09 6:57p lwhite |
|---|
| 80 | * SW7468-6: Add 7468 support |
|---|
| 81 | * |
|---|
| 82 | * 33 8/19/09 11:13a mward |
|---|
| 83 | * PR55545: Typo, missing (. |
|---|
| 84 | * |
|---|
| 85 | * 32 8/18/09 7:06p mward |
|---|
| 86 | * PR55545: Add 7125 support. |
|---|
| 87 | * |
|---|
| 88 | * 31 8/12/09 11:21a vsilyaev |
|---|
| 89 | * PR 57629: Replaced NEXUS_Surface_AutoFlush_priv with |
|---|
| 90 | * NEXUS_Surface_GetSurfaceAutoFlush_priv |
|---|
| 91 | * |
|---|
| 92 | * 30 8/10/09 6:03p vsilyaev |
|---|
| 93 | * PR 57552: Use tagged tailquee to manage temporary surfaces, traverse |
|---|
| 94 | * list only after user called Checkpoint function |
|---|
| 95 | * |
|---|
| 96 | * 29 8/5/09 4:55p jrubio |
|---|
| 97 | * PR55232: add 7342/7340 support |
|---|
| 98 | * |
|---|
| 99 | * 28 8/4/09 9:42a erickson |
|---|
| 100 | * PR57260: added call to BGRClib_ResetState after direct access to GRC |
|---|
| 101 | * |
|---|
| 102 | * 27 7/29/09 4:18p nickh |
|---|
| 103 | * PR56017: Add 7420B0 support for memory register naming changes |
|---|
| 104 | * |
|---|
| 105 | * 26 6/24/09 1:37p erickson |
|---|
| 106 | * PR55968: added power management |
|---|
| 107 | * |
|---|
| 108 | * 25 3/11/09 9:20a erickson |
|---|
| 109 | * PR53076: support NEXUS_Graphics2D_DestripeToSurface to an RGB surface |
|---|
| 110 | * |
|---|
| 111 | * 24 3/6/09 10:38a erickson |
|---|
| 112 | * PR52859: check return code on BGRC_ResetState |
|---|
| 113 | * |
|---|
| 114 | * 23 2/9/09 12:30p erickson |
|---|
| 115 | * PR51393: fix race condition with BGRC_IssueState and handle- |
|---|
| 116 | * >blitSurfaces |
|---|
| 117 | * |
|---|
| 118 | * 22 2/5/09 4:42p erickson |
|---|
| 119 | * PR51876: fix memory leak |
|---|
| 120 | * |
|---|
| 121 | * 21 2/5/09 4:37p erickson |
|---|
| 122 | * PR51866: fix warning |
|---|
| 123 | * |
|---|
| 124 | * 20 1/26/09 11:30a erickson |
|---|
| 125 | * PR51468: global variable naming convention |
|---|
| 126 | * |
|---|
| 127 | * 19 1/26/09 9:50a erickson |
|---|
| 128 | * PR51393: make NEXUS_Graphics2D_Destripe and NEXUS_Graphics2D_Memset32 |
|---|
| 129 | * asynchronous like all other blits and fills |
|---|
| 130 | * |
|---|
| 131 | * 18 12/3/08 3:05p erickson |
|---|
| 132 | * PR48963: set the stripe width per striped surface. this allows us to |
|---|
| 133 | * support multiple memory controllers and various stripe widths. |
|---|
| 134 | * |
|---|
| 135 | * 17 10/28/08 2:50p erickson |
|---|
| 136 | * PR46066: fix 3548 B0 support |
|---|
| 137 | * |
|---|
| 138 | * 16 10/20/08 9:57a erickson |
|---|
| 139 | * PR46527: extend NEXUS_Graphics2D_DestripeToSurface with optional |
|---|
| 140 | * pTargetRect |
|---|
| 141 | * |
|---|
| 142 | * 13 9/25/08 1:56p erickson |
|---|
| 143 | * PR46066: 3548 B0 support |
|---|
| 144 | * |
|---|
| 145 | * 12 9/8/08 4:12p erickson |
|---|
| 146 | * PR46430: allow destripe to a larger supplied surface |
|---|
| 147 | * |
|---|
| 148 | * 11 9/4/08 12:36p erickson |
|---|
| 149 | * PR46430: added NEXUS_Graphics2D_DestripeToSurface |
|---|
| 150 | * |
|---|
| 151 | * 10 8/14/08 5:26p katrep |
|---|
| 152 | * PR45674: Fix compiiler warning in kernel mode non debug builds |
|---|
| 153 | * |
|---|
| 154 | * 9 6/26/08 8:38a erickson |
|---|
| 155 | * PR44159: impl two pass destripe for workaround |
|---|
| 156 | * |
|---|
| 157 | * 8 5/5/08 2:54p erickson |
|---|
| 158 | * PR40777: handle interlaced stills using M2MC, not software |
|---|
| 159 | * |
|---|
| 160 | * 7 3/19/08 1:17p erickson |
|---|
| 161 | * PR40307: fix systems with single MEMC |
|---|
| 162 | * |
|---|
| 163 | * 6 3/19/08 10:44a erickson |
|---|
| 164 | * PR40307: implemented sw_destripe on 7405 non-uma |
|---|
| 165 | * |
|---|
| 166 | * 5 3/18/08 4:42p erickson |
|---|
| 167 | * PR40307: replaced GetEnv with new internal variable from XVD |
|---|
| 168 | * |
|---|
| 169 | * 4 3/14/08 10:10a erickson |
|---|
| 170 | * PR40316: added temp still_field env variable |
|---|
| 171 | * |
|---|
| 172 | * 3 3/7/08 5:35p erickson |
|---|
| 173 | * PR40307: downgrade WRN to MSG |
|---|
| 174 | * |
|---|
| 175 | * 2 2/28/08 12:00p erickson |
|---|
| 176 | * PR39786: added picMemIndex for 7400 |
|---|
| 177 | * |
|---|
| 178 | * 1 2/25/08 2:59p erickson |
|---|
| 179 | * PR39786: added NEXUS_Graphics2D_Destripe |
|---|
| 180 | * |
|---|
| 181 | **************************************************************************/ |
|---|
| 182 | #include "nexus_graphics2d_module.h" |
|---|
| 183 | #include "nexus_graphics2d_impl.h" |
|---|
| 184 | #include "priv/nexus_core.h" |
|---|
| 185 | #include "priv/nexus_core_video.h" |
|---|
| 186 | |
|---|
| 187 | BDBG_MODULE(nexus_graphics2d_destripe); |
|---|
| 188 | |
|---|
| 189 | /* TODO: sw destripe? two pass destripe? */ |
|---|
| 190 | |
|---|
| 191 | NEXUS_SurfaceHandle NEXUS_Graphics2D_Destripe( NEXUS_Graphics2DHandle handle, NEXUS_StripedSurfaceHandle stripedSurface ) |
|---|
| 192 | { |
|---|
| 193 | NEXUS_SurfaceHandle surface; |
|---|
| 194 | NEXUS_SurfaceCreateSettings surfaceCreateSettings; |
|---|
| 195 | BERR_Code rc = 0; |
|---|
| 196 | NEXUS_StripedSurfaceCreateSettings stripedSurfaceCreateSettings; |
|---|
| 197 | |
|---|
| 198 | NEXUS_StripedSurface_GetCreateSettings(stripedSurface, &stripedSurfaceCreateSettings); |
|---|
| 199 | |
|---|
| 200 | BDBG_MSG(("Retrieve still %dx%d (striped %dx%d)", stripedSurfaceCreateSettings.imageWidth, stripedSurfaceCreateSettings.imageHeight, stripedSurfaceCreateSettings.stripedWidth, stripedSurfaceCreateSettings.lumaStripedHeight)); |
|---|
| 201 | if (stripedSurfaceCreateSettings.imageHeight == 0 || stripedSurfaceCreateSettings.imageWidth == 0) { |
|---|
| 202 | BDBG_ERR(("invalid still image %dx%d", stripedSurfaceCreateSettings.imageHeight, stripedSurfaceCreateSettings.imageWidth)); |
|---|
| 203 | return NULL; |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | /* create a bsurface_t which wraps the BSUR_Handle used by VDC */ |
|---|
| 207 | NEXUS_Surface_GetDefaultCreateSettings(&surfaceCreateSettings); |
|---|
| 208 | surfaceCreateSettings.height = stripedSurfaceCreateSettings.imageHeight; |
|---|
| 209 | surfaceCreateSettings.width = stripedSurfaceCreateSettings.imageWidth; |
|---|
| 210 | surfaceCreateSettings.pixelFormat = NEXUS_PixelFormat_eY08_Cb8_Y18_Cr8; |
|---|
| 211 | surface = NEXUS_Surface_Create(&surfaceCreateSettings); |
|---|
| 212 | if (!surface) {rc=BERR_TRACE(NEXUS_OUT_OF_DEVICE_MEMORY);return NULL;} |
|---|
| 213 | |
|---|
| 214 | rc = NEXUS_Graphics2D_DestripeToSurface(handle, stripedSurface, surface, NULL); |
|---|
| 215 | if (rc) { |
|---|
| 216 | rc = BERR_TRACE(rc); |
|---|
| 217 | NEXUS_Surface_Destroy(surface); |
|---|
| 218 | surface = NULL; |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | return surface; |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | NEXUS_Error NEXUS_Graphics2D_DestripeToSurface( NEXUS_Graphics2DHandle handle, NEXUS_StripedSurfaceHandle stripedSurface, NEXUS_SurfaceHandle targetSurface, const NEXUS_Rect *pTargetRect ) |
|---|
| 225 | { |
|---|
| 226 | BERR_Code err = BERR_SUCCESS; |
|---|
| 227 | BM2MC_PACKET_Plane surSurface; |
|---|
| 228 | unsigned paletteOffset; |
|---|
| 229 | NEXUS_SurfaceCreateSettings targetSettings; |
|---|
| 230 | uint32_t lumaOffset; |
|---|
| 231 | uint32_t chromaOffset; |
|---|
| 232 | bool interlaced; |
|---|
| 233 | NEXUS_StripedSurfaceCreateSettings stripedSurfaceCreateSettings; |
|---|
| 234 | |
|---|
| 235 | NEXUS_StripedSurface_GetCreateSettings(stripedSurface, &stripedSurfaceCreateSettings); |
|---|
| 236 | |
|---|
| 237 | lumaOffset = NEXUS_AddrToOffset( stripedSurfaceCreateSettings.pLumaBuffer ); |
|---|
| 238 | chromaOffset = NEXUS_AddrToOffset( stripedSurfaceCreateSettings.pChromaBuffer ); |
|---|
| 239 | |
|---|
| 240 | interlaced = (stripedSurfaceCreateSettings.bufferType == NEXUS_VideoBufferType_eTopField) || (stripedSurfaceCreateSettings.bufferType == NEXUS_VideoBufferType_eBotField); |
|---|
| 241 | |
|---|
| 242 | /* for bottom field, we must apply an offset to the start address */ |
|---|
| 243 | if (stripedSurfaceCreateSettings.bufferType == NEXUS_VideoBufferType_eBotField) { |
|---|
| 244 | lumaOffset += stripedSurfaceCreateSettings.pitch; |
|---|
| 245 | chromaOffset += stripedSurfaceCreateSettings.pitch; |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | NEXUS_Surface_GetCreateSettings( targetSurface, &targetSettings ); |
|---|
| 249 | NEXUS_Graphics2D_P_SetPower( handle, NEXUS_Graphics2DPowerState_ePowerUp ); |
|---|
| 250 | |
|---|
| 251 | NEXUS_Module_Lock( g_NEXUS_graphics2DData.settings.surface ); |
|---|
| 252 | NEXUS_Surface_InitPlane_priv( targetSurface, &surSurface, &paletteOffset ); |
|---|
| 253 | NEXUS_Module_Unlock( g_NEXUS_graphics2DData.settings.surface ); |
|---|
| 254 | |
|---|
| 255 | err = BGRClib_Destripe_Blit( handle->grclib, &surSurface, (const BRect *)pTargetRect, |
|---|
| 256 | lumaOffset, chromaOffset, interlaced ? stripedSurfaceCreateSettings.pitch * 2: stripedSurfaceCreateSettings.pitch, |
|---|
| 257 | stripedSurfaceCreateSettings.imageWidth, interlaced ? stripedSurfaceCreateSettings.imageHeight / 2 : stripedSurfaceCreateSettings.imageHeight, |
|---|
| 258 | stripedSurfaceCreateSettings.stripedWidth, stripedSurfaceCreateSettings.lumaStripedHeight, stripedSurfaceCreateSettings.chromaStripedHeight, |
|---|
| 259 | NEXUS_PIXEL_FORMAT_IS_YCRCB(targetSettings.pixelFormat) ? NULL : g_NEXUS_ai32_Matrix_YCbCrtoRGB, 10); |
|---|
| 260 | |
|---|
| 261 | if( (err == BERR_OUT_OF_DEVICE_MEMORY) || (err == BERR_OUT_OF_SYSTEM_MEMORY) ) |
|---|
| 262 | return BERR_TRACE(NEXUS_GRAPHICS2D_QUEUE_FULL); |
|---|
| 263 | |
|---|
| 264 | return BERR_TRACE(err); |
|---|
| 265 | } |
|---|