1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

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@
This commit is contained in:
Marcel Moolenaar 2015-08-15 16:13:28 +00:00
parent 8bd2e88e36
commit 296a51148d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=286809

View File

@ -96,7 +96,6 @@ vt_efifb_probe(struct vt_device *vd)
static int static int
vt_efifb_init(struct vt_device *vd) vt_efifb_init(struct vt_device *vd)
{ {
int depth, d;
struct fb_info *info; struct fb_info *info;
struct efi_fb *efifb; struct efi_fb *efifb;
caddr_t kmdp; caddr_t kmdp;
@ -116,16 +115,13 @@ vt_efifb_init(struct vt_device *vd)
info->fb_height = efifb->fb_height; info->fb_height = efifb->fb_height;
info->fb_width = efifb->fb_width; info->fb_width = efifb->fb_width;
depth = fls(efifb->fb_mask_red); info->fb_depth = fls(efifb->fb_mask_red | efifb->fb_mask_green |
d = fls(efifb->fb_mask_green); efifb->fb_mask_blue | efifb->fb_mask_reserved);
depth = d > depth ? d : depth; /* Round to a multiple of the bits in a byte. */
d = fls(efifb->fb_mask_blue); info->fb_bpp = (info->fb_depth + NBBY - 1) & ~(NBBY - 1);
depth = d > depth ? d : depth;
d = fls(efifb->fb_mask_reserved);
depth = d > depth ? d : depth;
info->fb_depth = depth;
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, vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB,
efifb->fb_mask_red, ffs(efifb->fb_mask_red) - 1, 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_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase,
info->fb_size, VM_MEMATTR_WRITE_COMBINING); 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); vt_fb_init(vd);
return (CN_INTERNAL); return (CN_INTERNAL);