diff -Nru alsa-utils-1.2.2/debian/changelog alsa-utils-1.2.2/debian/changelog --- alsa-utils-1.2.2/debian/changelog 2020-03-04 16:46:27.000000000 +0000 +++ alsa-utils-1.2.2/debian/changelog 2021-04-14 13:38:30.000000000 +0000 @@ -1,3 +1,27 @@ +alsa-utils (1.2.2-1ubuntu2.1) focal; urgency=medium + + * d/p/0013-aplay-try-to-use-16-bit-format-to-increase-capture-q.patch + - aplay: try to use 16-bit format to increase capture quality + (LP: #1923841) + + -- Kai-Heng Feng Wed, 14 Apr 2021 21:38:30 +0800 + +alsa-utils (1.2.2-1ubuntu2) focal; urgency=medium + + * d/p/0001-alsactl-init-iterate-through-all-cards-for-the-initi.patch + * d/p/0002-alsactl-add-initial-support-for-UCM-init.patch + * d/p/0003-alsactl-redirect-alsa-lib-errors.patch + * d/p/0004-alsactl-add-D-argument-to-execute-also-the-UCM-defau.patch + * d/p/0005-alsactl-use-the-right-priority-for-syslog-messages.patch + * d/p/0006-alsactl-allow-to-compile-alsactl-without-UCM-support.patch + * d/p/0007-alsactl-ucm-rename-_once-command-to-_boot-command.patch + * d/p/0008-alsaucm-remove-custom-rules-alsactl-is-UCM-aware-now.patch + Make alsactl support _boot section defined in the ucm, then the + mixer values defined in the _boot section for Dell soundwire audio + machines could be executed at the first booting. (LP: #1899745) + + -- Hui Wang Fri, 16 Oct 2020 17:50:30 +0200 + alsa-utils (1.2.2-1ubuntu1) focal; urgency=medium * Resynchronize on Debian diff -Nru alsa-utils-1.2.2/debian/patches/0001-alsactl-init-iterate-through-all-cards-for-the-initi.patch alsa-utils-1.2.2/debian/patches/0001-alsactl-init-iterate-through-all-cards-for-the-initi.patch --- alsa-utils-1.2.2/debian/patches/0001-alsactl-init-iterate-through-all-cards-for-the-initi.patch 1970-01-01 00:00:00.000000000 +0000 +++ alsa-utils-1.2.2/debian/patches/0001-alsactl-init-iterate-through-all-cards-for-the-initi.patch 2020-10-16 15:33:50.000000000 +0000 @@ -0,0 +1,50 @@ +From 0f8eb1677ff2975ac622db35c3667901d4f351fa Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Thu, 14 May 2020 18:14:31 +0200 +Subject: [PATCH 1/8] alsactl: init - iterate through all cards for the initial + settings + +The generic initialization code returns error code 99 (-99). Take +all those codes equal or above (bellow) this value as non-fatal. + +Signed-off-by: Jaroslav Kysela +(cherry picked from commit 598488c4af555c31c234ea2e88e52cb39a2c045a) +Signed-off-by: Hui Wang +--- + alsactl/init_parse.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/alsactl/init_parse.c b/alsactl/init_parse.c +index c048fd3..12bffa5 100644 +--- a/alsactl/init_parse.c ++++ b/alsactl/init_parse.c +@@ -1745,7 +1745,7 @@ static int parse(struct space *space, const char *filename) + int init(const char *filename, const char *cardname) + { + struct space *space; +- int err = 0, card, first; ++ int err = 0, lasterr = 0, card, first; + + sysfs_init(); + if (!cardname) { +@@ -1767,11 +1767,17 @@ int init(const char *filename, const char *cardname) + space->rootdir = new_root_dir(filename); + if (space->rootdir != NULL) + err = parse(space, filename); ++ if (err <= -99) { /* non-fatal errors */ ++ if (lasterr == 0) ++ lasterr = err; ++ err = 0; ++ } + free_space(space); + } + if (err < 0) + break; + } ++ err = lasterr; + } else { + card = snd_card_get_index(cardname); + if (card < 0) { +-- +2.25.1 + diff -Nru alsa-utils-1.2.2/debian/patches/0002-alsactl-add-initial-support-for-UCM-init.patch alsa-utils-1.2.2/debian/patches/0002-alsactl-add-initial-support-for-UCM-init.patch --- alsa-utils-1.2.2/debian/patches/0002-alsactl-add-initial-support-for-UCM-init.patch 1970-01-01 00:00:00.000000000 +0000 +++ alsa-utils-1.2.2/debian/patches/0002-alsactl-add-initial-support-for-UCM-init.patch 2020-10-16 15:33:50.000000000 +0000 @@ -0,0 +1,116 @@ +From 13ea068eb744f17288900fce180a9ccd4e910c6b Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Thu, 14 May 2020 17:12:08 +0200 +Subject: [PATCH 2/8] alsactl: add initial support for UCM init + +Signed-off-by: Jaroslav Kysela +(cherry picked from commit 4bea8fe3a73cd2df8dcad1c8a14c35bab7b21073) +Signed-off-by: Hui Wang +--- + alsactl/Makefile.am | 4 ++-- + alsactl/alsactl.h | 1 + + alsactl/init_parse.c | 6 ++++++ + alsactl/init_ucm.c | 40 ++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 49 insertions(+), 2 deletions(-) + create mode 100644 alsactl/init_ucm.c + +diff --git a/alsactl/Makefile.am b/alsactl/Makefile.am +index e9ab2eb..c1031ac 100644 +--- a/alsactl/Makefile.am ++++ b/alsactl/Makefile.am +@@ -9,8 +9,8 @@ EXTRA_DIST=alsactl.1 alsactl_init.xml + + AM_CFLAGS = -D_GNU_SOURCE + +-alsactl_SOURCES=alsactl.c state.c lock.c utils.c init_parse.c daemon.c \ +- monitor.c ++alsactl_SOURCES=alsactl.c state.c lock.c utils.c init_parse.c init_ucm.c \ ++ daemon.c monitor.c + + alsactl_CFLAGS=$(AM_CFLAGS) -D__USE_GNU \ + -DSYS_ASOUNDRC=\"$(ASOUND_STATE_DIR)/asound.state\" \ +diff --git a/alsactl/alsactl.h b/alsactl/alsactl.h +index 69b539c..6e96e78 100644 +--- a/alsactl/alsactl.h ++++ b/alsactl/alsactl.h +@@ -25,6 +25,7 @@ void dbg_(const char *fcn, long line, const char *fmt, ...); + #endif + + int init(const char *file, const char *cardname); ++int init_ucm(int cardno); + int state_lock(const char *file, int timeout); + int state_unlock(int fd, const char *file); + int save_state(const char *file, const char *cardname); +diff --git a/alsactl/init_parse.c b/alsactl/init_parse.c +index 12bffa5..f176a7a 100644 +--- a/alsactl/init_parse.c ++++ b/alsactl/init_parse.c +@@ -1762,6 +1762,9 @@ int init(const char *filename, const char *cardname) + break; + } + first = 0; ++ err = init_ucm(card); ++ if (err == 0) ++ continue; + err = init_space(&space, card); + if (err == 0) { + space->rootdir = new_root_dir(filename); +@@ -1784,6 +1787,9 @@ int init(const char *filename, const char *cardname) + error("Cannot find soundcard '%s'...", cardname); + goto error; + } ++ err = init_ucm(card); ++ if (err == 0) ++ return 0; + memset(&space, 0, sizeof(space)); + err = init_space(&space, card); + if (err == 0) { +diff --git a/alsactl/init_ucm.c b/alsactl/init_ucm.c +new file mode 100644 +index 0000000..833a1f9 +--- /dev/null ++++ b/alsactl/init_ucm.c +@@ -0,0 +1,40 @@ ++/* ++ * Advanced Linux Sound Architecture Control Program - UCM Initialization ++ * Copyright (c) by Jaroslav Kysela ++ * ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ * ++ */ ++ ++#include ++ ++/* ++ * Keep it as simple as possible. Execute commands from the SectionOnce only. ++ */ ++int init_ucm(int cardno) ++{ ++ snd_use_case_mgr_t *uc_mgr; ++ char id[32]; ++ int err; ++ ++ snprintf(id, sizeof(id), "hw:%d", cardno); ++ err = snd_use_case_mgr_open(&uc_mgr, id); ++ if (err < 0) ++ return err; ++ err = snd_use_case_set(uc_mgr, "_once", NULL); ++ snd_use_case_mgr_close(uc_mgr); ++ return err; ++} +-- +2.25.1 + diff -Nru alsa-utils-1.2.2/debian/patches/0003-alsactl-redirect-alsa-lib-errors.patch alsa-utils-1.2.2/debian/patches/0003-alsactl-redirect-alsa-lib-errors.patch --- alsa-utils-1.2.2/debian/patches/0003-alsactl-redirect-alsa-lib-errors.patch 1970-01-01 00:00:00.000000000 +0000 +++ alsa-utils-1.2.2/debian/patches/0003-alsactl-redirect-alsa-lib-errors.patch 2020-10-16 15:34:00.000000000 +0000 @@ -0,0 +1,63 @@ +From 8c733bfaadd1e04b97b836d7ea824080ba5269ad Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Thu, 14 May 2020 19:09:45 +0200 +Subject: [PATCH 3/8] alsactl: redirect alsa-lib errors + +Signed-off-by: Jaroslav Kysela +(cherry picked from commit 8fb4016a175f5e83c6ec363528c9ba6332a262ef) +Signed-off-by: Hui Wang +--- + alsactl/alsactl.c | 2 ++ + alsactl/alsactl.h | 1 + + alsactl/utils.c | 16 ++++++++++++++++ + 3 files changed, 19 insertions(+) + +Index: alsa-utils-1.2.2/alsactl/alsactl.c +=================================================================== +--- alsa-utils-1.2.2.orig/alsactl/alsactl.c ++++ alsa-utils-1.2.2/alsactl/alsactl.c +@@ -356,6 +356,8 @@ int main(int argc, char *argv[]) + syslog(LOG_INFO, "alsactl " SND_UTIL_VERSION_STR " daemon started"); + } + ++ snd_lib_error_set_handler(error_handler); ++ + if (!strcmp(cmd, "init")) { + res = init(initfile, cardname); + snd_config_update_free_global(); +Index: alsa-utils-1.2.2/alsactl/alsactl.h +=================================================================== +--- alsa-utils-1.2.2.orig/alsactl/alsactl.h ++++ alsa-utils-1.2.2/alsactl/alsactl.h +@@ -11,6 +11,7 @@ void info_(const char *fcn, long line, c + void error_(const char *fcn, long line, const char *fmt, ...); + void cerror_(const char *fcn, long line, int cond, const char *fmt, ...); + void dbg_(const char *fcn, long line, const char *fmt, ...); ++void error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...); + + #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) + #define info(...) do { info_(__func__, __LINE__, __VA_ARGS__); } while (0) +Index: alsa-utils-1.2.2/alsactl/utils.c +=================================================================== +--- alsa-utils-1.2.2.orig/alsactl/utils.c ++++ alsa-utils-1.2.2/alsactl/utils.c +@@ -177,3 +177,19 @@ void dbg_(const char *fcn, long line, co + } + va_end(ap); + } ++ ++void error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...) ++{ ++ char buf[2048]; ++ va_list arg; ++ ++ va_start(arg, fmt); ++ vsnprintf(buf, sizeof(buf), fmt, arg); ++ va_end(arg); ++ if (use_syslog) ++ syslog(LOG_ERR, "alsa-lib %s:%i:(%s) %s%s%s\n", file, line, function, ++ buf, err ? ": " : "", err ? snd_strerror(err) : ""); ++ else ++ fprintf(stderr, "alsa-lib %s:%i:(%s) %s%s%s\n", file, line, function, ++ buf, err ? ": " : "", err ? snd_strerror(err) : ""); ++} diff -Nru alsa-utils-1.2.2/debian/patches/0004-alsactl-add-D-argument-to-execute-also-the-UCM-defau.patch alsa-utils-1.2.2/debian/patches/0004-alsactl-add-D-argument-to-execute-also-the-UCM-defau.patch --- alsa-utils-1.2.2/debian/patches/0004-alsactl-add-D-argument-to-execute-also-the-UCM-defau.patch 1970-01-01 00:00:00.000000000 +0000 +++ alsa-utils-1.2.2/debian/patches/0004-alsactl-add-D-argument-to-execute-also-the-UCM-defau.patch 2020-10-16 15:34:03.000000000 +0000 @@ -0,0 +1,214 @@ +From 516cfb74741a188806b5531a870fea8f389a6b18 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Thu, 14 May 2020 19:34:18 +0200 +Subject: [PATCH 4/8] alsactl: add -D argument to execute also the UCM defaults + section + +Signed-off-by: Jaroslav Kysela +(cherry picked from commit b68e854d287e93602c3511fa501c2a4824d3b865) +Signed-off-by: Hui Wang +--- + alsactl/alsactl.1 | 5 +++++ + alsactl/alsactl.c | 9 +++++++-- + alsactl/alsactl.h | 10 ++++++---- + alsactl/init_parse.c | 6 +++--- + alsactl/init_ucm.c | 12 +++++++++++- + alsactl/state.c | 10 +++++----- + 6 files changed, 37 insertions(+), 15 deletions(-) + +Index: alsa-utils-1.2.2/alsactl/alsactl.1 +=================================================================== +--- alsa-utils-1.2.2.orig/alsactl/alsactl.1 ++++ alsa-utils-1.2.2/alsactl/alsactl.1 +@@ -142,6 +142,11 @@ Set the process priority (see 'man nice' + \fI\-c, \-\-sched-idle\fP + Set the process scheduling policy to idle (SCHED_IDLE). + ++.TP ++\fI\-D, \-\-ucm-defaults\fP ++Execute also the 'defaults' section from the UCM configuration. The standard ++behaviour is to execute only 'once' section. ++ + .SH FILES + \fI/var/lib/alsa/asound.state\fP (or whatever file you specify with the + \fB\-f\fP flag) is used to store current settings for your +Index: alsa-utils-1.2.2/alsactl/alsactl.c +=================================================================== +--- alsa-utils-1.2.2.orig/alsactl/alsactl.c ++++ alsa-utils-1.2.2/alsactl/alsactl.c +@@ -96,6 +96,7 @@ static struct arg args[] = { + { 's', "syslog", "use syslog for messages" }, + { INTARG | 'n', "nice", "set the process priority (see 'man nice')" }, + { 'c', "sched-idle", "set the process scheduling policy to idle (SCHED_IDLE)" }, ++{ 'D', "ucm-defaults", "execute also the UCM 'defaults' section" }, + { HEADER, NULL, "Available commands:" }, + { CARDCMD, "store", "save current driver setup for one or each soundcards" }, + { EMPCMD, NULL, " to configuration file" }, +@@ -193,6 +194,7 @@ int main(int argc, char *argv[]) + int daemoncmd = 0; + int use_nice = NO_NICE; + int sched_idle = 0; ++ int initflags = 0; + struct arg *a; + struct option *o; + int i, j, k, res; +@@ -265,6 +267,9 @@ int main(int argc, char *argv[]) + case 'I': + init_fallback = 0; + break; ++ case 'D': ++ initflags |= FLAG_UCM_DEFAULTS; ++ break; + case 'r': + statefile = optarg; + break; +@@ -359,7 +364,7 @@ int main(int argc, char *argv[]) + snd_lib_error_set_handler(error_handler); + + if (!strcmp(cmd, "init")) { +- res = init(initfile, cardname); ++ res = init(initfile, initflags, cardname); + snd_config_update_free_global(); + } else if (!strcmp(cmd, "store")) { + res = save_state(cfgfile, cardname); +@@ -368,7 +373,7 @@ int main(int argc, char *argv[]) + !strcmp(cmd, "nrestore")) { + if (removestate) + remove(statefile); +- res = load_state(cfgfile, initfile, cardname, init_fallback); ++ res = load_state(cfgfile, initfile, initflags, cardname, init_fallback); + if (!strcmp(cmd, "rdaemon")) { + do_nice(use_nice, sched_idle); + res = state_daemon(cfgfile, cardname, period, pidfile); +Index: alsa-utils-1.2.2/alsactl/alsactl.h +=================================================================== +--- alsa-utils-1.2.2.orig/alsactl/alsactl.h ++++ alsa-utils-1.2.2/alsactl/alsactl.h +@@ -25,13 +25,15 @@ void error_handler(const char *file, int + #define dbg(args...) do { dbg_(__func__, __LINE__, ##args); } while (0) + #endif + +-int init(const char *file, const char *cardname); +-int init_ucm(int cardno); ++#define FLAG_UCM_DEFAULTS (1<<0) ++ ++int init(const char *file, int flags, const char *cardname); ++int init_ucm(int flags, int cardno); + int state_lock(const char *file, int timeout); + int state_unlock(int fd, const char *file); + int save_state(const char *file, const char *cardname); +-int load_state(const char *file, const char *initfile, const char *cardname, +- int do_init); ++int load_state(const char *file, const char *initfile, int initflags, ++ const char *cardname, int do_init); + int power(const char *argv[], int argc); + int monitor(const char *name); + int state_daemon(const char *file, const char *cardname, int period, +Index: alsa-utils-1.2.2/alsactl/init_parse.c +=================================================================== +--- alsa-utils-1.2.2.orig/alsactl/init_parse.c ++++ alsa-utils-1.2.2/alsactl/init_parse.c +@@ -1742,7 +1742,7 @@ static int parse(struct space *space, co + return err ? err : -abs(space->exit_code); + } + +-int init(const char *filename, const char *cardname) ++int init(const char *filename, int flags, const char *cardname) + { + struct space *space; + int err = 0, lasterr = 0, card, first; +@@ -1762,7 +1762,7 @@ int init(const char *filename, const cha + break; + } + first = 0; +- err = init_ucm(card); ++ err = init_ucm(flags, card); + if (err == 0) + continue; + err = init_space(&space, card); +@@ -1787,7 +1787,7 @@ int init(const char *filename, const cha + error("Cannot find soundcard '%s'...", cardname); + goto error; + } +- err = init_ucm(card); ++ err = init_ucm(flags, card); + if (err == 0) + return 0; + memset(&space, 0, sizeof(space)); +Index: alsa-utils-1.2.2/alsactl/init_ucm.c +=================================================================== +--- alsa-utils-1.2.2.orig/alsactl/init_ucm.c ++++ alsa-utils-1.2.2/alsactl/init_ucm.c +@@ -19,12 +19,14 @@ + * + */ + ++#include ++#include "alsactl.h" + #include + + /* + * Keep it as simple as possible. Execute commands from the SectionOnce only. + */ +-int init_ucm(int cardno) ++int init_ucm(int flags, int cardno) + { + snd_use_case_mgr_t *uc_mgr; + char id[32]; +@@ -35,6 +37,14 @@ int init_ucm(int cardno) + if (err < 0) + return err; + err = snd_use_case_set(uc_mgr, "_once", NULL); ++ if (err < 0) ++ goto _error; ++ if ((flags & FLAG_UCM_DEFAULTS) != 0) { ++ err = snd_use_case_set(uc_mgr, "_defaults", NULL); ++ if (err < 0) ++ goto _error; ++ } ++_error: + snd_use_case_mgr_close(uc_mgr); + return err; + } +Index: alsa-utils-1.2.2/alsactl/state.c +=================================================================== +--- alsa-utils-1.2.2.orig/alsactl/state.c ++++ alsa-utils-1.2.2/alsactl/state.c +@@ -1645,8 +1645,8 @@ out: + return err; + } + +-int load_state(const char *file, const char *initfile, const char *cardname, +- int do_init) ++int load_state(const char *file, const char *initfile, int initflags, ++ const char *cardname, int do_init) + { + int err, finalerr = 0; + snd_config_t *config; +@@ -1704,7 +1704,7 @@ single: + if (!do_init) + break; + sprintf(cardname1, "%i", card); +- err = init(initfile, cardname1); ++ err = init(initfile, initflags, cardname1); + if (err < 0) { + finalerr = err; + initfailed(card, "init", err); +@@ -1743,7 +1743,7 @@ single: + /* do a check if controls matches state file */ + if (do_init && set_controls(card, config, 0)) { + sprintf(cardname1, "%i", card); +- err = init(initfile, cardname1); ++ err = init(initfile, initflags, cardname1); + if (err < 0) { + initfailed(card, "init", err); + finalerr = err; +@@ -1766,7 +1766,7 @@ single: + } + /* do a check if controls matches state file */ + if (do_init && set_controls(cardno, config, 0)) { +- err = init(initfile, cardname); ++ err = init(initfile, initflags, cardname); + if (err < 0) { + initfailed(cardno, "init", err); + finalerr = err; diff -Nru alsa-utils-1.2.2/debian/patches/0005-alsactl-use-the-right-priority-for-syslog-messages.patch alsa-utils-1.2.2/debian/patches/0005-alsactl-use-the-right-priority-for-syslog-messages.patch --- alsa-utils-1.2.2/debian/patches/0005-alsactl-use-the-right-priority-for-syslog-messages.patch 1970-01-01 00:00:00.000000000 +0000 +++ alsa-utils-1.2.2/debian/patches/0005-alsactl-use-the-right-priority-for-syslog-messages.patch 2020-10-16 15:33:50.000000000 +0000 @@ -0,0 +1,28 @@ +From 2b8bd3315237d4c63c983d02124bbe191a7ab92f Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Thu, 14 May 2020 19:41:40 +0200 +Subject: [PATCH 5/8] alsactl: use the right priority for syslog messages + +Signed-off-by: Jaroslav Kysela +(cherry picked from commit 0adca4cac7f02ec07cf7b2042110125eb1052b60) +Signed-off-by: Hui Wang +--- + alsactl/utils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/alsactl/utils.c b/alsactl/utils.c +index fb59e0e..9d4166f 100644 +--- a/alsactl/utils.c ++++ b/alsactl/utils.c +@@ -111,7 +111,7 @@ static void syslog_(int prio, const char *fcn, long line, + buf[sizeof(buf)-1] = '\0'; + vsnprintf(buf + strlen(buf), sizeof(buf)-strlen(buf), fmt, ap); + buf[sizeof(buf)-1] = '\0'; +- syslog(LOG_INFO, "%s", buf); ++ syslog(prio, "%s", buf); + } + + void info_(const char *fcn, long line, const char *fmt, ...) +-- +2.25.1 + diff -Nru alsa-utils-1.2.2/debian/patches/0006-alsactl-allow-to-compile-alsactl-without-UCM-support.patch alsa-utils-1.2.2/debian/patches/0006-alsactl-allow-to-compile-alsactl-without-UCM-support.patch --- alsa-utils-1.2.2/debian/patches/0006-alsactl-allow-to-compile-alsactl-without-UCM-support.patch 1970-01-01 00:00:00.000000000 +0000 +++ alsa-utils-1.2.2/debian/patches/0006-alsactl-allow-to-compile-alsactl-without-UCM-support.patch 2020-10-16 15:33:50.000000000 +0000 @@ -0,0 +1,60 @@ +From dfbe27348f7d7a02deea8a209670e0fc64cf2b60 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Thu, 14 May 2020 19:54:04 +0200 +Subject: [PATCH 6/8] alsactl: allow to compile alsactl without UCM support + +Signed-off-by: Jaroslav Kysela +(cherry picked from commit 570ea6c455d1fe82c597e4ef9d5edbf07d6723dd) +Signed-off-by: Hui Wang +--- + alsactl/alsactl.c | 2 ++ + alsactl/init_ucm.c | 13 +++++++++++++ + 2 files changed, 15 insertions(+) + +diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c +index 5d7b450..e66e7d3 100644 +--- a/alsactl/alsactl.c ++++ b/alsactl/alsactl.c +@@ -96,7 +96,9 @@ static struct arg args[] = { + { 's', "syslog", "use syslog for messages" }, + { INTARG | 'n', "nice", "set the process priority (see 'man nice')" }, + { 'c', "sched-idle", "set the process scheduling policy to idle (SCHED_IDLE)" }, ++#ifdef HAVE_ALSA_USE_CASE_H + { 'D', "ucm-defaults", "execute also the UCM 'defaults' section" }, ++#endif + { HEADER, NULL, "Available commands:" }, + { CARDCMD, "store", "save current driver setup for one or each soundcards" }, + { EMPCMD, NULL, " to configuration file" }, +diff --git a/alsactl/init_ucm.c b/alsactl/init_ucm.c +index 9c05300..f6a43c5 100644 +--- a/alsactl/init_ucm.c ++++ b/alsactl/init_ucm.c +@@ -19,8 +19,12 @@ + * + */ + ++#include "aconfig.h" + #include + #include "alsactl.h" ++ ++#ifdef HAVE_ALSA_USE_CASE_H ++ + #include + + /* +@@ -48,3 +52,12 @@ _error: + snd_use_case_mgr_close(uc_mgr); + return err; + } ++ ++#else ++ ++int init_ucm(int flags, int cardno) ++{ ++ return 0; ++} ++ ++#endif +-- +2.25.1 + diff -Nru alsa-utils-1.2.2/debian/patches/0007-alsactl-ucm-rename-_once-command-to-_boot-command.patch alsa-utils-1.2.2/debian/patches/0007-alsactl-ucm-rename-_once-command-to-_boot-command.patch --- alsa-utils-1.2.2/debian/patches/0007-alsactl-ucm-rename-_once-command-to-_boot-command.patch 1970-01-01 00:00:00.000000000 +0000 +++ alsa-utils-1.2.2/debian/patches/0007-alsactl-ucm-rename-_once-command-to-_boot-command.patch 2020-10-16 15:33:50.000000000 +0000 @@ -0,0 +1,28 @@ +From 6a7cd0213093d4ee8cd601e9a6d0d782dbdd96ee Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Mon, 25 May 2020 19:21:25 +0200 +Subject: [PATCH 7/8] alsactl: ucm - rename _once command to _boot command + +Signed-off-by: Jaroslav Kysela +(backported from commit f8a2aad5bbdb0430c0b9cd1d4d8a3b81fa5e1df1) +Signed-off-by: Hui Wang +--- + alsactl/init_ucm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/alsactl/init_ucm.c b/alsactl/init_ucm.c +index f6a43c5..6468c9d 100644 +--- a/alsactl/init_ucm.c ++++ b/alsactl/init_ucm.c +@@ -40,7 +40,7 @@ int init_ucm(int flags, int cardno) + err = snd_use_case_mgr_open(&uc_mgr, id); + if (err < 0) + return err; +- err = snd_use_case_set(uc_mgr, "_once", NULL); ++ err = snd_use_case_set(uc_mgr, "_boot", NULL); + if (err < 0) + goto _error; + if ((flags & FLAG_UCM_DEFAULTS) != 0) { +-- +2.25.1 + diff -Nru alsa-utils-1.2.2/debian/patches/0008-alsaucm-remove-custom-rules-alsactl-is-UCM-aware-now.patch alsa-utils-1.2.2/debian/patches/0008-alsaucm-remove-custom-rules-alsactl-is-UCM-aware-now.patch --- alsa-utils-1.2.2/debian/patches/0008-alsaucm-remove-custom-rules-alsactl-is-UCM-aware-now.patch 1970-01-01 00:00:00.000000000 +0000 +++ alsa-utils-1.2.2/debian/patches/0008-alsaucm-remove-custom-rules-alsactl-is-UCM-aware-now.patch 2020-10-16 15:33:50.000000000 +0000 @@ -0,0 +1,55 @@ +From 7f2d0437362b7dcfc918e89172f2ac02d3a9f8cc Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Thu, 28 May 2020 21:00:18 +0200 +Subject: [PATCH 8/8] alsaucm: remove custom rules, alsactl is UCM aware now + +Signed-off-by: Jaroslav Kysela +(cherry picked from commit d3d01ee7cf0de4a07e893f34ca49b5281f593530) +Signed-off-by: Hui Wang +--- + alsaucm/89-alsa-ucm.rules.in | 8 -------- + alsaucm/Makefile.am | 15 ++------------- + 2 files changed, 2 insertions(+), 21 deletions(-) + delete mode 100644 alsaucm/89-alsa-ucm.rules.in + +diff --git a/alsaucm/89-alsa-ucm.rules.in b/alsaucm/89-alsa-ucm.rules.in +deleted file mode 100644 +index 52a7616..0000000 +--- a/alsaucm/89-alsa-ucm.rules.in ++++ /dev/null +@@ -1,8 +0,0 @@ +-SUBSYSTEM!="sound", GOTO="ucm_end" +-ACTION!="change", GOTO="ucm_end" +-KERNEL!="card*", GOTO="ucm_end" +- +-ATTRS{id}=="PAZ00", RUN+="@bindir@/alsaucm -c PAZ00 set _verb HiFi" +-ATTRS{id}=="PAZ00", RUN+="@bindir@/alsaucm -c PAZ00 set _verb Record" +- +-LABEL="ucm_end" +diff --git a/alsaucm/Makefile.am b/alsaucm/Makefile.am +index ae02fc3..2010fc0 100644 +--- a/alsaucm/Makefile.am ++++ b/alsaucm/Makefile.am +@@ -15,17 +15,6 @@ AM_CPPFLAGS = \ + %.1: %.rst + rst2man $< > $@ + +-udevrules_DATA = \ +- 89-alsa-ucm.rules ++EXTRA_DIST = alsaucm.rst + +-edit = \ +- $(SED) -r -e 's,@bindir\@,$(bindir),g' \ +- -e 's,@mydatadir\@,$(mydatadir),g' \ +- < $< > $@ || rm $@ +- +-89-alsa-ucm.rules: 89-alsa-ucm.rules.in +- $(edit) +- +-EXTRA_DIST = alsaucm.rst 89-alsa-ucm.rules.in +- +-CLEANFILES = alsaucm.1 89-alsa-ucm.rules ++CLEANFILES = alsaucm.1 +-- +2.25.1 + diff -Nru alsa-utils-1.2.2/debian/patches/0020-aplay-try-to-use-16-bit-format-to-increase-capture-q.patch alsa-utils-1.2.2/debian/patches/0020-aplay-try-to-use-16-bit-format-to-increase-capture-q.patch --- alsa-utils-1.2.2/debian/patches/0020-aplay-try-to-use-16-bit-format-to-increase-capture-q.patch 1970-01-01 00:00:00.000000000 +0000 +++ alsa-utils-1.2.2/debian/patches/0020-aplay-try-to-use-16-bit-format-to-increase-capture-q.patch 2021-04-14 13:38:30.000000000 +0000 @@ -0,0 +1,183 @@ +From: Hui Wang +Date: Fri, 23 Oct 2020 16:47:10 +0800 +Subject: aplay: try to use 16-bit format to increase capture quality + +Recently users reported a bug, I tested it and found it is a common +issue on Laptop or Desktop machines. + +The issue is users plug a headset and use "arecord test.wav" to +record a sound with default input volume, the recorded sound has +poor quality and nearly can't distinguish it is the sound we want +to record. + +This is because the input volume is low and the default format is U8. +The driver records sound with 16bit, because the input volume is low, +most of samples are within (-256,+256), when converting 16bit to U8, +those samples will be 0x7f. This is called quantization noise and we +could only workaround it by increase the input volume or adding -f to +arecord. + +But users want to record a better quality sound with default input +volume (after installing a new OS, the volume is the default volume), +and they don't want to add parameters to the arecord because most of +new linux users just use "arecord test.wav". + +So this patch tries to change the default format from U8 to S16_LE/BE. +If the machine doesn't support S16_LE/BE, it still uses U8 as default +format. + +Signed-off-by: Hui Wang +Signed-off-by: Jaroslav Kysela +Signed-off-by: Kai-Heng Feng +--- + aplay/aplay.c | 43 ++++++++++++++++++++++++++++++++++--------- + 1 file changed, 34 insertions(+), 9 deletions(-) + +diff --git a/aplay/aplay.c b/aplay/aplay.c +index 08395f6..680663a 100644 +--- a/aplay/aplay.c ++++ b/aplay/aplay.c +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -94,6 +95,7 @@ enum { + VUMETER_STEREO + }; + ++static snd_pcm_format_t default_format = DEFAULT_FORMAT; + static char *command; + static snd_pcm_t *handle; + static struct { +@@ -468,6 +470,24 @@ static long parse_long(const char *str, int *err) + return val; + } + ++static void try_to_adjust_default_format_16bit(void) ++{ ++ snd_pcm_hw_params_t *params; ++ int err; ++ ++ snd_pcm_hw_params_alloca(¶ms); ++ err = snd_pcm_hw_params_any(handle, params); ++ if (err < 0) { ++ error(_("Broken configuration for this PCM: no configurations available")); ++ prg_exit(EXIT_FAILURE); ++ } ++ ++ if (file_type != FORMAT_AU && snd_pcm_hw_params_test_format(handle, params, SND_PCM_FORMAT_S16_LE) == 0) ++ rhwparams.format = default_format = SND_PCM_FORMAT_S16_LE; ++ else if (file_type == FORMAT_AU && snd_pcm_hw_params_test_format(handle, params, SND_PCM_FORMAT_S16_BE) == 0) ++ rhwparams.format = default_format = SND_PCM_FORMAT_S16_BE; ++} ++ + int main(int argc, char *argv[]) + { + int duration_or_sample = 0; +@@ -528,6 +548,7 @@ int main(int argc, char *argv[]) + int do_device_list = 0, do_pcm_list = 0; + snd_pcm_info_t *info; + FILE *direction; ++ bool user_set_fmt = false; + + #ifdef ENABLE_NLS + setlocale(LC_ALL, ""); +@@ -562,7 +583,7 @@ int main(int argc, char *argv[]) + } + + chunk_size = -1; +- rhwparams.format = DEFAULT_FORMAT; ++ rhwparams.format = default_format; + rhwparams.rate = DEFAULT_SPEED; + rhwparams.channels = 1; + +@@ -612,6 +633,7 @@ int main(int argc, char *argv[]) + } + break; + case 'f': ++ user_set_fmt = true; + if (strcasecmp(optarg, "cd") == 0 || strcasecmp(optarg, "cdr") == 0) { + if (strcasecmp(optarg, "cdr") == 0) + rhwparams.format = SND_PCM_FORMAT_S16_BE; +@@ -844,6 +866,9 @@ int main(int argc, char *argv[]) + } + } + ++ if (!user_set_fmt) ++ try_to_adjust_default_format_16bit(); ++ + chunk_size = 1024; + hwparams = rhwparams; + +@@ -1064,7 +1089,7 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size) + hwparams.channels = channels; + switch (TO_CPU_SHORT(f->bit_p_spl, big_endian)) { + case 8: +- if (hwparams.format != DEFAULT_FORMAT && ++ if (hwparams.format != default_format && + hwparams.format != SND_PCM_FORMAT_U8) + fprintf(stderr, _("Warning: format is changed to U8\n")); + hwparams.format = SND_PCM_FORMAT_U8; +@@ -1074,7 +1099,7 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size) + native_format = SND_PCM_FORMAT_S16_BE; + else + native_format = SND_PCM_FORMAT_S16_LE; +- if (hwparams.format != DEFAULT_FORMAT && ++ if (hwparams.format != default_format && + hwparams.format != native_format) + fprintf(stderr, _("Warning: format is changed to %s\n"), + snd_pcm_format_name(native_format)); +@@ -1087,7 +1112,7 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size) + native_format = SND_PCM_FORMAT_S24_3BE; + else + native_format = SND_PCM_FORMAT_S24_3LE; +- if (hwparams.format != DEFAULT_FORMAT && ++ if (hwparams.format != default_format && + hwparams.format != native_format) + fprintf(stderr, _("Warning: format is changed to %s\n"), + snd_pcm_format_name(native_format)); +@@ -1098,7 +1123,7 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size) + native_format = SND_PCM_FORMAT_S24_BE; + else + native_format = SND_PCM_FORMAT_S24_LE; +- if (hwparams.format != DEFAULT_FORMAT && ++ if (hwparams.format != default_format && + hwparams.format != native_format) + fprintf(stderr, _("Warning: format is changed to %s\n"), + snd_pcm_format_name(native_format)); +@@ -1184,19 +1209,19 @@ static int test_au(int fd, void *buffer) + pbrec_count = BE_INT(ap->data_size); + switch (BE_INT(ap->encoding)) { + case AU_FMT_ULAW: +- if (hwparams.format != DEFAULT_FORMAT && ++ if (hwparams.format != default_format && + hwparams.format != SND_PCM_FORMAT_MU_LAW) + fprintf(stderr, _("Warning: format is changed to MU_LAW\n")); + hwparams.format = SND_PCM_FORMAT_MU_LAW; + break; + case AU_FMT_LIN8: +- if (hwparams.format != DEFAULT_FORMAT && ++ if (hwparams.format != default_format && + hwparams.format != SND_PCM_FORMAT_U8) + fprintf(stderr, _("Warning: format is changed to U8\n")); + hwparams.format = SND_PCM_FORMAT_U8; + break; + case AU_FMT_LIN16: +- if (hwparams.format != DEFAULT_FORMAT && ++ if (hwparams.format != default_format && + hwparams.format != SND_PCM_FORMAT_S16_BE) + fprintf(stderr, _("Warning: format is changed to S16_BE\n")); + hwparams.format = SND_PCM_FORMAT_S16_BE; +@@ -2312,7 +2337,7 @@ static void voc_play(int fd, int ofs, char *name) + prg_exit(EXIT_FAILURE); + } + } +- hwparams.format = DEFAULT_FORMAT; ++ hwparams.format = default_format; + hwparams.channels = 1; + hwparams.rate = DEFAULT_SPEED; + set_params(); diff -Nru alsa-utils-1.2.2/debian/patches/series alsa-utils-1.2.2/debian/patches/series --- alsa-utils-1.2.2/debian/patches/series 2020-03-04 16:44:43.000000000 +0000 +++ alsa-utils-1.2.2/debian/patches/series 2021-04-14 13:38:30.000000000 +0000 @@ -9,3 +9,12 @@ add_extra_volume_defaults.patch vmware_audio_volume.patch create_run_alsa.patch +0001-alsactl-init-iterate-through-all-cards-for-the-initi.patch +0002-alsactl-add-initial-support-for-UCM-init.patch +0003-alsactl-redirect-alsa-lib-errors.patch +0004-alsactl-add-D-argument-to-execute-also-the-UCM-defau.patch +0005-alsactl-use-the-right-priority-for-syslog-messages.patch +0006-alsactl-allow-to-compile-alsactl-without-UCM-support.patch +0007-alsactl-ucm-rename-_once-command-to-_boot-command.patch +0008-alsaucm-remove-custom-rules-alsactl-is-UCM-aware-now.patch +0020-aplay-try-to-use-16-bit-format-to-increase-capture-q.patch