summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@jsg.id.au>2013-03-18 12:01:19 +1100
committerJonathan Gray <jsg@jsg.id.au>2013-03-18 12:02:20 +1100
commit8a9c72f304a643d7d4d2a081b128a2bfc08776ee (patch)
treec4ac6a63b39ff59e86751d85d3fd08616f8dade2
parentced165cddcd198eed276fd7caf5f3bb706c9c59e (diff)
hookup the rest of the displayport code, currently untested
-rw-r--r--sys/dev/pci/drm/drm_dp_helper.c75
-rw-r--r--sys/dev/pci/drm/drm_dp_helper.h1
-rw-r--r--sys/dev/pci/drm/i915/intel_dp.c1
3 files changed, 47 insertions, 30 deletions
diff --git a/sys/dev/pci/drm/drm_dp_helper.c b/sys/dev/pci/drm/drm_dp_helper.c
index be48a148416..6b75ffd6737 100644
--- a/sys/dev/pci/drm/drm_dp_helper.c
+++ b/sys/dev/pci/drm/drm_dp_helper.c
@@ -44,6 +44,10 @@ int i2c_dp_aux_prepare_bus(struct i2c_controller *);
int i2c_dp_aux_add_bus(struct i2c_controller *);
u8 dp_link_status(u8 link_status[DP_LINK_STATUS_SIZE], int);
u8 dp_get_lane_status(u8 link_status[DP_LINK_STATUS_SIZE], int);
+int i2c_algo_dp_aux_exec(void *, i2c_op_t, i2c_addr_t,
+ const void *, size_t, void *, size_t, int);
+void i2c_dp_aux_release_bus(void *, int);
+int i2c_dp_aux_acquire_bus(void *, int);
/* Run a single AUX_CH I2C transaction, writing/reading data as necessary */
int
@@ -138,47 +142,40 @@ i2c_algo_dp_aux_get_byte(struct i2c_controller *adapter, u8 *byte_ret)
return ret;
}
-#ifdef notyet
int
-i2c_algo_dp_aux_xfer(struct i2c_controller *adapter,
- struct i2c_msg *msgs,
- int num)
+i2c_algo_dp_aux_exec(void *cookie, i2c_op_t op, i2c_addr_t addr,
+ const void *cmdbuf, size_t cmdlen, void *buffer, size_t len, int flags)
{
+ struct i2c_algo_dp_aux_data *algo_data = cookie;
+ struct i2c_controller *adapter = algo_data->adapter;
int ret = 0;
bool reading = false;
- int m;
int b;
-
- for (m = 0; m < num; m++) {
- u16 len = msgs[m].len;
- u8 *buf = msgs[m].buf;
- reading = (msgs[m].flags & I2C_M_RD) != 0;
- ret = i2c_algo_dp_aux_address(adapter, msgs[m].addr, reading);
- if (ret < 0)
- break;
- if (reading) {
- for (b = 0; b < len; b++) {
- ret = i2c_algo_dp_aux_get_byte(adapter, &buf[b]);
- if (ret < 0)
- break;
- }
- } else {
- for (b = 0; b < len; b++) {
- ret = i2c_algo_dp_aux_put_byte(adapter, buf[b]);
- if (ret < 0)
- break;
- }
+ uint8_t *buf = buffer;
+
+ reading = I2C_OP_READ_P(op);
+ ret = i2c_algo_dp_aux_address(adapter, addr, reading);
+ if (ret < 0)
+ goto out;
+ if (reading) {
+ for (b = 0; b < len; b++) {
+ ret = i2c_algo_dp_aux_get_byte(adapter, &buf[b]);
+ 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]);
+ if (ret < 0)
+ break;
}
- if (ret < 0)
- break;
}
- if (ret >= 0)
- ret = num;
+
+out:
i2c_algo_dp_aux_stop(adapter, reading);
DRM_DEBUG_KMS("dp_aux_xfer return %d\n", ret);
return ret;
}
-#endif
void
i2c_dp_aux_reset_bus(struct i2c_controller *adapter)
@@ -188,12 +185,30 @@ i2c_dp_aux_reset_bus(struct i2c_controller *adapter)
}
int
+i2c_dp_aux_acquire_bus(void *cookie, int flags)
+{
+ return (0);
+}
+
+void
+i2c_dp_aux_release_bus(void *cookie, int flags)
+{
+ struct i2c_algo_dp_aux_data *algo_data = cookie;
+
+ i2c_dp_aux_reset_bus(algo_data->adapter);
+}
+
+int
i2c_dp_aux_prepare_bus(struct i2c_controller *adapter)
{
#ifdef notyet
adapter->algo = &i2c_dp_aux_algo;
adapter->retries = 3;
#endif
+ /* cookie set in driver */
+ adapter->ic_acquire_bus = i2c_dp_aux_acquire_bus;
+ adapter->ic_release_bus = i2c_dp_aux_release_bus;
+ adapter->ic_exec = i2c_algo_dp_aux_exec;
i2c_dp_aux_reset_bus(adapter);
return 0;
}
diff --git a/sys/dev/pci/drm/drm_dp_helper.h b/sys/dev/pci/drm/drm_dp_helper.h
index 12cd3728a3b..ec09dc65411 100644
--- a/sys/dev/pci/drm/drm_dp_helper.h
+++ b/sys/dev/pci/drm/drm_dp_helper.h
@@ -318,6 +318,7 @@
* @aux_ch: driver callback to transfer a single byte of the i2c payload
*/
struct i2c_algo_dp_aux_data {
+ struct i2c_controller *adapter;
bool running;
u16 address;
int (*aux_ch) (struct i2c_controller *adapter,
diff --git a/sys/dev/pci/drm/i915/intel_dp.c b/sys/dev/pci/drm/i915/intel_dp.c
index 2114601a32f..5beff9bcc79 100644
--- a/sys/dev/pci/drm/i915/intel_dp.c
+++ b/sys/dev/pci/drm/i915/intel_dp.c
@@ -796,6 +796,7 @@ intel_dp_i2c_init(struct intel_dp *intel_dp,
intel_dp->algo.running = false;
intel_dp->algo.address = 0;
intel_dp->algo.aux_ch = intel_dp_i2c_aux_ch;
+ intel_dp->algo.adapter = &intel_dp->adapter;
memset(&intel_dp->adapter, '\0', sizeof(intel_dp->adapter));
#if 0