Graphics stuff is weird.  It doesn't just care about endianness on the
byte level, but also about endianness on the bit level.  This matters
for monochrome framebuffers, where a true big-endian framebuffer will
have the leftmost pixel in the MSB wheras a little-endian framebuffer
will have it in the LSB.  The optimized rasops1_putchar8() and
rasops1_putchar16() assume the framebuffer uses the big-endian byte
order since that is how our fonts are encoded.  The generic
rasops1_putchar() function assumes native bit order though.  This is
inconsistent and confusing.

The diff below disables the optimized functions on little-endian
architectures such that we always use rasops1_putchar().  This makes
ssdfb(4) work with the default 8x16 font on arm64.

ok?


Index: dev/rasops/rasops1.c
===================================================================
RCS file: /cvs/src/sys/dev/rasops/rasops1.c,v
retrieving revision 1.10
diff -u -p -r1.10 rasops1.c
--- dev/rasops/rasops1.c        25 May 2020 09:55:49 -0000      1.10
+++ dev/rasops/rasops1.c        18 Dec 2020 21:19:55 -0000
@@ -44,7 +44,7 @@ int   rasops1_copycols(void *, int, int, i
 int    rasops1_erasecols(void *, int, int, int, uint32_t);
 int    rasops1_do_cursor(struct rasops_info *);
 int    rasops1_putchar(void *, int, int col, u_int, uint32_t);
-#ifndef RASOPS_SMALL
+#if defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
 int    rasops1_putchar8(void *, int, int col, u_int, uint32_t);
 int    rasops1_putchar16(void *, int, int col, u_int, uint32_t);
 #endif
@@ -58,7 +58,7 @@ rasops1_init(struct rasops_info *ri)
        rasops_masks_init();
 
        switch (ri->ri_font->fontwidth) {
-#ifndef RASOPS_SMALL
+#if defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
        case 8:
                ri->ri_ops.putchar = rasops1_putchar8;
                break;
@@ -223,7 +223,7 @@ rasops1_putchar(void *cookie, int row, i
        return 0;
 }
 
-#ifndef RASOPS_SMALL
+#if defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN
 /*
  * Paint a single character. This is for 8-pixel wide fonts.
  */
@@ -350,7 +350,7 @@ rasops1_putchar16(void *cookie, int row,
 
        return 0;
 }
-#endif /* !RASOPS_SMALL */
+#endif /* !defined(RASOPS_SMALL) && BYTE_ORDER == BIG_ENDIAN */
 
 /*
  * Grab routines common to depths where (bpp < 8)

Reply via email to