Source-Changes-HG archive

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

[src/trunk]: src/sys Add new arcofi(4) audio driver for NetBSD/hp300, ported ...



details:   https://anonhg.NetBSD.org/src/rev/7b91c9145f7c
branches:  trunk
changeset: 331779:7b91c9145f7c
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Aug 24 08:17:44 2014 +0000

description:
Add new arcofi(4) audio driver for NetBSD/hp300, ported from OpenBSD.

The arcofi(4) is a driver for the HP "Audio1" device
(Siemens PSB 2160 "ARCOFI" phone quality audio chip)
found on the HP9000/425e and HP9000/{705,710,745,747} models
(but only hp300 attachment is ported for now).
The chip supports 8-bit mono 8kHz U-law, A-law and
16-bit mono slinear_be formats.

The old HP9000/425e playing tunes with this new arcofi(4) audio driver
was also demonstrated at Open Source Conference 2014 Shimane.

diffstat:

 sys/arch/hp300/conf/GENERIC      |     8 +-
 sys/arch/hp300/conf/files.hp300  |     6 +-
 sys/arch/hp300/conf/majors.hp300 |     3 +-
 sys/arch/hp300/dev/arcofi_dio.c  |    94 ++
 sys/arch/hp300/hp300/intr.c      |    12 +-
 sys/arch/hp300/hp300/locore.s    |     9 +-
 sys/conf/files                   |     6 +-
 sys/dev/ic/arcofi.c              |  1274 ++++++++++++++++++++++++++++++++++++++
 sys/dev/ic/arcofivar.h           |    56 +
 9 files changed, 1460 insertions(+), 8 deletions(-)

diffs (truncated from 1592 to 300 lines):

diff -r 4334431768dd -r 7b91c9145f7c sys/arch/hp300/conf/GENERIC
--- a/sys/arch/hp300/conf/GENERIC       Sun Aug 24 08:05:29 2014 +0000
+++ b/sys/arch/hp300/conf/GENERIC       Sun Aug 24 08:17:44 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.187 2014/08/24 07:59:22 jnemeth Exp $
+# $NetBSD: GENERIC,v 1.188 2014/08/24 08:17:44 tsutsui Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.187 $"
+#ident                 "GENERIC-$Revision: 1.188 $"
 
 makeoptions    COPTS="-O2 -fno-reorder-blocks" # see share/mk/sys.mk
 
@@ -281,6 +281,10 @@
 ss*            at scsibus? target ? lun ?      # SCSI scanners
 uk*            at scsibus? target ? lun ?      # unknown SCSI devices
 
+# 425e digital audio
+arcofi*        at dio? scode ?
+audio*         at arcofi?
+
 #
 # Pseudo-devices
 #
diff -r 4334431768dd -r 7b91c9145f7c sys/arch/hp300/conf/files.hp300
--- a/sys/arch/hp300/conf/files.hp300   Sun Aug 24 08:05:29 2014 +0000
+++ b/sys/arch/hp300/conf/files.hp300   Sun Aug 24 08:17:44 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.hp300,v 1.88 2014/04/20 04:12:54 tsutsui Exp $
+#      $NetBSD: files.hp300,v 1.89 2014/08/24 08:17:44 tsutsui Exp $
 #
 # hp300-specific configuration info
 
@@ -147,6 +147,10 @@
 attach le at dio: le24
 file   arch/hp300/dev/if_le.c          le
 
+# 425e digital audio
+attach arcofi at dio with arcofi_dio
+file   arch/hp300/dev/arcofi_dio.c     arcofi_dio
+
 # HP-IB interfaces
 define hpibdev { }
 
diff -r 4334431768dd -r 7b91c9145f7c sys/arch/hp300/conf/majors.hp300
--- a/sys/arch/hp300/conf/majors.hp300  Sun Aug 24 08:05:29 2014 +0000
+++ b/sys/arch/hp300/conf/majors.hp300  Sun Aug 24 08:17:44 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: majors.hp300,v 1.25 2011/06/30 20:09:30 wiz Exp $
+#      $NetBSD: majors.hp300,v 1.26 2014/08/24 08:17:44 tsutsui Exp $
 #
 # Device majors for hp300
 #
