rpms/kernel/devel alsa-pcm-always-reset-invalid-position.patch, NONE, 1.1 alsa-pcm-fix-delta-calc-at-overlap.patch, NONE, 1.1 alsa-pcm-safer-boundary-checks.patch, NONE, 1.1 kernel.spec, 1.1479, 1.1480

Chuck Ebbert cebbert at fedoraproject.org
Sun Mar 29 23:04:20 UTC 2009


Author: cebbert

Update of /cvs/pkgs/rpms/kernel/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26848

Modified Files:
	kernel.spec 
Added Files:
	alsa-pcm-always-reset-invalid-position.patch 
	alsa-pcm-fix-delta-calc-at-overlap.patch 
	alsa-pcm-safer-boundary-checks.patch 
Log Message:
More fixes for ALSA hardware pointer updating.

alsa-pcm-always-reset-invalid-position.patch:

--- NEW FILE alsa-pcm-always-reset-invalid-position.patch ---
From: Takashi Iwai <tiwai at suse.de>
Date: Thu, 19 Mar 2009 09:01:47 +0000 (+0100)
Subject: ALSA: pcm - Reset invalid position even without debug option
X-Git-Url: http://git.alsa-project.org/?p=alsa-kernel.git;a=commitdiff_plain;h=f28f43ce9ae6573952d2348bb6da859cad762143

ALSA: pcm - Reset invalid position even without debug option

Always reset the invalind hw_ptr position returned by the pointer
callback.  The behavior should be consitent independently from the
debug option.

Also, add the printk_ratelimit() check to avoid flooding debug
prints.

Signed-off-by: Takashi Iwai <tiwai at suse.de>
Signed-off-by: Jaroslav Kysela <perex at perex.cz>
---

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 3026547..92ed6d8 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -159,11 +159,15 @@ snd_pcm_update_hw_ptr_pos(struct snd_pcm_substream *substream,
 	pos = substream->ops->pointer(substream);
 	if (pos == SNDRV_PCM_POS_XRUN)
 		return pos; /* XRUN */
-#ifdef CONFIG_SND_DEBUG
 	if (pos >= runtime->buffer_size) {
-		snd_printk(KERN_ERR  "BUG: stream = %i, pos = 0x%lx, buffer size = 0x%lx, period size = 0x%lx\n", substream->stream, pos, runtime->buffer_size, runtime->period_size);
+		if (printk_ratelimit()) {
+			snd_printd(KERN_ERR  "BUG: stream = %i, pos = 0x%lx, "
+				   "buffer size = 0x%lx, period size = 0x%lx\n",
+				   substream->stream, pos, runtime->buffer_size,
+				   runtime->period_size);
+		}
+		pos = 0;
 	}
-#endif
 	pos -= pos % runtime->min_align;
 	return pos;
 }

alsa-pcm-fix-delta-calc-at-overlap.patch:

--- NEW FILE alsa-pcm-fix-delta-calc-at-overlap.patch ---
From: Takashi Iwai <tiwai at suse.de>
Date: Thu, 19 Mar 2009 09:08:49 +0000 (+0100)
Subject: ALSA: pcm - Fix delta calculation at boundary overlap
X-Git-Url: http://git.alsa-project.org/?p=alsa-kernel.git;a=commitdiff_plain;h=09a067199b6caa61818fc04f4759048dff13b21c

ALSA: pcm - Fix delta calculation at boundary overlap

When the hw_ptr_interrupt reaches the boundary, it must check whether
the hw_base was already lapped and corret the delta value appropriately.

Also, rebasing the hw_ptr needs a correction because buffer_size isn't
always aligned to period_size.

Signed-off-by: Takashi Iwai <tiwai at suse.de>
Signed-off-by: Jaroslav Kysela <perex at perex.cz>
---

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 92ed6d8..063c675 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -221,8 +221,11 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream)
 	new_hw_ptr = hw_base + pos;
 	hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size;
 	delta = new_hw_ptr - hw_ptr_interrupt;
-	if (hw_ptr_interrupt == runtime->boundary)
-		hw_ptr_interrupt = 0;
+	if (hw_ptr_interrupt >= runtime->boundary) {
+		hw_ptr_interrupt %= runtime->boundary;
+		if (!hw_base) /* hw_base was already lapped; recalc delta */
+			delta = new_hw_ptr - hw_ptr_interrupt;
+	}
 	if (delta < 0) {
 		delta += runtime->buffer_size;
 		if (delta < 0) {
@@ -233,6 +236,8 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream)
 				     (long)hw_ptr_interrupt);
 			/* rebase to interrupt position */
 			hw_base = new_hw_ptr = hw_ptr_interrupt;
