blob: f8b17fe82efedf054e92e5351bbc92d542e939ac [file] [log] [blame]
Bryan Wuc6994e62009-06-03 09:17:58 -04001/*
Jassi Brar18b5b3b2012-02-02 21:59:53 +05302 * u_uac1.h -- interface to USB gadget "ALSA AUDIO" utilities
Bryan Wuc6994e62009-06-03 09:17:58 -04003 *
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
12#ifndef __U_AUDIO_H
13#define __U_AUDIO_H
14
15#include <linux/device.h>
16#include <linux/err.h>
17#include <linux/usb/audio.h>
18#include <linux/usb/composite.h>
19
20#include <sound/core.h>
21#include <sound/pcm.h>
22#include <sound/pcm_params.h>
23
24#include "gadget_chips.h"
25
Andrzej Pietrasiewiczbcec9782014-07-22 19:58:42 +020026#define FILE_PCM_PLAYBACK "/dev/snd/pcmC0D0p"
27#define FILE_PCM_CAPTURE "/dev/snd/pcmC0D0c"
28#define FILE_CONTROL "/dev/snd/controlC0"
29
30#define UAC1_OUT_EP_MAX_PACKET_SIZE 200
31#define UAC1_REQ_COUNT 256
32#define UAC1_AUDIO_BUF_SIZE 48000
33
Bryan Wuc6994e62009-06-03 09:17:58 -040034/*
35 * This represents the USB side of an audio card device, managed by a USB
36 * function which provides control and stream interfaces.
37 */
38
39struct gaudio_snd_dev {
40 struct gaudio *card;
41 struct file *filp;
42 struct snd_pcm_substream *substream;
43 int access;
44 int format;
45 int channels;
46 int rate;
47};
48
49struct gaudio {
50 struct usb_function func;
51 struct usb_gadget *gadget;
52
53 /* ALSA sound device interfaces */
54 struct gaudio_snd_dev control;
55 struct gaudio_snd_dev playback;
56 struct gaudio_snd_dev capture;
57
58 /* TODO */
59};
60
Andrzej Pietrasiewiczf3a34062014-07-22 19:58:38 +020061struct f_uac1_opts {
62 struct usb_function_instance func_inst;
63 int req_buf_size;
64 int req_count;
65 int audio_buf_size;
66 char *fn_play;
67 char *fn_cap;
68 char *fn_cntl;
Andrzej Pietrasiewicz08546112014-07-22 19:58:43 +020069 unsigned bound:1;
70 unsigned fn_play_alloc:1;
71 unsigned fn_cap_alloc:1;
72 unsigned fn_cntl_alloc:1;
Andrzej Pietrasiewiczf3a34062014-07-22 19:58:38 +020073 struct gaudio *card;
Andrzej Pietrasiewicz08546112014-07-22 19:58:43 +020074 struct mutex lock;
75 int refcnt;
Andrzej Pietrasiewiczf3a34062014-07-22 19:58:38 +020076};
77
Bryan Wuc6994e62009-06-03 09:17:58 -040078int gaudio_setup(struct gaudio *card);
Andrzej Pietrasiewiczf3a34062014-07-22 19:58:38 +020079void gaudio_cleanup(struct gaudio *the_card);
Andrzej Pietrasiewiczf3a34062014-07-22 19:58:38 +020080
81size_t u_audio_playback(struct gaudio *card, void *buf, size_t count);
82int u_audio_get_playback_channels(struct gaudio *card);
83int u_audio_get_playback_rate(struct gaudio *card);
Bryan Wuc6994e62009-06-03 09:17:58 -040084
85#endif /* __U_AUDIO_H */