@@ -48,6 +48,7 @@
 device-major   ss              char 49                 ss
 device-major   uk              char 50                 uk
 device-major   ses             char 51                 ses
+device-major   audio           char 52                 audio
 
 device-major   nsmb            char 98                 nsmb
 
diff -r 4334431768dd -r 7b91c9145f7c sys/arch/hp300/dev/arcofi_dio.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hp300/dev/arcofi_dio.c   Sun Aug 24 08:17:44 2014 +0000
@@ -0,0 +1,94 @@
+/*     $NetBSD: arcofi_dio.c,v 1.1 2014/08/24 08:17:44 tsutsui Exp $   */
+/*     $OpenBSD: arcofi_dio.c,v 1.1 2011/12/21 23:12:03 miod Exp $     */
+
+/*
+ * Copyright (c) 2011 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+#include <sys/intr.h>
+
+#include <sys/audioio.h>
+#include <dev/audio_if.h>
+#include <dev/ic/arcofivar.h>
+
+#include <hp300/dev/dioreg.h>
+#include <hp300/dev/diovar.h>
+
+#include <hp300/dev/diodevs.h>
+
+#define SOFTINT_AUDIO  SOFTINT_SERIAL  /* XXX */
+
+static void    arcofi_dio_attach(device_t, device_t, void *);
+static int     arcofi_dio_match(device_t, cfdata_t, void *);
+
+struct arcofi_dio_softc {
+       struct arcofi_softc     sc_arcofi;
+
+       struct bus_space_tag sc_tag;
+};
+
+CFATTACH_DECL_NEW(arcofi_dio, sizeof(struct arcofi_dio_softc),
+    arcofi_dio_match, arcofi_dio_attach, NULL, NULL);
+
+static int
+arcofi_dio_match(device_t parent, cfdata_t match, void *aux)
+{
+       struct dio_attach_args *da = aux;
+
+       if (da->da_id != DIO_DEVICE_ID_AUDIO)
+               return 0;
+
+       return 1;
+}
+
+static void
+arcofi_dio_attach(device_t parent, device_t self, void *aux)
+{
+       struct arcofi_dio_softc *adsc = device_private(self);
+       struct arcofi_softc *sc = &adsc->sc_arcofi;
+       struct dio_attach_args *da = aux;
+       bus_space_tag_t iot = &adsc->sc_tag;
+       int ipl;
+
+       sc->sc_dev = self;
+
+       /* XXX is it better to use sc->sc_reg[] to handle odd sparse map? */
+       memcpy(iot, da->da_bst, sizeof(struct bus_space_tag));
+       dio_set_bus_space_oddbyte(iot);
+       sc->sc_iot = iot;
+
+       if (bus_space_map(iot, da->da_addr, DIOII_SIZEOFF, 0,
+           &sc->sc_ioh) != 0) {
+               aprint_error(": can't map registers\n");
+               return;
+       }
+
+       sc->sc_sih = softint_establish(SOFTINT_AUDIO, arcofi_swintr, sc);
+       if (sc->sc_sih == NULL) {
+               aprint_error(": can't register soft interrupt\n");
+               return;
+       }
+       ipl = da->da_ipl;
+       dio_intr_establish(arcofi_hwintr, sc, ipl, IPL_AUDIO);
+
+       aprint_normal("\n");
+
+       arcofi_attach(sc, "dio");
+}
diff -r 4334431768dd -r 7b91c9145f7c sys/arch/hp300/hp300/intr.c
--- a/sys/arch/hp300/hp300/intr.c       Sun Aug 24 08:05:29 2014 +0000
+++ b/sys/arch/hp300/hp300/intr.c       Sun Aug 24 08:17:44 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.40 2010/12/20 00:25:33 matt Exp $   */
+/*     $NetBSD: intr.c,v 1.41 2014/08/24 08:17:44 tsutsui Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 1999 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.40 2010/12/20 00:25:33 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.41 2014/08/24 08:17:44 tsutsui Exp $");
 
 #define _HP300_INTR_H_PRIVATE
 
@@ -45,6 +45,8 @@
 #include <sys/cpu.h>
 #include <sys/intr.h>
 
+#include "audio.h"
+
 /*
  * The location and size of the autovectored interrupt portion
  * of the vector table.
@@ -209,6 +211,12 @@
            ih = LIST_NEXT(ih, ih_q))
                handled |= (*ih->ih_fn)(ih->ih_arg);
 
+#if NAUDIO > 0
+       /* hardclock() on ipl 6 is already handled in locore.s */
+       if (ipl == 6)
+               return;
+#endif
+
        if (handled)
                straycount = 0;
        else if (++straycount > 50)
