Deleted Added
full compact
28c28
< __FBSDID("$FreeBSD: head/sys/arm/broadcom/bcm2835/bcm2835_fb.c 239922 2012-08-30 20:59:37Z gonzo $");
---
> __FBSDID("$FreeBSD: head/sys/arm/broadcom/bcm2835/bcm2835_fb.c 243423 2012-11-23 04:30:54Z gonzo $");
70a71,96
> struct argb {
> uint8_t a;
> uint8_t r;
> uint8_t g;
> uint8_t b;
> };
>
> static struct argb bcmfb_palette[16] = {
> {0x00, 0x00, 0x00, 0x00},
> {0x00, 0x00, 0x00, 0xaa},
> {0x00, 0x00, 0xaa, 0x00},
> {0x00, 0x00, 0xaa, 0xaa},
> {0x00, 0xaa, 0x00, 0x00},
> {0x00, 0xaa, 0x00, 0xaa},
> {0x00, 0xaa, 0x55, 0x00},
> {0x00, 0xaa, 0xaa, 0xaa},
> {0x00, 0x55, 0x55, 0x55},
> {0x00, 0x55, 0x55, 0xff},
> {0x00, 0x55, 0xff, 0x55},
> {0x00, 0x55, 0xff, 0xff},
> {0x00, 0xff, 0x55, 0x55},
> {0x00, 0xff, 0x55, 0xff},
> {0x00, 0xff, 0xff, 0x55},
> {0x00, 0xff, 0xff, 0xff}
> };
>
72a99
> #define FB_DEPTH 24
109a137
> unsigned int depth;
128a157,158
> static void bcmfb_update_margins(video_adapter_t *adp);
> static int bcmfb_configure(int);
136a167,168
> phandle_t node;
> pcell_t cell;
138,140c170,190
< /* TODO: replace it with FDT stuff */
< fb_config->xres = FB_WIDTH;
< fb_config->yres = FB_HEIGHT;
---
> node = ofw_bus_get_node(sc->dev);
>
> fb_config->xres = 0;
> fb_config->yres = 0;
> fb_config->bpp = 0;
>
> if ((OF_getprop(node, "broadcom,width", &cell, sizeof(cell))) > 0)
> fb_config->xres = (int)fdt32_to_cpu(cell);
> if (fb_config->xres == 0)
> fb_config->xres = FB_WIDTH;
>
> if ((OF_getprop(node, "broadcom,height", &cell, sizeof(cell))) > 0)
> fb_config->yres = (uint32_t)fdt32_to_cpu(cell);
> if (fb_config->yres == 0)
> fb_config->yres = FB_HEIGHT;
>
> if ((OF_getprop(node, "broadcom,depth", &cell, sizeof(cell))) > 0)
> fb_config->bpp = (uint32_t)fdt32_to_cpu(cell);
> if (fb_config->bpp == 0)
> fb_config->bpp = FB_DEPTH;
>
145d194
< fb_config->bpp = 24;
157c206
< if (err == 0) {
---
> if (fb_config->base != 0) {
169,173c218,225
< if (fb_config->base) {
< va_sc->fb_addr = (intptr_t)pmap_mapdev(fb_config->base, fb_config->screen_size);
< va_sc->fb_size = fb_config->screen_size;
< va_sc->stride = fb_config->pitch;
< }
---
> va_sc->fb_addr = (intptr_t)pmap_mapdev(fb_config->base, fb_config->screen_size);
> va_sc->fb_size = fb_config->screen_size;
> va_sc->depth = fb_config->bpp;
> va_sc->stride = fb_config->pitch;
>
> va_sc->width = fb_config->xres;
> va_sc->height = fb_config->yres;
> bcmfb_update_margins(&va_sc->va);
175c227
< else
---
> else {
176a229,230
> return;
> }
184c238
< int error;
---
> int error = 0;
193d246
<
196a250
>
296c350
< DRIVER_MODULE(bcm2835fb, simplebus, bcm_fb_driver, bcm_fb_devclass, 0, 0);
---
> DRIVER_MODULE(bcm2835fb, fdtbus, bcm_fb_driver, bcm_fb_devclass, 0, 0);
301d354
< static int bcmfb_configure(int);
376a430,445
> /*
> * Update videoadapter settings after changing resolution
> */
> static void
> bcmfb_update_margins(video_adapter_t *adp)
> {
> struct video_adapter_softc *sc;
> video_info_t *vi;
>
> sc = (struct video_adapter_softc *)adp;
> vi = &adp->va_info;
>
> sc->xmargin = (sc->width - (vi->vi_width * vi->vi_cwidth)) / 2;
> sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight))/2;
> }
>
380c449
< struct video_adapter_softc *sc;
---
> struct video_adapter_softc *va_sc;
382c451,453
< sc = &va_softc;
---
> va_sc = &va_softc;
> phandle_t display, root;
> pcell_t cell;
384,385c455,456
< if (sc->initialized)
< return 0;
---
> if (va_sc->initialized)
> return (0);
387,388c458,459
< sc->height = FB_HEIGHT;
< sc->width = FB_WIDTH;
---
> va_sc->width = 0;
> va_sc->height = 0;
390c461,471
< bcmfb_init(0, &sc->va, 0);
---
> /*
> * It seems there is no way to let syscons framework know
> * that framebuffer resolution has changed. So just try
> * to fetch data from FDT and go with defaults if failed
> */
> root = OF_finddevice("/");
> if ((root != 0) &&
> (display = fdt_find_compatible(root, "broadcom,bcm2835-fb", 1))) {
> if ((OF_getprop(display, "broadcom,width",
> &cell, sizeof(cell))) > 0)
> va_sc->width = (int)fdt32_to_cpu(cell);
392c473,476
< sc->initialized = 1;
---
> if ((OF_getprop(display, "broadcom,height",
> &cell, sizeof(cell))) > 0)
> va_sc->height = (int)fdt32_to_cpu(cell);
> }
393a478,486
> if (va_sc->width == 0)
> va_sc->width = FB_WIDTH;
> if (va_sc->height == 0)
> va_sc->height = FB_HEIGHT;
>
> bcmfb_init(0, &va_sc->va, 0);
>
> va_sc->initialized = 1;
>
417a511
>
431a526
>
543a639,644
> struct video_adapter_softc *sc;
>
> sc = (struct video_adapter_softc *)adp;
> if (sc && sc->fb_addr)
> memset((void*)sc->fb_addr, 0, sc->fb_size);
>
640a742
> uint16_t rgb;
654,658c756,757
< /*
< * FIXME: hardcoded
< */
< bg = 0x00;
< fg = 0x80;
---
> fg = a & 0xf ;
> bg = (a >> 8) & 0xf;
667,669c766,787
< addr[3*j] = color;
< addr[3*j+1] = color;
< addr[3*j+2] = color;
---
> switch (sc->depth) {
> case 32:
> addr[4*j+0] = bcmfb_palette[color].r;
> addr[4*j+1] = bcmfb_palette[color].g;
> addr[4*j+2] = bcmfb_palette[color].b;
> addr[4*j+3] = bcmfb_palette[color].a;
> break;
> case 24:
> addr[3*j] = bcmfb_palette[color].r;
> addr[3*j+1] = bcmfb_palette[color].g;
> addr[3*j+2] = bcmfb_palette[color].b;
> break;
> case 16:
> rgb = (bcmfb_palette[color].r >> 3) << 10;
> rgb |= (bcmfb_palette[color].g >> 3) << 5;
> rgb |= (bcmfb_palette[color].b >> 3);
> addr[2*j] = (rgb >> 8) & 0xff;
> addr[2*j + 1] = rgb & 0xff;
> default:
> /* Not supported yet */
> break;
> }