Commit 825ca110 authored by Torsten Schenk's avatar Torsten Schenk Committed by Greg Kroah-Hartman

ALSA: 6fire: make buffers DMA-able (pcm)

commit 5ece263f upstream.

Patch makes pcm buffers DMA-able by allocating each one separately.
Signed-off-by: default avatarTorsten Schenk <torsten.schenk@zoho.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
Cc: Weng Meiling <wengmeiling.weng@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a204372b
...@@ -578,6 +578,33 @@ static void __devinit usb6fire_pcm_init_urb(struct pcm_urb *urb, ...@@ -578,6 +578,33 @@ static void __devinit usb6fire_pcm_init_urb(struct pcm_urb *urb,
urb->instance.number_of_packets = PCM_N_PACKETS_PER_URB; urb->instance.number_of_packets = PCM_N_PACKETS_PER_URB;
} }
static int usb6fire_pcm_buffers_init(struct pcm_runtime *rt)
{
int i;
for (i = 0; i < PCM_N_URBS; i++) {
rt->out_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
* PCM_MAX_PACKET_SIZE, GFP_KERNEL);
if (!rt->out_urbs[i].buffer)
return -ENOMEM;
rt->in_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
* PCM_MAX_PACKET_SIZE, GFP_KERNEL);
if (!rt->in_urbs[i].buffer)
return -ENOMEM;
}
return 0;
}
static void usb6fire_pcm_buffers_destroy(struct pcm_runtime *rt)
{
int i;
for (i = 0; i < PCM_N_URBS; i++) {
kfree(rt->out_urbs[i].buffer);
kfree(rt->in_urbs[i].buffer);
}
}
int __devinit usb6fire_pcm_init(struct sfire_chip *chip) int __devinit usb6fire_pcm_init(struct sfire_chip *chip)
{ {
int i; int i;
...@@ -589,6 +616,13 @@ int __devinit usb6fire_pcm_init(struct sfire_chip *chip) ...@@ -589,6 +616,13 @@ int __devinit usb6fire_pcm_init(struct sfire_chip *chip)
if (!rt) if (!rt)
return -ENOMEM; return -ENOMEM;
ret = usb6fire_pcm_buffers_init(rt);
if (ret) {
usb6fire_pcm_buffers_destroy(rt);
kfree(rt);
return ret;
}
rt->chip = chip; rt->chip = chip;
rt->stream_state = STREAM_DISABLED; rt->stream_state = STREAM_DISABLED;
rt->rate = ARRAY_SIZE(rates); rt->rate = ARRAY_SIZE(rates);
...@@ -610,6 +644,7 @@ int __devinit usb6fire_pcm_init(struct sfire_chip *chip) ...@@ -610,6 +644,7 @@ int __devinit usb6fire_pcm_init(struct sfire_chip *chip)
ret = snd_pcm_new(chip->card, "DMX6FireUSB", 0, 1, 1, &pcm); ret = snd_pcm_new(chip->card, "DMX6FireUSB", 0, 1, 1, &pcm);
if (ret < 0) { if (ret < 0) {
usb6fire_pcm_buffers_destroy(rt);
kfree(rt); kfree(rt);
snd_printk(KERN_ERR PREFIX "cannot create pcm instance.\n"); snd_printk(KERN_ERR PREFIX "cannot create pcm instance.\n");
return ret; return ret;
...@@ -625,6 +660,7 @@ int __devinit usb6fire_pcm_init(struct sfire_chip *chip) ...@@ -625,6 +660,7 @@ int __devinit usb6fire_pcm_init(struct sfire_chip *chip)
snd_dma_continuous_data(GFP_KERNEL), snd_dma_continuous_data(GFP_KERNEL),
MAX_BUFSIZE, MAX_BUFSIZE); MAX_BUFSIZE, MAX_BUFSIZE);
if (ret) { if (ret) {
usb6fire_pcm_buffers_destroy(rt);
kfree(rt); kfree(rt);
snd_printk(KERN_ERR PREFIX snd_printk(KERN_ERR PREFIX
"error preallocating pcm buffers.\n"); "error preallocating pcm buffers.\n");
...@@ -669,6 +705,9 @@ void usb6fire_pcm_abort(struct sfire_chip *chip) ...@@ -669,6 +705,9 @@ void usb6fire_pcm_abort(struct sfire_chip *chip)
void usb6fire_pcm_destroy(struct sfire_chip *chip) void usb6fire_pcm_destroy(struct sfire_chip *chip)
{ {
kfree(chip->pcm); struct pcm_runtime *rt = chip->pcm;
usb6fire_pcm_buffers_destroy(rt);
kfree(rt);
chip->pcm = NULL; chip->pcm = NULL;
} }
...@@ -32,7 +32,7 @@ struct pcm_urb { ...@@ -32,7 +32,7 @@ struct pcm_urb {
struct urb instance; struct urb instance;
struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB]; struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB];
/* END DO NOT SEPARATE */ /* END DO NOT SEPARATE */
u8 buffer[PCM_N_PACKETS_PER_URB * PCM_MAX_PACKET_SIZE]; u8 *buffer;
struct pcm_urb *peer; struct pcm_urb *peer;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment