bug-hurd
[Top][All Lists]
Advanced

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

Re: Patch for setting the keyboard LEDs state


From: Marco Gerards
Subject: Re: Patch for setting the keyboard LEDs state
Date: 30 Jan 2004 19:21:15 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de> writes:

> BTW, the changelog entry has the dirname in it.  For subdir changelogs this
> isn't needed.

Right, I forgot the Hurd has subdir changelogs.  I've changed this.

> Then I think you lacked a changelog entry for it.  I didn't check that part
> of the patch, check it in if you verified it - how does it come it doesn't
> allocate the keyboard buffer twice with your change?  (Ie, you add an
> allocation at an earlier place, why isn't it allocated a second time in the
> place where it used to be allocated?)

I had this changelog entry:
        * i386/i386at/kd.c (kdinit): Initialize the input buffer.

Or is there something wrong with this?

The ttychars call checks if the tty is not initialized yet with:

if ((tp->t_flags & TS_INIT) == 0) {
  ...
  tp->t_state |= TS_INIT;
}

> > > If you have done the above, you can check in the LED patches.
> > 
> > Before doing that I will send the patch to bug-hurd first because both
> > Alfred and Roland asked me.
> 
> Sure.

And here it is.

In a few minutes I will update the patch on savannah as well.

Thanks,
Marco


2004-01-30  Marco Gerards  <metgerards@student.han.nl>

        * i386/i386at/kd.c (kdinit): Initialize the input buffer.

        * i386/i386at/kd.h (KDSETLEDS): New macro.
        * i386/i386at/kd_event.c (kbdsetstat): Handle KDSETLEDS here to
        set the keyboard LEDs state.


Index: i386/i386at/kd.c
===================================================================
RCS file: /cvsroot/hurd/gnumach/i386/i386at/Attic/kd.c,v
retrieving revision 1.5
diff -u -p -r1.5 kd.c
--- i386/i386at/kd.c    17 Aug 2001 23:46:24 -0000      1.5
+++ i386/i386at/kd.c    29 Jan 2004 00:47:55 -0000
@@ -1244,6 +1244,9 @@ kdinit()
                                           enable the keyboard controller.
                                           This keeps NUM-LOCK from being
                                           set on the NEC Versa. */
+
+       /* Allocate the input buffer.  */
+       ttychars(&kd_tty);
 }
 
 /*
Index: i386/i386at/kd.h
===================================================================
RCS file: /cvsroot/hurd/gnumach/i386/i386at/Attic/kd.h,v
retrieving revision 1.3
diff -u -p -r1.3 kd.h
--- i386/i386at/kd.h    17 Aug 2001 23:46:24 -0000      1.3
+++ i386/i386at/kd.h    29 Jan 2004 00:47:56 -0000
@@ -640,6 +640,8 @@ extern      int     kb_mode;
 #define KDGKBDTYPE     _IOR('K', 2, int)       /* get keyboard type */
 #define KB_VANILLAKB   0
 
+#define KDSETLEDS      _IOW('K', 5, int)       /* set the keyboard ledstate */
+
 struct X_kdb {
        u_int *ptr;
        u_int size;
Index: i386/i386at/kd_event.c
===================================================================
RCS file: /cvsroot/hurd/gnumach/i386/i386at/Attic/kd_event.c,v
retrieving revision 1.3
diff -u -p -r1.3 kd_event.c
--- i386/i386at/kd_event.c      5 Apr 2001 06:39:21 -0000       1.3
+++ i386/i386at/kd_event.c      29 Jan 2004 00:47:57 -0000
@@ -210,6 +210,11 @@ io_return_t kbdsetstat(dev, flavor, data
                /* XXX - what to do about unread events? */
                /* XXX - should check that 'data' contains an OK valud */
                break;
+          case KDSETLEDS:
+               if (count != 1)
+                   return (D_INVALID_OPERATION);
+               kd_setleds1 (*data);
+               break;
            case K_X_KDB_ENTER:
                return X_kdb_enter_init(data, count);
            case K_X_KDB_EXIT:




2004-01-30  Marco Gerards  <metgerards@student.han.nl>

        * pc-kbd.c (KDSETLEDS): New macro.
        (update_leds): Add support for setting the keyboard LED state on
        GNUMach 1.x (> 1.3).

        (input_loop): Use size_t for `nr' instead of int to silence a gcc
        warning.



Index: console-client/pc-kbd.c
===================================================================
RCS file: /cvsroot/hurd/hurd/console-client/pc-kbd.c,v
retrieving revision 1.8
diff -u -p -r1.8 pc-kbd.c
--- console-client/pc-kbd.c     5 May 2003 21:39:22 -0000       1.8
+++ console-client/pc-kbd.c     30 Jan 2004 17:47:03 -0000
@@ -1,5 +1,5 @@
 /* pc-kbd.c - The PC Keyboard input driver.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
    Written by Marcus Brinkmann.
 
    This file is part of the GNU Hurd.
@@ -634,6 +634,9 @@ typedef struct {
 #define KDGKBDTYPE      _IOR('K', 2, int)       /* get keyboard type */
 #define KB_VANILLAKB    0
 
+#define KDSETLEDS      _IOW('K', 5, int)        /* set keyboard leds */
+
+
 /* End of Mach code.  */
 
 static enum scancode
@@ -676,22 +679,33 @@ gnumach_v1_input_next ()
 static void
 update_leds (void)
 {
-  char leds[2];
   error_t err;
-
-  /* GNU Mach v1 does not support setting the keyboard LEDs.  */
+  
   if (gnumach_v1_compat)
-    return;
+    {
+      int led = (led_state.scroll_lock ? 1 : 0)
+       | (led_state.num_lock ? 2 : 0)
+       | (led_state.caps_lock ? 4 : 0);
+      
+      err = device_set_status (kbd_dev, KDSETLEDS, &led, 1);
+      /* Just ignore the error, GNUMach 1.3 and older cannot set the
+        keyboard LEDs.  */
+    }
+  else
+    {
+      char leds[2];
+      mach_msg_type_number_t data_cnt = 2;
 
-  leds[0] = '\xed';
-  leds[1] = (led_state.scroll_lock ? 1 : 0)
-    | (led_state.num_lock ? 2 : 0)
-    | (led_state.caps_lock ? 4 : 0);
-  mach_msg_type_number_t data_cnt = 2;
-  err = device_write_inband (kbd_dev, 0, -1, (void *) leds, 2, &data_cnt);
-  if (!err && data_cnt == 1)
-    err = device_write_inband (kbd_dev, 0, -1, (void *) &leds[1], 1,
-                              &data_cnt);
+      leds[0] = '\xed';
+      leds[1] = (led_state.scroll_lock ? 1 : 0)
+       | (led_state.num_lock ? 2 : 0)
+       | (led_state.caps_lock ? 4 : 0);
+      
+      err = device_write_inband (kbd_dev, 0, -1, (void *) leds, 2, &data_cnt);
+      if (!err && data_cnt == 1)
+       err = device_write_inband (kbd_dev, 0, -1, (void *) &leds[1], 1,
+                                  &data_cnt);
+    }
 }
 
 static enum scancode
@@ -1014,7 +1028,7 @@ input_loop (any_t unused)
                      size_t left = sizeof (buf) - size;
                      char *inbuf = (char *) &state.direct;
                      size_t inbufsize = sizeof (wchar_t);
-                     int nr;
+                     size_t nr;
                      
                      nr = iconv (cd, &inbuf, &inbufsize, &buffer, &left);
                      if (nr == (size_t) -1)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]