BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / add-ons / accelerants / s3 / savage_edid.cpp
blob9bea23ab8ca5428bac92fa9137c391c145d647a3
1 /*
2 Haiku S3 Savage driver adapted from the X.org Savage driver.
4 Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
5 Copyright (c) 2003-2006, X.Org Foundation
7 Copyright 2007-2008 Haiku, Inc. All rights reserved.
8 Distributed under the terms of the MIT license.
10 Authors:
11 Gerald Zajac 2007-2008
14 #include "accel.h"
15 #include "savage.h"
17 #include <string.h>
18 #include <ddc.h>
19 #include <edid.h>
23 static status_t
24 GetI2CSignals(void* cookie, int* _clock, int* data)
26 uint32 index = (uint32)cookie;
27 uint8 value = ReadCrtcReg(index);
29 *_clock = (value & 0x4) != 0;
30 *data = (value & 0x8) != 0;
31 return B_OK;
35 static status_t
36 SetI2CSignals(void* cookie, int _clock, int data)
38 uint32 index = (uint32)cookie;
39 uint8 value = 0x10;
41 if (_clock)
42 value |= 0x1;
43 if (data)
44 value |= 0x2;
46 WriteCrtcReg(index, value);
47 return B_OK;
52 bool
53 Savage_GetEdidInfo(edid1_info& edidInfo)
55 // Get the EDID info and return true if successful.
57 SharedInfo& si = *gInfo.sharedInfo;
59 uint32 DDCPort = 0;
61 switch (si.chipType) {
62 case S3_SAVAGE_3D:
63 case S3_SAVAGE_MX:
64 case S3_SUPERSAVAGE:
65 case S3_SAVAGE2000:
66 DDCPort = 0xAA;
67 break;
69 case S3_SAVAGE4:
70 case S3_PROSAVAGE:
71 case S3_TWISTER:
72 case S3_PROSAVAGE_DDR:
73 DDCPort = 0xB1;
74 break;
77 i2c_bus bus;
78 bus.cookie = (void*)DDCPort;
79 bus.set_signals = &SetI2CSignals;
80 bus.get_signals = &GetI2CSignals;
81 ddc2_init_timing(&bus);
83 uint8 tmp = ReadCrtcReg(DDCPort);
84 WriteCrtcReg(DDCPort, tmp | 0x13);
86 bool bResult = (ddc2_read_edid1(&bus, &edidInfo, NULL, NULL) == B_OK);
87 WriteCrtcReg(DDCPort, tmp);
89 return bResult;