*** bcm2835_mbox_prop.h.orig Fri Dec 7 00:01:50 2018 --- bcm2835_mbox_prop.h Tue Jan 29 05:26:36 2019 *************** *** 467,486 **** --- 467,494 ---- }; struct msg_fb_get_w_h { struct bcm2835_mbox_hdr hdr; struct bcm2835_mbox_tag_fb_w_h physical_w_h; uint32_t end_tag; }; int bcm2835_mbox_fb_get_w_h(struct bcm2835_fb_config *); + struct msg_fb_get_bpp { + struct bcm2835_mbox_hdr hdr; + struct bcm2835_mbox_tag_depth bpp; + uint32_t end_tag; + }; + + int bcm2835_mbox_fb_get_bpp(struct bcm2835_fb_config *); + struct msg_fb_setup { struct bcm2835_mbox_hdr hdr; struct bcm2835_mbox_tag_fb_w_h physical_w_h; struct bcm2835_mbox_tag_fb_w_h virtual_w_h; struct bcm2835_mbox_tag_virtual_offset offset; struct bcm2835_mbox_tag_depth depth; struct bcm2835_mbox_tag_alpha_mode alpha; struct bcm2835_mbox_tag_allocate_buffer buffer; struct bcm2835_mbox_tag_pitch pitch; uint32_t end_tag; *** bcm2835_mbox.c.orig Fri Dec 7 00:01:50 2018 --- bcm2835_mbox.c Tue Jan 29 02:12:51 2019 *************** *** 492,511 **** --- 492,532 ---- err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err == 0) { fb->xres = msg.physical_w_h.body.resp.width; fb->yres = msg.physical_w_h.body.resp.height; } return (err); } int + bcm2835_mbox_fb_get_bpp(struct bcm2835_fb_config *fb) + { + int err; + struct msg_fb_get_bpp msg; + + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + BCM2835_MBOX_INIT_TAG(&msg.bpp, GET_DEPTH); + msg.bpp.tag_hdr.val_len = 0; + msg.end_tag = 0; + + err = bcm2835_mbox_property(&msg, sizeof(msg)); + if (err == 0) { + fb->bpp = msg.bpp.body.resp.bpp; + } + + return (err); + } + + int bcm2835_mbox_fb_init(struct bcm2835_fb_config *fb) { int err; struct msg_fb_setup msg; memset(&msg, 0, sizeof(msg)); msg.hdr.buf_size = sizeof(msg); msg.hdr.code = BCM2835_MBOX_CODE_REQ; BCM2835_MBOX_INIT_TAG(&msg.physical_w_h, SET_PHYSICAL_W_H); msg.physical_w_h.body.req.width = fb->xres; *** bcm2835_fbd.c.orig Fri Dec 7 00:01:50 2018 --- bcm2835_fbd.c Tue Jan 29 04:22:24 2019 *************** *** 78,98 **** static int bcm_fb_init(struct bcmsc_softc *sc, struct bcm2835_fb_config *fb) { int err; err = 0; memset(fb, 0, sizeof(*fb)); if (bcm2835_mbox_fb_get_w_h(fb) != 0) return (ENXIO); ! fb->bpp = FB_DEPTH; fb->vxres = fb->xres; fb->vyres = fb->yres; fb->xoffset = fb->yoffset = 0; if ((err = bcm2835_mbox_fb_init(fb)) != 0) { device_printf(sc->dev, "bcm2835_mbox_fb_init failed, err=%d\n", err); return (ENXIO); } --- 78,107 ---- static int bcm_fb_init(struct bcmsc_softc *sc, struct bcm2835_fb_config *fb) { int err; err = 0; memset(fb, 0, sizeof(*fb)); if (bcm2835_mbox_fb_get_w_h(fb) != 0) return (ENXIO); ! if (bcm2835_mbox_fb_get_bpp(fb) != 0) ! return (ENXIO); ! if (fb->bpp < FB_DEPTH) { ! device_printf(sc->dev, "Changing fb bpp from %d to %d\n", ! fb->bpp, FB_DEPTH); ! fb->bpp = FB_DEPTH; ! } else { ! device_printf(sc->dev, "Keeping existing fb bpp of %d\n", ! fb->bpp); ! } fb->vxres = fb->xres; fb->vyres = fb->yres; fb->xoffset = fb->yoffset = 0; if ((err = bcm2835_mbox_fb_init(fb)) != 0) { device_printf(sc->dev, "bcm2835_mbox_fb_init failed, err=%d\n", err); return (ENXIO); }