Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hp700 add driver for harmony audio. from openbsd, ...
details: https://anonhg.NetBSD.org/src/rev/5ce1d567f586
branches: trunk
changeset: 570057:5ce1d567f586
user: chs <chs%NetBSD.org@localhost>
date: Sun Sep 19 23:03:34 2004 +0000
description:
add driver for harmony audio. from openbsd, adapted for netbsd by me.
diffstat:
sys/arch/hp700/conf/GENERIC | 8 +-
sys/arch/hp700/conf/majors.hp700 | 5 +-
sys/arch/hp700/dev/asp.c | 5 +-
sys/arch/hp700/gsc/harmony.c | 1308 ++++++++++++++++++++++++++++++++++++++
sys/arch/hp700/gsc/harmonyreg.h | 154 ++++
sys/arch/hp700/gsc/harmonyvar.h | 120 +++
6 files changed, 1592 insertions(+), 8 deletions(-)
diffs (truncated from 1670 to 300 lines):
diff -r 8ab6f65252ff -r 5ce1d567f586 sys/arch/hp700/conf/GENERIC
--- a/sys/arch/hp700/conf/GENERIC Sun Sep 19 23:00:29 2004 +0000
+++ b/sys/arch/hp700/conf/GENERIC Sun Sep 19 23:03:34 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.31 2004/09/04 23:29:47 manu Exp $
+# $NetBSD: GENERIC,v 1.32 2004/09/19 23:03:34 chs Exp $
#
# GENERIC machine description file
#
@@ -23,7 +23,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel
-#ident "GENERIC-$Revision: 1.31 $"
+#ident "GENERIC-$Revision: 1.32 $"
maxusers 32 # estimated number of users
@@ -505,9 +505,9 @@
# GSC audio devices
#aone* at gsc? # Audio Type 1 (PSB 2160-N)
-#harmony* at gsc? # Audio Type 2 (CS4215)
+harmony* at gsc? # Audio Type 2 (CS4215)
#com* at harmony? # Telephone add-in card
-#audio* at audiobus?
+audio* at audiobus?
# Pseudo-Devices
diff -r 8ab6f65252ff -r 5ce1d567f586 sys/arch/hp700/conf/majors.hp700
--- a/sys/arch/hp700/conf/majors.hp700 Sun Sep 19 23:00:29 2004 +0000
+++ b/sys/arch/hp700/conf/majors.hp700 Sun Sep 19 23:03:34 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: majors.hp700,v 1.13 2003/12/10 02:04:01 jmc Exp $
+# $NetBSD: majors.hp700,v 1.14 2004/09/19 23:03:34 chs Exp $
#
# Device majors for hp700
#
@@ -41,8 +41,9 @@
device-major cgd char 35 block 8 cgd
device-major ksyms char 36 ksyms
device-major wsfont char 37 wsfont
+device-major scsibus char 38 scsibus
device-major clockctl char 39 clockctl
-device-major scsibus char 38 scsibus
+device-major audio char 40 audio
# Majors up to 143 are reserved for machine-dependant drivers.
# New machine-independant driver majors are assigned in
diff -r 8ab6f65252ff -r 5ce1d567f586 sys/arch/hp700/dev/asp.c
--- a/sys/arch/hp700/dev/asp.c Sun Sep 19 23:00:29 2004 +0000
+++ b/sys/arch/hp700/dev/asp.c Sun Sep 19 23:03:34 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: asp.c,v 1.7 2003/11/23 17:09:29 chs Exp $ */
+/* $NetBSD: asp.c,v 1.8 2004/09/19 23:03:34 chs Exp $ */
/* $OpenBSD: asp.c,v 1.5 2000/02/09 05:04:22 mickey Exp $ */
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: asp.c,v 1.7 2003/11/23 17:09:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: asp.c,v 1.8 2004/09/19 23:03:34 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -163,6 +163,7 @@
ASP_IRQ(0x25000, 9); /* osiop */
ASP_IRQ(0x26000, 8); /* ie */
ASP_IRQ(0x30000, 3); /* siop */
+ ASP_IRQ(0x800000, 13); /* harmony */
#undef ASP_IRQ
}
diff -r 8ab6f65252ff -r 5ce1d567f586 sys/arch/hp700/gsc/harmony.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hp700/gsc/harmony.c Sun Sep 19 23:03:34 2004 +0000
@@ -0,0 +1,1308 @@
+/* $NetBSD: harmony.c,v 1.1 2004/09/19 23:03:34 chs Exp $ */
+
+/* $OpenBSD: harmony.c,v 1.23 2004/02/13 21:28:19 mickey Exp $ */
+
+/*
+ * Copyright (c) 2003 Jason L. Wright (jason%thought.net@localhost)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Harmony (CS4215/AD1849 LASI) audio interface.
+ */
+
+#include "rnd.h"
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/ioctl.h>
+#include <sys/device.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+#include <uvm/uvm_extern.h>
+
+#if NRND > 0
+#include <sys/rnd.h>
+#endif
+
+#include <sys/audioio.h>
+#include <dev/audio_if.h>
+#include <dev/auconv.h>
+
+#include <machine/cpu.h>
+#include <machine/intr.h>
+#include <machine/iomod.h>
+#include <machine/autoconf.h>
+#include <machine/bus.h>
+
+#include <hp700/dev/cpudevs.h>
+#include <hp700/gsc/gscbusvar.h>
+#include <hp700/gsc/harmonyreg.h>
+#include <hp700/gsc/harmonyvar.h>
+
+int harmony_open(void *, int);
+void harmony_close(void *);
+int harmony_query_encoding(void *, struct audio_encoding *);
+int harmony_set_params(void *, int, int, struct audio_params *,
+ struct audio_params *);
+int harmony_round_blocksize(void *, int);
+int harmony_commit_settings(void *);
+int harmony_halt_output(void *);
+int harmony_halt_input(void *);
+int harmony_getdev(void *, struct audio_device *);
+int harmony_set_port(void *, mixer_ctrl_t *);
+int harmony_get_port(void *, mixer_ctrl_t *);
+int harmony_query_devinfo(void *, mixer_devinfo_t *);
+void * harmony_allocm(void *, int, size_t, struct malloc_type *, int);
+void harmony_freem(void *, void *, struct malloc_type *);
+size_t harmony_round_buffersize(void *, int, size_t);
+int harmony_get_props(void *);
+int harmony_trigger_output(void *, void *, void *, int,
+ void (*)(void *), void *, struct audio_params *);
+int harmony_trigger_input(void *, void *, void *, int,
+ void (*)(void *), void *, struct audio_params *);
+
+struct audio_hw_if harmony_sa_hw_if = {
+ harmony_open,
+ harmony_close,
+ NULL,
+ harmony_query_encoding,
+ harmony_set_params,
+ harmony_round_blocksize,
+ harmony_commit_settings,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ harmony_halt_output,
+ harmony_halt_input,
+ NULL,
+ harmony_getdev,
+ NULL,
+ harmony_set_port,
+ harmony_get_port,
+ harmony_query_devinfo,
+ harmony_allocm,
+ harmony_freem,
+ harmony_round_buffersize,
+ NULL,
+ harmony_get_props,
+ harmony_trigger_output,
+ harmony_trigger_input,
+};
+
+int harmony_match(struct device *, struct cfdata *, void *);
+void harmony_attach(struct device *, struct device *, void *);
+
+
+CFATTACH_DECL(harmony, sizeof(struct harmony_softc),
+ harmony_match, harmony_attach, NULL, NULL);
+
+int harmony_intr(void *);
+void harmony_intr_enable(struct harmony_softc *);
+void harmony_intr_disable(struct harmony_softc *);
+uint32_t harmony_speed_bits(struct harmony_softc *, u_long *);
+int harmony_set_gainctl(struct harmony_softc *);
+void harmony_reset_codec(struct harmony_softc *);
+void harmony_start_cp(struct harmony_softc *);
+void harmony_tick_pb(void *);
+void harmony_tick_cp(void *);
+void harmony_try_more(struct harmony_softc *);
+
+#if NRND > 0
+void harmony_acc_tmo(void *);
+#define ADD_CLKALLICA(sc) do { \
+ (sc)->sc_acc <<= 1; \
+ (sc)->sc_acc |= READ_REG((sc), HARMONY_DIAG) & DIAG_CO; \
+ if ((sc)->sc_acc_cnt++ && !((sc)->sc_acc_cnt % 32)) \
+ rnd_add_uint32(&(sc)->sc_rnd_source, \
+ (sc)->sc_acc_num ^= (sc)->sc_acc); \
+} while(0)
+#endif
+
+int
+harmony_match(struct device *parent, struct cfdata *match, void *aux)
+{
+ struct gsc_attach_args *ga = aux;
+
+ if (ga->ga_type.iodc_type == HPPA_TYPE_FIO) {
+ if (ga->ga_type.iodc_sv_model == HPPA_FIO_A1 ||
+ ga->ga_type.iodc_sv_model == HPPA_FIO_A2NB ||
+ ga->ga_type.iodc_sv_model == HPPA_FIO_A1NB ||
+ ga->ga_type.iodc_sv_model == HPPA_FIO_A2)
+ return (1);
+ }
+ return (0);
+}
+
+void
+harmony_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct harmony_softc *sc = (struct harmony_softc *)self;
+ struct gsc_attach_args *ga = aux;
+ uint8_t rev;
+ uint32_t cntl;
+ int i;
+
+ sc->sc_bt = ga->ga_iot;
+ sc->sc_dmat = ga->ga_dmatag;
+
+ if (bus_space_map(sc->sc_bt, ga->ga_hpa, HARMONY_NREGS, 0,
+ &sc->sc_bh) != 0) {
+ printf(": couldn't map registers\n");
+ return;
+ }
+
+ cntl = READ_REG(sc, HARMONY_ID);
+ switch ((cntl & ID_REV_MASK)) {
+ case ID_REV_TS:
+ sc->sc_teleshare = 1;
+ case ID_REV_NOTS:
+ break;
+ default:
+ printf(": unknown id == 0x%02x\n",
+ (cntl & ID_REV_MASK) >> ID_REV_SHIFT);
+ bus_space_unmap(sc->sc_bt, sc->sc_bh, HARMONY_NREGS);
+ return;
+ }
+
+ if (bus_dmamem_alloc(sc->sc_dmat, sizeof(struct harmony_empty),
+ PAGE_SIZE, 0, &sc->sc_empty_seg, 1, &sc->sc_empty_rseg,
+ BUS_DMA_NOWAIT) != 0) {
+ printf(": couldn't alloc DMA memory\n");
+ bus_space_unmap(sc->sc_bt, sc->sc_bh, HARMONY_NREGS);
+ return;
+ }
+ if (bus_dmamem_map(sc->sc_dmat, &sc->sc_empty_seg, 1,
+ sizeof(struct harmony_empty), (caddr_t *)&sc->sc_empty_kva,
+ BUS_DMA_NOWAIT) != 0) {
+ printf(": couldn't map DMA memory\n");
+ bus_dmamem_free(sc->sc_dmat, &sc->sc_empty_seg,
+ sc->sc_empty_rseg);
+ bus_space_unmap(sc->sc_bt, sc->sc_bh, HARMONY_NREGS);
+ return;
+ }
+ if (bus_dmamap_create(sc->sc_dmat, sizeof(struct harmony_empty), 1,
+ sizeof(struct harmony_empty), 0, BUS_DMA_NOWAIT,
+ &sc->sc_empty_map) != 0) {
+ printf(": can't create DMA map\n");
+ bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->sc_empty_kva,
+ sizeof(struct harmony_empty));
+ bus_dmamem_free(sc->sc_dmat, &sc->sc_empty_seg,
+ sc->sc_empty_rseg);
+ bus_space_unmap(sc->sc_bt, sc->sc_bh, HARMONY_NREGS);
+ return;
+ }
+ if (bus_dmamap_load(sc->sc_dmat, sc->sc_empty_map, sc->sc_empty_kva,
+ sizeof(struct harmony_empty), NULL, BUS_DMA_NOWAIT) != 0) {
Home |
Main Index |
Thread Index |
Old Index