Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c Fix block offsets for ddc_read_edid_block.



details:   https://anonhg.NetBSD.org/src/rev/23e8435e72ac
branches:  trunk
changeset: 339501:23e8435e72ac
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jul 25 15:20:49 2015 +0000

description:
Fix block offsets for ddc_read_edid_block.

diffstat:

 sys/dev/i2c/ddc.c |  16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (49 lines):

diff -r 9df7ef22ff12 -r 23e8435e72ac sys/dev/i2c/ddc.c
--- a/sys/dev/i2c/ddc.c Sat Jul 25 15:19:54 2015 +0000
+++ b/sys/dev/i2c/ddc.c Sat Jul 25 15:20:49 2015 +0000
@@ -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 @@
 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;
 }
 



Home | Main Index | Thread Index | Old Index