svn commit: r286809 - head/sys/dev/vt/hw/efifb

Marcel Moolenaar marcel at FreeBSD.org
Sat Aug 15 16:13:29 UTC 2015


Author: marcel
Date: Sat Aug 15 16:13:28 2015
New Revision: 286809
URL: https://svnweb.freebsd.org/changeset/base/286809

Log:
  Improve support for Macs that have a stride not equal to the
  horizonal resolution (width). In those cases fb_bpp ended up
  completely wrong -- as in 6 bytes per pixel or something like
  that. Since we already have a way to calculate fb_depth given
  the masks and fb_bpp is effectively the same as fb_depth, all
  we need to do is make sure fb_bpp is rounded to the next
  multiple of the number of bits in a byte -- we assume we can
  divide by the number of bits in a byte throughout vt(4).
  While here:
  -   simplify how we calculate fb_depth.
  -   use fb_bpp instead of fb_depth to calculate fb_stride;
      we know we can divide fb_bpp.
  -   don't limit fb_width and fb_height by VT_FB_DEFAULT_WIDTH
      and VT_FB_DEFAULT_HEIGHT (resp.). Those constants have
      not relation to the size of the frame buffer.
  
  This at least fixes "lower-resolution" Macs. We're talking
  1280x1024 or so. There still is a problem with 27" Macs,
  which typically have a horizontal resolution over 2K.
  
  PR:		193745 (partial)
  Ok'd by:	emaste@

Modified:
  head/sys/dev/vt/hw/efifb/efifb.c

Modified: head/sys/dev/vt/hw/efifb/efifb.c
==============================================================================
--- head/sys/dev/vt/hw/efifb/efifb.c	Sat Aug 15 15:44:09 2015	(r286808)
+++ head/sys/dev/vt/hw/efifb/efifb.c	Sat Aug 15 16:13:28 2015	(r286809)
@@ -96,7 +96,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;
@@ -116,16 +115,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,
@@ -137,16 +133,6 @@ vt_efifb_init(struct vt_device *vd)
 	info->fb_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase,
 	    info->fb_size, VM_MEMATTR_WRITE_COMBINING);
 
-	/* 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);
-
 	vt_fb_init(vd);
 
 	return (CN_INTERNAL);


More information about the svn-src-all mailing list