From patchwork Mon Dec 17 11:24:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Glendinning X-Patchwork-Id: 1886721 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 496EADFAC4 for ; Mon, 17 Dec 2012 11:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752320Ab2LQLfa (ORCPT ); Mon, 17 Dec 2012 06:35:30 -0500 Received: from cust23-dsl91-135-1.idnet.net ([91.135.1.23]:52214 "EHLO drevil.shawell.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752298Ab2LQLf3 (ORCPT ); Mon, 17 Dec 2012 06:35:29 -0500 X-Greylist: delayed 652 seconds by postgrey-1.27 at vger.kernel.org; Mon, 17 Dec 2012 06:35:29 EST Received: from ivana.shawell.net (unknown [10.0.20.197]) by drevil.shawell.net (Postfix) with ESMTP id B000B67A3E; Mon, 17 Dec 2012 11:24:35 +0000 (GMT) From: Steve Glendinning To: linux-fbdev@vger.kernel.org Cc: FlorianSchandinat@gmx.de, Steve Glendinning Subject: [PATCH 1/2] smscufx: ensure framebuffer is byte-swapped to LE Date: Mon, 17 Dec 2012 11:24:21 +0000 Message-Id: <1355743462-2670-1-git-send-email-steve.glendinning@shawell.net> X-Mailer: git-send-email 1.7.10.4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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 --- 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 */ } }