patch-2.2.18 linux/drivers/sound/emu10k1/voicemgr.c

Next file: linux/drivers/sound/emu10k1/voicemgr.h
Previous file: linux/drivers/sound/emu10k1/recmgr.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/drivers/sound/emu10k1/voicemgr.c linux/drivers/sound/emu10k1/voicemgr.c
@@ -32,7 +32,7 @@
 #include "voicemgr.h"
 #include "8010.h"
 
-int emu10k1_voice_alloc(struct emu10k1_card *card, struct emu_voice *voice, struct voice_allocdesc *voiceallocdesc)
+int emu10k1_voice_alloc(struct emu10k1_card *card, struct emu_voice *voice)
 {
 	u8 *voicetable = card->voicetable;
 	int i;
@@ -42,17 +42,17 @@
 
 	spin_lock_irqsave(&card->lock, flags);
 
-	if (voiceallocdesc->flags & VOICE_FLAGS_STEREO) {
+	if (voice->flags & VOICE_FLAGS_STEREO) {
 		for (i = 0; i < NUM_G; i += 2)
 			if ((voicetable[i] == VOICE_USAGE_FREE) && (voicetable[i + 1] == VOICE_USAGE_FREE)) {
-				voicetable[i] = voiceallocdesc->usage;
-				voicetable[i + 1] = voiceallocdesc->usage;
+				voicetable[i] = voice->usage;
+				voicetable[i + 1] = voice->usage;
 				break;
 			}
 	} else {
 		for (i = 0; i < NUM_G; i++)
 			if (voicetable[i] == VOICE_USAGE_FREE) {
-				voicetable[i] = voiceallocdesc->usage;
+				voicetable[i] = voice->usage;
 				break;
 			}
 	}
@@ -63,8 +63,6 @@
 		return -1;
 
 	voice->card = card;
-	voice->flags = voiceallocdesc->flags;
-	voice->usage = voiceallocdesc->usage;
 	voice->num = i;
 
 #ifdef PRIVATE_PCM_VOLUME
@@ -99,7 +97,6 @@
 {
 	struct emu10k1_card *card = voice->card;
 	int i;
-	u32 cra, sample;
 	unsigned long flags;
 
 	DPF(2, "emu10k1_voice_free()\n");
@@ -122,9 +119,7 @@
 #endif
 
 	for (i = 0; i < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); i++) {
-		int cra1;
-
-		DPD(2, " voice freed -> %d\n", voice->num + i);
+		DPD(2, " voice released -> %d\n", voice->num + i);
 
 		sblive_writeptr_tag(card, voice->num + i, DCYSUSV, 0, 
 							VTFT, 0x0000ffff,
@@ -132,15 +127,6 @@
 							CVCF, 0x0000ffff,
 							CPF, 0,
 							TAGLIST_END);
-
-		sample = (voice->flags & VOICE_FLAGS_16BIT) ? 0 : 0x80808080;
-		cra = sblive_readptr(card, CCR, voice->num) & CCR_READADDRESS_MASK;
-		cra1 = (cra >> 18) & 0xf;
-
-		sblive_writeptr_tag(card, voice->num + i, CCR, cra,
-							CD0 + cra1, sample,
-							CD0 + ((cra1 + 0x1) & 0xf), sample,
-							TAGLIST_END);
 	}
 
 	voice->usage = VOICE_USAGE_FREE;
@@ -157,91 +143,48 @@
 	return;
 }
 
-/*       Sets up a voices for Wave Playback */
-
 void emu10k1_voice_playback_setup(struct emu_voice *voice)
 {
 	struct emu10k1_card *card = voice->card;
-	u32 sample, cra = 0, start = 0;
+	u32 start;
 	int i;
 
 	DPF(2, "emu10k1_voice_playback_setup()\n");
 
-	for (i = 0; i < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); i++) {
-		sblive_writeptr(card, FXRT, voice->num + i, voice->params[i].bus_routing << 16);
-
-		/* Stop CA */
-		/* Assumption that PT is alreadt 0 so no harm overwriting */
-		sblive_writeptr(card, PTRX, voice->num + i, (voice->params[i].send_a << 8) | voice->params[i].send_b);
-
-		if (i == 0) {
-			if (voice->flags & VOICE_FLAGS_STEREO) {
-				/* Set stereo bit */
-				cra = 64;
-				sblive_writeptr(card, CPF, voice->num, CPF_STEREO_MASK);
-				sblive_writeptr(card, CPF, voice->num + 1, CPF_STEREO_MASK);
-			} else {
-				cra = 32;
-				sblive_writeptr(card, CPF, voice->num, 0);
-			}
-
-			if (voice->flags & VOICE_FLAGS_16BIT)
-				sample = 0;
-			else {
-				cra = cra * 2;
-				sample = 0x80808080;
-			}
-			cra -= 4;
+	if (voice->flags & VOICE_FLAGS_STEREO) {
+		/* Set stereo bit */
+		start = 28;
+		sblive_writeptr(card, CPF, voice->num, CPF_STEREO_MASK);
+		sblive_writeptr(card, CPF, voice->num + 1, CPF_STEREO_MASK);
+	} else {
+		start = 30;
+		sblive_writeptr(card, CPF, voice->num, 0);
+	}
 
-			if (voice->flags & VOICE_FLAGS_STEREO) {
-				/* CCR_READADDRESS_MASK */
-				sblive_writeptr(card, CCR, voice->num, 0x3c << 16);
-				sblive_writeptr_tag(card, voice->num + 1, CCR, cra << 16, CDE, sample, CDF, sample, TAGLIST_END);
-				start = voice->start + cra / 2;
-			} else {
-				sblive_writeptr_tag(card, voice->num, CCR, 0x1c << 16,	/* FIXME: Is 0x1c correct? */
-						    CDE, sample, CDF, sample, TAGLIST_END);
-				start = voice->start + cra;
-			}
+	if(!(voice->flags & VOICE_FLAGS_16BIT))
+		start *= 2;
 
-			if (start > voice->endloop) {
-				start -= voice->endloop;
+	voice->start += start;
 
-				if (voice->flags & VOICE_FLAGS_STEREO)
-					cra = (cra << 25) | 0x1bc0000 | ((cra - start) << 9);
-				else
-					cra = (cra << 25) | 0x11c0000 | ((cra - start) << 9);
-
-				start += voice->startloop;
-
-				if (start >= voice->endloop)
-					start = voice->endloop - 1;
-			} else if (voice->flags & VOICE_FLAGS_STEREO)
-				cra = (cra << 25) | (0x3c << 16);
-			else
-				cra = (cra << 25) | (0x1c << 16);
+	for (i = 0; i < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); i++) {
+		sblive_writeptr(card, FXRT, voice->num + i, voice->params[i].send_routing << 16);
 
-			start |= CCCA_INTERPROM_0;
-		}
+		/* Stop CA */
+		/* Assumption that PT is already 0 so no harm overwriting */
+		sblive_writeptr(card, PTRX, voice->num + i, (voice->params[i].send_a << 8) | voice->params[i].send_b);
 
-		/* CSL, ST, CA */
 		sblive_writeptr_tag(card, voice->num + i,
+				/* CSL, ST, CA */
 				    DSL, voice->endloop | (voice->params[i].send_d << 24),
 				    PSST, voice->startloop | (voice->params[i].send_c << 24),
-				    CCCA, start | ((voice->flags & VOICE_FLAGS_16BIT) ? 0 : CCCA_8BITSELECT),
+				    CCCA, (voice->start) | CCCA_INTERPROM_0 | ((voice->flags & VOICE_FLAGS_16BIT) ? 0 : CCCA_8BITSELECT),
 				    /* Clear filter delay memory */
 				    Z1, 0,
 				    Z2, 0,
 				    /* Invalidate maps */
 				    MAPA, MAP_PTI_MASK | (card->silentpage.dma_handle * 2),
-				    MAPB, MAP_PTI_MASK | (card->silentpage.dma_handle * 2), TAGLIST_END);
-
-		/* Fill cache */
-		if (i == 0)
-			sblive_writeptr(card, CCR, voice->num, cra);
-
-		/* modulation envelope */
-		sblive_writeptr_tag(card, voice->num + i,
+				    MAPB, MAP_PTI_MASK | (card->silentpage.dma_handle * 2),
+				/* modulation envelope */
 				    CVCF, 0x0000ffff,
 				    VTFT, 0x0000ffff,
 				    ATKHLDM, 0,
@@ -252,12 +195,12 @@
 				    TREMFRQ, 0,
 				    FM2FRQ2, 0,
 				    ENVVAL, 0x8000,
-				    /* volume envelope */
+				/* volume envelope */
 				    ATKHLDV, 0x7f7f,
 				    ENVVOL, 0x8000,
-				    /* filter envelope */
+				/* filter envelope */
 				    PEFE_FILTERAMOUNT, 0x7f,
-				    /* pitch envelope */
+				/* pitch envelope */
 				    PEFE_PITCHAMOUNT, 0, TAGLIST_END);
 
 #ifdef PRIVATE_PCM_VOLUME
@@ -286,13 +229,49 @@
 	return;
 }
 
-void emu10k1_voice_start(struct emu_voice *voice)
+void emu10k1_voice_start(struct emu_voice *voice, int set)
 {
 	struct emu10k1_card *card = voice->card;
 	int i;
 
 	DPF(2, "emu10k1_voice_start()\n");
 
+	if (!set) {
+		u32 cra, ccis, cs, sample;
+		if (voice->flags & VOICE_FLAGS_STEREO) {
+			cra = 64;
+			ccis = 28;
+			cs = 4;
+		} else {
+			cra = 64;
+			ccis = 30;
+			cs = 2;
+		}
+
+		if(voice->flags & VOICE_FLAGS_16BIT) {
+			sample = 0x00000000;
+		} else {
+			sample = 0x80808080;		
+			ccis *= 2;
+		}
+
+		for(i = 0; i < cs; i++)
+	                sblive_writeptr(card, CD0 + i, voice->num, sample);
+
+		/* Reset cache */
+		sblive_writeptr(card, CCR_CACHEINVALIDSIZE, voice->num, 0);
+		if (voice->flags & VOICE_FLAGS_STEREO)
+			sblive_writeptr(card, CCR_CACHEINVALIDSIZE, voice->num + 1, 0);
+
+		sblive_writeptr(card, CCR_READADDRESS, voice->num, cra);
+
+		if (voice->flags & VOICE_FLAGS_STEREO)
+			sblive_writeptr(card, CCR_READADDRESS, voice->num + 1, cra);
+
+		/* Fill cache */
+		sblive_writeptr(card, CCR_CACHEINVALIDSIZE, voice->num, ccis);
+	}
+
 	for (i = 0; i < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); i++) {
 		sblive_writeptr_tag(card, voice->num + i,
 				    IFATN, (voice->params[i].initial_fc << 8) | voice->params[i].initial_attn,
@@ -301,18 +280,7 @@
 				    DCYSUSV, (voice->params[i].byampl_env_sustain << 8) | voice->params[i].byampl_env_decay,
 				    TAGLIST_END);
 
-		/* Using StopOnLoop for MIDI stops the playback
-		   too early, which may cause a DC level to be played
-		   until the note is released. */
-
-		if (voice->usage == VOICE_USAGE_MIDI)
-			emu10k1_clear_stop_on_loop(card, voice->num + i);
-		else {
-			if (voice->startloop > voice->end)
-				emu10k1_set_stop_on_loop(card, voice->num + i);
-			else
-				emu10k1_clear_stop_on_loop(card, voice->num + i);
-		}
+		emu10k1_clear_stop_on_loop(card, voice->num + i);
 
 		sblive_writeptr(card, PTRX_PITCHTARGET, voice->num + i, voice->pitch_target);
 
@@ -333,32 +301,16 @@
 	DPF(2, "emu10k1_voice_stop()\n");
 
 	for (i = 0; i < (voice->flags & VOICE_FLAGS_STEREO ? 2 : 1); i++) {
-		sblive_writeptr_tag(card, voice->num + i, IFATN, 0xffff,
-				    VTFT, 0x0000ffff,
-				    PTRX_PITCHTARGET, 0,
-				    IP, 0,
-				    TAGLIST_END);
+		sblive_writeptr_tag(card, voice->num + i,
+					PTRX_PITCHTARGET, 0,
+					CPF_CURRENTPITCH, 0,
+					IFATN, 0xffff,
+					VTFT, 0x0000ffff,
+					CVCF, 0x0000ffff,
+					IP, 0,
+					TAGLIST_END);
 	}
 
 	return;
 }
 
-void emu10k1_voice_setcontrol(struct emu_voice *voice, struct voice_cntlset *setting, u32 numparam)
-{
-	struct emu10k1_card *card = voice->card;
-	int count;
-
-	for (count = 0; count < numparam; count++)
-		sblive_writeptr(card, setting[count].paramID, voice->num, setting[count].value);
-
-	return;
-}
-
-void emu10k1_voice_getcontrol(struct emu_voice *voice, u32 controlid, u32 * value)
-{
-	struct emu10k1_card *card = voice->card;
-
-	*value = sblive_readptr(card, controlid, voice->num);
-
-	return;
-}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)