Source-Changes-HG archive

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

[src/trunk]: src/sys Add a command to layer 1 drivers to update LED state for...



details:   https://anonhg.NetBSD.org/src/rev/ee7267e420e5
branches:  trunk
changeset: 524782:ee7267e420e5
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Mar 30 17:54:17 2002 +0000

description:
Add a command to layer 1 drivers to update LED state for controllers that
have status LEDs.

diffstat:

 sys/dev/ic/isic_l1.c                   |  18 ++++++++++++---
 sys/dev/ic/isic_l1.h                   |   4 ++-
 sys/dev/isapnp/isic_isapnp_elsa_qs1i.c |  37 ++++++++++++++++++++++++++++++++-
 sys/netisdn/i4b_global.h               |  10 ++++++++-
 sys/netisdn/i4b_l4if.c                 |  35 ++++++++++++++++++++++++++++---
 sys/netisdn/i4b_q931.c                 |   8 +++---
 6 files changed, 96 insertions(+), 16 deletions(-)

diffs (truncated from 328 to 300 lines):

diff -r 5a226114d63e -r ee7267e420e5 sys/dev/ic/isic_l1.c
--- a/sys/dev/ic/isic_l1.c      Sat Mar 30 17:10:31 2002 +0000
+++ b/sys/dev/ic/isic_l1.c      Sat Mar 30 17:54:17 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isic_l1.c,v 1.4 2002/03/24 20:35:46 martin Exp $ */
+/* $NetBSD: isic_l1.c,v 1.5 2002/03/30 17:54:17 martin Exp $ */
 
 /*
  * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isic_l1.c,v 1.4 2002/03/24 20:35:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isic_l1.c,v 1.5 2002/03/30 17:54:17 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/ioctl.h>
@@ -219,17 +219,24 @@
 isic_std_mph_command_req(isdn_layer1token token, int command, void *parm)
 {
        struct isic_softc *sc = (struct isic_softc*)token;
-       
+       int pass_down = 0;
+
        switch(command)
        {
                case CMR_DOPEN:         /* daemon running */
                        NDBGL1(L1_PRIM, "%s, command = CMR_DOPEN", sc->sc_dev.dv_xname);
-                       sc->sc_enabled = 1;                     
+                       sc->sc_enabled = 1;
+                       pass_down = 1;
                        break;
                        
                case CMR_DCLOSE:        /* daemon not running */
                        NDBGL1(L1_PRIM, "%s, command = CMR_DCLOSE", sc->sc_dev.dv_xname);
                        sc->sc_enabled = 0;
+                       pass_down = 1;
+                       break;
+
+               case CMR_SETLEDS:
+                       pass_down = 1;
                        break;
 
                case CMR_SETTRACE:
@@ -242,6 +249,9 @@
                        break;
        }
 
+       if (pass_down && sc->drv_command != NULL)
+               sc->drv_command(sc, command, parm);
+
        return(0);
 }
 
diff -r 5a226114d63e -r ee7267e420e5 sys/dev/ic/isic_l1.h
--- a/sys/dev/ic/isic_l1.h      Sat Mar 30 17:10:31 2002 +0000
+++ b/sys/dev/ic/isic_l1.h      Sat Mar 30 17:54:17 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isic_l1.h,v 1.7 2002/03/27 07:39:37 martin Exp $ */
+/* $NetBSD: isic_l1.h,v 1.8 2002/03/30 17:54:17 martin Exp $ */
 
 /*
  * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
@@ -265,6 +265,8 @@
        void            (*writefifo) __P((struct isic_softc *sc, int what, const void *data, size_t size));
        void            (*clearirq) __P((struct isic_softc *sc));
 
+       void            (*drv_command) __P((struct isic_softc *sc, int cmd, void *data));
+
 #define        ISAC_READ(r)            (*sc->readreg)(sc, ISIC_WHAT_ISAC, (r))
 #define        ISAC_WRITE(r,v)         (*sc->writereg)(sc, ISIC_WHAT_ISAC, (r), (v))
 #define        ISAC_RDFIFO(b,s)        (*sc->readfifo)(sc, ISIC_WHAT_ISAC, (b), (s))
diff -r 5a226114d63e -r ee7267e420e5 sys/dev/isapnp/isic_isapnp_elsa_qs1i.c
--- a/sys/dev/isapnp/isic_isapnp_elsa_qs1i.c    Sat Mar 30 17:10:31 2002 +0000
+++ b/sys/dev/isapnp/isic_isapnp_elsa_qs1i.c    Sat Mar 30 17:54:17 2002 +0000
@@ -27,14 +27,14 @@
  *     isic - I4B Siemens ISDN Chipset Driver for ELSA Quickstep 1000pro ISA
  *     =====================================================================
  *
- *     $Id: isic_isapnp_elsa_qs1i.c,v 1.4 2002/03/24 20:35:51 martin Exp $
+ *     $Id: isic_isapnp_elsa_qs1i.c,v 1.5 2002/03/30 17:54:17 martin Exp $
  *
  *      last edit-date: [Fri Jan  5 11:38:29 2001]
  *
  *---------------------------------------------------------------------------*/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isic_isapnp_elsa_qs1i.c,v 1.4 2002/03/24 20:35:51 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isic_isapnp_elsa_qs1i.c,v 1.5 2002/03/30 17:54:17 martin Exp $");
 
 #include "opt_isicpnp.h"
 #if defined(ISICPNP_ELSA_QS1ISA) || defined(ISICPNP_ELSA_PCC16)
