Subject: Re: blank_screen patch for Laptops (Questions)

From: [email-masked] (James H. Cloos Jr.)
Date: Sat, 19 Mar 1994 11:09:30 GMT

I was waiting on this until I finished it, but I thought I should
followup now anyway.

I had previously hacked version 99.14 to turn off my backlight at
timeout, and leave it on when graphics mode was activated.

I decided to do a cleaner mod for 1.0.

The following patch to drivers/char/console.c and include/linux/tty.h
adds the beginings of support for a user space daemon that can
function as a general screen saver--whether than means controllong the
backlight, or wastings cpu time on a fireworks display ;-) or
whatever.

What I need to do is add an ioclt to register the pid of said daemon
so that the kernel can signal it.  

I also want to request comments on the signals to send to the daemon,
and whether some heuristic is needed to confirm the pid still existst.

I expect the daemon to set up its signal handlers, call the as-yet-
to-be-added ioclt to register itself, and wait for signals.  The
handler for SIGTERM &c should call the ioclt to unregister itself.

Comments?

========================================
diff -u linux/drivers/char/console.c_1.0 linux/drivers/char/console.c
--- linux/drivers/char/console.c_1.0	Wed Feb 23 01:52:24 1994
+++ linux/drivers/char/console.c	Thu Mar 17 04:29:57 1994
@@ -14,6 +14,8 @@
  * 	'void update_screen(int new_console)'
  * 	'void blank_screen(void)'
  * 	'void unblank_screen(void)'
+ * 	'void user_blank_screen(void)'
+ * 	'void user_unblank_screen(void)'
  *
  *      'int  con_get_font(char *)' 
  *      'int  con_set_font(char *)' 
@@ -35,6 +37,9 @@
  * Code to check for different video-cards mostly by Galen Hunt,
  * <[email-masked]>
  *
+ * user_{un}?blank_screen() Copyright 1994 by James H. Cloos, Jr.
+ * <[email-masked]>
+ *
  */
 
 #define CAN_LOAD_EGA_FONTS    /* undefine if the user must not do this */
@@ -148,6 +153,7 @@
 unsigned short *vc_scrbuf[NR_CONSOLES];
 static unsigned short * vc_scrmembuf;
 static int console_blanked = 0;
+static int user_blank_pid = 0;
 
 #define origin		(vc_cons[currcons].vc_origin)
 #define scr_end		(vc_cons[currcons].vc_scr_end)
@@ -1402,7 +1408,7 @@
 	video_page = ORIG_VIDEO_PAGE;
 	screen_size = (video_num_lines * video_size_row);
 	kmem_start += NR_CONSOLES * screen_size;
-	timer_table[BLANK_TIMER].fn = blank_screen;
+	timer_table[BLANK_TIMER].fn = user_blank_screen;
 	timer_table[BLANK_TIMER].expires = 0;
 	if (blankinterval) {
 		timer_table[BLANK_TIMER].expires = jiffies+blankinterval;
@@ -1550,18 +1556,31 @@
 {
 	if (console_blanked)
 		return;
-	timer_table[BLANK_TIMER].fn = unblank_screen;
+	timer_table[BLANK_TIMER].fn = user_unblank_screen;
 	get_scrmem(fg_console);
 	hide_cursor();
 	console_blanked = 1;
 	memsetw((void *)video_mem_base, 0x0020, video_mem_term-video_mem_base );
 }
 
+void user_blank_screen(void)
+{
+	if (console_blanked)
+		return;
+	blank_screen();
+#if 0
+/* we want to send SIGUSR1 to the registered process, if any. */
+/* perhaps SIGCONT would be better?                           */
+	if (user_blank_pid)
+		(void) kill_proc(user_blank_pid,SIGUSR1,1);
+#endif
+}
+
 void unblank_screen(void)
 {
 	if (!console_blanked)
 		return;
-	timer_table[BLANK_TIMER].fn = blank_screen;
+	timer_table[BLANK_TIMER].fn = user_blank_screen;
 	if (blankinterval) {
 		timer_table[BLANK_TIMER].expires = jiffies + blankinterval;
 		timer_active |= 1<<BLANK_TIMER;
@@ -1572,6 +1591,19 @@
 	set_cursor(fg_console);
 }
 
+void user_unblank_screen(void)
+{
+	if (!console_blanked)
+		return;
+	unblank_screen();
+#if 0
+/* we want to send SIGUSR2 to the registered process, if any. */
+/* perhaps SIGSTOP would be better?                           */
+	if (user_blank_pid)
+		(void) kill_proc(user_blank_pid,SIGUSR2,1);
+#endif
+}
+
 void update_screen(int new_console)
 {
 	static int lock = 0;
@@ -1671,7 +1703,7 @@
 	int i, ps, pe;
 	char *off = (char *)origin - hwscroll_offset;
 
-	unblank_screen();
+	user_unblank_screen();
 	args = (unsigned short *)(arg + 1);
 	xs = get_fs_word(args++) - 1;
 	ys = get_fs_word(args++) - 1;
@@ -1805,7 +1837,7 @@
 
 	if (! *bp)
 		return 0;
-	unblank_screen();
+	user_unblank_screen();
 	while (*bp) {
 		put_tty_queue(*bp, &tty->read_q);
 		bp++;

diff finished at Sat Mar 19 05:56:30
diff -u linux/include/linux/tty.h-1.0 linux/include/linux/tty.h
--- linux/include/linux/tty.h-1.0	Fri Feb 18 04:08:41 1994
+++ linux/include/linux/tty.h	Thu Mar 17 04:30:52 1994
@@ -438,7 +438,9 @@
 extern int con_open(struct tty_struct * tty, struct file * filp);
 extern void update_screen(int new_console);
 extern void blank_screen(void);
+extern void user_blank_screen(void);
 extern void unblank_screen(void);
+extern void user_unblank_screen(void);
 
 /* vt.c */

diff finished at Sat Mar 19 05:58:01

=====================================
--
James H. Cloos, Jr.	include <std/qotd>
[email-masked]	include <std/disclaimers.h>
([email-masked])		Snail:	POBox 1111, Amherst, NY 14226-1111
Finger for pgp pub key.	Phone:	+1 716 673-1250 (machine now; fax eventually)