Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/audio Move machine dependent AUDIO_BLK_MS default va...



details:   https://anonhg.NetBSD.org/src/rev/a917ab680015
branches:  trunk
changeset: 971675:a917ab680015
user:      isaki <isaki%NetBSD.org@localhost>
date:      Fri May 01 08:21:27 2020 +0000

description:
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

diffstat:

 sys/arch/hppa/include/param.h  |   7 ++++++-
 sys/arch/m68k/include/param.h  |   7 ++++++-
 sys/arch/sh3/include/param.h   |   7 ++++++-
 sys/arch/sparc/include/param.h |   5 ++++-
 sys/arch/vax/include/param.h   |   6 +++++-
 sys/dev/audio/audio.c          |  37 ++++++++++++-------------------------
 6 files changed, 39 insertions(+), 30 deletions(-)

diffs (160 lines):

diff -r 38ef050faf8b -r a917ab680015 sys/arch/hppa/include/param.h
--- a/sys/arch/hppa/include/param.h     Fri May 01 07:27:51 2020 +0000
+++ b/sys/arch/hppa/include/param.h     Fri May 01 08:21:27 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.26 2020/03/21 17:00:47 riastradh Exp $     */
+/*     $NetBSD: param.h,v 1.27 2020/05/01 08:21:27 isaki 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
diff -r 38ef050faf8b -r a917ab680015 sys/arch/m68k/include/param.h
--- a/sys/arch/m68k/include/param.h     Fri May 01 07:27:51 2020 +0000
+++ b/sys/arch/m68k/include/param.h     Fri May 01 08:21:27 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.22 2019/01/07 22:00:31 jdolecek Exp $      */
+/*     $NetBSD: param.h,v 1.23 2020/05/01 08:21:27 isaki 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_ */
diff -r 38ef050faf8b -r a917ab680015 sys/arch/sh3/include/param.h
--- a/sys/arch/sh3/include/param.h      Fri May 01 07:27:51 2020 +0000
+++ b/sys/arch/sh3/include/param.h      Fri May 01 08:21:27 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.24 2019/01/07 22:00:32 jdolecek Exp $      */
+/*     $NetBSD: param.h,v 1.25 2020/05/01 08:21:27 isaki 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_ */
diff -r 38ef050faf8b -r a917ab680015 sys/arch/sparc/include/param.h
--- a/sys/arch/sparc/include/param.h    Fri May 01 07:27:51 2020 +0000
+++ b/sys/arch/sparc/include/param.h    Fri May 01 08:21:27 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.73 2019/05/15 16:59:10 christos Exp $ */
+/*     $NetBSD: param.h,v 1.74 2020/05/01 08:21:27 isaki Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -155,4 +155,7 @@
 #      define PGSHIFT          pgshift
 #endif
 
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#define        __AUDIO_BLK_MS (40)
+
 #endif /* _KERNEL || _STANDALONE */
diff -r 38ef050faf8b -r a917ab680015 sys/arch/vax/include/param.h
--- a/sys/arch/vax/include/param.h      Fri May 01 07:27:51 2020 +0000
+++ b/sys/arch/vax/include/param.h      Fri May 01 08:21:27 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: param.h,v 1.62 2019/01/07 22:00:33 jdolecek Exp $    */
+/*      $NetBSD: param.h,v 1.63 2020/05/01 08:21:27 isaki Exp $    */
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
@@ -118,6 +118,10 @@
 
 #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_ */
diff -r 38ef050faf8b -r a917ab680015 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Fri May 01 07:27:51 2020 +0000
+++ b/sys/dev/audio/audio.c     Fri May 01 08:21:27 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.68 2020/04/29 03:58:27 isaki Exp $ */
+/*     $NetBSD: audio.c,v 1.69 2020/05/01 08:21:27 isaki Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.68 2020/04/29 03:58:27 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.69 2020/05/01 08:21:27 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -454,38 +454,25 @@
 /*
  * Default hardware blocksize in msec.
  *
- * We use 10 msec for most platforms.  This period is good enough to play
- * audio and video synchronizely.
+ * 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.
+ * 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.
- *
- * 40 msec was initially choosen for the following reason:
- * (1 / 40ms) = 25 = 5^2.  Thus, the frequency is factored by 5.
- * 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(__hppa__)  || \
-    defined(__m68k__)  || \
-    defined(__sh3__)   || \
-    (defined(__sparc__) && !defined(__sparc64__))      || \
-    defined(__vax__)
-#define AUDIO_TOO_SLOW_ARCHS 1
-#endif
-
+ */
 #if !defined(AUDIO_BLK_MS)
-# if defined(AUDIO_TOO_SLOW_ARCHS)
-#  define AUDIO_BLK_MS 40
+# if defined(__AUDIO_BLK_MS)
+#  define AUDIO_BLK_MS __AUDIO_BLK_MS
 # else
-#  define AUDIO_BLK_MS 10
+#  define AUDIO_BLK_MS (10)
 # endif
 #endif
 
-#undef AUDIO_TOO_SLOW_ARCHS
-
 /* Device timeout in msec */
 #define AUDIO_TIMEOUT  (3000)
 



Home | Main Index | Thread Index | Old Index