Skip to contentSkip to conversation

Testers needed: memio-mmap patch (rme32,rme96,nm256)

DISCUSSION Takashi Iwai 2 participants 7 messages Jun 18, 2004 – Jul 13, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

the attached patch will fix/simplify the mmap of the devices with the mmio buffers, such as rme32, rme96 and nm256.
If you have one of such devices, please test and report whether it works with mmap mode (e.g. aplay -M option).

The patch is to CVS version, but likely can be applied to 1.0.5, too.

thanks,

Takashi

#1 lore raw
Quoted 6 lines · Takashi Iwai

Hi,

the attached patch will fix/simplify the mmap of the devices with the mmio buffers, such as rme32, rme96 and nm256.
If you have one of such devices, please test and report whether it works with mmap mode (e.g. aplay -M option).

aplay -M and arecord -M is running fine on rme32 :)

Quoted 1 line

The patch is to CVS version, but likely can be applied to 1.0.5, too.

And if you are using kernel 2.4.x, you have to tune io_remap_page_range() in the pcm_native.c patch:

    io_remap_page_range(area->vm_start, runtime->dma_addr + offset,
    			size, area->vm_page_prot)

Ok, let's try fullduplex now...

bye,
martin

Signature · 9 lines
                                     Living on earth may be expensive,
                   but it includes an annual free trip around the sun. 


-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
#2 lore raw

At Sun, 20 Jun 2004 12:11:35 +0200,

Quoted 2 lines · Martin Langer

Ok, let's try fullduplex now...

JFYI: it's now on CVS tree.
fullduplex module option is disabled as default, though.

Takashi

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com

#3 lore raw
Quoted 7 lines · Takashi Iwai

At Sun, 20 Jun 2004 12:11:35 +0200,

Quoted 2 lines · Martin Langer

Ok, let's try fullduplex now...

JFYI: it's now on CVS tree.
fullduplex module option is disabled as default, though.

For enabling fullduplex you will need the following patch, too.

FYI: The situation is that I get only silence in fullduplex_mode after a short time. But nevertheless in the beginning it is correct.

martin

alsa-rme32b/alsa-kernel/pci/rme32.c renamed from pci/rme32.c +5 -0
@@ -1990,6 +2002,11 @@
 	rme32->card = card;
 	rme32->pci = pci;
 	snd_card_set_dev(card, &pci->dev);
+
+        if (fullduplex[dev]) {
+                rme32->fullduplex_mode = 1;
+        }
+
 	if ((err = snd_rme32_create(rme32)) < 0) {
 		snd_card_free(card);
 		return err;

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com

#4 lore raw

At Thu, 1 Jul 2004 22:13:26 +0200,

Quoted 11 lines · Martin Langer
Quoted 7 lines · Takashi Iwai

At Sun, 20 Jun 2004 12:11:35 +0200,

Quoted 2 lines · Martin Langer

Ok, let's try fullduplex now...

JFYI: it's now on CVS tree.
fullduplex module option is disabled as default, though.

For enabling fullduplex you will need the following patch, too.

Oh yes, thanks ;)

Quoted 2 lines

FYI: The situation is that I get only silence in fullduplex_mode after a short time. But nevertheless in the beginning it is correct.

How about the attached patch?

Takashi

Index: alsa-kernel/include/pcm-indirect.h
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/include/pcm-indirect.h,v retrieving revision 1.1
retrieving revision 1.2

include/pcm-indirect.h +11 -11
diff -u -r1.1 -r1.2
@@ -34,7 +34,7 @@
 	unsigned int sw_data;	/* Offset to next dst (or src) in sw ring buffer */
 	unsigned int sw_io;	/* Current software pointer in bytes */
 	int sw_ready;		/* Bytes ready to be transferred to/from hw */
