The branch main has been updated by christos:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e963472ef8533fb39b581e746cdc2ddc7447dca2

commit e963472ef8533fb39b581e746cdc2ddc7447dca2
Author:     Christos Margiolis <[email protected]>
AuthorDate: 2026-01-02 16:56:07 +0000
Commit:     Christos Margiolis <[email protected]>
CommitDate: 2026-01-02 16:58:05 +0000

    snd_dummy: Initial MIDI support
    
    Because testing the midi/ code of sound(4) requires a physical MIDI
    device, add some basic MIDI support to snd_dummy(4) so that we can test
    patches to midi/ easier.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54127
---
 sys/dev/sound/dummy.c                   | 47 +++++++++++++++++++++++++++++++++
 sys/modules/sound/driver/dummy/Makefile |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/sys/dev/sound/dummy.c b/sys/dev/sound/dummy.c
index 74ca1d0c924c..aec76339ae17 100644
--- a/sys/dev/sound/dummy.c
+++ b/sys/dev/sound/dummy.c
@@ -40,7 +40,10 @@
 #endif
 
 #include <dev/sound/pcm/sound.h>
+#include <dev/sound/midi/mpu401.h>
+
 #include <mixer_if.h>
+#include <mpufoi_if.h>
 
 #define DUMMY_NPCHAN   1
 #define DUMMY_NRCHAN   1
@@ -66,6 +69,8 @@ struct dummy_softc {
        struct callout callout;
        struct mtx lock;
        bool stopped;
+       struct mpu401 *mpu;
+       mpu401_intr_t *mpu_intr;
 };
 
 static bool
@@ -93,6 +98,9 @@ dummy_chan_io(void *arg)
        struct dummy_chan *ch;
        int i = 0;
 
+       if (sc->mpu_intr)
+               (sc->mpu_intr)(sc->mpu);
+
        if (sc->stopped)
                return;
 
@@ -294,6 +302,39 @@ static kobj_method_t dummy_mixer_methods[] = {
 
 MIXER_DECLARE(dummy_mixer);
 
+static uint8_t
+dummy_mpu_read(struct mpu401 *arg, void *sc, int reg)
+{
+       return (0);
+}
+
+static void
+dummy_mpu_write(struct mpu401 *arg, void *sc, int reg, unsigned char b)
+{
+}
+
+static int
+dummy_mpu_uninit(struct mpu401 *arg, void *cookie)
+{
+       struct dummy_softc *sc = cookie;
+
+       mtx_lock(&sc->lock);
+       sc->mpu_intr = NULL;
+       sc->mpu = NULL;
+       mtx_unlock(&sc->lock);
+
+       return (0);
+}
+
+static kobj_method_t dummy_mpu_methods[] = {
+       KOBJMETHOD(mpufoi_read,         dummy_mpu_read),
+       KOBJMETHOD(mpufoi_write,        dummy_mpu_write),
+       KOBJMETHOD(mpufoi_uninit,       dummy_mpu_uninit),
+       KOBJMETHOD_END
+};
+
+static DEFINE_CLASS(dummy_mpu, dummy_mpu_methods, 0);
+
 static void
 dummy_identify(driver_t *driver, device_t parent)
 {
@@ -354,6 +395,11 @@ dummy_attach(device_t dev)
         */
        make_dev_alias(sc->info.dsp_dev, "dsp.dummy");
 
+       sc->mpu = mpu401_init(&dummy_mpu_class, sc, dummy_chan_io,
+           &sc->mpu_intr);
+       if (sc->mpu == NULL)
+               return (ENXIO);
+
        return (0);
 }
 
@@ -368,6 +414,7 @@ dummy_detach(device_t dev)
        mtx_unlock(&sc->lock);
        callout_drain(&sc->callout);
        err = pcm_unregister(dev);
+       mpu401_uninit(sc->mpu);
        mtx_destroy(&sc->lock);
 
        return (err);
diff --git a/sys/modules/sound/driver/dummy/Makefile 
b/sys/modules/sound/driver/dummy/Makefile
index fb4127d35073..41dec7c83b4d 100644
--- a/sys/modules/sound/driver/dummy/Makefile
+++ b/sys/modules/sound/driver/dummy/Makefile
@@ -1,7 +1,7 @@
 .PATH: ${SRCTOP}/sys/dev/sound
 
 KMOD=  snd_dummy
-SRCS=  bus_if.h device_if.h
+SRCS=  bus_if.h device_if.h mpufoi_if.h
 SRCS+= dummy.c
 
 .include <bsd.kmod.mk>

Reply via email to