Skip to contentSkip to conversation

i810_audio: offset LVI from CIV to avoid stalled start

PATCH In review John W. Linville 2 participants 12 messages Jan 20, 2005 – Aug 3, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i810_audio: offset LVI from CIV to avoid stalled start

Offset LVI past CIV when starting DAC/ADC in order to prevent stalled start.

---
This fixes a "no sound" problem with Wolfenstein Enemy Territory and (apparently) other games using the Quake3 engine. It probably affects some other OSS applications as well.

This recreates some code that had been removed from the i810_audio driver around 5/2004.

 drivers/sound/i810_audio.c |   10 ++++++++++
 1 files changed, 10 insertions(+)
drivers/sound/i810_audio.c renamed from drivers/sound/i810_audio.c.orig +10 -0
@@ -1062,10 +1062,20 @@
 	if (count < fragsize)
 		return;
 
+	/* if we are currently stopped, then our CIV is actually set to our
+	 * *last* sg segment and we are ready to wrap to the next.  However,
+	 * if we set our LVI to the last sg segment, then it won't wrap to
+	 * the next sg segment, it won't even get a start.  So, instead, when
+	 * we are stopped, we set both the LVI value and also we increment
+	 * the CIV value to the next sg segment to be played so that when
+	 * we call start, things will operate properly
+	 */
 	if (!dmabuf->enable && dmabuf->ready) {
 		if (!(dmabuf->trigger & trigger))
 			return;
 
+		CIV_TO_LVI(state->card, port, 1);
+
 		start(state);
 		while (!(inb(port + OFF_CR) & ((1<<4) | (1<<2))))
 			;
Signature · 2 lines
John W. Linville
[email protected]
#1 lore raw
Quoted 5 lines · John W. Linville
drivers/sound/i810_audio.c renamed from drivers/sound/i810_audio.c.orig +4 -0
+	/* if we are currently stopped, then our CIV is actually set to our
+	 * *last* sg segment and we are ready to wrap to the next.  However,
+	 * if we set our LVI to the last sg segment, then it won't wrap to
+	 * the next sg segment, it won't even get a start.  So, instead, when

drivers/sound/i810_audio.c line 1078

Quoted 10 lines
drivers/sound/i810_audio.c renamed from drivers/sound/i810_audio.c.orig +6 -0
+	 * we are stopped, we set both the LVI value and also we increment
+	 * the CIV value to the next sg segment to be played so that when
+	 * we call start, things will operate properly
+	 */
 	if (!dmabuf->enable && dmabuf->ready) {
 		if (!(dmabuf->trigger & trigger))
 			return;
 
+		CIV_TO_LVI(state->card, port, 1);
+

BTW, I think you want to fix up the last sentence in the comment. It doesn't seem to correspond to what the code is doing.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw
In reply to John W. Linville

Please ignore this patch...it was made assuming that a previous patch had been applied -- that seems not to have been the case...

I will reform and repost...

John

Quoted 48 lines · John W. Linville

Offset LVI past CIV when starting DAC/ADC in order to prevent stalled start.

---
This fixes a "no sound" problem with Wolfenstein Enemy Territory and (apparently) other games using the Quake3 engine. It probably affects some other OSS applications as well.

This recreates some code that had been removed from the i810_audio driver around 5/2004.

 drivers/sound/i810_audio.c |   10 ++++++++++
 1 files changed, 10 insertions(+)
drivers/sound/i810_audio.c renamed from drivers/sound/i810_audio.c.orig +10 -0
@@ -1062,10 +1062,20 @@
 	if (count < fragsize)
 		return;
 
+	/* if we are currently stopped, then our CIV is actually set to our
+	 * *last* sg segment and we are ready to wrap to the next.  However,
+	 * if we set our LVI to the last sg segment, then it won't wrap to
+	 * the next sg segment, it won't even get a start.  So, instead, when
+	 * we are stopped, we set both the LVI value and also we increment
+	 * the CIV value to the next sg segment to be played so that when
+	 * we call start, things will operate properly
+	 */
 	if (!dmabuf->enable && dmabuf->ready) {
 		if (!(dmabuf->trigger & trigger))
 			return;
 
+		CIV_TO_LVI(state->card, port, 1);
+
 		start(state);
 		while (!(inb(port + OFF_CR) & ((1<<4) | (1<<2))))
 			;
Signature · 7 lines
John W. Linville
[email protected]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Signature · 2 lines
John W. Linville
[email protected]
#3 lore raw

PATCH 1/1 i810_audio: offset LVI from CIV to avoid stalled start

Offset LVI past CIV when starting DAC/ADC in order to prevent stalled start.

---
(Use this one...it doesn't depend on a non-existent patch...)

This fixes a "no sound" problem with Wolfenstein Enemy Territory and (apparently) other games using the Quake3 engine. It probably affects some other OSS applications as well.

This recreates some code that had been removed from the i810_audio driver around 5/2004.

 drivers/sound/i810_audio.c |   10 ++++++++++
 1 files changed, 10 insertions(+)
drivers/sound/i810_audio.c renamed from drivers/sound/i810_audio.c.orig +10 -0
@@ -1062,10 +1062,20 @@
 	if (count < fragsize)
 		return;
 
+	/* if we are currently stopped, then our CIV is actually set to our
+	 * *last* sg segment and we are ready to wrap to the next.  However,
+	 * if we set our LVI to the last sg segment, then it won't wrap to
+	 * the next sg segment, it won't even get a start.  So, instead, when
+	 * we are stopped, we increment the CIV value to the next sg segment
+	 * to be played so that when we call start, things will operate
+	 * properly
+	 */
 	if (!dmabuf->enable && dmabuf->ready) {
 		if (!(dmabuf->trigger & trigger))
 			return;
 
+		CIV_TO_LVI(port, 1);
+
 		start(state);
 		while (!(inb(port + OFF_CR) & ((1<<4) | (1<<2))))
 			;
Signature · 2 lines
John W. Linville
[email protected]
#4 lore raw

drivers/sound/i810_audio.c line 1072

Quoted 8 lines · John W. Linville
drivers/sound/i810_audio.c renamed from drivers/sound/i810_audio.c.orig +8 -0
+	/* if we are currently stopped, then our CIV is actually set to our
+	 * *last* sg segment and we are ready to wrap to the next.  However,
+	 * if we set our LVI to the last sg segment, then it won't wrap to
+	 * the next sg segment, it won't even get a start.  So, instead, when
+	 * we are stopped, we increment the CIV value to the next sg segment
+	 * to be played so that when we call start, things will operate
+	 * properly
+	 */

Herbert,

Is this (slightly altered) comment more to your liking? If so, I'll post an additive patch for the 2.6 version...

John

Signature · 2 lines
John W. Linville
[email protected]
#5 lore raw
Quoted 13 lines · John W. Linville

drivers/sound/i810_audio.c line 1072

Quoted 8 lines · John W. Linville
drivers/sound/i810_audio.c renamed from drivers/sound/i810_audio.c.orig +8 -0
+	/* if we are currently stopped, then our CIV is actually set to our
+	 * *last* sg segment and we are ready to wrap to the next.  However,
+	 * if we set our LVI to the last sg segment, then it won't wrap to
+	 * the next sg segment, it won't even get a start.  So, instead, when
+	 * we are stopped, we increment the CIV value to the next sg segment
+	 * to be played so that when we call start, things will operate
+	 * properly
+	 */

Is this (slightly altered) comment more to your liking? If so, I'll post an additive patch for the 2.6 version...

IMHO the last sentence is still wrong. We're not touching the value of CIV at all. We're setting LVI to CIV + 1...

OTOH, perhaps we should actually try implementing what the comment suggests?

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#6 lore raw
Quoted 15 lines · herbert
Quoted 13 lines · John W. Linville

drivers/sound/i810_audio.c line 1072

Quoted 8 lines · John W. Linville
drivers/sound/i810_audio.c renamed from drivers/sound/i810_audio.c.orig +8 -0
+	/* if we are currently stopped, then our CIV is actually set to our
+	 * *last* sg segment and we are ready to wrap to the next.  However,
+	 * if we set our LVI to the last sg segment, then it won't wrap to
+	 * the next sg segment, it won't even get a start.  So, instead, when
+	 * we are stopped, we increment the CIV value to the next sg segment
+	 * to be played so that when we call start, things will operate
+	 * properly
+	 */

Is this (slightly altered) comment more to your liking? If so, I'll post an additive patch for the 2.6 version...

Quoted 5 lines

IMHO the last sentence is still wrong. We're not touching the value of CIV at all. We're setting LVI to CIV + 1...

OTOH, perhaps we should actually try implementing what the comment suggests?

OK I dug into the archives and found that the reason we need to do it this way is because you can't set the value of CIV directly. So how about s/CIV/LVI/ in the last sentence?

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#7 lore raw
Quoted 4 lines · Herbert Xu
Quoted 2 lines · herbert
Quoted 1 line · John W. Linville

On Thu, Jan 20, 2005 at 04:23:46PM -0500, John W. Linville wrote:

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines

drivers/sound/i810_audio.c line 1072

Quoted 5 lines
drivers/sound/i810_audio.c renamed from drivers/sound/i810_audio.c.orig +5 -0
+	 * the next sg segment, it won't even get a start.  So, instead, when
+	 * we are stopped, we increment the CIV value to the next sg segment
+	 * to be played so that when we call start, things will operate
+	 * properly
+	 */

OK I dug into the archives and found that the reason we need to do it this way is because you can't set the value of CIV directly. So how about s/CIV/LVI/ in the last sentence?

Herbert,

Agreed...I will post a patch to that effect shortly...

John

Signature · 2 lines
John W. Linville
[email protected]
#8 lore raw
In reply to John W. Linville
Quoted 2 lines · John W. Linville

Offset LVI past CIV when starting DAC/ADC in order to prevent stalled start.

Please hold-off on applying this patch...I'm going to repost this patch with a related patch shortly.

John

Signature · 2 lines
John W. Linville
[email protected]
#9 lore raw

PATCH 1/1 i810_audio: offset LVI from CIV to avoid stalled start

In reply to John W. Linville

Offset LVI past CIV when starting DAC/ADC in order to prevent stalled start.

---
This fixes a "no sound" problem with Wolfenstein Enemy Territory and (apparently) other games using the Quake3 engine. It probably affects some other OSS applications as well.

This recreates some code that had been removed from the i810_audio driver around 5/2004. The euqivalent patch has been in the 2.6 stream since about 2.6.11.

 drivers/sound/i810_audio.c |   13 +++++++++++++
 1 files changed, 13 insertions(+)
drivers/sound/i810_audio.c +13 -0
@@ -1062,10 +1062,23 @@ static void __i810_update_lvi(struct i81
 	if (count < fragsize)
 		return;
 
+	/* if we are currently stopped, then our CIV is actually set to our
+	 * *last* sg segment and we are ready to wrap to the next.  However,
+	 * if we set our LVI to the last sg segment, then it won't wrap to
+	 * the next sg segment, it won't even get a start.  So, instead, when
+	 * we are stopped, we set both the LVI value and also we increment
+	 * the LVI value to the next sg segment to be played so that when
+	 * we call start, things will operate properly.  Since the CIV can't
+	 * be written to directly for this purpose, we set the LVI to CIV + 1
+	 * temporarily.  Once the engine has started we set the LVI to its
+	 * final value.
+	 */
 	if (!dmabuf->enable && dmabuf->ready) {
 		if (!(dmabuf->trigger & trigger))
 			return;
 
+		CIV_TO_LVI(port, 1);
+
 		start(state);
 		while (!(inb(port + OFF_CR) & ((1<<4) | (1<<2))))
 			;
Signature · 2 lines
John W. Linville
[email protected]
#10 lore raw

drivers/sound/i810_audio.c static void __i810_update_lvi(struct i81 · line 1071

Quoted 3 lines · John W. Linville
drivers/sound/i810_audio.c +3 -0
+	 * we are stopped, we set both the LVI value and also we increment
+	 * the LVI value to the next sg segment to be played so that when
+	 * we call start, things will operate properly.  Since the CIV can't

Scratch that...bad comment...will repost...

Signature · 2 lines
John W. Linville
[email protected]
#11 lore raw

PATCH 1/1 i810_audio: offset LVI from CIV to avoid stalled start

In reply to John W. Linville

Offset LVI past CIV when starting DAC/ADC in order to prevent stalled start.

---
This fixes a "no sound" problem with Wolfenstein Enemy Territory and (apparently) other games using the Quake3 engine. It probably affects some other OSS applications as well.

This recreates some code that had been removed from the i810_audio driver around 5/2004. The euqivalent patch has been in the 2.6 stream since about 2.6.11.

 drivers/sound/i810_audio.c |   13 +++++++++++++
 1 files changed, 13 insertions(+)
drivers/sound/i810_audio.c +13 -0
@@ -1062,10 +1062,23 @@ static void __i810_update_lvi(struct i81
 	if (count < fragsize)
 		return;
 
+	/* if we are currently stopped, then our CIV is actually set to our
+	 * *last* sg segment and we are ready to wrap to the next.  However,
+	 * if we set our LVI to the last sg segment, then it won't wrap to
+	 * the next sg segment, it won't even get a start.  So, instead, when
+	 * we are stopped, we set both the LVI value and also we increment
+	 * the CIV value to the next sg segment to be played so that when
+	 * we call start, things will operate properly.  Since the CIV can't
+	 * be written to directly for this purpose, we set the LVI to CIV + 1
+	 * temporarily.  Once the engine has started we set the LVI to its
+	 * final value.
+	 */
 	if (!dmabuf->enable && dmabuf->ready) {
 		if (!(dmabuf->trigger & trigger))
 			return;
 
+		CIV_TO_LVI(port, 1);
+
 		start(state);
 		while (!(inb(port + OFF_CR) & ((1<<4) | (1<<2))))
 			;
Signature · 2 lines
John W. Linville
[email protected]