summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Liu2018-09-01 20:17:17 +1000
committerJonathan Liu2018-09-01 20:17:17 +1000
commit74e00b089a4c22eb1865a75aee4fc15e30199d61 (patch)
tree5346108a76fe5605e9c4a0e8ca3e7985d4f70220
parent9a03248489ffb2eeca43b32d4f2e7b9a09fc5594 (diff)
downloadaur-74e00b089a4c22eb1865a75aee4fc15e30199d61.tar.gz
Update to 4.18.5-1
-rw-r--r--.SRCINFO13
-rw-r--r--PKGBUILD14
-rw-r--r--lowlatency.patch17
-rw-r--r--parameters.patch204
-rw-r--r--snd-usb-audio-lowlatency-dkms.install14
-rw-r--r--snd-usb-audio.conf21
6 files changed, 256 insertions, 27 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 6f6fbd30a88a..e90926ca4c70 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,21 +1,24 @@
pkgbase = snd-usb-audio-lowlatency-dkms
pkgdesc = snd-usb-audio kernel module modified for low latency
- pkgver = 4.18.4
+ pkgver = 4.18.5
pkgrel = 1
url = https://www.kernel.org/
+ install = snd-usb-audio-lowlatency-dkms.install
arch = any
license = GPL2
depends = dkms
source = https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.18.tar.xz
- source = https://cdn.kernel.org/pub/linux/kernel/v4.x/patch-4.18.4.xz
+ source = https://cdn.kernel.org/pub/linux/kernel/v4.x/patch-4.18.5.xz
source = dkms.conf
- source = lowlatency.patch
+ source = parameters.patch
+ source = snd-usb-audio.conf
validpgpkeys = ABAF11C65A2970B130ABE3C479BE3E4300411886
validpgpkeys = 647F28654894E3BD457199BE38DBBDC86092693E
sha256sums = 19d8bcf49ef530cd4e364a45b4a22fa70714b70349c8100e7308488e26f1eaf1
- sha256sums = cc22261cd9651dc2a05ad817a5b5fd3c63076ca86abfade7097915e7ba0b3bd6
+ sha256sums = c88a4e56ab8a37e38c76dbb12be53a2a3379e920ce4b86003ccfff8a4a9d1f69
sha256sums = 69f325c3af92c4098c9d118b2eab7de76eba691677864f714697bce5f47005e2
- sha256sums = c2b7784899d184b142c5969c1be17cc949f11f4e59fbe5b1a8ffe062a1c4a88f
+ sha256sums = 7c9b89931e4edc595dda38f8c6116dc45d10d191885c52aba3d9d8efdc26d261
+ sha256sums = 346e8ae33ac878530f5a9538424f006f0f6017a5d26852cd917d209eb1ab3add
pkgname = snd-usb-audio-lowlatency-dkms
diff --git a/PKGBUILD b/PKGBUILD
index 301ceeb8b9df..dba7dca72670 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
# Maintainer: Jonathan Liu <net147@gmail.com>
pkgname=snd-usb-audio-lowlatency-dkms
_basepkgname=snd-usb-audio-lowlatency
-pkgver=4.18.4
+pkgver=4.18.5
_srcname=linux-${pkgver%.*}
pkgrel=1
pkgdesc="snd-usb-audio kernel module modified for low latency"
@@ -9,25 +9,28 @@ arch=('any')
url="https://www.kernel.org/"
license=('GPL2')
depends=('dkms')
+install="${pkgname}.install"
source=(
"https://cdn.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.xz"
"https://cdn.kernel.org/pub/linux/kernel/v4.x/patch-${pkgver}.xz"
'dkms.conf'
- 'lowlatency.patch'
+ 'parameters.patch'
+ 'snd-usb-audio.conf'
)
validpgpkeys=(
'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
'647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
)
sha256sums=('19d8bcf49ef530cd4e364a45b4a22fa70714b70349c8100e7308488e26f1eaf1'
- 'cc22261cd9651dc2a05ad817a5b5fd3c63076ca86abfade7097915e7ba0b3bd6'
+ 'c88a4e56ab8a37e38c76dbb12be53a2a3379e920ce4b86003ccfff8a4a9d1f69'
'69f325c3af92c4098c9d118b2eab7de76eba691677864f714697bce5f47005e2'
- 'c2b7784899d184b142c5969c1be17cc949f11f4e59fbe5b1a8ffe062a1c4a88f')
+ '7c9b89931e4edc595dda38f8c6116dc45d10d191885c52aba3d9d8efdc26d261'
+ '346e8ae33ac878530f5a9538424f006f0f6017a5d26852cd917d209eb1ab3add')
prepare() {
cd "${_srcname}"
patch -Np1 -i ../patch-${pkgver}
- patch -Np1 -i ../lowlatency.patch
+ patch -Np1 -i ../parameters.patch
}
package() {
@@ -35,6 +38,7 @@ package() {
install -Dm644 ../dkms.conf "${pkgdir}/usr/src/${_basepkgname}-${pkgver}/dkms.conf"
sed -e "s/@PKGVER@/${pkgver}/" -i "${pkgdir}/usr/src/${_basepkgname}-${pkgver}/dkms.conf"
cp -a sound/usb/* "${pkgdir}/usr/src/${_basepkgname}-${pkgver}/"
+ install -Dm644 ../snd-usb-audio.conf "${pkgdir}/usr/lib/modprobe.d/snd-usb-audio.conf"
}
# vim:set ts=2 sw=2 et:
diff --git a/lowlatency.patch b/lowlatency.patch
deleted file mode 100644
index 9c3a7b603d5a..000000000000
--- a/lowlatency.patch
+++ /dev/null
@@ -1,17 +0,0 @@
---- a/sound/usb/card.h
-+++ b/sound/usb/card.h
-@@ -3,10 +3,10 @@
- #define __USBAUDIO_CARD_H
-
- #define MAX_NR_RATES 1024
--#define MAX_PACKS 6 /* per URB */
--#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */
--#define MAX_URBS 12
--#define SYNC_URBS 4 /* always four urbs for sync */
-+#define MAX_PACKS 1 /* per URB */
-+#define MAX_PACKS_HS MAX_PACKS /* in high speed mode */
-+#define MAX_URBS 2
-+#define SYNC_URBS MAX_URBS
- #define MAX_QUEUE 18 /* try not to exceed this queue length, in ms */
-
- struct audioformat {
diff --git a/parameters.patch b/parameters.patch
new file mode 100644
index 000000000000..e516e67cd0bc
--- /dev/null
+++ b/parameters.patch
@@ -0,0 +1,204 @@
+diff --git a/sound/usb/card.c b/sound/usb/card.c
+index a1ed798a1c6b..6d7f1a8a7fe1 100644
+--- a/sound/usb/card.c
++++ b/sound/usb/card.c
+@@ -81,6 +81,11 @@ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card *
+ /* Vendor/product IDs for this card */
+ static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
+ static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
++static int max_packs = 6; /* per URB */
++static int max_packs_hs = 6 * 8; /* in high speed mode */
++static int max_urbs = 12;
++static int sync_urbs = 4; /* always four urbs for sync */
++static int max_queue = 18; /* try not to exceed this queue length, in ms */
+ static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
+ static bool ignore_ctl_error;
+ static bool autoclock = true;
+@@ -98,6 +103,16 @@ module_param_array(vid, int, NULL, 0444);
+ MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device.");
+ module_param_array(pid, int, NULL, 0444);
+ MODULE_PARM_DESC(pid, "Product ID for the USB audio device.");
++module_param(max_packs, int, 0644);
++MODULE_PARM_DESC(max_packs, "Max. number of packets per URB in low speed mode");
++module_param(max_packs_hs, int, 0644);
++MODULE_PARM_DESC(max_packs_hs, "Max. number of packets per URB in high speed mode");
++module_param(max_urbs, int, 0644);
++MODULE_PARM_DESC(max_urbs, "Max. number of URBs");
++module_param(sync_urbs, int, 0644);
++MODULE_PARM_DESC(sync_urbs, "Number of URBs for sync");
++module_param(max_queue, int, 0644);
++MODULE_PARM_DESC(max_queue, "Try not to exceed this queue length, in ms");
+ module_param_array(device_setup, int, NULL, 0444);
+ MODULE_PARM_DESC(device_setup, "Specific device setup (if needed).");
+ module_param(ignore_ctl_error, bool, 0444);
+@@ -486,6 +501,16 @@ static int snd_usb_audio_create(struct usb_interface *intf,
+ chip->dev = dev;
+ chip->card = card;
+ chip->setup = device_setup[idx];
++ chip->max_packs = min(max(1, max_packs), MAX_PACKS_LIMIT);
++ dev_info(&dev->dev, "snd-usb-audio: max_packs: %d\n", chip->max_packs);
++ chip->max_packs_hs = min(max(1, max_packs_hs), MAX_PACKS_LIMIT);
++ dev_info(&dev->dev, "snd-usb-audio: max_packs_hs: %d\n", chip->max_packs_hs);
++ chip->max_urbs = min(max(1, max_urbs), MAX_URBS_LIMIT);
++ dev_info(&dev->dev, "snd-usb-audio: max_urbs: %d\n", chip->max_urbs);
++ chip->sync_urbs = min(max(1, sync_urbs), MAX_URBS_LIMIT);
++ dev_info(&dev->dev, "snd-usb-audio: sync_urbs: %d\n", chip->sync_urbs);
++ chip->max_queue = max(1, max_queue);
++ dev_info(&dev->dev, "snd-usb-audio: max_queue: %d\n", chip->max_queue);
+ chip->autoclock = autoclock;
+ atomic_set(&chip->active, 1); /* avoid autopm during probing */
+ atomic_set(&chip->usage_count, 0);
+diff --git a/sound/usb/card.h b/sound/usb/card.h
+index 9b41b7dda84f..40e106042bb9 100644
+--- a/sound/usb/card.h
++++ b/sound/usb/card.h
+@@ -3,11 +3,8 @@
+ #define __USBAUDIO_CARD_H
+
+ #define MAX_NR_RATES 1024
+-#define MAX_PACKS 6 /* per URB */
+-#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */
+-#define MAX_URBS 12
+-#define SYNC_URBS 4 /* always four urbs for sync */
+-#define MAX_QUEUE 18 /* try not to exceed this queue length, in ms */
++#define MAX_PACKS_LIMIT 64
++#define MAX_URBS_LIMIT 32
+
+ struct audioformat {
+ struct list_head list;
+@@ -45,7 +42,7 @@ struct snd_urb_ctx {
+ struct snd_usb_endpoint *ep;
+ int index; /* index for urb array */
+ int packets; /* number of packets per urb */
+- int packet_size[MAX_PACKS_HS]; /* size of packets for next submission */
++ int packet_size[MAX_PACKS_LIMIT]; /* size of packets for next submission */
+ struct list_head ready_list;
+ };
+
+@@ -66,12 +63,12 @@ struct snd_usb_endpoint {
+ struct snd_usb_endpoint *sync_master;
+ struct snd_usb_endpoint *sync_slave;
+
+- struct snd_urb_ctx urb[MAX_URBS];
++ struct snd_urb_ctx urb[MAX_URBS_LIMIT];
+
+ struct snd_usb_packet_info {
+- uint32_t packet_size[MAX_PACKS_HS];
++ uint32_t packet_size[MAX_PACKS_LIMIT];
+ int packets;
+- } next_packet[MAX_URBS];
++ } next_packet[MAX_URBS_LIMIT];
+ int next_packet_read_pos, next_packet_write_pos;
+ struct list_head ready_playback_urbs;
+
+diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
+index c90607ebe155..8980cc16284c 100644
+--- a/sound/usb/endpoint.c
++++ b/sound/usb/endpoint.c
+@@ -332,7 +332,7 @@ static void queue_pending_output_urbs(struct snd_usb_endpoint *ep)
+ if (ep->next_packet_read_pos != ep->next_packet_write_pos) {
+ packet = ep->next_packet + ep->next_packet_read_pos;
+ ep->next_packet_read_pos++;
+- ep->next_packet_read_pos %= MAX_URBS;
++ ep->next_packet_read_pos %= ep->chip->max_urbs;
+
+ /* take URB out of FIFO */
+ if (!list_empty(&ep->ready_playback_urbs))
+@@ -601,7 +601,7 @@ static void release_urbs(struct snd_usb_endpoint *ep, int force)
+ release_urb_ctx(&ep->urb[i]);
+
+ if (ep->syncbuf)
+- usb_free_coherent(ep->chip->dev, SYNC_URBS * 4,
++ usb_free_coherent(ep->chip->dev, ep->chip->sync_urbs * 4,
+ ep->syncbuf, ep->sync_dma);
+
+ ep->syncbuf = NULL;
+@@ -694,10 +694,10 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
+
+ if (snd_usb_get_speed(ep->chip->dev) != USB_SPEED_FULL) {
+ packs_per_ms = 8 >> ep->datainterval;
+- max_packs_per_urb = MAX_PACKS_HS;
++ max_packs_per_urb = ep->chip->max_packs_hs;
+ } else {
+ packs_per_ms = 1;
+- max_packs_per_urb = MAX_PACKS;
++ max_packs_per_urb = ep->chip->max_packs;
+ }
+ if (sync_ep && !snd_usb_endpoint_implicit_feedback_sink(ep))
+ max_packs_per_urb = min(max_packs_per_urb,
+@@ -733,13 +733,13 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
+ urb_packs = min(max_packs_per_urb, urb_packs);
+ while (urb_packs > 1 && urb_packs * maxsize >= period_bytes)
+ urb_packs >>= 1;
+- ep->nurbs = MAX_URBS;
++ ep->nurbs = ep->chip->max_urbs;
+
+ /*
+ * Playback endpoints without implicit sync are adjusted so that
+ * a period fits as evenly as possible in the smallest number of
+ * URBs. The total number of URBs is adjusted to the size of the
+- * ALSA buffer, subject to the MAX_URBS and MAX_QUEUE limits.
++ * ALSA buffer, subject to the max_urbs and max_queue limits.
+ */
+ } else {
+ /* determine how small a packet can be */
+@@ -764,8 +764,8 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
+ urbs_per_period);
+
+ /* try to use enough URBs to contain an entire ALSA buffer */
+- max_urbs = min((unsigned) MAX_URBS,
+- MAX_QUEUE * packs_per_ms / urb_packs);
++ max_urbs = min((unsigned int) ep->chip->max_urbs,
++ ep->chip->max_queue * packs_per_ms / urb_packs);
+ ep->nurbs = min(max_urbs, urbs_per_period * periods_per_buffer);
+ }
+
+@@ -810,12 +810,12 @@ static int sync_ep_set_params(struct snd_usb_endpoint *ep)
+ {
+ int i;
+
+- ep->syncbuf = usb_alloc_coherent(ep->chip->dev, SYNC_URBS * 4,
++ ep->syncbuf = usb_alloc_coherent(ep->chip->dev, ep->chip->sync_urbs * 4,
+ GFP_KERNEL, &ep->sync_dma);
+ if (!ep->syncbuf)
+ return -ENOMEM;
+
+- for (i = 0; i < SYNC_URBS; i++) {
++ for (i = 0; i < ep->chip->sync_urbs; i++) {
+ struct snd_urb_ctx *u = &ep->urb[i];
+ u->index = i;
+ u->ep = ep;
+@@ -834,7 +834,7 @@ static int sync_ep_set_params(struct snd_usb_endpoint *ep)
+ u->urb->complete = snd_complete_urb;
+ }
+
+- ep->nurbs = SYNC_URBS;
++ ep->nurbs = ep->chip->sync_urbs;
+
+ return 0;
+
+@@ -1146,7 +1146,7 @@ void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep,
+ }
+
+ ep->next_packet_write_pos++;
+- ep->next_packet_write_pos %= MAX_URBS;
++ ep->next_packet_write_pos %= ep->chip->max_urbs;
+ spin_unlock_irqrestore(&ep->lock, flags);
+ queue_pending_output_urbs(ep);
+
+diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
+index b9faeca645fd..f7a25935ca03 100644
+--- a/sound/usb/usbaudio.h
++++ b/sound/usb/usbaudio.h
+@@ -60,6 +60,11 @@ struct snd_usb_audio {
+ struct list_head mixer_list; /* list of mixer interfaces */
+
+ int setup; /* from the 'device_setup' module param */
++ int max_packs; /* from the 'max_packs' module param */
++ int max_packs_hs; /* from the 'max_packs_hs' module param */
++ int max_urbs; /* from the 'max_urbs' module param */
++ int sync_urbs; /* from the 'sync_urbs' module param */
++ int max_queue; /* from the 'max_queue' module param */
+ bool autoclock; /* from the 'autoclock' module param */
+ bool keep_iface; /* keep interface/altset after closing
+ * or parameter change
diff --git a/snd-usb-audio-lowlatency-dkms.install b/snd-usb-audio-lowlatency-dkms.install
new file mode 100644
index 000000000000..e780d49aac45
--- /dev/null
+++ b/snd-usb-audio-lowlatency-dkms.install
@@ -0,0 +1,14 @@
+post_install() {
+ cat << 'EOF'
+To tweak parameters:
+1. Copy /usr/lib/modprobe.d/snd-usb-audio.conf to /etc/modprobe.d/snd-usb-audio.conf
+2. Modify /etc/modprobe.d/snd-usb-audio.conf as needed
+3. modprobe -r snd-usb-audio
+ Note: You will need to stop all processes currently using USB audio before unloading the module.
+4. modprobe snd-usb-audio
+EOF
+}
+
+post_upgrade() {
+ post_install
+}
diff --git a/snd-usb-audio.conf b/snd-usb-audio.conf
new file mode 100644
index 000000000000..cbc8ca481912
--- /dev/null
+++ b/snd-usb-audio.conf
@@ -0,0 +1,21 @@
+# max_packs - Max. number of packets per URB in full speed mode (int)
+# Default: 6
+# Optimized: 1
+
+# max_packs_hs - Max. number of packets per URB in high speed mode (int)
+# Default: max_packs * 8 = 24
+# Optimized: 1
+
+# max_urbs - Max. number of URBs (int)
+# Default: 12
+# Optimized: 2 - 12
+
+# sync_urbs - Number of URBs for sync (int)
+# Default: 4
+# Optimized: 2 - 4
+
+# max_queue - Try not to exceed this queue length, in ms (int)
+# Default: 18
+# Optimized: 18
+
+options snd-usb-audio max_packs=1 max_packs_hs=1 max_urbs=12 sync_urbs=4 max_queue=18