Module Name: src Committed By: jmcneill Date: Fri May 31 01:35:56 UTC 2019
Modified Files: src/sys/dev/wsfb: files.wsfb genfb.c Log Message: If an EDID is available, attempt to use the screen size to influence font selection by passing a "wantcols" value to rasops_init that is satisfied by a font that is at least 3mm wide. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/wsfb/files.wsfb cvs rdiff -u -r1.64 -r1.65 src/sys/dev/wsfb/genfb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/wsfb/files.wsfb diff -u src/sys/dev/wsfb/files.wsfb:1.9 src/sys/dev/wsfb/files.wsfb:1.10 --- src/sys/dev/wsfb/files.wsfb:1.9 Fri May 1 02:00:41 2015 +++ src/sys/dev/wsfb/files.wsfb Fri May 31 01:35:56 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.wsfb,v 1.9 2015/05/01 02:00:41 nat Exp $ +# $NetBSD: files.wsfb,v 1.10 2019/05/31 01:35:56 jmcneill Exp $ # # wsdisplay framebuffer drivers @@ -9,7 +9,7 @@ defflag opt_wsfb.h WSFB_FAKE_VGA_FB # al defflag opt_wsfb.h WSFB_ALLOW_OTHERS # allow to mmap() foreign ranges # a generic framebuffer console -define genfb: rasops1, rasops2, rasops8, rasops15, rasops16, rasops24, rasops32, vcons +define genfb: rasops1, rasops2, rasops8, rasops15, rasops16, rasops24, rasops32, vcons, edid device genfb: genfb, wsemuldisplaydev, drm, splash file dev/wsfb/genfb.c genfb needs-flag defflag opt_genfb.h GENFB_DEBUG GENFB_SHADOWFB Index: src/sys/dev/wsfb/genfb.c diff -u src/sys/dev/wsfb/genfb.c:1.64 src/sys/dev/wsfb/genfb.c:1.65 --- src/sys/dev/wsfb/genfb.c:1.64 Mon Sep 3 16:29:34 2018 +++ src/sys/dev/wsfb/genfb.c Fri May 31 01:35:56 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: genfb.c,v 1.64 2018/09/03 16:29:34 riastradh Exp $ */ +/* $NetBSD: genfb.c,v 1.65 2019/05/31 01:35:56 jmcneill Exp $ */ /*- * Copyright (c) 2007 Michael Lorenz @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.64 2018/09/03 16:29:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.65 2019/05/31 01:35:56 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -49,6 +49,9 @@ __KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1. #include <dev/wsfb/genfbvar.h> +#include <dev/videomode/videomode.h> +#include <dev/videomode/edidvar.h> + #ifdef GENFB_DISABLE_TEXT #include <sys/reboot.h> #define DISABLESPLASH (boothowto & (RB_SINGLE | RB_USERCONF | RB_ASKNAME | \ @@ -58,6 +61,7 @@ __KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1. #ifdef _KERNEL_OPT #include "opt_genfb.h" #include "opt_wsfb.h" +#include "opt_rasops.h" #endif #ifdef GENFB_DEBUG @@ -67,12 +71,15 @@ __KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1. #endif #define GENFB_BRIGHTNESS_STEP 15 +#define GENFB_CHAR_WIDTH_MM 3 static int genfb_ioctl(void *, void *, u_long, void *, int, struct lwp *); static paddr_t genfb_mmap(void *, void *, off_t, int); static void genfb_pollc(void *, int); static void genfb_init_screen(void *, struct vcons_screen *, int, long *); +static int genfb_calc_hsize(struct genfb_softc *); +static int genfb_calc_cols(struct genfb_softc *); static int genfb_putcmap(struct genfb_softc *, struct wsdisplay_cmap *); static int genfb_getcmap(struct genfb_softc *, struct wsdisplay_cmap *); @@ -530,6 +537,7 @@ genfb_init_screen(void *cookie, struct v { struct genfb_softc *sc = cookie; struct rasops_info *ri = &scr->scr_ri; + int wantcols; ri->ri_depth = sc->sc_depth; ri->ri_width = sc->sc_width; @@ -583,8 +591,9 @@ genfb_init_screen(void *cookie, struct v if (ri->ri_depth == 8 && sc->sc_cmcb != NULL) ri->ri_flg |= RI_ENABLE_ALPHA | RI_8BIT_IS_RGB; + wantcols = genfb_calc_cols(sc); - rasops_init(ri, 0, 0); + rasops_init(ri, 0, wantcols); ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | WSSCREEN_RESIZE; rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight, @@ -599,6 +608,36 @@ genfb_init_screen(void *cookie, struct v #endif } +/* Returns the width of the display in millimeters, or 0 if not known. */ +static int +genfb_calc_hsize(struct genfb_softc *sc) +{ + device_t dev = sc->sc_dev; + prop_dictionary_t dict = device_properties(dev); + prop_data_t edid_data; + struct edid_info edid; + const char *edid_ptr; + + edid_data = prop_dictionary_get(dict, "EDID"); + if (edid_data == NULL || prop_data_size(edid_data) < 128) + return 0; + + edid_ptr = prop_data_data_nocopy(edid_data); + if (edid_parse(__UNCONST(edid_ptr), &edid) != 0) + return 0; + + return (int)edid.edid_max_hsize * 10; +} + +/* Return the minimum number of character columns based on DPI */ +static int +genfb_calc_cols(struct genfb_softc *sc) +{ + const int hsize = genfb_calc_hsize(sc); + + return MAX(RASOPS_DEFAULT_WIDTH, hsize / GENFB_CHAR_WIDTH_MM); +} + static int genfb_putcmap(struct genfb_softc *sc, struct wsdisplay_cmap *cm) {