1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * compress_offload.h - compress offload header definations
5 * Copyright (C) 2011 Intel Corporation
6 * Authors: Vinod Koul <vinod.koul@linux.intel.com>
7 * Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
9 #ifndef __COMPRESS_OFFLOAD_H
10 #define __COMPRESS_OFFLOAD_H
12 #include <linux/types.h>
13 #include <sound/asound.h>
14 #include <sound/compress_params.h>
17 #define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 3, 0)
19 * struct snd_compressed_buffer - compressed buffer
20 * @fragment_size: size of buffer fragment in bytes
21 * @fragments: number of such fragments
23 struct snd_compressed_buffer
{
26 } __attribute__((packed
, aligned(4)));
29 * struct snd_compr_params - compressed stream params
30 * @buffer: buffer description
31 * @codec: codec parameters
32 * @no_wake_mode: dont wake on fragment elapsed
34 struct snd_compr_params
{
35 struct snd_compressed_buffer buffer
;
36 struct snd_codec codec
;
38 } __attribute__((packed
, aligned(4)));
41 * struct snd_compr_tstamp - timestamp descriptor
42 * @byte_offset: Byte offset in ring buffer to DSP
43 * @copied_total: Total number of bytes copied from/to ring buffer to/by DSP
44 * @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by
45 * large steps and should only be used to monitor encoding/decoding
46 * progress. It shall not be used for timing estimates.
47 * @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio
48 * output/input. This field should be used for A/V sync or time estimates.
49 * @sampling_rate: sampling rate of audio
51 struct snd_compr_tstamp
{
57 } __attribute__((packed
, aligned(4)));
60 * struct snd_compr_avail - avail descriptor
61 * @avail: Number of bytes available in ring buffer for writing/reading
62 * @tstamp: timestamp information
64 struct snd_compr_avail
{
66 struct snd_compr_tstamp tstamp
;
67 } __attribute__((packed
, aligned(4)));
69 enum snd_compr_direction
{
70 SND_COMPRESS_PLAYBACK
= 0,
76 * struct snd_compr_caps - caps descriptor
77 * @codecs: pointer to array of codecs
78 * @direction: direction supported. Of type snd_compr_direction
79 * @min_fragment_size: minimum fragment supported by DSP
80 * @max_fragment_size: maximum fragment supported by DSP
81 * @min_fragments: min fragments supported by DSP
82 * @max_fragments: max fragments supported by DSP
83 * @num_codecs: number of codecs supported
84 * @reserved: reserved field
86 struct snd_compr_caps
{
89 __u32 min_fragment_size
;
90 __u32 max_fragment_size
;
93 __u32 codecs
[MAX_NUM_CODECS
];
95 } __attribute__((packed
, aligned(4)));
98 * struct snd_compr_codec_caps - query capability of codec
99 * @codec: codec for which capability is queried
100 * @num_descriptors: number of codec descriptors
101 * @descriptor: array of codec capability descriptor
103 struct snd_compr_codec_caps
{
105 __u32 num_descriptors
;
106 struct snd_codec_desc descriptor
[MAX_NUM_CODEC_DESCRIPTORS
];
107 } __attribute__((packed
, aligned(4)));
110 * enum sndrv_compress_encoder - encoder metadata key
111 * @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the
113 * @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the
114 * beginning of the track
116 enum sndrv_compress_encoder
{
117 SNDRV_COMPRESS_ENCODER_PADDING
= 1,
118 SNDRV_COMPRESS_ENCODER_DELAY
= 2,
122 * struct snd_compr_metadata - compressed stream metadata
126 struct snd_compr_metadata
{
129 } __attribute__((packed
, aligned(4)));
131 /* flags for struct snd_compr_task */
132 #define SND_COMPRESS_TFLG_NEW_STREAM (1<<0) /* mark for the new stream data */
135 * struct snd_compr_task - task primitive for non-realtime operation
136 * @seqno: sequence number (task identifier)
137 * @origin_seqno: previous sequence number (task identifier) - for reuse
138 * @input_fd: data input file descriptor (dma-buf)
139 * @output_fd: data output file descriptor (dma-buf)
140 * @input_size: filled data in bytes (from caller, must not exceed fragment size)
141 * @flags: see SND_COMPRESS_TFLG_* defines
142 * @reserved: reserved for future extension
144 struct snd_compr_task
{
152 } __attribute__((packed
, aligned(4)));
155 * enum snd_compr_state - task state
156 * @SND_COMPRESS_TASK_STATE_IDLE: task is not queued
157 * @SND_COMPRESS_TASK_STATE_ACTIVE: task is in the queue
158 * @SND_COMPRESS_TASK_STATE_FINISHED: task was processed, output is available
160 enum snd_compr_state
{
161 SND_COMPRESS_TASK_STATE_IDLE
= 0,
162 SND_COMPRESS_TASK_STATE_ACTIVE
,
163 SND_COMPRESS_TASK_STATE_FINISHED
167 * struct snd_compr_task_status - task status
168 * @seqno: sequence number (task identifier)
169 * @input_size: filled data in bytes (from user space)
170 * @output_size: filled data in bytes (from driver)
171 * @output_flags: reserved for future (all zeros - from driver)
172 * @state: actual task state (SND_COMPRESS_TASK_STATE_*)
173 * @reserved: reserved for future extension
175 struct snd_compr_task_status
{
182 } __attribute__((packed
, aligned(4)));
185 * compress path ioctl definitions
186 * SNDRV_COMPRESS_GET_CAPS: Query capability of DSP
187 * SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec
188 * SNDRV_COMPRESS_SET_PARAMS: Set codec and stream parameters
189 * Note: only codec params can be changed runtime and stream params cant be
190 * SNDRV_COMPRESS_GET_PARAMS: Query codec params
191 * SNDRV_COMPRESS_TSTAMP: get the current timestamp value
192 * SNDRV_COMPRESS_AVAIL: get the current buffer avail value.
193 * This also queries the tstamp properties
194 * SNDRV_COMPRESS_PAUSE: Pause the running stream
195 * SNDRV_COMPRESS_RESUME: resume a paused stream
196 * SNDRV_COMPRESS_START: Start a stream
197 * SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content
198 * and the buffers currently with DSP
199 * SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that
200 * SNDRV_COMPRESS_IOCTL_VERSION: Query the API version
202 #define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int)
203 #define SNDRV_COMPRESS_GET_CAPS _IOWR('C', 0x10, struct snd_compr_caps)
204 #define SNDRV_COMPRESS_GET_CODEC_CAPS _IOWR('C', 0x11,\
205 struct snd_compr_codec_caps)
206 #define SNDRV_COMPRESS_SET_PARAMS _IOW('C', 0x12, struct snd_compr_params)
207 #define SNDRV_COMPRESS_GET_PARAMS _IOR('C', 0x13, struct snd_codec)
208 #define SNDRV_COMPRESS_SET_METADATA _IOW('C', 0x14,\
209 struct snd_compr_metadata)
210 #define SNDRV_COMPRESS_GET_METADATA _IOWR('C', 0x15,\
211 struct snd_compr_metadata)
212 #define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp)
213 #define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail)
214 #define SNDRV_COMPRESS_PAUSE _IO('C', 0x30)
215 #define SNDRV_COMPRESS_RESUME _IO('C', 0x31)
216 #define SNDRV_COMPRESS_START _IO('C', 0x32)
217 #define SNDRV_COMPRESS_STOP _IO('C', 0x33)
218 #define SNDRV_COMPRESS_DRAIN _IO('C', 0x34)
219 #define SNDRV_COMPRESS_NEXT_TRACK _IO('C', 0x35)
220 #define SNDRV_COMPRESS_PARTIAL_DRAIN _IO('C', 0x36)
223 #define SNDRV_COMPRESS_TASK_CREATE _IOWR('C', 0x60, struct snd_compr_task)
224 #define SNDRV_COMPRESS_TASK_FREE _IOW('C', 0x61, __u64)
225 #define SNDRV_COMPRESS_TASK_START _IOWR('C', 0x62, struct snd_compr_task)
226 #define SNDRV_COMPRESS_TASK_STOP _IOW('C', 0x63, __u64)
227 #define SNDRV_COMPRESS_TASK_STATUS _IOWR('C', 0x68, struct snd_compr_task_status)
231 * 1. add mmap support
234 #define SND_COMPR_TRIGGER_DRAIN 7 /*FIXME move this to pcm.h */
235 #define SND_COMPR_TRIGGER_NEXT_TRACK 8
236 #define SND_COMPR_TRIGGER_PARTIAL_DRAIN 9