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 *****************************************************************************/
25 #include "gc_hal_kernel.h"
29 #define _GC_OBJ_ZONE gcvZONE_HARDWARE
31 /******************************************************************************\
32 ********************************* Support Code *********************************
33 \******************************************************************************/
38 OUT gceCHIPMODEL
* ChipModel
,
39 OUT gctUINT32
* ChipRevision
,
40 OUT gctUINT32
* ChipFeatures
,
41 OUT gctUINT32
* ChipMinorFeatures
,
42 OUT gctUINT32
* ChipMinorFeatures2
46 gctUINT32 chipIdentity
;
50 /* Read chip identity register. */
51 gcmkERR_BREAK(gckOS_ReadRegisterEx(Os
, gcvCORE_VG
, 0x00018, &chipIdentity
));
53 /* Special case for older graphic cores. */
54 if (((((gctUINT32
) (chipIdentity
)) >> (0 ? 31:24) & ((gctUINT32
) ((((1 ? 31:24) - (0 ? 31:24) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 31:24) - (0 ? 31:24) + 1)))))) == (0x01 & ((gctUINT32
) ((((1 ? 31:24) - (0 ? 31:24) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 31:24) - (0 ? 31:24) + 1))))))))
57 *ChipRevision
= (((((gctUINT32
) (chipIdentity
)) >> (0 ? 15:12)) & ((gctUINT32
) ((((1 ? 15:12) - (0 ? 15:12) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 15:12) - (0 ? 15:12) + 1)))))) );
62 /* Read chip identity register. */
63 gcmkERR_BREAK(gckOS_ReadRegisterEx(Os
, gcvCORE_VG
,
65 (gctUINT32
*) ChipModel
));
67 /* Read CHIP_REV register. */
68 gcmkERR_BREAK(gckOS_ReadRegisterEx(Os
, gcvCORE_VG
,
73 /* Read chip feature register. */
74 gcmkERR_BREAK(gckOS_ReadRegisterEx(
75 Os
, gcvCORE_VG
, 0x0001C, ChipFeatures
78 /* Read chip minor feature register. */
79 gcmkERR_BREAK(gckOS_ReadRegisterEx(
80 Os
, gcvCORE_VG
, 0x00034, ChipMinorFeatures
83 /* Read chip minor feature register #2. */
84 gcmkERR_BREAK(gckOS_ReadRegisterEx(
85 Os
, gcvCORE_VG
, 0x00074, ChipMinorFeatures2
91 "ChipRevision=0x%08X\n"
92 "ChipFeatures=0x%08X\n"
93 "ChipMinorFeatures=0x%08X\n"
94 "ChipMinorFeatures2=0x%08X\n",
107 /* Return the status. */
111 /******************************************************************************\
112 ****************************** gckVGHARDWARE API code *****************************
113 \******************************************************************************/
115 /*******************************************************************************
117 ** gckVGHARDWARE_Construct
119 ** Construct a new gckVGHARDWARE object.
124 ** Pointer to an initialized gckOS object.
128 ** gckVGHARDWARE * Hardware
129 ** Pointer to a variable that will hold the pointer to the gckVGHARDWARE
133 gckVGHARDWARE_Construct(
135 OUT gckVGHARDWARE
* Hardware
138 gckVGHARDWARE hardware
;
140 gceCHIPMODEL chipModel
;
141 gctUINT32 chipRevision
;
142 gctUINT32 chipFeatures
;
143 gctUINT32 chipMinorFeatures
;
144 gctUINT32 chipMinorFeatures2
;
146 gcmkHEADER_ARG("Os=0x%x Hardware=0x%x ", Os
, Hardware
);
148 /* Verify the arguments. */
149 gcmkVERIFY_OBJECT(Os
, gcvOBJ_OS
);
150 gcmkVERIFY_ARGUMENT(Hardware
!= gcvNULL
);
154 /* Identify the hardware. */
155 gcmkERR_BREAK(_IdentifyHardware(Os
,
156 &chipModel
, &chipRevision
,
157 &chipFeatures
, &chipMinorFeatures
, &chipMinorFeatures2
160 /* Allocate the gckVGHARDWARE object. */
161 gcmkERR_BREAK(gckOS_Allocate(Os
,
162 gcmSIZEOF(struct _gckVGHARDWARE
), (gctPOINTER
*) &hardware
165 /* Initialize the gckVGHARDWARE object. */
166 hardware
->object
.type
= gcvOBJ_HARDWARE
;
169 /* Set chip identity. */
170 hardware
->chipModel
= chipModel
;
171 hardware
->chipRevision
= chipRevision
;
172 hardware
->chipFeatures
= chipFeatures
;
173 hardware
->chipMinorFeatures
= chipMinorFeatures
;
174 hardware
->chipMinorFeatures2
= chipMinorFeatures2
;
176 /* Determine whether FE 2.0 is present. */
177 hardware
->fe20
= ((((gctUINT32
) (hardware
->chipFeatures
)) >> (0 ? 28:28) & ((gctUINT32
) ((((1 ? 28:28) - (0 ? 28:28) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 28:28) - (0 ? 28:28) + 1)))))) == (0x1 & ((gctUINT32
) ((((1 ? 28:28) - (0 ? 28:28) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 28:28) - (0 ? 28:28) + 1)))))));
179 /* Determine whether VG 2.0 is present. */
180 hardware
->vg20
= ((((gctUINT32
) (hardware
->chipMinorFeatures
)) >> (0 ? 13:13) & ((gctUINT32
) ((((1 ? 13:13) - (0 ? 13:13) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 13:13) - (0 ? 13:13) + 1)))))) == (0x1 & ((gctUINT32
) ((((1 ? 13:13) - (0 ? 13:13) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 13:13) - (0 ? 13:13) + 1)))))));
182 /* Determine whether VG 2.1 is present. */
183 hardware
->vg21
= ((((gctUINT32
) (hardware
->chipMinorFeatures
)) >> (0 ? 18:18) & ((gctUINT32
) ((((1 ? 18:18) - (0 ? 18:18) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 18:18) - (0 ? 18:18) + 1)))))) == (0x1 & ((gctUINT32
) ((((1 ? 18:18) - (0 ? 18:18) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 18:18) - (0 ? 18:18) + 1)))))));
185 /* Set default event mask. */
186 hardware
->eventMask
= 0xFFFFFFFF;
188 /* Set fast clear to auto. */
189 gcmkVERIFY_OK(gckVGHARDWARE_SetFastClear(hardware
, -1));
191 /* Return pointer to the gckVGHARDWARE object. */
192 *Hardware
= hardware
;
201 /* Return the status. */
205 /*******************************************************************************
207 ** gckVGHARDWARE_Destroy
209 ** Destroy an gckVGHARDWARE object.
213 ** gckVGHARDWARE Hardware
214 ** Pointer to the gckVGHARDWARE object that needs to be destroyed.
221 gckVGHARDWARE_Destroy(
222 IN gckVGHARDWARE Hardware
226 gcmkHEADER_ARG("Hardware=0x%x ", Hardware
);
227 /* Verify the arguments. */
228 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
230 /* Mark the object as unknown. */
231 Hardware
->object
.type
= gcvOBJ_UNKNOWN
;
233 /* Free the object. */
234 status
= gckOS_Free(Hardware
->os
, Hardware
);
239 /*******************************************************************************
241 ** gckVGHARDWARE_QueryMemory
243 ** Query the amount of memory available on the hardware.
247 ** gckVGHARDWARE Hardware
248 ** Pointer to the gckVGHARDWARE object.
252 ** gctSIZE_T * InternalSize
253 ** Pointer to a variable that will hold the size of the internal video
254 ** memory in bytes. If 'InternalSize' is gcvNULL, no information of the
255 ** internal memory will be returned.
257 ** gctUINT32 * InternalBaseAddress
258 ** Pointer to a variable that will hold the hardware's base address for
259 ** the internal video memory. This pointer cannot be gcvNULL if
260 ** 'InternalSize' is also non-gcvNULL.
262 ** gctUINT32 * InternalAlignment
263 ** Pointer to a variable that will hold the hardware's base address for
264 ** the internal video memory. This pointer cannot be gcvNULL if
265 ** 'InternalSize' is also non-gcvNULL.
267 ** gctSIZE_T * ExternalSize
268 ** Pointer to a variable that will hold the size of the external video
269 ** memory in bytes. If 'ExternalSize' is gcvNULL, no information of the
270 ** external memory will be returned.
272 ** gctUINT32 * ExternalBaseAddress
273 ** Pointer to a variable that will hold the hardware's base address for
274 ** the external video memory. This pointer cannot be gcvNULL if
275 ** 'ExternalSize' is also non-gcvNULL.
277 ** gctUINT32 * ExternalAlignment
278 ** Pointer to a variable that will hold the hardware's base address for
279 ** the external video memory. This pointer cannot be gcvNULL if
280 ** 'ExternalSize' is also non-gcvNULL.
282 ** gctUINT32 * HorizontalTileSize
283 ** Number of horizontal pixels per tile. If 'HorizontalTileSize' is
284 ** gcvNULL, no horizontal pixel per tile will be returned.
286 ** gctUINT32 * VerticalTileSize
287 ** Number of vertical pixels per tile. If 'VerticalTileSize' is
288 ** gcvNULL, no vertical pixel per tile will be returned.
291 gckVGHARDWARE_QueryMemory(
292 IN gckVGHARDWARE Hardware
,
293 OUT gctSIZE_T
* InternalSize
,
294 OUT gctUINT32
* InternalBaseAddress
,
295 OUT gctUINT32
* InternalAlignment
,
296 OUT gctSIZE_T
* ExternalSize
,
297 OUT gctUINT32
* ExternalBaseAddress
,
298 OUT gctUINT32
* ExternalAlignment
,
299 OUT gctUINT32
* HorizontalTileSize
,
300 OUT gctUINT32
* VerticalTileSize
303 gcmkHEADER_ARG("Hardware=0x%x InternalSize=0x%x InternalBaseAddress=0x%x InternalAlignment=0x%x"
304 "ExternalSize=0x%x ExternalBaseAddress=0x%x ExternalAlignment=0x%x HorizontalTileSize=0x%x VerticalTileSize=0x%x",
305 Hardware
, InternalSize
, InternalBaseAddress
, InternalAlignment
,
306 ExternalSize
, ExternalBaseAddress
, ExternalAlignment
, HorizontalTileSize
, VerticalTileSize
);
308 /* Verify the arguments. */
309 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
311 if (InternalSize
!= gcvNULL
)
313 /* No internal memory. */
317 if (ExternalSize
!= gcvNULL
)
319 /* No external memory. */
323 if (HorizontalTileSize
!= gcvNULL
)
326 *HorizontalTileSize
= 4;
329 if (VerticalTileSize
!= gcvNULL
)
332 *VerticalTileSize
= 4;
340 /*******************************************************************************
342 ** gckVGHARDWARE_QueryChipIdentity
344 ** Query the identity of the hardware.
348 ** gckVGHARDWARE Hardware
349 ** Pointer to the gckVGHARDWARE object.
353 ** gceCHIPMODEL * ChipModel
354 ** If 'ChipModel' is not gcvNULL, the variable it points to will
355 ** receive the model of the chip.
357 ** gctUINT32 * ChipRevision
358 ** If 'ChipRevision' is not gcvNULL, the variable it points to will
359 ** receive the revision of the chip.
361 ** gctUINT32 * ChipFeatures
362 ** If 'ChipFeatures' is not gcvNULL, the variable it points to will
363 ** receive the feature set of the chip.
365 ** gctUINT32 * ChipMinorFeatures
366 ** If 'ChipMinorFeatures' is not gcvNULL, the variable it points to
367 ** will receive the minor feature set of the chip.
369 ** gctUINT32 * ChipMinorFeatures2
370 ** If 'ChipMinorFeatures2' is not gcvNULL, the variable it points to
371 ** will receive the minor feature set of the chip.
375 gckVGHARDWARE_QueryChipIdentity(
376 IN gckVGHARDWARE Hardware
,
377 OUT gceCHIPMODEL
* ChipModel
,
378 OUT gctUINT32
* ChipRevision
,
379 OUT gctUINT32
* ChipFeatures
,
380 OUT gctUINT32
* ChipMinorFeatures
,
381 OUT gctUINT32
* ChipMinorFeatures2
384 gcmkHEADER_ARG("Hardware=0x%x ChipModel=0x%x ChipRevision=0x%x ChipFeatures = 0x%x ChipMinorFeatures = 0x%x ChipMinorFeatures2 = 0x%x",
385 Hardware
, ChipModel
, ChipRevision
, ChipFeatures
, ChipMinorFeatures
, ChipMinorFeatures2
);
387 /* Verify the arguments. */
388 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
390 /* Return chip model. */
391 if (ChipModel
!= gcvNULL
)
393 *ChipModel
= Hardware
->chipModel
;
396 /* Return revision number. */
397 if (ChipRevision
!= gcvNULL
)
399 *ChipRevision
= Hardware
->chipRevision
;
402 /* Return feature set. */
403 if (ChipFeatures
!= gcvNULL
)
405 gctUINT32 features
= Hardware
->chipFeatures
;
407 if ((((((gctUINT32
) (features
)) >> (0 ? 0:0)) & ((gctUINT32
) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1)))))) ))
409 features
= ((((gctUINT32
) (features
)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) | (((gctUINT32
) ((gctUINT32
) (Hardware
->allowFastClear
) & ((gctUINT32
) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0)));
412 /* Mark 2D pipe as available for GC500.0 since it did not have this *\
414 if ((Hardware
->chipModel
== gcv500
)
415 && (Hardware
->chipRevision
== 0)
418 features
= ((((gctUINT32
) (features
)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) | (((gctUINT32
) (0x1 & ((gctUINT32
) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9)));
421 /* Mark 2D pipe as available for GC300 since it did not have this *\
423 if (Hardware
->chipModel
== gcv300
)
425 features
= ((((gctUINT32
) (features
)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9))) | (((gctUINT32
) (0x1 & ((gctUINT32
) ((((1 ? 9:9) - (0 ? 9:9) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 9:9) - (0 ? 9:9) + 1))))))) << (0 ? 9:9)));
428 *ChipFeatures
= features
;
431 /* Return minor feature set. */
432 if (ChipMinorFeatures
!= gcvNULL
)
434 *ChipMinorFeatures
= Hardware
->chipMinorFeatures
;
437 /* Return minor feature set #2. */
438 if (ChipMinorFeatures2
!= gcvNULL
)
440 *ChipMinorFeatures2
= Hardware
->chipMinorFeatures2
;
448 /*******************************************************************************
450 ** gckVGHARDWARE_ConvertFormat
452 ** Convert an API format to hardware parameters.
456 ** gckVGHARDWARE Hardware
457 ** Pointer to the gckVGHARDWARE object.
459 ** gceSURF_FORMAT Format
460 ** API format to convert.
464 ** gctUINT32 * BitsPerPixel
465 ** Pointer to a variable that will hold the number of bits per pixel.
467 ** gctUINT32 * BytesPerTile
468 ** Pointer to a variable that will hold the number of bytes per tile.
471 gckVGHARDWARE_ConvertFormat(
472 IN gckVGHARDWARE Hardware
,
473 IN gceSURF_FORMAT Format
,
474 OUT gctUINT32
* BitsPerPixel
,
475 OUT gctUINT32
* BytesPerTile
478 gctUINT32 bitsPerPixel
;
479 gctUINT32 bytesPerTile
;
481 gcmkHEADER_ARG("Hardware=0x%x Format=0x%x BitsPerPixel=0x%x BytesPerTile = 0x%x",
482 Hardware
, Format
, BitsPerPixel
, BytesPerTile
);
484 /* Verify the arguments. */
485 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
487 /* Dispatch on format. */
494 bytesPerTile
= (1 * 4 * 4) / 8;
500 bytesPerTile
= (4 * 4 * 4) / 8;
508 bytesPerTile
= (8 * 4 * 4) / 8;
512 /* 12-bpp planar YUV formats. */
514 bytesPerTile
= (12 * 4 * 4) / 8;
518 /* 12-bpp planar YUV formats. */
520 bytesPerTile
= (12 * 4 * 4) / 8;
523 /* 4444 variations. */
524 case gcvSURF_X4R4G4B4
:
525 case gcvSURF_A4R4G4B4
:
526 case gcvSURF_R4G4B4X4
:
527 case gcvSURF_R4G4B4A4
:
528 case gcvSURF_B4G4R4X4
:
529 case gcvSURF_B4G4R4A4
:
530 case gcvSURF_X4B4G4R4
:
531 case gcvSURF_A4B4G4R4
:
533 /* 1555 variations. */
534 case gcvSURF_X1R5G5B5
:
535 case gcvSURF_A1R5G5B5
:
536 case gcvSURF_R5G5B5X1
:
537 case gcvSURF_R5G5B5A1
:
538 case gcvSURF_X1B5G5R5
:
539 case gcvSURF_A1B5G5R5
:
540 case gcvSURF_B5G5R5X1
:
541 case gcvSURF_B5G5R5A1
:
543 /* 565 variations. */
553 bytesPerTile
= (16 * 4 * 4) / 8;
556 case gcvSURF_X8R8G8B8
:
557 case gcvSURF_A8R8G8B8
:
558 case gcvSURF_X8B8G8R8
:
559 case gcvSURF_A8B8G8R8
:
560 case gcvSURF_R8G8B8X8
:
561 case gcvSURF_R8G8B8A8
:
562 case gcvSURF_B8G8R8X8
:
563 case gcvSURF_B8G8R8A8
:
567 bytesPerTile
= (32 * 4 * 4) / 8;
573 bytesPerTile
= (32 * 4 * 4) / 8;
579 bytesPerTile
= (4 * 4 * 4) / 8;
587 bytesPerTile
= (8 * 4 * 4) / 8;
591 /* Invalid format. */
592 return gcvSTATUS_INVALID_ARGUMENT
;
595 /* Set the result. */
596 if (BitsPerPixel
!= gcvNULL
)
598 * BitsPerPixel
= bitsPerPixel
;
601 if (BytesPerTile
!= gcvNULL
)
603 * BytesPerTile
= bytesPerTile
;
611 /*******************************************************************************
613 ** gckVGHARDWARE_SplitMemory
615 ** Split a hardware specific memory address into a pool and offset.
619 ** gckVGHARDWARE Hardware
620 ** Pointer to the gckVGHARDWARE object.
623 ** Address in hardware specific format.
628 ** Pointer to a variable that will hold the pool type for the address.
630 ** gctUINT32 * Offset
631 ** Pointer to a variable that will hold the offset for the address.
634 gckVGHARDWARE_SplitMemory(
635 IN gckVGHARDWARE Hardware
,
636 IN gctUINT32 Address
,
638 OUT gctUINT32
* Offset
641 gcmkHEADER_ARG("Hardware=0x%x Address=0x%x Pool=0x%x Offset = 0x%x",
642 Hardware
, Address
, Pool
, Offset
);
643 /* Verify the arguments. */
644 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
645 gcmkVERIFY_ARGUMENT(Pool
!= gcvNULL
);
646 gcmkVERIFY_ARGUMENT(Offset
!= gcvNULL
);
648 /* Dispatch on memory type. */
649 switch ((((((gctUINT32
) (Address
)) >> (0 ? 1:0)) & ((gctUINT32
) ((((1 ? 1:0) - (0 ? 1:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:0) - (0 ? 1:0) + 1)))))) ))
653 *Pool
= gcvPOOL_SYSTEM
;
657 /* Virtual memory. */
658 *Pool
= gcvPOOL_VIRTUAL
;
662 /* Invalid memory type. */
663 return gcvSTATUS_INVALID_ARGUMENT
;
666 /* Return offset of address. */
667 *Offset
= ((((gctUINT32
) (Address
)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 1:0) - (0 ? 1:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) | (((gctUINT32
) ((gctUINT32
) (0) & ((gctUINT32
) ((((1 ? 1:0) - (0 ? 1:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0)));
674 /*******************************************************************************
676 ** gckVGHARDWARE_Execute
678 ** Kickstart the hardware's command processor with an initialized command
683 ** gckVGHARDWARE Hardware
684 ** Pointer to the gckVGHARDWARE object.
687 ** Address of the command buffer.
690 ** Number of command-sized data units to be executed.
697 gckVGHARDWARE_Execute(
698 IN gckVGHARDWARE Hardware
,
699 IN gctUINT32 Address
,
705 gcmkHEADER_ARG("Hardware=0x%x Address=0x%x Count=0x%x",
706 Hardware
, Address
, Count
);
708 /* Verify the arguments. */
709 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
713 /* Enable all events. */
714 gcmkERR_BREAK(gckOS_WriteRegisterEx(
723 /* Write address register. */
724 gcmkERR_BREAK(gckOS_WriteRegisterEx(
728 gcmFIXADDRESS(Address
)
731 /* Write control register. */
732 gcmkERR_BREAK(gckOS_WriteRegisterEx(
741 /* Write address register. */
742 gcmkERR_BREAK(gckOS_WriteRegisterEx(
746 gcmFIXADDRESS(Address
)
749 /* Write control register. */
750 gcmkERR_BREAK(gckOS_WriteRegisterEx(
754 ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 16:16) - (0 ? 16:16) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))) | (((gctUINT32
) (0x1 & ((gctUINT32
) ((((1 ? 16:16) - (0 ? 16:16) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 16:16) - (0 ? 16:16) + 1))))))) << (0 ? 16:16))) |
755 ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) | (((gctUINT32
) ((gctUINT32
) (Count
) & ((gctUINT32
) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0)))
766 /* Return the status. */
770 /*******************************************************************************
772 ** gckVGHARDWARE_AlignToTile
774 ** Align the specified width and height to tile boundaries.
778 ** gckVGHARDWARE Hardware
779 ** Pointer to an gckVGHARDWARE object.
782 ** Type of alignment.
785 ** Pointer to the width to be aligned. If 'Width' is gcvNULL, no width
788 ** gctUINT32 * Height
789 ** Pointer to the height to be aligned. If 'Height' is gcvNULL, no height
795 ** Pointer to a variable that will receive the aligned width.
797 ** gctUINT32 * Height
798 ** Pointer to a variable that will receive the aligned height.
801 gckVGHARDWARE_AlignToTile(
802 IN gckVGHARDWARE Hardware
,
803 IN gceSURF_TYPE Type
,
804 IN OUT gctUINT32
* Width
,
805 IN OUT gctUINT32
* Height
808 gcmkHEADER_ARG("Hardware=0x%x Type=0x%x Width=0x%x Height=0x%x",
809 Hardware
, Type
, Width
, Height
);
810 /* Verify the arguments. */
811 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
813 if (Width
!= gcvNULL
)
815 /* Align the width. */
816 *Width
= gcmALIGN(*Width
, (Type
== gcvSURF_TEXTURE
) ? 4 : 16);
819 if (Height
!= gcvNULL
)
821 /* Special case for VG images. */
822 if ((*Height
== 0) && (Type
== gcvSURF_IMAGE
))
828 /* Align the height. */
829 *Height
= gcmALIGN(*Height
, 4);
838 /*******************************************************************************
840 ** gckVGHARDWARE_ConvertLogical
842 ** Convert a logical system address into a hardware specific address.
846 ** gckVGHARDWARE Hardware
847 ** Pointer to an gckVGHARDWARE object.
849 ** gctPOINTER Logical
850 ** Logical address to convert.
852 ** gctUINT32* Address
853 ** Return hardware specific address.
860 gckVGHARDWARE_ConvertLogical(
861 IN gckVGHARDWARE Hardware
,
862 IN gctPOINTER Logical
,
863 OUT gctUINT32
* Address
869 gcmkHEADER_ARG("Hardware=0x%x Logical=0x%x Address=0x%x",
870 Hardware
, Logical
, Address
);
872 /* Verify the arguments. */
873 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
874 gcmkVERIFY_ARGUMENT(Logical
!= gcvNULL
);
875 gcmkVERIFY_ARGUMENT(Address
!= gcvNULL
);
879 /* Convert logical address into a physical address. */
880 gcmkERR_BREAK(gckOS_GetPhysicalAddress(
881 Hardware
->os
, Logical
, &address
884 /* Return hardware specific address. */
885 *Address
= ((((gctUINT32
) (address
)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 1:0) - (0 ? 1:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) | (((gctUINT32
) (0x0 & ((gctUINT32
) ((((1 ? 1:0) - (0 ? 1:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0)));
893 /* Return the status. */
897 /*******************************************************************************
899 ** gckVGHARDWARE_QuerySystemMemory
901 ** Query the command buffer alignment and number of reserved bytes.
905 ** gckVGHARDWARE Harwdare
906 ** Pointer to an gckVGHARDWARE object.
910 ** gctSIZE_T * SystemSize
911 ** Pointer to a variable that receives the maximum size of the system
914 ** gctUINT32 * SystemBaseAddress
915 ** Poinetr to a variable that receives the base address for system
918 gceSTATUS
gckVGHARDWARE_QuerySystemMemory(
919 IN gckVGHARDWARE Hardware
,
920 OUT gctSIZE_T
* SystemSize
,
921 OUT gctUINT32
* SystemBaseAddress
924 gcmkHEADER_ARG("Hardware=0x%x SystemSize=0x%x SystemBaseAddress=0x%x",
925 Hardware
, SystemSize
, SystemBaseAddress
);
927 /* Verify the arguments. */
928 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
930 if (SystemSize
!= gcvNULL
)
932 /* Maximum system memory can be 2GB. */
933 *SystemSize
= (gctSIZE_T
)(1 << 31);
936 if (SystemBaseAddress
!= gcvNULL
)
938 /* Set system memory base address. */
939 *SystemBaseAddress
= ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 1:0) - (0 ? 1:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) | (((gctUINT32
) (0x0 & ((gctUINT32
) ((((1 ? 1:0) - (0 ? 1:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0)));
947 /*******************************************************************************
949 ** gckVGHARDWARE_SetMMU
951 ** Set the page table base address.
955 ** gckVGHARDWARE Harwdare
956 ** Pointer to an gckVGHARDWARE object.
958 ** gctPOINTER Logical
959 ** Logical address of the page table.
965 gceSTATUS
gckVGHARDWARE_SetMMU(
966 IN gckVGHARDWARE Hardware
,
967 IN gctPOINTER Logical
971 gctUINT32 address
= 0;
973 gcmkHEADER_ARG("Hardware=0x%x Logical=0x%x",
976 /* Verify the arguments. */
977 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
978 gcmkVERIFY_ARGUMENT(Logical
!= gcvNULL
);
982 /* Convert the logical address into an hardware address. */
983 gcmkERR_BREAK(gckVGHARDWARE_ConvertLogical(Hardware
, Logical
, &address
) );
985 /* Write the AQMemoryFePageTable register. */
986 gcmkERR_BREAK(gckOS_WriteRegisterEx(Hardware
->os
, gcvCORE_VG
,
988 gcmFIXADDRESS(address
)) );
990 /* Write the AQMemoryTxPageTable register. */
991 gcmkERR_BREAK(gckOS_WriteRegisterEx(Hardware
->os
, gcvCORE_VG
,
993 gcmFIXADDRESS(address
)) );
995 /* Write the AQMemoryPePageTable register. */
996 gcmkERR_BREAK(gckOS_WriteRegisterEx(Hardware
->os
, gcvCORE_VG
,
998 gcmFIXADDRESS(address
)) );
1000 /* Write the AQMemoryPezPageTable register. */
1001 gcmkERR_BREAK(gckOS_WriteRegisterEx(Hardware
->os
, gcvCORE_VG
,
1003 gcmFIXADDRESS(address
)) );
1005 /* Write the AQMemoryRaPageTable register. */
1006 gcmkERR_BREAK(gckOS_WriteRegisterEx(Hardware
->os
, gcvCORE_VG
,
1008 gcmFIXADDRESS(address
)) );
1013 /* Return the status. */
1017 /*******************************************************************************
1019 ** gckVGHARDWARE_FlushMMU
1021 ** Flush the page table.
1025 ** gckVGHARDWARE Harwdare
1026 ** Pointer to an gckVGHARDWARE object.
1032 gceSTATUS
gckVGHARDWARE_FlushMMU(
1033 IN gckVGHARDWARE Hardware
1037 gckVGCOMMAND command
;
1039 gcmkHEADER_ARG("Hardware=0x%x ", Hardware
);
1040 /* Verify the arguments. */
1041 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
1045 gcsCMDBUFFER_PTR commandBuffer
;
1046 gctUINT32_PTR buffer
;
1048 /* Create a shortcut to the command buffer object. */
1049 command
= Hardware
->kernel
->command
;
1051 /* Allocate command buffer space. */
1052 gcmkERR_BREAK(gckVGCOMMAND_Allocate(
1053 Hardware
->kernel
->command
, 8, &commandBuffer
, (gctPOINTER
*) &buffer
1057 = ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27))) | (((gctUINT32
) (0x01 & ((gctUINT32
) ((((1 ? 31:27) - (0 ? 31:27) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 31:27) - (0 ? 31:27) + 1))))))) << (0 ? 31:27)))
1058 | ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0))) | (((gctUINT32
) ((gctUINT32
) (0x0E04) & ((gctUINT32
) ((((1 ? 15:0) - (0 ? 15:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 15:0) - (0 ? 15:0) + 1))))))) << (0 ? 15:0)))
1059 | ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16))) | (((gctUINT32
) ((gctUINT32
) (1) & ((gctUINT32
) ((((1 ? 25:16) - (0 ? 25:16) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 25:16) - (0 ? 25:16) + 1))))))) << (0 ? 25:16)));
1062 = ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0))) | (((gctUINT32
) (0x1 & ((gctUINT32
) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1))))))) << (0 ? 0:0)))
1063 | ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 1:1) - (0 ? 1:1) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1))) | (((gctUINT32
) (0x1 & ((gctUINT32
) ((((1 ? 1:1) - (0 ? 1:1) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:1) - (0 ? 1:1) + 1))))))) << (0 ? 1:1)))
1064 | ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 2:2) - (0 ? 2:2) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2))) | (((gctUINT32
) (0x1 & ((gctUINT32
) ((((1 ? 2:2) - (0 ? 2:2) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 2:2) - (0 ? 2:2) + 1))))))) << (0 ? 2:2)))
1065 | ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 3:3) - (0 ? 3:3) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3))) | (((gctUINT32
) (0x1 & ((gctUINT32
) ((((1 ? 3:3) - (0 ? 3:3) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 3:3) - (0 ? 3:3) + 1))))))) << (0 ? 3:3)))
1066 | ((((gctUINT32
) (0)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 4:4) - (0 ? 4:4) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 4:4) - (0 ? 4:4) + 1))))))) << (0 ? 4:4))) | (((gctUINT32
) (0x1 & ((gctUINT32
) ((((1 ? 4:4) - (0 ? 4:4) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 4:4) - (0 ? 4:4) + 1))))))) << (0 ? 4:4)));
1068 gcmkERR_BREAK(gckVGCOMMAND_Execute(
1069 Hardware
->kernel
->command
,
1075 /* Return the status. */
1079 /*******************************************************************************
1081 ** gckVGHARDWARE_BuildVirtualAddress
1083 ** Build a virtual address.
1087 ** gckVGHARDWARE Harwdare
1088 ** Pointer to an gckVGHARDWARE object.
1091 ** Index into page table.
1094 ** Offset into page.
1098 ** gctUINT32 * Address
1099 ** Pointer to a variable receiving te hardware address.
1101 gceSTATUS
gckVGHARDWARE_BuildVirtualAddress(
1102 IN gckVGHARDWARE Hardware
,
1104 IN gctUINT32 Offset
,
1105 OUT gctUINT32
* Address
1110 gcmkHEADER_ARG("Hardware=0x%x Index=0x%x Offset=0x%x Address=0x%x",
1111 Hardware
, Index
, Offset
, Address
);
1113 /* Verify the arguments. */
1114 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
1115 gcmkVERIFY_ARGUMENT(Address
!= gcvNULL
);
1117 /* Build virtual address. */
1118 address
= (Index
<< 12) | Offset
;
1120 /* Set virtual type. */
1121 address
= ((((gctUINT32
) (address
)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 1:0) - (0 ? 1:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0))) | (((gctUINT32
) (0x2 & ((gctUINT32
) ((((1 ? 1:0) - (0 ? 1:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 1:0) - (0 ? 1:0) + 1))))))) << (0 ? 1:0)));
1123 /* Set the result. */
1128 return gcvSTATUS_OK
;
1132 gckVGHARDWARE_GetIdle(
1133 IN gckVGHARDWARE Hardware
,
1134 OUT gctUINT32
* Data
1138 gcmkHEADER_ARG("Hardware=0x%x Data=0x%x", Hardware
, Data
);
1139 /* Verify the arguments. */
1140 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
1141 gcmkVERIFY_ARGUMENT(Data
!= gcvNULL
);
1143 /* Read register and return. */
1144 status
= gckOS_ReadRegisterEx(Hardware
->os
, gcvCORE_VG
, 0x00004, Data
);
1150 gckVGHARDWARE_SetFastClear(
1151 IN gckVGHARDWARE Hardware
,
1158 if (!(((((gctUINT32
) (Hardware
->chipFeatures
)) >> (0 ? 0:0)) & ((gctUINT32
) ((((1 ? 0:0) - (0 ? 0:0) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 0:0) - (0 ? 0:0) + 1)))))) ))
1160 return gcvSTATUS_OK
;
1167 Enable
= (Hardware
->chipModel
> gcv500
) ||
1168 ((Hardware
->chipModel
== gcv500
) && (Hardware
->chipRevision
>= 3));
1171 gcmkERR_BREAK(gckOS_ReadRegisterEx(Hardware
->os
, gcvCORE_VG
,
1175 debug
= ((((gctUINT32
) (debug
)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? 20:20) - (0 ? 20:20) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 20:20) - (0 ? 20:20) + 1))))))) << (0 ? 20:20))) | (((gctUINT32
) ((gctUINT32
) (Enable
== 0) & ((gctUINT32
) ((((1 ? 20:20) - (0 ? 20:20) + 1) == 32) ? ~0 : (~(~0 << ((1 ? 20:20) - (0 ? 20:20) + 1))))))) << (0 ? 20:20)));
1177 #ifdef AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
1178 debug
= ((((gctUINT32
) (debug
)) & ~(((gctUINT32
) (((gctUINT32
) ((((1 ? AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
) - (0 ? AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
) + 1) == 32) ? ~0 : (~(~0 << ((1 ? AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
) - (0 ? AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
) + 1))))))) << (0 ? AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
))) | (((gctUINT32
) ((gctUINT32
) (Enable
== 0) & ((gctUINT32
) ((((1 ? AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
) - (0 ? AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
) + 1) == 32) ? ~0 : (~(~0 << ((1 ? AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
) - (0 ? AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
) + 1))))))) << (0 ? AQ_MEMORY_DEBUG_DISABLE_Z_COMPRESSION
)));
1181 gcmkERR_BREAK(gckOS_WriteRegisterEx(Hardware
->os
, gcvCORE_VG
,
1185 Hardware
->allowFastClear
= Enable
;
1195 gckVGHARDWARE_ReadInterrupt(
1196 IN gckVGHARDWARE Hardware
,
1197 OUT gctUINT32_PTR IDs
1201 gcmkHEADER_ARG("Hardware=0x%x IDs=0x%x", Hardware
, IDs
);
1203 /* Verify the arguments. */
1204 gcmkVERIFY_OBJECT(Hardware
, gcvOBJ_HARDWARE
);
1205 gcmkVERIFY_ARGUMENT(IDs
!= gcvNULL
);
1207 /* Read AQIntrAcknowledge register. */
1208 status
= gckOS_ReadRegisterEx(Hardware
->os
, gcvCORE_VG
,
1215 #endif /* gcdENABLE_VG */