alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: Make pmdown_time a per-card setting
@ 2010-02-12 11:40 Mark Brown
  2010-02-12 11:40 ` [PATCH 2/2] ASoC: Make pmdown_time runtime configurable Mark Brown
  2010-02-12 14:19 ` [PATCH 1/2] ASoC: Make pmdown_time a per-card setting Liam Girdwood
  0 siblings, 2 replies; 5+ messages in thread
From: Mark Brown @ 2010-02-12 11:40 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Grazvydas Ignotas, Liam Girdwood

Make the pmdown_time a per-card setting rather than a global one,
initialised before the card initialisation runs. This allows cards
to override the default setting if it makes sense to do so (for
example, due to an unavoidable pop).

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 include/sound/soc.h  |    2 ++
 sound/soc/soc-core.c |    4 +++-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index e6a6d10..d9d88dd 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -521,6 +521,8 @@ struct snd_soc_card {
 	int (*set_bias_level)(struct snd_soc_card *,
 			      enum snd_soc_bias_level level);
 
+	int pmdown_time;
+
 	/* CPU <--> Codec DAI links  */
 	struct snd_soc_dai_link *dai_link;
 	int num_links;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index ca89c78..94b9cde 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -542,7 +542,7 @@ static int soc_codec_close(struct snd_pcm_substream *substream)
 		/* start delayed pop wq here for playback streams */
 		codec_dai->pop_wait = 1;
 		schedule_delayed_work(&card->delayed_work,
-			msecs_to_jiffies(pmdown_time));
+			msecs_to_jiffies(card->pmdown_time));
 	} else {
 		/* capture streams can be powered down now */
 		snd_soc_dapm_stream_event(codec,
@@ -1039,6 +1039,8 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
 	dev_dbg(card->dev, "All components present, instantiating\n");
 
 	/* Found everything, bring it up */
+	card->pmdown_time = pmdown_time;
+
 	if (card->probe) {
 		ret = card->probe(pdev);
 		if (ret < 0)
-- 
1.6.6.1

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

* [PATCH 2/2] ASoC: Make pmdown_time runtime configurable
  2010-02-12 11:40 [PATCH 1/2] ASoC: Make pmdown_time a per-card setting Mark Brown
@ 2010-02-12 11:40 ` Mark Brown
  2010-02-12 14:22   ` Liam Girdwood
  2010-02-13 14:46   ` Grazvydas Ignotas
  2010-02-12 14:19 ` [PATCH 1/2] ASoC: Make pmdown_time a per-card setting Liam Girdwood
  1 sibling, 2 replies; 5+ messages in thread
From: Mark Brown @ 2010-02-12 11:40 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Grazvydas Ignotas, Liam Girdwood

Provide a sysfs file allowing userspace to inspect and change the
pmdown_time setting at runtime.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 sound/soc/soc-core.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 94b9cde..c2008bc 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -130,6 +130,29 @@ static ssize_t codec_reg_show(struct device *dev,
 
 static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
 
+static ssize_t pmdown_time_show(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	struct snd_soc_device *socdev = dev_get_drvdata(dev);
+	struct snd_soc_card *card = socdev->card;
+
+	return sprintf(buf, "%d\n", card->pmdown_time);
+}
+
+static ssize_t pmdown_time_set(struct device *dev,
+			       struct device_attribute *attr,
+			       const char *buf, size_t count)
+{
+	struct snd_soc_device *socdev = dev_get_drvdata(dev);
+	struct snd_soc_card *card = socdev->card;
+
+	strict_strtol(buf, 10, &card->pmdown_time);
+
+	return count;
+}
+
+static DEVICE_ATTR(pmdown_time, 0644, pmdown_time_show, pmdown_time_set);
+
 #ifdef CONFIG_DEBUG_FS
 static int codec_reg_open_file(struct inode *inode, struct file *file)
 {
@@ -1124,6 +1147,10 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
 	if (ret < 0)
 		printk(KERN_WARNING "asoc: failed to add dapm sysfs entries\n");
 
+	ret = device_create_file(card->socdev->dev, &dev_attr_pmdown_time);
+	if (ret < 0)
+		printk(KERN_WARNING "asoc: failed to add pmdown_time sysfs\n");
+
 	ret = device_create_file(card->socdev->dev, &dev_attr_codec_reg);
 	if (ret < 0)
 		printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
-- 
1.6.6.1

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

* Re: [PATCH 1/2] ASoC: Make pmdown_time a per-card setting
  2010-02-12 11:40 [PATCH 1/2] ASoC: Make pmdown_time a per-card setting Mark Brown
  2010-02-12 11:40 ` [PATCH 2/2] ASoC: Make pmdown_time runtime configurable Mark Brown
@ 2010-02-12 14:19 ` Liam Girdwood
  1 sibling, 0 replies; 5+ messages in thread
From: Liam Girdwood @ 2010-02-12 14:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Grazvydas Ignotas

On Fri, 2010-02-12 at 11:40 +0000, Mark Brown wrote:
> Make the pmdown_time a per-card setting rather than a global one,
> initialised before the card initialisation runs. This allows cards
> to override the default setting if it makes sense to do so (for
> example, due to an unavoidable pop).
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>

-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

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

* Re: [PATCH 2/2] ASoC: Make pmdown_time runtime configurable
  2010-02-12 11:40 ` [PATCH 2/2] ASoC: Make pmdown_time runtime configurable Mark Brown
@ 2010-02-12 14:22   ` Liam Girdwood
  2010-02-13 14:46   ` Grazvydas Ignotas
  1 sibling, 0 replies; 5+ messages in thread
From: Liam Girdwood @ 2010-02-12 14:22 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Grazvydas Ignotas

On Fri, 2010-02-12 at 11:40 +0000, Mark Brown wrote:
> Provide a sysfs file allowing userspace to inspect and change the
> pmdown_time setting at runtime.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  sound/soc/soc-core.c |   27 +++++++++++++++++++++++++++
>  1 files changed, 27 insertions(+), 0 deletions(-)
> 

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>

Btw, I wonder if we should make this configurable via alsa-lib in the
future (probably could be part of a QoS API). It's on my todo list now. 

Liam

-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

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

* Re: [PATCH 2/2] ASoC: Make pmdown_time runtime configurable
  2010-02-12 11:40 ` [PATCH 2/2] ASoC: Make pmdown_time runtime configurable Mark Brown
  2010-02-12 14:22   ` Liam Girdwood
@ 2010-02-13 14:46   ` Grazvydas Ignotas
  1 sibling, 0 replies; 5+ messages in thread
From: Grazvydas Ignotas @ 2010-02-13 14:46 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Liam Girdwood

On Fri, Feb 12, 2010 at 1:40 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> Provide a sysfs file allowing userspace to inspect and change the
> pmdown_time setting at runtime.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Thanks for doing this,
Tested-by: Grazvydas Ignotas <notasas@gmail.com>

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

end of thread, other threads:[~2010-02-13 14:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-12 11:40 [PATCH 1/2] ASoC: Make pmdown_time a per-card setting Mark Brown
2010-02-12 11:40 ` [PATCH 2/2] ASoC: Make pmdown_time runtime configurable Mark Brown
2010-02-12 14:22   ` Liam Girdwood
2010-02-13 14:46   ` Grazvydas Ignotas
2010-02-12 14:19 ` [PATCH 1/2] ASoC: Make pmdown_time a per-card setting 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).