1*35db13eaSAxel Dörfler /* 2*35db13eaSAxel Dörfler Haiku S3 Savage driver adapted from the X.org Savage driver. 3*35db13eaSAxel Dörfler 4*35db13eaSAxel Dörfler Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. 5*35db13eaSAxel Dörfler Copyright (c) 2003-2006, X.Org Foundation 6*35db13eaSAxel Dörfler 7*35db13eaSAxel Dörfler Copyright 2007-2008 Haiku, Inc. All rights reserved. 8*35db13eaSAxel Dörfler Distributed under the terms of the MIT license. 9*35db13eaSAxel Dörfler 10*35db13eaSAxel Dörfler Authors: 11*35db13eaSAxel Dörfler Gerald Zajac 2007-2008 12*35db13eaSAxel Dörfler */ 13*35db13eaSAxel Dörfler 14*35db13eaSAxel Dörfler #include "accel.h" 15*35db13eaSAxel Dörfler #include "savage.h" 16*35db13eaSAxel Dörfler 17*35db13eaSAxel Dörfler #include <string.h> 18*35db13eaSAxel Dörfler #include <ddc.h> 19*35db13eaSAxel Dörfler #include <edid.h> 20*35db13eaSAxel Dörfler 21*35db13eaSAxel Dörfler 22*35db13eaSAxel Dörfler 23*35db13eaSAxel Dörfler static status_t 24*35db13eaSAxel Dörfler GetI2CSignals(void* cookie, int* _clock, int* data) 25*35db13eaSAxel Dörfler { 26*35db13eaSAxel Dörfler uint32 index = (uint32)cookie; 27*35db13eaSAxel Dörfler uint8 value = ReadCrtcReg(index); 28*35db13eaSAxel Dörfler 29*35db13eaSAxel Dörfler *_clock = (value & 0x4) != 0; 30*35db13eaSAxel Dörfler *data = (value & 0x8) != 0; 31*35db13eaSAxel Dörfler return B_OK; 32*35db13eaSAxel Dörfler } 33*35db13eaSAxel Dörfler 34*35db13eaSAxel Dörfler 35*35db13eaSAxel Dörfler static status_t 36*35db13eaSAxel Dörfler SetI2CSignals(void* cookie, int _clock, int data) 37*35db13eaSAxel Dörfler { 38*35db13eaSAxel Dörfler uint32 index = (uint32)cookie; 39*35db13eaSAxel Dörfler uint8 value = 0x10; 40*35db13eaSAxel Dörfler 41*35db13eaSAxel Dörfler if (_clock) 42*35db13eaSAxel Dörfler value |= 0x1; 43*35db13eaSAxel Dörfler if (data) 44*35db13eaSAxel Dörfler value |= 0x2; 45*35db13eaSAxel Dörfler 46*35db13eaSAxel Dörfler WriteCrtcReg(index, value); 47*35db13eaSAxel Dörfler return B_OK; 48*35db13eaSAxel Dörfler } 49*35db13eaSAxel Dörfler 50*35db13eaSAxel Dörfler 51*35db13eaSAxel Dörfler 52*35db13eaSAxel Dörfler bool 53*35db13eaSAxel Dörfler Savage_GetEdidInfo(void) 54*35db13eaSAxel Dörfler { 55*35db13eaSAxel Dörfler // Get the EDID info and return true if successful. 56*35db13eaSAxel Dörfler 57*35db13eaSAxel Dörfler SharedInfo& si = *gInfo.sharedInfo; 58*35db13eaSAxel Dörfler 59*35db13eaSAxel Dörfler uint32 DDCPort = 0; 60*35db13eaSAxel Dörfler 61*35db13eaSAxel Dörfler switch (si.chipType) { 62*35db13eaSAxel Dörfler case S3_SAVAGE_3D: 63*35db13eaSAxel Dörfler case S3_SAVAGE_MX: 64*35db13eaSAxel Dörfler case S3_SUPERSAVAGE: 65*35db13eaSAxel Dörfler case S3_SAVAGE2000: 66*35db13eaSAxel Dörfler DDCPort = 0xAA; 67*35db13eaSAxel Dörfler break; 68*35db13eaSAxel Dörfler 69*35db13eaSAxel Dörfler case S3_SAVAGE4: 70*35db13eaSAxel Dörfler case S3_PROSAVAGE: 71*35db13eaSAxel Dörfler case S3_TWISTER: 72*35db13eaSAxel Dörfler case S3_PROSAVAGE_DDR: 73*35db13eaSAxel Dörfler DDCPort = 0xB1; 74*35db13eaSAxel Dörfler break; 75*35db13eaSAxel Dörfler } 76*35db13eaSAxel Dörfler 77*35db13eaSAxel Dörfler i2c_bus bus; 78*35db13eaSAxel Dörfler bus.cookie = (void*)DDCPort; 79*35db13eaSAxel Dörfler bus.set_signals = &SetI2CSignals; 80*35db13eaSAxel Dörfler bus.get_signals = &GetI2CSignals; 81*35db13eaSAxel Dörfler ddc2_init_timing(&bus); 82*35db13eaSAxel Dörfler 83*35db13eaSAxel Dörfler uint8 tmp = ReadCrtcReg(DDCPort); 84*35db13eaSAxel Dörfler WriteCrtcReg(DDCPort, tmp | 0x13); 85*35db13eaSAxel Dörfler 86*35db13eaSAxel Dörfler si.bHaveEDID = (ddc2_read_edid1(&bus, &(si.edidInfo), NULL, NULL) == B_OK); 87*35db13eaSAxel Dörfler 88*35db13eaSAxel Dörfler WriteCrtcReg(DDCPort, tmp); 89*35db13eaSAxel Dörfler 90*35db13eaSAxel Dörfler if (si.bHaveEDID) { 91*35db13eaSAxel Dörfler #ifdef ENABLE_DEBUG_TRACE 92*35db13eaSAxel Dörfler edid_dump(&(si.edidInfo)); 93*35db13eaSAxel Dörfler #endif 94*35db13eaSAxel Dörfler } else { 95*35db13eaSAxel Dörfler TRACE("Savage_GetEdidInfo() failed!\n"); 96*35db13eaSAxel Dörfler } 97*35db13eaSAxel Dörfler 98*35db13eaSAxel Dörfler return si.bHaveEDID; 99*35db13eaSAxel Dörfler } 100