From 852d33b30bd6b435fad28c6d1dabaf6f65db5910 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Thu, 29 Sep 2022 19:49:34 -0500 Subject: [PATCH] third times the charm? --- i2c_smbus/i2c_smbus_amdadl.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/i2c_smbus/i2c_smbus_amdadl.cpp b/i2c_smbus/i2c_smbus_amdadl.cpp index b43d0d804..4fd43e31a 100644 --- a/i2c_smbus/i2c_smbus_amdadl.cpp +++ b/i2c_smbus/i2c_smbus_amdadl.cpp @@ -181,21 +181,17 @@ s32 i2c_smbus_amdadl::i2c_smbus_xfer(u8 addr, char read_write, u8 command, int s if (read_write == I2C_SMBUS_READ) { - /* An SMBus read is a one-byte write followed by a repeat start read */ - pI2C->iOffset = 0; - pI2C->iAction = ADL_DL_I2C_ACTIONWRITE; - pI2C->iDataSize = 1; - pI2C->pcData = (char *)&command; - - ret = ADL2_Display_WriteAndReadI2C(context, PrimaryDisplay, pI2C); - - pI2C->iAction = ADL_DL_I2C_ACTIONREAD_REPEATEDSTART; + /* An SMBus read can be achieved by setting the offset to the command (register address) */ + pI2C->iOffset = command; + pI2C->iAction = ADL_DL_I2C_ACTIONREAD; pI2C->iDataSize = data_size; pI2C->pcData = (char *)data; + ret = ADL2_Display_WriteAndReadI2C(context, PrimaryDisplay, pI2C); } else { + /* An SMBus write has one extra byte, the register address, before the data */ pI2C->iAction = ADL_DL_I2C_ACTIONWRITE; pI2C->iDataSize = data_size + 1; pI2C->pcData = i2c_buf;