From: Andrew Gabbasov <andrew_gabbasov@mentor.com> To: <alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, Timo Wischer <twischer@de.adit-jv.com>, Andrew Gabbasov <andrew_gabbasov@mentor.com> Subject: [PATCH v3 7/7] ALSA: aloop: Support runtime change of snd_timer via info interface Date: Mon, 11 Nov 2019 05:08:46 -0600 [thread overview] Message-ID: <20191111110846.18223-8-andrew_gabbasov@mentor.com> (raw) In-Reply-To: <20191111110846.18223-7-andrew_gabbasov@mentor.com> Show and change sound card timer source with read-write info file in proc filesystem. Initial string can still be set as module parameter. The timer source string value can be changed at any time, but it is latched by PCM substream open callback (the first one for a particular cable). At this point it is actually used, that is the string is parsed, and the timer is looked up and opened. The timer source is set for a loopback card (the same as initial setting by module parameter), but every cable uses the value, current at the moment of open. Setting the value to empty string switches the timer to jiffies. Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com> --- sound/drivers/aloop.c | 45 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 2f08038f8792..430ab757a4c4 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -1667,7 +1667,7 @@ static void print_cable_info(struct snd_info_entry *entry, mutex_unlock(&loopback->cable_lock); } -static int loopback_proc_new(struct loopback *loopback, int cidx) +static int loopback_cable_proc_new(struct loopback *loopback, int cidx) { char name[32]; @@ -1688,6 +1688,44 @@ static void loopback_set_timer_source(struct loopback *loopback, value, GFP_KERNEL); } +static void print_timer_source_info(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) +{ + struct loopback *loopback = entry->private_data; + + mutex_lock(&loopback->cable_lock); + snd_iprintf(buffer, "%s\n", + loopback->timer_source ? loopback->timer_source : ""); + mutex_unlock(&loopback->cable_lock); +} + +static void change_timer_source_info(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) +{ + struct loopback *loopback = entry->private_data; + char line[64]; + + mutex_lock(&loopback->cable_lock); + if (!snd_info_get_line(buffer, line, sizeof(line))) + loopback_set_timer_source(loopback, strim(line)); + mutex_unlock(&loopback->cable_lock); +} + +static int loopback_timer_source_proc_new(struct loopback *loopback) +{ + struct snd_info_entry *entry; + int err; + + err = snd_card_proc_new(loopback->card, "timer_source", &entry); + if (err < 0) + return err; + + snd_info_set_text_ops(entry, loopback, print_timer_source_info); + entry->mode |= S_IWUSR; + entry->c.text.write = change_timer_source_info; + return 0; +} + static int loopback_probe(struct platform_device *devptr) { struct snd_card *card; @@ -1720,8 +1758,9 @@ static int loopback_probe(struct platform_device *devptr) err = loopback_mixer_new(loopback, pcm_notify[dev] ? 1 : 0); if (err < 0) goto __nodev; - loopback_proc_new(loopback, 0); - loopback_proc_new(loopback, 1); + loopback_cable_proc_new(loopback, 0); + loopback_cable_proc_new(loopback, 1); + loopback_timer_source_proc_new(loopback); strcpy(card->driver, "Loopback"); strcpy(card->shortname, "Loopback"); sprintf(card->longname, "Loopback %i", dev + 1); -- 2.21.0
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Gabbasov <andrew_gabbasov@mentor.com> To: <alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, Timo Wischer <twischer@de.adit-jv.com>, Andrew Gabbasov <andrew_gabbasov@mentor.com> Subject: [alsa-devel] [PATCH v3 7/7] ALSA: aloop: Support runtime change of snd_timer via info interface Date: Mon, 11 Nov 2019 05:08:46 -0600 [thread overview] Message-ID: <20191111110846.18223-8-andrew_gabbasov@mentor.com> (raw) In-Reply-To: <20191111110846.18223-7-andrew_gabbasov@mentor.com> Show and change sound card timer source with read-write info file in proc filesystem. Initial string can still be set as module parameter. The timer source string value can be changed at any time, but it is latched by PCM substream open callback (the first one for a particular cable). At this point it is actually used, that is the string is parsed, and the timer is looked up and opened. The timer source is set for a loopback card (the same as initial setting by module parameter), but every cable uses the value, current at the moment of open. Setting the value to empty string switches the timer to jiffies. Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com> --- sound/drivers/aloop.c | 45 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 2f08038f8792..430ab757a4c4 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -1667,7 +1667,7 @@ static void print_cable_info(struct snd_info_entry *entry, mutex_unlock(&loopback->cable_lock); } -static int loopback_proc_new(struct loopback *loopback, int cidx) +static int loopback_cable_proc_new(struct loopback *loopback, int cidx) { char name[32]; @@ -1688,6 +1688,44 @@ static void loopback_set_timer_source(struct loopback *loopback, value, GFP_KERNEL); } +static void print_timer_source_info(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) +{ + struct loopback *loopback = entry->private_data; + + mutex_lock(&loopback->cable_lock); + snd_iprintf(buffer, "%s\n", + loopback->timer_source ? loopback->timer_source : ""); + mutex_unlock(&loopback->cable_lock); +} + +static void change_timer_source_info(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) +{ + struct loopback *loopback = entry->private_data; + char line[64]; + + mutex_lock(&loopback->cable_lock); + if (!snd_info_get_line(buffer, line, sizeof(line))) + loopback_set_timer_source(loopback, strim(line)); + mutex_unlock(&loopback->cable_lock); +} + +static int loopback_timer_source_proc_new(struct loopback *loopback) +{ + struct snd_info_entry *entry; + int err; + + err = snd_card_proc_new(loopback->card, "timer_source", &entry); + if (err < 0) + return err; + + snd_info_set_text_ops(entry, loopback, print_timer_source_info); + entry->mode |= S_IWUSR; + entry->c.text.write = change_timer_source_info; + return 0; +} + static int loopback_probe(struct platform_device *devptr) { struct snd_card *card; @@ -1720,8 +1758,9 @@ static int loopback_probe(struct platform_device *devptr) err = loopback_mixer_new(loopback, pcm_notify[dev] ? 1 : 0); if (err < 0) goto __nodev; - loopback_proc_new(loopback, 0); - loopback_proc_new(loopback, 1); + loopback_cable_proc_new(loopback, 0); + loopback_cable_proc_new(loopback, 1); + loopback_timer_source_proc_new(loopback); strcpy(card->driver, "Loopback"); strcpy(card->shortname, "Loopback"); sprintf(card->longname, "Loopback %i", dev + 1); -- 2.21.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2019-11-11 11:10 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-11 11:08 [PATCH v3 0/7] ALSA: aloop: Support sound timer as clock source instead of jiffies Andrew Gabbasov 2019-11-11 11:08 ` [alsa-devel] " Andrew Gabbasov 2019-11-11 11:08 ` [PATCH v3 1/7] ALSA: aloop: Describe units of variables Andrew Gabbasov 2019-11-11 11:08 ` [alsa-devel] " Andrew Gabbasov 2019-11-11 11:08 ` [PATCH v3 2/7] ALSA: aloop: Support return of error code for timer start and stop Andrew Gabbasov 2019-11-11 11:08 ` [alsa-devel] " Andrew Gabbasov 2019-11-11 11:08 ` [PATCH v3 3/7] ALSA: aloop: Use callback functions for timer specific implementations Andrew Gabbasov 2019-11-11 11:08 ` [alsa-devel] " Andrew Gabbasov 2019-11-11 11:08 ` [PATCH v3 4/7] ALSA: aloop: Rename all jiffies timer specific functions Andrew Gabbasov 2019-11-11 11:08 ` [alsa-devel] " Andrew Gabbasov 2019-11-11 11:08 ` [PATCH v3 5/7] ALSA: aloop: Move CABLE_VALID_BOTH to the top of file Andrew Gabbasov 2019-11-11 11:08 ` [alsa-devel] " Andrew Gabbasov 2019-11-11 11:08 ` [PATCH v3 6/7] ALSA: aloop: Support selection of snd_timer instead of jiffies Andrew Gabbasov 2019-11-11 11:08 ` [alsa-devel] " Andrew Gabbasov 2019-11-11 11:08 ` Andrew Gabbasov [this message] 2019-11-11 11:08 ` [alsa-devel] [PATCH v3 7/7] ALSA: aloop: Support runtime change of snd_timer via info interface Andrew Gabbasov 2019-11-14 17:10 ` [PATCH v3 0/7] ALSA: aloop: Support sound timer as clock source instead of jiffies Takashi Iwai 2019-11-14 17:10 ` [alsa-devel] " Takashi Iwai 2019-11-20 12:15 ` Andrew Gabbasov 2019-11-20 12:15 ` [alsa-devel] " Andrew Gabbasov
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=20191111110846.18223-8-andrew_gabbasov@mentor.com \ --to=andrew_gabbasov@mentor.com \ --cc=alsa-devel@alsa-project.org \ --cc=linux-kernel@vger.kernel.org \ --cc=perex@perex.cz \ --cc=tiwai@suse.com \ --cc=twischer@de.adit-jv.com \ /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: linkBe 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.