Skip to contentSkip to conversation

conf: Remove dmix.direct_memory_access setup

PATCH New Takashi Iwai 1 participant 2 messages May 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 conf: Remove dmix.direct_memory_access setup

The commit [22eca6468b4a: pcm: dmix: Allow disabling x86 optimizations] introduced the new flag for dmix & co, direct_memory_access. However, it turned out that such an addition of the new flag in the default pcm definition causes an error when it's used with old alsa-lib codes. Although the code added here is correct, per se, and it works as expected, it's not wise to break the configuration with old stuff -- even if the usage is somehow incorrect and should be avoided.

Since the usage of the new flag is only for HDMI LPE audio, and the usage of dmix itself should be limited with that hardware, this patch removes the setup so that it works with the old alsa-lib again. We may introduce the dmix behavior change in a smarter way, e.g. passing some flag from the hardware driver so that it works more generically without the manual fiddling of config files.

Bugzilla: http://bugzilla.opensuse.org/show_bug.cgi?id=1037021

---
 src/conf/cards/HdmiLpeAudio.conf | 23 -----------------------
 src/conf/pcm/dmix.conf           | 15 ---------------
 2 files changed, 38 deletions(-)
src/conf/cards/HdmiLpeAudio.conf +0 -23
index 61bdfeae2917..dae71facac6d 100644
@@ -20,29 +20,6 @@ HdmiLpeAudio.pcm.front.0 {
 	}
 }
 
-# uncached memory reads have a high penalty
-HdmiLpeAudio.dmix.direct_memory_access false
-
-# default with dmix+softvol
-HdmiLpeAudio.pcm.default {
-	@args [ CARD ]
-	@args.CARD {
-		type string
-	}
-	type plug
-	slave.pcm {
-		type softvol
-		slave.pcm {
-			@func concat
-			strings [ "dmix:" $CARD ]
-		}
-		control {
-			name "PCM Playback Volume"
-			card $CARD
-		}
-	}
-}
-
 <confdir:pcm/surround40.conf>
 <confdir:pcm/surround21.conf>
 <confdir:pcm/surround41.conf>
src/conf/pcm/dmix.conf +0 -15
index 2d3b329e533a..7d0aa0158c42 100644
@@ -49,21 +49,6 @@ pcm.!dmix {
 		@func refer
 		name defaults.pcm.ipc_perm
 	}
-	direct_memory_access {
-		@func refer
-		name {
-			@func concat
-			strings [
-				"cards."
-				{
-					@func card_driver
-					card $CARD
-				}
-				".dmix.direct_memory_access"
-			]
-		}
-		default true
-	}
 	slave {
 		pcm {
 			type hw
Signature · 1 line
2.12.2
#1 lore raw

PATCH 2/2 conf: Allow dynamic top-level config directory

Currently the top-level config directory is specified only via configure script option, and is fixed after that. It's inconvenient when the library is moved to another base directory, or if you want to use a library code (e.g. with $LD_PRELOAD) with the incompatible config setups.

This patch allows user to override the top-level config path via the environment varialbe, $ALSA_CONFIG_DIR. For that, a new helper function, snd_config_topdir(), was introduced, and the codes referring to the top config dir have been modified to handle it dynamically.

---
 include/conf.h            |  2 ++
 src/alisp/alisp.c         |  2 +-
 src/conf.c                | 66 ++++++++++++++++++++++++++++++++---------------
 src/confmisc.c            |  2 +-
 src/mixer/simple_abst.c   |  8 ++++--
 src/topology/data.c       |  7 +++--
 src/topology/tplg_local.h |  1 -
 src/ucm/parser.c          | 26 +++++++++++++------
 src/ucm/ucm_local.h       |  1 -
 9 files changed, 78 insertions(+), 37 deletions(-)
include/conf.h +2 -0
index 5d293d583fbb..efb1176b8b7f 100644
@@ -84,6 +84,8 @@ typedef struct _snd_config_update snd_config_update_t;
 
 extern snd_config_t *snd_config;
 
+const char *snd_config_topdir(void);
+
 int snd_config_top(snd_config_t **config);
 
 int snd_config_load(snd_config_t *config, snd_input_t *in);
src/alisp/alisp.c +1 -1
index 3c61bb1754c3..4ed4ad1ed02d 100644
@@ -2399,7 +2399,7 @@ struct alisp_object * F_path(struct alisp_instance *instance, struct alisp_objec
 	}
 	if (!strcmp(p1->value.s, "data")) {
 		delete_tree(instance, p1);
-		return new_string(instance, ALSA_CONFIG_DIR);
+		return new_string(instance, snd_config_topdir());
 	}
 	delete_tree(instance, p1);
 	return &alsa_lisp_nil;
src/conf.c +45 -21

104 lines not on this page · raw message

src/confmisc.c +1 -1
index a985f1434dd9..d5b934b62cb6 100644
@@ -588,7 +588,7 @@ int snd_func_datadir(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED,
 	err = snd_config_get_id(src, &id);
 	if (err < 0)
 		return err;
-	return snd_config_imake_string(dst, id, ALSA_CONFIG_DIR);
+	return snd_config_imake_string(dst, id, snd_config_topdir());
 }
 #ifndef DOC_HIDDEN
 SND_DLSYM_BUILD_VERSION(snd_func_datadir, SND_CONFIG_DLSYM_VERSION_EVALUATE);
src/mixer/simple_abst.c +6 -2
index 5297472a6d26..477c73ff7a1e 100644
@@ -299,8 +299,12 @@ int snd_mixer_simple_basic_register(snd_mixer_t *mixer,
 	snd_mixer_class_set_private(class, priv);
 	snd_mixer_class_set_private_free(class, private_free);
 	file = getenv("ALSA_MIXER_SIMPLE");
-	if (!file)
-		file = ALSA_CONFIG_DIR "/smixer.conf";
+	if (!file) {
+		const char *topdir = snd_config_topdir();
+		char *s = alloca(strlen(topdir) + strlen("smixer.conf") + 2);
+		sprintf(s, "%s/smixer.conf", topdir);
+		file = s;
+	}
 	err = snd_config_top(&top);
 	if (err >= 0) {
 		err = snd_input_stdio_open(&input, file, "r");
src/topology/data.c +5 -2
index 36060eb1bf97..5b83b9fc22e1 100644
@@ -76,8 +76,11 @@ static int tplg_parse_data_file(snd_config_t *cfg, struct tplg_elem *elem)
 		return -EINVAL;
 
 	/* prepend alsa config directory to path */
-	snprintf(filename, sizeof(filename), "%s/%s",
-		env ? env : ALSA_TPLG_DIR, value);
+	if (env)
+		snprintf(filename, sizeof(filename), "%s/%s", env, value);
+	else
+		snprintf(filename, sizeof(filename), "%s/topology/%s",
+			 snd_config_topdir(), value);
 
 	fp = fopen(filename, "r");
 	if (fp == NULL) {
src/topology/tplg_local.h +0 -1
index eb7eac5b2305..42e3201db41b 100644
@@ -31,7 +31,6 @@
 
 #define MAX_FILE		256
 #define TPLG_MAX_PRIV_SIZE	(1024 * 128)
-#define ALSA_TPLG_DIR	ALSA_CONFIG_DIR "/topology"
 
 /** The name of the environment variable containing the tplg directory */
 #define ALSA_CONFIG_TPLG_VAR "ALSA_CONFIG_TPLG"
src/ucm/parser.c +18 -8
index b79b92dbf7b1..8aa7099483ed 100644
@@ -1082,9 +1082,12 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
 	}
 
 	/* open Verb file for reading */
-	snprintf(filename, sizeof(filename), "%s/%s/%s",
-		env ? env : ALSA_USE_CASE_DIR,
-		uc_mgr->card_name, file);
+	if (env)
+		snprintf(filename, sizeof(filename), "%s/%s/%s",
+			 env, uc_mgr->card_name, file);
+	else
+		snprintf(filename, sizeof(filename), "%s/ucm/%s/%s",
+			 snd_config_topdir(), uc_mgr->card_name, file);
 	filename[sizeof(filename)-1] = '\0';
 	
 	err = uc_mgr_config_load(filename, &cfg);
@@ -1404,9 +1407,13 @@ static int load_master_config(const char *card_name, snd_config_t **cfg)
 		return -EINVAL;
 	}
 
-	snprintf(filename, sizeof(filename)-1,
-		"%s/%s/%s.conf", env ? env : ALSA_USE_CASE_DIR,
-		card_name, card_name);
+	if (env)
+		snprintf(filename, sizeof(filename)-1,
+			 "%s/%s/%s.conf", env, card_name, card_name);
+	else
+		snprintf(filename, sizeof(filename)-1,
+			 "%s/ucm/%s/%s.conf", snd_config_topdir(),
+			 card_name, card_name);
 	filename[MAX_FILE-1] = '\0';
 
 	err = uc_mgr_config_load(filename, cfg);
@@ -1514,8 +1521,11 @@ int uc_mgr_scan_master_configs(const char **_list[])
 	ssize_t ss;
 	struct dirent **namelist;
 
-	snprintf(filename, sizeof(filename)-1,
-		"%s", env ? env : ALSA_USE_CASE_DIR);
+	if (env)
+		snprintf(filename, sizeof(filename)-1, "%s", env);
+	else
+		snprintf(filename, sizeof(filename)-1, "%s/ucm",
+			 snd_config_topdir());
 	filename[MAX_FILE-1] = '\0';
 
 #if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__sun)
src/ucm/ucm_local.h +0 -1
index 299a5b96dba5..e5f59cea721f 100644
@@ -42,7 +42,6 @@
 
 #define MAX_FILE		256
 #define MAX_CARD_LONG_NAME	80
-#define ALSA_USE_CASE_DIR	ALSA_CONFIG_DIR "/ucm"
 
 #define SEQUENCE_ELEMENT_TYPE_CDEV	1
 #define SEQUENCE_ELEMENT_TYPE_CSET	2
Signature · 1 line
2.12.2