Module Name:    src
Committed By:   isaki
Date:           Mon Jul 31 14:53:08 UTC 2017

Modified Files:
        src/sys/arch/x68k/dev: vs.c

Log Message:
Update confused vs_set_params().
play and rec are identical but pfil and rfil are independent.
XXX I introduce VS_USE_PREC8 option for debugging purposes
    temporarily.  I'll remove it if the problem is solved.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x68k/dev/vs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.40 src/sys/arch/x68k/dev/vs.c:1.41
--- src/sys/arch/x68k/dev/vs.c:1.40	Sat Jul 29 07:30:39 2017
+++ src/sys/arch/x68k/dev/vs.c	Mon Jul 31 14:53:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.40 2017/07/29 07:30:39 nat Exp $	*/
+/*	$NetBSD: vs.c,v 1.41 2017/07/31 14:53:08 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.40 2017/07/29 07:30:39 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.41 2017/07/31 14:53:08 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -56,6 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.40 
 
 #include <arch/x68k/dev/vsvar.h>
 
+//#define VS_USE_PREC8 /* for debugging */
 #ifdef VS_DEBUG
 #define DPRINTF(y,x)	if (vs_debug >= (y)) printf x
 static int vs_debug;
@@ -329,9 +330,15 @@ vs_query_encoding(void *hdl, struct audi
 	DPRINTF(1, ("vs_query_encoding\n"));
 
 	if (fp->index == 0) {
+#if defined(VS_USE_PREC8)
+		strcpy(fp->name, AudioEslinear);
+		fp->encoding = AUDIO_ENCODING_SLINEAR;
+		fp->precision = 8;
+#else
 		strcpy(fp->name, AudioEslinear_be);
 		fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
 		fp->precision = 16;
+#endif
 		fp->flags = 0;
 		return 0;
 	}
@@ -380,6 +387,8 @@ vs_set_params(void *hdl, int setmode, in
 		setmode, play->encoding, play->sample_rate,
 		play->precision, play->channels));
 
+	/* *play and *rec are identical because !AUDIO_PROP_INDEPENDENT */
+
 	if (play->channels != 1) {
 		DPRINTF(1, ("channels not matched\n"));
 		return EINVAL;
@@ -391,33 +400,42 @@ vs_set_params(void *hdl, int setmode, in
 		return EINVAL;
 	}
 
-	if (play->encoding != AUDIO_ENCODING_SLINEAR_BE) {
-		DPRINTF(1, ("encoding not matched\n"));
-		return EINVAL;
-	}
-	if (play->precision != 16) {
-		DPRINTF(1, ("precision not matched\n"));
+#if defined(VS_USE_PREC8)
+	if (play->precision != 8 || play->encoding != AUDIO_ENCODING_SLINEAR) {
+#else
+	if (play->precision != 16 || play->encoding != AUDIO_ENCODING_SLINEAR_BE) {
+#endif
+		DPRINTF(1, ("prec/enc not matched\n"));
 		return EINVAL;
 	}
 
-	play->encoding = AUDIO_ENCODING_ADPCM;
-	play->validbits = 4;
-	play->precision = 4;
-
-	pfil->prepend(pfil, msm6258_slinear16_to_adpcm, play);
-	rfil->prepend(rfil, msm6258_adpcm_to_slinear16, play);
-
-	play->validbits = 16;
-	play->precision = 16;
-
-	pfil->prepend(pfil, null_filter, play);
-	rfil->prepend(rfil, null_filter, play);
-
 	sc->sc_current.prate = rate;
 	sc->sc_current.rrate = rate;
 
-	/* copy to rec because it's !AUDIO_PROP_INDEPENDENT */
-	*rec = *play;
+	/* pfil and rfil are independent even if !AUDIO_PROP_INDEPENDENT */
+
+	if ((setmode & AUMODE_PLAY) != 0) {
+		pfil->append(pfil, null_filter, play);
+		play->encoding = AUDIO_ENCODING_ADPCM;
+		play->validbits = 4;
+		play->precision = 4;
+#if defined(VS_USE_PREC8)
+		pfil->append(pfil, msm6258_linear8_to_adpcm, play);
+#else
+		pfil->append(pfil, msm6258_slinear16_to_adpcm, play);
+#endif
+	}
+	if ((setmode & AUMODE_RECORD) != 0) {
+		rfil->append(rfil, null_filter, rec);
+		rec->encoding = AUDIO_ENCODING_ADPCM;
+		rec->validbits = 4;
+		rec->precision = 4;
+#if defined(VS_USE_PREC8)
+		rfil->append(rfil, msm6258_adpcm_to_linear8, rec);
+#else
+		rfil->append(rfil, msm6258_adpcm_to_slinear16, rec);
+#endif
+	}
 
 	DPRINTF(1, ("accepted\n"));
 	return 0;

Reply via email to