Commit 4c0a58ef authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: usx2y: Fix spaces

This patch corrects merely the spaces in the usx2y code, including the
superfluous trailing space in the debug prints and a slight reformat
of some comment lines.  Nothing really touches about the code itself.

Link: https://lore.kernel.org/r/20210517131545.27252-3-tiwai@suse.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent bae3ce49
Loading
Loading
Loading
Loading
+22 −16
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ static void pt_info_set(struct usb_device *dev, u8 v)
static void usb_stream_hwdep_vm_open(struct vm_area_struct *area)
{
	struct us122l *us122l = area->vm_private_data;

	atomic_inc(&us122l->mmap_count);
	snd_printdd(KERN_DEBUG "%i\n", atomic_read(&us122l->mmap_count));
}
@@ -138,6 +139,7 @@ static vm_fault_t usb_stream_hwdep_vm_fault(struct vm_fault *vmf)
static void usb_stream_hwdep_vm_close(struct vm_area_struct *area)
{
	struct us122l *us122l = area->vm_private_data;

	atomic_dec(&us122l->mmap_count);
	snd_printdd(KERN_DEBUG "%i\n", atomic_read(&us122l->mmap_count));
}
@@ -148,11 +150,11 @@ static const struct vm_operations_struct usb_stream_hwdep_vm_ops = {
	.close = usb_stream_hwdep_vm_close,
};


