mirror of https://gitee.com/openkylin/linux.git
ALSA: usb-audio: Add snd_usb_get_endpoint() helper
Factor out the code to obtain snd_usb_endpoint object matching with the given endpoint. It'll be used in the later patch to add the implicit feedback hw-constraint. No functional change by this patch itself. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-6-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
2e43aae2bf
commit
c7474d0977
|
@ -439,6 +439,26 @@ static void snd_complete_urb(struct urb *urb)
|
||||||
clear_bit(ctx->index, &ep->active_mask);
|
clear_bit(ctx->index, &ep->active_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the existing endpoint object corresponding EP, iface and alt numbers
|
||||||
|
* Returns NULL if not present.
|
||||||
|
* Call inside chip->mutex locking for avoiding the race.
|
||||||
|
*/
|
||||||
|
struct snd_usb_endpoint *
|
||||||
|
snd_usb_get_endpoint(struct snd_usb_audio *chip,
|
||||||
|
int ep_num, int iface, int altsetting)
|
||||||
|
{
|
||||||
|
struct snd_usb_endpoint *ep;
|
||||||
|
|
||||||
|
list_for_each_entry(ep, &chip->ep_list, list) {
|
||||||
|
if (ep->ep_num == ep_num &&
|
||||||
|
ep->iface == iface &&
|
||||||
|
ep->altsetting == altsetting)
|
||||||
|
return ep;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* snd_usb_add_endpoint: Add an endpoint to an USB audio chip
|
* snd_usb_add_endpoint: Add an endpoint to an USB audio chip
|
||||||
*
|
*
|
||||||
|
@ -470,15 +490,13 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
|
||||||
|
|
||||||
mutex_lock(&chip->mutex);
|
mutex_lock(&chip->mutex);
|
||||||
|
|
||||||
list_for_each_entry(ep, &chip->ep_list, list) {
|
ep = snd_usb_get_endpoint(chip, ep_num,
|
||||||
if (ep->ep_num == ep_num &&
|
alts->desc.bInterfaceNumber,
|
||||||
ep->iface == alts->desc.bInterfaceNumber &&
|
alts->desc.bAlternateSetting);
|
||||||
ep->altsetting == alts->desc.bAlternateSetting) {
|
if (ep) {
|
||||||
usb_audio_dbg(ep->chip,
|
usb_audio_dbg(ep->chip, "Re-using EP %x in iface %d,%d @%p\n",
|
||||||
"Re-using EP %x in iface %d,%d @%p\n",
|
ep_num, ep->iface, ep->altsetting, ep);
|
||||||
ep_num, ep->iface, ep->altsetting, ep);
|
goto __exit_unlock;
|
||||||
goto __exit_unlock;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_audio_dbg(chip, "Creating new %s %s endpoint #%x\n",
|
usb_audio_dbg(chip, "Creating new %s %s endpoint #%x\n",
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
#define SND_USB_ENDPOINT_TYPE_DATA 0
|
#define SND_USB_ENDPOINT_TYPE_DATA 0
|
||||||
#define SND_USB_ENDPOINT_TYPE_SYNC 1
|
#define SND_USB_ENDPOINT_TYPE_SYNC 1
|
||||||
|
|
||||||
|
struct snd_usb_endpoint *snd_usb_get_endpoint(struct snd_usb_audio *chip,
|
||||||
|
int ep_num, int iface,
|
||||||
|
int altsetting);
|
||||||
|
|
||||||
struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
|
struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
|
||||||
struct usb_host_interface *alts,
|
struct usb_host_interface *alts,
|
||||||
int ep_num, int direction, int type);
|
int ep_num, int direction, int type);
|
||||||
|
|
Loading…
Reference in New Issue