diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2008-04-28 05:14:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-28 11:58:35 -0400 |
commit | e4c690e061b909127ab0f12e929f82f3f39ec953 (patch) | |
tree | b798bbda541f615cd4830cad96ed3f58db1fd19c /drivers/video/cfbimgblt.c | |
parent | 6b745b6fd02213f4b2fef2f2635985929fc5b8cc (diff) |
fb: add support for foreign endianness
Add support for the framebuffers with non-native endianness. This is done via
FBINFO_FOREIGN_ENDIAN flag that will be used by the drivers. Depending on the
host endianness this flag will be overwritten by FBINFO_BE_MATH internal flag,
or cleared.
Tested to work on MPC8360E-RDK (BE) + Fujitsu MINT framebuffer (LE).
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: <Valdis.Kletnieks@vt.edu>
Cc: Clemens Koller <clemens.koller@anagramm.de>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/cfbimgblt.c')
-rw-r--r-- | drivers/video/cfbimgblt.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/video/cfbimgblt.c b/drivers/video/cfbimgblt.c index f598907b42ad..ff3136bd464b 100644 --- a/drivers/video/cfbimgblt.c +++ b/drivers/video/cfbimgblt.c | |||
@@ -43,30 +43,26 @@ | |||
43 | #define DPRINTK(fmt, args...) | 43 | #define DPRINTK(fmt, args...) |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | static const u32 cfb_tab8[] = { | 46 | static const u32 cfb_tab8_be[] = { |
47 | #if defined(__BIG_ENDIAN) | ||
48 | 0x00000000,0x000000ff,0x0000ff00,0x0000ffff, | 47 | 0x00000000,0x000000ff,0x0000ff00,0x0000ffff, |
49 | 0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff, | 48 | 0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff, |
50 | 0xff000000,0xff0000ff,0xff00ff00,0xff00ffff, | 49 | 0xff000000,0xff0000ff,0xff00ff00,0xff00ffff, |
51 | 0xffff0000,0xffff00ff,0xffffff00,0xffffffff | 50 | 0xffff0000,0xffff00ff,0xffffff00,0xffffffff |
52 | #elif defined(__LITTLE_ENDIAN) | 51 | }; |
52 | |||
53 | static const u32 cfb_tab8_le[] = { | ||
53 | 0x00000000,0xff000000,0x00ff0000,0xffff0000, | 54 | 0x00000000,0xff000000,0x00ff0000,0xffff0000, |
54 | 0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00, | 55 | 0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00, |
55 | 0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff, | 56 | 0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff, |
56 | 0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff | 57 | 0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff |
57 | #else | ||
58 | #error FIXME: No endianness?? | ||
59 | #endif | ||
60 | }; | 58 | }; |
61 | 59 | ||
62 | static const u32 cfb_tab16[] = { | 60 | static const u32 cfb_tab16_be[] = { |
63 | #if defined(__BIG_ENDIAN) | ||
64 | 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff | 61 | 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff |
65 | #elif defined(__LITTLE_ENDIAN) | 62 | }; |
63 | |||
64 | static const u32 cfb_tab16_le[] = { | ||
66 | 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff | 65 | 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff |
67 | #else | ||
68 | #error FIXME: No endianness?? | ||
69 | #endif | ||
70 | }; | 66 | }; |
71 | 67 | ||
72 | static const u32 cfb_tab32[] = { | 68 | static const u32 cfb_tab32[] = { |
@@ -98,7 +94,8 @@ static inline void color_imageblit(const struct fb_image *image, | |||
98 | val = 0; | 94 | val = 0; |
99 | 95 | ||
100 | if (start_index) { | 96 | if (start_index) { |
101 | u32 start_mask = ~fb_shifted_pixels_mask_u32(start_index, bswapmask); | 97 | u32 start_mask = ~fb_shifted_pixels_mask_u32(p, |
98 | start_index, bswapmask); | ||
102 | val = FB_READL(dst) & start_mask; | 99 | val = FB_READL(dst) & start_mask; |
103 | shift = start_index; | 100 | shift = start_index; |
104 | } | 101 | } |
@@ -108,20 +105,21 @@ static inline void color_imageblit(const struct fb_image *image, | |||
108 | color = palette[*src]; | 105 | color = palette[*src]; |
109 | else | 106 | else |
110 | color = *src; | 107 | color = *src; |
111 | color <<= FB_LEFT_POS(bpp); | 108 | color <<= FB_LEFT_POS(p, bpp); |
112 | val |= FB_SHIFT_HIGH(color, shift ^ bswapmask); | 109 | val |= FB_SHIFT_HIGH(p, color, shift ^ bswapmask); |
113 | if (shift >= null_bits) { | 110 | if (shift >= null_bits) { |
114 | FB_WRITEL(val, dst++); | 111 | FB_WRITEL(val, dst++); |
115 | 112 | ||
116 | val = (shift == null_bits) ? 0 : | 113 | val = (shift == null_bits) ? 0 : |
117 | FB_SHIFT_LOW(color, 32 - shift); | 114 | FB_SHIFT_LOW(p, color, 32 - shift); |
118 | } | 115 | } |
119 | shift += bpp; | 116 | shift += bpp; |
120 | shift &= (32 - 1); | 117 | shift &= (32 - 1); |
121 | src++; | 118 | src++; |
122 | } | 119 | } |
123 | if (shift) { | 120 | if (shift) { |
124 | u32 end_mask = fb_shifted_pixels_mask_u32(shift, bswapmask); | 121 | u32 end_mask = fb_shifted_pixels_mask_u32(p, shift, |
122 | bswapmask); | ||
125 | 123 | ||
126 | FB_WRITEL((FB_READL(dst) & end_mask) | val, dst); | 124 | FB_WRITEL((FB_READL(dst) & end_mask) | val, dst); |
127 | } | 125 | } |
@@ -152,8 +150,8 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info * | |||
152 | u32 bswapmask = fb_compute_bswapmask(p); | 150 | u32 bswapmask = fb_compute_bswapmask(p); |
153 | 151 | ||
154 | dst2 = (u32 __iomem *) dst1; | 152 | dst2 = (u32 __iomem *) dst1; |
155 | fgcolor <<= FB_LEFT_POS(bpp); | 153 | fgcolor <<= FB_LEFT_POS(p, bpp); |
156 | bgcolor <<= FB_LEFT_POS(bpp); | 154 | bgcolor <<= FB_LEFT_POS(p, bpp); |
157 | 155 | ||
158 | for (i = image->height; i--; ) { | 156 | for (i = image->height; i--; ) { |
159 | shift = val = 0; | 157 | shift = val = 0; |
@@ -164,7 +162,8 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info * | |||
164 | 162 | ||
165 | /* write leading bits */ | 163 | /* write leading bits */ |
166 | if (start_index) { | 164 | if (start_index) { |
167 | u32 start_mask = ~fb_shifted_pixels_mask_u32(start_index, bswapmask); | 165 | u32 start_mask = ~fb_shifted_pixels_mask_u32(p, |
166 | start_index, bswapmask); | ||
168 | val = FB_READL(dst) & start_mask; | 167 | val = FB_READL(dst) & start_mask; |
169 | shift = start_index; | 168 | shift = start_index; |
170 | } | 169 | } |
@@ -172,13 +171,13 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info * | |||
172 | while (j--) { | 171 | while (j--) { |
173 | l--; | 172 | l--; |
174 | color = (*s & (1 << l)) ? fgcolor : bgcolor; | 173 | color = (*s & (1 << l)) ? fgcolor : bgcolor; |
175 | val |= FB_SHIFT_HIGH(color, shift ^ bswapmask); | 174 | val |= FB_SHIFT_HIGH(p, color, shift ^ bswapmask); |
176 | 175 | ||
177 | /* Did the bitshift spill bits to the next long? */ | 176 | /* Did the bitshift spill bits to the next long? */ |
178 | if (shift >= null_bits) { | 177 | if (shift >= null_bits) { |
179 | FB_WRITEL(val, dst++); | 178 | FB_WRITEL(val, dst++); |
180 | val = (shift == null_bits) ? 0 : | 179 | val = (shift == null_bits) ? 0 : |
181 | FB_SHIFT_LOW(color,32 - shift); | 180 | FB_SHIFT_LOW(p, color, 32 - shift); |
182 | } | 181 | } |
183 | shift += bpp; | 182 | shift += bpp; |
184 | shift &= (32 - 1); | 183 | shift &= (32 - 1); |
@@ -187,7 +186,8 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info * | |||
187 | 186 | ||
188 | /* write trailing bits */ | 187 | /* write trailing bits */ |
189 | if (shift) { | 188 | if (shift) { |
190 | u32 end_mask = fb_shifted_pixels_mask_u32(shift, bswapmask); | 189 | u32 end_mask = fb_shifted_pixels_mask_u32(p, shift, |
190 | bswapmask); | ||
191 | 191 | ||
192 | FB_WRITEL((FB_READL(dst) & end_mask) | val, dst); | 192 | FB_WRITEL((FB_READL(dst) & end_mask) | val, dst); |
193 | } | 193 | } |
@@ -223,13 +223,13 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info * | |||
223 | u32 __iomem *dst; | 223 | u32 __iomem *dst; |
224 | const u32 *tab = NULL; | 224 | const u32 *tab = NULL; |
225 | int i, j, k; | 225 | int i, j, k; |
226 | 226 | ||
227 | switch (bpp) { | 227 | switch (bpp) { |
228 | case 8: | 228 | case 8: |
229 | tab = cfb_tab8; | 229 | tab = fb_be_math(p) ? cfb_tab8_be : cfb_tab8_le; |
230 | break; | 230 | break; |
231 | case 16: | 231 | case 16: |
232 | tab = cfb_tab16; | 232 | tab = fb_be_math(p) ? cfb_tab16_be : cfb_tab16_le; |
233 | break; | 233 | break; |
234 | case 32: | 234 | case 32: |
235 | default: | 235 | default: |