Module Name:    src
Committed By:   martin
Date:           Mon May 18 18:12:25 UTC 2020

Modified Files:
        src/sys/arch/amd64/conf [netbsd-9]: GENERIC
        src/sys/arch/evbarm/conf [netbsd-9]: GENERIC GENERIC64
        src/sys/arch/hppa/include [netbsd-9]: param.h
        src/sys/arch/m68k/include [netbsd-9]: param.h
        src/sys/arch/sh3/include [netbsd-9]: param.h
        src/sys/arch/sparc/include [netbsd-9]: param.h
        src/sys/arch/vax/include [netbsd-9]: param.h
        src/sys/dev/audio [netbsd-9]: audio.c audiodef.h

Log Message:
Pull up following revision(s) (requested by isaki in ticket #911):

        sys/dev/audio/audiodef.h: revision 1.13
        sys/dev/audio/audiodef.h: revision 1.14
        sys/arch/sparc/include/param.h: revision 1.74
        sys/arch/evbarm/conf/GENERIC64: revision 1.148
        sys/arch/sh3/include/param.h: revision 1.25
        sys/arch/evbarm/conf/GENERIC: revision 1.75
        sys/arch/m68k/include/param.h: revision 1.23
        sys/arch/amd64/conf/GENERIC: revision 1.564
        sys/arch/hppa/include/param.h: revision 1.27
        sys/dev/audio/audio.c: revision 1.68
        sys/arch/vax/include/param.h: revision 1.63
        sys/dev/audio/audio.c: revision 1.69

Reduce default AUDIO_BLK_MS from 40msec to 10msec on all platform except m68k
(m68k uses 40msec default as before).  And remove the option from GENERIC.

- It's not good idea to set such parameter in individual GENERICs.
- 4msec is (probably no problem for most modern real hardware but)
  too aggressive to be default.
- 10msec is too severe for antique machines but it's hard to draw a line.

Set AUDIO_BLK_MS 40 msec on other old(slow) architectures not only m68k.

Thanks tsutsui@ for comment about architecture choice.
And move it from audiodef.h to audio.c as suggested by joerg@.

Move machine dependent AUDIO_BLK_MS default value to <machine/param.h>.
If the port has __AUDIO_BLK_MS in <machine/param.h>, it will be used.

Otherwise the default value (currently 10 msec) defined in audio.c will
be used.  This mechanism is for very old ports which cannot satisfactorily
handle 10 msec block.  Currently hppa, m68k, sh3, sparc(!64) and vax are.

For port maintainers, if general models in your port cannot satisfactorily
handle 10 msec block, please consider to define your suitable longer period
(40 msec would be a good first choice).

But please don't be eager to make the default value shorter.
<machine/param.h> was discussed in source-changes-d.  It's better than
ifdef storm, or adding 60+ new header files in every arch/*/include/
directories for this.  Thanks mrg@, ad@, and everyone.
http://mail-index.netbsd.org/source-changes-d/2020/05/01/msg012572.html


To generate a diff of this commit:
cvs rdiff -u -r1.531.2.8 -r1.531.2.9 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.48.2.7 -r1.48.2.8 src/sys/arch/evbarm/conf/GENERIC
cvs rdiff -u -r1.103.2.9 -r1.103.2.10 src/sys/arch/evbarm/conf/GENERIC64
cvs rdiff -u -r1.23 -r1.23.4.1 src/sys/arch/hppa/include/param.h
cvs rdiff -u -r1.22 -r1.22.4.1 src/sys/arch/m68k/include/param.h
cvs rdiff -u -r1.24 -r1.24.4.1 src/sys/arch/sh3/include/param.h
cvs rdiff -u -r1.73 -r1.73.2.1 src/sys/arch/sparc/include/param.h
cvs rdiff -u -r1.62 -r1.62.4.1 src/sys/arch/vax/include/param.h
cvs rdiff -u -r1.28.2.14 -r1.28.2.15 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.7.2.3 -r1.7.2.4 src/sys/dev/audio/audiodef.h

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/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.531.2.8 src/sys/arch/amd64/conf/GENERIC:1.531.2.9
--- src/sys/arch/amd64/conf/GENERIC:1.531.2.8	Mon Jan 27 07:06:02 2020
+++ src/sys/arch/amd64/conf/GENERIC	Mon May 18 18:12:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.531.2.8 2020/01/27 07:06:02 martin Exp $
+# $NetBSD: GENERIC,v 1.531.2.9 2020/05/18 18:12:25 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.531.2.8 $"
+#ident		"GENERIC-$Revision: 1.531.2.9 $"
 
 maxusers	64		# estimated number of users
 
@@ -55,9 +55,6 @@ maxusers	64		# estimated number of users
 
 options 	INSECURE	# disable kernel security levels - X needs this
 
-options		AUDIO_BLK_MS=4	# make software with low latency needs performant
-				# no substantial CPU overhead on this platform
-
 options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
 options 	NTP		# NTP phase/frequency locked loop
 

Index: src/sys/arch/evbarm/conf/GENERIC
diff -u src/sys/arch/evbarm/conf/GENERIC:1.48.2.7 src/sys/arch/evbarm/conf/GENERIC:1.48.2.8
--- src/sys/arch/evbarm/conf/GENERIC:1.48.2.7	Thu Apr  2 19:20:07 2020
+++ src/sys/arch/evbarm/conf/GENERIC	Mon May 18 18:12:25 2020
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC,v 1.48.2.7 2020/04/02 19:20:07 martin Exp $
+#	$NetBSD: GENERIC,v 1.48.2.8 2020/05/18 18:12:25 martin Exp $
 #
 #	GENERIC ARM (aarch32) kernel
 #
@@ -614,7 +614,6 @@ sun8icodec* 	at fdt?			# Audio codec (su
 sunxicodec* 	at fdt?			# Allwinner audio codec
 sunxii2s* 	at fdt?			# I2S/PCM
 audio* 		at audiobus?
-options 	AUDIO_BLK_MS=4
 spkr* 		at audio?
 
 # SDMMC

Index: src/sys/arch/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.103.2.9 src/sys/arch/evbarm/conf/GENERIC64:1.103.2.10
--- src/sys/arch/evbarm/conf/GENERIC64:1.103.2.9	Thu Apr  2 19:20:07 2020
+++ src/sys/arch/evbarm/conf/GENERIC64	Mon May 18 18:12:25 2020
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.103.2.9 2020/04/02 19:20:07 martin Exp $
+#	$NetBSD: GENERIC64,v 1.103.2.10 2020/05/18 18:12:25 martin Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -426,7 +426,6 @@ h3codec*	at fdt?			# Allwinner H3 audio 
 a64acodec*	at fdt?			# Allwinner A64 audio codec (analog part)
 sunxii2s*	at fdt?			# Allwinner I2S/PCM
 audio*		at audiobus?
-options 	AUDIO_BLK_MS=4
 
 spkr*		at audio?		# PC speaker (synthesized)
 

Index: src/sys/arch/hppa/include/param.h
diff -u src/sys/arch/hppa/include/param.h:1.23 src/sys/arch/hppa/include/param.h:1.23.4.1
--- src/sys/arch/hppa/include/param.h:1.23	Tue Apr 16 12:25:17 2019
+++ src/sys/arch/hppa/include/param.h	Mon May 18 18:12:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.23 2019/04/16 12:25:17 skrll Exp $	*/
+/*	$NetBSD: param.h,v 1.23.4.1 2020/05/18 18:12:25 martin Exp $	*/
 
 /*	$OpenBSD: param.h,v 1.12 2001/07/06 02:07:41 provos Exp $	*/
 
@@ -88,3 +88,8 @@
 
 #define btop(x)		((unsigned long)(x) >> PGSHIFT)
 #define ptob(x)		((unsigned long)(x) << PGSHIFT)
+
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#if defined(_KERNEL)
+#define	__AUDIO_BLK_MS (40)
+#endif

Index: src/sys/arch/m68k/include/param.h
diff -u src/sys/arch/m68k/include/param.h:1.22 src/sys/arch/m68k/include/param.h:1.22.4.1
--- src/sys/arch/m68k/include/param.h:1.22	Mon Jan  7 22:00:31 2019
+++ src/sys/arch/m68k/include/param.h	Mon May 18 18:12:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.22 2019/01/07 22:00:31 jdolecek Exp $	*/
+/*	$NetBSD: param.h,v 1.22.4.1 2020/05/18 18:12:25 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -95,4 +95,9 @@
 #define	m68k_btop(x)		((vaddr_t)(x) >> PGSHIFT)
 #define	m68k_ptob(x)		((vaddr_t)(x) << PGSHIFT)
 
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#if defined(_KERNEL)
+#define	__AUDIO_BLK_MS (40)
+#endif
+
 #endif	/* !_M68K_PARAM_H_ */

Index: src/sys/arch/sh3/include/param.h
diff -u src/sys/arch/sh3/include/param.h:1.24 src/sys/arch/sh3/include/param.h:1.24.4.1
--- src/sys/arch/sh3/include/param.h:1.24	Mon Jan  7 22:00:32 2019
+++ src/sys/arch/sh3/include/param.h	Mon May 18 18:12:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.24 2019/01/07 22:00:32 jdolecek Exp $	*/
+/*	$NetBSD: param.h,v 1.24.4.1 2020/05/18 18:12:25 martin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@@ -91,4 +91,9 @@
 #define	NKMEMPAGES_MIN_DEFAULT	((16 * 1024 * 1024) >> PAGE_SHIFT)
 #define	NKMEMPAGES_MAX_DEFAULT	((128 * 1024 * 1024) >> PAGE_SHIFT)
 
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#if defined(_KERNEL)
+#define	__AUDIO_BLK_MS (40)
+#endif
+
 #endif /* !_SH3_PARAM_H_ */

Index: src/sys/arch/sparc/include/param.h
diff -u src/sys/arch/sparc/include/param.h:1.73 src/sys/arch/sparc/include/param.h:1.73.2.1
--- src/sys/arch/sparc/include/param.h:1.73	Wed May 15 16:59:10 2019
+++ src/sys/arch/sparc/include/param.h	Mon May 18 18:12:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.73 2019/05/15 16:59:10 christos Exp $ */
+/*	$NetBSD: param.h,v 1.73.2.1 2020/05/18 18:12:25 martin Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -155,4 +155,7 @@ extern void	delay(unsigned int);
 #	define PGSHIFT		pgshift
 #endif
 
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#define	__AUDIO_BLK_MS (40)
+
 #endif /* _KERNEL || _STANDALONE */

Index: src/sys/arch/vax/include/param.h
diff -u src/sys/arch/vax/include/param.h:1.62 src/sys/arch/vax/include/param.h:1.62.4.1
--- src/sys/arch/vax/include/param.h:1.62	Mon Jan  7 22:00:33 2019
+++ src/sys/arch/vax/include/param.h	Mon May 18 18:12:25 2020
@@ -1,4 +1,4 @@
-/*      $NetBSD: param.h,v 1.62 2019/01/07 22:00:33 jdolecek Exp $    */
+/*      $NetBSD: param.h,v 1.62.4.1 2020/05/18 18:12:25 martin Exp $    */
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
@@ -118,6 +118,10 @@ void	delay(int);
 
 #define	DELAY(x) delay(x)
 #define	MAXEXEC	1
+
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#define	__AUDIO_BLK_MS (40)
+
 #endif /* _KERNEL */
 
 #endif /* _VAX_PARAM_H_ */

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.14 src/sys/dev/audio/audio.c:1.28.2.15
--- src/sys/dev/audio/audio.c:1.28.2.14	Mon May 18 18:05:34 2020
+++ src/sys/dev/audio/audio.c	Mon May 18 18:12:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.14 2020/05/18 18:05:34 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.15 2020/05/18 18:12:24 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.14 2020/05/18 18:05:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.15 2020/05/18 18:12:24 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -454,6 +454,28 @@ audio_track_bufstat(audio_track_t *track
 #define SPECIFIED(x)	((x) != ~0)
 #define SPECIFIED_CH(x)	((x) != (u_char)~0)
 
+/*
+ * Default hardware blocksize in msec.
+ *
+ * We use 10 msec for most modern platforms.  This period is good enough to
+ * play audio and video synchronizely.
+ * In contrast, for very old platforms, this is usually too short and too
+ * severe.  Also such platforms usually can not play video confortably, so
+ * it's not so important to make the blocksize shorter.  If the platform
+ * defines its own value as __AUDIO_BLK_MS in its <machine/param.h>, it
+ * uses this instead.
+ *
+ * In either case, you can overwrite AUDIO_BLK_MS by your kernel
+ * configuration file if you wish.
+ */
+#if !defined(AUDIO_BLK_MS)
+# if defined(__AUDIO_BLK_MS)
+#  define AUDIO_BLK_MS __AUDIO_BLK_MS
+# else
+#  define AUDIO_BLK_MS (10)
+# endif
+#endif
+
 /* Device timeout in msec */
 #define AUDIO_TIMEOUT	(3000)
 

Index: src/sys/dev/audio/audiodef.h
diff -u src/sys/dev/audio/audiodef.h:1.7.2.3 src/sys/dev/audio/audiodef.h:1.7.2.4
--- src/sys/dev/audio/audiodef.h:1.7.2.3	Sat Mar 21 15:47:00 2020
+++ src/sys/dev/audio/audiodef.h	Mon May 18 18:12:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiodef.h,v 1.7.2.3 2020/03/21 15:47:00 martin Exp $	*/
+/*	$NetBSD: audiodef.h,v 1.7.2.4 2020/05/18 18:12:24 martin Exp $	*/
 
 /*
  * Copyright (C) 2017 Tetsuya Isaki. All rights reserved.
@@ -43,17 +43,6 @@
 #define AUMINNOBLK	(3)
 
 /*
- * Hardware blocksize in msec.
- * We use 40 msec as default.  (1 / 40ms) = 25 = 5^2.
- * In this case, the number of frames in a block can be an integer
- * even if the frequency is a multiple of 100 (44100, 48000, etc),
- * or even if 15625Hz (vs(4)).
- */
-#if !defined(AUDIO_BLK_MS)
-#define AUDIO_BLK_MS 40
-#endif
-
-/*
  * Whether the playback mixer use single buffer mode.
  * It reduces the latency one block but needs machine power.
  * In case of the double buffer (as default), it increases the latency

Reply via email to