All of lore.kernel.org
 help / color / mirror / Atom feed
* Line6 TonePort UX1 driver
@ 2006-05-08 17:16 Stefano D Angelo
  2006-05-10 13:29 ` Takashi Iwai
  0 siblings, 1 reply; 9+ messages in thread
From: Stefano D Angelo @ 2006-05-08 17:16 UTC (permalink / raw)
  To: alsa-devel

Hello everyone,
I'm an italian university student and I'm developing an ALSA driver for Line6
TonePort UX1 USB sound card.
This is my first driver-writing experience, so maybe this is a dumb question
for you.
This soundcard supports 44.1/48 kHz 16/24-bits modes and full-duplex, but only
in one mode due to USB altesttings.
To be more precise if you are playing some audio stream at 44.1 kHz, 16-bits,
you can only capture data at 44.1 kHz and 16-bits, for example.
The Windows' driver uses some kind of implicit conversion for
playback/capture, so that it uses only 48 kHz, 24-bit mode (unless you use a
program to switch).
Do you think I should use such a compromise too or go on another way?

Stefano D'Angelo

-----------------
Registra il tuo nome di dominio su: http://www.oneonline.it/domini
One On Line ti offre domino + spazio web illimitato + 5 email + 5000 uscite banner + PHP + Link a soli Euro 15 iva compresa



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Line6 TonePort UX1 driver
@ 2006-05-16  8:57 Stefano D Angelo
  0 siblings, 0 replies; 9+ messages in thread
From: Stefano D Angelo @ 2006-05-16  8:57 UTC (permalink / raw)
  To: alsa-devel

Hey,
are you still receiving my e-mails?

Stefano

-----------------
Registra il tuo nome di dominio su: http://www.oneonline.it/domini
One On Line ti offre domino + spazio web illimitato + 5 email + 5000 uscite banner + PHP + Link a soli Euro 15 iva compresa



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Line6 Toneport UX1 driver
@ 2006-06-09  9:30 Stefano D'Angelo
  2006-06-09 13:00 ` Clemens Ladisch
  0 siblings, 1 reply; 9+ messages in thread
From: Stefano D'Angelo @ 2006-06-09  9:30 UTC (permalink / raw)
  To: alsa-devel


