Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/wsfb If an EDID is available, attempt to use the scr...



details:   https://anonhg.NetBSD.org/src/rev/782396e0ea10
branches:  trunk
changeset: 451692:782396e0ea10
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri May 31 01:35:56 2019 +0000

description:
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.

diffstat:

 sys/dev/wsfb/files.wsfb |   4 ++--
 sys/dev/wsfb/genfb.c    |  45 ++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 44 insertions(+), 5 deletions(-)

diffs (126 lines):

diff -r 3234cf8e646e -r 782396e0ea10 sys/dev/wsfb/files.wsfb
--- a/sys/dev/wsfb/files.wsfb   Fri May 31 01:30:08 2019 +0000
+++ b/sys/dev/wsfb/files.wsfb   Fri May 31 01:35:56 2019 +0000
@@ -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_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
diff -r 3234cf8e646e -r 782396e0ea10 sys/dev/wsfb/genfb.c
--- a/sys/dev/wsfb/genfb.c      Fri May 31 01:30:08 2019 +0000
+++ b/sys/dev/wsfb/genfb.c      Fri May 31 01:35:56 2019 +0000
@@ -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 @@
 
 #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 @@
 #ifdef _KERNEL_OPT
 #include "opt_genfb.h"
 #include "opt_wsfb.h"
+#include "opt_rasops.h"
 #endif
 
 #ifdef GENFB_DEBUG
@@ -67,12 +71,15 @@
 #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 @@
 {
        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 @@
        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 @@
 #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)
 {



Home | Main Index | Thread Index | Old Index