1
2
3
4
5
6
7
8
9
10#ifndef __COMPRESS_DRIVER_H
11#define __COMPRESS_DRIVER_H
12
13#include <linux/types.h>
14#include <linux/sched.h>
15#include <sound/core.h>
16#include <sound/compress_offload.h>
17#include <sound/asound.h>
18#include <sound/pcm.h>
19
20struct snd_compr_ops;
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38struct snd_compr_runtime {
39 snd_pcm_state_t state;
40 struct snd_compr_ops *ops;
41 struct snd_dma_buffer *dma_buffer_p;
42 void *buffer;
43 u64 buffer_size;
44 u32 fragment_size;
45 u32 fragments;
46 u64 total_bytes_available;
47 u64 total_bytes_transferred;
48 wait_queue_head_t sleep;
49 void *private_data;
50};
51
52
53
54
55
56
57
58
59
60
61
62
63
64struct snd_compr_stream {
65 const char *name;
66 struct snd_compr_ops *ops;
67 struct snd_compr_runtime *runtime;
68 struct snd_compr *device;
69 struct delayed_work error_work;
70 enum snd_compr_direction direction;
71 bool metadata_set;
72 bool next_track;
73 void *private_data;
74};
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99struct snd_compr_ops {
100 int (*open)(struct snd_compr_stream *stream);
101 int (*free)(struct snd_compr_stream *stream);
102 int (*set_params)(struct snd_compr_stream *stream,
103 struct snd_compr_params *params);
104 int (*get_params)(struct snd_compr_stream *stream,
105 struct snd_codec *params);
106 int (*set_metadata)(struct snd_compr_stream *stream,
107 struct snd_compr_metadata *metadata);
108 int (*get_metadata)(struct snd_compr_stream *stream,
109 struct snd_compr_metadata *metadata);
110 int (*trigger)(struct snd_compr_stream *stream, int cmd);
111 int (*pointer)(struct snd_compr_stream *stream,
112 struct snd_compr_tstamp *tstamp);
113 int (*copy)(struct snd_compr_stream *stream, char __user *buf,
114 size_t count);
115 int (*mmap)(struct snd_compr_stream *stream,
116 struct vm_area_struct *vma);
117 int (*ack)(struct snd_compr_stream *stream, size_t bytes);
118 int (*get_caps) (struct snd_compr_stream *stream,
119 struct snd_compr_caps *caps);
120 int (*get_codec_caps) (struct snd_compr_stream *stream,
121 struct snd_compr_codec_caps *codec);
122};
123
124
125
126
127
128
129
130
131
132
133
134
135struct snd_compr {
136 const char *name;
137 struct device dev;
138 struct snd_compr_ops *ops;
139 void *private_data;
140 struct snd_card *card;
141 unsigned int direction;
142 struct mutex lock;
143 int device;
144#ifdef CONFIG_SND_VERBOSE_PROCFS
145
146 char id[64];
147 struct snd_info_entry *proc_root;
148 struct snd_info_entry *proc_info_entry;
149#endif
150};
151
152
153int snd_compress_register(struct snd_compr *device);
154int snd_compress_deregister(struct snd_compr *device);
155int snd_compress_new(struct snd_card *card, int device,
156 int type, const char *id, struct snd_compr *compr);
157
158
159
160
161
162
163
164
165
166static inline void snd_compr_fragment_elapsed(struct snd_compr_stream *stream)
167{
168 wake_up(&stream->runtime->sleep);
169}
170
171static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
172{
173 if (snd_BUG_ON(!stream))
174 return;
175
176 stream->runtime->state = SNDRV_PCM_STATE_SETUP;
177
178 wake_up(&stream->runtime->sleep);
179}
180
181
182
183
184
185
186
187
188
189static inline void snd_compr_set_runtime_buffer(
190 struct snd_compr_stream *substream,
191 struct snd_dma_buffer *bufp)
192{
193 struct snd_compr_runtime *runtime = substream->runtime;
194
195 runtime->dma_buffer_p = bufp;
196}
197
198int snd_compr_stop_error(struct snd_compr_stream *stream,
199 snd_pcm_state_t state);
200
201#endif
202