All of lore.kernel.org
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH alsa-lib] ucm: Do not fail to parse configs on cards with an empty CardComponents lists
@ 2019-12-03 17:27 Hans de Goede
  2019-12-03 19:39 ` Jaroslav Kysela
  0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2019-12-03 17:27 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Takashi Iwai, Hans de Goede, alsa-devel, Pierre-Louis Bossart

Since the UCM profiles for all Bay- and Cherry-Trail SST cards have been
moved over to UCM2, parsing them fails with:

ALSA lib ucm_subs.c:220:(uc_mgr_get_substituted_value) variable '${CardComponents}' is not defined in this context!

This completely breaks audio support on all Bay- and Cherry-Trail devices.

This is caused by these non-SOF ASoC using cards having an empty
CardComponents list. Which in itself is fine, but is rejected by
the ucm_subs.c code. This commit changes the ucm_subs code to accept
an empty string as a valid value for CardComponents restoring audio
functionality on these boards.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 src/ucm/ucm_subs.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c
index 00afa9e3..90e395f0 100644
--- a/src/ucm/ucm_subs.c
+++ b/src/ucm/ucm_subs.c
@@ -25,6 +25,7 @@
  */
 
 #include "ucm_local.h"
+#include <stdbool.h>
 #include <sys/stat.h>
 #include <limits.h>
 
@@ -145,10 +146,11 @@ static char *rval_sysfs(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char
 	return strdup(path);
 }
 
-#define MATCH_VARIABLE(name, id, fcn)					\
+#define MATCH_VARIABLE(name, id, fcn, empty_ok)				\
 	if (strncmp((name), (id), sizeof(id) - 1) == 0) { 		\
 		rval = fcn(uc_mgr);					\
 		idsize = sizeof(id) - 1;				\
+		allow_empty = (empty_ok);				\
 		goto __rval;						\
 	}
 
@@ -189,12 +191,14 @@ int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr,
 
 	while (*value) {
 		if (*value == '$' && *(value+1) == '{') {
-			MATCH_VARIABLE(value, "${ConfName}", rval_conf_name);
-			MATCH_VARIABLE(value, "${CardId}", rval_card_id);
-			MATCH_VARIABLE(value, "${CardDriver}", rval_card_driver);
-			MATCH_VARIABLE(value, "${CardName}", rval_card_name);
-			MATCH_VARIABLE(value, "${CardLongName}", rval_card_longname);
-			MATCH_VARIABLE(value, "${CardComponents}", rval_card_components);
+			bool allow_empty = false;
+
+			MATCH_VARIABLE(value, "${ConfName}", rval_conf_name, false);
+			MATCH_VARIABLE(value, "${CardId}", rval_card_id, false);
+			MATCH_VARIABLE(value, "${CardDriver}", rval_card_driver, false);
+			MATCH_VARIABLE(value, "${CardName}", rval_card_name, false);
+			MATCH_VARIABLE(value, "${CardLongName}", rval_card_longname, false);
+			MATCH_VARIABLE(value, "${CardComponents}", rval_card_components, true);
 			MATCH_VARIABLE2(value, "${env:", rval_env);
 			MATCH_VARIABLE2(value, "${sys:", rval_sysfs);
 			err = -EINVAL;
@@ -208,7 +212,7 @@ int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr,
 			}
 			goto __error;
 __rval:
-			if (rval == NULL || rval[0] == '\0') {
+			if (rval == NULL || (!allow_empty && rval[0] == '\0')) {
 				free(rval);
 				strncpy(r, value, idsize);
 				r[idsize] = '\0';
-- 
2.23.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [alsa-devel] [PATCH alsa-lib] ucm: Do not fail to parse configs on cards with an empty CardComponents lists
  2019-12-03 17:27 [alsa-devel] [PATCH alsa-lib] ucm: Do not fail to parse configs on cards with an empty CardComponents lists Hans de Goede
@ 2019-12-03 19:39 ` Jaroslav Kysela
  0 siblings, 0 replies; 2+ messages in thread
From: Jaroslav Kysela @ 2019-12-03 19:39 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Takashi Iwai, alsa-devel, Pierre-Louis Bossart

Dne 03. 12. 19 v 18:27 Hans de Goede napsal(a):
> Since the UCM profiles for all Bay- and Cherry-Trail SST cards have been
> moved over to UCM2, parsing them fails with:
> 
> ALSA lib ucm_subs.c:220:(uc_mgr_get_substituted_value) variable '${CardComponents}' is not defined in this context!
> 
> This completely breaks audio support on all Bay- and Cherry-Trail devices.
> 
> This is caused by these non-SOF ASoC using cards having an empty
> CardComponents list. Which in itself is fine, but is rejected by
> the ucm_subs.c code. This commit changes the ucm_subs code to accept
> an empty string as a valid value for CardComponents restoring audio
> functionality on these boards.

I applied this patch to the alsa-lib repo. Thank you for this fix.

				Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-03 19:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03 17:27 [alsa-devel] [PATCH alsa-lib] ucm: Do not fail to parse configs on cards with an empty CardComponents lists Hans de Goede
2019-12-03 19:39 ` Jaroslav Kysela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.