1 /* 2 * Copyright 2010 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * Gerald Zajac 7 */ 8 9 #include "accelerant.h" 10 #include "3dfx.h" 11 12 13 14 uint32 TDFX_GetVideoMemorySize(void)15TDFX_GetVideoMemorySize(void) 16 { 17 // Return the number of bytes of video memory. 18 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; 24 25 if (gInfo.sharedInfo->chipType == VOODOO_5) { 26 chipSize = 1 << ((dramInit0 >> 27) & 0x7); 27 } else { 28 // Banshee or Voodoo3 29 if (memType == MEM_TYPE_SDRAM) 30 chipSize = 2; 31 else 32 chipSize = (dramInit0 & SGRAM_TYPE) ? 2 : 1; 33 } 34 35 // Disable block writes for SDRAM. 36 37 uint32 miscInit1 = INREG32(MISC_INIT1); 38 if (memType == MEM_TYPE_SDRAM) { 39 miscInit1 |= DISABLE_2D_BLOCK_WRITE; 40 } 41 miscInit1 |= 1; 42 OUTREG32(MISC_INIT1, miscInit1); 43 44 return chipSize * numChips * 1024 * 1024; 45 } 46 47 48 status_t TDFX_Init(void)49TDFX_Init(void) 50 { 51 TRACE("TDFX_Init()\n"); 52 53 SharedInfo& si = *gInfo.sharedInfo; 54 55 si.videoMemSize = TDFX_GetVideoMemorySize(); 56 57 si.cursorOffset = 0; 58 si.frameBufferOffset = si.cursorOffset + CURSOR_BYTES; 59 si.maxFrameBufferSize = si.videoMemSize - si.frameBufferOffset; 60 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); 64 65 switch (si.chipType) { 66 case BANSHEE: 67 si.maxPixelClock = 270000; 68 break; 69 case VOODOO_3: 70 si.maxPixelClock = 300000; 71 break; 72 case VOODOO_5: 73 si.maxPixelClock = 350000; 74 break; 75 default: 76 TRACE("Undefined chip type: %d\n", si.chipType); 77 return B_ERROR; 78 } 79 80 // Set up the array of color spaces supported by the 3dfx chips. 81 82 si.colorSpaces[0] = B_CMAP8; 83 si.colorSpaces[1] = B_RGB16; 84 si.colorSpaces[2] = B_RGB32; 85 si.colorSpaceCount = 3; 86 87 // Setup the mode list. 88 89 return CreateModeList(IsModeUsable); 90 } 91