All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 2/3] test-runner: Add audio card support
Date: Fri, 10 Jun 2022 09:28:49 +0200	[thread overview]
Message-ID: <20220610072850.16593-3-frederic.danis@collabora.com> (raw)
In-Reply-To: <20220610072850.16593-1-frederic.danis@collabora.com>

With this commit audio daemons can detect an audio card with output and
input, allowing to test interaction between BlueZ and the audio daemon.
---
 doc/test-runner.txt |  5 +++++
 tools/test-runner.c | 23 ++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/doc/test-runner.txt b/doc/test-runner.txt
index 683c622a2..019c23188 100644
--- a/doc/test-runner.txt
+++ b/doc/test-runner.txt
@@ -54,6 +54,11 @@ For Bluetooth functionality:
 
 	CONFIG_UHID=y
 
+For Audio functionality:
+	CONFIG_SYSVIPC=y
+	CONFIG_SOUND=y
+	CONFIG_SND=y
+	CONFIG_SND_INTEL8X0=y
 
 These options should be installed as .config in the kernel source directory
 followed by this command.
diff --git a/tools/test-runner.c b/tools/test-runner.c
index 9fc8e7b33..bbbca5b5d 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -54,6 +54,7 @@ static bool start_monitor = false;
 static int num_devs = 0;
 static const char *qemu_binary = NULL;
 static const char *kernel_image = NULL;
+static bool audio_support;
 
 static const char *qemu_table[] = {
 	"qemu-system-x86_64",
@@ -261,6 +262,7 @@ static void start_qemu(void)
 				run_auto, testargs);
 
 	argv = alloca(sizeof(qemu_argv) +
+				(audio_support ? 4 : 0) +
 				(sizeof(char *) * (4 + (num_devs * 4))));
 	memcpy(argv, qemu_argv, sizeof(qemu_argv));
 
@@ -268,6 +270,20 @@ static void start_qemu(void)
 
 	argv[0] = (char *) qemu_binary;
 
+	if (audio_support) {
+		char *xdg_runtime_dir, *audiodev;
+
+		xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
+		audiodev = alloca(40 + strlen(xdg_runtime_dir));
+		sprintf(audiodev, "id=audio,driver=pa,server=%s/pulse/native",
+				xdg_runtime_dir);
+
+		argv[pos++] = "-audiodev";
+		argv[pos++] = audiodev;
+		argv[pos++] = "-device";
+		argv[pos++] = "AC97,audiodev=audio";
+	}
+
 	argv[pos++] = "-kernel";
 	argv[pos++] = (char *) kernel_image;
 	argv[pos++] = "-append";
@@ -990,6 +1006,7 @@ static void usage(void)
 		"\t-u, --unix [path]      Provide serial device\n"
 		"\t-q, --qemu <path>      QEMU binary\n"
 		"\t-k, --kernel <image>   Kernel image (bzImage)\n"
+		"\t-A, --audio            Add audio support\n"
 		"\t-h, --help             Show help options\n");
 }
 
@@ -1004,6 +1021,7 @@ static const struct option main_options[] = {
 	{ "monitor", no_argument,       NULL, 'm' },
 	{ "qemu",    required_argument, NULL, 'q' },
 	{ "kernel",  required_argument, NULL, 'k' },
+	{ "audio",   no_argument,       NULL, 'A' },
 	{ "version", no_argument,       NULL, 'v' },
 	{ "help",    no_argument,       NULL, 'h' },
 	{ }
@@ -1023,7 +1041,7 @@ int main(int argc, char *argv[])
 	for (;;) {
 		int opt;
 
-		opt = getopt_long(argc, argv, "aubdslmq:k:vh", main_options,
+		opt = getopt_long(argc, argv, "aubdslmq:k:Avh", main_options,
 								NULL);
 		if (opt < 0)
 			break;
@@ -1057,6 +1075,9 @@ int main(int argc, char *argv[])
 		case 'k':
 			kernel_image = optarg;
 			break;
+		case 'A':
+			audio_support = true;
+			break;
 		case 'v':
 			printf("%s\n", VERSION);
 			return EXIT_SUCCESS;
-- 
2.25.1


  parent reply	other threads:[~2022-06-10  7:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10  7:28 [PATCH BlueZ v2 0/3] test-runner: Add support for audio daemons Frédéric Danis
2022-06-10  7:28 ` [PATCH BlueZ v2 1/3] test-runner: Add DBus session support Frédéric Danis
2022-06-10  9:51   ` test-runner: Add support for audio daemons bluez.test.bot
2022-06-10  7:28 ` Frédéric Danis [this message]
2022-06-10 15:48   ` [PATCH BlueZ v2 2/3] test-runner: Add audio card support Luiz Augusto von Dentz
2022-06-10  7:28 ` [PATCH BlueZ v2 3/3] test-runner: Add udevd and trigger events Frédéric Danis
2022-06-10 15:50   ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220610072850.16593-3-frederic.danis@collabora.com \
    --to=frederic.danis@collabora.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.