The framebuffer on the 14" and 16" macbook pro is special.  The screen
is a little bit taller than the standard 16:10 ratio.  And the top of
the display is partly covered by "the notch" that integrates the
camera.  The pixels behind the notch exist as far as the framebuffer
is considered, but aren't visible.

Since none of the applications we're running on OpenBSD are aware of
this, the m1n1 bootloader presents a framebuffer that starts below the
notch.  This works fine and you still have a display with the standard
16:10 aspect ration.

There is a problem though.  The pixel in the top left corner no longer
starts on a page boundary.  And this in turn trips up wsfb(4),
creating a display that wraps around in a funny way.

The diff below fixes this by exposing the offset within the first page
where the first pixel starts.  My implementation changes the
WSDISPLAYIO_GINFO ioctl in an incompatible way.  This wasn't done when
WSDISPLAYIO_LINEBYTES was introduced.  So I added that information
too.  Maybe we can deprecate WSDISPLAYIO_LINEBYTES somwehere in the
future.  Note that I do have to fix up some other drivers such that
they don't accidentally expose garbage in these new fields.  Obviously
old xenocara will not work with the new kernel and vice versa.

Thoughts?


Index: dev/fdt/simplefb.c
===================================================================
RCS file: /cvs/src/sys/dev/fdt/simplefb.c,v
retrieving revision 1.15
diff -u -p -r1.15 simplefb.c
--- dev/fdt/simplefb.c  9 Jan 2022 05:42:37 -0000       1.15
+++ dev/fdt/simplefb.c  26 Jun 2022 15:49:31 -0000
@@ -234,6 +234,7 @@ int
 simplefb_wsioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
 {
        struct rasops_info *ri = v;
+       struct simplefb_softc *sc = ri->ri_hw;
        struct wsdisplay_param *dp = (struct wsdisplay_param *)data;
        struct wsdisplay_fbinfo *wdf;
 
@@ -254,6 +255,8 @@ simplefb_wsioctl(void *v, u_long cmd, ca
                wdf->width = ri->ri_width;
                wdf->height = ri->ri_height;
                wdf->depth = ri->ri_depth;
+               wdf->stride = ri->ri_stride;
+               wdf->offset = sc->sc_paddr & PAGE_MASK;
                wdf->cmsize = 0;        /* color map is unavailable */
                break;
        case WSDISPLAYIO_LINEBYTES:
Index: dev/wscons/wsconsio.h
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wsconsio.h,v
retrieving revision 1.97
diff -u -p -r1.97 wsconsio.h
--- dev/wscons/wsconsio.h       12 Mar 2021 23:42:50 -0000      1.97
+++ dev/wscons/wsconsio.h       26 Jun 2022 15:49:31 -0000
@@ -448,6 +448,8 @@ struct wsdisplay_fbinfo {
        u_int   height;                         /* height in pixels */
        u_int   width;                          /* width in pixels */
        u_int   depth;                          /* bits per pixel */
+       u_int   stride;                         /* bytes per line */
+       u_int   offset;                         /* offset in bytes */
        u_int   cmsize;                         /* color map size (entries) */
 };
 #define        WSDISPLAYIO_GINFO       _IOR('W', 65, struct wsdisplay_fbinfo)



Index: driver/xf86-video-wsfb/src/wsfb_driver.c
===================================================================
RCS file: /cvs/xenocara/driver/xf86-video-wsfb/src/wsfb_driver.c,v
retrieving revision 1.40
diff -u -p -r1.40 wsfb_driver.c
--- driver/xf86-video-wsfb/src/wsfb_driver.c    7 Feb 2022 18:38:44 -0000       
1.40
+++ driver/xf86-video-wsfb/src/wsfb_driver.c    26 Jun 2022 15:50:44 -0000
@@ -885,7 +885,8 @@ WsfbScreenInit(SCREEN_INIT_ARGS_DECL)
                           strerror(errno));
                return FALSE;
        }
-       fPtr->fbmem = wsfb_mmap(len, 0, fPtr->fd);
+       fPtr->fbmem = wsfb_mmap(len + fPtr->info.offset, 0, fPtr->fd);
+       fPtr->fbmem += fPtr->info.offset;
 
        if (fPtr->fbmem == NULL) {
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,

Reply via email to