Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/wscons wsdisplay(4): Factor out WSDISPLAY_SCROLLSUPP...



details:   https://anonhg.NetBSD.org/src/rev/37462d490e2d
branches:  trunk
changeset: 368516:37462d490e2d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Jul 17 10:28:09 2022 +0000

description:
wsdisplay(4): Factor out WSDISPLAY_SCROLLSUPPORT logic.

Should find a way to avoid the #ifdefs in the .h file, but this makes
the code a good deal more legible and easier to maitain, at least.
No functional change intended.

diffstat:

 sys/arch/arm/omap/omapfb.c          |   8 +--
 sys/arch/arm/ti/omap3_dss.c         |   8 +--
 sys/dev/pci/wcfb.c                  |   8 +--
 sys/dev/wscons/wsdisplay_vcons.c    |  68 +++++-------------------------------
 sys/dev/wscons/wsdisplay_vconsvar.h |  12 +++++-
 5 files changed, 31 insertions(+), 73 deletions(-)

diffs (269 lines):

diff -r 4edab7d50d2c -r 37462d490e2d sys/arch/arm/omap/omapfb.c
--- a/sys/arch/arm/omap/omapfb.c        Sun Jul 17 10:27:45 2022 +0000
+++ b/sys/arch/arm/omap/omapfb.c        Sun Jul 17 10:28:09 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: omapfb.c,v 1.30 2021/08/07 16:18:45 thorpej Exp $      */
+/*     $NetBSD: omapfb.c,v 1.31 2022/07/17 10:28:09 riastradh Exp $    */
 
 /*
  * Copyright (c) 2010 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omapfb.c,v 1.30 2021/08/07 16:18:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omapfb.c,v 1.31 2022/07/17 10:28:09 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -980,9 +980,7 @@
        int pos;
 
        pos = col + row * ri->ri_cols;
-#ifdef WSDISPLAY_SCROLLSUPPORT
-       pos += scr->scr_offset_to_zero;
-#endif
+       pos += vcons_offset_to_zero(scr);
        if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
                if (ri->ri_flg & RI_CURSOR) {
                        omapfb_putchar(cookie, row, col, scr->scr_chars[pos],
diff -r 4edab7d50d2c -r 37462d490e2d sys/arch/arm/ti/omap3_dss.c
--- a/sys/arch/arm/ti/omap3_dss.c       Sun Jul 17 10:27:45 2022 +0000
+++ b/sys/arch/arm/ti/omap3_dss.c       Sun Jul 17 10:28:09 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: omap3_dss.c,v 1.5 2021/08/07 16:18:46 thorpej Exp $    */
+/*     $NetBSD: omap3_dss.c,v 1.6 2022/07/17 10:28:09 riastradh Exp $  */
 
 /*
  * Copyright (c) 2010 Michael Lorenz
@@ -33,7 +33,7 @@
 #include "opt_wsdisplay_compat.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap3_dss.c,v 1.5 2021/08/07 16:18:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap3_dss.c,v 1.6 2022/07/17 10:28:09 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -993,9 +993,7 @@
        int pos;
 
        pos = col + row * ri->ri_cols;
-#ifdef WSDISPLAY_SCROLLSUPPORT
-       pos += scr->scr_offset_to_zero;
-#endif
+       pos += vcons_offset_to_zero(scr);
        if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
                if (ri->ri_flg & RI_CURSOR) {
                        omapfb_putchar(cookie, row, col, scr->scr_chars[pos],
diff -r 4edab7d50d2c -r 37462d490e2d sys/dev/pci/wcfb.c
--- a/sys/dev/pci/wcfb.c        Sun Jul 17 10:27:45 2022 +0000
+++ b/sys/dev/pci/wcfb.c        Sun Jul 17 10:28:09 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wcfb.c,v 1.20 2021/08/07 16:19:14 thorpej Exp $ */
+/*     $NetBSD: wcfb.c,v 1.21 2022/07/17 10:28:09 riastradh Exp $ */
 
 /*
  * Copyright (c) 2007, 2008, 2009 Miodrag Vallat.
@@ -20,7 +20,7 @@
 /* a driver for (some) 3DLabs Wildcat cards, based on OpenBSD's ifb driver */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wcfb.c,v 1.20 2021/08/07 16:19:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wcfb.c,v 1.21 2022/07/17 10:28:09 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -590,9 +590,7 @@
                if (ri->ri_flg & RI_CURSOR) {
                        /* remove cursor */
                        coffset = ri->ri_ccol + (ri->ri_crow * ri->ri_cols);
-#ifdef WSDISPLAY_SCROLLSUPPORT
-                       coffset += scr->scr_offset_to_zero;
-#endif
+                       coffset += vcons_offset_to_zero(scr);
                        wcfb_putchar(cookie, ri->ri_crow,
                            ri->ri_ccol, scr->scr_chars[coffset],
                            scr->scr_attrs[coffset]);
diff -r 4edab7d50d2c -r 37462d490e2d sys/dev/wscons/wsdisplay_vcons.c
--- a/sys/dev/wscons/wsdisplay_vcons.c  Sun Jul 17 10:27:45 2022 +0000
+++ b/sys/dev/wscons/wsdisplay_vcons.c  Sun Jul 17 10:28:09 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsdisplay_vcons.c,v 1.55 2022/07/17 10:27:45 riastradh Exp $ */
+/*     $NetBSD: wsdisplay_vcons.c,v 1.56 2022/07/17 10:28:09 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.55 2022/07/17 10:27:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.56 2022/07/17 10:28:09 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -878,21 +878,12 @@
        struct vcons_screen *scr = ri->ri_hw;
        int from = srccol + row * ri->ri_cols;
        int to = dstcol + row * ri->ri_cols;
-
-#ifdef WSDISPLAY_SCROLLSUPPORT
-       int offset;
-       offset = scr->scr_offset_to_zero;
+       int offset = vcons_offset_to_zero(scr);
 
        memmove(&scr->scr_attrs[offset + to], &scr->scr_attrs[offset + from],
            ncols * sizeof(long));
        memmove(&scr->scr_chars[offset + to], &scr->scr_chars[offset + from],
            ncols * sizeof(uint32_t));
-#else
-       memmove(&scr->scr_attrs[to], &scr->scr_attrs[from],
-           ncols * sizeof(long));
-       memmove(&scr->scr_chars[to], &scr->scr_chars[from],
-           ncols * sizeof(uint32_t));
-#endif
 
 #ifdef VCONS_DRAW_INTR
        atomic_inc_uint(&scr->scr_dirty);
@@ -973,21 +964,12 @@
        struct vcons_screen *scr = ri->ri_hw;
        int start = startcol + row * ri->ri_cols;
        int end = start + ncols, i;
-
-#ifdef WSDISPLAY_SCROLLSUPPORT
-       int offset;
-       offset = scr->scr_offset_to_zero;
+       int offset = vcons_offset_to_zero(scr);
 
        for (i = start; i < end; i++) {
                scr->scr_attrs[offset + i] = fillattr;
                scr->scr_chars[offset + i] = 0x20;
        }
-#else
-       for (i = start; i < end; i++) {
-               scr->scr_attrs[i] = fillattr;
-               scr->scr_chars[i] = 0x20;
-       }
-#endif
 
 #ifdef VCONS_DRAW_INTR
        atomic_inc_uint(&scr->scr_dirty);
@@ -1042,30 +1024,22 @@
        struct rasops_info *ri = cookie;
        struct vcons_screen *scr = ri->ri_hw;
        int from, to, len;
-
-#ifdef WSDISPLAY_SCROLLSUPPORT
-       int offset;
-       offset = scr->scr_offset_to_zero;
+       int offset = vcons_offset_to_zero(scr);
 
        /* do we need to scroll the back buffer? */
-       if (dstrow == 0) {
+       if (dstrow == 0 && offset != 0) {
                from = ri->ri_cols * srcrow;
                to = ri->ri_cols * dstrow;
 
                memmove(&scr->scr_attrs[to], &scr->scr_attrs[from],
-                   scr->scr_offset_to_zero * sizeof(long));
+                   offset * sizeof(long));
                memmove(&scr->scr_chars[to], &scr->scr_chars[from],
-                   scr->scr_offset_to_zero * sizeof(uint32_t));
+                   offset * sizeof(uint32_t));
        }
        from = ri->ri_cols * srcrow + offset;
        to = ri->ri_cols * dstrow + offset;
        len = ri->ri_cols * nrows;
 