diff -r 4334431768dd -r 7b91c9145f7c sys/arch/hp300/hp300/locore.s
--- a/sys/arch/hp300/hp300/locore.s     Sun Aug 24 08:05:29 2014 +0000
+++ b/sys/arch/hp300/hp300/locore.s     Sun Aug 24 08:17:44 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.170 2014/03/15 09:26:36 tsutsui Exp $     */
+/*     $NetBSD: locore.s,v 1.171 2014/08/24 08:17:44 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -97,6 +97,7 @@
 #include <hp300/hp300/leds.h>
 #endif
 
+#include "audio.h"
 #include "ksyms.h"
 
 #define MMUADDR(ar)    movl    _C_LABEL(MMUbase),ar
@@ -951,6 +952,12 @@
        CLKADDR(%a0)
        movb    %a0@(CLKSR),%d0         | see if anything happened
        jmi     Lclkagain               |  while we were in hardclock/statintr
+#if NAUDIO >0
+       movw    %sp@(22),%sp@-          | push exception vector info
+       clrw    %sp@-
+       jbsr    _C_LABEL(intr_dispatch) | call dispatch routine
+       addql   #4,%sp
+#endif
        INTERRUPT_RESTOREREG
        subql   #1,_C_LABEL(idepth)     | exiting from interrupt
        jra     _ASM_LABEL(rei)         | all done
diff -r 4334431768dd -r 7b91c9145f7c sys/conf/files
--- a/sys/conf/files    Sun Aug 24 08:05:29 2014 +0000
+++ b/sys/conf/files    Sun Aug 24 08:17:44 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.1099 2014/08/24 07:59:23 jnemeth Exp $
+#      $NetBSD: files,v 1.1100 2014/08/24 08:17:44 tsutsui Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
 version        20100430
@@ -913,6 +913,10 @@
 define am7930
 file   dev/ic/am7930.c                 am7930
 
+# Siemens PSB2160 audio codec, as found in HP systems
+device arcofi: audiobus, auconv, mulaw
+file   dev/ic/arcofi.c                 arcofi
+
 # SPARC `SUNW,audiocs'
 #
 device audiocs: audiobus, auconv, ad1848
diff -r 4334431768dd -r 7b91c9145f7c sys/dev/ic/arcofi.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/ic/arcofi.c       Sun Aug 24 08:17:44 2014 +0000
@@ -0,0 +1,1274 @@
+/*     $NetBSD: arcofi.c,v 1.1 2014/08/24 08:17:44 tsutsui Exp $       */
+/*     $OpenBSD: arcofi.c,v 1.6 2013/05/15 08:29:24 ratchov Exp $      */
+
+/*
+ * Copyright (c) 2011 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Driver for the HP ``Audio1'' device, which is a FIFO layer around a
+ * Siemens PSB 2160 ``ARCOFI'' phone quality audio chip.
+ *
+ * It is known to exist in two flavours: on-board the HP9000/425e as a DIO
+ * device, an on-board the HP9000/{705,710,745,747} as a GIO device.
+ *
+ * The FIFO logic buffers up to 128 bytes. When using 8 bit samples and
+ * the logic set to interrupt every half FIFO, the device will interrupt
+ * 125 times per second.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/bus.h>
+#include <sys/intr.h>
+



Home | Main Index | Thread Index | Old Index