tcp: Add APICall trace entry and move TRACEs into locked parts.
[haiku.git] / src / add-ons / accelerants / 3dfx / 3dfx_edid.cpp
blobb89e2a7f139ec79689922c360669687d6917dc26
1 /*
2 * Copyright 2010 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
5 * Authors:
6 * Gerald Zajac
7 */
9 #include "accelerant.h"
10 #include "3dfx.h"
12 #include <string.h>
13 #include <ddc.h>
14 #include <edid.h>
18 static status_t
19 GetI2CSignals(void* cookie, int* _clock, int* data)
21 (void)cookie; // avoid compiler warning for unused arg
23 uint32 reg = INREG32(VIDEO_SERIAL_PARALLEL_PORT);
24 *_clock = (reg & VSP_SCL0_IN) ? 1 : 0;;
25 *data = (reg & VSP_SDA0_IN) ? 1 : 0;
26 return B_OK;
30 static status_t
31 SetI2CSignals(void* cookie, int _clock, int data)
33 (void)cookie; // avoid compiler warning for unused arg
35 uint32 reg = (INREG32(VIDEO_SERIAL_PARALLEL_PORT)
36 & ~(VSP_SDA0_OUT | VSP_SCL0_OUT));
37 reg = (reg | (_clock ? VSP_SCL0_OUT : 0) | (data ? VSP_SDA0_OUT : 0));
38 OUTREG32(VIDEO_SERIAL_PARALLEL_PORT, reg);
39 return B_OK;
44 bool
45 TDFX_GetEdidInfo(edid1_info& edidInfo)
47 // Get the EDID info and return true if successful.
49 i2c_bus bus;
51 bus.cookie = (void*)NULL;
52 bus.set_signals = &SetI2CSignals;
53 bus.get_signals = &GetI2CSignals;
54 ddc2_init_timing(&bus);
56 uint32 reg = INREG32(VIDEO_SERIAL_PARALLEL_PORT);
57 OUTREG32(VIDEO_SERIAL_PARALLEL_PORT, reg | VSP_ENABLE_IIC0);
59 bool bResult = (ddc2_read_edid1(&bus, &edidInfo, NULL, NULL) == B_OK);
61 OUTREG32(VIDEO_SERIAL_PARALLEL_PORT, reg);
63 return bResult;