1 From 976f8f62238f0d837584adc7c31035bdb29b6d6f Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Tue, 3 Dec 2019 18:27:39 +0100
4 Subject: [PATCH 5/5] ucm: Do not fail to parse configs on cards with an empty
7 Since the UCM profiles for all Bay- and Cherry-Trail SST cards have been
8 moved over to UCM2, parsing them fails with:
10 ALSA lib ucm_subs.c:220:(uc_mgr_get_substituted_value) variable '${CardComponents}' is not defined in this context!
12 This completely breaks audio support on all Bay- and Cherry-Trail devices.
14 This is caused by these non-SOF ASoC using cards having an empty
15 CardComponents list. Which in itself is fine, but is rejected by
16 the ucm_subs.c code. This commit changes the ucm_subs code to accept
17 an empty string as a valid value for CardComponents restoring audio
18 functionality on these boards.
20 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
21 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
23 Upstream-Status: Backport
24 Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
26 src/ucm/ucm_subs.c | 20 ++++++++++++--------
27 1 file changed, 12 insertions(+), 8 deletions(-)
29 diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c
30 index 00afa9e3..90e395f0 100644
31 --- a/src/ucm/ucm_subs.c
32 +++ b/src/ucm/ucm_subs.c
36 #include "ucm_local.h"
41 @@ -145,10 +146,11 @@ static char *rval_sysfs(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char
45 -#define MATCH_VARIABLE(name, id, fcn) \
46 +#define MATCH_VARIABLE(name, id, fcn, empty_ok) \
47 if (strncmp((name), (id), sizeof(id) - 1) == 0) { \
49 idsize = sizeof(id) - 1; \
50 + allow_empty = (empty_ok); \
54 @@ -189,12 +191,14 @@ int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr,
57 if (*value == '$' && *(value+1) == '{') {
58 - MATCH_VARIABLE(value, "${ConfName}", rval_conf_name);
59 - MATCH_VARIABLE(value, "${CardId}", rval_card_id);
60 - MATCH_VARIABLE(value, "${CardDriver}", rval_card_driver);
61 - MATCH_VARIABLE(value, "${CardName}", rval_card_name);
62 - MATCH_VARIABLE(value, "${CardLongName}", rval_card_longname);
63 - MATCH_VARIABLE(value, "${CardComponents}", rval_card_components);
64 + bool allow_empty = false;
66 + MATCH_VARIABLE(value, "${ConfName}", rval_conf_name, false);
67 + MATCH_VARIABLE(value, "${CardId}", rval_card_id, false);
68 + MATCH_VARIABLE(value, "${CardDriver}", rval_card_driver, false);
69 + MATCH_VARIABLE(value, "${CardName}", rval_card_name, false);
70 + MATCH_VARIABLE(value, "${CardLongName}", rval_card_longname, false);
71 + MATCH_VARIABLE(value, "${CardComponents}", rval_card_components, true);
72 MATCH_VARIABLE2(value, "${env:", rval_env);
73 MATCH_VARIABLE2(value, "${sys:", rval_sysfs);
75 @@ -208,7 +212,7 @@ int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr,
79 - if (rval == NULL || rval[0] == '\0') {
80 + if (rval == NULL || (!allow_empty && rval[0] == '\0')) {
82 strncpy(r, value, idsize);