All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] offb: Fix little-endian support
@ 2014-05-14 13:21 ` Takashi Iwai
  0 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-05-14 13:21 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Jean-Christophe Plagniol-Villard, Cedric Le Goater, linux-fbdev,
	linux-kernel

Although the color palette was corrected for little endian by the
commit  [e1edf18b: offb: Add palette hack for little endian], the
graphics mode is still shown in psychedelic colors.  For fixing this
properly, we rather need to correct the RGB offsets depending on
endianess.

Since the RGB base offsets are corrected, we don't need the hack for
pallette color entries.  This patch reverts that, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/video/fbdev/offb.c | 51 +++++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 19 deletions(-)

diff --git a/drivers/video/fbdev/offb.c b/drivers/video/fbdev/offb.c
index 7d44d669d5b6..0224a62aa49d 100644
--- a/drivers/video/fbdev/offb.c
+++ b/drivers/video/fbdev/offb.c
@@ -93,13 +93,6 @@ extern boot_infos_t *boot_infos;
 
 #define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
 
-static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
-{
-	u32 bpp = info->var.bits_per_pixel;
-
-	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
-}
-
     /*
      *  Set a single color register. The values supplied are already
      *  rounded down to the hardware's capabilities (according to the
@@ -129,7 +122,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
 			mask <<= info->var.transp.offset;
 			value |= mask;
 		}
-		pal[regno] = offb_cmap_byteswap(info, value);
+		pal[regno] = value;
 		return 0;
 	}
 
@@ -451,6 +444,8 @@ static void __init offb_init_fb(const char *name, const char *full_name,
 	else
 		fix->visual = FB_VISUAL_TRUECOLOR;
 
+	info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE | foreign_endian;
+
 	var->xoffset = var->yoffset = 0;
 	switch (depth) {
 	case 8:
@@ -466,35 +461,54 @@ static void __init offb_init_fb(const char *name, const char *full_name,
 		break;
 	case 15:		/* RGB 555 */
 		var->bits_per_pixel = 16;
-		var->red.offset = 10;
+		if (fb_be_math(info)) {
+			var->red.offset = 10;
+			var->green.offset = 5;
+			var->blue.offset = 0;
+		} else {
+			var->red.offset = 0;
+			var->green.offset = 5;
+			var->blue.offset = 10;
+		}
 		var->red.length = 5;
-		var->green.offset = 5;
 		var->green.length = 5;
-		var->blue.offset = 0;
 		var->blue.length = 5;
 		var->transp.offset = 0;
 		var->transp.length = 0;
 		break;
 	case 16:		/* RGB 565 */
 		var->bits_per_pixel = 16;
-		var->red.offset = 11;
+		if (fb_be_math(info)) {
+			var->red.offset = 11;
+			var->green.offset = 5;
+			var->blue.offset = 0;
+		} else {
+			var->red.offset = 0;
+			var->green.offset = 5;
+			var->blue.offset = 11;
+		}
 		var->red.length = 5;
-		var->green.offset = 5;
 		var->green.length = 6;
-		var->blue.offset = 0;
 		var->blue.length = 5;
 		var->transp.offset = 0;
 		var->transp.length = 0;
 		break;
 	case 32:		/* RGB 888 */
 		var->bits_per_pixel = 32;
-		var->red.offset = 16;
+		if (fb_be_math(info)) {
+			var->red.offset = 16;
+			var->green.offset = 8;
+			var->blue.offset = 0;
+			var->transp.offset = 24;
+		} else {
+			var->red.offset = 8;
+			var->green.offset = 16;
+			var->blue.offset = 24;
+			var->transp.offset = 0;
+		}
 		var->red.length = 8;
-		var->green.offset = 8;
 		var->green.length = 8;
-		var->blue.offset = 0;
 		var->blue.length = 8;
-		var->transp.offset = 24;
 		var->transp.length = 8;
 		break;
 	}
@@ -521,7 +535,6 @@ static void __init offb_init_fb(const char *name, const char *full_name,
 	info->fbops = &offb_ops;
 	info->screen_base = ioremap(address, fix->smem_len);
 	info->pseudo_palette = (void *) (info + 1);
-	info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE | foreign_endian;
 
 	fb_alloc_cmap(&info->cmap, 256, 0);
 
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH] offb: Fix little-endian support
@ 2014-05-14 13:21 ` Takashi Iwai
  0 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-05-14 13:21 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Jean-Christophe Plagniol-Villard, Cedric Le Goater, linux-fbdev,
	linux-kernel

Although the color palette was corrected for little endian by the
commit  [e1edf18b: offb: Add palette hack for little endian], the
graphics mode is still shown in psychedelic colors.  For fixing this
properly, we rather need to correct the RGB offsets depending on
endianess.

Since the RGB base offsets are corrected, we don't need the hack for
pallette color entries.  This patch reverts that, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/video/fbdev/offb.c | 51 +++++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 19 deletions(-)

diff --git a/drivers/video/fbdev/offb.c b/drivers/video/fbdev/offb.c
index 7d44d669d5b6..0224a62aa49d 100644
--- a/drivers/video/fbdev/offb.c
+++ b/drivers/video/fbdev/offb.c
@@ -93,13 +93,6 @@ extern boot_infos_t *boot_infos;
 
 #define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
 
-static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
-{
-	u32 bpp = info->var.bits_per_pixel;
-
-	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
-}
-
     /*
      *  Set a single color register. The values supplied are already
      *  rounded down to the hardware's capabilities (according to the
@@ -129,7 +122,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
 			mask <<= info->var.transp.offset;
 			value |= mask;
 		}
-		pal[regno] = offb_cmap_byteswap(info, value);
+		pal[regno] = value;
 		return 0;
 	}
 
@@ -451,6 +444,8 @@ static void __init offb_init_fb(const char *name, const char *full_name,
 	else
 		fix->visual = FB_VISUAL_TRUECOLOR;
 
+	info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE | foreign_endian;
+
 	var->xoffset = var->yoffset = 0;
 	switch (depth) {
 	case 8:
@@ -466,35 +461,54 @@ static void __init offb_init_fb(const char *name, const char *full_name,
 		break;
 	case 15:		/* RGB 555 */
 		var->bits_per_pixel = 16;
-		var->red.offset = 10;
+		if (fb_be_math(info)) {
+			var->red.offset = 10;
+			var->green.offset = 5;
+			var->blue.offset = 0;
+		} else {
+			var->red.offset = 0;
+			var->green.offset = 5;
+			var->blue.offset = 10;
+		}
 		var->red.length = 5;
-		var->green.offset = 5;
 		var->green.length = 5;
-		var->blue.offset = 0;
 		var->blue.length = 5;
 		var->transp.offset = 0;
 		var->transp.length = 0;
 		break;
 	case 16:		/* RGB 565 */
 		var->bits_per_pixel = 16;
-		var->red.offset = 11;
+		if (fb_be_math(info)) {
+			var->red.offset = 11;
+			var->green.offset = 5;
+			var->blue.offset = 0;
+		} else {
+			var->red.offset = 0;
+			var->green.offset = 5;
+			var->blue.offset = 11;
+		}
 		var->red.length = 5;
-		var->green.offset = 5;
 		var->green.length = 6;
-		var->blue.offset = 0;
 		var->blue.length = 5;
 		var->transp.offset = 0;
 		var->transp.length = 0;
 		break;
 	case 32:		/* RGB 888 */
 		var->bits_per_pixel = 32;
-		var->red.offset = 16;
+		if (fb_be_math(info)) {
+			var->red.offset = 16;
+			var->green.offset = 8;
+			var->blue.offset = 0;
+			var->transp.offset = 24;
+		} else {
+			var->red.offset = 8;
+			var->green.offset = 16;
+			var->blue.offset = 24;
+			var->transp.offset = 0;
+		}
 		var->red.length = 8;
-		var->green.offset = 8;
 		var->green.length = 8;
-		var->blue.offset = 0;
 		var->blue.length = 8;
-		var->transp.offset = 24;
 		var->transp.length = 8;
 		break;
 	}