[-- Attachment #1.1: Type: text/plain, Size: 1464 bytes --]

I just can't get it working... here's the code I've written:

static void snd_line6_tp_ux1_complete_playback_transfer (struct urb* urb,
                                                         struct pt_regs*
regs)
{
    snd_pcm_substream_t *substream = (snd_pcm_substream_t *)(urb->context);
    struct snd_line6_tp_ux1 *chip = snd_pcm_substream_chip (substream);
    snd_pcm_runtime_t *runtime = substream->runtime;

    urb->dev = chip->dev;
    urb->transfer_dma = runtime->dma_addr;
    urb->transfer_buffer = usb_buffer_alloc (urb->dev,
LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2, GFP_KERNEL, &urb->transfer_dma);
    memcpy (urb->transfer_buffer, runtime->dma_area + chip->playback_pos *
2, LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2);
    urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;

    usb_submit_urb (urb, GFP_ATOMIC);

    chip->playback_pos += LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2 / 4;
    snd_pcm_period_elapsed (substream);
}

don't care about freeing, etc. The problem is that it gives me a kind of
beep sound for anything I play. No underruns, etc., just that sound!
URBs' data seems to be correct and also the transfer seems to happen with no
particular problem. (no error checking right now however).
Another thing is this: I've seen that you decrement the hardware pointer
when it reaches the end of a period, but when I try to do this, it gives me
back garbage values, how is this possible?
What do you think I should do?

[-- Attachment #1.2: Type: text/html, Size: 2050 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Line6 Toneport UX1 driver
@ 2006-06-12  8:54 Stefano D'Angelo
  0 siblings, 0 replies; 9+ messages in thread
From: Stefano D'Angelo @ 2006-06-12  8:54 UTC (permalink / raw)
  To: alsa-devel


[-- Attachment #1.1: Type: text/plain, Size: 3671 bytes --]

Hi,

> Stefano D'Angelo wrote:
> >    urb->transfer_dma = runtime->dma_addr;
>
> This will always play the data at the beginning of the buffer.


fixed

>    urb->transfer_buffer = usb_buffer_alloc (urb->dev,
> > LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2, GFP_KERNEL,
> &urb->transfer_dma);
>
> This buffer should be allocated when the URB is allocated.


fixed

>    memcpy (urb->transfer_buffer, runtime->dma_area + chip->playback_pos *
> > 2, LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2);
>
> I hope the buffer size is a multiple of PACKET_SIZE_OUT * 2.
>

yes, it is

>    urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
>
> Why the NO_TRANSFER_DMA_MAP?  You shouldn't need to do such
> optimizations in the first version of the driver.


ok, put it out

 >    snd_pcm_period_elapsed (substream);
>
> What is the period size?


period size is 96 = LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2 (double
buffering) / 2 (16 bit data), so everytime an urb is sent a period elapses.

Here is how I'm doing right now but I still got the same beep for everything
I play (when I used the copy () callback it kind of worked, is perphaps
possible that this USB soundcard doesn't support dma transfers?):


static void snd_line6_tp_ux1_complete_playback_transfer (struct urb* urb,
                                                         struct pt_regs*
regs)
{
    snd_pcm_substream_t *substream = (snd_pcm_substream_t *)(urb->context);
    struct snd_line6_tp_ux1 *chip = snd_pcm_substream_chip (substream);
    snd_pcm_runtime_t *runtime = substream->runtime;

    chip->playback_pos += LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2 / 2;
    if (chip->playback_pos == runtime->buffer_size) {
        chip->playback_pos -= runtime->buffer_size;

    }

    memcpy (urb->transfer_buffer, runtime->dma_area + chip->playback_pos *
2, LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2);

    snd_pcm_period_elapsed (substream);

    usb_submit_urb (urb, GFP_ATOMIC);
}

static int snd_line6_tp_ux1_pcm_trigger (snd_pcm_substream_t *substream,
                                         int cmd)

{
    struct snd_line6_tp_ux1 *chip = snd_pcm_substream_chip (substream);
    snd_pcm_runtime_t *runtime = substream->runtime;
    static struct urb* urb;

    switch (cmd) {
    case SNDRV_PCM_TRIGGER_START:
        urb = usb_alloc_urb (2, GFP_ATOMIC);
        urb->dev = chip->dev;
        urb->pipe = usb_sndisocpipe (urb->dev, 1);
        urb->complete = snd_line6_tp_ux1_complete_playback_transfer;
        urb->context = substream;

        urb->transfer_dma = runtime->dma_addr;
        urb->transfer_buffer = usb_buffer_alloc (urb->dev,
                 LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2, GFP_ATOMIC,
                 &urb->transfer_dma);
        memcpy (urb->transfer_buffer, runtime->dma_area,
                            LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2);

        urb->transfer_flags = URB_ISO_ASAP; // | URB_NO_TRANSFER_DMA_MAP;
        urb->interval = 1;
        urb->number_of_packets = 2;
        urb->iso_frame_desc[0].offset = 0;
        urb->iso_frame_desc[0].length = urb->iso_frame_desc[1].offset =
        urb->iso_frame_desc[1].length =
                                 LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT;
        chip->playback_pos = 0;
        usb_submit_urb (urb, GFP_KERNEL);
            break;
    case SNDRV_PCM_TRIGGER_STOP:
        usb_buffer_free (chip->dev,

                         LINE6_TP_UX1_48000_16_PACKET_SIZE_OUT * 2,
                         urb->transfer_buffer, urb->transfer_dma);
        usb_free_urb (urb);
            break;
    default:
            return -EINVAL;
        break;
    }

    return 0;
}

Thanks, Stefano

[-- Attachment #1.2: Type: text/html, Size: 7660 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

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

end of thread, other threads:[~2006-06-12  8:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-08 17:16 Line6 TonePort UX1 driver Stefano D Angelo
2006-05-10 13:29 ` Takashi Iwai
     [not found]   ` <20060510165635.M757@oneonline.it>
2006-05-10 15:34     ` Takashi Iwai
     [not found]       ` <20060512004915.M47766@oneonline.it>
2006-05-12  8:15         ` Stefano D Angelo
  -- strict thread matches above, loose matches on Subject: below --
2006-05-16  8:57 Stefano D Angelo
2006-06-09  9:30 Line6 Toneport " Stefano D'Angelo
2006-06-09 13:00 ` Clemens Ladisch
     [not found]   ` <160c13350606100338y63b73447t7e783f2709683e63@mail.gmail.com>
2006-06-10 11:28     ` Stefano D'Angelo
2006-06-12  8:54 Stefano D'Angelo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.