static int usb_stream_hwdep_open(struct snd_hwdep *hw, struct file *file)
{
	struct us122l	*us122l = hw->private_data;
	struct usb_interface *iface;

	snd_printdd(KERN_DEBUG "%p %p\n", hw, file);
	if (hw->used >= 2)
		return -EBUSY;
@@ -173,6 +175,7 @@ static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file)
{
	struct us122l	*us122l = hw->private_data;
	struct usb_interface *iface;

	snd_printdd(KERN_DEBUG "%p %p\n", hw, file);

	if (us122l->is_us144) {
@@ -243,6 +246,7 @@ static __poll_t usb_stream_hwdep_poll(struct snd_hwdep *hw,
	mask = EPOLLIN | EPOLLOUT | EPOLLWRNORM | EPOLLERR;
	if (mutex_trylock(&us122l->mutex)) {
		struct usb_stream *s = us122l->sk.s;

		if (s && s->state == usb_stream_ready) {
			if (us122l->first == file)
				polled = &s->periods_polled;
@@ -262,6 +266,7 @@ static __poll_t usb_stream_hwdep_poll(struct snd_hwdep *hw,
static void us122l_stop(struct us122l *us122l)
{
	struct list_head *p;

	list_for_each(p, &us122l->midi_list)
		snd_usbmidi_input_stop(p);

@@ -431,7 +436,6 @@ static int usb_stream_hwdep_new(struct snd_card *card)
	return 0;
}


static bool us122l_create_card(struct snd_card *card)
{
	int err;
@@ -468,6 +472,7 @@ static bool us122l_create_card(struct snd_card *card)
	if (err < 0) {
		/* release the midi resources */
		struct list_head *p;

		list_for_each(p, &us122l->midi_list)
			snd_usbmidi_disconnect(p);

@@ -484,6 +489,7 @@ static void snd_us122l_free(struct snd_card *card)
{
	struct us122l	*us122l = US122L(card);
	int		index = us122l->card_index;

	if (index >= 0  &&  index < SNDRV_CARDS)
		snd_us122l_card_used[index] = 0;
}
@@ -717,8 +723,8 @@ static const struct usb_device_id snd_us122l_usb_id_table[] = {
	},
	{ /* terminator */ }
};

MODULE_DEVICE_TABLE(usb, snd_us122l_usb_id_table);

static struct usb_driver snd_us122l_usb_driver = {
	.name =		"snd-usb-us122l",
	.probe =	snd_us122l_probe,
+25 −27
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ static __poll_t snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, poll
	__poll_t	mask = 0;
	struct usx2ydev	*us428 = hw->private_data;
	struct us428ctls_sharedmem *shm = us428->us428ctls_sharedmem;

	if (us428->chip_status & USX2Y_STAT_CHIP_HUP)
		return EPOLLHUP;

@@ -123,7 +124,6 @@ static int snd_usx2y_hwdep_dsp_status(struct snd_hwdep *hw,
	return 0;
}


static int usx2y_create_usbmidi(struct snd_card *card)
{
	static const struct snd_usb_midi_endpoint_info quirk_data_1 = {
@@ -228,7 +228,6 @@ static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw,
	return err;
}


int usx2y_hwdep_new(struct snd_card *card, struct usb_device *device)
{
	int err;
@@ -247,4 +246,3 @@ int usx2y_hwdep_new(struct snd_card *card, struct usb_device* device)
	sprintf(hw->name, "/dev/bus/usb/%03d/%03d", device->bus->busnum, device->devnum);
	return 0;
}
+31 −12
Original line number Diff line number Diff line
@@ -8,12 +8,12 @@

#include "usb_stream.h"


/*                             setup                                  */

static unsigned usb_stream_next_packet_size(struct usb_stream_kernel *sk)
{
	struct usb_stream *s = sk->s;

	sk->out_phase_peeked = (sk->out_phase & 0xffff) + sk->freqn;
	return (sk->out_phase_peeked >> 16) * s->cfg.frame_size;
}
@@ -25,6 +25,7 @@ static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb)

	for (pack = 0; pack < sk->n_o_ps; pack++) {
		int l = usb_stream_next_packet_size(sk);

		if (s->idle_outsize + lb + l > s->period_size)
			goto check;

@@ -56,6 +57,7 @@ static int init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
	     ++u, transfer += transfer_length) {
		struct urb *urb = urbs[u];
		struct usb_iso_packet_descriptor *desc;

		urb->transfer_buffer = transfer;
		urb->dev = dev;
		urb->pipe = pipe;
@@ -84,9 +86,8 @@ static int init_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
		      struct usb_device *dev, int in_pipe, int out_pipe)
{
	struct usb_stream	*s = sk->s;
	char			*indata = (char *)s + sizeof(*s) +
					sizeof(struct usb_stream_packet) *
					s->inpackets;
	char			*indata =
		(char *)s + sizeof(*s) + sizeof(struct usb_stream_packet) * s->inpackets;
	int			u;

	for (u = 0; u < USB_STREAM_NURBS; ++u) {
@@ -107,7 +108,6 @@ static int init_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
	return 0;
}


/*
 * convert a sampling rate into our full speed format (fs/1000 in Q16.16)
 * this will overflow at approx 524 kHz
@@ -231,12 +231,12 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
	return sk->s;
}


/*                             start                                  */

static bool balance_check(struct usb_stream_kernel *sk, struct urb *urb)
{
	bool r;

	if (unlikely(urb->status)) {
		if (urb->status != -ESHUTDOWN && urb->status != -ENOENT)
			snd_printk(KERN_WARNING "status=%i\n", urb->status);
@@ -267,6 +267,7 @@ static void subs_set_complete(struct urb **urbs, void (*complete)(struct urb *))

	for (u = 0; u < USB_STREAM_NURBS; u++) {
		struct urb *urb = urbs[u];

		urb->complete = complete;
	}
}
@@ -284,6 +285,7 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk,

	for (; s->sync_packet < 0; ++p, ++s->sync_packet) {
		struct urb *ii = sk->completed_inurb;

		id = ii->iso_frame_desc +
			ii->number_of_packets + s->sync_packet;
		l = id->actual_length;
@@ -351,6 +353,7 @@ static int submit_urbs(struct usb_stream_kernel *sk,
		       struct urb *inurb, struct urb *outurb)
{
	int err;

	prepare_inurb(sk->idle_outurb->number_of_packets, sk->idle_inurb);
	err = usb_submit_urb(sk->idle_inurb, GFP_ATOMIC);
	if (err < 0)
@@ -447,6 +450,7 @@ static void stream_idle(struct usb_stream_kernel *sk,

	for (p = 0; p < inurb->number_of_packets; ++p) {
		struct usb_iso_packet_descriptor *id = inurb->iso_frame_desc;

		l = id[p].actual_length;
		if (unlikely(l == 0 || id[p].status)) {
			snd_printk(KERN_WARNING "underrun, status=%u\n",
@@ -503,6 +507,7 @@ static void stream_idle(struct usb_stream_kernel *sk,
static void i_capture_idle(struct urb *urb)
{
	struct usb_stream_kernel *sk = urb->context;

	if (balance_capture(sk, urb))
		stream_idle(sk, urb, sk->i_urb);
}
@@ -510,6 +515,7 @@ static void i_capture_idle(struct urb *urb)
static void i_playback_idle(struct urb *urb)
{
	struct usb_stream_kernel *sk = urb->context;

	if (balance_playback(sk, urb))
		stream_idle(sk, sk->i_urb, urb);
}
@@ -518,10 +524,12 @@ static void stream_start(struct usb_stream_kernel *sk,
			 struct urb *inurb, struct urb *outurb)
{
	struct usb_stream *s = sk->s;

	if (s->state >= usb_stream_sync1) {
		int l, p, max_diff, max_diff_0;
		int urb_size = 0;
		unsigned frames_per_packet, min_frames = 0;

		frames_per_packet = (s->period_size - s->idle_insize);
		frames_per_packet <<= 8;
		frames_per_packet /=
@@ -536,6 +544,7 @@ static void stream_start(struct usb_stream_kernel *sk,
		max_diff = max_diff_0;
		for (p = 0; p < inurb->number_of_packets; ++p) {
			int diff;

			l = inurb->iso_frame_desc[p].actual_length;
			urb_size += l;

@@ -562,6 +571,7 @@ static void stream_start(struct usb_stream_kernel *sk,
			s->next_inpacket_split_at = 0;
		} else {
			unsigned split = s->inpacket_head;

			l = s->idle_insize;
			while (l > s->inpacket[split].length) {
				l -= s->inpacket[split].length;
@@ -609,6 +619,7 @@ static void i_capture_start(struct urb *urb)

	for (p = 0; p < urb->number_of_packets; ++p) {
		int l = id[p].actual_length;

		if (l < s->cfg.frame_size) {
			++empty;
			if (s->state >= usb_stream_sync0) {
@@ -628,6 +639,7 @@ static void i_capture_start(struct urb *urb)
		       urb->iso_frame_desc[0].actual_length);
		for (pack = 1; pack < urb->number_of_packets; ++pack) {
			int l = urb->iso_frame_desc[pack].actual_length;

			printk(KERN_CONT " %i", l);
		}
		printk(KERN_CONT "\n");
@@ -643,6 +655,7 @@ static void i_capture_start(struct urb *urb)
static void i_playback_start(struct urb *urb)
{
	struct usb_stream_kernel *sk = urb->context;

	if (balance_playback(sk, urb))
		stream_start(sk, sk->i_urb, urb);
}
@@ -671,6 +684,7 @@ int usb_stream_start(struct usb_stream_kernel *sk)
	for (u = 0; u < 2; u++) {
		struct urb *inurb = sk->inurb[u];
		struct urb *outurb = sk->outurb[u];

		playback_prep_freqn(sk, outurb);
		inurb->number_of_packets = outurb->number_of_packets;
		inurb->transfer_buffer_length =
@@ -680,6 +694,7 @@ int usb_stream_start(struct usb_stream_kernel *sk)
		if (u == 0) {
			int now;
			struct usb_device *dev = inurb->dev;

			frame = usb_get_current_frame_number(dev);
			do {
				now = usb_get_current_frame_number(dev);
@@ -688,14 +703,16 @@ int usb_stream_start(struct usb_stream_kernel *sk)
		}
		err = usb_submit_urb(inurb, GFP_ATOMIC);
		if (err < 0) {
			snd_printk(KERN_ERR"usb_submit_urb(sk->inurb[%i])"
				   " returned %i\n", u, err);
			snd_printk(KERN_ERR
				   "usb_submit_urb(sk->inurb[%i]) returned %i\n",
				   u, err);
			return err;
		}
		err = usb_submit_urb(outurb, GFP_ATOMIC);
		if (err < 0) {
			snd_printk(KERN_ERR"usb_submit_urb(sk->outurb[%i])"
				   " returned %i\n", u, err);
			snd_printk(KERN_ERR
				   "usb_submit_urb(sk->outurb[%i]) returned %i\n",
				   u, err);
			return err;
		}

@@ -716,8 +733,8 @@ int usb_stream_start(struct usb_stream_kernel *sk)
			snd_printd(KERN_DEBUG "goto dotry;\n");
			goto dotry;
		}
		snd_printk(KERN_WARNING"couldn't start"
			   " all urbs on the same start_frame.\n");
		snd_printk(KERN_WARNING
			   "couldn't start all urbs on the same start_frame.\n");
		return -EFAULT;
	}

@@ -729,6 +746,7 @@ int usb_stream_start(struct usb_stream_kernel *sk)
/* wait, check */
	{
		int wait_ms = 3000;

		while (s->state != usb_stream_ready && wait_ms > 0) {
			snd_printdd(KERN_DEBUG "%i\n", s->state);
			msleep(200);
@@ -745,6 +763,7 @@ int usb_stream_start(struct usb_stream_kernel *sk)
void usb_stream_stop(struct usb_stream_kernel *sk)
{
	int u;

	if (!sk->s)
		return;
	for (u = 0; u < USB_STREAM_NURBS; ++u) {
+39 −39
Original line number Diff line number Diff line
@@ -103,7 +103,6 @@
	"pcm -c 2" doesn't work. "pcm -c 2 -m direct_interleaved" does.
	KDE3: "Enable full duplex operation" deadlocks.

	
2002-08-31 Karsten Wiese
	Version 0.0.3: audio also simplex;
	simplifying: iso urbs only 1 packet, melted structs.
@@ -132,8 +131,6 @@
#include "usbusx2y.h"
#include "usX2Yhwdep.h"



MODULE_AUTHOR("Karsten Wiese <annabellesgarden@yahoo.de>");
MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.8.7.2");
MODULE_LICENSE("GPL");
@@ -149,7 +146,6 @@ MODULE_PARM_DESC(id, "ID string for "NAME_ALLCAPS".");
module_param_array(enable, bool, NULL, 0444);
MODULE_PARM_DESC(enable, "Enable "NAME_ALLCAPS".");


static int snd_usx2y_card_used[SNDRV_CARDS];

static void usx2y_usb_disconnect(struct usb_device *usb_device, void *ptr);
@@ -164,7 +160,9 @@ static void i_usx2y_out04_int(struct urb *urb)
	if (urb->status) {
		int i;
		struct usx2ydev *usx2y = urb->context;
		for (i = 0; i < 10 && usx2y->as04.urb[i] != urb; i++);

		for (i = 0; i < 10 && usx2y->as04.urb[i] != urb; i++)
			;
		snd_printdd("i_usx2y_out04_int() urb %i status=%i\n", i, urb->status);
	}
#endif
@@ -186,12 +184,14 @@ static void i_usx2y_in04_int(struct urb *urb)
	//	printk("%i:0x%02X ", 8, (int)((unsigned char*)usx2y->in04_buf)[8]); Master volume shows 0 here if fader is at max during boot ?!?
	if (us428ctls) {
		int diff = -1;

		if (-2 == us428ctls->ctl_snapshot_last) {
			diff = 0;
			memcpy(usx2y->in04_last, usx2y->in04_buf, sizeof(usx2y->in04_last));
			us428ctls->ctl_snapshot_last = -1;
		} else {
			int i;

			for (i = 0; i < 21; i++) {
				if (usx2y->in04_last[i] != ((char *)usx2y->in04_buf)[i]) {
					if (diff < 0)
@@ -202,6 +202,7 @@ static void i_usx2y_in04_int(struct urb *urb)
		}
		if (0 <= diff) {
			int n = us428ctls->ctl_snapshot_last + 1;

			if (n >= N_US428_CTL_BUFS  ||  n < 0)
				n = 0;
			memcpy(us428ctls->ctl_snapshot + n, usx2y->in04_buf, sizeof(us428ctls->ctl_snapshot[0]));
@@ -211,7 +212,6 @@ static void i_usx2y_in04_int(struct urb *urb)
		}
	}

	
	if (usx2y->us04) {
		if (0 == usx2y->us04->submitted)
			do {
@@ -221,11 +221,13 @@ static void i_usx2y_in04_int(struct urb *urb)
		if (us428ctls && us428ctls->p4out_last >= 0 && us428ctls->p4out_last < N_US428_P4OUT_BUFS) {
			if (us428ctls->p4out_last != us428ctls->p4out_sent) {
				int j, send = us428ctls->p4out_sent + 1;

				if (send >= N_US428_P4OUT_BUFS)
					send = 0;
				for (j = 0; j < URBS_ASYNC_SEQ  &&  !err; ++j)
					if (0 == usx2y->as04.urb[j]->status) {
						struct us428_p4out *p4out = us428ctls->p4out + send;	// FIXME if more than 1 p4out is new, 1 gets lost.

						usb_fill_bulk_urb(usx2y->as04.urb[j], usx2y->dev,
								  usb_sndbulkpipe(usx2y->dev, 0x04), &p4out->val.vol,
								  p4out->type == ELT_LIGHT ? sizeof(struct us428_lights) : 5,
@@ -249,8 +251,7 @@ static void i_usx2y_in04_int(struct urb *urb)
 */
int usx2y_async_seq04_init(struct usx2ydev *usx2y)
{
	int	err = 0,
		i;
	int	err = 0, i;

	usx2y->as04.buffer = kmalloc_array(URBS_ASYNC_SEQ,
					   URB_DATA_LEN_ASYNC_SEQ, GFP_KERNEL);
@@ -265,8 +266,7 @@ int usx2y_async_seq04_init(struct usx2ydev *usx2y)
			usb_fill_bulk_urb(usx2y->as04.urb[i], usx2y->dev,
					  usb_sndbulkpipe(usx2y->dev, 0x04),
					  usx2y->as04.buffer + URB_DATA_LEN_ASYNC_SEQ*i, 0,
						i_usx2y_out04_int, usx2y
				);
					  i_usx2y_out04_int, usx2y);
			err = usb_urb_ep_type_check(usx2y->as04.urb[i]);
			if (err < 0)
				break;
@@ -295,6 +295,7 @@ int usx2y_in04_init(struct usx2ydev *usx2y)
static void usx2y_unlinkseq(struct snd_usx2y_async_seq *s)
{
	int	i;

	for (i = 0; i < URBS_ASYNC_SEQ; ++i) {
		usb_kill_urb(s->urb[i]);
		usb_free_urb(s->urb[i]);
@@ -303,7 +304,6 @@ static void usx2y_unlinkseq(struct snd_usx2y_async_seq *s)
	kfree(s->buffer);
}


static const struct usb_device_id snd_usx2y_usb_id_table[] = {
	{
		.match_flags =	USB_DEVICE_ID_MATCH_DEVICE,
@@ -322,6 +322,7 @@ static const struct usb_device_id snd_usx2y_usb_id_table[] = {
	},
	{ /* terminator */ }
};
MODULE_DEVICE_TABLE(usb, snd_usx2y_usb_id_table);

static int usx2y_create_card(struct usb_device *device,
			     struct usb_interface *intf,
@@ -359,7 +360,6 @@ static int usx2y_create_card(struct usb_device *device,
	return 0;
}


static int usx2y_usb_probe(struct usb_device *device,
			   struct usb_interface *intf,
			   const struct usb_device_id *device_id,
@@ -408,7 +408,6 @@ static void snd_usx2y_disconnect(struct usb_interface *intf)
				 usb_get_intfdata(intf));
}

MODULE_DEVICE_TABLE(usb, snd_usx2y_usb_id_table);
static struct usb_driver snd_usx2y_usb_driver = {
	.name =		"snd-usb-usx2y",
	.probe =	snd_usx2y_probe,
@@ -436,6 +435,7 @@ static void usx2y_usb_disconnect(struct usb_device *device, void* ptr)
		struct snd_card *card = ptr;
		struct usx2ydev *usx2y = usx2y(card);
		struct list_head *p;

		usx2y->chip_status = USX2Y_STAT_CHIP_HUP;
		usx2y_unlinkseq(&usx2y->as04);
		usb_kill_urb(usx2y->in04_urb);
+80 −60
Original line number Diff line number Diff line
@@ -28,21 +28,23 @@
#include "usx2y.h"
#include "usbusx2y.h"

#define USX2Y_NRPACKS 4			/* Default value used for nr of packs per urb.
					  1 to 4 have been tested ok on uhci.
					  To use 3 on ohci, you'd need a patch:
					  look for "0000425-linux-2.6.9-rc4-mm1_ohci-hcd.patch.gz" on
					  "https://bugtrack.alsa-project.org/alsa-bug/bug_view_page.php?bug_id=0000425"
					  .
					  1, 2 and 4 work out of the box on ohci, if I recall correctly.
					  Bigger is safer operation,
					  smaller gives lower latencies.
/* Default value used for nr of packs per urb.
 * 1 to 4 have been tested ok on uhci.
 * To use 3 on ohci, you'd need a patch:
 * look for "0000425-linux-2.6.9-rc4-mm1_ohci-hcd.patch.gz" on
 * "https://bugtrack.alsa-project.org/alsa-bug/bug_view_page.php?bug_id=0000425"
 *
 * 1, 2 and 4 work out of the box on ohci, if I recall correctly.
 * Bigger is safer operation, smaller gives lower latencies.
 */
#define USX2Y_NRPACKS_VARIABLE y	/* If your system works ok with this module's parameter
					   nrpacks set to 1, you might as well comment 
					   this #define out, and thereby produce smaller, faster code.
					   You'd also set USX2Y_NRPACKS to 1 then.
#define USX2Y_NRPACKS 4

/* If your system works ok with this module's parameter
 * nrpacks set to 1, you might as well comment
 * this define out, and thereby produce smaller, faster code.
 * You'd also set USX2Y_NRPACKS to 1 then.
 */
#define USX2Y_NRPACKS_VARIABLE 1

#ifdef USX2Y_NRPACKS_VARIABLE
static int nrpacks = USX2Y_NRPACKS; /* number of packets per urb */
@@ -53,7 +55,6 @@
#define nr_of_packs() USX2Y_NRPACKS
#endif


static int usx2y_urb_capt_retire(struct snd_usx2y_substream *subs)
{
	struct urb	*urb = subs->completed_urb;
@@ -65,8 +66,8 @@ static int usx2y_urb_capt_retire(struct snd_usx2y_substream *subs)
	for (i = 0; i < nr_of_packs(); i++) {
		cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset;
		if (urb->iso_frame_desc[i].status) { /* active? hmm, skip this */
			snd_printk(KERN_ERR "active frame status %i. "
				   "Most probably some hardware problem.\n",
			snd_printk(KERN_ERR
				   "active frame status %i. Most probably some hardware problem.\n",
				   urb->iso_frame_desc[i].status);
			return urb->iso_frame_desc[i].status;
		}
@@ -80,6 +81,7 @@ static int usx2y_urb_capt_retire(struct snd_usx2y_substream *subs)
		if ((hwptr_done + len) > runtime->buffer_size) {
			int cnt = runtime->buffer_size - hwptr_done;
			int blen = cnt * usx2y->stride;

			memcpy(runtime->dma_area + hwptr_done * usx2y->stride, cp, blen);
			memcpy(runtime->dma_area, cp + blen, len * usx2y->stride - blen);
		} else {
@@ -100,6 +102,7 @@ static int usx2y_urb_capt_retire(struct snd_usx2y_substream *subs)
	}
	return 0;
}

/*
 * prepare urb for playback data pipe
 *
@@ -140,6 +143,7 @@ static int usx2y_urb_play_prepare(struct snd_usx2y_substream *subs,
			 * copy the data to the temp buffer.
			 */
			int len;

			len = runtime->buffer_size - subs->hwptr;
			urb->transfer_buffer = subs->tmpbuf;
			memcpy(subs->tmpbuf, runtime->dma_area +
@@ -183,6 +187,7 @@ static void usx2y_urb_play_retire(struct snd_usx2y_substream *subs, struct urb *
static int usx2y_urb_submit(struct snd_usx2y_substream *subs, struct urb *urb, int frame)
{
	int err;

	if (!urb)
		return -ENODEV;
	urb->start_frame = (frame + NRURBS * nr_of_packs());  // let hcd do rollover sanity checks
@@ -243,13 +248,13 @@ static inline int usx2y_usbframe_complete(struct snd_usx2y_substream *capsubs,
	return 0;
}


static void usx2y_clients_stop(struct usx2ydev *usx2y)
{
	int s, u;

	for (s = 0; s < 4; s++) {
		struct snd_usx2y_substream *subs = usx2y->subs[s];

		if (subs) {
			snd_printdd("%i %p state=%i\n", s, subs, atomic_read(&subs->state));
			atomic_set(&subs->state, STATE_STOPPED);
@@ -257,11 +262,13 @@ static void usx2y_clients_stop(struct usx2ydev *usx2y)
	}
	for (s = 0; s < 4; s++) {
		struct snd_usx2y_substream *subs = usx2y->subs[s];

		if (subs) {
			if (atomic_read(&subs->state) >= STATE_PRERUNNING)
				snd_pcm_stop_xrun(subs->pcm_substream);
			for (u = 0; u < NRURBS; u++) {
				struct urb *urb = subs->urb[u];

				if (NULL != urb)
					snd_printdd("%i status=%i start_frame=%i\n",
						    u, urb->status, urb->start_frame);
@@ -302,6 +309,7 @@ static void i_usx2y_urb_complete(struct urb *urb)
	{
		struct snd_usx2y_substream *capsubs = usx2y->subs[SNDRV_PCM_STREAM_CAPTURE],
			*playbacksubs = usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK];

		if (capsubs->completed_urb &&
		    atomic_read(&capsubs->state) >= STATE_PREPARED &&
		    (playbacksubs->completed_urb ||
@@ -320,11 +328,14 @@ static void usx2y_urbs_set_complete(struct usx2ydev * usx2y,
				    void (*complete)(struct urb *))
{
	int s, u;

	for (s = 0; s < 4; s++) {
		struct snd_usx2y_substream *subs = usx2y->subs[s];

		if (NULL != subs)
			for (u = 0; u < NRURBS; u++) {
				struct urb *urb = subs->urb[u];

				if (NULL != urb)
					urb->complete = complete;
			}
@@ -342,6 +353,7 @@ static void i_usx2y_subs_startup(struct urb *urb)
	struct snd_usx2y_substream *subs = urb->context;
	struct usx2ydev *usx2y = subs->usx2y;
	struct snd_usx2y_substream *prepare_subs = usx2y->prepare_subs;

	if (NULL != prepare_subs)
		if (urb->start_frame == prepare_subs->urb[0]->start_frame) {
			usx2y_subs_startup_finish(usx2y);
@@ -362,7 +374,6 @@ static void usx2y_subs_prepare(struct snd_usx2y_substream *subs)
	subs->transfer_done = 0;
}


static void usx2y_urb_release(struct urb **urb, int free_tb)
{
	if (*urb) {
@@ -373,12 +384,14 @@ static void usx2y_urb_release(struct urb **urb, int free_tb)
		*urb = NULL;
	}
}

/*
 * release a substreams urbs
 */
static void usx2y_urbs_release(struct snd_usx2y_substream *subs)
{
	int i;

	snd_printdd("usx2y_urbs_release() %i\n", subs->endpoint);
	for (i = 0; i < NRURBS; i++)
		usx2y_urb_release(subs->urb + i,
@@ -387,6 +400,7 @@ static void usx2y_urbs_release(struct snd_usx2y_substream *subs)
	kfree(subs->tmpbuf);
	subs->tmpbuf = NULL;
}

/*
 * initialize a substream's urbs
 */
@@ -411,6 +425,7 @@ static int usx2y_urbs_allocate(struct snd_usx2y_substream *subs)
	/* allocate and initialize data urbs */
	for (i = 0; i < NRURBS; i++) {
		struct urb **purb = subs->urb + i;

		if (*purb) {
			usb_kill_urb(*purb);
			continue;
@@ -443,6 +458,7 @@ static int usx2y_urbs_allocate(struct snd_usx2y_substream *subs)
static void usx2y_subs_startup(struct snd_usx2y_substream *subs)
{
	struct usx2ydev *usx2y = subs->usx2y;

	usx2y->prepare_subs = subs;
	subs->urb[0]->start_frame = -1;
	wmb();
@@ -459,6 +475,7 @@ static int usx2y_urbs_start(struct snd_usx2y_substream *subs)
	subs->completed_urb = NULL;
	for (i = 0; i < 4; i++) {
		struct snd_usx2y_substream *subs = usx2y->subs[i];

		if (subs != NULL && atomic_read(&subs->state) >= STATE_PREPARED)
			goto start;
	}
@@ -467,8 +484,10 @@ static int usx2y_urbs_start(struct snd_usx2y_substream *subs)
	usx2y_subs_startup(subs);
	for (i = 0; i < NRURBS; i++) {
		struct urb *urb = subs->urb[i];

		if (usb_pipein(urb->pipe)) {
			unsigned long pack;

			if (0 == i)
				atomic_set(&subs->state, STATE_STARTING3);
			urb->dev = usx2y->dev;
@@ -509,8 +528,10 @@ static int usx2y_urbs_start(struct snd_usx2y_substream *subs)
static snd_pcm_uframes_t snd_usx2y_pcm_pointer(struct snd_pcm_substream *substream)
{
	struct snd_usx2y_substream *subs = substream->runtime->private_data;

	return subs->hwptr_done;
}

/*
 * start/stop substream
 */
@@ -540,7 +561,6 @@ static int snd_usx2y_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
	return 0;
}


/*
 * allocate a buffer, setup samplerate
 *
@@ -553,8 +573,7 @@ static const struct s_c2
{
	char c1, c2;
}
	setrate_44100[] =
{
	setrate_44100[] = {
	{ 0x14, 0x08},	// this line sets 44100, well actually a little less
	{ 0x18, 0x40},	// only tascam / frontier design knows the further lines .......
	{ 0x18, 0x42},
@@ -589,8 +608,8 @@ static const struct s_c2
	{ 0x18, 0x7C},
	{ 0x18, 0x7E}
};
static const struct s_c2 setrate_48000[] =
{

static const struct s_c2 setrate_48000[] = {
	{ 0x14, 0x09},	// this line sets 48000, well actually a little less
	{ 0x18, 0x40},	// only tascam / frontier design knows the further lines .......
	{ 0x18, 0x42},
@@ -625,6 +644,7 @@ static const struct s_c2 setrate_48000[] =
	{ 0x18, 0x7C},
	{ 0x18, 0x7E}
};

#define NOOF_SETRATE_URBS ARRAY_SIZE(setrate_48000)

static void i_usx2y_04int(struct urb *urb)
@@ -681,6 +701,7 @@ static int usx2y_rate_set(struct usx2ydev *usx2y, int rate)
			us->submitted =	2*NOOF_SETRATE_URBS;
			for (i = 0; i < NOOF_SETRATE_URBS; ++i) {
				struct urb *urb = us->urb[i];

				if (!urb)
					continue;
				if (urb->status) {
@@ -706,6 +727,7 @@ static int usx2y_format_set(struct usx2ydev *usx2y, snd_pcm_format_t format)
{
	int alternate, err;
	struct list_head *p;

	if (format == SNDRV_PCM_FORMAT_S24_3LE) {
		alternate = 2;
		usx2y->stride = 6;
@@ -778,11 +800,13 @@ static int snd_usx2y_pcm_hw_free(struct snd_pcm_substream *substream)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct snd_usx2y_substream *subs = runtime->private_data;

	mutex_lock(&subs->usx2y->pcm_mutex);
	snd_printdd("snd_usx2y_hw_free(%p)\n", substream);

	if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
		struct snd_usx2y_substream *cap_subs = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE];

		atomic_set(&subs->state, STATE_STOPPED);
		usx2y_urbs_release(subs);
		if (!cap_subs->pcm_substream ||
@@ -794,6 +818,7 @@ static int snd_usx2y_pcm_hw_free(struct snd_pcm_substream *substream)
		}
	} else {
		struct snd_usx2y_substream *playback_subs = subs->usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK];

		if (atomic_read(&playback_subs->state) < STATE_PREPARED) {
			atomic_set(&subs->state, STATE_STOPPED);
			usx2y_urbs_release(subs);
@@ -802,6 +827,7 @@ static int snd_usx2y_pcm_hw_free(struct snd_pcm_substream *substream)
	mutex_unlock(&subs->usx2y->pcm_mutex);
	return 0;
}

/*
 * prepare callback
 *
@@ -814,6 +840,7 @@ static int snd_usx2y_pcm_prepare(struct snd_pcm_substream *substream)
	struct usx2ydev *usx2y = subs->usx2y;
	struct snd_usx2y_substream *capsubs = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE];
	int err = 0;

	snd_printdd("snd_usx2y_pcm_prepare(%p)\n", substream);

	mutex_lock(&usx2y->pcm_mutex);
@@ -840,8 +867,7 @@ static int snd_usx2y_pcm_prepare(struct snd_pcm_substream *substream)
	return err;
}

static const struct snd_pcm_hardware snd_usx2y_2c =
{
static const struct snd_pcm_hardware snd_usx2y_2c = {
	.info =			(SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
				 SNDRV_PCM_INFO_BLOCK_TRANSFER |
				 SNDRV_PCM_INFO_MMAP_VALID |
@@ -860,8 +886,6 @@ static const struct snd_pcm_hardware snd_usx2y_2c =
	.fifo_size =              0
};



static int snd_usx2y_pcm_open(struct snd_pcm_substream *substream)
{
	struct snd_usx2y_substream	*subs = ((struct snd_usx2y_substream **)
@@ -878,8 +902,6 @@ static int snd_usx2y_pcm_open(struct snd_pcm_substream *substream)
	return 0;
}



static int snd_usx2y_pcm_close(struct snd_pcm_substream *substream)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
@@ -890,9 +912,7 @@ static int snd_usx2y_pcm_close(struct snd_pcm_substream *substream)
	return 0;
}


static const struct snd_pcm_ops snd_usx2y_pcm_ops =
{
static const struct snd_pcm_ops snd_usx2y_pcm_ops = {
	.open =		snd_usx2y_pcm_open,
	.close =	snd_usx2y_pcm_close,
	.hw_params =	snd_usx2y_pcm_hw_params,
@@ -902,7 +922,6 @@ static const struct snd_pcm_ops snd_usx2y_pcm_ops =
	.pointer =	snd_usx2y_pcm_pointer,
};


/*
 * free a usb stream instance
 */
@@ -919,6 +938,7 @@ static void usx2y_audio_stream_free(struct snd_usx2y_substream **usx2y_substream
static void snd_usx2y_pcm_private_free(struct snd_pcm *pcm)
{
	struct snd_usx2y_substream **usx2y_stream = pcm->private_data;

	if (usx2y_stream)
		usx2y_audio_stream_free(usx2y_stream);
}
Loading