Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Mar 2007 16:14:54 GMT
From:      Alexander Leidinger <netchild@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 116029 for review
Message-ID:  <200703171614.l2HGEs3a077699@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=116029

Change 116029 by netchild@netchild_magellan on 2007/03/17 16:14:36

	IFC

Affected files ...

.. //depot/projects/soundsystem/src/sys/dev/sound/isa/ad1816.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/isa/mss.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/isa/sbc.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/midi/midi.c#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/midi/midi.h#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/midi/midiq.h#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/midi/mpu401.c#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/midi/mpu401.h#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/midi/mpu_if.m#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/midi/mpufoi_if.m#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/midi/sequencer.c#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/midi/sequencer.h#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/midi/synth_if.m#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/als4000.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/atiixp.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/cmi.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/ds1.c#5 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/emu10k1.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/emu10kx-pcm.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/envy24.c#5 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/envy24ht.c#5 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/es137x.c#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/hda/hdac.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/ich.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/maestro.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/maestro3.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/solo.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/t4dwave.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/via8233.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pci/via82c686.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/ac97.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/buffer.c#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/channel.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/channel_if.m#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/dsp.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/fake.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/feeder.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/feeder.h#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/feeder_fmt.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/feeder_rate.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/feeder_volume.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/sndstat.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/sound.c#4 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/sound.h#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/pcm/vchan.c#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/sbus/cs4231.c#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/usb/uaudio.c#3 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/usb/uaudio.h#2 integrate
.. //depot/projects/soundsystem/src/sys/dev/sound/usb/uaudio_pcm.c#3 integrate

Differences ...

==== //depot/projects/soundsystem/src/sys/dev/sound/isa/ad1816.c#4 (text+ko) ====

@@ -33,7 +33,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/isa/ad1816.c,v 1.41 2007/02/23 13:47:33 netchild Exp $");
+SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/isa/ad1816.c,v 1.42 2007/03/15 16:41:25 ariff Exp $");
 
 struct ad1816_info;
 
