u_uac1.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include "gadget_chips.h"
  21. #define FILE_PCM_PLAYBACK "/dev/snd/pcmC0D0p"
  22. #define FILE_PCM_CAPTURE "/dev/snd/pcmC0D0c"
  23. #define FILE_CONTROL "/dev/snd/controlC0"
  24. #define UAC1_OUT_EP_MAX_PACKET_SIZE 200
  25. #define UAC1_REQ_COUNT 256
  26. #define UAC1_AUDIO_BUF_SIZE 48000
  27. /*
  28. * This represents the USB side of an audio card device, managed by a USB
  29. * function which provides control and stream interfaces.
  30. */
  31. struct gaudio_snd_dev {
  32. struct gaudio *card;
  33. struct file *filp;
  34. struct snd_pcm_substream *substream;
  35. int access;
  36. int format;
  37. int channels;
  38. int rate;
  39. };
  40. struct gaudio {
  41. struct usb_function func;
  42. struct usb_gadget *gadget;
  43. /* ALSA sound device interfaces */
  44. struct gaudio_snd_dev control;
  45. struct gaudio_snd_dev playback;
  46. struct gaudio_snd_dev capture;
  47. /* TODO */
  48. };
  49. struct f_uac1_opts {
  50. struct usb_function_instance func_inst;
  51. int req_buf_size;
  52. int req_count;
  53. int audio_buf_size;
  54. char *fn_play;
  55. char *fn_cap;
  56. char *fn_cntl;
  57. unsigned bound:1;
  58. unsigned fn_play_alloc:1;
  59. unsigned fn_cap_alloc:1;
  60. unsigned fn_cntl_alloc:1;
  61. struct mutex lock;
  62. int refcnt;
  63. };
  64. int gaudio_setup(struct gaudio *card);
  65. void gaudio_cleanup(struct gaudio *the_card);
  66. size_t u_audio_playback(struct gaudio *card, void *buf, size_t count);
  67. int u_audio_get_playback_channels(struct gaudio *card);
  68. int u_audio_get_playback_rate(struct gaudio *card);
  69. #endif /* __U_AUDIO_H */