summaryrefslogtreecommitdiff
path: root/include/sound
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2024-10-02 11:39:04 +0200
committerTakashi Iwai <tiwai@suse.de>2024-10-25 10:53:20 +0200
commit04177158cf98a79744937893b100020d77e6f9ac (patch)
tree0cd5bcd84b412d20185af3998d5eba167492ae26 /include/sound
parent42f7652d3eb527d03665b09edac47f85fb600924 (diff)
downloadlwn-04177158cf98a79744937893b100020d77e6f9ac.tar.gz
lwn-04177158cf98a79744937893b100020d77e6f9ac.zip
ALSA: compress_offload: introduce accel operation mode
There is a requirement to expose the audio hardware that accelerates various tasks for user space such as sample rate converters, compressed stream decoders, etc. This is description for the API extension for the compress ALSA API which is able to handle "tasks" that are not bound to real-time operations and allows for the serialization of operations. For details, refer to "compress-accel.rst" document. Cc: Mark Brown <broonie@kernel.org> Cc: Shengjiu Wang <shengjiu.wang@gmail.com> Cc: Nicolas Dufresne <nicolas@ndufresne.ca> Cc: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev> Cc: Vinod Koul <vkoul@kernel.org> Signed-off-by: Jaroslav Kysela <perex@perex.cz> Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Tested-by: Shengjiu Wang <shengjiu.wang@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20241002093904.1809799-1-perex@perex.cz
Diffstat (limited to 'include/sound')
-rw-r--r--include/sound/compress_driver.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
index bcf872c17dd3..5db4881b0681 100644
--- a/include/sound/compress_driver.h
+++ b/include/sound/compress_driver.h
@@ -20,6 +20,30 @@
struct snd_compr_ops;
/**
+ * struct snd_compr_task_runtime: task runtime description
+ * @list: list of all managed tasks
+ * @input: input DMA buffer
+ * @output: output DMA buffer
+ * @seqno: sequence number
+ * @input_size: really used data in the input buffer
+ * @output_size: really used data in the output buffer
+ * @flags: see SND_COMPRESS_TFLG_*
+ * @state: actual task state
+ * @private_value: used by the lowlevel driver (opaque)
+ */
+struct snd_compr_task_runtime {
+ struct list_head list;
+ struct dma_buf *input;
+ struct dma_buf *output;
+ u64 seqno;
+ u64 input_size;
+ u64 output_size;
+ u32 flags;
+ u8 state;
+ void *private_value;
+};
+
+/**
* struct snd_compr_runtime: runtime stream description
* @state: stream state
* @ops: pointer to DSP callbacks
@@ -37,6 +61,10 @@ struct snd_compr_ops;
* @dma_addr: physical buffer address (not accessible from main CPU)
* @dma_bytes: size of DMA area
* @dma_buffer_p: runtime dma buffer pointer
+ * @active_tasks: count of active tasks
+ * @total_tasks: count of all tasks
+ * @task_seqno: last task sequence number (!= 0)
+ * @tasks: list of all tasks
*/
struct snd_compr_runtime {
snd_pcm_state_t state;
@@ -54,6 +82,13 @@ struct snd_compr_runtime {
dma_addr_t dma_addr;
size_t dma_bytes;
struct snd_dma_buffer *dma_buffer_p;
+
+#if IS_ENABLED(CONFIG_SND_COMPRESS_ACCEL)
+ u32 active_tasks;
+ u32 total_tasks;
+ u64 task_seqno;
+ struct list_head tasks;
+#endif
};
/**
@@ -132,6 +167,12 @@ struct snd_compr_ops {
struct snd_compr_caps *caps);
int (*get_codec_caps) (struct snd_compr_stream *stream,
struct snd_compr_codec_caps *codec);
+#if IS_ENABLED(CONFIG_SND_COMPRESS_ACCEL)
+ int (*task_create) (struct snd_compr_stream *stream, struct snd_compr_task_runtime *task);
+ int (*task_start) (struct snd_compr_stream *stream, struct snd_compr_task_runtime *task);
+ int (*task_stop) (struct snd_compr_stream *stream, struct snd_compr_task_runtime *task);
+ int (*task_free) (struct snd_compr_stream *stream, struct snd_compr_task_runtime *task);
+#endif
};
/**
@@ -242,4 +283,9 @@ int snd_compr_free_pages(struct snd_compr_stream *stream);
int snd_compr_stop_error(struct snd_compr_stream *stream,
snd_pcm_state_t state);
+#if IS_ENABLED(CONFIG_SND_COMPRESS_ACCEL)
+void snd_compr_task_finished(struct snd_compr_stream *stream,
+ struct snd_compr_task_runtime *task);
+#endif
+
#endif