From 28401b25cc5c1afb272e506cef196ba3a1258bd3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 30 Nov 2006 15:45:13 -0800 Subject: Add debug code for the bit-banging I2C implementation. --- src/i830_i2c.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/i830_i2c.c b/src/i830_i2c.c index 8b93c8e6..ea828ffb 100644 --- a/src/i830_i2c.c +++ b/src/i830_i2c.c @@ -273,12 +273,51 @@ i830I2CGetBits(I2CBusPtr b, int *clock, int *data) *clock = (val & GPIO_CLOCK_VAL_IN) != 0; } +#define I2C_DEBUG 0 + +#if I2C_DEBUG +static int last_clock = 0, last_data = 0; +static Bool first = TRUE; +#endif + static void i830I2CPutBits(I2CBusPtr b, int clock, int data) { +#if I2C_DEBUG + int cur_clock, cur_data; + char *debug = ""; +#endif + ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex]; I830Ptr pI830 = I830PTR(pScrn); +#if I2C_DEBUG + if (!first && cur_clock != last_clock && cur_data != last_data) { + /* If we change the clock and data simultaneously, that would be bad. + * I thought we did sometimes, but maybe not. + */ + debug = " <--"; + } + + last_clock = cur_clock; + last_data = cur_data; + + i830I2CGetBits(b, &cur_clock, &cur_data); + + if (first) { + ErrorF("I2C Debug: C D C D\n"); + first = FALSE; + } + + ErrorF("Setting I2C 0x%08x to: %c %c (at: %c %c)%s\n", + b->DriverPrivate.uval, + clock ? '^' : 'v', + data ? '^' : 'v', + cur_clock ? '^' : 'v', + cur_data ? '^' : 'v', + debug); +#endif + OUTREG(b->DriverPrivate.uval, (data ? GPIO_DATA_VAL_OUT : 0) | (clock ? GPIO_CLOCK_VAL_OUT : 0) | -- cgit v1.2.3