hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/sound/compress_driver.h
....@@ -12,6 +12,7 @@
1212
1313 #include <linux/types.h>
1414 #include <linux/sched.h>
15
+#include <linux/android_kabi.h>
1516 #include <sound/core.h>
1617 #include <sound/compress_offload.h>
1718 #include <sound/asound.h>
....@@ -33,6 +34,10 @@
3334 * @total_bytes_transferred: cumulative bytes transferred by offload DSP
3435 * @sleep: poll sleep
3536 * @private_data: driver private data pointer
37
+ * @dma_area: virtual buffer address
38
+ * @dma_addr: physical buffer address (not accessible from main CPU)
39
+ * @dma_bytes: size of DMA area
40
+ * @dma_buffer_p: runtime dma buffer pointer
3641 */
3742 struct snd_compr_runtime {
3843 snd_pcm_state_t state;
....@@ -45,6 +50,13 @@
4550 u64 total_bytes_transferred;
4651 wait_queue_head_t sleep;
4752 void *private_data;
53
+
54
+ unsigned char *dma_area;
55
+ dma_addr_t dma_addr;
56
+ size_t dma_bytes;
57
+ struct snd_dma_buffer *dma_buffer_p;
58
+
59
+ ANDROID_KABI_RESERVE(1);
4860 };
4961
5062 /**
....@@ -57,7 +69,9 @@
5769 * @direction: stream direction, playback/recording
5870 * @metadata_set: metadata set flag, true when set
5971 * @next_track: has userspace signal next track transition, true when set
72
+ * @partial_drain: undergoing partial_drain for stream, true when set
6073 * @private_data: pointer to DSP private data
74
+ * @dma_buffer: allocated buffer if any
6175 */
6276 struct snd_compr_stream {
6377 const char *name;
....@@ -68,8 +82,11 @@
6882 enum snd_compr_direction direction;
6983 bool metadata_set;
7084 bool next_track;
85
+ bool partial_drain;
7186 void *private_data;
72
- struct snd_soc_pcm_runtime *be;
87
+ struct snd_dma_buffer dma_buffer;
88
+
89
+ ANDROID_KABI_RESERVE(1);
7390 };
7491
7592 /**
....@@ -84,8 +101,6 @@
84101 * @get_params: retrieve the codec parameters, mandatory
85102 * @set_metadata: Set the metadata values for a stream
86103 * @get_metadata: retrieves the requested metadata values from stream
87
- * @set_next_track_param: send codec specific data of subsequent track
88
- * in gapless
89104 * @trigger: Trigger operations like start, pause, resume, drain, stop.
90105 * This callback is mandatory
91106 * @pointer: Retrieve current h/w pointer information. Mandatory
....@@ -108,8 +123,6 @@
108123 struct snd_compr_metadata *metadata);
109124 int (*get_metadata)(struct snd_compr_stream *stream,
110125 struct snd_compr_metadata *metadata);
111
- int (*set_next_track_param)(struct snd_compr_stream *stream,
112
- union snd_codec_options *codec_options);
113126 int (*trigger)(struct snd_compr_stream *stream, int cmd);
114127 int (*pointer)(struct snd_compr_stream *stream,
115128 struct snd_compr_tstamp *tstamp);
....@@ -122,6 +135,8 @@
122135 struct snd_compr_caps *caps);
123136 int (*get_codec_caps) (struct snd_compr_stream *stream,
124137 struct snd_compr_codec_caps *codec);
138
+
139
+ ANDROID_KABI_RESERVE(1);
125140 };
126141
127142 /**
....@@ -150,6 +165,7 @@
150165 struct snd_info_entry *proc_root;
151166 struct snd_info_entry *proc_info_entry;
152167 #endif
168
+ ANDROID_KABI_RESERVE(1);
153169 };
154170
155171 /* compress device register APIs */
....@@ -176,11 +192,47 @@
176192 if (snd_BUG_ON(!stream))
177193 return;
178194
179
- stream->runtime->state = SNDRV_PCM_STATE_SETUP;
195
+ /* for partial_drain case we are back to running state on success */
196
+ if (stream->partial_drain) {
197
+ stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
198
+ stream->partial_drain = false; /* clear this flag as well */
199
+ } else {
200
+ stream->runtime->state = SNDRV_PCM_STATE_SETUP;
201
+ }
180202
181203 wake_up(&stream->runtime->sleep);
182204 }
183205
206
+/**
207
+ * snd_compr_set_runtime_buffer - Set the Compress runtime buffer
208
+ * @stream: compress stream to set
209
+ * @bufp: the buffer information, NULL to clear
210
+ *
211
+ * Copy the buffer information to runtime buffer when @bufp is non-NULL.
212
+ * Otherwise it clears the current buffer information.
213
+ */
214
+static inline void
215
+snd_compr_set_runtime_buffer(struct snd_compr_stream *stream,
216
+ struct snd_dma_buffer *bufp)
217
+{
218
+ struct snd_compr_runtime *runtime = stream->runtime;
219
+
220
+ if (bufp) {
221
+ runtime->dma_buffer_p = bufp;
222
+ runtime->dma_area = bufp->area;
223
+ runtime->dma_addr = bufp->addr;
224
+ runtime->dma_bytes = bufp->bytes;
225
+ } else {
226
+ runtime->dma_buffer_p = NULL;
227
+ runtime->dma_area = NULL;
228
+ runtime->dma_addr = 0;
229
+ runtime->dma_bytes = 0;
230
+ }
231
+}
232
+
233
+int snd_compr_malloc_pages(struct snd_compr_stream *stream, size_t size);
234
+int snd_compr_free_pages(struct snd_compr_stream *stream);
235
+
184236 int snd_compr_stop_error(struct snd_compr_stream *stream,
185237 snd_pcm_state_t state);
186238