From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Cc: alsa-devel@alsa-project.org, linux-usb@vger.kernel.org, tglx@linutronix.de, Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz> Subject: [4/9,v2] ALSA: usb-audio: use usb_fill_int_urb() Date: Wed, 20 Jun 2018 11:38:27 +0200 [thread overview] Message-ID: <20180620093827.ei6bqkkb4ahk3hbn@linutronix.de> (raw) 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. usb_fill_int_urb() ensures 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 working 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> --- v1…v2: description changes (spelling + usb_fill_int_urb() ensures "syncinterval" not data_ep_set_params()) 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;
WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Cc: alsa-devel@alsa-project.org, linux-usb@vger.kernel.org, tglx@linutronix.de, Takashi Iwai <tiwai@suse.com> Subject: [PATCH 4/9 v2] ALSA: usb-audio: use usb_fill_int_urb() Date: Wed, 20 Jun 2018 11:38:27 +0200 [thread overview] Message-ID: <20180620093827.ei6bqkkb4ahk3hbn@linutronix.de> (raw) In-Reply-To: <ce8ffb2b-35e8-1108-9065-81f4d3cb4d8d@cogentembedded.com> 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. usb_fill_int_urb() ensures 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 working 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> --- v1…v2: description changes (spelling + usb_fill_int_urb() ensures "syncinterval" not data_ep_set_params()) 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; -- 2.17.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next reply other threads:[~2018-06-20 9:38 UTC|newest] Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-06-20 9:38 Sebastian Andrzej Siewior [this message] 2018-06-20 9:38 ` [PATCH 4/9 v2] ALSA: usb-audio: use usb_fill_int_urb() Sebastian Andrzej Siewior -- strict thread matches above, loose matches on Subject: below -- 2018-06-22 10:14 [6/9] ALSA: usb: caiaq: " Sebastian Andrzej Siewior 2018-06-22 10:14 ` [PATCH 6/9] " Sebastian Andrzej Siewior 2018-06-22 10:01 [6/9] " Daniel Mack 2018-06-22 10:01 ` [PATCH 6/9] " Daniel Mack 2018-06-22 8:49 [6/9] " Takashi Iwai 2018-06-22 8:49 ` [PATCH 6/9] " Takashi Iwai 2018-06-21 21:16 [6/9] " Sebastian Andrzej Siewior 2018-06-21 21:16 ` [PATCH 6/9] " Sebastian Andrzej Siewior 2018-06-21 20:19 [6/9] " Daniel Mack 2018-06-21 20:19 ` [PATCH 6/9] " Daniel Mack 2018-06-21 20:18 [5/9] ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback Daniel Mack 2018-06-21 20:18 ` [PATCH 5/9] " Daniel Mack 2018-06-20 16:20 [8/9] ALSA: usx2y: usbusx2yaudio: use usb_fill_int_urb() Takashi Iwai 2018-06-20 16:20 ` [PATCH 8/9] " Takashi Iwai 2018-06-20 15:47 [8/9] " Sebastian Andrzej Siewior 2018-06-20 15:47 ` [PATCH 8/9] " Sebastian Andrzej Siewior 2018-06-20 15:38 [8/9] " Sebastian Andrzej Siewior 2018-06-20 15:38 ` [PATCH 8/9] " Sebastian Andrzej Siewior 2018-06-20 14:52 [8/9] " Takashi Iwai 2018-06-20 14:52 ` [PATCH 8/9] " Takashi Iwai 2018-06-20 14:39 [8/9] " Sebastian Andrzej Siewior 2018-06-20 14:39 ` [PATCH 8/9] " Sebastian Andrzej Siewior 2018-06-20 14:00 [4/9,v2] ALSA: usb-audio: " Takashi Iwai 2018-06-20 14:00 ` [PATCH 4/9 v2] " Takashi Iwai 2018-06-20 13:56 [4/9,v2] " Takashi Iwai 2018-06-20 13:56 ` [PATCH 4/9 v2] " Takashi Iwai 2018-06-20 13:52 [4/9,v2] " Sebastian Andrzej Siewior 2018-06-20 13:52 ` [PATCH 4/9 v2] " Sebastian Andrzej Siewior 2018-06-20 13:21 [4/9,v2] " Takashi Iwai 2018-06-20 13:21 ` [PATCH 4/9 v2] " Takashi Iwai 2018-06-20 12:51 [8/9] ALSA: usx2y: usbusx2yaudio: " Takashi Iwai 2018-06-20 12:51 ` [PATCH 8/9] " Takashi Iwai 2018-06-20 8:23 [4/9] ALSA: usb-audio: " Sergei Shtylyov 2018-06-20 8:23 ` [PATCH 4/9] " Sergei Shtylyov 2018-06-19 21:55 [9/9] ALSA: usx2y: usx2yhwdeppcm: " Sebastian Andrzej Siewior 2018-06-19 21:55 ` [PATCH 9/9] " Sebastian Andrzej Siewior 2018-06-19 21:55 [8/9] ALSA: usx2y: usbusx2yaudio: " Sebastian Andrzej Siewior 2018-06-19 21:55 ` [PATCH 8/9] " Sebastian Andrzej Siewior 2018-06-19 21:55 [7/9] ALSA: usb-midi: use irqsave() in USB's complete callback Sebastian Andrzej Siewior 2018-06-19 21:55 ` [PATCH 7/9] " Sebastian Andrzej Siewior 2018-06-19 21:55 [6/9] ALSA: usb: caiaq: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-19 21:55 ` [PATCH 6/9] " Sebastian Andrzej Siewior 2018-06-19 21:55 [5/9] ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback Sebastian Andrzej Siewior 2018-06-19 21:55 ` [PATCH 5/9] " Sebastian Andrzej Siewior 2018-06-19 21:55 [4/9] ALSA: usb-audio: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-19 21:55 ` [PATCH 4/9] " Sebastian Andrzej Siewior 2018-06-19 21:55 [3/9] ALSA: ua101: " Sebastian Andrzej Siewior 2018-06-19 21:55 ` [PATCH 3/9] " Sebastian Andrzej Siewior 2018-06-19 21:55 [2/9] ALSA: line6: " Sebastian Andrzej Siewior 2018-06-19 21:55 ` [PATCH 2/9] " Sebastian Andrzej Siewior 2018-06-19 21:55 [1/9] ALSA: 6fire: " Sebastian Andrzej Siewior 2018-06-19 21:55 ` [PATCH 1/9] " Sebastian Andrzej Siewior 2018-06-19 21:55 ALSA: use irqsave() in URB completion + usb_fill_int_urb Sebastian Andrzej Siewior 2018-06-20 12:55 ` Takashi Iwai
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180620093827.ei6bqkkb4ahk3hbn@linutronix.de \ --to=bigeasy@linutronix.de \ --cc=alsa-devel@alsa-project.org \ --cc=linux-usb@vger.kernel.org \ --cc=perex@perex.cz \ --cc=sergei.shtylyov@cogentembedded.com \ --cc=tglx@linutronix.de \ --cc=tiwai@suse.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.