summaryrefslogtreecommitdiffstats
path: root/sys/dev/vt/hw/efifb/efifb.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/vt/hw/efifb/efifb.c')
-rw-r--r--sys/dev/vt/hw/efifb/efifb.c56
1 files changed, 8 insertions, 48 deletions
diff --git a/sys/dev/vt/hw/efifb/efifb.c b/sys/dev/vt/hw/efifb/efifb.c
index 05b2d79..2451277 100644
--- a/sys/dev/vt/hw/efifb/efifb.c
+++ b/sys/dev/vt/hw/efifb/efifb.c
@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
static vd_init_t vt_efifb_init;
static vd_probe_t vt_efifb_probe;
-static void vt_efifb_remap(void *efifb_data);
static struct vt_driver vt_efifb_driver = {
.vd_name = "efifb",
@@ -73,8 +72,6 @@ static struct vt_driver vt_efifb_driver = {
static struct fb_info local_info;
VT_DRIVER_DECLARE(vt_efifb, vt_efifb_driver);
-SYSINIT(efifb_remap, SI_SUB_KMEM, SI_ORDER_ANY, vt_efifb_remap, &local_info);
-
static int
vt_efifb_probe(struct vt_device *vd)
{
@@ -101,7 +98,6 @@ vt_efifb_probe(struct vt_device *vd)
static int
vt_efifb_init(struct vt_device *vd)
{
- int depth, d;
struct fb_info *info;
struct efi_fb *efifb;
caddr_t kmdp;
@@ -121,16 +117,13 @@ vt_efifb_init(struct vt_device *vd)
info->fb_height = efifb->fb_height;
info->fb_width = efifb->fb_width;
- depth = fls(efifb->fb_mask_red);
- d = fls(efifb->fb_mask_green);
- depth = d > depth ? d : depth;
- d = fls(efifb->fb_mask_blue);
- depth = d > depth ? d : depth;
- d = fls(efifb->fb_mask_reserved);
- depth = d > depth ? d : depth;
- info->fb_depth = depth;
+ info->fb_depth = fls(efifb->fb_mask_red | efifb->fb_mask_green |
+ efifb->fb_mask_blue | efifb->fb_mask_reserved);
+ /* Round to a multiple of the bits in a byte. */
+ info->fb_bpp = (info->fb_depth + NBBY - 1) & ~(NBBY - 1);
- info->fb_stride = efifb->fb_stride * (depth / 8);
+ /* Stride in bytes, not pixels */
+ info->fb_stride = efifb->fb_stride * (info->fb_bpp / NBBY);
vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB,
efifb->fb_mask_red, ffs(efifb->fb_mask_red) - 1,
@@ -139,43 +132,10 @@ vt_efifb_init(struct vt_device *vd)
info->fb_size = info->fb_height * info->fb_stride;
info->fb_pbase = efifb->fb_addr;
- /*
- * Use the direct map as a crutch until pmap is available. Once pmap
- * is online, the framebuffer will be remapped by vt_efifb_remap()
- * using pmap_mapdev_attr().
- */
- info->fb_vbase = PHYS_TO_DMAP(efifb->fb_addr);
-
- /* Get pixel storage size. */
- info->fb_bpp = info->fb_stride / info->fb_width * 8;
-
- /*
- * Early FB driver work with static window buffer, so reduce to minimal
- * size, buffer or screen.
- */
- info->fb_width = MIN(info->fb_width, VT_FB_DEFAULT_WIDTH);
- info->fb_height = MIN(info->fb_height, VT_FB_DEFAULT_HEIGHT);
+ info->fb_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase,
+ info->fb_size, VM_MEMATTR_WRITE_COMBINING);
vt_fb_init(vd);
return (CN_INTERNAL);
}
-
-static void
-vt_efifb_remap(void *xinfo)
-{
- struct fb_info *info = xinfo;
-
- if (info->fb_pbase == 0)
- return;
-
- /*
- * Remap as write-combining. This massively improves performance and
- * happens very early in kernel initialization, when everything is
- * still single-threaded and interrupts are off, so replacing the
- * mapping address is safe.
- */
- info->fb_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase,
- info->fb_size, VM_MEMATTR_WRITE_COMBINING);
-}
-
OpenPOWER on IntegriCloud