162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef __USBAUDIO_ENDPOINT_H
362306a36Sopenharmony_ci#define __USBAUDIO_ENDPOINT_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#define SND_USB_ENDPOINT_TYPE_DATA     0
662306a36Sopenharmony_ci#define SND_USB_ENDPOINT_TYPE_SYNC     1
762306a36Sopenharmony_ci
862306a36Sopenharmony_cistruct snd_usb_endpoint *snd_usb_get_endpoint(struct snd_usb_audio *chip,
962306a36Sopenharmony_ci					      int ep_num);
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciint snd_usb_add_endpoint(struct snd_usb_audio *chip, int ep_num, int type);
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cistruct snd_usb_endpoint *
1462306a36Sopenharmony_cisnd_usb_endpoint_open(struct snd_usb_audio *chip,
1562306a36Sopenharmony_ci		      const struct audioformat *fp,
1662306a36Sopenharmony_ci		      const struct snd_pcm_hw_params *params,
1762306a36Sopenharmony_ci		      bool is_sync_ep,
1862306a36Sopenharmony_ci		      bool fixed_rate);
1962306a36Sopenharmony_civoid snd_usb_endpoint_close(struct snd_usb_audio *chip,
2062306a36Sopenharmony_ci			    struct snd_usb_endpoint *ep);
2162306a36Sopenharmony_ciint snd_usb_endpoint_set_params(struct snd_usb_audio *chip,
2262306a36Sopenharmony_ci				struct snd_usb_endpoint *ep);
2362306a36Sopenharmony_ciint snd_usb_endpoint_prepare(struct snd_usb_audio *chip,
2462306a36Sopenharmony_ci			     struct snd_usb_endpoint *ep);
2562306a36Sopenharmony_ciint snd_usb_endpoint_get_clock_rate(struct snd_usb_audio *chip, int clock);
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_cibool snd_usb_endpoint_compatible(struct snd_usb_audio *chip,
2862306a36Sopenharmony_ci				 struct snd_usb_endpoint *ep,
2962306a36Sopenharmony_ci				 const struct audioformat *fp,
3062306a36Sopenharmony_ci				 const struct snd_pcm_hw_params *params);
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_civoid snd_usb_endpoint_set_sync(struct snd_usb_audio *chip,
3362306a36Sopenharmony_ci			       struct snd_usb_endpoint *data_ep,
3462306a36Sopenharmony_ci			       struct snd_usb_endpoint *sync_ep);
3562306a36Sopenharmony_civoid snd_usb_endpoint_set_callback(struct snd_usb_endpoint *ep,
3662306a36Sopenharmony_ci				   int (*prepare)(struct snd_usb_substream *subs,
3762306a36Sopenharmony_ci						  struct urb *urb,
3862306a36Sopenharmony_ci						  bool in_stream_lock),
3962306a36Sopenharmony_ci				   void (*retire)(struct snd_usb_substream *subs,
4062306a36Sopenharmony_ci						  struct urb *urb),
4162306a36Sopenharmony_ci				   struct snd_usb_substream *data_subs);
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciint snd_usb_endpoint_start(struct snd_usb_endpoint *ep);
4462306a36Sopenharmony_civoid snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool keep_pending);
4562306a36Sopenharmony_civoid snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
4662306a36Sopenharmony_civoid snd_usb_endpoint_suspend(struct snd_usb_endpoint *ep);
4762306a36Sopenharmony_civoid snd_usb_endpoint_release(struct snd_usb_endpoint *ep);
4862306a36Sopenharmony_civoid snd_usb_endpoint_free_all(struct snd_usb_audio *chip);
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciint snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep);
5162306a36Sopenharmony_ciint snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep,
5262306a36Sopenharmony_ci				      struct snd_urb_ctx *ctx, int idx,
5362306a36Sopenharmony_ci				      unsigned int avail);
5462306a36Sopenharmony_ciint snd_usb_queue_pending_output_urbs(struct snd_usb_endpoint *ep,
5562306a36Sopenharmony_ci				      bool in_stream_lock);
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#endif /* __USBAUDIO_ENDPOINT_H */
58