* [4/9] ALSA: usb-audio: use usb_fill_int_urb()
@ 2018-06-19 21:55 Sebastian Andrzej Siewior
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-06-19 21:55 UTC (permalink / raw)
To: alsa-devel
Cc: linux-usb, tglx, Takashi Iwai, Jaroslav Kysela,
Sebastian Andrzej Siewior
Using usb_fill_int_urb() helps to find code which initializes an
URB. A grep for members of the struct (like ->complete) reveal lots
of other things, too.
data_ep_set_params() additionally sets urb->transfer_buffer_length which
was not the case earlier.
data_ep_set_params() and data_ep_set_params() ensure that syncinterval is
within the allowed range on HS/SS. The interval value seems to come from
snd_usb_parse_datainterval() which is bInterval - 1 and only in the rage 1 … 4.
So in order to keep the magic wokring I pass datainterval + 1.
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
sound/usb/endpoint.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index c90607ebe155..bbc02db5b417 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -772,6 +772,8 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
/* allocate and initialize data urbs */
for (i = 0; i < ep->nurbs; i++) {
struct snd_urb_ctx *u = &ep->urb[i];
+ void *buf;
+
u->index = i;
u->ep = ep;
u->packets = urb_packs;
@@ -783,16 +785,13 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
if (!u->urb)
goto out_of_memory;
- u->urb->transfer_buffer =
- usb_alloc_coherent(ep->chip->dev, u->buffer_size,
- GFP_KERNEL, &u->urb->transfer_dma);
- if (!u->urb->transfer_buffer)
+ buf = usb_alloc_coherent(ep->chip->dev, u->buffer_size,
+ GFP_KERNEL, &u->urb->transfer_dma);
+ if (!buf)
goto out_of_memory;
- u->urb->pipe = ep->pipe;
+ usb_fill_int_urb(u->urb, NULL, ep->pipe, buf, u->buffer_size,
+ snd_complete_urb, u, ep->datainterval + 1);
u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
- u->urb->interval = 1 << ep->datainterval;
- u->urb->context = u;
- u->urb->complete = snd_complete_urb;
INIT_LIST_HEAD(&u->ready_list);
}
@@ -823,15 +822,12 @@ static int sync_ep_set_params(struct snd_usb_endpoint *ep)
u->urb = usb_alloc_urb(1, GFP_KERNEL);
if (!u->urb)
goto out_of_memory;
- u->urb->transfer_buffer = ep->syncbuf + i * 4;
+ usb_fill_int_urb(u->urb, NULL, ep->pipe, ep->syncbuf + i * 4, 4,
+ snd_complete_urb, u, ep->syncinterval + 1);
+
u->urb->transfer_dma = ep->sync_dma + i * 4;
- u->urb->transfer_buffer_length = 4;
- u->urb->pipe = ep->pipe;
u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
u->urb->number_of_packets = 1;
- u->urb->interval = 1 << ep->syncinterval;
- u->urb->context = u;
- u->urb->complete = snd_complete_urb;
}
ep->nurbs = SYNC_URBS;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [4/9] ALSA: usb-audio: use usb_fill_int_urb()
@ 2018-06-20 8:23 Sergei Shtylyov
0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2018-06-20 8:23 UTC (permalink / raw)
To: Sebastian Andrzej Siewior, alsa-devel
Cc: linux-usb, tglx, Takashi Iwai, Jaroslav Kysela
Hello!
On 6/20/2018 12:55 AM, Sebastian Andrzej Siewior wrote:
> Using usb_fill_int_urb() helps to find code which initializes an
> URB. A grep for members of the struct (like ->complete) reveal lots
> of other things, too.
>
> data_ep_set_params() additionally sets urb->transfer_buffer_length which
> was not the case earlier.
> data_ep_set_params() and data_ep_set_params()
These 2 are the same function?
> ensure that syncinterval is
> within the allowed range on HS/SS. The interval value seems to come from
> snd_usb_parse_datainterval() which is bInterval - 1 and only in the rage 1 … 4.
> So in order to keep the magic wokring I pass datainterval + 1.
Working.
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
[...]
MBR, Sergei
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-20 8:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-19 21:55 [4/9] ALSA: usb-audio: use usb_fill_int_urb() Sebastian Andrzej Siewior
-- strict thread matches above, loose matches on Subject: below --
2018-06-20 8:23 Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).