Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/dev/hdaudio Pull up following revision(s) (requested ...
details: https://anonhg.NetBSD.org/src/rev/7ae629f51d5b
branches: netbsd-9
changeset: 963810:7ae629f51d5b
user: martin <martin%NetBSD.org@localhost>
date: Sat Apr 25 10:40:45 2020 +0000
description:
Pull up following revision(s) (requested by isaki in ticket #852):
sys/dev/hdaudio/hdafg.c: revision 1.22
Make round_blocksize satisfy all of
- restrictions that existed before merging isaki-audio2 branch.
- better support for 6 channels hardware.
- audio layer's requirement.
This may help PR kern/54474.
diffstat:
sys/dev/hdaudio/hdafg.c | 43 +++++++++++++++++++++++++++++++++++--------
1 files changed, 35 insertions(+), 8 deletions(-)
diffs (85 lines):
diff -r 7f351a15ff33 -r 7ae629f51d5b sys/dev/hdaudio/hdafg.c
--- a/sys/dev/hdaudio/hdafg.c Fri Apr 24 17:48:01 2020 +0000
+++ b/sys/dev/hdaudio/hdafg.c Sat Apr 25 10:40:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdafg.c,v 1.18 2019/06/08 08:02:38 isaki Exp $ */
+/* $NetBSD: hdafg.c,v 1.18.2.1 2020/04/25 10:40:45 martin Exp $ */
/*
* Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.18 2019/06/08 08:02:38 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.18.2.1 2020/04/25 10:40:45 martin Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -3934,12 +3934,28 @@
return 0;
}
+/* LCM for round_blocksize */
+static u_int gcd(u_int, u_int);
+static u_int lcm(u_int, u_int);
+
+static u_int gcd(u_int a, u_int b)
+{
+
+ return (b == 0) ? a : gcd(b, a % b);
+}
+static u_int lcm(u_int a, u_int b)
+{
+
+ return a * b / gcd(a, b);
+}
+
static int
hdafg_round_blocksize(void *opaque, int blksize, int mode,
const audio_params_t *param)
{
struct hdaudio_audiodev *ad = opaque;
struct hdaudio_stream *st;
+ u_int minblksize;
int bufsize;
st = (mode == AUMODE_PLAY) ? ad->ad_playback : ad->ad_capture;
@@ -3949,6 +3965,15 @@
return 128;
}
+ if (blksize > 8192)
+ blksize = 8192;
+
+ /* Make sure there are enough BDL descriptors */
+ bufsize = st->st_data.dma_size;
+ if (bufsize > HDAUDIO_BDL_MAX * blksize) {
+ blksize = bufsize / HDAUDIO_BDL_MAX;
+ }
+
/*
* HD audio's buffer constraint looks like following:
* - The buffer MUST start on a 128bytes boundary.
@@ -3956,13 +3981,15 @@
* - The buffer size is preferred multiple of 128bytes for efficiency.
*
* https://www.intel.co.jp/content/www/jp/ja/standards/high-definition-audio-specification.html , p70.
+ *
+ * Also, the audio layer requires that the blocksize must be a
+ * multiple of the number of channels.
*/
-
- /* Make sure there are enough BDL descriptors */
- bufsize = st->st_data.dma_size;
- if (bufsize > HDAUDIO_BDL_MAX * blksize) {
- blksize = bufsize / HDAUDIO_BDL_MAX;
- }
+ minblksize = lcm(128, param->channels);
+ blksize = rounddown(blksize, minblksize);
+ if (blksize < minblksize)
+ blksize = minblksize;
+
return blksize;
}
Home |
Main Index |
Thread Index |
Old Index