From f101fd7fdc8a809762e0ab0b7d706c751c8465d9 Mon Sep 17 00:00:00 2001 From: Aleksandr Rybalko Date: Sun, 13 Jan 2013 22:05:46 +0000 Subject: [PATCH] Enable syscons framebuffer support for bcm2835. It makes possible to run Xorg on Raspberry Pi. o convert mmap address to physical. o add FBIOGTYPE ioctl handler - allow to get screen resolution by new xf86-video-scfb driver. Originally designed for "Efika MX" project. Sponsored by: FreeBSD Foundation --- sys/arm/broadcom/bcm2835/bcm2835_fb.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/arm/broadcom/bcm2835/bcm2835_fb.c b/sys/arm/broadcom/bcm2835/bcm2835_fb.c index 35343c88801e..0f1e81c2bc22 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_fb.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_fb.c @@ -136,6 +136,7 @@ struct video_adapter_softc { int console; intptr_t fb_addr; + intptr_t fb_paddr; unsigned int fb_size; unsigned int height; @@ -222,6 +223,7 @@ bcm_fb_init(void *arg) fb_config->screen_size); va_sc->fb_addr = (intptr_t)pmap_mapdev(fb_config->base, fb_config->screen_size); + va_sc->fb_paddr = fb_config->base; va_sc->fb_size = fb_config->screen_size; va_sc->depth = fb_config->bpp; va_sc->stride = fb_config->pitch; @@ -795,7 +797,7 @@ bcmfb_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr, * framebuffer, since it shouldn't be touched */ if (offset < sc->stride*sc->height) { - *paddr = sc->fb_addr + offset; + *paddr = sc->fb_paddr + offset; return (0); } @@ -805,6 +807,27 @@ bcmfb_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr, static int bcmfb_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data) { + struct video_adapter_softc *sc; + struct fbtype *fb; + + sc = (struct video_adapter_softc *)adp; + + switch (cmd) { + case FBIOGTYPE: + fb = (struct fbtype *)data; + fb->fb_type = FBTYPE_PCIMISC; + fb->fb_height = sc->height; + fb->fb_width = sc->width; + fb->fb_depth = sc->depth; + if (sc->depth <= 1 || sc->depth > 8) + fb->fb_cmsize = 0; + else + fb->fb_cmsize = 1 << sc->depth; + fb->fb_size = sc->fb_size; + break; + default: + return (fb_commonioctl(adp, cmd, data)); + } return (0); }