Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/luna68k luna68k: add psgpam(4) audio for LUNA, usin...
details: https://anonhg.NetBSD.org/src/rev/4860a8ec9bf9
branches: trunk
changeset: 366716:4860a8ec9bf9
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Fri Jun 10 21:42:23 2022 +0000
description:
luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.
"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA
Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584
This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505
Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.
I would like to thank all people still working on ancient LUNA machines!
diffstat:
sys/arch/luna68k/conf/GENERIC | 14 +-
sys/arch/luna68k/conf/INSTALL | 13 +-
sys/arch/luna68k/conf/files.luna68k | 19 +-
sys/arch/luna68k/conf/majors.luna68k | 3 +-
sys/arch/luna68k/dev/psgpam.c | 798 ++++++
sys/arch/luna68k/dev/psgpam_enc.c | 152 +
sys/arch/luna68k/dev/psgpam_enc.h | 61 +
sys/arch/luna68k/dev/psgpam_table.c | 4197 ++++++++++++++++++++++++++++++++++
sys/arch/luna68k/dev/psgpam_table.h | 47 +
sys/arch/luna68k/dev/xp.c | 88 +-
sys/arch/luna68k/dev/xpbus.c | 328 ++
sys/arch/luna68k/dev/xpbusvar.h | 75 +
sys/arch/luna68k/dev/xpcmd.c | 96 +
sys/arch/luna68k/dev/xpcmd.h | 2 +
sys/arch/luna68k/dev/xplx/Makefile | 29 +
sys/arch/luna68k/dev/xplx/cdump.awk | 50 +
sys/arch/luna68k/dev/xplx/mkdefs.awk | 92 +
sys/arch/luna68k/dev/xplx/xplx.asm | 2074 ++++++++++++++++
sys/arch/luna68k/dev/xplx/xplx.inc | 239 +
sys/arch/luna68k/dev/xplx/xplxdefs.h | 220 +
sys/arch/luna68k/dev/xplxfirm.c | 43 +
sys/arch/luna68k/dev/xplxfirm.h | 2 +
sys/arch/luna68k/luna68k/locore.s | 9 +-
sys/arch/luna68k/luna68k/mainbus.c | 6 +-
24 files changed, 8596 insertions(+), 61 deletions(-)
diffs (truncated from 8950 to 300 lines):
diff -r ecde29a84722 -r 4860a8ec9bf9 sys/arch/luna68k/conf/GENERIC
--- a/sys/arch/luna68k/conf/GENERIC Fri Jun 10 21:28:50 2022 +0000
+++ b/sys/arch/luna68k/conf/GENERIC Fri Jun 10 21:42:23 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.132 2022/05/27 16:59:19 tsutsui Exp $
+# $NetBSD: GENERIC,v 1.133 2022/06/10 21:42:23 tsutsui Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.132 $"
+#ident "GENERIC-$Revision: 1.133 $"
makeoptions COPTS="-O2 -fno-reorder-blocks -fno-unwind-tables -fno-omit-frame-pointer"
# See share/mk/sys.mk. -fno-omit-frame-pointer is necessary for
@@ -157,7 +157,14 @@
fb0 at mainbus0 # 16 or 256 pseudo color
# HD647180X I/O processor
-xp0 at mainbus0
+xpbus0 at mainbus0
+xp0 at xpbus0
+
+# HD647180X I/O processor as PSG PAM audio
+psgpam0 at xpbus0
+audio* at psgpam?
+#spkr* at audio?
+#wsbell* at spkr?
# Workstation Console attachments
wsdisplay* at fb?
@@ -203,6 +210,7 @@
#pseudo-device vnd # disk-like interface to files
#options VND_COMPRESSION # compressed vnd(4)
pseudo-device clockctl # user control of clock subsystem
+pseudo-device drvctl # user control of drive subsystem
pseudo-device ksyms # /dev/ksyms
pseudo-device wsmux # mouse & keyboard multiplexsor
diff -r ecde29a84722 -r 4860a8ec9bf9 sys/arch/luna68k/conf/INSTALL
--- a/sys/arch/luna68k/conf/INSTALL Fri Jun 10 21:28:50 2022 +0000
+++ b/sys/arch/luna68k/conf/INSTALL Fri Jun 10 21:42:23 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.33 2022/05/27 16:59:19 tsutsui Exp $
+# $NetBSD: INSTALL,v 1.34 2022/06/10 21:42:23 tsutsui Exp $
#
# config for installation ramdisk kernel
#
@@ -134,6 +134,16 @@
# framebuffer
fb0 at mainbus0 # 16 or 256 pseudo color
+# HD647180X I/O processor
+#xpbus0 at mainbus0
+#xp0 at xpbus0
+
+# HD647180X I/O processor as PSG PAM audio
+#psgpam0 at xpbus0
+#audio* at psgpam?
+#spkr* at audio?
+#wsbell* at spkr?
+
# Workstation Console attachments
wsdisplay* at fb?
wskbd* at ws? console ?
@@ -178,6 +188,7 @@
#pseudo-device vnd # disk-like interface to files
#options VND_COMPRESSION # compressed vnd(4)
#pseudo-device clockctl # user control of clock subsystem
+#pseudo-device drvctl # user control of drive subsystem
#pseudo-device ksyms # /dev/ksyms
# Veriexec
diff -r ecde29a84722 -r 4860a8ec9bf9 sys/arch/luna68k/conf/files.luna68k
--- a/sys/arch/luna68k/conf/files.luna68k Fri Jun 10 21:28:50 2022 +0000
+++ b/sys/arch/luna68k/conf/files.luna68k Fri Jun 10 21:42:23 2022 +0000
@@ -1,5 +1,5 @@
#
-# $NetBSD: files.luna68k,v 1.29 2021/12/26 16:08:20 andvar Exp $
+# $NetBSD: files.luna68k,v 1.30 2022/06/10 21:42:23 tsutsui Exp $
#
maxpartitions 8
maxusers 2 8 64
@@ -48,10 +48,22 @@
file arch/luna68k/dev/siotty.c siotty needs-flag
# HD647180X I/O processor
+device xpbus {}
+attach xpbus at mainbus
+file arch/luna68k/dev/xpbus.c xpbus
+file arch/luna68k/dev/xpcmd.c xpbus
+file arch/luna68k/dev/xplxfirm.c xpbus
+
device xp
-attach xp at mainbus
+attach xp at xpbus
file arch/luna68k/dev/xp.c xp
+device psgpam: audiobus
+attach psgpam at xpbus
+file arch/luna68k/dev/psgpam.c psgpam
+file arch/luna68k/dev/psgpam_enc.c psgpam
+file arch/luna68k/dev/psgpam_table.c psgpam
+
device ws: wskbddev,wsmousedev
attach ws at sio
file arch/luna68k/dev/lunaws.c ws
@@ -81,4 +93,7 @@
include "compat/sunos/files.sunos"
file arch/m68k/m68k/sunos_machdep.c compat_sunos
+# OSS audio driver compatibility
+include "compat/ossaudio/files.ossaudio"
+
include "arch/luna68k/conf/majors.luna68k"
diff -r ecde29a84722 -r 4860a8ec9bf9 sys/arch/luna68k/conf/majors.luna68k
--- a/sys/arch/luna68k/conf/majors.luna68k Fri Jun 10 21:28:50 2022 +0000
+++ b/sys/arch/luna68k/conf/majors.luna68k Fri Jun 10 21:42:23 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: majors.luna68k,v 1.24 2020/04/04 16:06:14 jdolecek Exp $
+# $NetBSD: majors.luna68k,v 1.25 2022/06/10 21:42:23 tsutsui Exp $
#
# Device majors for luna68k
#
@@ -40,6 +40,7 @@
device-major wsfont char 39 wsfont
device-major xp char 40 xp
device-major lcd char 41 lcd
+device-major audio char 42 audio
#device-major obsolete char 98 obsolete (nsmb)
diff -r ecde29a84722 -r 4860a8ec9bf9 sys/arch/luna68k/dev/psgpam.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/luna68k/dev/psgpam.c Fri Jun 10 21:42:23 2022 +0000
@@ -0,0 +1,798 @@
+/* $NetBSD: psgpam.c,v 1.1 2022/06/10 21:42:23 tsutsui Exp $ */
+
+/*
+ * Copyright (c) 2018 Yosuke Sugahara. 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: psgpam.c,v 1.1 2022/06/10 21:42:23 tsutsui Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/endian.h>
+#include <sys/kmem.h>
+#include <sys/sysctl.h>
+
+#include <sys/cpu.h>
+#include <sys/audioio.h>
+#include <dev/audio/audio_if.h>
+
+#include <machine/autoconf.h>
+
+#include <luna68k/dev/xpbusvar.h>
+#include <luna68k/dev/psgpam_enc.h>
+#include <luna68k/dev/xpcmd.h>
+#include <luna68k/dev/xplx/xplxdefs.h>
+
+#include <luna68k/luna68k/isr.h>
+
+#include "ioconf.h"
+
+/*
+ * Debug level:
+ * 0: No debug logs
+ * 1: action changes like open/close/set_format...
+ * 2: + normal operations like read/write/ioctl...
+ * 3: + TRACEs except interrupt
+ * 4: + TRACEs including interrupt
+ */
+/* Note AUDIO_DEBUG should be sync'ed with src/sys/dev/audio/audio.c */
+/* #define AUDIO_DEBUG 1 */
+
+#if defined(AUDIO_DEBUG)
+#define DPRINTF(n, fmt...) do { \
+ if (psgpamdebug >= (n)) { \
+ if (cpu_intr_p()) { \
+ audio_mlog_printf(fmt); \
+ } else { \
+ audio_mlog_flush(); \
+ printf(fmt); \
+ } \
+ } \
+} while (0)
+
+/* XXX Parasitic to audio.c... */
+extern void audio_mlog_flush(void);
+extern void audio_mlog_printf(const char *, ...);
+
+static int psgpamdebug = AUDIO_DEBUG;
+#else
+#define DPRINTF(n, fmt...) __nothing
+#endif
+
+struct psgpam_softc {
+ device_t sc_dev;
+ vaddr_t sc_shm_base;
+ vsize_t sc_shm_size;
+
+ void (*sc_intr)(void *);
+ void *sc_arg;
+
+ kmutex_t sc_intr_lock;
+ kmutex_t sc_thread_lock;
+
+ int sc_isopen;
+
+ int sc_started;
+ int sc_outcount;
+ int sc_xp_state;
+ uint16_t sc_xp_addr; /* XP buffer addr */
+
+ int sc_xp_enc;
+ int sc_xp_rept;
+ int sc_xp_cycle_clk;
+ int sc_xp_rept_clk;
+ int sc_xp_rept_max;
+
+ u_int sc_sample_rate;
+ int sc_stride;
+ int sc_dynamic;
+
+ uint8_t *sc_start_ptr;
+ uint8_t *sc_end_ptr;
+ int sc_blksize;
+ int sc_blkcount;
+ int sc_cur_blk_id;
+
+ struct psgpam_codecvar sc_psgpam_codecvar;
+};
+
+static int psgpam_match(device_t, cfdata_t, void *);
+static void psgpam_attach(device_t, device_t, void *);
+
+/* MI audio layer interface */
+static int psgpam_open(void *, int);
+static void psgpam_close(void *);
+static int psgpam_query_format(void *, audio_format_query_t *);
+static int psgpam_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
+static int psgpam_trigger_output(void *, void *, void *, int,
+ void (*)(void *), void *, const audio_params_t *);
+static int psgpam_halt_output(void *);
+static int psgpam_getdev(void *, struct audio_device *);
+static int psgpam_set_port(void *, mixer_ctrl_t *);
+static int psgpam_get_port(void *, mixer_ctrl_t *);
+static int psgpam_query_devinfo(void *, mixer_devinfo_t *);
+static int psgpam_get_props(void *);
+static void psgpam_get_locks(void *, kmutex_t **, kmutex_t **);
+static int psgpam_round_blocksize(void *, int, int, const audio_params_t *);
+static size_t psgpam_round_buffersize(void *, int, size_t);
+
+static int psgpam_intr(void *);
+
+#if defined(AUDIO_DEBUG)
+static int psgpam_sysctl_debug(SYSCTLFN_PROTO);
+#endif
+static int psgpam_sysctl_enc(SYSCTLFN_PROTO);
+static int psgpam_sysctl_dynamic(SYSCTLFN_PROTO);
+
+CFATTACH_DECL_NEW(psgpam, sizeof(struct psgpam_softc),
+ psgpam_match, psgpam_attach, NULL, NULL);
+
+static int psgpam_matched;
+
+static const struct audio_hw_if psgpam_hw_if = {
+ .open = psgpam_open,
+ .close = psgpam_close,
+ .query_format = psgpam_query_format,
+ .set_format = psgpam_set_format,
Home |
Main Index |
Thread Index |
Old Index