Module Name: src
Committed By: jmcneill
Date: Sat Jul 25 15:20:49 UTC 2015
Modified Files:
src/sys/dev/i2c: ddc.c
Log Message:
Fix block offsets for ddc_read_edid_block.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/ddc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/i2c/ddc.c
diff -u src/sys/dev/i2c/ddc.c:1.5 src/sys/dev/i2c/ddc.c:1.6
--- src/sys/dev/i2c/ddc.c:1.5 Sun May 17 01:27:16 2015
+++ src/sys/dev/i2c/ddc.c Sat Jul 25 15:20:49 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: ddc.c,v 1.5 2015/05/17 01:27:16 jmcneill Exp $ */
+/* $NetBSD: ddc.c,v 1.6 2015/07/25 15:20:49 jmcneill Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ddc.c,v 1.5 2015/05/17 01:27:16 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ddc.c,v 1.6 2015/07/25 15:20:49 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -98,20 +98,28 @@ ddc_read_edid(i2c_tag_t tag, uint8_t *de
int
ddc_read_edid_block(i2c_tag_t tag, uint8_t *dest, size_t len, uint8_t block)
{
+ uint8_t edid[256];
uint8_t wbuf[2];
int error;
if ((error = iic_acquire_bus(tag, I2C_F_POLL)) != 0)
return error;
- wbuf[0] = block; /* start address */
+ wbuf[0] = block >> 1; /* start address */
if ((error = iic_exec(tag, I2C_OP_READ_WITH_STOP, DDC_ADDR, wbuf, 1,
- dest, len, I2C_F_POLL)) != 0) {
+ edid, sizeof(edid), I2C_F_POLL)) != 0) {
iic_release_bus(tag, I2C_F_POLL);
return error;
}
iic_release_bus(tag, I2C_F_POLL);
+
+ if (block & 1) {
+ memcpy(dest, &edid[128], min(len, 128));
+ } else {
+ memcpy(dest, &edid[0], min(len, 128));
+ }
+
return 0;
}