linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Michael Schmitz <schmitz@opal.biophys.uni-duesseldorf.de>,
	linux-fbdev-devel@lists.sourceforge.net
Cc: linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [patch 4/6] fbdev: c2p - Extract common c2p core to c2p_core.h
Date: Sun, 21 Dec 2008 16:01:03 +0100	[thread overview]
Message-ID: <20081221150122.756673142@mail.of.borg> (raw)
In-Reply-To: 20081221150059.844577615@mail.of.borg

[-- Attachment #1: c2p-extract-common.diff --]
[-- Type: text/plain, Size: 4802 bytes --]

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/video/c2p.c      |   87 ----------------------------------------
 drivers/video/c2p_core.h |  101 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+), 86 deletions(-)

--- a/drivers/video/c2p.c
+++ b/drivers/video/c2p.c
@@ -15,80 +15,7 @@
 #include <linux/module.h>
 #include <linux/string.h>
 #include "c2p.h"
-
-
-    /*
-     *  Basic transpose step
-     */
-
-#define _transp(d, i1, i2, shift, mask)			\
-    do {						\
-	u32 t = (d[i1] ^ (d[i2] >> shift)) & mask;	\
-	d[i1] ^= t;					\
-	d[i2] ^= t << shift;				\
-    } while (0)
-
-static inline u32 get_mask(int n)
-{
-    switch (n) {
-	case 1:
-	    return 0x55555555;
-	    break;
-
-	case 2:
-	    return 0x33333333;
-	    break;
-
-	case 4:
-	    return 0x0f0f0f0f;
-	    break;
-
-	case 8:
-	    return 0x00ff00ff;
-	    break;
-
-	case 16:
-	    return 0x0000ffff;
-	    break;
-    }
-    return 0;
-}
-
-#define transp8_nx1(d, n)				\
-    do {						\
-	u32 mask = get_mask(n);				\
-	/* First block */				\
-	_transp(d, 0, 1, n, mask);			\
-	/* Second block */				\
-	_transp(d, 2, 3, n, mask);			\
-	/* Third block */				\
-	_transp(d, 4, 5, n, mask);			\
-	/* Fourth block */				\
-	_transp(d, 6, 7, n, mask);			\
-    } while (0)
-
-#define transp8_nx2(d, n)				\
-    do {						\
-	u32 mask = get_mask(n);				\
-	/* First block */				\
-	_transp(d, 0, 2, n, mask);			\
-	_transp(d, 1, 3, n, mask);			\
-	/* Second block */				\
-	_transp(d, 4, 6, n, mask);			\
-	_transp(d, 5, 7, n, mask);			\
-    } while (0)
-
-#define transp8_nx4(d, n)				\
-    do {						\
-	u32 mask = get_mask(n);				\
-	/* Single block */				\
-	_transp(d, 0, 4, n, mask);			\
-	_transp(d, 1, 5, n, mask);			\
-	_transp(d, 2, 6, n, mask);			\
-	_transp(d, 3, 7, n, mask);			\
-    } while (0)
-
-#define transp8(d, n, m)	transp8_nx ## m(d, n)
+#include "c2p_core.h"
 
 
     /*
@@ -116,18 +43,6 @@ static const int perm_c2p_32x8[8] = { 7,
 
 
     /*
-     *  Compose two values, using a bitmask as decision value
-     *  This is equivalent to (a & mask) | (b & ~mask)
-     */
-
-static inline unsigned long comp(unsigned long a, unsigned long b,
-				 unsigned long mask)
-{
-	return ((a ^ b) & mask) ^ b;
-}
-
-
-    /*
      *  Store a full block of planar data after c2p conversion
      */
 
