u_uac1_legacy.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * u_uac1.h -- interface to USB gadget "ALSA AUDIO" utilities
  4. *
  5. * Copyright (C) 2008 Bryan Wu <cooloney@kernel.org>
  6. * Copyright (C) 2008 Analog Devices, Inc
  7. */
  8. #ifndef __U_UAC1_LEGACY_H
  9. #define __U_UAC1_LEGACY_H
  10. #include <linux/device.h>
  11. #include <linux/err.h>
  12. #include <linux/usb/audio.h>
  13. #include <linux/usb/composite.h>
  14. #include <sound/core.h>
  15. #include <sound/pcm.h>
  16. #include <sound/pcm_params.h>
  17. #define FILE_PCM_PLAYBACK "/dev/snd/pcmC0D0p"
  18. #define FILE_PCM_CAPTURE "/dev/snd/pcmC0D0c"
  19. #define FILE_CONTROL "/dev/snd/controlC0"
  20. #define UAC1_OUT_EP_MAX_PACKET_SIZE 200
  21. #define UAC1_REQ_COUNT 256
  22. #define UAC1_AUDIO_BUF_SIZE 48000
  23. /*
  24. * This represents the USB side of an audio card device, managed by a USB
  25. * function which provides control and stream interfaces.
  26. */
  27. struct gaudio_snd_dev {
  28. struct gaudio *card;
  29. struct file *filp;
  30. struct snd_pcm_substream *substream;
  31. int access;
  32. int format;
  33. int channels;
  34. int rate;
  35. };
  36. struct gaudio {
  37. struct usb_function func;
  38. struct usb_gadget *gadget;
  39. /* ALSA sound device interfaces */
  40. struct gaudio_snd_dev control;
  41. struct gaudio_snd_dev playback;
  42. struct gaudio_snd_dev capture;
  43. /* TODO */
  44. };
  45. struct f_uac1_legacy_opts {
  46. struct usb_function_instance func_inst;
  47. int req_buf_size;
  48. int req_count;
  49. int audio_buf_size;
  50. char *fn_play;
  51. char *fn_cap;
  52. char *fn_cntl;
  53. unsigned bound:1;
  54. unsigned fn_play_alloc:1;
  55. unsigned fn_cap_alloc:1;
  56. unsigned fn_cntl_alloc:1;
  57. struct mutex lock;
  58. int refcnt;
  59. };
  60. int gaudio_setup(struct gaudio *card);
  61. void gaudio_cleanup(struct gaudio *the_card);
  62. size_t u_audio_playback(struct gaudio *card, void *buf, size_t count);
  63. int u_audio_get_playback_channels(struct gaudio *card);
  64. int u_audio_get_playback_rate(struct gaudio *card);
  65. #endif /* __U_UAC1_LEGACY_H */