| 1 |
|
| 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 | #define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 4, 1)
|
| 17 | |
| 18 | * struct snd_compressed_buffer - compressed buffer
|
| 19 | * @fragment_size: size of buffer fragment in bytes
|
| 20 | * @fragments: number of such fragments
|
| 21 |
|
| 22 | struct snd_compressed_buffer {
|
| 23 | __u32 fragment_size;
|
| 24 | __u32 fragments;
|
| 25 | } __attribute__((packed, aligned(4)));
|
| 26 |
|
| 27 | |
| 28 | * struct snd_compr_params - compressed stream params
|
| 29 | * @buffer: buffer description
|
| 30 | * @codec: codec parameters
|
| 31 | * @no_wake_mode: dont wake on fragment elapsed
|
| 32 |
|
| 33 | struct snd_compr_params {
|
| 34 | struct snd_compressed_buffer buffer;
|
| 35 | struct snd_codec codec;
|
| 36 | __u8 no_wake_mode;
|
| 37 | } __attribute__((packed, aligned(4)));
|
| 38 |
|
| 39 | |
| 40 | * struct snd_compr_tstamp - timestamp descriptor
|
| 41 | * @byte_offset: Byte offset in ring buffer to DSP
|
| 42 | * @copied_total: Total number of bytes copied from/to ring buffer to/by DSP
|
| 43 | * @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by
|
| 44 | * large steps and should only be used to monitor encoding/decoding
|
| 45 | * progress. It shall not be used for timing estimates.
|
| 46 | * @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio
|
| 47 | * output/input. This field should be used for A/V sync or time estimates.
|
| 48 | * @sampling_rate: sampling rate of audio
|
| 49 |
|
| 50 | struct snd_compr_tstamp {
|
| 51 | __u32 byte_offset;
|
| 52 | __u32 copied_total;
|
| 53 | __u32 pcm_frames;
|
| 54 | __u32 pcm_io_frames;
|
| 55 | __u32 sampling_rate;
|
| 56 | } __attribute__((packed, aligned(4)));
|
| 57 |
|
| 58 | |
| 59 | * struct snd_compr_tstamp64 - timestamp descriptor with fields in 64 bit
|
| 60 | * @byte_offset: Byte offset in ring buffer to DSP
|
| 61 | * @copied_total: Total number of bytes copied from/to ring buffer to/by DSP
|
| 62 | * @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by
|
| 63 | * large steps and should only be used to monitor encoding/decoding
|
| 64 | * progress. It shall not be used for timing estimates.
|
| 65 | * @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio
|
| 66 | * output/input. This field should be used for A/V sync or time estimates.
|
| 67 | * @sampling_rate: sampling rate of audio
|
| 68 |
|
| 69 | struct snd_compr_tstamp64 {
|
| 70 | __u32 byte_offset;
|
| 71 | __u64 copied_total;
|
| 72 | __u64 pcm_frames;
|
| 73 | __u64 pcm_io_frames;
|
| 74 | __u32 sampling_rate;
|
| 75 | } __attribute__((packed, aligned(4)));
|
| 76 |
|
| 77 | |
| 78 | * struct snd_compr_avail - avail descriptor
|
| 79 | * @avail: Number of bytes available in ring buffer for writing/reading
|
| 80 | * @tstamp: timestamp information
|
| 81 |
|
| 82 | struct snd_compr_avail {
|
| 83 | __u64 avail;
|
| 84 | struct snd_compr_tstamp tstamp;
|
| 85 | } __attribute__((packed, aligned(4)));
|
| 86 |
|
| 87 | |
| 88 | * struct snd_compr_avail64 - avail descriptor with tstamp in 64 bit format
|
| 89 | * @avail: Number of bytes available in ring buffer for writing/reading
|
| 90 | * @tstamp: timestamp information
|
| 91 |
|
| 92 | struct snd_compr_avail64 {
|
| 93 | __u64 avail;
|
| 94 | struct snd_compr_tstamp64 tstamp;
|
| 95 | } __attribute__((packed, aligned(4)));
|
| 96 |
|
| 97 | enum snd_compr_direction {
|
| 98 | SND_COMPRESS_PLAYBACK = 0,
|
| 99 | SND_COMPRESS_CAPTURE,
|
| 100 | SND_COMPRESS_ACCEL
|
| 101 | };
|
| 102 |
|
| 103 | |
| 104 | * struct snd_compr_caps - caps descriptor
|
| 105 | * @codecs: pointer to array of codecs
|
| 106 | * @direction: direction supported. Of type snd_compr_direction
|
| 107 | * @min_fragment_size: minimum fragment supported by DSP
|
| 108 | * @max_fragment_size: maximum fragment supported by DSP
|
| 109 | * @min_fragments: min fragments supported by DSP
|
| 110 | * @max_fragments: max fragments supported by DSP
|
| 111 | * @num_codecs: number of codecs supported
|
| 112 | * @reserved: reserved field
|
| 113 |
|
| 114 | struct snd_compr_caps {
|
| 115 | __u32 num_codecs;
|
| 116 | __u32 direction;
|
| 117 | __u32 min_fragment_size;
|
| 118 | __u32 max_fragment_size;
|
| 119 | __u32 min_fragments;
|
| 120 | __u32 max_fragments;
|
| 121 | __u32 codecs[MAX_NUM_CODECS];
|
| 122 | __u32 reserved[11];
|
| 123 | } __attribute__((packed, aligned(4)));
|
| 124 |
|
| 125 | |
| 126 | * struct snd_compr_codec_caps - query capability of codec
|
| 127 | * @codec: codec for which capability is queried
|
| 128 | * @num_descriptors: number of codec descriptors
|
| 129 | * @descriptor: array of codec capability descriptor
|
| 130 |
|
| 131 | struct snd_compr_codec_caps {
|
| 132 | __u32 codec;
|
| 133 | __u32 num_descriptors;
|
| 134 | struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS];
|
| 135 | } __attribute__((packed, aligned(4)));
|
| 136 |
|
| 137 | |
| 138 | * enum sndrv_compress_encoder - encoder metadata key
|
| 139 | * @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the
|
| 140 | * end of the track
|
| 141 | * @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the
|
| 142 | * beginning of the track
|
| 143 |
|
| 144 | enum sndrv_compress_encoder {
|
| 145 | SNDRV_COMPRESS_ENCODER_PADDING = 1,
|
| 146 | SNDRV_COMPRESS_ENCODER_DELAY = 2,
|
| 147 | };
|
| 148 |
|
| 149 | |
| 150 | * struct snd_compr_metadata - compressed stream metadata
|
| 151 | * @key: key id
|
| 152 | * @value: key value
|
| 153 |
|
| 154 | struct snd_compr_metadata {
|
| 155 | __u32 key;
|
| 156 | __u32 value[8];
|
| 157 | } __attribute__((packed, aligned(4)));
|
| 158 |
|
| 159 |
|
| 160 | #define SND_COMPRESS_TFLG_NEW_STREAM (1<<0)
|
| 161 |
|
| 162 | |
| 163 | * struct snd_compr_task - task primitive for non-realtime operation
|
| 164 | * @seqno: sequence number (task identifier)
|
| 165 | * @origin_seqno: previous sequence number (task identifier) - for reuse
|
| 166 | * @input_fd: data input file descriptor (dma-buf)
|
| 167 | * @output_fd: data output file descriptor (dma-buf)
|
| 168 | * @input_size: filled data in bytes (from caller, must not exceed fragment size)
|
| 169 | * @flags: see SND_COMPRESS_TFLG_* defines
|
| 170 | * @reserved: reserved for future extension
|
| 171 |
|
| 172 | struct snd_compr_task {
|
| 173 | __u64 seqno;
|
| 174 | __u64 origin_seqno;
|
| 175 | int input_fd;
|
| 176 | int output_fd;
|
| 177 | __u64 input_size;
|
| 178 | __u32 flags;
|
| 179 | __u8 reserved[16];
|
| 180 | } __attribute__((packed, aligned(4)));
|
| 181 |
|
| 182 | |
| 183 | * enum snd_compr_state - task state
|
| 184 | * @SND_COMPRESS_TASK_STATE_IDLE: task is not queued
|
| 185 | * @SND_COMPRESS_TASK_STATE_ACTIVE: task is in the queue
|
| 186 | * @SND_COMPRESS_TASK_STATE_FINISHED: task was processed, output is available
|
| 187 |
|
| 188 | enum snd_compr_state {
|
| 189 | SND_COMPRESS_TASK_STATE_IDLE = 0,
|
| 190 | SND_COMPRESS_TASK_STATE_ACTIVE,
|
| 191 | SND_COMPRESS_TASK_STATE_FINISHED
|
| 192 | };
|
| 193 |
|
| 194 | |
| 195 | * struct snd_compr_task_status - task status
|
| 196 | * @seqno: sequence number (task identifier)
|
| 197 | * @input_size: filled data in bytes (from user space)
|
| 198 | * @output_size: filled data in bytes (from driver)
|
| 199 | * @output_flags: reserved for future (all zeros - from driver)
|
| 200 | * @state: actual task state (SND_COMPRESS_TASK_STATE_*)
|
| 201 | * @reserved: reserved for future extension
|
| 202 |
|
| 203 | struct snd_compr_task_status {
|
| 204 | __u64 seqno;
|
| 205 | __u64 input_size;
|
| 206 | __u64 output_size;
|
| 207 | __u32 output_flags;
|
| 208 | __u8 state;
|
| 209 | __u8 reserved[15];
|
| 210 | } __attribute__((packed, aligned(4)));
|
| 211 |
|
| 212 | |
| 213 | * compress path ioctl definitions
|
| 214 | * SNDRV_COMPRESS_GET_CAPS: Query capability of DSP
|
| 215 | * SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec
|
| 216 | * SNDRV_COMPRESS_SET_PARAMS: Set codec and stream parameters
|
| 217 | * Note: only codec params can be changed runtime and stream params cant be
|
| 218 | * SNDRV_COMPRESS_GET_PARAMS: Query codec params
|
| 219 | * SNDRV_COMPRESS_TSTAMP: get the current timestamp value
|
| 220 | * SNDRV_COMPRESS_TSTAMP64: get the current timestamp value in 64 bit format
|
| 221 | * SNDRV_COMPRESS_AVAIL: get the current buffer avail value.
|
| 222 | * This also queries the tstamp properties
|
| 223 | * SNDRV_COMPRESS_PAUSE: Pause the running stream
|
| 224 | * SNDRV_COMPRESS_RESUME: resume a paused stream
|
| 225 | * SNDRV_COMPRESS_START: Start a stream
|
| 226 | * SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content
|
| 227 | * and the buffers currently with DSP
|
| 228 | * SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that
|
| 229 | * SNDRV_COMPRESS_IOCTL_VERSION: Query the API version
|
| 230 |
|
| 231 | #define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int)
|
| 232 | #define SNDRV_COMPRESS_GET_CAPS _IOWR('C', 0x10, struct snd_compr_caps)
|
| 233 | #define SNDRV_COMPRESS_GET_CODEC_CAPS _IOWR('C', 0x11,\
|
| 234 | struct snd_compr_codec_caps)
|
| 235 | #define SNDRV_COMPRESS_SET_PARAMS _IOW('C', 0x12, struct snd_compr_params)
|
| 236 | #define SNDRV_COMPRESS_GET_PARAMS _IOR('C', 0x13, struct snd_codec)
|
| 237 | #define SNDRV_COMPRESS_SET_METADATA _IOW('C', 0x14,\
|
| 238 | struct snd_compr_metadata)
|
| 239 | #define SNDRV_COMPRESS_GET_METADATA _IOWR('C', 0x15,\
|
| 240 | struct snd_compr_metadata)
|
| 241 | #define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp)
|
| 242 | #define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail)
|
| 243 | #define SNDRV_COMPRESS_TSTAMP64 _IOR('C', 0x22, struct snd_compr_tstamp64)
|
| 244 | #define SNDRV_COMPRESS_AVAIL64 _IOR('C', 0x23, struct snd_compr_avail64)
|
| 245 | #define SNDRV_COMPRESS_PAUSE _IO('C', 0x30)
|
| 246 | #define SNDRV_COMPRESS_RESUME _IO('C', 0x31)
|
| 247 | #define SNDRV_COMPRESS_START _IO('C', 0x32)
|
| 248 | #define SNDRV_COMPRESS_STOP _IO('C', 0x33)
|
| 249 | #define SNDRV_COMPRESS_DRAIN _IO('C', 0x34)
|
| 250 | #define SNDRV_COMPRESS_NEXT_TRACK _IO('C', 0x35)
|
| 251 | #define SNDRV_COMPRESS_PARTIAL_DRAIN _IO('C', 0x36)
|
| 252 |
|
| 253 |
|
| 254 | #define SNDRV_COMPRESS_TASK_CREATE _IOWR('C', 0x60, struct snd_compr_task)
|
| 255 | #define SNDRV_COMPRESS_TASK_FREE _IOW('C', 0x61, __u64)
|
| 256 | #define SNDRV_COMPRESS_TASK_START _IOWR('C', 0x62, struct snd_compr_task)
|
| 257 | #define SNDRV_COMPRESS_TASK_STOP _IOW('C', 0x63, __u64)
|
| 258 | #define SNDRV_COMPRESS_TASK_STATUS _IOWR('C', 0x68, struct snd_compr_task_status)
|
| 259 |
|
| 260 | |
| 261 | * TODO
|
| 262 | * 1. add mmap support
|
| 263 | *
|
| 264 |
|
| 265 | #define SND_COMPR_TRIGGER_DRAIN 7
|
| 266 | #define SND_COMPR_TRIGGER_NEXT_TRACK 8
|
| 267 | #define SND_COMPR_TRIGGER_PARTIAL_DRAIN 9
|
| 268 | #endif
|