1 2 #include <stdlib.h> 3 #include <string.h> 4 5 #include "timing.h" 6 #include "libvga.h" /* for __svgalib_infotable and ramdac inlines */ 7 #include "ramdac/ramdac.h" 8 #include "accel.h" 9 10 11 /* 12 * This is a temporary function that allocates and fills in a ModeInfo 13 * structure based on a svgalib mode number. 14 */ 15 16 ModeInfo * __svgalib_createModeInfoStructureForSvgalibMode(int mode)17 __svgalib_createModeInfoStructureForSvgalibMode(int mode) 18 { 19 ModeInfo *modeinfo; 20 /* Create the new ModeInfo structure. */ 21 modeinfo = malloc(sizeof(ModeInfo)); 22 modeinfo->width = __svgalib_infotable[mode].xdim; 23 modeinfo->height = __svgalib_infotable[mode].ydim; 24 modeinfo->bytesPerPixel = __svgalib_infotable[mode].bytesperpixel; 25 switch (__svgalib_infotable[mode].colors) { 26 case 16: 27 modeinfo->colorBits = 4; 28 break; 29 case 256: 30 modeinfo->colorBits = 8; 31 break; 32 case 32768: 33 modeinfo->colorBits = 15; 34 modeinfo->blueOffset = 0; 35 modeinfo->greenOffset = 5; 36 modeinfo->redOffset = 10; 37 modeinfo->blueWeight = 5; 38 modeinfo->greenWeight = 5; 39 modeinfo->redWeight = 5; 40 break; 41 case 65536: 42 modeinfo->colorBits = 16; 43 modeinfo->blueOffset = 0; 44 modeinfo->greenOffset = 5; 45 modeinfo->redOffset = 11; 46 modeinfo->blueWeight = 5; 47 modeinfo->greenWeight = 6; 48 modeinfo->redWeight = 5; 49 break; 50 case 256 * 65536: 51 modeinfo->colorBits = 24; 52 modeinfo->blueOffset = 0; 53 modeinfo->greenOffset = 8; 54 modeinfo->redOffset = 16; 55 modeinfo->blueWeight = 8; 56 modeinfo->greenWeight = 8; 57 modeinfo->redWeight = 8; 58 break; 59 } 60 modeinfo->bitsPerPixel = modeinfo->bytesPerPixel * 8; 61 if (__svgalib_infotable[mode].colors == 16) 62 modeinfo->bitsPerPixel = 4; 63 modeinfo->lineWidth = __svgalib_infotable[mode].xbytes; 64 return modeinfo; 65 } 66 67 68 /* 69 * This function converts a number of significant color bits to a matching 70 * DAC mode type as defined in the RAMDAC interface. 71 */ 72 __svgalib_colorbits_to_colormode(int bpp,int colorbits)73int __svgalib_colorbits_to_colormode(int bpp, int colorbits) 74 { 75 if (colorbits == 8) 76 return CLUT8_6; 77 if (colorbits == 15) 78 return RGB16_555; 79 if (colorbits == 16) 80 return RGB16_565; 81 if (colorbits == 24) { 82 if (bpp == 24) 83 return RGB24_888_B; 84 else 85 return RGB32_888_B; 86 } 87 return CLUT8_6; 88 } 89 90 91 /* 92 * Clear the accelspecs structure (disable acceleration). 93 */ 94 __svgalib_clear_accelspecs(AccelSpecs * accelspecs)95void __svgalib_clear_accelspecs(AccelSpecs * accelspecs) 96 { 97 memset(accelspecs, 0, sizeof(AccelSpecs)); 98 } 99