Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Finally fix the blitting function.



details:   https://anonhg.NetBSD.org/src/rev/57537a2b5605
branches:  trunk
changeset: 369881:57537a2b5605
user:      nat <nat%NetBSD.org@localhost>
date:      Tue Sep 06 02:20:17 2022 +0000

description:
Finally fix the blitting function.

This means better performance for mostly static displays.
Full screen updates are still done five times a second.

Introduce a new variable sc_clear to force a full update.

diffstat:

 sys/dev/usb/udl.c |  69 ++++++++++++++----------------------------------------
 sys/dev/usb/udl.h |   3 +-
 2 files changed, 20 insertions(+), 52 deletions(-)

diffs (123 lines):

diff -r 647ebe295aa2 -r 57537a2b5605 sys/dev/usb/udl.c
--- a/sys/dev/usb/udl.c Tue Sep 06 01:44:24 2022 +0000
+++ b/sys/dev/usb/udl.c Tue Sep 06 02:20:17 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: udl.c,v 1.28 2022/05/17 05:05:20 andvar Exp $  */
+/*     $NetBSD: udl.c,v 1.29 2022/09/06 02:20:17 nat Exp $     */
 
 /*-
  * Copyright (c) 2009 FUKAUMI Naoki.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udl.c,v 1.28 2022/05/17 05:05:20 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udl.c,v 1.29 2022/09/06 02:20:17 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1822,21 +1822,12 @@
 udl_update_thread(void *v)
 {
        struct udl_softc *sc = v;
-       int stride;
-#ifdef notyet
-       bool update = false;
-       int linecount, x, y;
        uint16_t *fb, *fbcopy;
-       uint8_t *curfb;
-#else
-       uint16_t *fb;
-       int offs;
-#endif
+       int offs, stride, count = 0;
 
        mutex_enter(&sc->sc_thread_mtx);
 
        for (;;) {
-               stride = uimin(sc->sc_width, UDL_CMD_WIDTH_MAX - 8);
                if (sc->sc_dying == true) {
                        mutex_exit(&sc->sc_thread_mtx);
                        kthread_exit(0);
@@ -1845,49 +1836,25 @@
                if (sc->sc_thread_stop == true || sc->sc_fbmem == NULL)
                        goto thread_wait;
 
-#ifdef notyet
-               curfb = kmem_zalloc(UDL_FBMEM_SIZE(sc), KM_SLEEP);
-               memcpy(curfb, sc->sc_fbmem, sc->sc_height * sc->sc_width * 2);
-               fb = (uint16_t *)curfb;
+               if (sc->sc_clear == true)
+                       count = 0;
+               sc->sc_clear = false;
+
+               stride = uimin(sc->sc_width, UDL_CMD_WIDTH_MAX - 8);
+               stride /= 8;
+               fb = (uint16_t *)sc->sc_fbmem;
                fbcopy = (uint16_t *)sc->sc_fbmem_prev;
-               for (y = 0; y < sc->sc_height; y++) {
-                       linecount = 0;
-                       update = false;
-                       for (x = 0; x < sc->sc_width; x++) {
-                               if (linecount >= stride) {
-                                       udl_draw_line(sc, &fb[y * sc->sc_width
-                                           + x - linecount], y * sc->sc_width
-                                           + x - linecount, linecount);
-                                       linecount = 0;
-                                       update = false;
-                               }
-                               if (fb[y * sc->sc_width + x] ^ fbcopy[y *
-                                   sc->sc_width + x]) {
-                                       update = true;
-                                       linecount ++;
-                               } else if (update == true) {
-                                       udl_draw_line(sc, &fb[y * sc->sc_width
-                                           + x - linecount], y * sc->sc_width
-                                           + x - linecount, linecount);
-                                       linecount = 0;
-                                       update = false;
-                               }
-                       }
-                       if (linecount) {
-                               udl_draw_line(sc, &fb[y * sc->sc_width + x -
-                                   linecount], y * sc->sc_width  + x -
-                                   linecount, linecount);
+               for (offs = 0; offs < (sc->sc_height * sc->sc_width) - stride;
+                   offs += stride) {
+                       if (count % (hz / 5) == 0 || memcmp(&fb[offs],
+                           &fbcopy[offs], stride * sizeof(uint16_t)) != 0) {
+                               udl_draw_line(sc, &fb[offs], offs, stride);
+                               memcpy(&fbcopy[offs], &fb[offs], stride *
+                                  sizeof(uint16_t));
                        }
                }
-               memcpy(sc->sc_fbmem_prev, curfb, sc->sc_height * sc->sc_width
-                   * 2);
-               kmem_free(curfb, UDL_FBMEM_SIZE(sc));
-#else
-               fb = (uint16_t *)sc->sc_fbmem;
-               for (offs = 0; offs < sc->sc_height * sc->sc_width; offs += stride)
-                       udl_draw_line(sc, &fb[offs], offs, stride);
+               count++;
 
-#endif
 
                kpause("udlslp", false, (40 * hz)/1000 + 1, &sc->sc_thread_mtx);
                continue;
diff -r 647ebe295aa2 -r 57537a2b5605 sys/dev/usb/udl.h
--- a/sys/dev/usb/udl.h Tue Sep 06 01:44:24 2022 +0000
+++ b/sys/dev/usb/udl.h Tue Sep 06 02:20:17 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: udl.h,v 1.5 2019/09/14 15:24:23 maxv Exp $     */
+/*     $NetBSD: udl.h,v 1.6 2022/09/06 02:20:17 nat Exp $      */
 
 /*-
  * Copyright (c) 2009 FUKAUMI Naoki.
@@ -111,6 +111,7 @@
        device_t                 sc_wsdisplay;
        u_int                    sc_mode;
        u_int                    sc_blank;
+       bool                     sc_clear;
        uint8_t                  sc_nscreens;
 
        uint8_t                 *sc_fbmem;      /* framebuffer for X11 */



Home | Main Index | Thread Index | Old Index