status_t Rage128_SetDisplayMode(const DisplayModeEx& mode) { // The code to actually configure the display. // All the error checking must be done in ProposeDisplayMode(), // and assume that the mode values we get here are acceptable. DisplayParams params; // where computed parameters are saved if (gInfo.sharedInfo->displayType == MT_VGA) { // Chip is connected to a monitor via a VGA connector. if ( ! CalculateCrtcRegisters(mode, params)) return B_BAD_VALUE; if ( ! CalculatePLLRegisters(mode, params)) return B_BAD_VALUE; if ( ! CalculateDDARegisters(mode, params)) return B_BAD_VALUE; SetRegisters(params); } else { // Chip is connected to a laptop LCD monitor; or via a DVI interface. uint16 vesaMode = GetVesaModeNumber(display_mode(mode), mode.bitsPerPixel); if (vesaMode == 0) return B_BAD_VALUE; if (ioctl(gInfo.deviceFileDesc, ATI_SET_VESA_DISPLAY_MODE, &vesaMode, sizeof(vesaMode)) != B_OK) return B_ERROR; } Rage128_AdjustFrame(mode); // Initialize the palette so that color depths > 8 bits/pixel will display // the correct colors. // Select primary monitor and enable 8-bit color. OUTREGM(R128_DAC_CNTL, R128_DAC_8BIT_EN, R128_DAC_PALETTE_ACC_CTL | R128_DAC_8BIT_EN); OUTREG8(R128_PALETTE_INDEX, 0); // set first color index for (int i = 0; i < 256; i++) OUTREG(R128_PALETTE_DATA, (i << 16) | (i << 8) | i ); Rage128_EngineInit(mode); return B_OK; }
status_t Mach64_SetDisplayMode(const DisplayModeEx& mode) { // The code to actually configure the display. // All the error checking must be done in ProposeDisplayMode(), // and assume that the mode values we get here are acceptable. SharedInfo& si = *gInfo.sharedInfo; if (si.displayType == MT_VGA) { // Chip is connected to a monitor via a VGA connector. SetCrtcRegisters(mode); SetClockRegisters(mode); if (si.chipType >= MACH64_264VTB) SetDSPRegisters(mode); } else { // Chip is connected to a laptop LCD monitor; or via a DVI interface. uint16 vesaMode = GetVesaModeNumber(display_mode(mode), mode.bitsPerPixel); if (vesaMode == 0) return B_BAD_VALUE; status_t status = ioctl(gInfo.deviceFileDesc, ATI_SET_VESA_DISPLAY_MODE, &vesaMode, sizeof(vesaMode)); if (status != B_OK) return status; } Mach64_AdjustFrame(mode); // Initialize the palette so that the various color depths will display // the correct colors. OUTREGM(DAC_CNTL, DAC_8BIT_EN, DAC_8BIT_EN); OUTREG8(DAC_MASK, 0xff); OUTREG8(DAC_W_INDEX, 0); // initial color index for (int i = 0; i < 256; i++) { OUTREG8(DAC_DATA, i); OUTREG8(DAC_DATA, i); OUTREG8(DAC_DATA, i); } Mach64_EngineInit(mode); return B_OK; }