@@ -86,6 +86,7 @@
 #else
 static void i4b_eq1i_clrirq(struct isic_softc *sc);
 void isic_attach_Eqs1pi __P((struct isic_softc *sc));
+static void elsa_command_req(struct isic_softc *sc, int command, void *data);
 #endif
 
 /* masks for register encoded in base addr */
@@ -463,6 +464,36 @@
 
 #else /* !__FreeBSD__ */
 
+static void
+elsa_command_req(struct isic_softc *sc, int command, void *data)
+{
+       int v, s;
+       u_int8_t led_val;
+
+       if (command != CMR_SETLEDS)
+               return;
+
+       s = splnet();
+
+       led_val = ELSA_CTRL_SECRET;
+       v = (int)data;
+       if (v & CMRLEDS_TEI)
+               led_val |= ELSA_CTRL_LED_GREEN;
+       if (v & (CMRLEDS_B0|CMRLEDS_B1))
+               led_val |= ELSA_CTRL_LED_YELLOW;
+
+       /* XXX - this does not work, no idea why yet */
+#if 0
+       printf("%s: LED change, writing 0x%02x to ctrl port\n",
+           sc->sc_dev.dv_xname, led_val);
+
+        bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h,
+           ELSA_OFF_CTRL, led_val);
+#endif
+
+       splx(s);
+}
+
 void
 isic_attach_Eqs1pi(struct isic_softc *sc)
 {
@@ -488,6 +519,8 @@
        sc->readfifo = eqs1pi_read_fifo;
        sc->writefifo = eqs1pi_write_fifo;
 
+       sc->drv_command = elsa_command_req;
+
        /* setup card type */
        
        sc->sc_cardtyp = CARD_TYPEP_ELSAQS1ISA;
diff -r 5a226114d63e -r ee7267e420e5 sys/netisdn/i4b_global.h
--- a/sys/netisdn/i4b_global.h  Sat Mar 30 17:10:31 2002 +0000
+++ b/sys/netisdn/i4b_global.h  Sat Mar 30 17:54:17 2002 +0000
@@ -27,7 +27,7 @@
  *     i4b_global.h - i4b global include file
  *     --------------------------------------
  *
- *     $Id: i4b_global.h,v 1.3 2001/03/24 12:40:31 martin Exp $
+ *     $Id: i4b_global.h,v 1.4 2002/03/30 17:54:18 martin Exp $
  *
  * $FreeBSD$
  *
@@ -137,5 +137,13 @@
 #define CMR_SETTRACE   2       /* set D-channel and B-channel trace    */
 #define CMR_GCST       3       /* get chipset statistics               */
 #define CMR_CCST       4       /* clear chipset statistics             */
+#define        CMR_SETLEDS     5       /* set LEDs (if available)              */
+
+/* param for CMR_SETLEDS: */
+#define        CMRLEDS_TEI     1       /* this controller has a TEI */
+#define        CMRLEDS_B0      2       /* first B channel is in use */
+#define        CMRLEDS_B0_IN   4       /* first B channel handles an incoming call */
+#define        CMRLEDS_B1      8       /* second B channel is in use */
+#define        CMRLEDS_B1_IN   16      /* second B channel handles an incoming call */
 
 #endif /* _I4B_GLOBAL_H_ */
diff -r 5a226114d63e -r ee7267e420e5 sys/netisdn/i4b_l4if.c
--- a/sys/netisdn/i4b_l4if.c    Sat Mar 30 17:10:31 2002 +0000
+++ b/sys/netisdn/i4b_l4if.c    Sat Mar 30 17:54:17 2002 +0000
@@ -27,7 +27,7 @@
  *     i4b_l4if.c - Layer 3 interface to Layer 4
  *     -------------------------------------------
  *
- *     $Id: i4b_l4if.c,v 1.9 2002/03/30 11:43:33 martin Exp $ 
+ *     $Id: i4b_l4if.c,v 1.10 2002/03/30 17:54:18 martin Exp $ 
  *
  * $FreeBSD$
  *
@@ -36,7 +36,7 @@
  *---------------------------------------------------------------------------*/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i4b_l4if.c,v 1.9 2002/03/30 11:43:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i4b_l4if.c,v 1.10 2002/03/30 17:54:18 martin Exp $");
 
 #ifdef __FreeBSD__
 #include "i4bq931.h"
@@ -85,6 +85,8 @@
 void n_alert_request(struct call_desc *cd);
 void n_mgmt_command(struct isdn_l3_driver *drv, int cmd, void *parm);
 
+static void update_controller_leds(struct isdn_l3_driver *d);
+
 /*---------------------------------------------------------------------------*
  *     i4b_mdl_status_ind - status indication from lower layers
  *---------------------------------------------------------------------------*/
@@ -92,7 +94,7 @@
 i4b_mdl_status_ind(int bri, int status, int parm)
 {
        struct isdn_l3_driver *d = NULL;
-       int sendup;
+       int sendup, update_leds = 0;
        int i;
        
        NDBGL3(L3_MSG, "bri = %d, status = %d, parm = %d", bri, status, parm);
@@ -109,11 +111,13 @@
 
                case STI_L1STAT:
                        i4b_l4_l12stat(bri, 1, parm);
+                       update_leds = 1;
                        NDBGL3(L3_MSG, "STI_L1STAT: bri %d layer 1 = %s", bri, status ? "up" : "down");
                        break;
                        
                case STI_L2STAT:
                        i4b_l4_l12stat(bri, 2, parm);
+                       update_leds = 1;
                        NDBGL3(L3_MSG, "STI_L2STAT: bri %d layer 2 = %s", bri, status ? "up" : "down");
                        break;
 
@@ -121,6 +125,7 @@
                        d = isdn_find_l3_by_bri(bri);
                        d->tei = parm;
                        i4b_l4_teiasg(bri, parm);
+                       update_leds = 1;
                        NDBGL3(L3_MSG, "STI_TEIASG: bri %d TEI = %d = 0x%02x", bri, parm, parm);
                        break;
 
@@ -128,6 +133,7 @@
                        NDBGL3(L3_ERR, "STI_PDEACT: bri %d TEI = %d = 0x%02x", bri, parm, parm);
                        d = isdn_find_l3_by_bri(bri);
 
+                       update_leds = 1;
                        sendup = 0;
 
                        for(i=0; i < num_call_desc; i++)
@@ -155,6 +161,7 @@
                case STI_NOL1ACC:       /* no outgoing access to S0 */
                        NDBGL3(L3_ERR, "STI_NOL1ACC: bri %d no outgoing access to S0", bri);
                        d = isdn_find_l3_by_bri(bri);
+                       update_leds = 1;
 
                        for(i=0; i < num_call_desc; i++)
                        {
@@ -178,10 +185,29 @@
                default:
                        NDBGL3(L3_ERR, "ERROR, bri %d, unknown status value %d!", bri, status);
                        break;
-       }               
+       }
+
+       if (update_leds && d != NULL)
+               update_controller_leds(d);
+
        return(0);
 }
 
