Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Add ioctls for setting and getting the beep volume. ...



details:   https://anonhg.NetBSD.org/src/rev/ed7b64448b67
branches:  trunk
changeset: 824603:ed7b64448b67
user:      nat <nat%NetBSD.org@localhost>
date:      Sun Jun 11 03:33:48 2017 +0000

description:
Add ioctls for setting and getting the beep volume.  Currently only
supported on spkr devices attached to audio.

Ok pgoyette@.

diffstat:

 sys/dev/spkr.c       |  12 ++++++++++--
 sys/dev/spkr_audio.c |  11 +++++++----
 sys/dev/spkrio.h     |   4 +++-
 sys/dev/spkrvar.h    |   3 ++-
 4 files changed, 22 insertions(+), 8 deletions(-)

diffs (114 lines):

diff -r 1c2584fad64e -r ed7b64448b67 sys/dev/spkr.c
--- a/sys/dev/spkr.c    Sun Jun 11 03:25:02 2017 +0000
+++ b/sys/dev/spkr.c    Sun Jun 11 03:33:48 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spkr.c,v 1.7 2017/06/01 09:44:30 pgoyette Exp $        */
+/*     $NetBSD: spkr.c,v 1.8 2017/06/11 03:33:48 nat Exp $     */
 
 /*
  * Copyright (c) 1990 Eric S. Raymond (esr%snark.thyrsus.com@localhost)
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.7 2017/06/01 09:44:30 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.8 2017/06/11 03:33:48 nat Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -484,6 +484,14 @@
                        playonetone(sc, &ttp);
                }
                return 0;
+       case SPKRGETVOL:
+               if (data != NULL)
+                       *(u_int *)data = sc->sc_vol;
+               return 0;
+       case SPKRSETVOL:
+               if (data != NULL && *(u_int *)data <= 100)
+                       sc->sc_vol = *(u_int *)data;
+               return 0;
        default:
                return ENOTTY;
        }
diff -r 1c2584fad64e -r ed7b64448b67 sys/dev/spkr_audio.c
--- a/sys/dev/spkr_audio.c      Sun Jun 11 03:25:02 2017 +0000
+++ b/sys/dev/spkr_audio.c      Sun Jun 11 03:33:48 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spkr_audio.c,v 1.4 2017/06/11 03:25:02 nat Exp $       */
+/*     $NetBSD: spkr_audio.c,v 1.5 2017/06/11 03:33:48 nat Exp $       */
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.4 2017/06/11 03:25:02 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.5 2017/06/11 03:33:48 nat Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -68,7 +68,8 @@
 #ifdef SPKRDEBUG
        aprint_debug_dev(self, "%s: %u %d\n", __func__, xhz, ticks);
 #endif /* SPKRDEBUG */
-       audiobell(sc->sc_audiodev, xhz, ticks * (1000 / hz), 80, 0);
+       audiobell(sc->sc_audiodev, xhz, ticks * (1000 / hz),
+           sc->sc_spkr.sc_vol, 0);
 }
 
 static void
@@ -80,7 +81,8 @@
        aprint_debug_dev(self, "%s: %d\n", __func__, ticks);
 #endif /* SPKRDEBUG */
        if (ticks > 0)
-               audiobell(sc->sc_audiodev, 0, ticks * (1000 / hz), 80, 0);
+               audiobell(sc->sc_audiodev, 0, ticks * (1000 / hz),
+                   sc->sc_spkr.sc_vol, 0);
 }
 
 static int
@@ -99,6 +101,7 @@
        aprint_normal(": PC Speaker (synthesized)\n");
 
        sc->sc_audiodev = parent;
+       sc->sc_spkr.sc_vol = 80;
        
        if (!pmf_device_register(self, NULL, NULL))
                aprint_error_dev(self, "couldn't establish power handler\n"); 
diff -r 1c2584fad64e -r ed7b64448b67 sys/dev/spkrio.h
--- a/sys/dev/spkrio.h  Sun Jun 11 03:25:02 2017 +0000
+++ b/sys/dev/spkrio.h  Sun Jun 11 03:33:48 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spkrio.h,v 1.2 2016/12/09 04:46:39 christos Exp $      */
+/*     $NetBSD: spkrio.h,v 1.3 2017/06/11 03:33:48 nat Exp $   */
 
 /*
  * spkrio.h -- interface definitions for speaker ioctl()
@@ -11,6 +11,8 @@
 
 #define SPKRTONE        _IOW('S', 1, tone_t)    /* emit tone */
 #define SPKRTUNE        _IO('S', 2)             /* emit tone sequence */
+#define SPKRGETVOL      _IOR('S', 3, u_int)     /* get volume */
+#define SPKRSETVOL      _IOW('S', 4, u_int)     /* set volume */
 
 typedef struct {
        int     frequency;      /* in hertz */
diff -r 1c2584fad64e -r ed7b64448b67 sys/dev/spkrvar.h
--- a/sys/dev/spkrvar.h Sun Jun 11 03:25:02 2017 +0000
+++ b/sys/dev/spkrvar.h Sun Jun 11 03:33:48 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spkrvar.h,v 1.6 2017/01/06 09:32:08 pgoyette Exp $ */
+/* $NetBSD: spkrvar.h,v 1.7 2017/06/11 03:33:48 nat Exp $ */
 
 #ifndef _SYS_DEV_SPKRVAR_H
 #define _SYS_DEV_SPKRVAR_H
@@ -18,6 +18,7 @@
        /* attachment-specific hooks */
        void (*sc_tone)(device_t, u_int, u_int);
        void (*sc_rest)(device_t, int);
+       u_int sc_vol;   /* volume - only for audio skpr */
 };
 
 void spkr_attach(device_t,



Home | Main Index | Thread Index | Old Index