-#else
-       from = ri->ri_cols * srcrow;
-       to = ri->ri_cols * dstrow;
-       len = ri->ri_cols * nrows;
-#endif
        memmove(&scr->scr_attrs[to], &scr->scr_attrs[from],
            len * sizeof(long));
        memmove(&scr->scr_chars[to], &scr->scr_chars[from],
@@ -1148,18 +1122,11 @@
 {
        struct rasops_info *ri = cookie;
        struct vcons_screen *scr = ri->ri_hw;
+       int offset = vcons_offset_to_zero(scr);
        int start, end, i;
 
-#ifdef WSDISPLAY_SCROLLSUPPORT
-       int offset;
-       offset = scr->scr_offset_to_zero;
-
        start = ri->ri_cols * row + offset;
        end = ri->ri_cols * (row + nrows) + offset;
-#else
-       start = ri->ri_cols * row;
-       end = ri->ri_cols * (row + nrows);
-#endif
 
        for (i = start; i < end; i++) {
                scr->scr_attrs[i] = fillattr;
@@ -1217,26 +1184,15 @@
 {
        struct rasops_info *ri = cookie;
        struct vcons_screen *scr = ri->ri_hw;
+       int offset = vcons_offset_to_zero(scr);
        int pos;
 
-#ifdef WSDISPLAY_SCROLLSUPPORT
-       int offset;
-       offset = scr->scr_offset_to_zero;
-
        if ((row >= 0) && (row < ri->ri_rows) && (col >= 0) &&
             (col < ri->ri_cols)) {
                pos = col + row * ri->ri_cols;
                scr->scr_attrs[pos + offset] = attr;
                scr->scr_chars[pos + offset] = c;
        }
-#else
-       if ((row >= 0) && (row < ri->ri_rows) && (col >= 0) &&
-            (col < ri->ri_cols)) {
-               pos = col + row * ri->ri_cols;
-               scr->scr_attrs[pos] = attr;
-               scr->scr_chars[pos] = c;
-       }
-#endif
 
 #ifdef VCONS_DRAW_INTR
        atomic_inc_uint(&scr->scr_dirty);
@@ -1428,9 +1384,7 @@
        }
 
        offset = ri->ri_cols * wsc->row + wsc->col;
-#ifdef WSDISPLAY_SCROLLSUPPORT
-       offset += scr->scr_offset_to_zero;
-#endif
+       offset += vcons_offset_to_zero(scr);
        wsc->letter = scr->scr_chars[offset];
        attr = scr->scr_attrs[offset];
 
diff -r 4edab7d50d2c -r 37462d490e2d sys/dev/wscons/wsdisplay_vconsvar.h
--- a/sys/dev/wscons/wsdisplay_vconsvar.h       Sun Jul 17 10:27:45 2022 +0000
+++ b/sys/dev/wscons/wsdisplay_vconsvar.h       Sun Jul 17 10:28:09 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsdisplay_vconsvar.h,v 1.31 2021/01/21 21:45:42 macallan Exp $ */
+/*     $NetBSD: wsdisplay_vconsvar.h,v 1.32 2022/07/17 10:28:09 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -170,4 +170,14 @@
 void   vcons_disable_polling(struct vcons_data *);
 void   vcons_hard_switch(struct vcons_screen *);
 
+static inline int
+vcons_offset_to_zero(const struct vcons_screen *scr)
+{
+#ifdef WSDISPLAY_SCROLLSUPPORT
+       return scr->scr_offset_to_zero;
+#else
+       return 0;
+#endif
+}
+
 #endif /* _WSDISPLAY_VCONS_H_ */



Home | Main Index | Thread Index | Old Index