u_uac1.h 1.9 KB

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