Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Add a way for machine-dependent code to tell a USB c...



details:   https://anonhg.NetBSD.org/src/rev/6c837eb7c3ae
branches:  trunk
changeset: 472771:6c837eb7c3ae
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu May 06 19:12:22 1999 +0000

description:
Add a way for machine-dependent code to tell a USB controller that it
has the console input device.  The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.

diffstat:

 sys/dev/pci/ohci_pci.c |  25 ++++++++++++++++++++++++-
 sys/dev/pci/uhci_pci.c |  25 ++++++++++++++++++++++++-
 sys/dev/usb/ukbd.c     |  30 ++++++++++++++++++++++++++++--
 sys/dev/usb/usbdivar.h |   3 ++-
 4 files changed, 78 insertions(+), 5 deletions(-)

diffs (175 lines):

diff -r 6ccb23349e69 -r 6c837eb7c3ae sys/dev/pci/ohci_pci.c
--- a/sys/dev/pci/ohci_pci.c    Thu May 06 19:11:02 1999 +0000
+++ b/sys/dev/pci/ohci_pci.c    Thu May 06 19:12:22 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci_pci.c,v 1.6 1998/12/27 13:03:58 augustss Exp $    */
+/*     $NetBSD: ohci_pci.c,v 1.7 1999/05/06 19:12:22 thorpej Exp $     */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -70,6 +70,13 @@
        sizeof(struct ohci_softc), ohci_pci_match, ohci_pci_attach
 };
 
+struct {
+       pcitag_t        tag;
+       int             valid;
+} ohci_pci_console_info;
+
+void ohci_pci_has_console __P((pcitag_t));
+
 int
 ohci_pci_match(parent, match, aux)
        struct device *parent;
@@ -152,6 +159,22 @@
                return;
        }
 
+       if (ohci_pci_console_info.valid &&
+           memcmp(&ohci_pci_console_info.tag, &pa->pa_tag,
+                  sizeof(pcitag_t)) == 0)
+               sc->sc_bus.has_console = 1;
+       else
+               sc->sc_bus.has_console = 0;
+
        /* Attach usb device. */
        config_found((void *)sc, &sc->sc_bus, usbctlprint);
 }
+
+void
+ohci_pci_has_console(tag)
+       pcitag_t tag;
+{
+
+       ohci_pci_console_info.tag = tag;
+       ohci_pci_console_info.valid = 1;
+}
diff -r 6ccb23349e69 -r 6c837eb7c3ae sys/dev/pci/uhci_pci.c
--- a/sys/dev/pci/uhci_pci.c    Thu May 06 19:11:02 1999 +0000
+++ b/sys/dev/pci/uhci_pci.c    Thu May 06 19:12:22 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhci_pci.c,v 1.4 1998/11/25 22:32:04 augustss Exp $    */
+/*     $NetBSD: uhci_pci.c,v 1.5 1999/05/06 19:12:22 thorpej Exp $     */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -63,6 +63,13 @@
        sizeof(uhci_softc_t), uhci_pci_match, uhci_pci_attach
 };
 
+struct {
+       pcitag_t        tag;
+       int             valid;
+} uhci_pci_console_info;
+
+void uhci_pci_has_console __P((pcitag_t));
+
 int
 uhci_pci_match(parent, match, aux)
        struct device *parent;
@@ -158,6 +165,22 @@
                return;
        }
 
+       if (uhci_pci_console_info.valid &&
+           memcmp(&uhci_pci_console_info.tag, &pa->pa_tag,
+                  sizeof(pcitag_t)) == 0)
+               sc->sc_bus.has_console = 1;
+       else
+               sc->sc_bus.has_console = 0;
+
        /* Attach usb device. */
        config_found((void *)sc, &sc->sc_bus, usbctlprint);
 }
+
+void
+uhci_pci_has_console(tag)
+       pcitag_t tag;
+{
+
+       uhci_pci_console_info.tag = tag;
+       uhci_pci_console_info.valid = 1;
+}
diff -r 6ccb23349e69 -r 6c837eb7c3ae sys/dev/usb/ukbd.c
--- a/sys/dev/usb/ukbd.c        Thu May 06 19:11:02 1999 +0000
+++ b/sys/dev/usb/ukbd.c        Thu May 06 19:12:22 1999 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: ukbd.c,v 1.28 1999/01/13 18:38:26 augustss Exp $        */
+/*      $NetBSD: ukbd.c,v 1.29 1999/05/06 19:12:23 thorpej Exp $        */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,6 +64,7 @@
 #include <dev/usb/usbhid.h>
 #include <dev/usb/usbdi.h>
 #include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbdivar.h>
 #include <dev/usb/usbdevs.h>
 #include <dev/usb/usb_quirks.h>
 #include <dev/usb/hid.h>
@@ -189,6 +190,8 @@
        char sc_enabled;
        char sc_disconnected;           /* device is gone */
 
+       int sc_console_keyboard;        /* we are the console keyboard */
+
        int sc_leds;
 #if defined(__NetBSD__)
        struct device *sc_wskbddev;
@@ -328,8 +331,23 @@
        sc->sc_ep_addr = ed->bEndpointAddress;
        sc->sc_disconnected = 0;
 
+       /*
+        * Remember if we're the console keyboard.
+        *
+        * XXX This always picks the first keyboard on the bus, but
+        * what else can we really do?
+        */
+       sc->sc_console_keyboard = uaa->device->bus->has_console;
+       if (sc->sc_console_keyboard) {
+               /* Don't let any other keyboard have it. */
+               uaa->device->bus->has_console = 0;
+       }
+
 #if defined(__NetBSD__)
-       a.console = 0;
+       if (sc->sc_console_keyboard)
+               ukbd_cnattach(sc);
+
+       a.console = sc->sc_console_keyboard;
 
        a.keymap = &ukbd_keymapdata;
 
@@ -390,6 +408,14 @@
        DPRINTF(("ukbd_disco: sc=%p\n", sc));
        usbd_abort_pipe(sc->sc_intrpipe);
        sc->sc_disconnected = 1;
+
+       if (sc->sc_console_keyboard) {
+               /*
+                * XXX Should probably disconnect our consops,
+                * XXX and set has_console in the bus handle back
+                * XXX to 1.
+                */
+       }
 }
 
 int
diff -r 6ccb23349e69 -r 6c837eb7c3ae sys/dev/usb/usbdivar.h
--- a/sys/dev/usb/usbdivar.h    Thu May 06 19:11:02 1999 +0000
+++ b/sys/dev/usb/usbdivar.h    Thu May 06 19:12:22 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdivar.h,v 1.17 1999/01/10 19:13:16 augustss Exp $   */
+/*     $NetBSD: usbdivar.h,v 1.18 1999/05/06 19:12:23 thorpej Exp $    */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -85,6 +85,7 @@
        usbd_status           (*open_pipe)__P((struct usbd_pipe *pipe));
        u_int32_t               pipe_size; /* size of a pipe struct */
        void                  (*do_poll)__P((struct usbd_bus *));
+       int                     has_console; /* console input on this bus */
        /* Filled by usb driver */
        struct usbd_device     *root_hub;
        usbd_device_handle      devices[USB_MAX_DEVICES];



Home | Main Index | Thread Index | Old Index