18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __USB_STREAM_H
38c2ecf20Sopenharmony_ci#define __USB_STREAM_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <uapi/sound/usb_stream.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#define USB_STREAM_NURBS 4
88c2ecf20Sopenharmony_ci#define USB_STREAM_URBDEPTH 4
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_cistruct usb_stream_kernel {
118c2ecf20Sopenharmony_ci	struct usb_stream *s;
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci	void *write_page;
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci	unsigned n_o_ps;
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci	struct urb *inurb[USB_STREAM_NURBS];
188c2ecf20Sopenharmony_ci	struct urb *idle_inurb;
198c2ecf20Sopenharmony_ci	struct urb *completed_inurb;
208c2ecf20Sopenharmony_ci	struct urb *outurb[USB_STREAM_NURBS];
218c2ecf20Sopenharmony_ci	struct urb *idle_outurb;
228c2ecf20Sopenharmony_ci	struct urb *completed_outurb;
238c2ecf20Sopenharmony_ci	struct urb *i_urb;
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	int iso_frame_balance;
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci	wait_queue_head_t sleep;
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci	unsigned out_phase;
308c2ecf20Sopenharmony_ci	unsigned out_phase_peeked;
318c2ecf20Sopenharmony_ci	unsigned freqn;
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistruct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
358c2ecf20Sopenharmony_ci				  struct usb_device *dev,
368c2ecf20Sopenharmony_ci				  unsigned in_endpoint, unsigned out_endpoint,
378c2ecf20Sopenharmony_ci				  unsigned sample_rate, unsigned use_packsize,
388c2ecf20Sopenharmony_ci				  unsigned period_frames, unsigned frame_size);
398c2ecf20Sopenharmony_civoid usb_stream_free(struct usb_stream_kernel *);
408c2ecf20Sopenharmony_ciint usb_stream_start(struct usb_stream_kernel *);
418c2ecf20Sopenharmony_civoid usb_stream_stop(struct usb_stream_kernel *);
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#endif /* __USB_STREAM_H */
44