Subject: Wsdisplay params in wsconsctl
To: None <tech-userlevel@NetBSD.org>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: tech-userlevel
Date: 02/24/2005 01:44:12
--5mCyUwZo2JvN/JJP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Attached is a patch to control brightness, contrast and backlight
through wsconsctl.  This is useful for hpc ports.  If there are no
objections I'll commit this.  One thing I'm not sure, is if we want to
group the wsdisplay params under one common parent node.

PS: Please keep me on Cc.

SY, Uwe
-- 
uwe@ptc.spbu.ru                         |       Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/            |       Ist zu Grunde gehen

--5mCyUwZo2JvN/JJP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="display.diff"

Index: display.c
===================================================================
RCS file: /cvsroot/src/sbin/wsconsctl/display.c,v
retrieving revision 1.9
diff -u -r1.9 display.c
--- display.c	19 Jan 2005 20:37:52 -0000	1.9
+++ display.c	21 Feb 2005 08:59:32 -0000
@@ -51,6 +51,9 @@
 static int border;
 static int dpytype;
 static struct wsdisplay_usefontdata font;
+static struct wsdisplay_param backlight;
+static struct wsdisplay_param brightness;
+static struct wsdisplay_param contrast;
 static struct wsdisplay_scroll_data scroll_l;
 static int msg_default_attrs, msg_default_bg, msg_default_fg;
 static int msg_kernel_attrs, msg_kernel_bg, msg_kernel_fg;
@@ -59,6 +62,9 @@
     { "border",			&border,	FMT_COLOR,	FLG_MODIFY },
     { "type",			&dpytype,	FMT_DPYTYPE,	FLG_RDONLY },
     { "font",			&font.name,	FMT_STRING,	FLG_WRONLY },
+    { "backlight",		&backlight.curval,  FMT_UINT,	FLG_MODIFY },
+    { "brightness",		&brightness.curval, FMT_UINT,	FLG_MODIFY },
+    { "contrast",		&contrast.curval,   FMT_UINT,	FLG_MODIFY },
     { "scroll.fastlines",	&scroll_l.fastlines, FMT_UINT, FLG_MODIFY },
     { "scroll.slowlines",	&scroll_l.slowlines, FMT_UINT, FLG_MODIFY },
     { "msg.default.attrs",	&msg_default_attrs, FMT_ATTRS,	FLG_MODIFY },
@@ -83,6 +89,24 @@
 		if (ioctl(fd, WSDISPLAYIO_GBORDER, &border) < 0)
 			field_disable_by_value(&border);
 	
+	if (field_by_value(&backlight.curval)->flags & FLG_GET) {
+		backlight.param = WSDISPLAYIO_PARAM_BACKLIGHT;
+		if (ioctl(fd, WSDISPLAYIO_GETPARAM, &backlight) < 0)
+			field_disable_by_value(&backlight.curval);
+	}
+
+	if (field_by_value(&brightness.curval)->flags & FLG_GET) {
+		brightness.param = WSDISPLAYIO_PARAM_BRIGHTNESS;
+		if (ioctl(fd, WSDISPLAYIO_GETPARAM, &brightness))
+			field_disable_by_value(&brightness.curval);
+	}
+
+	if (field_by_value(&contrast.curval)->flags & FLG_GET) {
+		contrast.param = WSDISPLAYIO_PARAM_CONTRAST;
+		if (ioctl(fd, WSDISPLAYIO_GETPARAM, &contrast))
+			field_disable_by_value(&contrast.curval);
+	}
+
 	if (field_by_value(&msg_default_attrs)->flags & FLG_GET ||
 	    field_by_value(&msg_default_bg)->flags & FLG_GET ||
 	    field_by_value(&msg_default_fg)->flags & FLG_GET ||
@@ -140,6 +164,24 @@
 		pr_field(field_by_value(&border), " -> ");
 	}
 
+	if (field_by_value(&backlight.curval)->flags & FLG_SET) {
+		backlight.param = WSDISPLAYIO_PARAM_BACKLIGHT;
+		ioctl(fd, WSDISPLAYIO_SETPARAM, &backlight);
+		pr_field(field_by_value(&backlight.curval), " -> ");
+	}
+
+	if (field_by_value(&brightness.curval)->flags & FLG_SET) {
+		brightness.param = WSDISPLAYIO_PARAM_BRIGHTNESS;
+		ioctl(fd, WSDISPLAYIO_SETPARAM, &brightness);
+		pr_field(field_by_value(&brightness.curval), " -> ");
+	}
+
+	if (field_by_value(&contrast.curval)->flags & FLG_SET) {
+		contrast.param = WSDISPLAYIO_PARAM_CONTRAST;
+		ioctl(fd, WSDISPLAYIO_SETPARAM, &contrast);
+		pr_field(field_by_value(&contrast.curval), " -> ");
+	}
+
 	if (field_by_value(&msg_default_attrs)->flags & FLG_SET ||
 	    field_by_value(&msg_default_bg)->flags & FLG_SET ||
 	    field_by_value(&msg_default_fg)->flags & FLG_SET ||

--5mCyUwZo2JvN/JJP--