1 /****************************************************************************
3 * Copyright (C) 2005 - 2011 by Vivante Corp.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the license, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *****************************************************************************/
24 #ifndef __gc_hal_raster_h_
25 #define __gc_hal_raster_h_
27 #include "gc_hal_enum.h"
28 #include "gc_hal_types.h"
34 /******************************************************************************\
35 ****************************** Object Declarations *****************************
36 \******************************************************************************/
38 typedef struct _gcoBRUSH
* gcoBRUSH
;
39 typedef struct _gcoBRUSH_CACHE
* gcoBRUSH_CACHE
;
41 /******************************************************************************\
42 ******************************** gcoBRUSH Object *******************************
43 \******************************************************************************/
45 /* Create a new solid color gcoBRUSH object. */
47 gcoBRUSH_ConstructSingleColor(
49 IN gctUINT32 ColorConvert
,
55 /* Create a new monochrome gcoBRUSH object. */
57 gcoBRUSH_ConstructMonochrome(
61 IN gctUINT32 ColorConvert
,
69 /* Create a color gcoBRUSH object. */
71 gcoBRUSH_ConstructColor(
75 IN gctPOINTER Address
,
76 IN gceSURF_FORMAT Format
,
81 /* Destroy an gcoBRUSH object. */
87 /******************************************************************************\
88 ******************************** gcoSURF Object *******************************
89 \******************************************************************************/
91 /* Set cipping rectangle. */
97 /* Clear one or more rectangular areas. */
100 IN gcoSURF DestSurface
,
101 IN gctUINT32 RectCount
,
102 IN gcsRECT_PTR DestRect
,
103 IN gctUINT32 LoColor
,
107 /* Draw one or more Bresenham lines. */
111 IN gctUINT32 LineCount
,
112 IN gcsRECT_PTR Position
,
118 /* Generic rectangular blit. */
121 IN OPTIONAL gcoSURF SrcSurface
,
122 IN gcoSURF DestSurface
,
123 IN gctUINT32 RectCount
,
124 IN OPTIONAL gcsRECT_PTR SrcRect
,
125 IN gcsRECT_PTR DestRect
,
126 IN OPTIONAL gcoBRUSH Brush
,
129 IN OPTIONAL gceSURF_TRANSPARENCY Transparency
,
130 IN OPTIONAL gctUINT32 TransparencyColor
,
131 IN OPTIONAL gctPOINTER Mask
,
132 IN OPTIONAL gceSURF_MONOPACK MaskPack
135 /* Monochrome blit. */
138 IN gcoSURF DestSurface
,
139 IN gctPOINTER Source
,
140 IN gceSURF_MONOPACK SourcePack
,
141 IN gcsPOINT_PTR SourceSize
,
142 IN gcsPOINT_PTR SourceOrigin
,
143 IN gcsRECT_PTR DestRect
,
144 IN OPTIONAL gcoBRUSH Brush
,
147 IN gctBOOL ColorConvert
,
148 IN gctUINT8 MonoTransparency
,
149 IN gceSURF_TRANSPARENCY Transparency
,
150 IN gctUINT32 FgColor
,
157 IN gcoSURF SrcSurface
,
158 IN gcoSURF DestSurface
,
159 IN gcsRECT_PTR SrcRect
,
160 IN gcsRECT_PTR DestRect
,
161 IN gcsRECT_PTR DestSubRect
164 /* Enable alpha blending engine in the hardware and disengage the ROP engine. */
166 gcoSURF_EnableAlphaBlend(
168 IN gctUINT8 SrcGlobalAlphaValue
,
169 IN gctUINT8 DstGlobalAlphaValue
,
170 IN gceSURF_PIXEL_ALPHA_MODE SrcAlphaMode
,
171 IN gceSURF_PIXEL_ALPHA_MODE DstAlphaMode
,
172 IN gceSURF_GLOBAL_ALPHA_MODE SrcGlobalAlphaMode
,
173 IN gceSURF_GLOBAL_ALPHA_MODE DstGlobalAlphaMode
,
174 IN gceSURF_BLEND_FACTOR_MODE SrcFactorMode
,
175 IN gceSURF_BLEND_FACTOR_MODE DstFactorMode
,
176 IN gceSURF_PIXEL_COLOR_MODE SrcColorMode
,
177 IN gceSURF_PIXEL_COLOR_MODE DstColorMode
180 /* Disable alpha blending engine in the hardware and engage the ROP engine. */
182 gcoSURF_DisableAlphaBlend(
186 /* Copy a rectangular area with format conversion. */
199 /* Read surface pixel. */
203 IN gctPOINTER Memory
,
206 IN gceSURF_FORMAT Format
,
207 OUT gctPOINTER PixelValue
210 /* Write surface pixel. */
214 IN gctPOINTER Memory
,
217 IN gceSURF_FORMAT Format
,
218 IN gctPOINTER PixelValue
226 /******************************************************************************\
227 ********************************** gco2D Object *********************************
228 \******************************************************************************/
230 /* Construct a new gco2D object. */
237 /* Destroy an gco2D object. */
243 /* Sets the maximum number of brushes in the brush cache. */
250 /* Flush the brush. */
255 IN gceSURF_FORMAT Format
258 /* Program the specified solid color brush. */
260 gco2D_LoadSolidBrush(
262 IN gceSURF_FORMAT Format
,
263 IN gctUINT32 ColorConvert
,
269 gco2D_LoadMonochromeBrush(
271 IN gctUINT32 OriginX
,
272 IN gctUINT32 OriginY
,
273 IN gctUINT32 ColorConvert
,
274 IN gctUINT32 FgColor
,
275 IN gctUINT32 BgColor
,
281 gco2D_LoadColorBrush(
283 IN gctUINT32 OriginX
,
284 IN gctUINT32 OriginY
,
285 IN gctUINT32 Address
,
286 IN gceSURF_FORMAT Format
,
290 /* Configure monochrome source. */
292 gco2D_SetMonochromeSource(
294 IN gctBOOL ColorConvert
,
295 IN gctUINT8 MonoTransparency
,
296 IN gceSURF_MONOPACK DataPack
,
297 IN gctBOOL CoordRelative
,
298 IN gceSURF_TRANSPARENCY Transparency
,
299 IN gctUINT32 FgColor
,
303 /* Configure color source. */
305 gco2D_SetColorSource(
307 IN gctUINT32 Address
,
309 IN gceSURF_FORMAT Format
,
310 IN gceSURF_ROTATION Rotation
,
311 IN gctUINT32 SurfaceWidth
,
312 IN gctBOOL CoordRelative
,
313 IN gceSURF_TRANSPARENCY Transparency
,
314 IN gctUINT32 TransparencyColor
317 /* Configure color source extension for full rotation. */
319 gco2D_SetColorSourceEx(
321 IN gctUINT32 Address
,
323 IN gceSURF_FORMAT Format
,
324 IN gceSURF_ROTATION Rotation
,
325 IN gctUINT32 SurfaceWidth
,
326 IN gctUINT32 SurfaceHeight
,
327 IN gctBOOL CoordRelative
,
328 IN gceSURF_TRANSPARENCY Transparency
,
329 IN gctUINT32 TransparencyColor
332 /* Configure color source. */
334 gco2D_SetColorSourceAdvanced(
336 IN gctUINT32 Address
,
338 IN gceSURF_FORMAT Format
,
339 IN gceSURF_ROTATION Rotation
,
340 IN gctUINT32 SurfaceWidth
,
341 IN gctUINT32 SurfaceHeight
,
342 IN gctBOOL CoordRelative
346 gco2D_SetColorSourceN(
348 IN gctUINT32 Address
,
350 IN gceSURF_FORMAT Format
,
351 IN gceSURF_ROTATION Rotation
,
352 IN gctUINT32 SurfaceWidth
,
353 IN gctUINT32 SurfaceHeight
,
354 IN gctUINT32 SurfaceNumber
357 /* Configure masked color source. */
359 gco2D_SetMaskedSource(
361 IN gctUINT32 Address
,
363 IN gceSURF_FORMAT Format
,
364 IN gctBOOL CoordRelative
,
365 IN gceSURF_MONOPACK MaskPack
368 /* Configure masked color source extension for full rotation. */
370 gco2D_SetMaskedSourceEx(
372 IN gctUINT32 Address
,
374 IN gceSURF_FORMAT Format
,
375 IN gctBOOL CoordRelative
,
376 IN gceSURF_MONOPACK MaskPack
,
377 IN gceSURF_ROTATION Rotation
,
378 IN gctUINT32 SurfaceWidth
,
379 IN gctUINT32 SurfaceHeight
382 /* Setup the source rectangle. */
386 IN gcsRECT_PTR SrcRect
389 /* Set clipping rectangle. */
396 /* Configure destination. */
400 IN gctUINT32 Address
,
402 IN gceSURF_ROTATION Rotation
,
403 IN gctUINT32 SurfaceWidth
406 /* Configure destination extension for full rotation. */
410 IN gctUINT32 Address
,
412 IN gceSURF_ROTATION Rotation
,
413 IN gctUINT32 SurfaceWidth
,
414 IN gctUINT32 SurfaceHeight
417 /* Calculate and program the stretch factors. */
419 gco2D_SetStretchFactors(
421 IN gctUINT32 HorFactor
,
422 IN gctUINT32 VerFactor
425 /* Calculate and program the stretch factors based on the rectangles. */
427 gco2D_SetStretchRectFactors(
429 IN gcsRECT_PTR SrcRect
,
430 IN gcsRECT_PTR DestRect
433 /* Create a new solid color gcoBRUSH object. */
435 gco2D_ConstructSingleColorBrush(
437 IN gctUINT32 ColorConvert
,
443 /* Create a new monochrome gcoBRUSH object. */
445 gco2D_ConstructMonochromeBrush(
447 IN gctUINT32 OriginX
,
448 IN gctUINT32 OriginY
,
449 IN gctUINT32 ColorConvert
,
450 IN gctUINT32 FgColor
,
451 IN gctUINT32 BgColor
,
457 /* Create a color gcoBRUSH object. */
459 gco2D_ConstructColorBrush(
461 IN gctUINT32 OriginX
,
462 IN gctUINT32 OriginY
,
463 IN gctPOINTER Address
,
464 IN gceSURF_FORMAT Format
,
469 /* Clear one or more rectangular areas. */
473 IN gctUINT32 RectCount
,
475 IN gctUINT32 Color32
,
478 IN gceSURF_FORMAT DestFormat
481 /* Draw one or more Bresenham lines. */
485 IN gctUINT32 LineCount
,
486 IN gcsRECT_PTR Position
,
490 IN gceSURF_FORMAT DestFormat
493 /* Draw one or more Bresenham lines based on the 32-bit color. */
497 IN gctUINT32 LineCount
,
498 IN gcsRECT_PTR Position
,
499 IN gctUINT32 Color32
,
502 IN gceSURF_FORMAT DestFormat
509 IN gctUINT32 RectCount
,
513 IN gceSURF_FORMAT DestFormat
519 IN gctUINT32 SrcCount
,
520 IN gctUINT32 RectCount
,
524 IN gceSURF_FORMAT DestFormat
531 IN gctUINT32 RectCount
,
532 IN gcsRECT_PTR SrcRect
,
533 IN gcsRECT_PTR DestRect
,
536 IN gceSURF_FORMAT DestFormat
543 IN gctUINT32 RectCount
,
547 IN gceSURF_FORMAT DestFormat
550 /* Monochrome blit. */
554 IN gctPOINTER StreamBits
,
555 IN gcsPOINT_PTR StreamSize
,
556 IN gcsRECT_PTR StreamRect
,
557 IN gceSURF_MONOPACK SrcStreamPack
,
558 IN gceSURF_MONOPACK DestStreamPack
,
559 IN gcsRECT_PTR DestRect
,
562 IN gceSURF_FORMAT DestFormat
565 /* Set kernel size. */
569 IN gctUINT8 HorKernelSize
,
570 IN gctUINT8 VerKernelSize
573 /* Set filter type. */
577 IN gceFILTER_TYPE FilterType
580 /* Set the filter kernel by user. */
582 gco2D_SetUserFilterKernel(
584 IN gceFILTER_PASS_TYPE PassType
,
585 IN gctUINT16_PTR KernelArray
588 /* Select the pass(es) to be done for user defined filter. */
590 gco2D_EnableUserFilterPasses(
596 /* Frees the temporary buffer allocated by filter blit operation. */
598 gco2D_FreeFilterBuffer(
606 IN gctUINT32 SrcAddress
,
607 IN gctUINT SrcStride
,
608 IN gctUINT32 SrcUAddress
,
609 IN gctUINT SrcUStride
,
610 IN gctUINT32 SrcVAddress
,
611 IN gctUINT SrcVStride
,
612 IN gceSURF_FORMAT SrcFormat
,
613 IN gceSURF_ROTATION SrcRotation
,
614 IN gctUINT32 SrcSurfaceWidth
,
615 IN gcsRECT_PTR SrcRect
,
616 IN gctUINT32 DestAddress
,
617 IN gctUINT DestStride
,
618 IN gceSURF_FORMAT DestFormat
,
619 IN gceSURF_ROTATION DestRotation
,
620 IN gctUINT32 DestSurfaceWidth
,
621 IN gcsRECT_PTR DestRect
,
622 IN gcsRECT_PTR DestSubRect
625 /* Filter blit extension for full rotation. */
629 IN gctUINT32 SrcAddress
,
630 IN gctUINT SrcStride
,
631 IN gctUINT32 SrcUAddress
,
632 IN gctUINT SrcUStride
,
633 IN gctUINT32 SrcVAddress
,
634 IN gctUINT SrcVStride
,
635 IN gceSURF_FORMAT SrcFormat
,
636 IN gceSURF_ROTATION SrcRotation
,
637 IN gctUINT32 SrcSurfaceWidth
,
638 IN gctUINT32 SrcSurfaceHeight
,
639 IN gcsRECT_PTR SrcRect
,
640 IN gctUINT32 DestAddress
,
641 IN gctUINT DestStride
,
642 IN gceSURF_FORMAT DestFormat
,
643 IN gceSURF_ROTATION DestRotation
,
644 IN gctUINT32 DestSurfaceWidth
,
645 IN gctUINT32 DestSurfaceHeight
,
646 IN gcsRECT_PTR DestRect
,
647 IN gcsRECT_PTR DestSubRect
653 IN gctUINT32_PTR SrcAddresses
,
654 IN gctUINT32 SrcAddressNum
,
655 IN gctUINT32_PTR SrcStrides
,
656 IN gctUINT32 SrcStrideNum
,
657 IN gceTILING SrcTiling
,
658 IN gceSURF_FORMAT SrcFormat
,
659 IN gceSURF_ROTATION SrcRotation
,
660 IN gctUINT32 SrcSurfaceWidth
,
661 IN gctUINT32 SrcSurfaceHeight
,
662 IN gcsRECT_PTR SrcRect
,
663 IN gctUINT32_PTR DestAddresses
,
664 IN gctUINT32 DestAddressNum
,
665 IN gctUINT32_PTR DestStrides
,
666 IN gctUINT32 DestStrideNum
,
667 IN gceTILING DestTiling
,
668 IN gceSURF_FORMAT DestFormat
,
669 IN gceSURF_ROTATION DestRotation
,
670 IN gctUINT32 DestSurfaceWidth
,
671 IN gctUINT32 DestSurfaceHeight
,
672 IN gcsRECT_PTR DestRect
,
673 IN gcsRECT_PTR DestSubRect
676 /* Enable alpha blending engine in the hardware and disengage the ROP engine. */
678 gco2D_EnableAlphaBlend(
680 IN gctUINT8 SrcGlobalAlphaValue
,
681 IN gctUINT8 DstGlobalAlphaValue
,
682 IN gceSURF_PIXEL_ALPHA_MODE SrcAlphaMode
,
683 IN gceSURF_PIXEL_ALPHA_MODE DstAlphaMode
,
684 IN gceSURF_GLOBAL_ALPHA_MODE SrcGlobalAlphaMode
,
685 IN gceSURF_GLOBAL_ALPHA_MODE DstGlobalAlphaMode
,
686 IN gceSURF_BLEND_FACTOR_MODE SrcFactorMode
,
687 IN gceSURF_BLEND_FACTOR_MODE DstFactorMode
,
688 IN gceSURF_PIXEL_COLOR_MODE SrcColorMode
,
689 IN gceSURF_PIXEL_COLOR_MODE DstColorMode
692 /* Enable alpha blending engine in the hardware. */
694 gco2D_EnableAlphaBlendAdvanced(
696 IN gceSURF_PIXEL_ALPHA_MODE SrcAlphaMode
,
697 IN gceSURF_PIXEL_ALPHA_MODE DstAlphaMode
,
698 IN gceSURF_GLOBAL_ALPHA_MODE SrcGlobalAlphaMode
,
699 IN gceSURF_GLOBAL_ALPHA_MODE DstGlobalAlphaMode
,
700 IN gceSURF_BLEND_FACTOR_MODE SrcFactorMode
,
701 IN gceSURF_BLEND_FACTOR_MODE DstFactorMode
704 /* Enable alpha blending engine with Porter Duff rule. */
706 gco2D_SetPorterDuffBlending(
708 IN gce2D_PORTER_DUFF_RULE Rule
711 /* Disable alpha blending engine in the hardware and engage the ROP engine. */
713 gco2D_DisableAlphaBlend(
717 /* Retrieve the maximum number of 32-bit data chunks for a single DE command. */
719 gco2D_GetMaximumDataCount(
723 /* Retrieve the maximum number of rectangles, that can be passed in a single DE command. */
725 gco2D_GetMaximumRectCount(
729 /* Returns the pixel alignment of the surface. */
731 gco2D_GetPixelAlignment(
732 gceSURF_FORMAT Format
,
733 gcsPOINT_PTR Alignment
736 /* Retrieve monochrome stream pack size. */
739 IN gceSURF_MONOPACK StreamPack
,
740 OUT gctUINT32
* PackWidth
,
741 OUT gctUINT32
* PackHeight
744 /* Flush the 2D pipeline. */
750 /* Load 256-entry color table for INDEX8 source surfaces. */
754 IN gctUINT FirstIndex
,
755 IN gctUINT IndexCount
,
756 IN gctPOINTER ColorTable
,
757 IN gctBOOL ColorConvert
760 /* Enable/disable 2D BitBlt mirrorring. */
762 gco2D_SetBitBlitMirror(
764 IN gctBOOL HorizontalMirror
,
765 IN gctBOOL VerticalMirror
769 * Set the transparency for source, destination and pattern.
770 * It also enable or disable the DFB color key mode.
773 gco2D_SetTransparencyAdvancedEx(
775 IN gce2D_TRANSPARENCY SrcTransparency
,
776 IN gce2D_TRANSPARENCY DstTransparency
,
777 IN gce2D_TRANSPARENCY PatTransparency
,
778 IN gctBOOL EnableDFBColorKeyMode
781 /* Set the transparency for source, destination and pattern. */
783 gco2D_SetTransparencyAdvanced(
785 IN gce2D_TRANSPARENCY SrcTransparency
,
786 IN gce2D_TRANSPARENCY DstTransparency
,
787 IN gce2D_TRANSPARENCY PatTransparency
790 /* Set the source color key. */
792 gco2D_SetSourceColorKeyAdvanced(
794 IN gctUINT32 ColorKey
797 /* Set the source color key range. */
799 gco2D_SetSourceColorKeyRangeAdvanced(
801 IN gctUINT32 ColorKeyLow
,
802 IN gctUINT32 ColorKeyHigh
805 /* Set the target color key. */
807 gco2D_SetTargetColorKeyAdvanced(
809 IN gctUINT32 ColorKey
812 /* Set the target color key range. */
814 gco2D_SetTargetColorKeyRangeAdvanced(
816 IN gctUINT32 ColorKeyLow
,
817 IN gctUINT32 ColorKeyHigh
820 /* Set the YUV color space mode. */
822 gco2D_SetYUVColorMode(
824 IN gce2D_YUV_COLOR_MODE Mode
827 /* Setup the source global color value in ARGB8 format. */
828 gceSTATUS
gco2D_SetSourceGlobalColorAdvanced(
833 /* Setup the target global color value in ARGB8 format. */
834 gceSTATUS
gco2D_SetTargetGlobalColorAdvanced(
839 /* Setup the source and target pixel multiply modes. */
841 gco2D_SetPixelMultiplyModeAdvanced(
843 IN gce2D_PIXEL_COLOR_MULTIPLY_MODE SrcPremultiplySrcAlpha
,
844 IN gce2D_PIXEL_COLOR_MULTIPLY_MODE DstPremultiplyDstAlpha
,
845 IN gce2D_GLOBAL_COLOR_MULTIPLY_MODE SrcPremultiplyGlobalMode
,
846 IN gce2D_PIXEL_COLOR_MULTIPLY_MODE DstDemultiplyDstAlpha
849 /* Set the GPU clock cycles after which the idle engine will keep auto-flushing. */
851 gco2D_SetAutoFlushCycles(
857 /* Read the profile registers available in the 2D engine and sets them in the profile.
858 The function will also reset the pixelsRendered counter every time.
863 OPTIONAL gcs2D_PROFILE_PTR Profile
867 /* Enable or disable 2D dithering. */
875 gco2D_SetGenericSource(
877 IN gctUINT32_PTR Addresses
,
878 IN gctUINT32 AddressNum
,
879 IN gctUINT32_PTR Strides
,
880 IN gctUINT32 StrideNum
,
882 IN gceSURF_FORMAT Format
,
883 IN gceSURF_ROTATION Rotation
,
884 IN gctUINT32 SurfaceWidth
,
885 IN gctUINT32 SurfaceHeight
889 gco2D_SetGenericTarget(
891 IN gctUINT32_PTR Addresses
,
892 IN gctUINT32 AddressNum
,
893 IN gctUINT32_PTR Strides
,
894 IN gctUINT32 StrideNum
,
896 IN gceSURF_FORMAT Format
,
897 IN gceSURF_ROTATION Rotation
,
898 IN gctUINT32 SurfaceWidth
,
899 IN gctUINT32 SurfaceHeight
903 gco2D_SetCurrentSourceIndex(
905 IN gctUINT32 SrcIndex
909 gco2D_MultiSourceBlit(
911 IN gctUINT32 SourceMask
,
912 IN gcsRECT_PTR DestRect
,
913 IN gctUINT32 RectCount
927 #endif /* __gc_hal_raster_h_ */