Skip to content

Commit

Permalink
drm/radeon: fix endian bugs in hw i2c atom routines
Browse files Browse the repository at this point in the history
Need to swap the data fetched over i2c properly.  This
is the same fix as the endian fix for aux channel
transactions.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
  • Loading branch information
Alex Deucher committed Aug 30, 2013
1 parent 1bd4cff commit 4543eda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/radeon/atombios_dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static char *pre_emph_names[] = {
* or from atom. Note that atom operates on
* dw units.
*/
static void radeon_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
{
#ifdef __BIG_ENDIAN
u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
Expand Down Expand Up @@ -100,7 +100,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,

base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1);

radeon_copy_swap(base, send, send_bytes, true);
radeon_atom_copy_swap(base, send, send_bytes, true);

args.v1.lpAuxRequest = cpu_to_le16((u16)(0 + 4));
args.v1.lpDataOut = cpu_to_le16((u16)(16 + 4));
Expand Down Expand Up @@ -137,7 +137,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
recv_bytes = recv_size;

if (recv && recv_size)
radeon_copy_swap(recv, base + 16, recv_bytes, false);
radeon_atom_copy_swap(recv, base + 16, recv_bytes, false);

return recv_bytes;
}
Expand Down
4 changes: 3 additions & 1 deletion drivers/gpu/drm/radeon/atombios_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "radeon.h"
#include "atom.h"

extern void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);

#define TARGET_HW_I2C_CLOCK 50

/* these are a limitation of ProcessI2cChannelTransaction not the hw */
Expand Down Expand Up @@ -77,7 +79,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
}

if (!(flags & HW_I2C_WRITE))
memcpy(buf, base, num);
radeon_atom_copy_swap(buf, base, num, false);

return 0;
}
Expand Down

0 comments on commit 4543eda

Please sign in to comment.