aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/6fire
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2013-08-23 08:12:22 -0400
committerTakashi Iwai <tiwai@suse.de>2013-08-23 08:12:22 -0400
commit68538bf2bce557c3b5fe8c59b034d45352500db1 (patch)
treea84b68990cadcbfc277acc7b7f2b75716750e203 /sound/usb/6fire
parenta8cc20999799a94929a56393ff39b32245e33d64 (diff)
parent43bcb402f84fe459102120b4e2d28d7117f16cd0 (diff)
Merge tag 'asoc-v3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Updates for v3.12 - DAPM is now mandatory for CODEC drivers in order to avoid the repeated regressions in the special cases for non-DAPM CODECs and make it easier to integrate with other components on boards. All existing drivers have had some level of DAPM support added. - A lot of cleanups in DAPM plus support for maintaining controls in a specific state while a DAPM widget all contributed by Lars-Peter Clausen. - Core helpers for bitbanged AC'97 reset from Markus Pargmann. - New drivers and support for Analog Devices ADAU1702 and ADAU1401(a), Asahi Kasei Microdevices AK4554, Atmel AT91ASM9x5 and WM8904 based machines, Freescale S/PDIF and SSI AC'97, Renesas R-Car SoCs, Samsung Exynos5420 SoCs, Texas Instruments PCM1681 and PCM1792A and Wolfson Microelectronics WM8997. - Support for building drivers that can support it cross-platform for compile test.
Diffstat (limited to 'sound/usb/6fire')
-rw-r--r--sound/usb/6fire/comm.c38
-rw-r--r--sound/usb/6fire/comm.h2
-rw-r--r--sound/usb/6fire/midi.c16
-rw-r--r--sound/usb/6fire/midi.h6
-rw-r--r--sound/usb/6fire/pcm.c55
-rw-r--r--sound/usb/6fire/pcm.h2
6 files changed, 102 insertions, 17 deletions
diff --git a/sound/usb/6fire/comm.c b/sound/usb/6fire/comm.c
index 9e6e3ffd86bb..23452ee617e1 100644
--- a/sound/usb/6fire/comm.c
+++ b/sound/usb/6fire/comm.c
@@ -110,19 +110,37 @@ static int usb6fire_comm_send_buffer(u8 *buffer, struct usb_device *dev)
110static int usb6fire_comm_write8(struct comm_runtime *rt, u8 request, 110static int usb6fire_comm_write8(struct comm_runtime *rt, u8 request,
111 u8 reg, u8 value) 111 u8 reg, u8 value)
112{ 112{
113 u8 buffer[13]; /* 13: maximum length of message */ 113 u8 *buffer;
114 int ret;
115
116 /* 13: maximum length of message */
117 buffer = kmalloc(13, GFP_KERNEL);
118 if (!buffer)
119 return -ENOMEM;
114 120
115 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, value, 0x00); 121 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, value, 0x00);
116 return usb6fire_comm_send_buffer(buffer, rt->chip->dev); 122 ret = usb6fire_comm_send_buffer(buffer, rt->chip->dev);
123
124 kfree(buffer);
125 return ret;
117} 126}
118 127
119static int usb6fire_comm_write16(struct comm_runtime *rt, u8 request, 128static int usb6fire_comm_write16(struct comm_runtime *rt, u8 request,
120 u8 reg, u8 vl, u8 vh) 129 u8 reg, u8 vl, u8 vh)
121{ 130{
122 u8 buffer[13]; /* 13: maximum length of message */ 131 u8 *buffer;
132 int ret;
133
134 /* 13: maximum length of message */
135 buffer = kmalloc(13, GFP_KERNEL);
136 if (!buffer)
137 return -ENOMEM;
123 138
124 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, vl, vh); 139 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, vl, vh);
125 return usb6fire_comm_send_buffer(buffer, rt->chip->dev); 140 ret = usb6fire_comm_send_buffer(buffer, rt->chip->dev);
141
142 kfree(buffer);
143 return ret;
126} 144}
127 145
128int usb6fire_comm_init(struct sfire_chip *chip) 146int usb6fire_comm_init(struct sfire_chip *chip)
@@ -135,6 +153,12 @@ int usb6fire_comm_init(struct sfire_chip *chip)
135 if (!rt) 153 if (!rt)
136 return -ENOMEM; 154 return -ENOMEM;
137 155
156 rt->receiver_buffer = kzalloc(COMM_RECEIVER_BUFSIZE, GFP_KERNEL);
157 if (!rt->receiver_buffer) {
158 kfree(rt);
159 return -ENOMEM;
160 }
161
138 urb = &rt->receiver; 162 urb = &rt->receiver;
139 rt->serial = 1; 163 rt->serial = 1;
140 rt->chip = chip; 164 rt->chip = chip;
@@ -153,6 +177,7 @@ int usb6fire_comm_init(struct sfire_chip *chip)
153 urb->interval = 1; 177 urb->interval = 1;
154 ret = usb_submit_urb(urb, GFP_KERNEL); 178 ret = usb_submit_urb(urb, GFP_KERNEL);
155 if (ret < 0) { 179 if (ret < 0) {
180 kfree(rt->receiver_buffer);
156 kfree(rt); 181 kfree(rt);
157 snd_printk(KERN_ERR PREFIX "cannot create comm data receiver."); 182 snd_printk(KERN_ERR PREFIX "cannot create comm data receiver.");
158 return ret; 183 return ret;
@@ -171,6 +196,9 @@ void usb6fire_comm_abort(struct sfire_chip *chip)
171 196
172void usb6fire_comm_destroy(struct sfire_chip *chip) 197void usb6fire_comm_destroy(struct sfire_chip *chip)
173{ 198{
174 kfree(chip->comm); 199 struct comm_runtime *rt = chip->comm;
200
201 kfree(rt->receiver_buffer);
202 kfree(rt);
175 chip->comm = NULL; 203 chip->comm = NULL;
176} 204}
diff --git a/sound/usb/6fire/comm.h b/sound/usb/6fire/comm.h
index 6a0840b0dcff..780d5ed8e5d8 100644
--- a/sound/usb/6fire/comm.h
+++ b/sound/usb/6fire/comm.h
@@ -24,7 +24,7 @@ struct comm_runtime {
24 struct sfire_chip *chip; 24 struct sfire_chip *chip;
25 25
26 struct urb receiver; 26 struct urb receiver;
27 u8 receiver_buffer[COMM_RECEIVER_BUFSIZE]; 27 u8 *receiver_buffer;
28 28
29 u8 serial; /* urb serial */ 29 u8 serial; /* urb serial */
30 30
diff --git a/sound/usb/6fire/midi.c b/sound/usb/6fire/midi.c
index 26722423330d..f3dd7266c391 100644
--- a/sound/usb/6fire/midi.c
+++ b/sound/usb/6fire/midi.c
@@ -19,6 +19,10 @@
19#include "chip.h" 19#include "chip.h"
20#include "comm.h" 20#include "comm.h"
21 21
22enum {
23 MIDI_BUFSIZE = 64
24};
25
22static void usb6fire_midi_out_handler(struct urb *urb) 26static void usb6fire_midi_out_handler(struct urb *urb)
23{ 27{
24 struct midi_runtime *rt = urb->context; 28 struct midi_runtime *rt = urb->context;
@@ -156,6 +160,12 @@ int usb6fire_midi_init(struct sfire_chip *chip)
156 if (!rt) 160 if (!rt)
157 return -ENOMEM; 161 return -ENOMEM;
158 162
163 rt->out_buffer = kzalloc(MIDI_BUFSIZE, GFP_KERNEL);
164 if (!rt->out_buffer) {
165 kfree(rt);
166 return -ENOMEM;
167 }
168
159 rt->chip = chip; 169 rt->chip = chip;
160 rt->in_received = usb6fire_midi_in_received; 170 rt->in_received = usb6fire_midi_in_received;
161 rt->out_buffer[0] = 0x80; /* 'send midi' command */ 171 rt->out_buffer[0] = 0x80; /* 'send midi' command */
@@ -169,6 +179,7 @@ int usb6fire_midi_init(struct sfire_chip *chip)
169 179
170 ret = snd_rawmidi_new(chip->card, "6FireUSB", 0, 1, 1, &rt->instance); 180 ret = snd_rawmidi_new(chip->card, "6FireUSB", 0, 1, 1, &rt->instance);
171 if (ret < 0) { 181 if (ret < 0) {
182 kfree(rt->out_buffer);
172 kfree(rt); 183 kfree(rt);
173 snd_printk(KERN_ERR PREFIX "unable to create midi.\n"); 184 snd_printk(KERN_ERR PREFIX "unable to create midi.\n");
174 return ret; 185 return ret;
@@ -197,6 +208,9 @@ void usb6fire_midi_abort(struct sfire_chip *chip)
197 208
198void usb6fire_midi_destroy(struct sfire_chip *chip) 209void usb6fire_midi_destroy(struct sfire_chip *chip)
199{ 210{
200 kfree(chip->midi); 211 struct midi_runtime *rt = chip->midi;
212
213 kfree(rt->out_buffer);
214 kfree(rt);
201 chip->midi = NULL; 215 chip->midi = NULL;
202} 216}
diff --git a/sound/usb/6fire/midi.h b/sound/usb/6fire/midi.h
index c321006e5430..84851b9f5559 100644
--- a/sound/usb/6fire/midi.h
+++ b/sound/usb/6fire/midi.h
@@ -16,10 +16,6 @@
16 16
17#include "common.h" 17#include "common.h"
18 18
19enum {
20 MIDI_BUFSIZE = 64
21};
22
23struct midi_runtime { 19struct midi_runtime {
24 struct sfire_chip *chip; 20 struct sfire_chip *chip;
25 struct snd_rawmidi *instance; 21 struct snd_rawmidi *instance;
@@ -32,7 +28,7 @@ struct midi_runtime {
32 struct snd_rawmidi_substream *out; 28 struct snd_rawmidi_substream *out;
33 struct urb out_urb; 29 struct urb out_urb;
34 u8 out_serial; /* serial number of out packet */ 30 u8 out_serial; /* serial number of out packet */
35 u8 out_buffer[MIDI_BUFSIZE]; 31 u8 *out_buffer;
36 int buffer_offset; 32 int buffer_offset;
37 33
38 void (*in_received)(struct midi_runtime *rt, u8 *data, int length); 34 void (*in_received)(struct midi_runtime *rt, u8 *data, int length);
diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
index c5b9cac37dc4..b5eb97fdc842 100644
--- a/sound/usb/6fire/pcm.c
+++ b/sound/usb/6fire/pcm.c
@@ -543,7 +543,7 @@ static snd_pcm_uframes_t usb6fire_pcm_pointer(
543 snd_pcm_uframes_t ret; 543 snd_pcm_uframes_t ret;
544 544
545 if (rt->panic || !sub) 545 if (rt->panic || !sub)
546 return SNDRV_PCM_STATE_XRUN; 546 return SNDRV_PCM_POS_XRUN;
547 547
548 spin_lock_irqsave(&sub->lock, flags); 548 spin_lock_irqsave(&sub->lock, flags);
549 ret = sub->dma_off; 549 ret = sub->dma_off;
@@ -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
585static 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
602static 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
585int usb6fire_pcm_init(struct sfire_chip *chip) 612int 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");
@@ -639,17 +675,25 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
639void usb6fire_pcm_abort(struct sfire_chip *chip) 675void usb6fire_pcm_abort(struct sfire_chip *chip)
640{ 676{
641 struct pcm_runtime *rt = chip->pcm; 677 struct pcm_runtime *rt = chip->pcm;
678 unsigned long flags;
642 int i; 679 int i;
643 680
644 if (rt) { 681 if (rt) {
645 rt->panic = true; 682 rt->panic = true;
646 683
647 if (rt->playback.instance) 684 if (rt->playback.instance) {
685 snd_pcm_stream_lock_irqsave(rt->playback.instance, flags);
648 snd_pcm_stop(rt->playback.instance, 686 snd_pcm_stop(rt->playback.instance,
649 SNDRV_PCM_STATE_XRUN); 687 SNDRV_PCM_STATE_XRUN);
650 if (rt->capture.instance) 688 snd_pcm_stream_unlock_irqrestore(rt->playback.instance, flags);
689 }
690
691 if (rt->capture.instance) {
692 snd_pcm_stream_lock_irqsave(rt->capture.instance, flags);
651 snd_pcm_stop(rt->capture.instance, 693 snd_pcm_stop(rt->capture.instance,
652 SNDRV_PCM_STATE_XRUN); 694 SNDRV_PCM_STATE_XRUN);
695 snd_pcm_stream_unlock_irqrestore(rt->capture.instance, flags);
696 }
653 697
654 for (i = 0; i < PCM_N_URBS; i++) { 698 for (i = 0; i < PCM_N_URBS; i++) {
655 usb_poison_urb(&rt->in_urbs[i].instance); 699 usb_poison_urb(&rt->in_urbs[i].instance);
@@ -661,6 +705,9 @@ void usb6fire_pcm_abort(struct sfire_chip *chip)
661 705
662void usb6fire_pcm_destroy(struct sfire_chip *chip) 706void usb6fire_pcm_destroy(struct sfire_chip *chip)
663{ 707{
664 kfree(chip->pcm); 708 struct pcm_runtime *rt = chip->pcm;
709
710 usb6fire_pcm_buffers_destroy(rt);
711 kfree(rt);
665 chip->pcm = NULL; 712 chip->pcm = NULL;
666} 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};