xref: /openbmc/linux/sound/usb/endpoint.h (revision fbeb1ec8)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2e5779998SDaniel Mack #ifndef __USBAUDIO_ENDPOINT_H
3e5779998SDaniel Mack #define __USBAUDIO_ENDPOINT_H
4e5779998SDaniel Mack 
58fdff6a3SDaniel Mack #define SND_USB_ENDPOINT_TYPE_DATA     0
68fdff6a3SDaniel Mack #define SND_USB_ENDPOINT_TYPE_SYNC     1
78fdff6a3SDaniel Mack 
8c7474d09STakashi Iwai struct snd_usb_endpoint *snd_usb_get_endpoint(struct snd_usb_audio *chip,
954cb3190STakashi Iwai 					      int ep_num);
10c7474d09STakashi Iwai 
1154cb3190STakashi Iwai int snd_usb_add_endpoint(struct snd_usb_audio *chip, int ep_num, int type);
128fdff6a3SDaniel Mack 
13bf6313a0STakashi Iwai struct snd_usb_endpoint *
14bf6313a0STakashi Iwai snd_usb_endpoint_open(struct snd_usb_audio *chip,
15cab941b7STakashi Iwai 		      const struct audioformat *fp,
16bf6313a0STakashi Iwai 		      const struct snd_pcm_hw_params *params,
17fd28941cSJaroslav Kysela 		      bool is_sync_ep,
18fd28941cSJaroslav Kysela 		      bool fixed_rate);
19bf6313a0STakashi Iwai void snd_usb_endpoint_close(struct snd_usb_audio *chip,
20bf6313a0STakashi Iwai 			    struct snd_usb_endpoint *ep);
212be79d58STakashi Iwai int snd_usb_endpoint_set_params(struct snd_usb_audio *chip,
222be79d58STakashi Iwai 				struct snd_usb_endpoint *ep);
232be79d58STakashi Iwai int snd_usb_endpoint_prepare(struct snd_usb_audio *chip,
24bf6313a0STakashi Iwai 			     struct snd_usb_endpoint *ep);
254e7cf1fbSTakashi Iwai int snd_usb_endpoint_get_clock_rate(struct snd_usb_audio *chip, int clock);
268fdff6a3SDaniel Mack 
27bf6313a0STakashi Iwai bool snd_usb_endpoint_compatible(struct snd_usb_audio *chip,
28bf6313a0STakashi Iwai 				 struct snd_usb_endpoint *ep,
29bf6313a0STakashi Iwai 				 const struct audioformat *fp,
30bf6313a0STakashi Iwai 				 const struct snd_pcm_hw_params *params);
31bf6313a0STakashi Iwai 
32bf6313a0STakashi Iwai void snd_usb_endpoint_set_sync(struct snd_usb_audio *chip,
33bf6313a0STakashi Iwai 			       struct snd_usb_endpoint *data_ep,
34bf6313a0STakashi Iwai 			       struct snd_usb_endpoint *sync_ep);
3596e221f3STakashi Iwai void snd_usb_endpoint_set_callback(struct snd_usb_endpoint *ep,
36d5f871f8STakashi Iwai 				   int (*prepare)(struct snd_usb_substream *subs,
37d5f871f8STakashi Iwai 						  struct urb *urb,
38d5f871f8STakashi Iwai 						  bool in_stream_lock),
3996e221f3STakashi Iwai 				   void (*retire)(struct snd_usb_substream *subs,
4096e221f3STakashi Iwai 						  struct urb *urb),
4196e221f3STakashi Iwai 				   struct snd_usb_substream *data_subs);
4296e221f3STakashi Iwai 
431d0f9530SIoan-Adrian Ratiu int snd_usb_endpoint_start(struct snd_usb_endpoint *ep);
44813a17caSTakashi Iwai void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool keep_pending);
45f58161baSTakashi Iwai void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
46bf6313a0STakashi Iwai void snd_usb_endpoint_suspend(struct snd_usb_endpoint *ep);
4792a586bdSTakashi Iwai void snd_usb_endpoint_release(struct snd_usb_endpoint *ep);
4800272c61STakashi Iwai void snd_usb_endpoint_free_all(struct snd_usb_audio *chip);
498fdff6a3SDaniel Mack 
5098ae472bSEldad Zack int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep);
513d58760fSTakashi Iwai int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep,
52d215f63dSTakashi Iwai 				      struct snd_urb_ctx *ctx, int idx,
53d215f63dSTakashi Iwai 				      unsigned int avail);
54*8c721c53STakashi Iwai int snd_usb_queue_pending_output_urbs(struct snd_usb_endpoint *ep,
55d5f871f8STakashi Iwai 				      bool in_stream_lock);
568fdff6a3SDaniel Mack 
57e5779998SDaniel Mack #endif /* __USBAUDIO_ENDPOINT_H */
58