linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Glendinning <steve.glendinning@shawell.net>
To: linux-fbdev@vger.kernel.org
Subject: [PATCH 1/2] smscufx: ensure framebuffer is byte-swapped to LE
Date: Mon, 17 Dec 2012 11:24:21 +0000	[thread overview]
Message-ID: <1355743462-2670-1-git-send-email-steve.glendinning@shawell.net> (raw)

This patch fixes the smscufx driver on big endian platforms, by
ensuring the framebuffer is correctly byte-swapped before sending
to the device.

Register and control words were already correctly swapped, so
without this patch the device "works" but with obviously incorrect
RGB values displayed on the output device.

This is implemented as an ifdef so platforms that don't require
byte swapping can use the faster memcpy method.

Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
---
 drivers/video/smscufx.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
index 97bd662..8009400 100644
--- a/drivers/video/smscufx.c
+++ b/drivers/video/smscufx.c
@@ -840,8 +840,16 @@ static void ufx_raw_rect(struct ufx_data *dev, u16 *cmd, int x, int y,
 	for (line = 0; line < height; line++) {
 		const int line_offset = dev->info->fix.line_length * (y + line);
 		const int byte_offset = line_offset + (x * BPP);
-		memcpy(&cmd[(24 + (packed_line_len * line)) / 2],
-			(char *)dev->info->fix.smem_start + byte_offset, width * BPP);
+		const int cmd_base = (24 + (packed_line_len * line)) / 2;
+		const u16 *source = (u16 *)((char *)dev->info->fix.smem_start + byte_offset);
+		u16 *dest = (u16 *)(&cmd[cmd_base]);
+#ifdef __BIG_ENDIAN
+		int pixel;
+		for (pixel = 0; pixel < width; pixel++)
+			dest[pixel] = cpu_to_le16(source[pixel]);
+#else /* __BIG_ENDIAN */
+		memcpy(dest, source, width * BPP);
+#endif /* __BIG_ENDIAN */
 	}
 }
 
-- 
1.7.10.4


                 reply	other threads:[~2012-12-17 11:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355743462-2670-1-git-send-email-steve.glendinning@shawell.net \
    --to=steve.glendinning@shawell.net \
    --cc=linux-fbdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).