+			/* align hw_base to buffer_size */
+			hw_base -= hw_base % runtime->buffer_size;
 			delta = 0;
 		} else {
 			hw_base += runtime->buffer_size;

alsa-pcm-safer-boundary-checks.patch:

--- NEW FILE alsa-pcm-safer-boundary-checks.patch ---
From: Takashi Iwai <tiwai at suse.de>
Date: Fri, 20 Mar 2009 15:26:15 +0000 (+0100)
Subject: ALSA: pcm - Safer boundary checks
X-Git-Url: http://git.alsa-project.org/?p=alsa-kernel.git;a=commitdiff_plain;h=d9b59892fb7108f6ee33a4fcdc257587b68f2ed6

ALSA: pcm - Safer boundary checks

Make the boundary checks a bit safer.
These caese are rare or theoretically won't happen, but nothing
bad to keep the checks safer...

Signed-off-by: Takashi Iwai <tiwai at suse.de>
Signed-off-by: Jaroslav Kysela <perex at perex.cz>
---

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 063c675..fbb2e39 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -222,8 +222,9 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream)
 	hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size;
 	delta = new_hw_ptr - hw_ptr_interrupt;
 	if (hw_ptr_interrupt >= runtime->boundary) {
-		hw_ptr_interrupt %= runtime->boundary;
-		if (!hw_base) /* hw_base was already lapped; recalc delta */
+		hw_ptr_interrupt -= runtime->boundary;
+		if (hw_base < runtime->boundary / 2)
+			/* hw_base was already lapped; recalc delta */
 			delta = new_hw_ptr - hw_ptr_interrupt;
 	}
 	if (delta < 0) {
@@ -241,7 +242,7 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream)
 			delta = 0;
 		} else {
 			hw_base += runtime->buffer_size;
-			if (hw_base == runtime->boundary)
+			if (hw_base >= runtime->boundary)
 				hw_base = 0;
 			new_hw_ptr = hw_base + pos;
 		}
@@ -296,7 +297,7 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream)
 			return 0;
 		}
 		hw_base += runtime->buffer_size;
-		if (hw_base == runtime->boundary)
+		if (hw_base >= runtime->boundary)
 			hw_base = 0;
 		new_hw_ptr = hw_base + pos;
 	}


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/kernel.spec,v
retrieving revision 1.1479
retrieving revision 1.1480
diff -u -r1.1479 -r1.1480
--- kernel.spec	28 Mar 2009 12:52:32 -0000	1.1479
+++ kernel.spec	29 Mar 2009 23:03:48 -0000	1.1480
@@ -639,6 +639,9 @@
 
 Patch600: linux-2.6-defaults-alsa-hda-beep-off.patch
 Patch601: alsa-rewrite-hw_ptr-updaters.patch
+Patch602: alsa-pcm-always-reset-invalid-position.patch
+Patch603: alsa-pcm-fix-delta-calc-at-overlap.patch
+Patch604: alsa-pcm-safer-boundary-checks.patch
 Patch610: hda_intel-prealloc-4mb-dmabuffer.patch
 
 Patch670: linux-2.6-ata-quirk.patch
@@ -1157,6 +1160,16 @@
 ApplyPatch linux-2.6-scsi-cpqarray-set-master.patch
 
 # ALSA
+# squelch hda_beep by default
+ApplyPatch linux-2.6-defaults-alsa-hda-beep-off.patch
+
+# fix alsa for pulseaudio
+ApplyPatch alsa-rewrite-hw_ptr-updaters.patch
+ApplyPatch alsa-pcm-always-reset-invalid-position.patch
+ApplyPatch alsa-pcm-fix-delta-calc-at-overlap.patch
+ApplyPatch alsa-pcm-safer-boundary-checks.patch
+
+ApplyPatch hda_intel-prealloc-4mb-dmabuffer.patch
 
 # Networking
 
@@ -1188,10 +1201,6 @@
 
 # Changes to upstream defaults.
 
-# squelch hda_beep by default
-ApplyPatch linux-2.6-defaults-alsa-hda-beep-off.patch
-ApplyPatch alsa-rewrite-hw_ptr-updaters.patch
-ApplyPatch hda_intel-prealloc-4mb-dmabuffer.patch
 
 # ia64 ata quirk
 ApplyPatch linux-2.6-ata-quirk.patch
@@ -1832,6 +1841,9 @@
 # and build.
 
 %changelog
+* Sun Mar 29 2009 Chuck Ebbert <cebbert at redhat.com>
+- More fixes for ALSA hardware pointer updating.
+
 * Sat Mar 28 2009 Mauro Carvalho Chehab <mchehab at redhat.com>
 - linux-2.6-revert-dvb-net-kabi-change.patch: attempt to fix dvb net breakage
 - update v4l fixes patch to reflect what's ready for 2.6.30




More information about the fedora-extras-commits mailing list