--- /dev/null
+++ b/drivers/video/c2p_core.h
@@ -0,0 +1,101 @@
+/*
+ *  Fast C2P (Chunky-to-Planar) Conversion
+ *
+ *  Copyright (C) 2003-2008 Geert Uytterhoeven
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License. See the file COPYING in the main directory of this archive
+ *  for more details.
+ */
+
+
+    /*
+     *  Basic transpose step
+     */
+
+#define _transp(d, i1, i2, shift, mask)				\
+	do {							\
+		u32 t = (d[i1] ^ (d[i2] >> shift)) & mask;	\
+		d[i1] ^= t;					\
+		d[i2] ^= t << shift;				\
+	} while (0)
+
+
+static inline u32 get_mask(int n)
+{
+	switch (n) {
+	case 1:
+		return 0x55555555;
+		break;
+
+	case 2:
+		return 0x33333333;
+		break;
+
+	case 4:
+		return 0x0f0f0f0f;
+		break;
+
+	case 8:
+		return 0x00ff00ff;
+		break;
+
+	case 16:
+		return 0x0000ffff;
+		break;
+	}
+	return 0;
+}
+
+
+    /*
+     *  Transpose operations on 8 32-bit words
+     */
+
+#define transp8_nx1(d, n)					\
+	do {							\
+		u32 mask = get_mask(n);				\
+		/* First block */				\
+		_transp(d, 0, 1, n, mask);			\
+		/* Second block */				\
+		_transp(d, 2, 3, n, mask);			\
+		/* Third block */				\
+		_transp(d, 4, 5, n, mask);			\
+		/* Fourth block */				\
+		_transp(d, 6, 7, n, mask);			\
+	} while (0)
+
+#define transp8_nx2(d, n)					\
+	do {							\
+		u32 mask = get_mask(n);				\
+		/* First block */				\
+		_transp(d, 0, 2, n, mask);			\
+		_transp(d, 1, 3, n, mask);			\
+		/* Second block */				\
+		_transp(d, 4, 6, n, mask);			\
+		_transp(d, 5, 7, n, mask);			\
+	} while (0)
+
+#define transp8_nx4(d, n)					\
+	do {							\
+		u32 mask = get_mask(n);				\
+		/* Single block */				\
+		_transp(d, 0, 4, n, mask);			\
+		_transp(d, 1, 5, n, mask);			\
+		_transp(d, 2, 6, n, mask);			\
+		_transp(d, 3, 7, n, mask);			\
+	} while (0)
+
+#define transp8(d, n, m)	transp8_nx ## m(d, n)
+
+
+    /*
+     *  Compose two values, using a bitmask as decision value
+     *  This is equivalent to (a & mask) | (b & ~mask)
+     */
+
+static inline unsigned long comp(unsigned long a, unsigned long b,
+				 unsigned long mask)
+{
+	return ((a ^ b) & mask) ^ b;
+}

-- 
Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


  parent reply	other threads:[~2008-12-21 15:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-21 15:00 [patch 0/6] [patch 0/6] Atari frame buffer fixes Geert Uytterhoeven
2008-12-21 15:01 ` [patch 1/6] fbdev: atafb - Fix line length handling Geert Uytterhoeven
2008-12-21 15:01 ` [patch 2/6] fbdev: atafb - Fix 16 bpp console Geert Uytterhoeven
2008-12-21 15:01 ` [patch 3/6] fbdev: c2p - Cleanups Geert Uytterhoeven
2008-12-22 23:22   ` Andrew Morton
2008-12-23  8:13     ` Geert Uytterhoeven
2008-12-21 15:01 ` Geert Uytterhoeven [this message]
2008-12-21 15:01 ` [patch 5/6] fbdev: c2p/atafb - Add support for Atari interleaved bitplanes Geert Uytterhoeven
2008-12-21 15:01 ` [patch 6/6] fbdev: c2p - Rename c2p to c2p_planar and correct indentation Geert Uytterhoeven
2008-12-22 23:23   ` Andrew Morton
2008-12-23  8:02     ` Geert Uytterhoeven
2008-12-22 23:24 ` [patch 0/6] [patch 0/6] Atari frame buffer fixes Andrew Morton

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=20081221150122.756673142@mail.of.borg \
    --to=geert@linux-m68k.org \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=schmitz@opal.biophys.uni-duesseldorf.de \
    /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).