fb: add support for foreign endianness
PATCH 1/2 fb: add support for foreign endianness
This patch adds 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).
--- drivers/video/cfbcopyarea.c | 23 ++++++++++-------- drivers/video/cfbfillrect.c | 48 +++++++++++++++++++++------------------ drivers/video/cfbimgblt.c | 52 +++++++++++++++++++++--------------------- drivers/video/fb_draw.h | 31 ++++++++++++++----------- drivers/video/fbmem.c | 8 ++++++ drivers/video/syscopyarea.c | 20 ++++++++-------- drivers/video/sysfillrect.c | 49 ++++++++++++++++++++------------------- drivers/video/sysimgblt.c | 47 ++++++++++++++++++-------------------- include/linux/fb.h | 30 +++++++++++++++++------- 9 files changed, 168 insertions(+), 140 deletions(-)
drivers/video/cfbcopyarea.c +13 -10
@@ -44,15 +44,16 @@*/ static void -bitcpy (unsigned long __iomem *dst,int dst_idx,const unsigned long __iomem *src, -int src_idx,int bits,unsigned n,u32 bswapmask) +bitcpy (struct fb_info *p,unsigned long __iomem *dst,int dst_idx, +const unsigned long __iomem *src,int src_idx,int bits, +unsigned n,u32 bswapmask) {unsigned long first, last;int const shift = dst_idx-src_idx;int left, right; - first =fb_shifted_pixels_mask_long (dst_idx, bswapmask); - last = ~fb_shifted_pixels_mask_long ((dst_idx+n) % bits, bswapmask); + first =fb_shifted_pixels_mask_long (p, dst_idx, bswapmask); + last = ~fb_shifted_pixels_mask_long (p, (dst_idx+n) % bits, bswapmask);if (!shift) {// Same alignment for source and dest
@@ -202,8 +203,9 @@ bitcpy(unsigned long __iomem *dst, int dst_idx, const unsigned long __iomem *src*/ static void -bitcpy_rev (unsigned long __iomem *dst,int dst_idx,const unsigned long __iomem *src, -int src_idx,int bits,unsigned n,u32 bswapmask) +bitcpy_rev (struct fb_info *p,unsigned long __iomem *dst,int dst_idx, +const unsigned long __iomem *src,int src_idx,int bits, +unsigned n,u32 bswapmask) {unsigned long first, last;int shift;
@@ -221,8 +223,9 @@ bitcpy_rev(unsigned long __iomem *dst, int dst_idx, const unsigned long __iomem shift = dst_idx-src_idx; - first =fb_shifted_pixels_mask_long (bits -1 - dst_idx, bswapmask); - last = ~fb_shifted_pixels_mask_long (bits -1 - ((dst_idx-n) % bits), bswapmask); + first =fb_shifted_pixels_mask_long (p, bits -1 - dst_idx, bswapmask); + last = ~fb_shifted_pixels_mask_long (p, bits -1 - ((dst_idx-n) % bits), + bswapmask);if (!shift) {// Same alignment for source and dest
@@ -404,7 +407,7 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy_rev (dst, dst_idx, src, src_idx, bits, +bitcpy_rev (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel, bswapmask); } }else {
@@ -413,7 +416,7 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy (dst, dst_idx, src, src_idx, bits, +bitcpy (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel, bswapmask); dst_idx += bits_per_line; src_idx += bits_per_line;
drivers/video/cfbfillrect.c +26 -22
120 lines not on this page · raw message
drivers/video/cfbimgblt.c +26 -26
131 lines not on this page · raw message
drivers/video/fb_draw.h +17 -14
@@ -93,41 +93,44 @@ static inline unsigned long fb_rev_pixels_in_long(unsigned long val, val =comp (val >>4 , val <<4 ,REV_PIXELS_MASK4 ); } -static inline u32 fb_shifted_pixels_mask_u32 (u32 index,u32 bswapmask) +static inline u32 fb_shifted_pixels_mask_u32 (struct fb_info *p,u32 index, +u32 bswapmask) {u32 mask;if (!bswapmask) { - mask =FB_SHIFT_HIGH (~(u32 )0 , index); + mask =FB_SHIFT_HIGH (p, ~(u32 )0 , index); }else { - mask =0xff <<FB_LEFT_POS (8 ); - mask =FB_SHIFT_LOW (mask, index & (bswapmask)) & mask; - mask =FB_SHIFT_HIGH (mask, index & ~(bswapmask)); + mask =0xff <<FB_LEFT_POS (p,8 ); + mask =FB_SHIFT_LOW (p, mask, index & (bswapmask)) & mask; + mask =FB_SHIFT_HIGH (p, mask, index & ~(bswapmask));#if defined(__i386__) || defined(__x86_64__)/* Shift argument is limited to 0 - 31 on x86 based CPU's */ if(index + bswapmask < 32)#endif - mask |=FB_SHIFT_HIGH (~(u32 )0 , + mask |=FB_SHIFT_HIGH (p, ~(u32 )0 , (index + bswapmask) & ~(bswapmask)); }return mask; } -static inline unsigned long fb_shifted_pixels_mask_long (u32 index,u32 bswapmask) +static inline unsigned long fb_shifted_pixels_mask_long (u32 index, +struct fb_info *p, +u32 bswapmask) {unsigned long mask;if (!bswapmask) { - mask =FB_SHIFT_HIGH (~0UL , index); + mask =FB_SHIFT_HIGH (p, ~0UL , index); }else { - mask =0xff <<FB_LEFT_POS (8 ); - mask =FB_SHIFT_LOW (mask, index & (bswapmask)) & mask; - mask =FB_SHIFT_HIGH (mask, index & ~(bswapmask)); + mask =0xff <<FB_LEFT_POS (p,8 ); + mask =FB_SHIFT_LOW (p, mask, index & (bswapmask)) & mask; + mask =FB_SHIFT_HIGH (p, mask, index & ~(bswapmask));#if defined(__i386__) || defined(__x86_64__)/* Shift argument is limited to 0 - 31 on x86 based CPU's */ if(index + bswapmask < BITS_PER_LONG)#endif - mask |=FB_SHIFT_HIGH (~0UL , + mask |=FB_SHIFT_HIGH (p, ~0UL , (index + bswapmask) & ~(bswapmask)); }return mask;
@@ -157,8 +160,8 @@ static inline unsigned long fb_rev_pixels_in_long(unsigned long val, return val; } -#define fb_shifted_pixels_mask_u32 (i, b) FB_SHIFT_HIGH(~(u32)0, (i)) -#define fb_shifted_pixels_mask_long (i, b) FB_SHIFT_HIGH(~0UL, (i)) +#define fb_shifted_pixels_mask_u32 (p, i, b) FB_SHIFT_HIGH((p), ~(u32)0, (i)) +#define fb_shifted_pixels_mask_long (p, i, b) FB_SHIFT_HIGH((p), ~0UL, (i))#define fb_compute_bswapmask (...) 0#endif /* CONFIG_FB_CFB_REV_PIXELS_IN_BYTE */
drivers/video/fbmem.c +8 -0
@@ -1368,6 +1368,7 @@ register_framebuffer(struct fb_info *fb_info)int i;struct fb_event event;struct fb_videomode mode; +const bool foreign_endian = fb_info->flags &FBINFO_FOREIGN_ENDIAN ;if (num_registered_fb ==FB_MAX )return -ENXIO ;
@@ -1404,6 +1405,13 @@ register_framebuffer(struct fb_info *fb_info)if (!fb_info->pixmap.blit_y) fb_info->pixmap.blit_y = ~(u32 )0 ; + fb_info->flags &= ~FBINFO_FOREIGN_ENDIAN ; +#ifdef __BIG_ENDIAN + fb_info->flags |= foreign_endian ?0 :FBINFO_BE_MATH ; +#else + fb_info->flags |= foreign_endian ?FBINFO_BE_MATH :0 ; +#endif +if (!fb_info->modelist.prev || !fb_info->modelist.next)INIT_LIST_HEAD (&fb_info->modelist);
drivers/video/syscopyarea.c +10 -10
@@ -26,15 +26,15 @@*/ static void -bitcpy (unsigned long *dst,int dst_idx,const unsigned long *src, -int src_idx,int bits,unsigned n) +bitcpy (struct fb_info *p,unsigned long *dst,int dst_idx, +const unsigned long *src,int src_idx,int bits,unsigned n) {unsigned long first, last;int const shift = dst_idx-src_idx;int left, right; - first =FB_SHIFT_HIGH (~0UL , dst_idx); - last = ~(FB_SHIFT_HIGH (~0UL , (dst_idx+n) % bits)); + first =FB_SHIFT_HIGH (p, ~0UL , dst_idx); + last = ~(FB_SHIFT_HIGH (p, ~0UL , (dst_idx+n) % bits));if (!shift) {/* Same alignment for source and dest */
@@ -167,8 +167,8 @@ bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,*/ static void -bitcpy_rev (unsigned long *dst,int dst_idx,const unsigned long *src, -int src_idx,int bits,unsigned n) +bitcpy_rev (struct fb_info *p,unsigned long *dst,int dst_idx, +const unsigned long *src,int src_idx,int bits,unsigned n) {unsigned long first, last;int shift;
@@ -186,8 +186,8 @@ bitcpy_rev(unsigned long *dst, int dst_idx, const unsigned long *src, shift = dst_idx-src_idx; - first =FB_SHIFT_LOW (~0UL , bits -1 - dst_idx); - last = ~(FB_SHIFT_LOW (~0UL , bits -1 - ((dst_idx-n) % bits))); + first =FB_SHIFT_LOW (p, ~0UL , bits -1 - dst_idx); + last = ~(FB_SHIFT_LOW (p, ~0UL , bits -1 - ((dst_idx-n) % bits)));if (!shift) {/* Same alignment for source and dest */
@@ -353,7 +353,7 @@ void sys_copyarea(struct fb_info *p, const struct fb_copyarea *area) dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy_rev (dst, dst_idx, src, src_idx, bits, +bitcpy_rev (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel); } }else {
@@ -362,7 +362,7 @@ void sys_copyarea(struct fb_info *p, const struct fb_copyarea *area) dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy (dst, dst_idx, src, src_idx, bits, +bitcpy (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel); dst_idx += bits_per_line; src_idx += bits_per_line;
drivers/video/sysfillrect.c +25 -24
121 lines not on this page · raw message
drivers/video/sysimgblt.c +22 -25
124 lines not on this page · raw message
include/linux/fb.h +21 -9
@@ -791,6 +791,17 @@ struct fb_tile_ops {*/ #define FBINFO_MISC_ALWAYS_SETPAR 0x40000 +/* +* Host and GPU endianness differ. +*/ +#define FBINFO_FOREIGN_ENDIAN 0x100000 +/* +* Big endian math. This is the same flags as above, but with different +* meaning, it is set by the fb subsystem depending FOREIGN_ENDIAN flag +* and host endianness. Drivers should not use this flag. +*/ +#define FBINFO_BE_MATH 0x100000 +struct fb_info {int node;int flags;
@@ -899,15 +910,11 @@ struct fb_info {#endif -#if defined (__BIG_ENDIAN) -#define FB_LEFT_POS (bpp) (32 - bpp) -#define FB_SHIFT_HIGH (val, bits) ((val) >> (bits)) -#define FB_SHIFT_LOW (val, bits) ((val) << (bits)) -#else -#define FB_LEFT_POS (bpp) (0) -#define FB_SHIFT_HIGH (val, bits) ((val) << (bits)) -#define FB_SHIFT_LOW (val, bits) ((val) >> (bits)) -#endif +#define FB_LEFT_POS (p, bpp) (fb_be_math(p) ? (32 - bpp) : 0) +#define FB_SHIFT_HIGH (p, val, bits) (fb_be_math(p) ? (val) >> (bits) : \ + (val) << (bits)) +#define FB_SHIFT_LOW (p, val, bits) (fb_be_math(p) ? (val) << (bits) : \ + (val) >> (bits))/* * `Generic' versions of the frame buffer device operations
@@ -970,6 +977,11 @@ extern void fb_deferred_io_cleanup(struct fb_info *info);extern int fb_deferred_io_fsync (struct file *file,struct dentry *dentry,int datasync); +static inline bool fb_be_math (struct fb_info *info) +{ +return info->flags &FBINFO_BE_MATH ; +} +/* drivers/video/fbsysfs.c */ extern struct fb_info *framebuffer_alloc (size_t size,struct device *dev);extern void framebuffer_release (struct fb_info *info);
Signature · 1 line
1.5.2.2
Quoted 4 lines · Anton Vorontsov
This patch adds support for the framebuffers with non-native endianness. This is done via
FBINFO_FOREIGN_ENDIANflag that will be used by the drivers. Depending on the host endianness this flag will be overwritten byFBINFO_BE_MATHinternal flag, or cleared.
Or better. Now introduce FB_FOREIGN_ENDIAN config option, so fb_be_math() could be optimized away.
- - - -
From: Anton Vorontsov <[email protected]>
Subject: [PATCH] fb: add support for foreign endianness
This patch adds 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).
--- drivers/video/Kconfig | 9 +++++++ drivers/video/cfbcopyarea.c | 23 ++++++++++-------- drivers/video/cfbfillrect.c | 48 +++++++++++++++++++++------------------ drivers/video/cfbimgblt.c | 52 +++++++++++++++++++++--------------------- drivers/video/fb_draw.h | 31 ++++++++++++++----------- drivers/video/fbmem.c | 8 ++++++ drivers/video/syscopyarea.c | 20 ++++++++-------- drivers/video/sysfillrect.c | 49 ++++++++++++++++++++------------------- drivers/video/sysimgblt.c | 47 ++++++++++++++++++-------------------- include/linux/fb.h | 36 ++++++++++++++++++++++------- 10 files changed, 183 insertions(+), 140 deletions(-)
drivers/video/Kconfig +9 -0
@@ -139,6 +139,15 @@ config FB_SYS_IMAGEBLIT blitting. This is used by drivers that don't provide their own (accelerated) version and the framebuffer is in system RAM. +config FB_FOREIGN_ENDIAN + bool "Enable support for foreign endianness" + depends on FB + ---help--- + This option enables support for the framebuffers with non-native + endianness (e.g. Little-Endian framebuffer on a Big-Endian machine). + You probably don't have such hardware, so in most cases it's safe to + say "n" here. + config FB_SYS_FOPS tristate depends on FB
drivers/video/cfbcopyarea.c +13 -10
@@ -44,15 +44,16 @@*/ static void -bitcpy (unsigned long __iomem *dst,int dst_idx,const unsigned long __iomem *src, -int src_idx,int bits,unsigned n,u32 bswapmask) +bitcpy (struct fb_info *p,unsigned long __iomem *dst,int dst_idx, +const unsigned long __iomem *src,int src_idx,int bits, +unsigned n,u32 bswapmask) {unsigned long first, last;int const shift = dst_idx-src_idx;int left, right; - first =fb_shifted_pixels_mask_long (dst_idx, bswapmask); - last = ~fb_shifted_pixels_mask_long ((dst_idx+n) % bits, bswapmask); + first =fb_shifted_pixels_mask_long (p, dst_idx, bswapmask); + last = ~fb_shifted_pixels_mask_long (p, (dst_idx+n) % bits, bswapmask);if (!shift) {// Same alignment for source and dest
@@ -202,8 +203,9 @@ bitcpy(unsigned long __iomem *dst, int dst_idx, const unsigned long __iomem *src*/ static void -bitcpy_rev (unsigned long __iomem *dst,int dst_idx,const unsigned long __iomem *src, -int src_idx,int bits,unsigned n,u32 bswapmask) +bitcpy_rev (struct fb_info *p,unsigned long __iomem *dst,int dst_idx, +const unsigned long __iomem *src,int src_idx,int bits, +unsigned n,u32 bswapmask) {unsigned long first, last;int shift;
@@ -221,8 +223,9 @@ bitcpy_rev(unsigned long __iomem *dst, int dst_idx, const unsigned long __iomem shift = dst_idx-src_idx; - first =fb_shifted_pixels_mask_long (bits -1 - dst_idx, bswapmask); - last = ~fb_shifted_pixels_mask_long (bits -1 - ((dst_idx-n) % bits), bswapmask); + first =fb_shifted_pixels_mask_long (p, bits -1 - dst_idx, bswapmask); + last = ~fb_shifted_pixels_mask_long (p, bits -1 - ((dst_idx-n) % bits), + bswapmask);if (!shift) {// Same alignment for source and dest
@@ -404,7 +407,7 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy_rev (dst, dst_idx, src, src_idx, bits, +bitcpy_rev (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel, bswapmask); } }else {
@@ -413,7 +416,7 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy (dst, dst_idx, src, src_idx, bits, +bitcpy (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel, bswapmask); dst_idx += bits_per_line; src_idx += bits_per_line;
drivers/video/cfbfillrect.c +26 -22
120 lines not on this page · raw message
drivers/video/cfbimgblt.c +26 -26
131 lines not on this page · raw message
drivers/video/fb_draw.h +17 -14
@@ -94,41 +94,44 @@ static inline unsigned long fb_rev_pixels_in_long(unsigned long val,return val; } -static inline u32 fb_shifted_pixels_mask_u32 (u32 index,u32 bswapmask) +static inline u32 fb_shifted_pixels_mask_u32 (struct fb_info *p,u32 index, +u32 bswapmask) {u32 mask;if (!bswapmask) { - mask =FB_SHIFT_HIGH (~(u32 )0 , index); + mask =FB_SHIFT_HIGH (p, ~(u32 )0 , index); }else { - mask =0xff <<FB_LEFT_POS (8 ); - mask =FB_SHIFT_LOW (mask, index & (bswapmask)) & mask; - mask =FB_SHIFT_HIGH (mask, index & ~(bswapmask)); + mask =0xff <<FB_LEFT_POS (p,8 ); + mask =FB_SHIFT_LOW (p, mask, index & (bswapmask)) & mask; + mask =FB_SHIFT_HIGH (p, mask, index & ~(bswapmask));#if defined(__i386__) || defined(__x86_64__)/* Shift argument is limited to 0 - 31 on x86 based CPU's */ if(index + bswapmask < 32)#endif - mask |=FB_SHIFT_HIGH (~(u32 )0 , + mask |=FB_SHIFT_HIGH (p, ~(u32 )0 , (index + bswapmask) & ~(bswapmask)); }return mask; } -static inline unsigned long fb_shifted_pixels_mask_long (u32 index,u32 bswapmask) +static inline unsigned long fb_shifted_pixels_mask_long (struct fb_info *p, +u32 index, +u32 bswapmask) {unsigned long mask;if (!bswapmask) { - mask =FB_SHIFT_HIGH (~0UL , index); + mask =FB_SHIFT_HIGH (p, ~0UL , index); }else { - mask =0xff <<FB_LEFT_POS (8 ); - mask =FB_SHIFT_LOW (mask, index & (bswapmask)) & mask; - mask =FB_SHIFT_HIGH (mask, index & ~(bswapmask)); + mask =0xff <<FB_LEFT_POS (p,8 ); + mask =FB_SHIFT_LOW (p, mask, index & (bswapmask)) & mask; + mask =FB_SHIFT_HIGH (p, mask, index & ~(bswapmask));#if defined(__i386__) || defined(__x86_64__)/* Shift argument is limited to 0 - 31 on x86 based CPU's */ if(index + bswapmask < BITS_PER_LONG)#endif - mask |=FB_SHIFT_HIGH (~0UL , + mask |=FB_SHIFT_HIGH (p, ~0UL , (index + bswapmask) & ~(bswapmask)); }return mask;
@@ -158,8 +161,8 @@ static inline unsigned long fb_rev_pixels_in_long(unsigned long val, return val; } -#define fb_shifted_pixels_mask_u32 (i, b) FB_SHIFT_HIGH(~(u32)0, (i)) -#define fb_shifted_pixels_mask_long (i, b) FB_SHIFT_HIGH(~0UL, (i)) +#define fb_shifted_pixels_mask_u32 (p, i, b) FB_SHIFT_HIGH((p), ~(u32)0, (i)) +#define fb_shifted_pixels_mask_long (p, i, b) FB_SHIFT_HIGH((p), ~0UL, (i))#define fb_compute_bswapmask (...) 0#endif /* CONFIG_FB_CFB_REV_PIXELS_IN_BYTE */
drivers/video/fbmem.c +8 -0
@@ -1368,6 +1368,7 @@ register_framebuffer(struct fb_info *fb_info)int i;struct fb_event event;struct fb_videomode mode; +const bool foreign_endian = fb_info->flags &FBINFO_FOREIGN_ENDIAN ;if (num_registered_fb ==FB_MAX )return -ENXIO ;
@@ -1404,6 +1405,13 @@ register_framebuffer(struct fb_info *fb_info)if (!fb_info->pixmap.blit_y) fb_info->pixmap.blit_y = ~(u32 )0 ; + fb_info->flags &= ~FBINFO_FOREIGN_ENDIAN ; +#ifdef __BIG_ENDIAN + fb_info->flags |= foreign_endian ?0 :FBINFO_BE_MATH ; +#else + fb_info->flags |= foreign_endian ?FBINFO_BE_MATH :0 ; +#endif +if (!fb_info->modelist.prev || !fb_info->modelist.next)INIT_LIST_HEAD (&fb_info->modelist);
drivers/video/syscopyarea.c +10 -10
@@ -26,15 +26,15 @@*/ static void -bitcpy (unsigned long *dst,int dst_idx,const unsigned long *src, -int src_idx,int bits,unsigned n) +bitcpy (struct fb_info *p,unsigned long *dst,int dst_idx, +const unsigned long *src,int src_idx,int bits,unsigned n) {unsigned long first, last;int const shift = dst_idx-src_idx;int left, right; - first =FB_SHIFT_HIGH (~0UL , dst_idx); - last = ~(FB_SHIFT_HIGH (~0UL , (dst_idx+n) % bits)); + first =FB_SHIFT_HIGH (p, ~0UL , dst_idx); + last = ~(FB_SHIFT_HIGH (p, ~0UL , (dst_idx+n) % bits));if (!shift) {/* Same alignment for source and dest */
@@ -167,8 +167,8 @@ bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,*/ static void -bitcpy_rev (unsigned long *dst,int dst_idx,const unsigned long *src, -int src_idx,int bits,unsigned n) +bitcpy_rev (struct fb_info *p,unsigned long *dst,int dst_idx, +const unsigned long *src,int src_idx,int bits,unsigned n) {unsigned long first, last;int shift;
@@ -186,8 +186,8 @@ bitcpy_rev(unsigned long *dst, int dst_idx, const unsigned long *src, shift = dst_idx-src_idx; - first =FB_SHIFT_LOW (~0UL , bits -1 - dst_idx); - last = ~(FB_SHIFT_LOW (~0UL , bits -1 - ((dst_idx-n) % bits))); + first =FB_SHIFT_LOW (p, ~0UL , bits -1 - dst_idx); + last = ~(FB_SHIFT_LOW (p, ~0UL , bits -1 - ((dst_idx-n) % bits)));if (!shift) {/* Same alignment for source and dest */
@@ -353,7 +353,7 @@ void sys_copyarea(struct fb_info *p, const struct fb_copyarea *area) dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy_rev (dst, dst_idx, src, src_idx, bits, +bitcpy_rev (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel); } }else {
@@ -362,7 +362,7 @@ void sys_copyarea(struct fb_info *p, const struct fb_copyarea *area) dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy (dst, dst_idx, src, src_idx, bits, +bitcpy (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel); dst_idx += bits_per_line; src_idx += bits_per_line;
drivers/video/sysfillrect.c +25 -24
121 lines not on this page · raw message
drivers/video/sysimgblt.c +22 -25
124 lines not on this page · raw message
include/linux/fb.h +27 -9
@@ -791,6 +791,17 @@ struct fb_tile_ops {*/ #define FBINFO_MISC_ALWAYS_SETPAR 0x40000 +/* +* Host and GPU endianness differ. +*/ +#define FBINFO_FOREIGN_ENDIAN 0x100000 +/* +* Big endian math. This is the same flags as above, but with different +* meaning, it is set by the fb subsystem depending FOREIGN_ENDIAN flag +* and host endianness. Drivers should not use this flag. +*/ +#define FBINFO_BE_MATH 0x100000 +struct fb_info {int node;int flags;
@@ -899,15 +910,11 @@ struct fb_info {#endif -#if defined (__BIG_ENDIAN) -#define FB_LEFT_POS (bpp) (32 - bpp) -#define FB_SHIFT_HIGH (val, bits) ((val) >> (bits)) -#define FB_SHIFT_LOW (val, bits) ((val) << (bits)) -#else -#define FB_LEFT_POS (bpp) (0) -#define FB_SHIFT_HIGH (val, bits) ((val) << (bits)) -#define FB_SHIFT_LOW (val, bits) ((val) >> (bits)) -#endif +#define FB_LEFT_POS (p, bpp) (fb_be_math(p) ? (32 - (bpp)) : 0) +#define FB_SHIFT_HIGH (p, val, bits) (fb_be_math(p) ? (val) >> (bits) : \ + (val) << (bits)) +#define FB_SHIFT_LOW (p, val, bits) (fb_be_math(p) ? (val) << (bits) : \ + (val) >> (bits))/* * `Generic' versions of the frame buffer device operations
@@ -970,6 +977,17 @@ extern void fb_deferred_io_cleanup(struct fb_info *info);extern int fb_deferred_io_fsync (struct file *file,struct dentry *dentry,int datasync); +static inline bool fb_be_math (struct fb_info *info) +{ +#if defined(CONFIG_FB_FOREIGN_ENDIAN ) +return info->flags &FBINFO_BE_MATH ; +#elif defined(__BIG_ENDIAN) +return true; +#else +return false; +#endif +} +/* drivers/video/fbsysfs.c */ extern struct fb_info *framebuffer_alloc (size_t size,struct device *dev);extern void framebuffer_release (struct fb_info *info);
Signature · 1 line
1.5.2.2
Quoted 6 lines · On Tue, 5 Feb 2008 18:44:32 +0300 Anton Vorontsov <[email protected]>…
This patch adds support for the framebuffers with non-native endianness. This is done via
FBINFO_FOREIGN_ENDIANflag that will be used by the drivers. Depending on the host endianness this flag will be overwritten byFBINFO_BE_MATHinternal flag, or cleared.Tested to work on MPC8360E-RDK (BE) + Fujitsu MINT framebuffer (LE).
That's a pretty large patch to fbdev core, and Tony appears to have gone offline again and you didn't cc the fbdev mailing list.
I fixed the third problem. Could the other fbdev developers please review and comment on this?
Thanks.
Actually... should CONFIG_FB_FOREIGN_ENDIAN exist, or should this feature be permanently enabled?
I'd like to at least queue a patch in -mm so that CONFIG_FB_FOREIGN_ENDIAN is forced-on, so the code gets some runtime testing. Will that break anything?
From: Anton Vorontsov <[email protected]>
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).
---
drivers/video/Kconfig | 9 +++++ drivers/video/cfbcopyarea.c | 23 ++++++++------- drivers/video/cfbfillrect.c | 48 +++++++++++++++++-------------- drivers/video/cfbimgblt.c | 52 +++++++++++++++++----------------- drivers/video/fb_draw.h | 31 +++++++++++--------- drivers/video/fbmem.c | 8 +++++ drivers/video/syscopyarea.c | 20 ++++++------- drivers/video/sysfillrect.c | 49 ++++++++++++++++---------------- drivers/video/sysimgblt.c | 47 ++++++++++++++---------------- include/linux/fb.h | 36 +++++++++++++++++------ 10 files changed, 183 insertions(+), 140 deletions(-)
drivers/video/Kconfig renamed from drivers/video/Kconfig~fb-add-support-for-foreign-endianness +9 -0
@@ -139,6 +139,15 @@ config FB_SYS_IMAGEBLIT blitting. This is used by drivers that don't provide their own (accelerated) version and the framebuffer is in system RAM. +config FB_FOREIGN_ENDIAN + bool "Enable support for foreign endianness" + depends on FB + ---help--- + This option enables support for the framebuffers with non-native + endianness (e.g. Little-Endian framebuffer on a Big-Endian machine). + You probably don't have such hardware, so in most cases it's safe to + say "n" here. + config FB_SYS_FOPS tristate depends on FB
drivers/video/cfbcopyarea.c renamed from drivers/video/cfbcopyarea.c~fb-add-support-for-foreign-endianness +13 -10
@@ -44,15 +44,16 @@*/ static void -bitcpy (unsigned long __iomem *dst,int dst_idx,const unsigned long __iomem *src, -int src_idx,int bits,unsigned n,u32 bswapmask) +bitcpy (struct fb_info *p,unsigned long __iomem *dst,int dst_idx, +const unsigned long __iomem *src,int src_idx,int bits, +unsigned n,u32 bswapmask) {unsigned long first, last;int const shift = dst_idx-src_idx;int left, right; - first =fb_shifted_pixels_mask_long (dst_idx, bswapmask); - last = ~fb_shifted_pixels_mask_long ((dst_idx+n) % bits, bswapmask); + first =fb_shifted_pixels_mask_long (p, dst_idx, bswapmask); + last = ~fb_shifted_pixels_mask_long (p, (dst_idx+n) % bits, bswapmask);if (!shift) {// Same alignment for source and dest
@@ -202,8 +203,9 @@ bitcpy(unsigned long __iomem *dst, int d*/ static void -bitcpy_rev (unsigned long __iomem *dst,int dst_idx,const unsigned long __iomem *src, -int src_idx,int bits,unsigned n,u32 bswapmask) +bitcpy_rev (struct fb_info *p,unsigned long __iomem *dst,int dst_idx, +const unsigned long __iomem *src,int src_idx,int bits, +unsigned n,u32 bswapmask) {unsigned long first, last;int shift;
@@ -221,8 +223,9 @@ bitcpy_rev(unsigned long __iomem *dst, i shift = dst_idx-src_idx; - first =fb_shifted_pixels_mask_long (bits -1 - dst_idx, bswapmask); - last = ~fb_shifted_pixels_mask_long (bits -1 - ((dst_idx-n) % bits), bswapmask); + first =fb_shifted_pixels_mask_long (p, bits -1 - dst_idx, bswapmask); + last = ~fb_shifted_pixels_mask_long (p, bits -1 - ((dst_idx-n) % bits), + bswapmask);if (!shift) {// Same alignment for source and dest
@@ -404,7 +407,7 @@ void cfb_copyarea(struct fb_info *p, con dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy_rev (dst, dst_idx, src, src_idx, bits, +bitcpy_rev (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel, bswapmask); } }else {
@@ -413,7 +416,7 @@ void cfb_copyarea(struct fb_info *p, con dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy (dst, dst_idx, src, src_idx, bits, +bitcpy (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel, bswapmask); dst_idx += bits_per_line; src_idx += bits_per_line;
drivers/video/cfbfillrect.c renamed from drivers/video/cfbfillrect.c~fb-add-support-for-foreign-endianness +26 -22
120 lines not on this page · raw message
drivers/video/cfbimgblt.c renamed from drivers/video/cfbimgblt.c~fb-add-support-for-foreign-endianness +26 -26
131 lines not on this page · raw message
drivers/video/fb_draw.h renamed from drivers/video/fb_draw.h~fb-add-support-for-foreign-endianness +17 -14
@@ -94,41 +94,44 @@ static inline unsigned long fb_rev_pixelreturn val; } -static inline u32 fb_shifted_pixels_mask_u32 (u32 index,u32 bswapmask) +static inline u32 fb_shifted_pixels_mask_u32 (struct fb_info *p,u32 index, +u32 bswapmask) {u32 mask;if (!bswapmask) { - mask =FB_SHIFT_HIGH (~(u32 )0 , index); + mask =FB_SHIFT_HIGH (p, ~(u32 )0 , index); }else { - mask =0xff <<FB_LEFT_POS (8 ); - mask =FB_SHIFT_LOW (mask, index & (bswapmask)) & mask; - mask =FB_SHIFT_HIGH (mask, index & ~(bswapmask)); + mask =0xff <<FB_LEFT_POS (p,8 ); + mask =FB_SHIFT_LOW (p, mask, index & (bswapmask)) & mask; + mask =FB_SHIFT_HIGH (p, mask, index & ~(bswapmask));#if defined(__i386__) || defined(__x86_64__)/* Shift argument is limited to 0 - 31 on x86 based CPU's */ if(index + bswapmask < 32)#endif - mask |=FB_SHIFT_HIGH (~(u32 )0 , + mask |=FB_SHIFT_HIGH (p, ~(u32 )0 , (index + bswapmask) & ~(bswapmask)); }return mask; } -static inline unsigned long fb_shifted_pixels_mask_long (u32 index,u32 bswapmask) +static inline unsigned long fb_shifted_pixels_mask_long (struct fb_info *p, +u32 index, +u32 bswapmask) {unsigned long mask;if (!bswapmask) { - mask =FB_SHIFT_HIGH (~0UL , index); + mask =FB_SHIFT_HIGH (p, ~0UL , index); }else { - mask =0xff <<FB_LEFT_POS (8 ); - mask =FB_SHIFT_LOW (mask, index & (bswapmask)) & mask; - mask =FB_SHIFT_HIGH (mask, index & ~(bswapmask)); + mask =0xff <<FB_LEFT_POS (p,8 ); + mask =FB_SHIFT_LOW (p, mask, index & (bswapmask)) & mask; + mask =FB_SHIFT_HIGH (p, mask, index & ~(bswapmask));#if defined(__i386__) || defined(__x86_64__)/* Shift argument is limited to 0 - 31 on x86 based CPU's */ if(index + bswapmask < BITS_PER_LONG)#endif - mask |=FB_SHIFT_HIGH (~0UL , + mask |=FB_SHIFT_HIGH (p, ~0UL , (index + bswapmask) & ~(bswapmask)); }return mask;
@@ -158,8 +161,8 @@ static inline unsigned long fb_rev_pixel return val; } -#define fb_shifted_pixels_mask_u32 (i, b) FB_SHIFT_HIGH(~(u32)0, (i)) -#define fb_shifted_pixels_mask_long (i, b) FB_SHIFT_HIGH(~0UL, (i)) +#define fb_shifted_pixels_mask_u32 (p, i, b) FB_SHIFT_HIGH((p), ~(u32)0, (i)) +#define fb_shifted_pixels_mask_long (p, i, b) FB_SHIFT_HIGH((p), ~0UL, (i))#define fb_compute_bswapmask (...) 0#endif /* CONFIG_FB_CFB_REV_PIXELS_IN_BYTE */
drivers/video/fbmem.c renamed from drivers/video/fbmem.c~fb-add-support-for-foreign-endianness +8 -0
@@ -1368,6 +1368,7 @@ register_framebuffer(struct fb_info *fb_int i;struct fb_event event;struct fb_videomode mode; +const bool foreign_endian = fb_info->flags &FBINFO_FOREIGN_ENDIAN ;if (num_registered_fb ==FB_MAX )return -ENXIO ;
@@ -1404,6 +1405,13 @@ register_framebuffer(struct fb_info *fb_if (!fb_info->pixmap.blit_y) fb_info->pixmap.blit_y = ~(u32 )0 ; + fb_info->flags &= ~FBINFO_FOREIGN_ENDIAN ; +#ifdef __BIG_ENDIAN + fb_info->flags |= foreign_endian ?0 :FBINFO_BE_MATH ; +#else + fb_info->flags |= foreign_endian ?FBINFO_BE_MATH :0 ; +#endif +if (!fb_info->modelist.prev || !fb_info->modelist.next)INIT_LIST_HEAD (&fb_info->modelist);
drivers/video/syscopyarea.c renamed from drivers/video/syscopyarea.c~fb-add-support-for-foreign-endianness +10 -10
@@ -26,15 +26,15 @@*/ static void -bitcpy (unsigned long *dst,int dst_idx,const unsigned long *src, -int src_idx,int bits,unsigned n) +bitcpy (struct fb_info *p,unsigned long *dst,int dst_idx, +const unsigned long *src,int src_idx,int bits,unsigned n) {unsigned long first, last;int const shift = dst_idx-src_idx;int left, right; - first =FB_SHIFT_HIGH (~0UL , dst_idx); - last = ~(FB_SHIFT_HIGH (~0UL , (dst_idx+n) % bits)); + first =FB_SHIFT_HIGH (p, ~0UL , dst_idx); + last = ~(FB_SHIFT_HIGH (p, ~0UL , (dst_idx+n) % bits));if (!shift) {/* Same alignment for source and dest */
@@ -167,8 +167,8 @@ bitcpy(unsigned long *dst, int dst_idx,*/ static void -bitcpy_rev (unsigned long *dst,int dst_idx,const unsigned long *src, -int src_idx,int bits,unsigned n) +bitcpy_rev (struct fb_info *p,unsigned long *dst,int dst_idx, +const unsigned long *src,int src_idx,int bits,unsigned n) {unsigned long first, last;int shift;
@@ -186,8 +186,8 @@ bitcpy_rev(unsigned long *dst, int dst_i shift = dst_idx-src_idx; - first =FB_SHIFT_LOW (~0UL , bits -1 - dst_idx); - last = ~(FB_SHIFT_LOW (~0UL , bits -1 - ((dst_idx-n) % bits))); + first =FB_SHIFT_LOW (p, ~0UL , bits -1 - dst_idx); + last = ~(FB_SHIFT_LOW (p, ~0UL , bits -1 - ((dst_idx-n) % bits)));if (!shift) {/* Same alignment for source and dest */
@@ -353,7 +353,7 @@ void sys_copyarea(struct fb_info *p, con dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy_rev (dst, dst_idx, src, src_idx, bits, +bitcpy_rev (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel); } }else {
@@ -362,7 +362,7 @@ void sys_copyarea(struct fb_info *p, con dst_idx &= (bytes -1 ); src += src_idx >> (ffs (bits) -1 ); src_idx &= (bytes -1 ); -bitcpy (dst, dst_idx, src, src_idx, bits, +bitcpy (p, dst, dst_idx, src, src_idx, bits, width*p->var.bits_per_pixel); dst_idx += bits_per_line; src_idx += bits_per_line;
drivers/video/sysfillrect.c renamed from drivers/video/sysfillrect.c~fb-add-support-for-foreign-endianness +25 -24
121 lines not on this page · raw message
drivers/video/sysimgblt.c renamed from drivers/video/sysimgblt.c~fb-add-support-for-foreign-endianness +22 -25
124 lines not on this page · raw message
include/linux/fb.h renamed from include/linux/fb.h~fb-add-support-for-foreign-endianness +27 -9
@@ -791,6 +791,17 @@ struct fb_tile_ops {*/ #define FBINFO_MISC_ALWAYS_SETPAR 0x40000 +/* +* Host and GPU endianness differ. +*/ +#define FBINFO_FOREIGN_ENDIAN 0x100000 +/* +* Big endian math. This is the same flags as above, but with different +* meaning, it is set by the fb subsystem depending FOREIGN_ENDIAN flag +* and host endianness. Drivers should not use this flag. +*/ +#define FBINFO_BE_MATH 0x100000 +struct fb_info {int node;int flags;
@@ -899,15 +910,11 @@ struct fb_info {#endif -#if defined (__BIG_ENDIAN) -#define FB_LEFT_POS (bpp) (32 - bpp) -#define FB_SHIFT_HIGH (val, bits) ((val) >> (bits)) -#define FB_SHIFT_LOW (val, bits) ((val) << (bits)) -#else -#define FB_LEFT_POS (bpp) (0) -#define FB_SHIFT_HIGH (val, bits) ((val) << (bits)) -#define FB_SHIFT_LOW (val, bits) ((val) >> (bits)) -#endif +#define FB_LEFT_POS (p, bpp) (fb_be_math(p) ? (32 - (bpp)) : 0) +#define FB_SHIFT_HIGH (p, val, bits) (fb_be_math(p) ? (val) >> (bits) : \ + (val) << (bits)) +#define FB_SHIFT_LOW (p, val, bits) (fb_be_math(p) ? (val) << (bits) : \ + (val) >> (bits))/* * `Generic' versions of the frame buffer device operations
@@ -970,6 +977,17 @@ extern void fb_deferred_io_cleanup(strucextern int fb_deferred_io_fsync (struct file *file,struct dentry *dentry,int datasync); +static inline bool fb_be_math (struct fb_info *info) +{ +#if defined(CONFIG_FB_FOREIGN_ENDIAN ) +return info->flags &FBINFO_BE_MATH ; +#elif defined(__BIG_ENDIAN) +return true; +#else +return false; +#endif +} +/* drivers/video/fbsysfs.c */ extern struct fb_info *framebuffer_alloc (size_t size,struct device *dev);extern void framebuffer_release (struct fb_info *info);
_
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 10 lines · Andrew Morton
Quoted 6 lines · On Tue, 5 Feb 2008 18:44:32 +0300 Anton Vorontsov <[email protected]>…
This patch adds support for the framebuffers with non-native endianness. This is done via
FBINFO_FOREIGN_ENDIANflag that will be used by the drivers. Depending on the host endianness this flag will be overwritten byFBINFO_BE_MATHinternal flag, or cleared.Tested to work on MPC8360E-RDK (BE) + Fujitsu MINT framebuffer (LE).
That's a pretty large patch to fbdev core,
Yes, but changes are mostly trivial. No insurance of typos and thinkos though. OTOH, it survived my tests.
Quoted 2 lines
and Tony appears to have gone
offline again and you didn't cc the fbdev mailing list.
FRAMEBUFFER LAYER
P: Antonino Daplas M: [email protected] L: [email protected] (subscribers-only)
I'm lazy to subscribe on occasional patches. Yup, this is hardly an excuse...
Quoted 9 lines
I fixed the third problem. Could the other fbdev developers please review and comment on this?
Thanks.
Actually... should
CONFIG_FB_FOREIGN_ENDIANexist, or should this feature be permanently enabled?
It should not. Because with CONFIG_FB_FOREIGN_ENDIAN enabled, drawing might be a little bit slower, because of external checks for endianness (I didn't noticed any slowdown, but I guess it's still measurable if we find some fb benchmark).
Thinking about it a little bit more, I believe we want to add a choice, which exactly foreign endianness we want to compile-in. Then, if we're pretty confident that particular BE machine uses only LE framebuffer, gcc can optimize away endianness checks.
Patch on top of previous inlined here. With that patch, slowdown is possible with CONFIG_FB_BOTH_ENDIAN option only, which is still default if FOREIGN_ENDIAN is selected.
Quoted 3 lines
I'd like to at least queue a patch in -mm so that
CONFIG_FB_FOREIGN_ENDIANis forced-on, so the code gets some runtime testing. Will that break anything?
Nope, it should not break anything, just possible fbconsole/tux drawing slowdown.
Thanks,
- - - -
From: Anton Vorontsov <[email protected]>
Subject: fb: add support for choice foreign endianness
With this patch FB_FOREIGN_ENDIAN converted to menuconfig with the choice inside: which type of foreign endianness we want to compile-in.
As a bonus, now fb subsystem will refuse to register framebuffer with unsupported endianness, and will suggest a way to solve the problem.
[ on top of fb-add-support-for-foreign-endianness.patch ]
--- drivers/video/Kconfig | 27 +++++++++++++++++++++------ drivers/video/fbmem.c | 38 ++++++++++++++++++++++++++++++-------- include/linux/fb.h | 14 +++++++++++--- 3 files changed, 62 insertions(+), 17 deletions(-)
drivers/video/Kconfig +21 -6
@@ -139,14 +139,29 @@ config FB_SYS_IMAGEBLIT blitting. This is used by drivers that don't provide their own (accelerated) version and the framebuffer is in system RAM. -config FB_FOREIGN_ENDIAN - bool "Enable support for foreign endianness" +menuconfig FB_FOREIGN_ENDIAN + bool "Framebuffer foreign endianness support" depends on FB ---help--- - This option enables support for the framebuffers with non-native - endianness (e.g. Little-Endian framebuffer on a Big-Endian machine). - You probably don't have such hardware, so in most cases it's safe to - say "n" here. + This menu will let you enable support for the framebuffers with + non-native endianness (e.g. Little-Endian framebuffer on a + Big-Endian machine). Most probably you don't have such hardware, + so it's safe to say "n" here. + +choice + prompt "Choice endianness support" + depends on FB_FOREIGN_ENDIAN + +config FB_BOTH_ENDIAN + bool "Support for Big- and Little-Endian framebuffers" + +config FB_BIG_ENDIAN + bool "Support for Big-Endian framebuffers only" + +config FB_LITTLE_ENDIAN + bool "Support for Little-Endian framebuffers only" + +endchoice config FB_SYS_FOPS tristate
drivers/video/fbmem.c +30 -8
@@ -1352,6 +1352,32 @@ static const struct file_operations fb_fops = {struct class *fb_class;EXPORT_SYMBOL (fb_class); + +static int fb_check_foreignness (struct fb_info *fi) +{ +const bool foreign_endian = fi->flags &FBINFO_FOREIGN_ENDIAN ; + + fi->flags &= ~FBINFO_FOREIGN_ENDIAN ; + +#ifdef __BIG_ENDIAN + fi->flags |= foreign_endian ?0 :FBINFO_BE_MATH ; +#else + fi->flags |= foreign_endian ?FBINFO_BE_MATH :0 ; +#endif /* __BIG_ENDIAN */ + +if (fi->flags &FBINFO_BE_MATH && !fb_be_math (fi)) { +pr_err ("%s: enable CONFIG_FB_BIG_ENDIAN to " +"support this framebuffer\n" , fi->fix.id); +return -ENOSYS ; + }else if (!(fi->flags &FBINFO_BE_MATH ) &&fb_be_math (fi)) { +pr_err ("%s: enable CONFIG_FB_LITTLE_ENDIAN to " +"support this framebuffer\n" , fi->fix.id); +return -ENOSYS ; + } + +return 0 ; +} +/** * register_framebuffer - registers a frame buffer device * @fb_info: frame buffer info structure
@@ -1368,10 +1394,13 @@ register_framebuffer(struct fb_info *fb_info)int i;struct fb_event event;struct fb_videomode mode; -const bool foreign_endian = fb_info->flags &FBINFO_FOREIGN_ENDIAN ;if (num_registered_fb ==FB_MAX )return -ENXIO ; + +if (fb_check_foreignness (fb_info)) +return -ENOSYS ; + num_registered_fb++;for (i =0 ; i <FB_MAX ; i++)if (!registered_fb[i])
@@ -1405,13 +1434,6 @@ register_framebuffer(struct fb_info *fb_info)if (!fb_info->pixmap.blit_y) fb_info->pixmap.blit_y = ~(u32 )0 ; - fb_info->flags &= ~FBINFO_FOREIGN_ENDIAN ; -#ifdef __BIG_ENDIAN - fb_info->flags |= foreign_endian ?0 :FBINFO_BE_MATH ; -#else - fb_info->flags |= foreign_endian ?FBINFO_BE_MATH :0 ; -#endif -if (!fb_info->modelist.prev || !fb_info->modelist.next)INIT_LIST_HEAD (&fb_info->modelist);
include/linux/fb.h +11 -3
@@ -979,13 +979,21 @@ extern int fb_deferred_io_fsync(struct file *file, struct dentry *dentry,static inline bool fb_be_math (struct fb_info *info) { -#if defined(CONFIG_FB_FOREIGN_ENDIAN ) +#ifdef CONFIG_FB_FOREIGN_ENDIAN +#if defined(CONFIG_FB_BOTH_ENDIAN )return info->flags &FBINFO_BE_MATH ; -#elif defined(__BIG_ENDIAN) +#elif defined(CONFIG_FB_BIG_ENDIAN ) +return true; +#elif defined(CONFIG_FB_LITTLE_ENDIAN ) +return false; +#endif /* CONFIG_FB_BOTH_ENDIAN */ +#else +#ifdef __BIG_ENDIANreturn true;#else return false; -#endif +#endif /* __BIG_ENDIAN */ +#endif /* CONFIG_FB_FOREIGN_ENDIAN */ }/* drivers/video/fbsysfs.c */
Signature · 1 line
1.5.2.2
Quoted 6 lines · Anton Vorontsov
This patch adds support for the framebuffers with non-native endianness. This is done via
FBINFO_FOREIGN_ENDIANflag that will be used by the drivers. Depending on the host endianness this flag will be overwritten byFBINFO_BE_MATHinternal flag, or cleared.Tested to work on MPC8360E-RDK (BE) + Fujitsu MINT framebuffer (LE).
Good luck running X on that thing :-)
The base server seems to cope.. until you start using render operations or that sort of things, and then things blow up. There's shitload of stuff that seems to assume native fb endianness..
Ben.
Quoted 17 lines · Anton Vorontsov
Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Tue, 5 Feb 2008 18:44:32 +0300 Anton Vorontsov <[email protected]>…
This patch adds support for the framebuffers with non-native endianness. This is done via
FBINFO_FOREIGN_ENDIANflag that will be used by the drivers. Depending on the host endianness this flag will be overwritten byFBINFO_BE_MATHinternal flag, or cleared.Tested to work on MPC8360E-RDK (BE) + Fujitsu MINT framebuffer (LE).
That's a pretty large patch to fbdev core,
Yes, but changes are mostly trivial. No insurance of typos and thinkos though. OTOH, it survived my tests.
Quoted 2 lines
and Tony appears to have gone
offline again and you didn't cc the fbdev mailing list.
Quoted 7 lines
FRAMEBUFFER LAYER
P: Antonino Daplas M: [email protected] L: [email protected] (subscribers-only)I'm lazy to subscribe on occasional patches. Yup, this is hardly an excuse...
While linux-fbdev is subscribers-only, non-subscribers are not plainly rejected, but moderated, so the casual patch/comment/question comes through.
I'll cook up a patch for MAINTAINERS to clarify.
Quoted 8 lines
Quoted 2 lines
Actually... should
CONFIG_FB_FOREIGN_ENDIANexist, or should this feature be permanently enabled?It should not. Because with
CONFIG_FB_FOREIGN_ENDIANenabled, drawing might be a little bit slower, because of external checks for endianness (I didn't noticed any slowdown, but I guess it's still measurable if we find some fb benchmark).
Quoted 6 lines
Quoted 3 lines
I'd like to at least queue a patch in -mm so that
CONFIG_FB_FOREIGN_ENDIANis forced-on, so the code gets some runtime testing. Will that break anything?Nope, it should not break anything, just possible fbconsole/tux drawing slowdown.
Tux drawing speed doesn't really matter, as it's done once only. Console text drawing is different.
`time cat MAINTAINERS' is a good test. Of course, is most time is spent in scrolling, you won't see much difference.
So probably we need a test file that contains lines of text interspersed with `HOME' escape sequences, so we don't scroll?
Quoted 11 lines
Thinking about it a little bit more, I believe we want to add a choice, which exactly foreign endianness we want to compile-in. Then, if we're pretty confident that particular BE machine uses only LE framebuffer, gcc can optimize away endianness checks.
Patch on top of previous inlined here. With that patch, slowdown is possible with
CONFIG_FB_BOTH_ENDIANoption only, which is still default ifFOREIGN_ENDIANis selected.
With this patchFB_FOREIGN_ENDIANconverted to menuconfig with the choice inside: which type of foreign endianness we want to compile-in.
The notion of `FOREIGN_ENDIAN' is relative, as it depends on the architecture you're compiling for.
Suppose you have a PCI graphics card with a frame buffer that's always big endian. When compiling for a big endian platform, the driver won't depend on FB_FOREIGN_ENDIAN. When compiling for a little endian platform, it will.
Shouldn't we add LITTLE_ENDIAN and BIG_ENDIAN Kconfig vars first, just like we have 64BIT?
Quoted 2 lines
As a bonus, now fb subsystem will refuse to register framebuffer with unsupported endianness, and will suggest a way to solve the problem.
I'd like to handle this in Kconfig (cfr. above).
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
Quoted 7 lines · On Sun, 17 Feb 2008 10:44:32 +0100 (CET) Geert Uytterhoeven…
Quoted 6 lines · Anton Vorontsov
Quoted 4 lines · Andrew Morton
On Tue, 5 Feb 2008 18:44:32 +0300 Anton Vorontsov <[email protected]> wrote:
Actually... should
CONFIG_FB_FOREIGN_ENDIANexist, or should this feature be permanently enabled?
(...)
Quoted 4 lines
The notion of `FOREIGN_ENDIAN' is relative, as it depends on the architecture you're compiling for.
Quoted 8 lines
Suppose you have a PCI graphics card with a frame buffer that's always big endian. When compiling for a big endian platform, the driver won't depend on
FB_FOREIGN_ENDIAN. When compiling for a little endian platform, it will.Shouldn't we add
LITTLE_ENDIANandBIG_ENDIANKconfigvars first, just like we have 64BIT?
I disagree here. The FOREIGN_ENDIAN is enough. It is determined only by graphics chip endianess and CPU (arch) endianess.
I know two fb drivers which use endianess information (pm2fb and s3c2410fb). Both resolve endianess at driver level. Actually, both handle it by setting special bits so the graphics chip itself reorder bytes to transform foreign endianess. I understand that this patch is for chips which cannot reorder bytes by themselves.
So the FOREIGN_ENDIANESS flag should be set by the driver if it is needed (if the graphics chip is BE and CPU is LE a simple #ifdef will add the flag).
Quoted 3 lines
I'd like to handle this in
Kconfig(cfr. above).
Again, it is possible. It is enough to put one rule which enables the FOREIGN_ENDIAN if the architecture endianess is "foreign" for the driver. The advantage here is that it can be set only for drivers which need it (as some driver can handle it without this code). It should be hidden option set only internally if needed (no user selectable).
I tested this patch on the s3c2410fb with disabled byte order corrections by the graphics chip itself. It worked for 8-bit depth but not for 16-bit depth (pixel position seemed ok but wrong tux' colors). I will investigate. The s3c2410fb is BE and the kernel was arm LE.
I would like to extend this patch to fb depths below 8-bit. The s3c2410fb cannot handle this correctly with LE kernel.
Kind regards,
Krzysztof
----------------------------------------------------------------------
Masz ostatnia szanse !
Sprawdz >>> http://link.interia.pl/f1d02
Quoted 4 lines · Krzysztof Helt
I know two fb drivers which use endianess information (pm2fb and s3c2410fb). Both resolve endianess at driver level. Actually, both handle it by setting special bits so the graphics chip itself reorder bytes to transform foreign endianess. I understand that this patch is for chips which cannot reorder bytes by themselves.
Does anybody know of such a chip that's actually available in the wild? Or are we writing drivers for speculative possible chips?
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Linux-fbdev-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
Quoted 7 lines · On Mon, Feb 18, 2008 at 12:30:11PM -0500, [email protected] wrote:
Quoted 4 lines · Krzysztof Helt
I know two fb drivers which use endianess information (pm2fb and s3c2410fb). Both resolve endianess at driver level. Actually, both handle it by setting special bits so the graphics chip itself reorder bytes to transform foreign endianess. I understand that this patch is for chips which cannot reorder bytes by themselves.
Does anybody know of such a chip that's actually available in the wild?
LE Fujitsu mb86277 (MINT) on the BE MPC8360E.
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
Quoted 8 lines · [email protected] schrieb:
Quoted 3 lines · Krzysztof Helt
I know two fb drivers which use endianess information (pm2fb and s3c2410fb).
Both resolve endianess at driver level. Actually, both handle it by setting special
bits so the graphics chip itself reorder bytes to transform foreign endianess. I understand that this patch is for chips which cannot reorder bytes by themselves.Does anybody know of such a chip that's actually available in the wild? Or are we writing drivers for speculative possible chips?
I had troubles with the Silicon Motion SM501/SM502 endianess on PowerPC PCI vs. LocalBus. The chip also has a register to swap endianess, but that seems to only affect some LocalBus modes.
The current fb and X drivers are working, but when it comes to font aliasing and hw-acceleration, the problems start to rise again...
Regards,
Clemens
Quoted 11 lines · Clemens Koller
Quoted 9 lines · [email protected] schrieb:
Quoted 4 lines · Krzysztof Helt
I know two fb drivers which use endianess information (pm2fb and s3c2410fb). Both resolve endianess at driver level. Actually, both handle it by setting special bits so the graphics chip itself reorder bytes to transform foreign endianess. I understand that this patch is for chips which cannot reorder bytes by themselves.
Does anybody know of such a chip that's actually available in the wild? Or are we writing drivers for speculative possible chips?
Quoted 5 lines
I had troubles with the Silicon Motion SM501/SM502 endianess on PowerPC PCI vs. LocalBus. The chip also has a register to swap endianess, but that seems to only affect some LocalBus modes.
The current fb and X drivers are working, but when it comes to font aliasing and hw-acceleration, the problems start to rise again...
Most "sane" gfx chips nowadays provide configurable surfaces that allow to perform the swap when writing/reading from regions of the framebuffer, with the ability to set a different swapper setting (based on bit depth) per region.
Then there is also the risk that your PCI<->Localbus has been wired improperly :-)
Ben.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 15 lines · Benjamin Herrenschmidt
Quoted 5 lines · Clemens Koller
Quoted 4 lines · [email protected] schrieb:
Quoted 3 lines · Krzysztof Helt
I know two fb drivers which use endianess information (pm2fb and s3c2410fb).
Both resolve endianess at driver level. Actually, both handle it by setting special
bits so the graphics chip itself reorder bytes to transform foreign endianess. I understand that this patch is for chips which cannot reorder bytes by themselves.Quoted 8 lines
Quoted 3 lines
Does anybody know of such a chip that's actually available in the wild? Or are we writing drivers for speculative possible chips?
I had troubles with the Silicon Motion SM501/SM502 endianess on PowerPC PCI vs. LocalBus. The chip also has a register to swap endianess, but that seems to only affect some LocalBus modes.
The current fb and X drivers are working, but when it comes to font aliasing and hw-acceleration, the problems start to rise again...
Quoted 4 lines
Most "sane" gfx chips nowadays provide configurable surfaces that allow to perform the swap when writing/reading from regions of the framebuffer, with the ability to set a different swapper setting (based on bit depth) per region.
Most! But not the SM50x. I still hope I would be wrong here. :-(
Quoted 2 lines
Then there is also the risk that your PCI<->Localbus has been wired improperly :-)
That's not an issue in my case. The SM50x can be connected to either an PCI or some Local/CPU-whateverbus IF.
I.e. on the MPC85xx PowerPC, PCI and LocalBus are separate bussses. If the sm501 is attached to the MPC85xx' PCI like any other video card, the PCI config-space is can be accessed as usual, whereas the framebuffer memory area is byte-swapped compared to other common video cards.
So, to get back on topic:
I would welcome endianess swapping in SW. Some architectures (PowerPC) should also be able to do swapped-endian mmapping. I just haven't had time for a closer look but it looks also interesting way to do it that way.
Regards,
Clemens
Quoted 34 lines · On Tue, 19 Feb 2008 12:27:54 +0100 Clemens Koller <[email protected]>…
Quoted 16 lines · Benjamin Herrenschmidt
Quoted 6 lines · Clemens Koller
Quoted 5 lines · [email protected] schrieb:
Quoted 4 lines · Krzysztof Helt
I know two fb drivers which use endianess information (pm2fb and s3c2410fb). Both resolve endianess at driver level. Actually, both handle it by setting special bits so the graphics chip itself reorder bytes to transform foreign endianess. I understand that this patch is for chips which cannot reorder bytes by themselves.
Quoted 8 lines
Quoted 3 lines
Does anybody know of such a chip that's actually available in the wild? Or are we writing drivers for speculative possible chips?
I had troubles with the Silicon Motion SM501/SM502 endianess on PowerPC PCI vs. LocalBus. The chip also has a register to swap endianess, but that seems to only affect some LocalBus modes.
The current fb and X drivers are working, but when it comes to font aliasing and hw-acceleration, the problems start to rise again...Quoted 4 lines
Most "sane" gfx chips nowadays provide configurable surfaces that allow to perform the swap when writing/reading from regions of the framebuffer, with the ability to set a different swapper setting (based on bit depth) per region.
Most! But not the SM50x. I still hope I would be wrong here. :-(
Quoted 2 lines
Then there is also the risk that your PCI<->Localbus has been wired improperly :-)
That's not an issue in my case. The SM50x can be connected to either an PCI or some Local/CPU-whateverbus IF.
I.e. on the MPC85xx PowerPC, PCI and LocalBus are separate bussses. If the sm501 is attached to the MPC85xx' PCI like any other video card, the PCI config-space is can be accessed as usual, whereas the framebuffer memory area is byte-swapped compared to other common video cards.
Quoted 5 lines
So, to get back on topic:
I would welcome endianess swapping in SW. Some architectures (PowerPC) should also be able to do swapped-endian mmapping. I just haven't had time for a closer look but it looks also interesting way to do it that way.
Bizarrely, the original author of the patch (Anton) has fallen off the cc. Could whoever did that please thwap himself?
Anyway, my head is now officially spinning. Did anyone actually have a reason why we shouldn't proceed with Anton's patch?
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 31 lines · Andrew Morton
Quoted 30 lines · On Tue, 19 Feb 2008 12:27:54 +0100 Clemens Koller <[email protected]>…
Quoted 14 lines · Benjamin Herrenschmidt
Quoted 5 lines · Clemens Koller
Quoted 4 lines · [email protected] schrieb:
Quoted 3 lines · Krzysztof Helt
I know two fb drivers which use endianess information (pm2fb and s3c2410fb).
Both resolve endianess at driver level. Actually, both handle it by setting special
bits so the graphics chip itself reorder bytes to transform foreign endianess. I understand that this patch is for chips which cannot reorder bytes by themselves.Quoted 8 lines
Quoted 3 lines
Does anybody know of such a chip that's actually available in the wild? Or are we writing drivers for speculative possible chips?
I had troubles with the Silicon Motion SM501/SM502 endianess on PowerPC PCI vs. LocalBus. The chip also has a register to swap endianess, but that seems to only affect some LocalBus modes.
The current fb and X drivers are working, but when it comes to font aliasing and hw-acceleration, the problems start to rise again...Quoted 4 lines
Most "sane" gfx chips nowadays provide configurable surfaces that allow to perform the swap when writing/reading from regions of the framebuffer, with the ability to set a different swapper setting (based on bit depth) per region.
Most! But not the SM50x. I still hope I would be wrong here. :-(
Quoted 2 lines
Then there is also the risk that your PCI<->Localbus has been wired improperly :-)
That's not an issue in my case. The SM50x can be connected to either an PCI or some Local/CPU-whateverbus IF.
I.e. on the MPC85xx PowerPC, PCI and LocalBus are separate bussses. If the sm501 is attached to the MPC85xx' PCI like any other video card, the PCI config-space is can be accessed as usual, whereas the framebuffer memory area is byte-swapped compared to other common video cards.
Quoted 7 lines
Quoted 5 lines
So, to get back on topic:
I would welcome endianess swapping in SW. Some architectures (PowerPC) should also be able to do swapped-endian mmapping. I just haven't had time for a closer look but it looks also interesting way to do it that way.Bizarrely, the original author of the patch (Anton) has fallen off the cc. Could whoever did that please thwap himself?
Propably my bad, being subscribed to several CCed lists...
Quoted 2 lines
Anyway, my head is now officially spinning. Did anyone actually have a reason why we shouldn't proceed with Anton's patch?
Since it seem that there are some odd chips out in the wild, I guess Valdis (also readded to CC:) has no more objections to give it a try. :-)
Regards,
Clemens
Quoted 11 lines · Andrew Morton
Quoted 6 lines · On Tue, 19 Feb 2008 12:27:54 +0100 Clemens Koller <[email protected]…
That's not an issue in my case. The SM50x can be connected to either an PCI or some Local/CPU-whateverbus IF.
I.e. on the MPC85xx PowerPC, PCI and LocalBus are separate bussses. If the sm501 is attached to the MPC85xx' PCI like any other video card, the PCI config-space is can be accessed as usual, whereas the framebuffer memory area is byte-swapped compared to other common video cards.Anyway, my head is now officially spinning. Did anyone actually have a reason why we shouldn't proceed with Anton's patch?
Clemens answered my question regarding the real-life existence of hardware that would benefit. I'd say if Anton's patch works on Clemens' hardware and otherwise passes review, we should proceed...
Quoted 10 lines · On Tue, 2008-02-19 at 19:47 -0500, [email protected] wrote:
Quoted 8 lines · Andrew Morton
Quoted 6 lines · On Tue, 19 Feb 2008 12:27:54 +0100 Clemens Koller <[email protected]…
That's not an issue in my case. The SM50x can be connected to either an PCI or some Local/CPU-whateverbus IF.
I.e. on the MPC85xx PowerPC, PCI and LocalBus are separate bussses. If the sm501 is attached to the MPC85xx' PCI like any other video card, the PCI config-space is can be accessed as usual, whereas the framebuffer memory area is byte-swapped compared to other common video cards.
Quoted 6 lines
Quoted 2 lines
Anyway, my head is now officially spinning. Did anyone actually have a reason why we shouldn't proceed with Anton's patch?
Clemens answered my question regarding the real-life existence of hardware that would benefit. I'd say if Anton's patch works on Clemens' hardware and otherwise passes review, we should proceed...
No objection here neither.
Ben.
Quoted 5 lines · Andrew Morton
Bizarrely, the original author of the patch (Anton) has fallen off the cc. Could whoever did that please thwap himself?
Anyway, my head is now officially spinning. Did anyone actually have a reason why we shouldn't proceed with Anton's patch?
I was wondering if it would be sufficient to provide alternative versions of fb_readl, fb_writel etc. that do byte-swapping. That would mean that all framebuffers would have to have the same endianness, but that would suffice for embedded systems such as Anton's and would end up a lot simpler IMHO.
Paul.
Quoted 10 lines · Paul Mackerras
Quoted 5 lines · Andrew Morton
Bizarrely, the original author of the patch (Anton) has fallen off the cc. Could whoever did that please thwap himself?
Anyway, my head is now officially spinning. Did anyone actually have a reason why we shouldn't proceed with Anton's patch?
I was wondering if it would be sufficient to provide alternative versions of
fb_readl,fb_writeletc. that do byte-swapping.
This is of course viable alternative. And I was considering this, but later I abandoned the idea: that way we'll end up doing math in the native endianness and then converting it to the foreign. This feels ugly in contrast when we can do the right math in the first place, per framebuffer.
Quoted 3 lines
That
would mean that all framebuffers would have to have the same endianness,
Yup, another downside of changing the code to fix some narrow problem. Plus, this means things will break if/when we'll attach PCI video card into the MPC8360E-RDK.
Thanks,
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
Quoted 4 lines · Paul Mackerras
Quoted 2 lines · Andrew Morton
Bizarrely, the original author of the patch (Anton) has fallen off the cc. Could whoever did that please thwap himself?
Quoted 8 lines
Quoted 2 lines
Anyway, my head is now officially spinning. Did anyone actually have a reason why we shouldn't proceed with Anton's patch?
I was wondering if it would be sufficient to provide alternative versions of
fb_readl,fb_writeletc. that do byte-swapping. That would mean that all framebuffers would have to have the same endianness, but that would suffice for embedded systems such as Anton's and would end up a lot simpler IMHO.
Yes. At least the affected PowerPC platforms can do byte-swapping on the fly, so this should be sufficient and without performance penalty, AFAICS.
Regards,
Clemens
Quoted 9 lines · Anton Vorontsov
Quoted 8 lines · Paul Mackerras
Quoted 5 lines · Andrew Morton
Bizarrely, the original author of the patch (Anton) has fallen off the cc. Could whoever did that please thwap himself?
Anyway, my head is now officially spinning. Did anyone actually have a reason why we shouldn't proceed with Anton's patch?
Quoted 8 lines
Quoted 2 lines
I was wondering if it would be sufficient to provide alternative versions of
fb_readl,fb_writeletc. that do byte-swapping.This is of course viable alternative. And I was considering this, but later I abandoned the idea: that way we'll end up doing math in the native endianness and then converting it to the foreign. This feels ugly in contrast when we can do the right math in the first place, per framebuffer.
Also, the type of swap to do in fb_readl/writel would have to depend on the bit depth which is kind of ugly.
Quoted 7 lines
Quoted 3 lines
That
would mean that all framebuffers would have to have the same endianness,Yup, another downside of changing the code to fix some narrow problem. Plus, this means things will break if/when we'll attach PCI video card into the MPC8360E-RDK.
Right.
Ben.
Quoted 8 lines · Anton Vorontsov
Quoted 2 lines
I was wondering if it would be sufficient to provide alternative versions of
fb_readl,fb_writeletc. that do byte-swapping.This is of course viable alternative. And I was considering this, but later I abandoned the idea: that way we'll end up doing math in the native endianness and then converting it to the foreign. This feels ugly in contrast when we can do the right math in the first place, per framebuffer.
OK. I guess I'm convinced then. However, your patch description needs to be a lot better. It should describe things like why you want to make the change and why the change you are proposing is a good idea and is better than other alternatives. If you'd done that originally we might not have needed to have all this discussion. :)
Paul.