summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm/drm_dp_helper.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2013-03-30 18:33:57 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2013-03-30 18:33:57 +0000
commit6962e1ef12ad2ee6194530e2f530d63ca8ca421e (patch)
treee622a1321c7ca84ff3fd56efadf18d9b28e6ad4f /sys/dev/pci/drm/drm_dp_helper.c
parent07c1e62b86b41e0ee57fc9f1dc70b27fe6d80408 (diff)
Fix i2c_algo_dp_aux_exec() such that it handles all transactions needed by
our i2c framework. Unbreaks EDID fetching over displayport. ok jsg@
Diffstat (limited to 'sys/dev/pci/drm/drm_dp_helper.c')
-rw-r--r--sys/dev/pci/drm/drm_dp_helper.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/sys/dev/pci/drm/drm_dp_helper.c b/sys/dev/pci/drm/drm_dp_helper.c
index 31c10018591..88461e21f5d 100644
--- a/sys/dev/pci/drm/drm_dp_helper.c
+++ b/sys/dev/pci/drm/drm_dp_helper.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_dp_helper.c,v 1.2 2013/03/20 05:14:34 jsg Exp $ */
+/* $OpenBSD: drm_dp_helper.c,v 1.3 2013/03/30 18:33:56 kettenis Exp $ */
/*
* Copyright © 2009 Keith Packard
*
@@ -148,34 +148,45 @@ i2c_algo_dp_aux_exec(void *cookie, i2c_op_t op, i2c_addr_t addr,
{
struct i2c_algo_dp_aux_data *algo_data = cookie;
struct i2c_controller *adapter = algo_data->adapter;
- int ret = 0;
- bool reading = false;
- int b;
- uint8_t *buf = buffer;
+ uint8_t *buf;
+ int i, ret;
+
+ buf = (void *)cmdbuf;
+ if (cmdlen > 0) {
+ ret = i2c_algo_dp_aux_address(adapter, addr, false);
+ if (ret < 0)
+ goto out;
+ for (i = 0; i < cmdlen; i++) {
+ ret = i2c_algo_dp_aux_put_byte(adapter, buf[i]);
+ if (ret < 0)
+ goto out;
+ }
+ }
- reading = I2C_OP_READ_P(op);
- ret = i2c_algo_dp_aux_address(adapter, addr, reading);
+ buf = buffer;
+ ret = i2c_algo_dp_aux_address(adapter, addr, I2C_OP_READ_P(op));
if (ret < 0)
goto out;
- if (reading) {
- for (b = 0; b < len; b++) {
- ret = i2c_algo_dp_aux_get_byte(adapter, &buf[b]);
+ if (I2C_OP_READ_P(op)) {
+ for (i = 0; i < len; i++) {
+ ret = i2c_algo_dp_aux_get_byte(adapter, &buf[i]);
if (ret < 0)
break;
}
- } else if (I2C_OP_WRITE_P(op)) {
- for (b = 0; b < len; b++) {
- ret = i2c_algo_dp_aux_put_byte(adapter, buf[b]);
+ } else {
+ for (i = 0; i < len; i++) {
+ ret = i2c_algo_dp_aux_put_byte(adapter, buf[i]);
if (ret < 0)
break;
}
}
out:
- if (ret > 0)
- ret = 0;
+ if (I2C_OP_STOP_P(op))
+ i2c_algo_dp_aux_stop(adapter, I2C_OP_READ_P(op));
- i2c_algo_dp_aux_stop(adapter, reading);
+ if (ret >= 0)
+ ret = 0;
DRM_DEBUG_KMS("dp_aux_exec return %d\n", ret);
return ret;
}