Re: [Alsa-devel] USB audio devices
Karsten Wiese wrote: We can also vary the exact USB frame time. With UHCI 1.1 USB Hosts there is the SOF Register. ... It really works here already with the us428: The trick is: We first make the USB-Frame longer until we capture 1 Sample Frame more 45 (for 44100). then the USB-Frame is shortened until we capture only 43 Sample Frames for one USB Frame. and so on. Cool idea! However, standard-compliant devices are supposed to base their timing for feedback/feedforward information on the arrival of SOF packets. Introducing jitter into the SOF timer may not be a good idea in every case. And this won't work if there is more than one audio device connected to the same bus, or if the HC is OHCI or EHCI. Regards, Clemens --- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click ___ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel
Re: [Alsa-devel] USB audio devices
Clemens Ladisch wrote: Jaroslav Kysela wrote: I don't know much about USB 2.0, Not too much differences for the driver. Well, I should have read the specification before saying such things. The format of synchronization information has changed, too; it's not 10.14 bits but 12.13 packed into 16.16 (4 bytes). Regards, Clemens --- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click ___ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel
Re: [Alsa-devel] USB audio devices
Jaroslav Kysela wrote: On Tue, 9 Mar 2004, Takashi Iwai wrote: BTW, the USB audio is another headache. the current ALSA PCM model isn't perfectly suitable for the devices like USB audio. Unfortunately I don't see a better model. Conceptually, USB devices have variable-sized periods. The question is whether we actually want to allow this in the API. Probably not. I have thought about forcing the period size to one ALSA frame (with period_elapsed() calls at USB frame boundaries, like it's now). In theory, applications should be able to cope with this. I don't know much about USB 2.0, Not too much differences for the driver. The main difference is that there are now 8000 microframes per second. I have written a patch (see below) and am about to test it. but I guess that 1.x compatibility issues brings another overhead to this extension which makes it also unuseable when 1.x devices are connected to same USB port. There are some nasty contortions when a 1.x device is connected through a 2.0 hub, but otherwise there is no overhead for 1.x devices because logically (and electrically AFAIK) either the 2.0 or the 1.x host controller device is connected to a specific port. Regards, Clemens -- Index: alsa-kernel/usb/usbaudio.c === RCS file: /cvsroot/alsa/alsa-kernel/usb/usbaudio.c,v retrieving revision 1.87 diff -u -r1.87 usbaudio.c --- alsa-kernel/usb/usbaudio.c 8 Mar 2004 09:29:51 - 1.87 +++ alsa-kernel/usb/usbaudio.c 8 Mar 2004 09:48:09 - @@ -104,6 +104,7 @@ */ #define MAX_PACKS 10 +#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ #define MAX_URBS 5 /* max. 20ms long packets */ #define SYNC_URBS 2 /* always two urbs for sync */ #define MIN_PACKS_URB 1 /* minimum 1 packet per urb */ @@ -165,6 +166,8 @@ unsigned int freqm; /* momentary sampling rate in USB format, i.e. fs/1000 in Q10.14 */ unsigned int freqmax;/* maximum sampling rate, used for buffer management */ unsigned int phase; /* phase accumulator */ + unsigned int phase_shift; /* fractional bits of phase */ + unsigned int phase_mask;/* (1 phase_shift) - 1 */ unsigned int maxpacksize; /* max packet size in bytes */ unsigned int maxframesize; /* max packet size in frames */ unsigned int curpacksize; /* current packet size in bytes (for capture) */ @@ -250,7 +253,6 @@ cp[1] = subs-freqn 8; cp[2] = subs-freqn 16; } - urb-interval = 1; return 0; } @@ -301,7 +303,6 @@ spin_unlock_irqrestore(subs-lock, flags); urb-transfer_buffer = ctx-buf; urb-transfer_buffer_length = offs; - urb-interval = 1; #if 0 // for check if (! urb-bandwidth) { int bustime; @@ -390,7 +391,6 @@ urb-iso_frame_desc[i].length = 3; urb-iso_frame_desc[i].offset = offs; } - urb-interval = 1; return 0; } @@ -464,8 +464,8 @@ if (subs-fill_max) counts = subs-maxframesize; /* fixed */ else { - subs-phase = (subs-phase 0x3fff) + subs-freqm; - counts = subs-phase 14; + subs-phase = (subs-phase subs-phase_mask) + subs-freqm; + counts = subs-phase subs-phase_shift; if (counts subs-maxframesize) counts = subs-maxframesize; } @@ -515,7 +515,6 @@ spin_unlock_irqrestore(subs-lock, flags); urb-transfer_buffer_length = offs * stride; ctx-transfer = offs; - urb-interval = 1; return 0; } @@ -822,15 +821,22 @@ { unsigned int maxsize, n, i; int is_playback = subs-direction == SNDRV_PCM_STREAM_PLAYBACK; - unsigned int npacks[MAX_URBS], total_packs; + unsigned int npacks[MAX_URBS], urb_packs, total_packs; /* calculate the frequency in 10.14 format */ subs-freqn = subs-freqm = get_usb_rate(rate); subs-freqmax = subs-freqn + (subs-freqn 2); /* max. allowed frequency */ subs-phase = 0; + if (subs-dev-speed == USB_SPEED_HIGH) { + subs-phase_shift = 11; + subs-phase_mask = 0x07ff; + } else { + subs-phase_shift = 14; + subs-phase_mask = 0x3fff; + } /* calculate the max. size of packet */ - maxsize = ((subs-freqmax + 0x3fff) * (frame_bits 3)) 14; + maxsize = ((subs-freqmax + subs-phase_mask) * (frame_bits 3)) subs-phase_shift; if (subs-maxpacksize maxsize subs-maxpacksize) { //snd_printd(KERN_DEBUG maxsize %d is greater than defined size %d\n, // maxsize, subs-maxpacksize); @@ -842,9 +848,14 @@ else
Re: [Alsa-devel] USB audio devices
On Wed, 10 Mar 2004, Clemens Ladisch wrote: Jaroslav Kysela wrote: On Tue, 9 Mar 2004, Takashi Iwai wrote: BTW, the USB audio is another headache. the current ALSA PCM model isn't perfectly suitable for the devices like USB audio. Unfortunately I don't see a better model. Conceptually, USB devices have variable-sized periods. The question is whether we actually want to allow this in the API. Probably not. What this does mean? I though that the period size is specified with time (1ms) for USB, isn't it? I think that we can describe this constraint with the refine algorithm. Jaroslav - Jaroslav Kysela [EMAIL PROTECTED] Linux Kernel Sound Maintainer ALSA Project, SuSE Labs --- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click ___ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel
Re: [Alsa-devel] USB audio devices
Jaroslav Kysela wrote: On Wed, 10 Mar 2004, Clemens Ladisch wrote: Conceptually, USB devices have variable-sized periods. The question is whether we actually want to allow this in the API. Probably not. What this does mean? I though that the period size is specified with time (1ms) for USB, isn't it? I think that we can describe this constraint with the refine algorithm. One USB frame is 1 ms, but the number of samples per USB frame varies if the sample rate isn't an integer multiple of 1000. E.g., at 44100 Hz, each USB frame has 44 samples, with one out of ten having 45. I don't know what happens when we constrain the period size to 1 ms, which would be exactly 44.1 frames. The period size in frames gets rounded to an integer, doesn't it? Regards, Clemens --- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click ___ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel
Re: [Alsa-devel] USB audio devices
At Wed, 10 Mar 2004 10:08:26 +0100 (CET), Jaroslav wrote: On Wed, 10 Mar 2004, Clemens Ladisch wrote: Jaroslav Kysela wrote: On Tue, 9 Mar 2004, Takashi Iwai wrote: BTW, the USB audio is another headache. the current ALSA PCM model isn't perfectly suitable for the devices like USB audio. Unfortunately I don't see a better model. Conceptually, USB devices have variable-sized periods. The question is whether we actually want to allow this in the API. Probably not. What this does mean? I though that the period size is specified with time (1ms) for USB, isn't it? I think that we can describe this constraint with the refine algorithm. the period time is constant but the sample numbers in this period varies from time to time because of tuncation to integer or due to sync mode. so far, we assume that the samples in a period is constant. we have some cases which we can't handle properly: 1) the period time is constant but the period size is variable e.g. USB-audio 2) the period size is constant but the period time is variable e.g. synchronization with another stream or clock source vari-speed stream 3) both period size and time are variable ??? not known Takashi --- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click ___ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel
Re: [Alsa-devel] USB audio devices
At Wed, 10 Mar 2004 09:26:27 +0100 (MET), Clemens Ladisch wrote: I don't know much about USB 2.0, Not too much differences for the driver. The main difference is that there are now 8000 microframes per second. I have written a patch (see below) and am about to test it. is there any real usb2-audio device available? Takashi --- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click ___ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel
Re: [Alsa-devel] USB audio devices
Takashi Iwai wrote: Clemens Ladisch wrote: I don't know much about USB 2.0, Not too much differences for the driver. The main difference is that there are now 8000 microframes per second. I have written a patch (see below) and am about to test it. is there any real usb2-audio device available? I have (remote) access to a machine with an Audigy 2 NX, which can do USB 2.0. And there is the Ediroal UA-1000, which I would really like to have access to. :-) Regards, Clemens --- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click ___ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel
Re: [Alsa-devel] USB audio devices
We can also vary the exact USB frame time. With UHCI 1.1 USB Hosts there is the SOF Register. It is setable from 0 to 255, the default being 127. Using this SOF-Register, we can set the actual USB Frame Rate from ((12000 - 127) / 12000)ms to ((12000 + 128) / 12000)ms. That is about -/+ 1%: More than enough to adjust the USB-Frame rate to let us get 44(44100) or 48 (48000) Sample Frames everyy USB Frame. It really works here already with the us428: The trick is: We first make the USB-Frame longer until we capture 1 Sample Frame more 45 (for 44100). then the USB-Frame is shortened until we capture only 43 Sample Frames for one USB Frame. and so on. If we use a period size of multiples of 44 (for 44100) then : - Latency is almost at its best (only 1/44 less than optimal. - User Prog Scheduling Jitter is minimized. - Alsas keeps constant Period size. cheers, Karsten --- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click ___ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel
Re: [Alsa-devel] USB audio devices
Karsten Wiese wrote: We can also vary the exact USB frame time. With UHCI 1.1 USB Hosts there is the SOF Register. It is setable from 0 to 255, the default being 127. Using this SOF-Register, we can set the actual USB Frame Rate from ((12000 - 127) / 12000)ms to ((12000 + 128) / 12000)ms. That is about -/+ 1%: More than enough to adjust the USB-Frame rate to let us get 44(44100) or 48 (48000) Sample Frames everyy USB Frame. It really works here already with the us428: The trick is: We first make the USB-Frame longer until we capture 1 Sample Frame more 45 (for 44100). then the USB-Frame is shortened until we capture only 43 Sample Frames for one USB Frame. and so on. If we use a period size of multiples of 44 (for 44100) then : - Latency is almost at its best (only 1/44 less than optimal. - User Prog Scheduling Jitter is minimized. - Alsas keeps constant Period size. Hallaluhjah Please please please make this standard for the usb audio driver. -- Patrick Shirkey - Boost Hardware Ltd. Http://www.boosthardware.com Http://www.djcj.org/LAU/guide/ - The Linux Audio Users guide Http://www.djcj.org/gigs/ - Gigs guide Korea Apparently upon the beginning of the barrage, the donkey broke discipline and panicked, toppling the cart. At that point, the rockets disconnected from the timer, leaving them strewn around the street. Tethered to the now toppled cart, the donkey was unable to escape before the arrival of U.S. troops. United Press International Rockets on donkeys hit major Baghdad sites By P. MITCHELL PROTHERO Published 11/21/2003 11:13 AM --- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click ___ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel