syscons - Partly implement FBIO_BLANK ioctl, for display powersaving.
authorImre Vadász <imre@vdsz.com>
Sat, 25 Nov 2017 17:25:54 +0000 (18:25 +0100)
committerImre Vadász <imre@vdsz.com>
Thu, 30 Nov 2017 21:55:28 +0000 (22:55 +0100)
* Only implement the parts relevant for display powersaving when a KMS
  graphics driver is loaded. Adjust the existing V_DISPLAY_* constant
  definitions to match the corresponding definitions in FreeBSD.

sys/dev/misc/syscons/blank/blank_saver.c
sys/dev/misc/syscons/fade/fade_saver.c
sys/dev/misc/syscons/scvidctl.c
sys/dev/misc/syscons/syscons.c
sys/dev/misc/syscons/syscons.h
sys/dev/video/fb/fbreg.h
sys/dev/video/fb/vga.c
sys/sys/fbio.h

index f581cd4..a878f94 100644 (file)
@@ -54,7 +54,7 @@ blank_saver(video_adapter_t *adp, int blank)
        }
 
        (*vidsw[adp->va_index]->blank_display)
-               (adp, blank ? V_DISPLAY_OFF : V_DISPLAY_ON);
+               (adp, blank ? V_DISPLAY_BLANK : V_DISPLAY_ON);
 
        blanked = blank;
 
index 5824b86..92bfe67 100644 (file)
@@ -72,7 +72,7 @@ fade_saver(video_adapter_t *adp, int blank)
                        }
                } else {
                        (*vidsw[adp->va_index]->blank_display)(adp,
-                                                              V_DISPLAY_OFF);
+                                                              V_DISPLAY_BLANK);
                }
        } else {
                if (ISPALAVAIL(adp->va_flags)) {
index ae29628..146d17e 100644 (file)
@@ -592,6 +592,23 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag)
        lwkt_reltoken(&tty_token);
        return ret;
 
+    case FBIO_BLANK:
+       if (scp != scp->sc->cur_scp) {
+           lwkt_reltoken(&tty_token);
+           return ENODEV;
+       }
+       if (scp->sc->fbi != NULL && ISGRAPHSC(scp)) {
+           if (*(int *)data == V_DISPLAY_ON)
+               sc_stop_scrn_saver(scp->sc);
+           else
+               sc_start_scrn_saver(scp->sc);
+           ret = 0;
+       } else {
+           ret = ENODEV;
+       }
+       lwkt_reltoken(&tty_token);
+       return ret;
+
     case FBIO_GETPALETTE:
     case FBIO_SETPALETTE:
     case FBIOPUTCMAP:
index 4bbc6b8..77f60f7 100644 (file)
@@ -2142,9 +2142,10 @@ scrn_timer(void *arg)
            run_scrn_saver = TRUE;
     }
 #if NSPLASH > 0
-    if ((saver_mode != CONS_LKM_SAVER) || !(sc->flags & SC_SCRN_IDLE))
-       if (sc->flags & SC_SCRN_BLANKED)
+    if ((saver_mode != CONS_LKM_SAVER) || !(sc->flags & SC_SCRN_IDLE)) {
+       if ((sc->flags & SC_SCRN_BLANKED) && !ISGRAPHSC(sc->cur_scp))
             stop_scrn_saver(sc, current_saver);
+    }
 #endif /* NSPLASH */
 
     /* should we just return ? */
@@ -2650,6 +2651,23 @@ restore_scrn_saver_mode(scr_stat *scp, int changemode)
     /* NOTREACHED */
 }
 
+void
+sc_start_scrn_saver(sc_softc_t *sc)
+{
+#if NSPLASH > 0
+    (*current_saver)(sc, TRUE);
+#endif
+}
+
+void
+sc_stop_scrn_saver(sc_softc_t *sc)
+{
+#if NSPLASH > 0
+    if (sc->flags & SC_SCRN_BLANKED)
+       stop_scrn_saver(sc, current_saver);
+#endif
+}
+
 static void
 stop_scrn_saver(sc_softc_t *sc, void (*saver)(sc_softc_t *, int))
 {
index a3c57a6..2fb7494 100644 (file)
@@ -524,6 +524,8 @@ void                sc_save_font(scr_stat *scp, int page, int size, u_char *font,
                             int base, int count);
 void           sc_show_font(scr_stat *scp, int page);
 
+void           sc_start_scrn_saver(sc_softc_t *sc);
+void           sc_stop_scrn_saver(sc_softc_t *sc);
 void           sc_touch_scrn_saver(void);
 void           sc_draw_cursor_image(scr_stat *scp);
 void           sc_remove_cursor_image(scr_stat *scp);
index b270429..5bb59fa 100644 (file)
@@ -63,10 +63,6 @@ typedef int vi_set_hw_cursor_t(video_adapter_t *adp, int col, int row);
 typedef int vi_set_hw_cursor_shape_t(video_adapter_t *adp, int base,
                                     int height, int celsize, int blink);
 typedef int vi_blank_display_t(video_adapter_t *adp, int mode);
-#define V_DISPLAY_ON           0
-#define V_DISPLAY_STAND_BY     (1<<0)
-#define V_DISPLAY_SUSPEND      (1<<1)
-#define V_DISPLAY_OFF          (1<<2)
 typedef int vi_mmap_t(video_adapter_t *adp, vm_offset_t offset, int prot);
 typedef int vi_ioctl_t(video_adapter_t *adp, u_long cmd, caddr_t data);
 typedef int vi_clear_t(video_adapter_t *adp);
index a4d8649..d69bf9c 100644 (file)
@@ -1678,7 +1678,7 @@ vga_blank_display(video_adapter_t *adp, int mode)
        val = inb(CRTC + 1);
        outb(CRTC + 1, val & ~0x80);
        break;
-    case V_DISPLAY_OFF:
+    case V_DISPLAY_BLANK:
        outb(TSIDX, 0x01);
        val = inb(TSREG);
        outb(TSIDX, 0x01);
index 0fe395b..e1264c3 100644 (file)
@@ -418,4 +418,12 @@ typedef struct video_color_palette video_color_palette_t;
 #define FBIO_GETPALETTE        _IOW('F', 113, video_color_palette_t)
 #define FBIO_SETPALETTE        _IOW('F', 114, video_color_palette_t)
 
+/* blank display */
+#define V_DISPLAY_ON           0
+#define V_DISPLAY_BLANK                1
+#define V_DISPLAY_STAND_BY     2
+#define V_DISPLAY_SUSPEND      3
+
+#define FBIO_BLANK     _IOW('F', 115, int)
+
 #endif /* !_SYS_FBIO_H_ */