-	size_t appl_ptr;	/* Last seen appl_ptr */
+	snd_pcm_uframes_t appl_ptr;	/* Last seen appl_ptr */
 } snd_pcm_indirect_t;
 
 typedef void (*snd_pcm_indirect_copy_t)(snd_pcm_substream_t *substream,
@@ -51,19 +51,19 @@
 	snd_pcm_runtime_t *runtime = substream->runtime;
 	snd_pcm_uframes_t appl_ptr = runtime->control->appl_ptr;
 	snd_pcm_sframes_t diff = appl_ptr - rec->appl_ptr;
-	snd_pcm_uframes_t qsize;
+	int qsize;
 
 	if (diff) {
 		if (diff < -(snd_pcm_sframes_t) (runtime->boundary / 2))
 			diff += runtime->boundary;
-		rec->sw_ready += frames_to_bytes(runtime, diff);
+		rec->sw_ready += (int)frames_to_bytes(runtime, diff);
 		rec->appl_ptr = appl_ptr;
 	}
 	qsize = rec->hw_queue_size ? rec->hw_queue_size : rec->hw_buffer_size;
 	while (rec->hw_ready < qsize && rec->sw_ready > 0) {
-		size_t hw_to_end = rec->hw_buffer_size - rec->hw_data;
-		size_t sw_to_end = rec->sw_buffer_size - rec->sw_data;
-		size_t bytes = rec->hw_buffer_size - rec->hw_ready;
+		unsigned int hw_to_end = rec->hw_buffer_size - rec->hw_data;
+		unsigned int sw_to_end = rec->sw_buffer_size - rec->sw_data;
+		unsigned int bytes = qsize - rec->hw_ready;
 		if (rec->sw_ready < (int)bytes)
 			bytes = rec->sw_ready;
 		if (hw_to_end < bytes)
@@ -74,7 +74,7 @@
 			break;
 		copy(substream, rec, bytes);
 		rec->hw_data += bytes;
-		if ((int)rec->hw_data == rec->hw_buffer_size)
+		if (rec->hw_data == rec->hw_buffer_size)
 			rec->hw_data = 0;
 		rec->sw_data += bytes;
 		if (rec->sw_data == rec->sw_buffer_size)
@@ -90,9 +90,9 @@
  */
 static inline snd_pcm_uframes_t
 snd_pcm_indirect_playback_pointer(snd_pcm_substream_t *substream,
-				  snd_pcm_indirect_t *rec, size_t ptr)
+				  snd_pcm_indirect_t *rec, unsigned int ptr)
 {
-	ssize_t bytes = ptr - rec->hw_io;
+	int bytes = ptr - rec->hw_io;
 	if (bytes < 0)
 		bytes += rec->hw_buffer_size;
 	rec->hw_io = ptr;
@@ -155,9 +155,9 @@
  */
 static inline snd_pcm_uframes_t
 snd_pcm_indirect_capture_pointer(snd_pcm_substream_t *substream,
-				 snd_pcm_indirect_t *rec, size_t ptr)
+				 snd_pcm_indirect_t *rec, unsigned int ptr)
 {
-	ssize_t bytes = ptr - rec->hw_io;
+	int bytes = ptr - rec->hw_io;
 	if (bytes < 0)
 		bytes += rec->hw_buffer_size;
 	rec->hw_io = ptr;

Index: alsa-kernel/pci/rme32.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/rme32.c,v retrieving revision 1.40

pci/rme32.c +6 -8
diff -u -r1.40 rme32.c
@@ -1210,20 +1210,16 @@
 snd_rme32_playback_fd_pointer(snd_pcm_substream_t * substream)
 {
 	rme32_t *rme32 = snd_pcm_substream_chip(substream);
-	size_t ptr;
-
-	ptr = readl(rme32->iobase + RME32_IO_GET_POS) & RME32_RCR_AUDIO_ADDR_MASK;
-	return snd_pcm_indirect_playback_pointer(substream, &rme32->playback_pcm, ptr);
+	return snd_pcm_indirect_playback_pointer(substream, &rme32->playback_pcm,
+						 snd_rme32_pcm_byteptr(rme32));
 }
 
 static snd_pcm_uframes_t
 snd_rme32_capture_fd_pointer(snd_pcm_substream_t * substream)
 {
 	rme32_t *rme32 = snd_pcm_substream_chip(substream);
-	size_t ptr;
-
-	ptr = readl(rme32->iobase + RME32_IO_GET_POS) & RME32_RCR_AUDIO_ADDR_MASK;
-	return snd_pcm_indirect_capture_pointer(substream, &rme32->capture_pcm, ptr);
+	return snd_pcm_indirect_capture_pointer(substream, &rme32->capture_pcm,
+						snd_rme32_pcm_byteptr(rme32));
 }
 
 /* for halfduplex mode */
@@ -1990,6 +1986,8 @@
 	rme32->card = card;
 	rme32->pci = pci;
 	snd_card_set_dev(card, &pci->dev);
+        if (fullduplex[dev])
+		rme32->fullduplex_mode = 1;
 	if ((err = snd_rme32_create(rme32)) < 0) {
 		snd_card_free(card);
 		return err;
#5 lore raw
Quoted 7 lines · Takashi Iwai

At Thu, 1 Jul 2004 22:13:26 +0200,

Quoted 2 lines · Martin Langer

FYI: The situation is that I get only silence in fullduplex_mode after a short time. But nevertheless in the beginning it is correct.

How about the attached patch?

Fine, there's no longer silence via the indirect way. But I'm still unhappy because the resulting data fragments on playback and capturing aren't clean. I mean there are often capturing fragments in the playback data; and OTOH you can get playback fragments during capturing. And the length of this fragments and the winning data type (playback or capture) seems to be chaotic for my ears.

Nevertheless thanks for the patch.

martin

Signature · 9 lines
                                     Living on earth may be expensive,
                   but it includes an annual free trip around the sun. 


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
#6 lore raw
Quoted 7 lines · Martin Langer
Quoted 6 lines · Takashi Iwai

At Thu, 1 Jul 2004 22:13:26 +0200,

Quoted 2 lines · Martin Langer

FYI: The situation is that I get only silence in fullduplex_mode after a short time. But nevertheless in the beginning it is correct.

Quoted 8 lines
Quoted 1 line

How about the attached patch?

Fine, there's no longer silence via the indirect way. But I'm still unhappy because the resulting data fragments on playback and capturing aren't clean. I mean there are often capturing fragments in the playback data; and OTOH you can get playback fragments during capturing. And the length of this fragments and the winning data type (playback or capture) seems to be chaotic for my ears.

If I understand the fullduplex mode correct: then playback is sometimes the winning process and another time it is capturing. I guess the code works fine if playback wins the race. But if capturing is the winner, the playback buffer isn't prefilled and the capture data will also be used in playback.

I don't see a rule that says: prefill the playback buffer before you run capturing. But perhaps I'm totally blind at the moment.

martin

Signature · 9 lines
                                     Living on earth may be expensive,
                   but it includes an annual free trip around the sun. 


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com