alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: tlv320dac33: Limit the US_TO_SAMPLES macro
@ 2010-10-29 11:07 Peter Ujfalusi
  2010-10-29 17:18 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Ujfalusi @ 2010-10-29 11:07 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, Liam Girdwood

Limit the time window to maximum 1s in the macro.
The driver deals with much shorter times (<200ms).
This will fix a rare division by zero bug in Mode1.
This could happen, when the work is not executed in
time (within mode1_latency) after the interrupt.
In this case the DAC33 will not receive the needed
nSample command in time, and enters to an unknown
state, and won't recover.
In such event the time window will increase, and
eventually going to be bigger than 1s, resulting
devision by zero.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
---
 sound/soc/codecs/tlv320dac33.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index 6778e2e..c5ab8c8 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -58,7 +58,7 @@
 	(1000000000 / ((rate * 1000) / samples))
 
 #define US_TO_SAMPLES(rate, us) \
-	(rate / (1000000 / us))
+	(rate / (1000000 / (us < 1000000 ? us : 1000000)))
 
 #define UTHR_FROM_PERIOD_SIZE(samples, playrate, burstrate) \
 	((samples * 5000) / ((burstrate * 5000) / (burstrate - playrate)))
-- 
1.7.3.2

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

* Re: [PATCH] ASoC: tlv320dac33: Limit the US_TO_SAMPLES macro
  2010-10-29 11:07 [PATCH] ASoC: tlv320dac33: Limit the US_TO_SAMPLES macro Peter Ujfalusi
@ 2010-10-29 17:18 ` Mark Brown
  2010-10-30 16:38   ` Liam Girdwood
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2010-10-29 17:18 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, Liam Girdwood

On Fri, Oct 29, 2010 at 02:07:25PM +0300, Peter Ujfalusi wrote:
> Limit the time window to maximum 1s in the macro.
> The driver deals with much shorter times (<200ms).

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

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

* Re: [PATCH] ASoC: tlv320dac33: Limit the US_TO_SAMPLES macro
  2010-10-29 17:18 ` Mark Brown
@ 2010-10-30 16:38   ` Liam Girdwood
  0 siblings, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2010-10-30 16:38 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Peter Ujfalusi

On Fri, 2010-10-29 at 10:18 -0700, Mark Brown wrote:
> On Fri, Oct 29, 2010 at 02:07:25PM +0300, Peter Ujfalusi wrote:
> > Limit the time window to maximum 1s in the macro.
> > The driver deals with much shorter times (<200ms).
> 
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

All Peter's fixes applied.

Thanks

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

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

end of thread, other threads:[~2010-10-30 16:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-29 11:07 [PATCH] ASoC: tlv320dac33: Limit the US_TO_SAMPLES macro Peter Ujfalusi
2010-10-29 17:18 ` Mark Brown
2010-10-30 16:38   ` 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).