Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/include/uapi/sound/compress_offload.h
26289 views
1
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2
/*
3
* compress_offload.h - compress offload header definations
4
*
5
* Copyright (C) 2011 Intel Corporation
6
* Authors: Vinod Koul <[email protected]>
7
* Pierre-Louis Bossart <[email protected]>
8
*/
9
#ifndef __COMPRESS_OFFLOAD_H
10
#define __COMPRESS_OFFLOAD_H
11
12
#include <linux/types.h>
13
#include <sound/asound.h>
14
#include <sound/compress_params.h>
15
16
17
#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 3, 0)
18
/**
19
* struct snd_compressed_buffer - compressed buffer
20
* @fragment_size: size of buffer fragment in bytes
21
* @fragments: number of such fragments
22
*/
23
struct snd_compressed_buffer {
24
__u32 fragment_size;
25
__u32 fragments;
26
} __attribute__((packed, aligned(4)));
27
28
/**
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
33
*/
34
struct snd_compr_params {
35
struct snd_compressed_buffer buffer;
36
struct snd_codec codec;
37
__u8 no_wake_mode;
38
} __attribute__((packed, aligned(4)));
39
40
/**
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
50
*/
51
struct snd_compr_tstamp {
52
__u32 byte_offset;
53
__u32 copied_total;
54
__u32 pcm_frames;
55
__u32 pcm_io_frames;
56
__u32 sampling_rate;
57
} __attribute__((packed, aligned(4)));
58
59
/**
60
* struct snd_compr_avail - avail descriptor
61
* @avail: Number of bytes available in ring buffer for writing/reading
62
* @tstamp: timestamp information
63
*/
64
struct snd_compr_avail {
65
__u64 avail;
66
struct snd_compr_tstamp tstamp;
67
} __attribute__((packed, aligned(4)));
68
69
enum snd_compr_direction {
70
SND_COMPRESS_PLAYBACK = 0,
71
SND_COMPRESS_CAPTURE,
72
SND_COMPRESS_ACCEL
73
};
74
75
/**
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
85
*/
86
struct snd_compr_caps {
87
__u32 num_codecs;
88
__u32 direction;
89
__u32 min_fragment_size;
90
__u32 max_fragment_size;
91
__u32 min_fragments;
92
__u32 max_fragments;
93
__u32 codecs[MAX_NUM_CODECS];
94
__u32 reserved[11];
95
} __attribute__((packed, aligned(4)));
96
97
/**
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
102
*/
103
struct snd_compr_codec_caps {
104
__u32 codec;
105
__u32 num_descriptors;
106
struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS];
107
} __attribute__((packed, aligned(4)));
108
109
/**
110
* enum sndrv_compress_encoder - encoder metadata key
111
* @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the
112
* end of the track
113
* @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the
114
* beginning of the track
115
*/
116
enum sndrv_compress_encoder {
117
SNDRV_COMPRESS_ENCODER_PADDING = 1,
118
SNDRV_COMPRESS_ENCODER_DELAY = 2,
119
};
120
121
/**
122
* struct snd_compr_metadata - compressed stream metadata
123
* @key: key id
124
* @value: key value
125
*/
126
struct snd_compr_metadata {
127
__u32 key;
128
__u32 value[8];
129
} __attribute__((packed, aligned(4)));
130
131
/* flags for struct snd_compr_task */
132
#define SND_COMPRESS_TFLG_NEW_STREAM (1<<0) /* mark for the new stream data */
133
134
/**
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
143
*/
144
struct snd_compr_task {
145
__u64 seqno;
146
__u64 origin_seqno;
147
int input_fd;
148
int output_fd;
149
__u64 input_size;
150
__u32 flags;
151
__u8 reserved[16];
152
} __attribute__((packed, aligned(4)));
153
154
/**
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
159
*/
160
enum snd_compr_state {
161
SND_COMPRESS_TASK_STATE_IDLE = 0,
162
SND_COMPRESS_TASK_STATE_ACTIVE,
163
SND_COMPRESS_TASK_STATE_FINISHED
164
};
165
166
/**
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
174
*/
175
struct snd_compr_task_status {
176
__u64 seqno;
177
__u64 input_size;
178
__u64 output_size;
179
__u32 output_flags;
180
__u8 state;
181
__u8 reserved[15];
182
} __attribute__((packed, aligned(4)));
183
184
/*
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
201
*/
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)
221
222
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)
228
229
/*
230
* TODO
231
* 1. add mmap support
232
*
233
*/
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
237
#endif
238
239