Hi,

here comes a series of small diffs which add generic support for
keyboard backlights.

Please find below the first diff, which adds new ioctls to wskbd(4) to
control keyboard backlights.

In contrast to an earlier diff from jcs, I have chosen to use a struct
in favor of a simple (unsigned) int as depending on the vendor
(Thinkpad, Apple, ...) different min/max values for the brightness of
the keyboard backlight are possible.

Comments, OK?

Thanks,
Regards,
Joerg



Index: wsconsio.h
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wsconsio.h,v
retrieving revision 1.72
diff -u -p -r1.72 wsconsio.h
--- wsconsio.h  30 Aug 2015 10:05:09 -0000      1.72
+++ wsconsio.h  7 Dec 2015 21:03:45 -0000
@@ -180,6 +180,13 @@ struct wskbd_map_data {
 #define WSKBDIO_GETENCODING    _IOR('W', 15, kbd_t)
 #define WSKBDIO_SETENCODING    _IOW('W', 16, kbd_t)
 
+/* Get/set keyboard backlight.  Not applicable to all keyboard types. */
+struct wskbd_backlight {
+       unsigned int min, max, curval;
+};
+#define        WSKBDIO_GETBACKLIGHT    _IOR('W', 17, struct wskbd_backlight)
+#define        WSKBDIO_SETBACKLIGHT    _IOW('W', 18, struct wskbd_backlight)
+
 /* internal use only */
 #define WSKBDIO_SETMODE                _IOW('W', 19, int)
 #define WSKBDIO_GETMODE                _IOR('W', 20, int)
Index: wskbd.c
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wskbd.c,v
retrieving revision 1.82
diff -u -p -r1.82 wskbd.c
--- wskbd.c     10 Sep 2015 18:14:52 -0000      1.82
+++ wskbd.c     7 Dec 2015 21:03:45 -0000
@@ -230,6 +230,9 @@ int wskbd_mux_close(struct wsevsrc *);
 int    wskbd_do_open(struct wskbd_softc *, struct wseventvar *);
 int    wskbd_do_ioctl(struct device *, u_long, caddr_t, int, struct proc *);
 
+int    (*wskbd_get_backlight)(struct wskbd_backlight *);
+int    (*wskbd_set_backlight)(struct wskbd_backlight *);
+
 struct cfdriver wskbd_cd = {
        NULL, "wskbd", DV_TTY
 };
@@ -1010,6 +1013,7 @@ wskbd_displayioctl(struct device *dev, u
        case WSKBDIO_SETDEFAULTKEYREPEAT:
        case WSKBDIO_SETMAP:
        case WSKBDIO_SETENCODING:
+       case WSKBDIO_SETBACKLIGHT:
                if ((flag & FWRITE) == 0)
                        return (EACCES);
        }
@@ -1155,6 +1159,18 @@ getkeyrepeat:
                        wsmux_set_layout(sc->sc_base.me_parent, enc);
 #endif
                return (0);
+
+       case WSKBDIO_GETBACKLIGHT:
+               if (wskbd_get_backlight != NULL)
+                       return (*wskbd_get_backlight)((struct wskbd_backlight 
*)data);
+               error = ENOTTY;
+               break;
+
+       case WSKBDIO_SETBACKLIGHT:
+               if (wskbd_set_backlight != NULL)
+                       return (*wskbd_set_backlight)((struct wskbd_backlight 
*)data);
+               error = ENOTTY;
+               break;
        }
 
        /*

Reply via email to