+static void
+update_controller_leds(struct isdn_l3_driver *d)
+{
+       int leds = 0;
+
+       if (d->tei != -1)
+               leds |= CMRLEDS_TEI;
+       if (d->bch_state[CHAN_B1] != BCH_ST_FREE)
+               leds |= CMRLEDS_B0;
+       if (d->bch_state[CHAN_B2] != BCH_ST_FREE)
+               leds |= CMRLEDS_B1;
+
+       d->l3driver->N_MGMT_COMMAND(d, CMR_SETLEDS, (void*)leds);
+}
+
 /*---------------------------------------------------------------------------*
  *     send command to the lower layers
  *---------------------------------------------------------------------------*/
@@ -272,6 +298,7 @@
        {
                d->bch_state[cd->channelid] = chstate;
                i4b_l2_channel_set_state(cd->bri, cd->channelid, chstate);
+               update_controller_leds(d);
        }
        else
        {
diff -r 5a226114d63e -r ee7267e420e5 sys/netisdn/i4b_q931.c
--- a/sys/netisdn/i4b_q931.c    Sat Mar 30 17:10:31 2002 +0000
+++ b/sys/netisdn/i4b_q931.c    Sat Mar 30 17:54:17 2002 +0000
@@ -27,7 +27,7 @@
  *     i4b_q931.c - Q931 received messages handling
  *     --------------------------------------------
  *
- *     $Id: i4b_q931.c,v 1.10 2002/03/30 11:43:33 martin Exp $ 
+ *     $Id: i4b_q931.c,v 1.11 2002/03/30 17:54:18 martin Exp $ 
  *
  * $FreeBSD$



Home | Main Index | Thread Index | Old Index