drm/kms: Make i2c buses faster
Subsystems (3)
PATCH 1/2 drm/kms: Make i2c buses faster
A udelay value of 20 leads to an I2C bus running at only 25 kbps. I2C devices can typically operate faster than this, 50 kbps should be fine for all devices (and compliant devices can always stretch the clock if needed.)
FWIW, the vast majority of framebuffer drivers set udelay to 10 already. So set it to 10 in DRM drivers too, this will make EDID block reads faster. We might even lower the udelay value later if no problem is reported.
---
Already sent on: 2011-10-21.
drivers/gpu/drm/i915/intel_i2c.c | 2 +- drivers/gpu/drm/radeon/radeon_i2c.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_i2c.c +1 -1
@@ -37,7 +37,7 @@/* Intel GPIO access functions */ -#define I2C_RISEFALL_TIME 20 +#define I2C_RISEFALL_TIME 10static inline struct intel_gmbus *to_intel_gmbus (struct i2c_adapter *i2c)
drivers/gpu/drm/radeon/radeon_i2c.c +1 -1
@@ -924,7 +924,7 @@ struct radeon_i2c_chan *radeon_i2c_creat i2c->algo.bit.setscl = set_clock; i2c->algo.bit.getsda = get_data; i2c->algo.bit.getscl = get_clock; - i2c->algo.bit.udelay =20 ; + i2c->algo.bit.udelay =10 ;/* vesa says 2.2 ms is enough, 1 jiffy doesn't seem to always * make this, 2 jiffies is a lot more reliable */ i2c->algo.bit.timeout =2 ;
Signature · 2 lines
Jean Delvare Suse L3
Quoted 10 lines · Jean Delvare
A udelay value of 20 leads to an I2C bus running at only 25 kbps. I2C devices can typically operate faster than this, 50 kbps should be fine for all devices (and compliant devices can always stretch the clock if needed.)
FWIW, the vast majority of framebuffer drivers set udelay to 10 already. So set it to 10 in DRM drivers too, this will make EDID block reads faster. We might even lower the udelay value later if no problem is reported.
Quoted 5 lines
Signed-off-by Jean Delvare <[email protected]>Acked-by Eugeni Dodonov <[email protected]>Cc Dave Airlie <[email protected]>Cc Keith Packard <[email protected]>Cc Alex Deucher <[email protected]>
Quoted 33 lines
---
Already sent on: 2011-10-21.drivers/gpu/drm/i915/intel_i2c.c | 2 +-
drivers/gpu/drm/radeon/radeon_i2c.c | 2 +-2 files changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_i2c.c 2012-01-28 10:28:16.884668894 +0100 renamed from drivers/gpu/drm/i915/intel_i2c.c 2012-01-28 10:12:16.554480007 +0100 +1
-1@@ -37,7 +37,7 @@ /* Intel GPIO access functions */ -#define I2C_RISEFALL_TIME 20 +#define I2C_RISEFALL_TIME 10static inline struct
intel_gmbus*
to_intel_gmbus(structi2c_adapter*i2c)drivers/gpu/drm/radeon/radeon_i2c.c 2012-01-28 10:28:16.886668894 +0100 renamed from drivers/gpu/drm/radeon/radeon_i2c.c 2012-01-28 10:12:16.555480007 +0100 +1
-2@@ -924,7 +924,7 @@ struct radeon_i2c_chan *radeon_i2c_creat i2c->algo.bit.setscl = set_clock; i2c->algo.bit.getsda = get_data; i2c->algo.bit.getscl = get_clock; - i2c->algo.bit.udelay = 20; + i2c->algo.bit.udelay = 10; /* vesa says 2.2 ms is enough, 1 jiffy doesn't seem to always * make this, 2 jiffies is a lot more reliable */ i2c->algo.bit.timeout = 2; --Jean Delvare
Suse L3
Quoted 9 lines · Jean Delvare
A udelay value of 20 leads to an I2C bus running at only 25 kbps. I2C devices can typically operate faster than this, 50 kbps should be fine for all devices (and compliant devices can always stretch the clock if needed.)
FWIW, the vast majority of framebuffer drivers set udelay to 10 already. So set it to 10 in DRM drivers too, this will make EDID block reads faster. We might even lower the udelay value later if no problem is reported.
That runs the DDC at a whopping 50kbps, which is half of the maximum rate specified in the DDC/CI standard. I don't know if we can count on clock stretching (http://www.i2c-bus.org/clock-stretching/), but if so, I don't know why we wouldn't just go to the standard 100kbps data rate and be done with it.
Might be nice to see what frequency Windows uses for i2c; anyone want to pull a vga cable apart and hook up a logic analyser?
Signature · 1 line
[email protected]
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Keith,
Sorry for the late reply.
Quoted 12 lines · Keith Packard
Quoted 9 lines · Jean Delvare
A udelay value of 20 leads to an I2C bus running at only 25 kbps. I2C devices can typically operate faster than this, 50 kbps should be fine for all devices (and compliant devices can always stretch the clock if needed.)
FWIW, the vast majority of framebuffer drivers set udelay to 10 already. So set it to 10 in DRM drivers too, this will make EDID block reads faster. We might even lower the udelay value later if no problem is reported.
Quoted 5 lines
That runs the DDC at a whopping 50kbps, which is half of the maximum rate specified in the DDC/CI standard. I don't know if we can count
on clock stretching (http://www.i2c-bus.org/clock-stretching/), but if so, I don't know why we wouldn't just go to the standard 100kbps data rate and be done with it.
We may end up doing that. I wanted to play it safe for now as at least Alan Cox expressed concerns with increasing the speed of DDC buses. I don't share them, but being cautious can't hurt.
Clock stretching is optional, each slave is free to implement it or not. I very much doubt it is needed when reading and EDID though, even at 100 kbps. Typically what takes time is writing to EEPROMs, but in general EEPROMs will buffer the write and simply stop responding to their slave addresses until done. This is why most EEPROMs have a documented write page size.
Displays must be interoperable by design, so I'd hope that every serious display maker would only use EEPROMs that can either cope with 100 kbps or do clock stretching as needed. I have no doubt crappy hardware exists, but I'd rather decrease the clock speed on repeated errors than default to a slow clock speed. Users with good hardware should get the best out of it.
Quoted 2 lines
Might be nice to see what frequency Windows uses for i2c; anyone want
to pull a vga cable apart and hook up a logic analyser?
Can't do that, sorry. It would certainly be valuable if someone has the time, hardware and interest, however I don't think "Windows" uses a frequency, rather separate video drivers are likely to have their own implementation and speed (if nothing else, simply because recent video cards use hardware I2C engines rather than bit-banging.)
Signature · 2 lines
Jean Delvare Suse L3