2 * Copyright 2010 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
9 #include "accelerant.h"
15 TDFX_GetVideoMemorySize(void)
17 // Return the number of bytes of video memory.
19 uint32 chipSize
; // size is in megabytes
20 uint32 dramInit0
= INREG32(DRAM_INIT0
);
21 uint32 dramInit1
= INREG32(DRAM_INIT1
);
22 uint32 numChips
= (dramInit0
& SGRAM_NUM_CHIPSETS
) ? 8 : 4;
23 int memType
= (dramInit1
& MCTL_TYPE_SDRAM
) ? MEM_TYPE_SDRAM
: MEM_TYPE_SGRAM
;
25 if (gInfo
.sharedInfo
->chipType
== VOODOO_5
) {
26 chipSize
= 1 << ((dramInit0
>> 27) & 0x7);
29 if (memType
== MEM_TYPE_SDRAM
)
32 chipSize
= (dramInit0
& SGRAM_TYPE
) ? 2 : 1;
35 // Disable block writes for SDRAM.
37 uint32 miscInit1
= INREG32(MISC_INIT1
);
38 if (memType
== MEM_TYPE_SDRAM
) {
39 miscInit1
|= DISABLE_2D_BLOCK_WRITE
;
42 OUTREG32(MISC_INIT1
, miscInit1
);
44 return chipSize
* numChips
* 1024 * 1024;
51 TRACE("TDFX_Init()\n");
53 SharedInfo
& si
= *gInfo
.sharedInfo
;
55 si
.videoMemSize
= TDFX_GetVideoMemorySize();
58 si
.frameBufferOffset
= si
.cursorOffset
+ CURSOR_BYTES
;
59 si
.maxFrameBufferSize
= si
.videoMemSize
- si
.frameBufferOffset
;
61 TRACE("Video Memory size: %d MB\n", si
.videoMemSize
/ 1024 / 1024);
62 TRACE("frameBufferOffset: 0x%x cursorOffset: 0x%x\n",
63 si
.frameBufferOffset
, si
.cursorOffset
);
65 switch (si
.chipType
) {
67 si
.maxPixelClock
= 270000;
70 si
.maxPixelClock
= 300000;
73 si
.maxPixelClock
= 350000;
76 TRACE("Undefined chip type: %d\n", si
.chipType
);
80 // Set up the array of color spaces supported by the 3dfx chips.
82 si
.colorSpaces
[0] = B_CMAP8
;
83 si
.colorSpaces
[1] = B_RGB16
;
84 si
.colorSpaces
[2] = B_RGB32
;
85 si
.colorSpaceCount
= 3;
87 // Setup the mode list.
89 return CreateModeList(IsModeUsable
);