diff options
author | Torsten Schenk <torsten.schenk@zoho.com> | 2013-08-11 05:11:19 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-08-12 05:42:28 -0400 |
commit | 5ece263f1d93fba8d992e67e3ab8a71acf674db9 (patch) | |
tree | 038670213da0df88ac884a8e48bbbd90eb1bb330 /sound/usb | |
parent | db8a38e5063a4daf61252e65d47ab3495c705f4c (diff) |
ALSA: 6fire: make buffers DMA-able (pcm)
Patch makes pcm buffers DMA-able by allocating each one separately.
Signed-off-by: Torsten Schenk <torsten.schenk@zoho.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/6fire/pcm.c | 41 | ||||
-rw-r--r-- | sound/usb/6fire/pcm.h | 2 |
2 files changed, 41 insertions, 2 deletions
diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c index 3d2551cc10f2..b5eb97fdc842 100644 --- a/sound/usb/6fire/pcm.c +++ b/sound/usb/6fire/pcm.c | |||
@@ -582,6 +582,33 @@ static void usb6fire_pcm_init_urb(struct pcm_urb *urb, | |||
582 | urb->instance.number_of_packets = PCM_N_PACKETS_PER_URB; | 582 | urb->instance.number_of_packets = PCM_N_PACKETS_PER_URB; |
583 | } | 583 | } |
584 | 584 | ||
585 | static int usb6fire_pcm_buffers_init(struct pcm_runtime *rt) | ||
586 | { | ||
587 | int i; | ||
588 | |||
589 | for (i = 0; i < PCM_N_URBS; i++) { | ||
590 | rt->out_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB | ||
591 | * PCM_MAX_PACKET_SIZE, GFP_KERNEL); | ||
592 | if (!rt->out_urbs[i].buffer) | ||
593 | return -ENOMEM; | ||
594 | rt->in_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB | ||
595 | * PCM_MAX_PACKET_SIZE, GFP_KERNEL); | ||
596 | if (!rt->in_urbs[i].buffer) | ||
597 | return -ENOMEM; | ||
598 | } | ||
599 | return 0; | ||
600 | } | ||
601 | |||
602 | static void usb6fire_pcm_buffers_destroy(struct pcm_runtime *rt) | ||
603 | { | ||
604 | int i; | ||
605 | |||
606 | for (i = 0; i < PCM_N_URBS; i++) { | ||
607 | kfree(rt->out_urbs[i].buffer); | ||
608 | kfree(rt->in_urbs[i].buffer); | ||
609 | } | ||
610 | } | ||
611 | |||
585 | int usb6fire_pcm_init(struct sfire_chip *chip) | 612 | int usb6fire_pcm_init(struct sfire_chip *chip) |
586 | { | 613 | { |
587 | int i; | 614 | int i; |
@@ -593,6 +620,13 @@ int usb6fire_pcm_init(struct sfire_chip *chip) | |||
593 | if (!rt) | 620 | if (!rt) |
594 | return -ENOMEM; | 621 | return -ENOMEM; |
595 | 622 | ||
623 | ret = usb6fire_pcm_buffers_init(rt); | ||
624 | if (ret) { | ||
625 | usb6fire_pcm_buffers_destroy(rt); | ||
626 | kfree(rt); | ||
627 | return ret; | ||
628 | } | ||
629 | |||
596 | rt->chip = chip; | 630 | rt->chip = chip; |
597 | rt->stream_state = STREAM_DISABLED; | 631 | rt->stream_state = STREAM_DISABLED; |
598 | rt->rate = ARRAY_SIZE(rates); | 632 | rt->rate = ARRAY_SIZE(rates); |
@@ -614,6 +648,7 @@ int usb6fire_pcm_init(struct sfire_chip *chip) | |||
614 | 648 | ||
615 | ret = snd_pcm_new(chip->card, "DMX6FireUSB", 0, 1, 1, &pcm); | 649 | ret = snd_pcm_new(chip->card, "DMX6FireUSB", 0, 1, 1, &pcm); |
616 | if (ret < 0) { | 650 | if (ret < 0) { |
651 | usb6fire_pcm_buffers_destroy(rt); | ||
617 | kfree(rt); | 652 | kfree(rt); |
618 | snd_printk(KERN_ERR PREFIX "cannot create pcm instance.\n"); | 653 | snd_printk(KERN_ERR PREFIX "cannot create pcm instance.\n"); |
619 | return ret; | 654 | return ret; |
@@ -625,6 +660,7 @@ int usb6fire_pcm_init(struct sfire_chip *chip) | |||
625 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_ops); | 660 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_ops); |
626 | 661 | ||
627 | if (ret) { | 662 | if (ret) { |
663 | usb6fire_pcm_buffers_destroy(rt); | ||
628 | kfree(rt); | 664 | kfree(rt); |
629 | snd_printk(KERN_ERR PREFIX | 665 | snd_printk(KERN_ERR PREFIX |
630 | "error preallocating pcm buffers.\n"); | 666 | "error preallocating pcm buffers.\n"); |
@@ -669,6 +705,9 @@ void usb6fire_pcm_abort(struct sfire_chip *chip) | |||
669 | 705 | ||
670 | void usb6fire_pcm_destroy(struct sfire_chip *chip) | 706 | void usb6fire_pcm_destroy(struct sfire_chip *chip) |
671 | { | 707 | { |
672 | kfree(chip->pcm); | 708 | struct pcm_runtime *rt = chip->pcm; |
709 | |||
710 | usb6fire_pcm_buffers_destroy(rt); | ||
711 | kfree(rt); | ||
673 | chip->pcm = NULL; | 712 | chip->pcm = NULL; |
674 | } | 713 | } |
diff --git a/sound/usb/6fire/pcm.h b/sound/usb/6fire/pcm.h index 9b01133ee3fe..f5779d6182c6 100644 --- a/sound/usb/6fire/pcm.h +++ b/sound/usb/6fire/pcm.h | |||
@@ -32,7 +32,7 @@ struct pcm_urb { | |||
32 | struct urb instance; | 32 | struct urb instance; |
33 | struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB]; | 33 | struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB]; |
34 | /* END DO NOT SEPARATE */ | 34 | /* END DO NOT SEPARATE */ |
35 | u8 buffer[PCM_N_PACKETS_PER_URB * PCM_MAX_PACKET_SIZE]; | 35 | u8 *buffer; |
36 | 36 | ||
37 | struct pcm_urb *peer; | 37 | struct pcm_urb *peer; |
38 | }; | 38 | }; |