alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* UCM list/set/get
@ 2011-01-28 17:36 pl bossart
  2011-01-31 11:22 ` Mark Brown
  0 siblings, 1 reply; 11+ messages in thread
From: pl bossart @ 2011-01-28 17:36 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 2246 bytes --]

I've been trying to figure out what exactly needs to be filled in UCM
configuration files, and so far it's been a pretty frustrating
experience with alsa-utils/alsaucm :-(

The interactive mode in alsa-utils/alsaucm is broken, I fixed a couple
of segfaults and bad output (patches attached), but so far the only
thing I can do is list the verbs...It looks like
alsa-lib/include/use-case.h and alsa-utils/alsaucm are not aligned,
whenever I query with predefined identifiers alsaucm seg faults or
provides an error message that doesn't help much. This happens with
the latest code.

[ume@plb alsaucm]$ ./alsaucm listcards
  0: AudioPC
    this is my AudioPCI card
  1: SDP4430
    this is my SDP4430 card
  2: TestHDA
    A test HDA card
[ume@plb alsaucm]$ ./alsaucm -c AudioPCI list _verbs
  0: HiFi
    Play and record HiFi quality Music.
  1: Voice
    Full duplex low-power voice call

So far so good. Now the fun begins

[ume@plb alsaucm]$ ./alsaucm -c AudioPCI list _devices
./alsaucm: error failed to get list _devices: No such file or directory
[ume@plb alsaucm]$ ./alsaucm -c AudioPCI set _verb HiFi
ALSA lib main.c:1250:(set_verb_user) error: failed to initialize new
use case: HiFi
./alsaucm: error failed to set _verb=HiFi: No such device
[ume@plb alsaucm]$ ./alsaucm -c AudioPCI get _verb
./alsaucm: error failed to get _verb: No such file or directory

Likewise if the .conf file contains a cset in the default values, then
the parser fails (I took the example from src/ucm/parser.c).
Commenting out the cset is the only solution. What exactly is this
index supposed to mean?
SectionDefaults [
cdev "hw:AudioPCI"
cset "name='Master Playback Switch',index=2 1,1"
]

[ume@plb alsaucm]$ ./alsaucm -c AudioPCI list _verbs
ALSA lib main.c:302:(import_master_config) Unable to execute default sequence
ALSA lib main.c:637:(snd_use_case_mgr_open) error: failed to import
AudioPCI use case configuration -19
./alsaucm: error failed to open sound card AudioPCI: No such device

Ideally I'd like to write an interface between PulseAudio and UCM,
there are existing modules I can reuse to set voice or hifi modes,
depending on what the client roles are. But if I can't make the
examples work I don't think this is going to go anywhere.
-Pierre

[-- Attachment #2: 0001-ucm-make-verb-comments-optional.patch --]
[-- Type: application/octet-stream, Size: 1270 bytes --]

From dbd97f43a5bacf40424a986556e553267b0afdb2 Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Date: Thu, 27 Jan 2011 23:17:43 -0600
Subject: [PATCH] ucm: make verb comments optional

avoid seg fault if no comment is provided

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
---
 src/ucm/parser.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/ucm/parser.c b/src/ucm/parser.c
index f3a75e6..560c224 100644
--- a/src/ucm/parser.c
+++ b/src/ucm/parser.c
@@ -777,12 +777,17 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
 	INIT_LIST_HEAD(&verb->modifier_list);
 	INIT_LIST_HEAD(&verb->value_list);
 	list_add_tail(&verb->list, &uc_mgr->verb_list);
+        if (use_case_name == NULL )
+                return -EINVAL;
 	verb->name = strdup(use_case_name);
 	if (verb->name == NULL)
 		return -ENOMEM;
-	verb->comment = strdup(comment);
-	if (verb->comment == NULL)
-		return -ENOMEM;
+
+        if (comment != NULL) {
+                verb->comment = strdup(comment);
+                if (verb->comment == NULL)
+                        return -ENOMEM;
+        }
 
 	/* open Verb file for reading */
 	snprintf(filename, sizeof(filename), "%s/%s/%s",
-- 
1.7.3.2


[-- Attachment #3: 0001-alsaucm-fix-list-command-and-output.patch --]
[-- Type: application/octet-stream, Size: 1353 bytes --]

From f42f607972f59ccbd8bd67037b422db48a828c3c Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Date: Thu, 27 Jan 2011 23:14:44 -0600
Subject: [PATCH] alsaucm: fix list command and output

add one argument to list to avoid error message, do not list
comments as verbs

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
---
 alsaucm/usecase.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/alsaucm/usecase.c b/alsaucm/usecase.c
index bb894c6..8a255ba 100644
--- a/alsaucm/usecase.c
+++ b/alsaucm/usecase.c
@@ -85,7 +85,7 @@ static struct cmd cmds[] = {
 	{ OM_RESET, 0, 1, "reset" },
 	{ OM_RELOAD, 0, 1, "reload" },
 	{ OM_LISTCARDS, 0, 0, "listcards" },
-	{ OM_LIST, 0, 1, "list" },
+	{ OM_LIST, 1, 1, "list" },
 	{ OM_SET, 2, 1, "set" },
 	{ OM_GET, 1, 1, "get" },
 	{ OM_GETI, 1, 1, "geti" },
@@ -232,8 +232,12 @@ static int do_one(struct context *context, struct cmd *cmd, char **argv)
 		}
 		if (err == 0)
 			printf("  list is empty\n");
-		for (i = 0; i < err; i++)
-			printf("  %i: %s\n", i, list[i]);
+		for (i = 0; i < err / 2; i++) {
+			printf("  %i: %s\n", i, list[i*2]);
+                        if (list[i*2+1])
+				printf("    %s\n", list[i*2+1]);
+                }
+
 		snd_use_case_free_list(list, err);
 		break;
 	case OM_SET:
-- 
1.7.3.2


[-- Attachment #4: AudioPCI.conf --]
[-- Type: application/octet-stream, Size: 935 bytes --]

Comment "this is my AudioPCI card"

SectionUseCase."HiFi" {
 		File "hifi"
 		Comment "Play and record HiFi quality Music."
}

SectionUseCase."Voice" {
 		File "voice"
 		Comment "Full duplex low-power voice call"
}

ValueDefaults {
 	PlaybackCTL "hw:CARD=0"
 	CaptureCTL "hw:CARD=0"
}

# This file also store the default sound card state.

SectionDefaults [
cdev "hw:AudioPCI"
#cset "name='Master Playback Switch',index=2 1,1"
#cset "name='Master Playback Volume',index=2 25,25"
#cset "name='Master Mono Playback',index=1 0"
#cset "name='Master Mono Playback Volume',index=1 0"
#cset "name='PCM Switch',index=2 1,1"
#cset "name='Master Playback Switch' 1,1"
#cset "name='Master Playback Volume' 10,25"
#cset "name='Master Mono Playback Switch' 0"
#cset "name='Master Mono Playback Volume' 0"
#cset "name='PCM Switch' 1,1"
#cset "name='PCM Volume' 25,25"
#cset "name='PCM Playback Switch' 1,1"
#cset "name='PCM Capture Switch' 0,0"
]


[-- Attachment #5: hifi --]
[-- Type: application/octet-stream, Size: 1139 bytes --]

SectionVerb {
	# enable and disable sequences are compulsory
	EnableSequence [
		cdev "hw:AudioPCI"
		cset "name='Master Playback Switch',index=2 0,0"
		cset "name='Master Playback Volume',index=2 25,25"
		#msleep 50
		cset "name='Master Playback Switch',index=2 1,1"
		cset "name='Master Playback Volume',index=2 50,50"
	]

	DisableSequence [
		cdev "hw:AudioPCI"
		cset "name='Master Playback Switch',index=2 0,0"
		cset "name='Master Playback Volume',index=2 25,25"
		#msleep 50
		cset "name='Master Playback Switch',index=2 1,1"
		cset "name='Master Playback Volume',index=2 50,50"
	]

     # Optional transition verb
#     TransitionSequence."ToCaseName" [
#		msleep 1
#     ]

	# Optional TQ and ALSA PCMs
	Value {
		TQ HiFi
		CapturePCM "hw:0"
		PlaybackPCM "hw:0"
	}
}

SectionDevice."Headphones".0 {
	
	EnableSequence [
		cdev "hw:AudioPCI"
		cset "name='PCM Capture Switch' 1,1"
	]

	DisableSequence [
		cdev "hw:AudioPCI"
		cset "name='PCM Capture Switch' 0,0"
	]

	# the hardware volume controls for this device
	PlaybackVolume "name='Master Playback Volume',index=2"
	PlaybackSwitch "name='Master Playback Switch',index=2"
}


[-- Attachment #6: Type: text/plain, Size: 160 bytes --]

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

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

end of thread, other threads:[~2011-02-03 16:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-28 17:36 UCM list/set/get pl bossart
2011-01-31 11:22 ` Mark Brown
2011-01-31 13:53   ` Liam Girdwood
2011-01-31 14:07     ` Jaroslav Kysela
2011-01-31 21:57       ` pl bossart
2011-01-31 22:40         ` Jaroslav Kysela
2011-01-31 23:44     ` Margarita Olaya
2011-02-02  8:11       ` Jaroslav Kysela
2011-02-02 20:42         ` Liam Girdwood
2011-02-03 15:31           ` pl bossart
2011-02-03 16:08             ` Pulseaudio UCM integration - (Was:UCM list/set/get) Liam Girdwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).