@@ -521,7 +535,6 @@ static void __init offb_init_fb(const char *name, const char *full_name,
 	info->fbops = &offb_ops;
 	info->screen_base = ioremap(address, fix->smem_len);
 	info->pseudo_palette = (void *) (info + 1);
-	info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE | foreign_endian;
 
 	fb_alloc_cmap(&info->cmap, 256, 0);
 
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
  2014-05-14 13:21 ` Takashi Iwai
@ 2014-05-14 14:01   ` Cedric Le Goater
  -1 siblings, 0 replies; 22+ messages in thread
From: Cedric Le Goater @ 2014-05-14 14:01 UTC (permalink / raw)
  To: Takashi Iwai, Tomi Valkeinen
  Cc: Jean-Christophe Plagniol-Villard, linux-fbdev, linux-kernel

Hi Iwai-san,

On 05/14/2014 03:21 PM, Takashi Iwai wrote:
> Although the color palette was corrected for little endian by the
> commit  [e1edf18b: offb: Add palette hack for little endian], the
> graphics mode is still shown in psychedelic colors.  

Are you referring to the linux logo colors ? If so, could you please
try the patch below, it should be a fix.

> For fixing this
> properly, we rather need to correct the RGB offsets depending on
> endianess.
> 
> Since the RGB base offsets are corrected, we don't need the hack for
> pallette color entries.  This patch reverts that, too.

Are you testing using qemu -vga std -vnc :x ? If so, did you try changing 
the depth to 8,15,16,32 ?  I think the patch might be breaking big endian 
too.

Now, I am far from being an expert on frame buffers. It would be glad 
to have some insights on that topic. 

Thanks,

C. 


[PATCH] fb: fix logo palette entries for little endian

The offb_cmap_byteswap() routine helps byteswapping the color map
entries when required. This patch externalizes and renames the helper 
routine to adjust the pseudo palette of the logo when running on 
little endian.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
---
 drivers/video/fbmem.c |    6 ++++--
 drivers/video/offb.c  |   11 +----------
 include/linux/fb.h    |    8 ++++++++
 3 files changed, 13 insertions(+), 12 deletions(-)

Index: linux.git/drivers/video/fbmem.c
===================================================================
--- linux.git.orig/drivers/video/fbmem.c
+++ linux.git/drivers/video/fbmem.c
@@ -252,7 +252,8 @@ static void  fb_set_logo_truepalette(str
 	blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
 
 	for ( i = 0; i < logo->clutsize; i++) {
-		palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
+		palette[i+32] = fb_cmap_byteswap(info,
+				 safe_shift((clut[0] & redmask), redshift) |
 				 safe_shift((clut[1] & greenmask), greenshift) |
 				 safe_shift((clut[2] & bluemask), blueshift));
 		clut += 3;
@@ -271,7 +272,8 @@ static void fb_set_logo_directpalette(st
 	blueshift = info->var.blue.offset;
 
 	for (i = 32; i < 32 + logo->clutsize; i++)
-		palette[i] = i << redshift | i << greenshift | i << blueshift;
+		palette[i] = fb_cmap_byteswap(info, i << redshift |
+					i << greenshift | i << blueshift);
 }
 
 static void fb_set_logo(struct fb_info *info,
Index: linux.git/drivers/video/offb.c
===================================================================
--- linux.git.orig/drivers/video/offb.c
+++ linux.git/drivers/video/offb.c
@@ -91,15 +91,6 @@ extern boot_infos_t *boot_infos;
 #define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN        0x6cd4
 #define AVIVO_DC_LUTB_WHITE_OFFSET_RED          0x6cd8
 
-#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
-
-static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
-{
-	u32 bpp = info->var.bits_per_pixel;
-
-	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
-}
-
     /*
      *  Set a single color register. The values supplied are already
      *  rounded down to the hardware's capabilities (according to the
@@ -129,7 +120,7 @@ static int offb_setcolreg(u_int regno, u
 			mask <<= info->var.transp.offset;
 			value |= mask;
 		}
-		pal[regno] = offb_cmap_byteswap(info, value);
+		pal[regno] = fb_cmap_byteswap(info, value);
 		return 0;
 	}
 
Index: linux.git/include/linux/fb.h
===================================================================
--- linux.git.orig/include/linux/fb.h
+++ linux.git/include/linux/fb.h
@@ -582,6 +582,7 @@ static inline struct apertures_struct *a
 
 #endif
 
+#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
 #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))
@@ -681,6 +682,13 @@ static inline bool fb_be_math(struct fb_
 #endif /* CONFIG_FB_FOREIGN_ENDIAN */
 }
 
+static inline u32 fb_cmap_byteswap(struct fb_info *info, u32 value)
+{
+	u32 bpp = info->var.bits_per_pixel;
+
+	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
+}
+
 /* drivers/video/fbsysfs.c */
 extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
 extern void framebuffer_release(struct fb_info *info);


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
@ 2014-05-14 14:01   ` Cedric Le Goater
  0 siblings, 0 replies; 22+ messages in thread
From: Cedric Le Goater @ 2014-05-14 14:01 UTC (permalink / raw)
  To: Takashi Iwai, Tomi Valkeinen
  Cc: Jean-Christophe Plagniol-Villard, linux-fbdev, linux-kernel

Hi Iwai-san,

On 05/14/2014 03:21 PM, Takashi Iwai wrote:
> Although the color palette was corrected for little endian by the
> commit  [e1edf18b: offb: Add palette hack for little endian], the
> graphics mode is still shown in psychedelic colors.  

Are you referring to the linux logo colors ? If so, could you please
try the patch below, it should be a fix.

> For fixing this
> properly, we rather need to correct the RGB offsets depending on
> endianess.
> 
> Since the RGB base offsets are corrected, we don't need the hack for
> pallette color entries.  This patch reverts that, too.

Are you testing using qemu -vga std -vnc :x ? If so, did you try changing 
the depth to 8,15,16,32 ?  I think the patch might be breaking big endian 
too.

Now, I am far from being an expert on frame buffers. It would be glad 
to have some insights on that topic. 

Thanks,

C. 


[PATCH] fb: fix logo palette entries for little endian

The offb_cmap_byteswap() routine helps byteswapping the color map
entries when required. This patch externalizes and renames the helper 
routine to adjust the pseudo palette of the logo when running on 
little endian.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
---
 drivers/video/fbmem.c |    6 ++++--
 drivers/video/offb.c  |   11 +----------
 include/linux/fb.h    |    8 ++++++++
 3 files changed, 13 insertions(+), 12 deletions(-)

Index: linux.git/drivers/video/fbmem.c
=================================--- linux.git.orig/drivers/video/fbmem.c
+++ linux.git/drivers/video/fbmem.c
@@ -252,7 +252,8 @@ static void  fb_set_logo_truepalette(str
 	blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
 
 	for ( i = 0; i < logo->clutsize; i++) {
-		palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
+		palette[i+32] = fb_cmap_byteswap(info,
+				 safe_shift((clut[0] & redmask), redshift) |
 				 safe_shift((clut[1] & greenmask), greenshift) |
 				 safe_shift((clut[2] & bluemask), blueshift));
 		clut += 3;
@@ -271,7 +272,8 @@ static void fb_set_logo_directpalette(st
 	blueshift = info->var.blue.offset;
 
 	for (i = 32; i < 32 + logo->clutsize; i++)
-		palette[i] = i << redshift | i << greenshift | i << blueshift;
+		palette[i] = fb_cmap_byteswap(info, i << redshift |
+					i << greenshift | i << blueshift);
 }
 
 static void fb_set_logo(struct fb_info *info,
Index: linux.git/drivers/video/offb.c
=================================--- linux.git.orig/drivers/video/offb.c
+++ linux.git/drivers/video/offb.c
@@ -91,15 +91,6 @@ extern boot_infos_t *boot_infos;
 #define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN        0x6cd4
 #define AVIVO_DC_LUTB_WHITE_OFFSET_RED          0x6cd8
 
-#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
-
-static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
-{
-	u32 bpp = info->var.bits_per_pixel;
-
-	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
-}
-
     /*
      *  Set a single color register. The values supplied are already
      *  rounded down to the hardware's capabilities (according to the
@@ -129,7 +120,7 @@ static int offb_setcolreg(u_int regno, u
 			mask <<= info->var.transp.offset;
 			value |= mask;
 		}
-		pal[regno] = offb_cmap_byteswap(info, value);
+		pal[regno] = fb_cmap_byteswap(info, value);
 		return 0;
 	}
 
Index: linux.git/include/linux/fb.h
=================================--- linux.git.orig/include/linux/fb.h
+++ linux.git/include/linux/fb.h
@@ -582,6 +582,7 @@ static inline struct apertures_struct *a
 
 #endif
 
+#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
 #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))
@@ -681,6 +682,13 @@ static inline bool fb_be_math(struct fb_
 #endif /* CONFIG_FB_FOREIGN_ENDIAN */
 }
 
+static inline u32 fb_cmap_byteswap(struct fb_info *info, u32 value)
+{
+	u32 bpp = info->var.bits_per_pixel;
+
+	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
+}
+
 /* drivers/video/fbsysfs.c */
 extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
 extern void framebuffer_release(struct fb_info *info);


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
  2014-05-14 14:01   ` Cedric Le Goater
@ 2014-05-14 14:24     ` Takashi Iwai
  -1 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-05-14 14:24 UTC (permalink / raw)
  To: Cedric Le Goater
  Cc: Dinar Valeev, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	linux-fbdev, linux-kernel

At Wed, 14 May 2014 16:01:17 +0200,
Cedric Le Goater wrote:
> 
> Hi Iwai-san,
> 
> On 05/14/2014 03:21 PM, Takashi Iwai wrote:
> > Although the color palette was corrected for little endian by the
> > commit  [e1edf18b: offb: Add palette hack for little endian], the
> > graphics mode is still shown in psychedelic colors.  
> 
> Are you referring to the linux logo colors ? If so, could you please
> try the patch below, it should be a fix.

Not only penguin logo but the whole X graphics got strange colors,
too, according to the bug report.  I put the original reporter/tester
(Dinar Valeev) to Cc.
I'm merely a person who tries to fix this mess ;)

BTW, did you try to run X on fbdev?

> > For fixing this
> > properly, we rather need to correct the RGB offsets depending on
> > endianess.
> > 
> > Since the RGB base offsets are corrected, we don't need the hack for
> > pallette color entries.  This patch reverts that, too.
> 
> Are you testing using qemu -vga std -vnc :x ? If so, did you try changing 
> the depth to 8,15,16,32 ?

Yes, it was with qemu -vga std -vnc :x.
About different color depths, Dinar can test / clarify better, I
suppose.

>  I think the patch might be breaking big endian 
> too.

Big endian should work as is because my patch uses the original
offsets when fb_be_math() is true.  It corrects the RGB offsets if
!fb_be_math().

But, I'm also entirely not sure whether this is 100% correct, either.
Namely, if the RGB offsets were correct for some little endian
machines with offb, my patch would break it, of course.  But, then
your previous fix must have already broken it as well, so I took the
same fb_be_math() check.


thanks,

Takashi

> Now, I am far from being an expert on frame buffers. It would be glad 
> to have some insights on that topic. 
> 
> Thanks,
> 
> C. 
> 
> 
> [PATCH] fb: fix logo palette entries for little endian
> 
> The offb_cmap_byteswap() routine helps byteswapping the color map
> entries when required. This patch externalizes and renames the helper 
> routine to adjust the pseudo palette of the logo when running on 
> little endian.
> 
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> ---
>  drivers/video/fbmem.c |    6 ++++--
>  drivers/video/offb.c  |   11 +----------
>  include/linux/fb.h    |    8 ++++++++
>  3 files changed, 13 insertions(+), 12 deletions(-)
> 
> Index: linux.git/drivers/video/fbmem.c
> ===================================================================
> --- linux.git.orig/drivers/video/fbmem.c
> +++ linux.git/drivers/video/fbmem.c
> @@ -252,7 +252,8 @@ static void  fb_set_logo_truepalette(str
>  	blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
>  
>  	for ( i = 0; i < logo->clutsize; i++) {
> -		palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
> +		palette[i+32] = fb_cmap_byteswap(info,
> +				 safe_shift((clut[0] & redmask), redshift) |
>  				 safe_shift((clut[1] & greenmask), greenshift) |
>  				 safe_shift((clut[2] & bluemask), blueshift));
>  		clut += 3;
> @@ -271,7 +272,8 @@ static void fb_set_logo_directpalette(st
>  	blueshift = info->var.blue.offset;
>  
>  	for (i = 32; i < 32 + logo->clutsize; i++)
> -		palette[i] = i << redshift | i << greenshift | i << blueshift;
> +		palette[i] = fb_cmap_byteswap(info, i << redshift |
> +					i << greenshift | i << blueshift);
>  }
>  
>  static void fb_set_logo(struct fb_info *info,
> Index: linux.git/drivers/video/offb.c
> ===================================================================
> --- linux.git.orig/drivers/video/offb.c
> +++ linux.git/drivers/video/offb.c
> @@ -91,15 +91,6 @@ extern boot_infos_t *boot_infos;
>  #define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN        0x6cd4
>  #define AVIVO_DC_LUTB_WHITE_OFFSET_RED          0x6cd8
>  
> -#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
> -
> -static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
> -{
> -	u32 bpp = info->var.bits_per_pixel;
> -
> -	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
> -}
> -
>      /*
>       *  Set a single color register. The values supplied are already
>       *  rounded down to the hardware's capabilities (according to the
> @@ -129,7 +120,7 @@ static int offb_setcolreg(u_int regno, u
>  			mask <<= info->var.transp.offset;
>  			value |= mask;
>  		}
> -		pal[regno] = offb_cmap_byteswap(info, value);
> +		pal[regno] = fb_cmap_byteswap(info, value);
>  		return 0;
>  	}
>  
> Index: linux.git/include/linux/fb.h
> ===================================================================
> --- linux.git.orig/include/linux/fb.h
> +++ linux.git/include/linux/fb.h
> @@ -582,6 +582,7 @@ static inline struct apertures_struct *a
>  
>  #endif
>  
> +#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
>  #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))
> @@ -681,6 +682,13 @@ static inline bool fb_be_math(struct fb_
>  #endif /* CONFIG_FB_FOREIGN_ENDIAN */
>  }
>  
> +static inline u32 fb_cmap_byteswap(struct fb_info *info, u32 value)
> +{
> +	u32 bpp = info->var.bits_per_pixel;
> +
> +	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
> +}
> +
>  /* drivers/video/fbsysfs.c */
>  extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
>  extern void framebuffer_release(struct fb_info *info);
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
@ 2014-05-14 14:24     ` Takashi Iwai
  0 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-05-14 14:24 UTC (permalink / raw)
  To: Cedric Le Goater
  Cc: Dinar Valeev, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	linux-fbdev, linux-kernel

At Wed, 14 May 2014 16:01:17 +0200,
Cedric Le Goater wrote:
> 
> Hi Iwai-san,
> 
> On 05/14/2014 03:21 PM, Takashi Iwai wrote:
> > Although the color palette was corrected for little endian by the
> > commit  [e1edf18b: offb: Add palette hack for little endian], the
> > graphics mode is still shown in psychedelic colors.  
> 
> Are you referring to the linux logo colors ? If so, could you please
> try the patch below, it should be a fix.

Not only penguin logo but the whole X graphics got strange colors,
too, according to the bug report.  I put the original reporter/tester
(Dinar Valeev) to Cc.
I'm merely a person who tries to fix this mess ;)

BTW, did you try to run X on fbdev?

> > For fixing this
> > properly, we rather need to correct the RGB offsets depending on
> > endianess.
> > 
> > Since the RGB base offsets are corrected, we don't need the hack for
> > pallette color entries.  This patch reverts that, too.
> 
> Are you testing using qemu -vga std -vnc :x ? If so, did you try changing 
> the depth to 8,15,16,32 ?

Yes, it was with qemu -vga std -vnc :x.
About different color depths, Dinar can test / clarify better, I
suppose.

>  I think the patch might be breaking big endian 
> too.

Big endian should work as is because my patch uses the original
offsets when fb_be_math() is true.  It corrects the RGB offsets if
!fb_be_math().

But, I'm also entirely not sure whether this is 100% correct, either.
Namely, if the RGB offsets were correct for some little endian
machines with offb, my patch would break it, of course.  But, then
your previous fix must have already broken it as well, so I took the
same fb_be_math() check.


thanks,

Takashi

> Now, I am far from being an expert on frame buffers. It would be glad 
> to have some insights on that topic. 
> 
> Thanks,
> 
> C. 
> 
> 
> [PATCH] fb: fix logo palette entries for little endian
> 
> The offb_cmap_byteswap() routine helps byteswapping the color map
> entries when required. This patch externalizes and renames the helper 
> routine to adjust the pseudo palette of the logo when running on 
> little endian.
> 
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> ---
>  drivers/video/fbmem.c |    6 ++++--
>  drivers/video/offb.c  |   11 +----------
>  include/linux/fb.h    |    8 ++++++++
>  3 files changed, 13 insertions(+), 12 deletions(-)
> 
> Index: linux.git/drivers/video/fbmem.c
> =================================> --- linux.git.orig/drivers/video/fbmem.c
> +++ linux.git/drivers/video/fbmem.c
> @@ -252,7 +252,8 @@ static void  fb_set_logo_truepalette(str
>  	blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
>  
>  	for ( i = 0; i < logo->clutsize; i++) {
> -		palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
> +		palette[i+32] = fb_cmap_byteswap(info,
> +				 safe_shift((clut[0] & redmask), redshift) |
>  				 safe_shift((clut[1] & greenmask), greenshift) |
>  				 safe_shift((clut[2] & bluemask), blueshift));
>  		clut += 3;
> @@ -271,7 +272,8 @@ static void fb_set_logo_directpalette(st
>  	blueshift = info->var.blue.offset;
>  
>  	for (i = 32; i < 32 + logo->clutsize; i++)
> -		palette[i] = i << redshift | i << greenshift | i << blueshift;
> +		palette[i] = fb_cmap_byteswap(info, i << redshift |
> +					i << greenshift | i << blueshift);
>  }
>  
>  static void fb_set_logo(struct fb_info *info,
> Index: linux.git/drivers/video/offb.c
> =================================> --- linux.git.orig/drivers/video/offb.c
> +++ linux.git/drivers/video/offb.c
> @@ -91,15 +91,6 @@ extern boot_infos_t *boot_infos;
>  #define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN        0x6cd4
>  #define AVIVO_DC_LUTB_WHITE_OFFSET_RED          0x6cd8
>  
> -#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
> -
> -static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
> -{
> -	u32 bpp = info->var.bits_per_pixel;
> -
> -	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
> -}
> -
>      /*
>       *  Set a single color register. The values supplied are already
>       *  rounded down to the hardware's capabilities (according to the
> @@ -129,7 +120,7 @@ static int offb_setcolreg(u_int regno, u
>  			mask <<= info->var.transp.offset;
>  			value |= mask;
>  		}
> -		pal[regno] = offb_cmap_byteswap(info, value);
> +		pal[regno] = fb_cmap_byteswap(info, value);
>  		return 0;
>  	}
>  
> Index: linux.git/include/linux/fb.h
> =================================> --- linux.git.orig/include/linux/fb.h
> +++ linux.git/include/linux/fb.h
> @@ -582,6 +582,7 @@ static inline struct apertures_struct *a
>  
>  #endif
>  
> +#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
>  #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))
> @@ -681,6 +682,13 @@ static inline bool fb_be_math(struct fb_
>  #endif /* CONFIG_FB_FOREIGN_ENDIAN */
>  }
>  
> +static inline u32 fb_cmap_byteswap(struct fb_info *info, u32 value)
> +{
> +	u32 bpp = info->var.bits_per_pixel;
> +
> +	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
> +}
> +
>  /* drivers/video/fbsysfs.c */
>  extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
>  extern void framebuffer_release(struct fb_info *info);
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
  2014-05-14 14:01   ` Cedric Le Goater
@ 2014-05-14 16:56     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 22+ messages in thread
From: Geert Uytterhoeven @ 2014-05-14 16:56 UTC (permalink / raw)
  To: Cedric Le Goater
  Cc: Takashi Iwai, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	Linux Fbdev development list, linux-kernel

On Wed, May 14, 2014 at 4:01 PM, Cedric Le Goater <clg@fr.ibm.com> wrote:
> --- linux.git.orig/drivers/video/fbmem.c
> +++ linux.git/drivers/video/fbmem.c
> @@ -252,7 +252,8 @@ static void  fb_set_logo_truepalette(str
>         blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
>
>         for ( i = 0; i < logo->clutsize; i++) {
> -               palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
> +               palette[i+32] = fb_cmap_byteswap(info,
> +                                safe_shift((clut[0] & redmask), redshift) |
>                                  safe_shift((clut[1] & greenmask), greenshift) |
>                                  safe_shift((clut[2] & bluemask), blueshift));
>                 clut += 3;
> @@ -271,7 +272,8 @@ static void fb_set_logo_directpalette(st
>         blueshift = info->var.blue.offset;
>
>         for (i = 32; i < 32 + logo->clutsize; i++)
> -               palette[i] = i << redshift | i << greenshift | i << blueshift;
> +               palette[i] = fb_cmap_byteswap(info, i << redshift |
> +                                       i << greenshift | i << blueshift);

I find it very strange you have to touch the generic code in such a way...

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
@ 2014-05-14 16:56     ` Geert Uytterhoeven
  0 siblings, 0 replies; 22+ messages in thread
From: Geert Uytterhoeven @ 2014-05-14 16:56 UTC (permalink / raw)
  To: Cedric Le Goater
  Cc: Takashi Iwai, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	Linux Fbdev development list, linux-kernel

On Wed, May 14, 2014 at 4:01 PM, Cedric Le Goater <clg@fr.ibm.com> wrote:
> --- linux.git.orig/drivers/video/fbmem.c
> +++ linux.git/drivers/video/fbmem.c
> @@ -252,7 +252,8 @@ static void  fb_set_logo_truepalette(str
>         blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
>
>         for ( i = 0; i < logo->clutsize; i++) {
> -               palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
> +               palette[i+32] = fb_cmap_byteswap(info,
> +                                safe_shift((clut[0] & redmask), redshift) |
>                                  safe_shift((clut[1] & greenmask), greenshift) |
>                                  safe_shift((clut[2] & bluemask), blueshift));
>                 clut += 3;
> @@ -271,7 +272,8 @@ static void fb_set_logo_directpalette(st
>         blueshift = info->var.blue.offset;
>
>         for (i = 32; i < 32 + logo->clutsize; i++)
> -               palette[i] = i << redshift | i << greenshift | i << blueshift;
> +               palette[i] = fb_cmap_byteswap(info, i << redshift |
> +                                       i << greenshift | i << blueshift);

I find it very strange you have to touch the generic code in such a way...

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
  2014-05-14 14:24     ` Takashi Iwai
@ 2014-05-14 17:04       ` Cedric Le Goater
  -1 siblings, 0 replies; 22+ messages in thread
From: Cedric Le Goater @ 2014-05-14 17:04 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Dinar Valeev, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	linux-fbdev, linux-kernel

On 05/14/2014 04:24 PM, Takashi Iwai wrote:
> At Wed, 14 May 2014 16:01:17 +0200,
> Cedric Le Goater wrote:
>>
>> Hi Iwai-san,
>>
>> On 05/14/2014 03:21 PM, Takashi Iwai wrote:
>>> Although the color palette was corrected for little endian by the
>>> commit  [e1edf18b: offb: Add palette hack for little endian], the
>>> graphics mode is still shown in psychedelic colors.  
>>
>> Are you referring to the linux logo colors ? If so, could you please
>> try the patch below, it should be a fix.
> 
> Not only penguin logo but the whole X graphics got strange colors,
> too, according to the bug report.  I put the original reporter/tester
> (Dinar Valeev) to Cc.
> I'm merely a person who tries to fix this mess ;)
> 
> BTW, did you try to run X on fbdev?

Not at the time, I was working on the console only, BE and LE. 
I just tried fbdev and indeed this is a psychedelic mess :)

Your fix has also issues on BE and console and the patch of mine 
below is of no use for fbdev. Damn, this is a nightmare.

C. 

>>> For fixing this
>>> properly, we rather need to correct the RGB offsets depending on
>>> endianess.
>>>
>>> Since the RGB base offsets are corrected, we don't need the hack for
>>> pallette color entries.  This patch reverts that, too.
>>
>> Are you testing using qemu -vga std -vnc :x ? If so, did you try changing 
>> the depth to 8,15,16,32 ?
> 
> Yes, it was with qemu -vga std -vnc :x.
> About different color depths, Dinar can test / clarify better, I
> suppose.
> 
>>  I think the patch might be breaking big endian 
>> too.
> 
> Big endian should work as is because my patch uses the original
> offsets when fb_be_math() is true.  It corrects the RGB offsets if
> !fb_be_math().
>
> But, I'm also entirely not sure whether this is 100% correct, either.
> Namely, if the RGB offsets were correct for some little endian
> machines with offb, my patch would break it, of course.  But, then
> your previous fix must have already broken it as well, so I took the
> same fb_be_math() check.
> 
> 
> thanks,
> 
> Takashi
> 
>> Now, I am far from being an expert on frame buffers. It would be glad 
>> to have some insights on that topic. 
>>
>> Thanks,
>>
>> C. 
>>
>>
>> [PATCH] fb: fix logo palette entries for little endian
>>
>> The offb_cmap_byteswap() routine helps byteswapping the color map
>> entries when required. This patch externalizes and renames the helper 
>> routine to adjust the pseudo palette of the logo when running on 
>> little endian.
>>
>> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
>> ---
>>  drivers/video/fbmem.c |    6 ++++--
>>  drivers/video/offb.c  |   11 +----------
>>  include/linux/fb.h    |    8 ++++++++
>>  3 files changed, 13 insertions(+), 12 deletions(-)
>>
>> Index: linux.git/drivers/video/fbmem.c
>> ===================================================================
>> --- linux.git.orig/drivers/video/fbmem.c
>> +++ linux.git/drivers/video/fbmem.c
>> @@ -252,7 +252,8 @@ static void  fb_set_logo_truepalette(str
>>  	blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
>>  
>>  	for ( i = 0; i < logo->clutsize; i++) {
>> -		palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
>> +		palette[i+32] = fb_cmap_byteswap(info,
>> +				 safe_shift((clut[0] & redmask), redshift) |
>>  				 safe_shift((clut[1] & greenmask), greenshift) |
>>  				 safe_shift((clut[2] & bluemask), blueshift));
>>  		clut += 3;
>> @@ -271,7 +272,8 @@ static void fb_set_logo_directpalette(st
>>  	blueshift = info->var.blue.offset;
>>  
>>  	for (i = 32; i < 32 + logo->clutsize; i++)
>> -		palette[i] = i << redshift | i << greenshift | i << blueshift;
>> +		palette[i] = fb_cmap_byteswap(info, i << redshift |
>> +					i << greenshift | i << blueshift);
>>  }
>>  
>>  static void fb_set_logo(struct fb_info *info,
>> Index: linux.git/drivers/video/offb.c
>> ===================================================================
>> --- linux.git.orig/drivers/video/offb.c
>> +++ linux.git/drivers/video/offb.c
>> @@ -91,15 +91,6 @@ extern boot_infos_t *boot_infos;
>>  #define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN        0x6cd4
>>  #define AVIVO_DC_LUTB_WHITE_OFFSET_RED          0x6cd8
>>  
>> -#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
>> -
>> -static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
>> -{
>> -	u32 bpp = info->var.bits_per_pixel;
>> -
>> -	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
>> -}
>> -
>>      /*
>>       *  Set a single color register. The values supplied are already
>>       *  rounded down to the hardware's capabilities (according to the
>> @@ -129,7 +120,7 @@ static int offb_setcolreg(u_int regno, u
>>  			mask <<= info->var.transp.offset;
>>  			value |= mask;
>>  		}
>> -		pal[regno] = offb_cmap_byteswap(info, value);
>> +		pal[regno] = fb_cmap_byteswap(info, value);
>>  		return 0;
>>  	}
>>  
>> Index: linux.git/include/linux/fb.h
>> ===================================================================
>> --- linux.git.orig/include/linux/fb.h
>> +++ linux.git/include/linux/fb.h
>> @@ -582,6 +582,7 @@ static inline struct apertures_struct *a
>>  
>>  #endif
>>  
>> +#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
>>  #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))
>> @@ -681,6 +682,13 @@ static inline bool fb_be_math(struct fb_
>>  #endif /* CONFIG_FB_FOREIGN_ENDIAN */
>>  }
>>  
>> +static inline u32 fb_cmap_byteswap(struct fb_info *info, u32 value)
>> +{
>> +	u32 bpp = info->var.bits_per_pixel;
>> +
>> +	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
>> +}
>> +
>>  /* drivers/video/fbsysfs.c */
>>  extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
>>  extern void framebuffer_release(struct fb_info *info);
>>
> 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
@ 2014-05-14 17:04       ` Cedric Le Goater
  0 siblings, 0 replies; 22+ messages in thread
From: Cedric Le Goater @ 2014-05-14 17:04 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Dinar Valeev, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	linux-fbdev, linux-kernel

On 05/14/2014 04:24 PM, Takashi Iwai wrote:
> At Wed, 14 May 2014 16:01:17 +0200,
> Cedric Le Goater wrote:
>>
>> Hi Iwai-san,
>>
>> On 05/14/2014 03:21 PM, Takashi Iwai wrote:
>>> Although the color palette was corrected for little endian by the
>>> commit  [e1edf18b: offb: Add palette hack for little endian], the
>>> graphics mode is still shown in psychedelic colors.  
>>
>> Are you referring to the linux logo colors ? If so, could you please
>> try the patch below, it should be a fix.
> 
> Not only penguin logo but the whole X graphics got strange colors,
> too, according to the bug report.  I put the original reporter/tester
> (Dinar Valeev) to Cc.
> I'm merely a person who tries to fix this mess ;)
> 
> BTW, did you try to run X on fbdev?

Not at the time, I was working on the console only, BE and LE. 
I just tried fbdev and indeed this is a psychedelic mess :)

Your fix has also issues on BE and console and the patch of mine 
below is of no use for fbdev. Damn, this is a nightmare.

C. 

>>> For fixing this
>>> properly, we rather need to correct the RGB offsets depending on
>>> endianess.
>>>
>>> Since the RGB base offsets are corrected, we don't need the hack for
>>> pallette color entries.  This patch reverts that, too.
>>
>> Are you testing using qemu -vga std -vnc :x ? If so, did you try changing 
>> the depth to 8,15,16,32 ?
> 
> Yes, it was with qemu -vga std -vnc :x.
> About different color depths, Dinar can test / clarify better, I
> suppose.
> 
>>  I think the patch might be breaking big endian 
>> too.
> 
> Big endian should work as is because my patch uses the original
> offsets when fb_be_math() is true.  It corrects the RGB offsets if
> !fb_be_math().
>
> But, I'm also entirely not sure whether this is 100% correct, either.
> Namely, if the RGB offsets were correct for some little endian
> machines with offb, my patch would break it, of course.  But, then
> your previous fix must have already broken it as well, so I took the
> same fb_be_math() check.
> 
> 
> thanks,
> 
> Takashi
> 
>> Now, I am far from being an expert on frame buffers. It would be glad 
>> to have some insights on that topic. 
>>
>> Thanks,
>>
>> C. 
>>
>>
>> [PATCH] fb: fix logo palette entries for little endian
>>
>> The offb_cmap_byteswap() routine helps byteswapping the color map
>> entries when required. This patch externalizes and renames the helper 
>> routine to adjust the pseudo palette of the logo when running on 
>> little endian.
>>
>> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
>> ---
>>  drivers/video/fbmem.c |    6 ++++--
>>  drivers/video/offb.c  |   11 +----------
>>  include/linux/fb.h    |    8 ++++++++
>>  3 files changed, 13 insertions(+), 12 deletions(-)
>>
>> Index: linux.git/drivers/video/fbmem.c
>> =================================>> --- linux.git.orig/drivers/video/fbmem.c
>> +++ linux.git/drivers/video/fbmem.c
>> @@ -252,7 +252,8 @@ static void  fb_set_logo_truepalette(str
>>  	blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
>>  
>>  	for ( i = 0; i < logo->clutsize; i++) {
>> -		palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
>> +		palette[i+32] = fb_cmap_byteswap(info,
>> +				 safe_shift((clut[0] & redmask), redshift) |
>>  				 safe_shift((clut[1] & greenmask), greenshift) |
>>  				 safe_shift((clut[2] & bluemask), blueshift));
>>  		clut += 3;
>> @@ -271,7 +272,8 @@ static void fb_set_logo_directpalette(st
>>  	blueshift = info->var.blue.offset;
>>  
>>  	for (i = 32; i < 32 + logo->clutsize; i++)
>> -		palette[i] = i << redshift | i << greenshift | i << blueshift;
>> +		palette[i] = fb_cmap_byteswap(info, i << redshift |
>> +					i << greenshift | i << blueshift);
>>  }
>>  
>>  static void fb_set_logo(struct fb_info *info,
>> Index: linux.git/drivers/video/offb.c
>> =================================>> --- linux.git.orig/drivers/video/offb.c
>> +++ linux.git/drivers/video/offb.c
>> @@ -91,15 +91,6 @@ extern boot_infos_t *boot_infos;
>>  #define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN        0x6cd4
>>  #define AVIVO_DC_LUTB_WHITE_OFFSET_RED          0x6cd8
>>  
>> -#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
>> -
>> -static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
>> -{
>> -	u32 bpp = info->var.bits_per_pixel;
>> -
>> -	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
>> -}
>> -
>>      /*
>>       *  Set a single color register. The values supplied are already
>>       *  rounded down to the hardware's capabilities (according to the
>> @@ -129,7 +120,7 @@ static int offb_setcolreg(u_int regno, u
>>  			mask <<= info->var.transp.offset;
>>  			value |= mask;
>>  		}
>> -		pal[regno] = offb_cmap_byteswap(info, value);
>> +		pal[regno] = fb_cmap_byteswap(info, value);
>>  		return 0;
>>  	}
>>  
>> Index: linux.git/include/linux/fb.h
>> =================================>> --- linux.git.orig/include/linux/fb.h
>> +++ linux.git/include/linux/fb.h
>> @@ -582,6 +582,7 @@ static inline struct apertures_struct *a
>>  
>>  #endif
>>  
>> +#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
>>  #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))
>> @@ -681,6 +682,13 @@ static inline bool fb_be_math(struct fb_
>>  #endif /* CONFIG_FB_FOREIGN_ENDIAN */
>>  }
>>  
>> +static inline u32 fb_cmap_byteswap(struct fb_info *info, u32 value)
>> +{
>> +	u32 bpp = info->var.bits_per_pixel;
>> +
>> +	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
>> +}
>> +
>>  /* drivers/video/fbsysfs.c */
>>  extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
>>  extern void framebuffer_release(struct fb_info *info);
>>
> 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
  2014-05-14 17:04       ` Cedric Le Goater
@ 2014-05-14 17:57         ` Takashi Iwai
  -1 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-05-14 17:57 UTC (permalink / raw)
  To: Cedric Le Goater
  Cc: Dinar Valeev, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	linux-fbdev, linux-kernel

At Wed, 14 May 2014 19:04:00 +0200,
Cedric Le Goater wrote:
> 
> On 05/14/2014 04:24 PM, Takashi Iwai wrote:
> > At Wed, 14 May 2014 16:01:17 +0200,
> > Cedric Le Goater wrote:
> >>
> >> Hi Iwai-san,
> >>
> >> On 05/14/2014 03:21 PM, Takashi Iwai wrote:
> >>> Although the color palette was corrected for little endian by the
> >>> commit  [e1edf18b: offb: Add palette hack for little endian], the
> >>> graphics mode is still shown in psychedelic colors.  
> >>
> >> Are you referring to the linux logo colors ? If so, could you please
> >> try the patch below, it should be a fix.
> > 
> > Not only penguin logo but the whole X graphics got strange colors,
> > too, according to the bug report.  I put the original reporter/tester
> > (Dinar Valeev) to Cc.
> > I'm merely a person who tries to fix this mess ;)
> > 
> > BTW, did you try to run X on fbdev?
> 
> Not at the time, I was working on the console only, BE and LE. 
> I just tried fbdev and indeed this is a psychedelic mess :)
> 
> Your fix has also issues on BE and console and the patch of mine 
> below is of no use for fbdev. Damn, this is a nightmare.

Hm, so it actually regressed on BE?

It's strange because fb_math_be() should be true and the patch won't
change the values in that case...


Takashi

> 
> C. 
> 
> >>> For fixing this
> >>> properly, we rather need to correct the RGB offsets depending on
> >>> endianess.
> >>>
> >>> Since the RGB base offsets are corrected, we don't need the hack for
> >>> pallette color entries.  This patch reverts that, too.
> >>
> >> Are you testing using qemu -vga std -vnc :x ? If so, did you try changing 
> >> the depth to 8,15,16,32 ?
> > 
> > Yes, it was with qemu -vga std -vnc :x.
> > About different color depths, Dinar can test / clarify better, I
> > suppose.
> > 
> >>  I think the patch might be breaking big endian 
> >> too.
> > 
> > Big endian should work as is because my patch uses the original
> > offsets when fb_be_math() is true.  It corrects the RGB offsets if
> > !fb_be_math().
> >
> > But, I'm also entirely not sure whether this is 100% correct, either.
> > Namely, if the RGB offsets were correct for some little endian
> > machines with offb, my patch would break it, of course.  But, then
> > your previous fix must have already broken it as well, so I took the
> > same fb_be_math() check.
> > 
> > 
> > thanks,
> > 
> > Takashi
> > 
> >> Now, I am far from being an expert on frame buffers. It would be glad 
> >> to have some insights on that topic. 
> >>
> >> Thanks,
> >>
> >> C. 
> >>
> >>
> >> [PATCH] fb: fix logo palette entries for little endian
> >>
> >> The offb_cmap_byteswap() routine helps byteswapping the color map
> >> entries when required. This patch externalizes and renames the helper 
> >> routine to adjust the pseudo palette of the logo when running on 
> >> little endian.
> >>
> >> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> >> ---
> >>  drivers/video/fbmem.c |    6 ++++--
> >>  drivers/video/offb.c  |   11 +----------
> >>  include/linux/fb.h    |    8 ++++++++
> >>  3 files changed, 13 insertions(+), 12 deletions(-)
> >>
> >> Index: linux.git/drivers/video/fbmem.c
> >> ===================================================================
> >> --- linux.git.orig/drivers/video/fbmem.c
> >> +++ linux.git/drivers/video/fbmem.c
> >> @@ -252,7 +252,8 @@ static void  fb_set_logo_truepalette(str
> >>  	blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
> >>  
> >>  	for ( i = 0; i < logo->clutsize; i++) {
> >> -		palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
> >> +		palette[i+32] = fb_cmap_byteswap(info,
> >> +				 safe_shift((clut[0] & redmask), redshift) |
> >>  				 safe_shift((clut[1] & greenmask), greenshift) |
> >>  				 safe_shift((clut[2] & bluemask), blueshift));
> >>  		clut += 3;
> >> @@ -271,7 +272,8 @@ static void fb_set_logo_directpalette(st
> >>  	blueshift = info->var.blue.offset;
> >>  
> >>  	for (i = 32; i < 32 + logo->clutsize; i++)
> >> -		palette[i] = i << redshift | i << greenshift | i << blueshift;
> >> +		palette[i] = fb_cmap_byteswap(info, i << redshift |
> >> +					i << greenshift | i << blueshift);
> >>  }
> >>  
> >>  static void fb_set_logo(struct fb_info *info,
> >> Index: linux.git/drivers/video/offb.c
> >> ===================================================================
> >> --- linux.git.orig/drivers/video/offb.c
> >> +++ linux.git/drivers/video/offb.c
> >> @@ -91,15 +91,6 @@ extern boot_infos_t *boot_infos;
> >>  #define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN        0x6cd4
> >>  #define AVIVO_DC_LUTB_WHITE_OFFSET_RED          0x6cd8
> >>  
> >> -#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
> >> -
> >> -static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
> >> -{
> >> -	u32 bpp = info->var.bits_per_pixel;
> >> -
> >> -	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
> >> -}
> >> -
> >>      /*
> >>       *  Set a single color register. The values supplied are already
> >>       *  rounded down to the hardware's capabilities (according to the
> >> @@ -129,7 +120,7 @@ static int offb_setcolreg(u_int regno, u
> >>  			mask <<= info->var.transp.offset;
> >>  			value |= mask;
> >>  		}
> >> -		pal[regno] = offb_cmap_byteswap(info, value);
> >> +		pal[regno] = fb_cmap_byteswap(info, value);
> >>  		return 0;
> >>  	}
> >>  
> >> Index: linux.git/include/linux/fb.h
> >> ===================================================================
> >> --- linux.git.orig/include/linux/fb.h
> >> +++ linux.git/include/linux/fb.h
> >> @@ -582,6 +582,7 @@ static inline struct apertures_struct *a
> >>  
> >>  #endif
> >>  
> >> +#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
> >>  #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))
> >> @@ -681,6 +682,13 @@ static inline bool fb_be_math(struct fb_
> >>  #endif /* CONFIG_FB_FOREIGN_ENDIAN */
> >>  }
> >>  
> >> +static inline u32 fb_cmap_byteswap(struct fb_info *info, u32 value)
> >> +{
> >> +	u32 bpp = info->var.bits_per_pixel;
> >> +
> >> +	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
> >> +}
> >> +
> >>  /* drivers/video/fbsysfs.c */
> >>  extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
> >>  extern void framebuffer_release(struct fb_info *info);
> >>
> > 
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
@ 2014-05-14 17:57         ` Takashi Iwai
  0 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-05-14 17:57 UTC (permalink / raw)
  To: Cedric Le Goater
  Cc: Dinar Valeev, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	linux-fbdev, linux-kernel

At Wed, 14 May 2014 19:04:00 +0200,
Cedric Le Goater wrote:
> 
> On 05/14/2014 04:24 PM, Takashi Iwai wrote:
> > At Wed, 14 May 2014 16:01:17 +0200,
> > Cedric Le Goater wrote:
> >>
> >> Hi Iwai-san,
> >>
> >> On 05/14/2014 03:21 PM, Takashi Iwai wrote:
> >>> Although the color palette was corrected for little endian by the
> >>> commit  [e1edf18b: offb: Add palette hack for little endian], the
> >>> graphics mode is still shown in psychedelic colors.  
> >>
> >> Are you referring to the linux logo colors ? If so, could you please
> >> try the patch below, it should be a fix.
> > 
> > Not only penguin logo but the whole X graphics got strange colors,
> > too, according to the bug report.  I put the original reporter/tester
> > (Dinar Valeev) to Cc.
> > I'm merely a person who tries to fix this mess ;)
> > 
> > BTW, did you try to run X on fbdev?
> 
> Not at the time, I was working on the console only, BE and LE. 
> I just tried fbdev and indeed this is a psychedelic mess :)
> 
> Your fix has also issues on BE and console and the patch of mine 
> below is of no use for fbdev. Damn, this is a nightmare.

Hm, so it actually regressed on BE?

It's strange because fb_math_be() should be true and the patch won't
change the values in that case...


Takashi

> 
> C. 
> 
> >>> For fixing this
> >>> properly, we rather need to correct the RGB offsets depending on
> >>> endianess.
> >>>
> >>> Since the RGB base offsets are corrected, we don't need the hack for
> >>> pallette color entries.  This patch reverts that, too.
> >>
> >> Are you testing using qemu -vga std -vnc :x ? If so, did you try changing 
> >> the depth to 8,15,16,32 ?
> > 
> > Yes, it was with qemu -vga std -vnc :x.
> > About different color depths, Dinar can test / clarify better, I
> > suppose.
> > 
> >>  I think the patch might be breaking big endian 
> >> too.
> > 
> > Big endian should work as is because my patch uses the original
> > offsets when fb_be_math() is true.  It corrects the RGB offsets if
> > !fb_be_math().
> >
> > But, I'm also entirely not sure whether this is 100% correct, either.
> > Namely, if the RGB offsets were correct for some little endian
> > machines with offb, my patch would break it, of course.  But, then
> > your previous fix must have already broken it as well, so I took the
> > same fb_be_math() check.
> > 
> > 
> > thanks,
> > 
> > Takashi
> > 
> >> Now, I am far from being an expert on frame buffers. It would be glad 
> >> to have some insights on that topic. 
> >>
> >> Thanks,
> >>
> >> C. 
> >>
> >>
> >> [PATCH] fb: fix logo palette entries for little endian
> >>
> >> The offb_cmap_byteswap() routine helps byteswapping the color map
> >> entries when required. This patch externalizes and renames the helper 
> >> routine to adjust the pseudo palette of the logo when running on 
> >> little endian.
> >>
> >> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> >> ---
> >>  drivers/video/fbmem.c |    6 ++++--
> >>  drivers/video/offb.c  |   11 +----------
> >>  include/linux/fb.h    |    8 ++++++++
> >>  3 files changed, 13 insertions(+), 12 deletions(-)
> >>
> >> Index: linux.git/drivers/video/fbmem.c
> >> =================================> >> --- linux.git.orig/drivers/video/fbmem.c
> >> +++ linux.git/drivers/video/fbmem.c
> >> @@ -252,7 +252,8 @@ static void  fb_set_logo_truepalette(str
> >>  	blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
> >>  
> >>  	for ( i = 0; i < logo->clutsize; i++) {
> >> -		palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
> >> +		palette[i+32] = fb_cmap_byteswap(info,
> >> +				 safe_shift((clut[0] & redmask), redshift) |
> >>  				 safe_shift((clut[1] & greenmask), greenshift) |
> >>  				 safe_shift((clut[2] & bluemask), blueshift));
> >>  		clut += 3;
> >> @@ -271,7 +272,8 @@ static void fb_set_logo_directpalette(st
> >>  	blueshift = info->var.blue.offset;
> >>  
> >>  	for (i = 32; i < 32 + logo->clutsize; i++)
> >> -		palette[i] = i << redshift | i << greenshift | i << blueshift;
> >> +		palette[i] = fb_cmap_byteswap(info, i << redshift |
> >> +					i << greenshift | i << blueshift);
> >>  }
> >>  
> >>  static void fb_set_logo(struct fb_info *info,
> >> Index: linux.git/drivers/video/offb.c
> >> =================================> >> --- linux.git.orig/drivers/video/offb.c
> >> +++ linux.git/drivers/video/offb.c
> >> @@ -91,15 +91,6 @@ extern boot_infos_t *boot_infos;
> >>  #define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN        0x6cd4
> >>  #define AVIVO_DC_LUTB_WHITE_OFFSET_RED          0x6cd8
> >>  
> >> -#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
> >> -
> >> -static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
> >> -{
> >> -	u32 bpp = info->var.bits_per_pixel;
> >> -
> >> -	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
> >> -}
> >> -
> >>      /*
> >>       *  Set a single color register. The values supplied are already
> >>       *  rounded down to the hardware's capabilities (according to the
> >> @@ -129,7 +120,7 @@ static int offb_setcolreg(u_int regno, u
> >>  			mask <<= info->var.transp.offset;
> >>  			value |= mask;
> >>  		}
> >> -		pal[regno] = offb_cmap_byteswap(info, value);
> >> +		pal[regno] = fb_cmap_byteswap(info, value);
> >>  		return 0;
> >>  	}
> >>  
> >> Index: linux.git/include/linux/fb.h
> >> =================================> >> --- linux.git.orig/include/linux/fb.h
> >> +++ linux.git/include/linux/fb.h
> >> @@ -582,6 +582,7 @@ static inline struct apertures_struct *a
> >>  
> >>  #endif
> >>  
> >> +#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
> >>  #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))
> >> @@ -681,6 +682,13 @@ static inline bool fb_be_math(struct fb_
> >>  #endif /* CONFIG_FB_FOREIGN_ENDIAN */
> >>  }
> >>  
> >> +static inline u32 fb_cmap_byteswap(struct fb_info *info, u32 value)
> >> +{
> >> +	u32 bpp = info->var.bits_per_pixel;
> >> +
> >> +	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
> >> +}
> >> +
> >>  /* drivers/video/fbsysfs.c */
> >>  extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
> >>  extern void framebuffer_release(struct fb_info *info);
> >>
> > 
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
  2014-05-14 17:57         ` Takashi Iwai
@ 2014-06-16  7:23           ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2014-06-16  7:23 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Cedric Le Goater, Dinar Valeev, Tomi Valkeinen,
	Jean-Christophe Plagniol-Villard, linux-fbdev, linux-kernel


On Wed, 2014-05-14 at 19:57 +0200, Takashi Iwai wrote:
> 
> Hm, so it actually regressed on BE?
> 
> It's strange because fb_math_be() should be true and the patch won't
> change the values in that case...

Shouldn't the patch be based on foreign endian being set rather than
just "be" anyway ?

IE. If the fb is LE and the host is LE we *also* don't want to change
the ordering, which will be the case when we fix qemu...

Cheers,
Ben.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
@ 2014-06-16  7:23           ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2014-06-16  7:23 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Cedric Le Goater, Dinar Valeev, Tomi Valkeinen,
	Jean-Christophe Plagniol-Villard, linux-fbdev, linux-kernel


On Wed, 2014-05-14 at 19:57 +0200, Takashi Iwai wrote:
> 
> Hm, so it actually regressed on BE?
> 
> It's strange because fb_math_be() should be true and the patch won't
> change the values in that case...

Shouldn't the patch be based on foreign endian being set rather than
just "be" anyway ?

IE. If the fb is LE and the host is LE we *also* don't want to change
the ordering, which will be the case when we fix qemu...

Cheers,
Ben.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
  2014-05-14 17:57         ` Takashi Iwai
@ 2014-06-16  7:32           ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2014-06-16  7:32 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Cedric Le Goater, Dinar Valeev, Tomi Valkeinen,
	Jean-Christophe Plagniol-Villard, linux-fbdev, linux-kernel


On Wed, 2014-05-14 at 19:57 +0200, Takashi Iwai wrote:
> 
> Hm, so it actually regressed on BE?
> 
> It's strange because fb_math_be() should be true and the patch won't
> change the values in that case...

Shouldn't the patch be based on foreign endian being set rather than
just "be" anyway ?

IE. If the fb is LE and the host is LE we *also* don't want to change
the ordering, which will be the case when we fix qemu...

Cheers,
Ben.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
@ 2014-06-16  7:32           ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2014-06-16  7:32 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Cedric Le Goater, Dinar Valeev, Tomi Valkeinen,
	Jean-Christophe Plagniol-Villard, linux-fbdev, linux-kernel


On Wed, 2014-05-14 at 19:57 +0200, Takashi Iwai wrote:
> 
> Hm, so it actually regressed on BE?
> 
> It's strange because fb_math_be() should be true and the patch won't
> change the values in that case...

Shouldn't the patch be based on foreign endian being set rather than
just "be" anyway ?

IE. If the fb is LE and the host is LE we *also* don't want to change
the ordering, which will be the case when we fix qemu...

Cheers,
Ben.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
  2014-05-14 13:21 ` Takashi Iwai
@ 2014-06-16  7:35   ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2014-06-16  7:35 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	Cedric Le Goater, linux-fbdev, linux-kernel

On Wed, 2014-05-14 at 15:21 +0200, Takashi Iwai wrote:
>         case 16:                /* RGB 565 */
>                 var->bits_per_pixel = 16;
> -               var->red.offset = 11;
> +               if (fb_be_math(info)) {
> +                       var->red.offset = 11;
> +                       var->green.offset = 5;
> +                       var->blue.offset = 0;
> +               } else {
> +                       var->red.offset = 0;
> +                       var->green.offset = 5;
> +                       var->blue.offset = 11;
> +               }
>                 var->red.length = 5;
> -               var->green.offset = 5;
>                 var->green.length = 6;
> -               var->blue.offset = 0;
>                 var->blue.length = 5;
>                 var->transp.offset = 0;
>                 var->transp.length = 0;
>                 break;

I somewhat doubt that this (and 5:5:5) actually work, do they ? the
green gets split into two separate fields, which we can't express
properly here...

Cheers,
Ben.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
@ 2014-06-16  7:35   ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2014-06-16  7:35 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	Cedric Le Goater, linux-fbdev, linux-kernel

On Wed, 2014-05-14 at 15:21 +0200, Takashi Iwai wrote:
>         case 16:                /* RGB 565 */
>                 var->bits_per_pixel = 16;
> -               var->red.offset = 11;
> +               if (fb_be_math(info)) {
> +                       var->red.offset = 11;
> +                       var->green.offset = 5;
> +                       var->blue.offset = 0;
> +               } else {
> +                       var->red.offset = 0;
> +                       var->green.offset = 5;
> +                       var->blue.offset = 11;
> +               }
>                 var->red.length = 5;
> -               var->green.offset = 5;
>                 var->green.length = 6;
> -               var->blue.offset = 0;
>                 var->blue.length = 5;
>                 var->transp.offset = 0;
>                 var->transp.length = 0;
>                 break;

I somewhat doubt that this (and 5:5:5) actually work, do they ? the
green gets split into two separate fields, which we can't express
properly here...

Cheers,
Ben.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
  2014-06-16  7:35   ` Benjamin Herrenschmidt
@ 2014-06-16 23:54     ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2014-06-16 23:54 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	Cedric Le Goater, linux-fbdev, linux-kernel

On Mon, 2014-06-16 at 17:35 +1000, Benjamin Herrenschmidt wrote:

> I somewhat doubt that this (and 5:5:5) actually work, do they ? the
> green gets split into two separate fields, which we can't express
> properly here...

So the conclusion of further investigation is:

 - The right fix is to fix qemu to flip endian

 - There's an open discussion as to whether qemu could do it
automatically when the guest endian changes on powerpc as a quick fix,
the long run approach is to have a register to control it, I'm working
on it. offb can then "learn" to flick it like it does the palette hack
today.

 - If we want to ever support foreign endian offb with X, we need to do
things a bit differently based on the foreign endian bit that is already
there.

 - We must revert the existing cmap swap patch from the kernel, it's
broken and will break things when we fix qemu (and breaks with real HW
in LE mode). I've sent a revert request to Linus and CC'ed stable.

Cheers,
Ben.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
@ 2014-06-16 23:54     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2014-06-16 23:54 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	Cedric Le Goater, linux-fbdev, linux-kernel

On Mon, 2014-06-16 at 17:35 +1000, Benjamin Herrenschmidt wrote:

> I somewhat doubt that this (and 5:5:5) actually work, do they ? the
> green gets split into two separate fields, which we can't express
> properly here...

So the conclusion of further investigation is:

 - The right fix is to fix qemu to flip endian

 - There's an open discussion as to whether qemu could do it
automatically when the guest endian changes on powerpc as a quick fix,
the long run approach is to have a register to control it, I'm working
on it. offb can then "learn" to flick it like it does the palette hack
today.

 - If we want to ever support foreign endian offb with X, we need to do
things a bit differently based on the foreign endian bit that is already
there.

 - We must revert the existing cmap swap patch from the kernel, it's
broken and will break things when we fix qemu (and breaks with real HW
in LE mode). I've sent a revert request to Linus and CC'ed stable.

Cheers,
Ben.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
  2014-06-16 23:54     ` Benjamin Herrenschmidt
@ 2014-06-17 10:01       ` Takashi Iwai
  -1 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-06-17 10:01 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	Cedric Le Goater, linux-fbdev, linux-kernel

At Tue, 17 Jun 2014 09:54:07 +1000,
Benjamin Herrenschmidt wrote:
> 
> On Mon, 2014-06-16 at 17:35 +1000, Benjamin Herrenschmidt wrote:
> 
> > I somewhat doubt that this (and 5:5:5) actually work, do they ? the
> > green gets split into two separate fields, which we can't express
> > properly here...
> 
> So the conclusion of further investigation is:
> 
>  - The right fix is to fix qemu to flip endian
> 
>  - There's an open discussion as to whether qemu could do it
> automatically when the guest endian changes on powerpc as a quick fix,
> the long run approach is to have a register to control it, I'm working
> on it. offb can then "learn" to flick it like it does the palette hack
> today.
> 
>  - If we want to ever support foreign endian offb with X, we need to do
> things a bit differently based on the foreign endian bit that is already
> there.
> 
>  - We must revert the existing cmap swap patch from the kernel, it's
> broken and will break things when we fix qemu (and breaks with real HW
> in LE mode). I've sent a revert request to Linus and CC'ed stable.

Yeah, I agree.  Both the current palette fix and my patch are really
wrong band-aiding.

(Though, the issue in X is rather a problem of X itself.  X should
 work with the tweaked RGB offsets.)


thanks,

Takashi

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] offb: Fix little-endian support
@ 2014-06-17 10:01       ` Takashi Iwai
  0 siblings, 0 replies; 22+ messages in thread
From: Takashi Iwai @ 2014-06-17 10:01 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	Cedric Le Goater, linux-fbdev, linux-kernel

At Tue, 17 Jun 2014 09:54:07 +1000,
Benjamin Herrenschmidt wrote:
> 
> On Mon, 2014-06-16 at 17:35 +1000, Benjamin Herrenschmidt wrote:
> 
> > I somewhat doubt that this (and 5:5:5) actually work, do they ? the
> > green gets split into two separate fields, which we can't express
> > properly here...
> 
> So the conclusion of further investigation is:
> 
>  - The right fix is to fix qemu to flip endian
> 
>  - There's an open discussion as to whether qemu could do it
> automatically when the guest endian changes on powerpc as a quick fix,
> the long run approach is to have a register to control it, I'm working
> on it. offb can then "learn" to flick it like it does the palette hack
> today.
> 
>  - If we want to ever support foreign endian offb with X, we need to do
> things a bit differently based on the foreign endian bit that is already
> there.
> 
>  - We must revert the existing cmap swap patch from the kernel, it's
> broken and will break things when we fix qemu (and breaks with real HW
> in LE mode). I've sent a revert request to Linus and CC'ed stable.

Yeah, I agree.  Both the current palette fix and my patch are really
wrong band-aiding.

(Though, the issue in X is rather a problem of X itself.  X should
 work with the tweaked RGB offsets.)


thanks,

Takashi

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2014-06-17 10:01 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-14 13:21 [PATCH] offb: Fix little-endian support Takashi Iwai
2014-05-14 13:21 ` Takashi Iwai
2014-05-14 14:01 ` Cedric Le Goater
2014-05-14 14:01   ` Cedric Le Goater
2014-05-14 14:24   ` Takashi Iwai
2014-05-14 14:24     ` Takashi Iwai
2014-05-14 17:04     ` Cedric Le Goater
2014-05-14 17:04       ` Cedric Le Goater
2014-05-14 17:57       ` Takashi Iwai
2014-05-14 17:57         ` Takashi Iwai
2014-06-16  7:23         ` Benjamin Herrenschmidt
2014-06-16  7:23           ` Benjamin Herrenschmidt
2014-06-16  7:32         ` Benjamin Herrenschmidt
2014-06-16  7:32           ` Benjamin Herrenschmidt
2014-05-14 16:56   ` Geert Uytterhoeven
2014-05-14 16:56     ` Geert Uytterhoeven
2014-06-16  7:35 ` Benjamin Herrenschmidt
2014-06-16  7:35   ` Benjamin Herrenschmidt
2014-06-16 23:54   ` Benjamin Herrenschmidt
2014-06-16 23:54     ` Benjamin Herrenschmidt
2014-06-17 10:01     ` Takashi Iwai
2014-06-17 10:01       ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.