@@ -601,7 +601,8 @@
 	ad1816 = (struct ad1816_info *)malloc(sizeof *ad1816, M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (!ad1816) return ENXIO;
 
-	ad1816->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
+	ad1816->lock = snd_mtxcreate(device_get_nameunit(dev),
+	    "snd_ad1816 softc");
 	ad1816->io_rid = 2;
 	ad1816->irq_rid = 0;
 	ad1816->drq1_rid = 0;

==== //depot/projects/soundsystem/src/sys/dev/sound/isa/mss.c#4 (text+ko) ====

@@ -29,7 +29,7 @@
 
 #include <dev/sound/pcm/sound.h>
 
-SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/isa/mss.c,v 1.107 2007/02/23 13:47:33 netchild Exp $");
+SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/isa/mss.c,v 1.108 2007/03/15 16:41:25 ariff Exp $");
 
 /* board-specific include files */
 #include <dev/sound/isa/mss.h>
@@ -1696,7 +1696,7 @@
     	int pdma, rdma, flags = device_get_flags(dev);
     	char status[SND_STATUSLEN], status2[SND_STATUSLEN];
 
-	mss->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
+	mss->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_mss softc");
 	mss->bufsize = pcm_getbuffersize(dev, 4096, MSS_DEFAULT_BUFSZ, 65536);
     	if (!mss_alloc_resources(mss, dev)) goto no;
     	mss_init(mss, dev);

==== //depot/projects/soundsystem/src/sys/dev/sound/isa/sbc.c#4 (text+ko) ====

@@ -30,7 +30,7 @@
 
 #include <isa/isavar.h>
 
-SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/isa/sbc.c,v 1.47 2007/02/23 19:40:13 ariff Exp $");
+SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/isa/sbc.c,v 1.48 2007/03/15 16:41:25 ariff Exp $");
 
 #define IO_MAX	3
 #define IRQ_MAX	1
@@ -120,7 +120,8 @@
 static void
 sbc_lockinit(struct sbc_softc *scp)
 {
-	scp->lock = snd_mtxcreate(device_get_nameunit(scp->dev), "sound softc");
+	scp->lock = snd_mtxcreate(device_get_nameunit(scp->dev),
+	    "snd_sbc softc");
 }
 
 static void

==== //depot/projects/soundsystem/src/sys/dev/sound/midi/midi.c#3 (text) ====

@@ -42,7 +42,7 @@
   */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/sound/midi/midi.c,v 1.21 2007/01/28 20:38:07 joel Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/sound/midi/midi.c,v 1.23 2007/03/15 14:57:54 ariff Exp $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -99,37 +99,36 @@
 #define MIDI_NAMELEN   16
 struct snd_midi {
 	KOBJ_FIELDS;
-	struct mtx      lock;	/* Protects all but queues */
-	void           *cookie;
+	struct mtx lock;		/* Protects all but queues */
+	void   *cookie;
 
-	int             unit;	/* Should only be used in midistat */
-	int             channel;/* Should only be used in midistat */
+	int	unit;			/* Should only be used in midistat */
+	int	channel;		/* Should only be used in midistat */
 
-	int             busy;
-	int             flags;	/* File flags */
-	char            name[MIDI_NAMELEN];
-	struct mtx      qlock;	/* Protects inq, outq and flags */
-	                MIDIQ_HEAD(, char)inq, outq;
-	int             rchan, wchan;
-	struct selinfo  rsel, wsel;
-	int             hiwat;	/* QLEN(outq)>High-water -> disable writes
-		     * from userland */
+	int	busy;
+	int	flags;			/* File flags */
+	char	name[MIDI_NAMELEN];
+	struct mtx qlock;		/* Protects inq, outq and flags */
+	MIDIQ_HEAD(, char) inq, outq;
+	int	rchan, wchan;
+	struct selinfo rsel, wsel;
+	int	hiwat;			/* QLEN(outq)>High-water -> disable
+					 * writes from userland */
 	enum midi_states inq_state;
-	int             inq_status, inq_left;	/* Variables for the state
-			     * machine in Midi_in, this
-			     * is to provide that signals
-			     * only get issued only
-			     * complete command packets. */
-	struct proc    *async;
-	struct cdev    *dev;
+	int	inq_status, inq_left;	/* Variables for the state machine in
+					 * Midi_in, this is to provide that
+					 * signals only get issued only
+					 * complete command packets. */
+	struct proc *async;
+	struct cdev *dev;
 	struct synth_midi *synth;
-	int		synth_flags;
+	int	synth_flags;
 	TAILQ_ENTRY(snd_midi) link;
 };
 
 struct synth_midi {
-    KOBJ_FIELDS;
-    struct snd_midi *m;
+	KOBJ_FIELDS;
+	struct snd_midi *m;
 };
 
 static synth_open_t midisynth_open;
@@ -144,30 +143,30 @@
 
 
 static kobj_method_t midisynth_methods[] = {
-            KOBJMETHOD(synth_open,midisynth_open),
-            KOBJMETHOD(synth_close,midisynth_close),
-            KOBJMETHOD(synth_writeraw,midisynth_writeraw),
-            KOBJMETHOD(synth_setinstr,midisynth_setinstr),
-            KOBJMETHOD(synth_startnote,midisynth_startnote),
-            KOBJMETHOD(synth_killnote,midisynth_killnote),
-	    KOBJMETHOD(synth_alloc, midisynth_alloc),
-	    KOBJMETHOD(synth_controller, midisynth_controller),
-	    KOBJMETHOD(synth_bender, midisynth_bender),
-            { 0, 0 }
+	KOBJMETHOD(synth_open, midisynth_open),
+	KOBJMETHOD(synth_close, midisynth_close),
+	KOBJMETHOD(synth_writeraw, midisynth_writeraw),
+	KOBJMETHOD(synth_setinstr, midisynth_setinstr),
+	KOBJMETHOD(synth_startnote, midisynth_startnote),
+	KOBJMETHOD(synth_killnote, midisynth_killnote),
+	KOBJMETHOD(synth_alloc, midisynth_alloc),
+	KOBJMETHOD(synth_controller, midisynth_controller),
+	KOBJMETHOD(synth_bender, midisynth_bender),
+	{0, 0}
 };
 
 DEFINE_CLASS(midisynth, midisynth_methods, 0);
 
 /*
  * Module Exports & Interface
- * 
+ *
  * struct midi_chan *midi_init(MPU_CLASS cls, int unit, int chan) int
  * midi_uninit(struct snd_midi *) 0 == no error EBUSY or other error int
  * Midi_in(struct midi_chan *, char *buf, int count) int Midi_out(struct
  * midi_chan *, char *buf, int count)
- * 
+ *
  * midi_{in,out} return actual size transfered
- * 
+ *
  */
 
 
@@ -268,21 +267,21 @@
  * cookie is passed back on MPU calls Typical device drivers will call with
  * unit=0, channel=1..(number of channels) and cookie=soft_c and won't care
  * what unit number is used.
- * 
+ *
  * It is an error to call midi_init with an already used unit/channel combo.
- * 
+ *
  * Returns NULL on error
- * 
+ *
  */
 struct snd_midi *
 midi_init(kobj_class_t cls, int unit, int channel, void *cookie)
 {
 	struct snd_midi *m;
-	int             i;
-	int             inqsize, outqsize;
-	MIDI_TYPE      *buf;
+	int i;
+	int inqsize, outqsize;
+	MIDI_TYPE *buf;
 
-	MIDI_DEBUG(1,printf("midiinit: unit %d/%d.\n", unit, channel));
+	MIDI_DEBUG(1, printf("midiinit: unit %d/%d.\n", unit, channel));
 	mtx_lock(&midistat_lock);
 	/*
 	 * Protect against call with existing unit/channel or auto-allocate a
@@ -290,29 +289,29 @@
 	 */
 	i = -1;
 	TAILQ_FOREACH(m, &midi_devs, link) {
-	    mtx_lock(&m->lock);
-	    if (unit != 0) {
-	    if (m->unit == unit && m->channel == channel) {
-	        mtx_unlock(&m->lock);
-		goto err0;
+		mtx_lock(&m->lock);
+		if (unit != 0) {
+			if (m->unit == unit && m->channel == channel) {
+				mtx_unlock(&m->lock);
+				goto err0;
+			}
+		} else {
+			/*
+			 * Find a better unit number
+			 */
+			if (m->unit > i)
+				i = m->unit;
 		}
-	    } else {
-	/*
-	 * Find a better unit number
-	 */
-	    if (m->unit > i)
-		i = m->unit;
-	    }
-	    mtx_unlock(&m->lock);
+		mtx_unlock(&m->lock);
 	}
 
 	if (unit == 0)
-	    unit = i + 1;
+		unit = i + 1;
 
 	MIDI_DEBUG(1, printf("midiinit #2: unit %d/%d.\n", unit, channel));
 	m = malloc(sizeof(*m), M_MIDI, M_NOWAIT | M_ZERO);
 	if (m == NULL)
-	    goto err0;
+		goto err0;
 
 	m->synth = malloc(sizeof(*m->synth), M_MIDI, M_NOWAIT | M_ZERO);
 	kobj_init((kobj_t)m->synth, &midisynth_class);
@@ -323,32 +322,32 @@
 
 	MIDI_DEBUG(1, printf("midiinit queues %d/%d.\n", inqsize, outqsize));
 	if (!inqsize && !outqsize)
-	    goto err1;
+		goto err1;
 
-	mtx_init(&m->lock, "raw midi", 0, 0);
-	mtx_init(&m->qlock, "q raw midi", 0, 0);
+	mtx_init(&m->lock, "raw midi", NULL, 0);
+	mtx_init(&m->qlock, "q raw midi", NULL, 0);
 
 	mtx_lock(&m->lock);
 	mtx_lock(&m->qlock);
 
 	if (inqsize)
-	    buf = malloc(sizeof(MIDI_TYPE) * inqsize, M_MIDI, M_NOWAIT);
+		buf = malloc(sizeof(MIDI_TYPE) * inqsize, M_MIDI, M_NOWAIT);
 	else
-	    buf = NULL;
+		buf = NULL;
 
 	MIDIQ_INIT(m->inq, buf, inqsize);
 
 	if (outqsize)
-	    buf = malloc(sizeof(MIDI_TYPE) * outqsize, M_MIDI, M_NOWAIT);
+		buf = malloc(sizeof(MIDI_TYPE) * outqsize, M_MIDI, M_NOWAIT);
 	else
-	    buf = NULL;
+		buf = NULL;
 	m->hiwat = outqsize / 2;
 
 	MIDIQ_INIT(m->outq, buf, outqsize);
 
 	if ((inqsize && !MIDIQ_BUF(m->inq)) ||
 	    (outqsize && !MIDIQ_BUF(m->outq)))
-	    goto err2;
+		goto err2;
 
 
 	m->busy = 0;
@@ -358,7 +357,7 @@
 	m->cookie = cookie;
 
 	if (MPU_INIT(m, cookie))
-	    goto err2;
+		goto err2;
 
 	mtx_unlock(&m->lock);
 	mtx_unlock(&m->qlock);
@@ -368,8 +367,8 @@
 	mtx_unlock(&midistat_lock);
 
 	m->dev = make_dev(&midi_cdevsw,
-			MIDIMKMINOR(unit, MIDI_DEV_RAW, channel),
-	         	UID_ROOT, GID_WHEEL, 0666, "midi%d.%d", unit, channel);
+	    MIDIMKMINOR(unit, MIDI_DEV_RAW, channel),
+	    UID_ROOT, GID_WHEEL, 0666, "midi%d.%d", unit, channel);
 	m->dev->si_drv1 = m;
 
 	return m;
@@ -378,9 +377,9 @@
 	mtx_destroy(&m->lock);
 
 	if (MIDIQ_BUF(m->inq))
-	    free(MIDIQ_BUF(m->inq), M_MIDI);
+		free(MIDIQ_BUF(m->inq), M_MIDI);
 	if (MIDIQ_BUF(m->outq))
-	    free(MIDIQ_BUF(m->outq), M_MIDI);
+		free(MIDIQ_BUF(m->outq), M_MIDI);
 err1:	free(m, M_MIDI);
 err0:	mtx_unlock(&midistat_lock);
 	MIDI_DEBUG(1, printf("midi_init ended in error\n"));
@@ -391,32 +390,32 @@
  * midi_uninit does not call MIDI_UNINIT, as since this is the implementors
  * entry point. midi_unint if fact, does not send any methods. A call to
  * midi_uninit is a defacto promise that you won't manipulate ch anymore
- * 
+ *
  */
 
 int
-midi_uninit(struct snd_midi * m)
+midi_uninit(struct snd_midi *m)
 {
-	int             err;
+	int err;
 
 	err = ENXIO;
 	mtx_lock(&midistat_lock);
 	mtx_lock(&m->lock);
 	if (m->busy) {
-	    if (!(m->rchan || m->wchan))
-		goto err;
+		if (!(m->rchan || m->wchan))
+			goto err;
 
-	    if (m->rchan) {
-		wakeup(&m->rchan);
-		m->rchan = 0;
-	    }
-	    if (m->wchan) {
-		wakeup(&m->wchan);
-		m->wchan = 0;
-	    }
+		if (m->rchan) {
+			wakeup(&m->rchan);
+			m->rchan = 0;
+		}
+		if (m->wchan) {
+			wakeup(&m->wchan);
+			m->wchan = 0;
+		}
 	}
 	err = midi_destroy(m, 0);
-	if(!err)
+	if (!err)
 		goto exit;
 
 err:	mtx_unlock(&m->lock);
@@ -432,8 +431,9 @@
  */
 
 #ifdef notdef
-static int      midi_lengths[] = {2, 2, 2, 2, 1, 1, 2, 0};
-#endif /* notdef */
+static int midi_lengths[] = {2, 2, 2, 2, 1, 1, 2, 0};
+
+#endif					/* notdef */
 /* Number of bytes in a MIDI command */
 #define MIDI_LENGTH(d) (midi_lengths[((d) >> 4) & 7])
 #define MIDI_ACK	0xfe
@@ -445,10 +445,11 @@
 
 
 int
-midi_in(struct snd_midi * m, MIDI_TYPE * buf, int size)
+midi_in(struct snd_midi *m, MIDI_TYPE *buf, int size)
 {
 	/* int             i, sig, enq; */
-	int             used;
+	int used;
+
 	/* MIDI_TYPE       data; */
 	MIDI_DEBUG(5, printf("midi_in: m=%p size=%d\n", m, size));
 
@@ -456,7 +457,7 @@
  * XXX: locking flub
  */
 	if (!(m->flags & M_RX))
-	    return size;
+		return size;
 
 	used = 0;
 
@@ -468,100 +469,102 @@
 	 */
 
 	if (!(m->flags & M_RX))
-	    return size;
+		return size;
 
 	for (i = sig = 0; i < size; i++) {
 
-	    data = buf[i];
-	    enq = 0;
-	    if (data == MIDI_ACK)
-		continue;
+		data = buf[i];
+		enq = 0;
+		if (data == MIDI_ACK)
+			continue;
 
-	    switch (m->inq_state) {
-	    case MIDI_IN_START:
-		if (MIDI_IS_STATUS(data)) {
-		    switch (data) {
-		    case 0xf0:	/* Sysex */
-			m->inq_state = MIDI_IN_SYSEX;
+		switch (m->inq_state) {
+		case MIDI_IN_START:
+			if (MIDI_IS_STATUS(data)) {
+				switch (data) {
+				case 0xf0:	/* Sysex */
+					m->inq_state = MIDI_IN_SYSEX;
+					break;
+				case 0xf1:	/* MTC quarter frame */
+				case 0xf3:	/* Song select */
+					m->inq_state = MIDI_IN_DATA;
+					enq = 1;
+					m->inq_left = 1;
+					break;
+				case 0xf2:	/* Song position pointer */
+					m->inq_state = MIDI_IN_DATA;
+					enq = 1;
+					m->inq_left = 2;
+					break;
+				default:
+					if (MIDI_IS_COMMON(data)) {
+						enq = 1;
+						sig = 1;
+					} else {
+						m->inq_state = MIDI_IN_DATA;
+						enq = 1;
+						m->inq_status = data;
+						m->inq_left = MIDI_LENGTH(data);
+					}
+					break;
+				}
+			} else if (MIDI_IS_STATUS(m->inq_status)) {
+				m->inq_state = MIDI_IN_DATA;
+				if (!MIDIQ_FULL(m->inq)) {
+					used++;
+					MIDIQ_ENQ(m->inq, &m->inq_status, 1);
+				}
+				enq = 1;
+				m->inq_left = MIDI_LENGTH(m->inq_status) - 1;
+			}
 			break;
-		    case 0xf1:	/* MTC quarter frame */
-		    case 0xf3:	/* Song select */
-			m->inq_state = MIDI_IN_DATA;
+			/*
+			 * End of case MIDI_IN_START:
+			 */
+
+		case MIDI_IN_DATA:
 			enq = 1;
-			m->inq_left = 1;
+			if (--m->inq_left <= 0)
+				sig = 1;/* deliver data */
 			break;
-		    case 0xf2:	/* Song position pointer */
-			m->inq_state = MIDI_IN_DATA;
-			enq = 1;
-			m->inq_left = 2;
+		case MIDI_IN_SYSEX:
+			if (data == MIDI_SYSEX_END)
+				m->inq_state = MIDI_IN_START;
 			break;
-		    default:
-			if (MIDI_IS_COMMON(data)) {
-			    enq = 1;
-			    sig = 1;
-			} else {
-			    m->inq_state = MIDI_IN_DATA;
-			    enq = 1;
-			    m->inq_status = data;
-			    m->inq_left = MIDI_LENGTH(data);
+		}
+
+		if (enq)
+			if (!MIDIQ_FULL(m->inq)) {
+				MIDIQ_ENQ(m->inq, &data, 1);
+				used++;
 			}
-			break;
-		    }
-		} else if (MIDI_IS_STATUS(m->inq_status)) {
-		    m->inq_state = MIDI_IN_DATA;
-		    if (!MIDIQ_FULL(m->inq)) {
-			used++;
-			MIDIQ_ENQ(m->inq, &m->inq_status, 1);
-		    }
-		    enq = 1;
-		    m->inq_left = MIDI_LENGTH(m->inq_status) - 1;
-		}
-		break;
 		/*
-		 * End of case MIDI_IN_START:
-		 */
-
-	    case MIDI_IN_DATA:
-		enq = 1;
-		if (--m->inq_left <= 0)
-		    sig = 1;	/* deliver data */
-		break;
-	    case MIDI_IN_SYSEX:
-		if (data == MIDI_SYSEX_END)
-		    m->inq_state = MIDI_IN_START;
-		break;
-	    }
-
-	    if (enq)
-		if (!MIDIQ_FULL(m->inq)) {
-		    MIDIQ_ENQ(m->inq, &data, 1);
-		    used++;
-		}
-	    /*
-	     * End of the state machines main "for loop"
-	     */
+	         * End of the state machines main "for loop"
+	         */
 	}
 	if (sig) {
 #endif
-	MIDI_DEBUG(6, printf("midi_in: len %jd avail %jd\n", (intmax_t)MIDIQ_LEN(m->inq), (intmax_t)MIDIQ_AVAIL(m->inq))) ;
-	if (MIDIQ_AVAIL(m->inq) > size) {
-		used=size;
-		MIDIQ_ENQ(m->inq, buf, size);
-	} else {
-		MIDI_DEBUG(4,printf("midi_in: Discarding data qu\n"));
-		mtx_unlock(&m->qlock);
-		return 0;
-	}
-	    if (m->rchan) {
-		wakeup(&m->rchan);
-		m->rchan = 0;
-	    }
-	    selwakeup(&m->rsel);
-	    if (m->async) {
-		PROC_LOCK(m->async);
-		psignal(m->async, SIGIO);
-		PROC_UNLOCK(m->async);
-	    }
+		MIDI_DEBUG(6, printf("midi_in: len %jd avail %jd\n",
+		    (intmax_t)MIDIQ_LEN(m->inq),
+		    (intmax_t)MIDIQ_AVAIL(m->inq)));
+		if (MIDIQ_AVAIL(m->inq) > size) {
+			used = size;
+			MIDIQ_ENQ(m->inq, buf, size);
+		} else {
+			MIDI_DEBUG(4, printf("midi_in: Discarding data qu\n"));
+			mtx_unlock(&m->qlock);
+			return 0;
+		}
+		if (m->rchan) {
+			wakeup(&m->rchan);
+			m->rchan = 0;
+		}
+		selwakeup(&m->rsel);
+		if (m->async) {
+			PROC_LOCK(m->async);
+			psignal(m->async, SIGIO);
+			PROC_UNLOCK(m->async);
+		}
 #if 0
 	}
 #endif
@@ -573,9 +576,9 @@
  * midi_out: The only clearer of the M_TXEN flag.
  */
 int
-midi_out(struct snd_midi * m, MIDI_TYPE * buf, int size)
+midi_out(struct snd_midi *m, MIDI_TYPE *buf, int size)
 {
-	int             used;
+	int used;
 
 /*
  * XXX: locking flub
@@ -583,23 +586,23 @@
 	if (!(m->flags & M_TXEN))
 		return 0;
 
-	MIDI_DEBUG(2, printf("midi_out: %p\n", m)); 
+	MIDI_DEBUG(2, printf("midi_out: %p\n", m));
 	mtx_lock(&m->qlock);
 	used = MIN(size, MIDIQ_LEN(m->outq));
 	MIDI_DEBUG(3, printf("midi_out: used %d\n", used));
 	if (used)
-	    MIDIQ_DEQ(m->outq, buf, used);
+		MIDIQ_DEQ(m->outq, buf, used);
 	if (MIDIQ_EMPTY(m->outq)) {
-	    m->flags &= ~M_TXEN;
-	    MPU_CALLBACKP(m, m->cookie, m->flags);
+		m->flags &= ~M_TXEN;
+		MPU_CALLBACKP(m, m->cookie, m->flags);
 	}
-	if (used && MIDIQ_AVAIL(m->outq) > m->hiwat ) {
+	if (used && MIDIQ_AVAIL(m->outq) > m->hiwat) {
 		if (m->wchan) {
 			wakeup(&m->wchan);
 			m->wchan = 0;
 		}
 		selwakeup(&m->wsel);
-		 if (m->async) {
+		if (m->async) {
 			PROC_LOCK(m->async);
 			psignal(m->async, SIGIO);
 			PROC_UNLOCK(m->async);
@@ -614,15 +617,15 @@
  * /dev/rmidi#.#	device access functions
  */
 int
-midi_open(struct cdev *i_dev, int flags, int mode, struct thread * td)
+midi_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 {
 	struct snd_midi *m = i_dev->si_drv1;
-	int             retval;
+	int retval;
 
-	MIDI_DEBUG(1,printf("midiopen %p %s %s\n", td,
-		flags & FREAD?"M_RX":"", flags & FWRITE?"M_TX":""));
+	MIDI_DEBUG(1, printf("midiopen %p %s %s\n", td,
+	    flags & FREAD ? "M_RX" : "", flags & FWRITE ? "M_TX" : ""));
 	if (m == NULL)
-	    return ENXIO;
+		return ENXIO;
 
 	mtx_lock(&m->lock);
 	mtx_lock(&m->qlock);
@@ -630,20 +633,20 @@
 	retval = 0;
 
 	if (flags & FREAD) {
-	    if (MIDIQ_SIZE(m->inq) == 0)
-		retval = ENXIO;
-	    else if (m->flags & M_RX)
-		retval = EBUSY;
-	    if (retval)
-		goto err;
+		if (MIDIQ_SIZE(m->inq) == 0)
+			retval = ENXIO;
+		else if (m->flags & M_RX)
+			retval = EBUSY;
+		if (retval)
+			goto err;
 	}
 	if (flags & FWRITE) {
-	    if (MIDIQ_SIZE(m->outq) == 0)
-		retval = ENXIO;
-	    else if (m->flags & M_TX)
-		retval = EBUSY;
-	    if (retval)
-		goto err;
+		if (MIDIQ_SIZE(m->outq) == 0)
+			retval = ENXIO;
+		else if (m->flags & M_TX)
+			retval = EBUSY;
+		if (retval)
+			goto err;
 	}
 	m->busy++;
 
@@ -652,16 +655,16 @@
 	m->async = 0;
 
 	if (flags & FREAD) {
-	    m->flags |= M_RX | M_RXEN;
-	    /*
-	     * Only clear the inq, the outq might still have data to drain from
-	     * a previous session
-	     */
-	    MIDIQ_CLEAR(m->inq);
+		m->flags |= M_RX | M_RXEN;
+		/*
+	         * Only clear the inq, the outq might still have data to drain
+	         * from a previous session
+	         */
+		MIDIQ_CLEAR(m->inq);
 	};
 
 	if (flags & FWRITE)
-	    m->flags |= M_TX;
+		m->flags |= M_TX;
 
 	MPU_CALLBACK(m, m->cookie, m->flags);
 
@@ -673,37 +676,36 @@
 }
 
 int
-midi_close(struct cdev *i_dev, int flags, int mode, struct thread * td)
+midi_close(struct cdev *i_dev, int flags, int mode, struct thread *td)
 {
 	struct snd_midi *m = i_dev->si_drv1;
-	int             retval;
-	int		oldflags;
+	int retval;
+	int oldflags;
 
 	MIDI_DEBUG(1, printf("midi_close %p %s %s\n", td,
-		flags & FREAD?"M_RX":"", flags & FWRITE?"M_TX":""));
+	    flags & FREAD ? "M_RX" : "", flags & FWRITE ? "M_TX" : ""));
 
 	if (m == NULL)
-	    return           ENXIO;
+		return ENXIO;
 
 	mtx_lock(&m->lock);
 	mtx_lock(&m->qlock);
 
-	if ( (flags & FREAD && !(m->flags & M_RX)) || 
-	     (flags & FWRITE && !(m->flags & M_TX)) ) {
-	    retval = ENXIO;
-	    goto err;
+	if ((flags & FREAD && !(m->flags & M_RX)) ||
+	    (flags & FWRITE && !(m->flags & M_TX))) {
+		retval = ENXIO;
+		goto err;
 	}
-
 	m->busy--;
 
 	oldflags = m->flags;
 
 	if (flags & FREAD)
-	    m->flags &= ~(M_RX | M_RXEN);
+		m->flags &= ~(M_RX | M_RXEN);
 	if (flags & FWRITE)
-	    m->flags &= ~M_TX;
+		m->flags &= ~M_TX;
 
-	if( (m->flags & (M_TXEN | M_RXEN)) != (oldflags & (M_RXEN | M_TXEN)) )
+	if ((m->flags & (M_TXEN | M_RXEN)) != (oldflags & (M_RXEN | M_TXEN)))
 		MPU_CALLBACK(m, m->cookie, m->flags);
 
 	MIDI_DEBUG(1, printf("midi_close: closed, busy = %d.\n", m->busy));
@@ -713,70 +715,73 @@
 	retval = 0;
 err:	return retval;
 }
+
 /*
- * TODO: midi_read, per oss programmer's guide pg. 42 should return as soon as data is available.
+ * TODO: midi_read, per oss programmer's guide pg. 42 should return as soon
+ * as data is available.
  */
 int
-midi_read(struct cdev *i_dev, struct uio * uio, int ioflag)
+midi_read(struct cdev *i_dev, struct uio *uio, int ioflag)
 {
 #define MIDI_RSIZE 32
 	struct snd_midi *m = i_dev->si_drv1;
-	int             retval;
-	int             used;
-	char            buf[MIDI_RSIZE];
+	int retval;
+	int used;
+	char buf[MIDI_RSIZE];
 
-	MIDI_DEBUG(5, printf("midiread: count=%lu\n", (unsigned long)uio->uio_resid));
+	MIDI_DEBUG(5, printf("midiread: count=%lu\n",
+	    (unsigned long)uio->uio_resid));
 
 	retval = EIO;
 
 	if (m == NULL)
-	    goto err0;
+		goto err0;
 
 	mtx_lock(&m->lock);
 	mtx_lock(&m->qlock);
 
 	if (!(m->flags & M_RX))
-	    goto err1;
+		goto err1;
 
 	while (uio->uio_resid > 0) {
-	    while (MIDIQ_EMPTY(m->inq)) {
-		retval = EWOULDBLOCK;
-		if (ioflag & O_NONBLOCK)
-		    goto err1;
-		mtx_unlock(&m->lock);
-		m->rchan = 1;
-		retval = msleep(&m->rchan, &m->qlock,
-			PCATCH | PDROP, "midi RX", 0);
+		while (MIDIQ_EMPTY(m->inq)) {
+			retval = EWOULDBLOCK;
+			if (ioflag & O_NONBLOCK)
+				goto err1;
+			mtx_unlock(&m->lock);
+			m->rchan = 1;
+			retval = msleep(&m->rchan, &m->qlock,
+			    PCATCH | PDROP, "midi RX", 0);
+			/*
+			 * We slept, maybe things have changed since last
+			 * dying check
+			 */
+			if (retval == EINTR)
+				goto err0;
+			if (m != i_dev->si_drv1)
+				retval = ENXIO;
+			/* if (retval && retval != ERESTART) */
+			if (retval)
+				goto err0;
+			mtx_lock(&m->lock);
+			mtx_lock(&m->qlock);
+			m->rchan = 0;
+			if (!m->busy)
+				goto err1;
+		}
+		MIDI_DEBUG(6, printf("midi_read start\n"));
 		/*
-		 * We slept, maybe things have changed since last
-		 * dying check
-		 */
-		if (retval == EINTR)
-		    goto err0;
-		if (m != i_dev->si_drv1)
-		    retval = ENXIO;
-		/* if (retval && retval != ERESTART) */
-		if (retval)
-		    goto err0;
-		mtx_lock(&m->lock);
-		mtx_lock(&m->qlock);
-		m->rchan = 0;
-		if (!m->busy)
-		    goto err1;
-	    }
-		MIDI_DEBUG(6, printf("midi_read start\n"));
-	    /*
-	     * At this point, it is certain that m->inq has data
-	     */
+	         * At this point, it is certain that m->inq has data
+	         */
 
-	    used = MIN(MIDIQ_LEN(m->inq), uio->uio_resid);
-	    used = MIN(used, MIDI_RSIZE);
+		used = MIN(MIDIQ_LEN(m->inq), uio->uio_resid);
+		used = MIN(used, MIDI_RSIZE);
 
-	    MIDI_DEBUG(6,printf("midiread: uiomove cc=%d\n", used));
-	    MIDIQ_DEQ(m->inq, buf, used);
-	    retval = uiomove(buf, used, uio);
-	    if (retval)
-		goto err1;
+		MIDI_DEBUG(6, printf("midiread: uiomove cc=%d\n", used));
+		MIDIQ_DEQ(m->inq, buf, used);
+		retval = uiomove(buf, used, uio);
+		if (retval)
+			goto err1;
 	}
 
 	/*
@@ -785,7 +790,7 @@
 	retval = 0;
 err1:	mtx_unlock(&m->qlock);
 	mtx_unlock(&m->lock);
-err0:	MIDI_DEBUG(4, printf("midi_read: ret %d\n",retval));
+err0:	MIDI_DEBUG(4, printf("midi_read: ret %d\n", retval));
 	return retval;
 }
 
@@ -794,74 +799,76 @@
  */
 
 int
-midi_write(struct cdev *i_dev, struct uio * uio, int ioflag)
+midi_write(struct cdev *i_dev, struct uio *uio, int ioflag)
 {
 #define MIDI_WSIZE 32
 	struct snd_midi *m = i_dev->si_drv1;
-	int             retval;
-	int             used;
-	char            buf[MIDI_WSIZE];
+	int retval;
+	int used;
+	char buf[MIDI_WSIZE];
 
 
-	MIDI_DEBUG(4, printf("midi_write\n")); 
+	MIDI_DEBUG(4, printf("midi_write\n"));
 	retval = 0;
 	if (m == NULL)
-	    goto err0;
+		goto err0;
 
 	mtx_lock(&m->lock);
 	mtx_lock(&m->qlock);
 
 	if (!(m->flags & M_TX))
-	    goto err1;
+		goto err1;
 
 	while (uio->uio_resid > 0) {
-	    while (MIDIQ_AVAIL(m->outq) == 0) {
-		retval = EWOULDBLOCK;
-		if (ioflag & O_NONBLOCK)
-		    goto err1;
-		mtx_unlock(&m->lock);
-		m->wchan = 1;
-		MIDI_DEBUG(3,printf("midi_write msleep\n"));
-		retval = msleep(&m->wchan, &m->qlock,
-			PCATCH | PDROP, "midi TX", 0);
+		while (MIDIQ_AVAIL(m->outq) == 0) {
+			retval = EWOULDBLOCK;
+			if (ioflag & O_NONBLOCK)
+				goto err1;
+			mtx_unlock(&m->lock);
+			m->wchan = 1;
+			MIDI_DEBUG(3, printf("midi_write msleep\n"));
+			retval = msleep(&m->wchan, &m->qlock,
+			    PCATCH | PDROP, "midi TX", 0);
+			/*
+			 * We slept, maybe things have changed since last
+			 * dying check

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703171614.l2HGEs3a077699>