1674e95caSDavid Howells /* 2674e95caSDavid Howells * compress_offload.h - compress offload header definations 3674e95caSDavid Howells * 4674e95caSDavid Howells * Copyright (C) 2011 Intel Corporation 5674e95caSDavid Howells * Authors: Vinod Koul <vinod.koul@linux.intel.com> 6674e95caSDavid Howells * Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> 7674e95caSDavid Howells * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8674e95caSDavid Howells * 9674e95caSDavid Howells * This program is free software; you can redistribute it and/or modify 10674e95caSDavid Howells * it under the terms of the GNU General Public License as published by 11674e95caSDavid Howells * the Free Software Foundation; version 2 of the License. 12674e95caSDavid Howells * 13674e95caSDavid Howells * This program is distributed in the hope that it will be useful, but 14674e95caSDavid Howells * WITHOUT ANY WARRANTY; without even the implied warranty of 15674e95caSDavid Howells * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16674e95caSDavid Howells * General Public License for more details. 17674e95caSDavid Howells * 18674e95caSDavid Howells * You should have received a copy of the GNU General Public License along 19674e95caSDavid Howells * with this program; if not, write to the Free Software Foundation, Inc., 20674e95caSDavid Howells * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 21674e95caSDavid Howells * 22674e95caSDavid Howells * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23674e95caSDavid Howells * 24674e95caSDavid Howells */ 25674e95caSDavid Howells #ifndef __COMPRESS_OFFLOAD_H 26674e95caSDavid Howells #define __COMPRESS_OFFLOAD_H 27674e95caSDavid Howells 28674e95caSDavid Howells #include <linux/types.h> 29674e95caSDavid Howells #include <sound/asound.h> 30674e95caSDavid Howells #include <sound/compress_params.h> 31674e95caSDavid Howells 32674e95caSDavid Howells 336733cf57STakashi Iwai #define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 1, 2) 34674e95caSDavid Howells /** 35674e95caSDavid Howells * struct snd_compressed_buffer: compressed buffer 36674e95caSDavid Howells * @fragment_size: size of buffer fragment in bytes 37674e95caSDavid Howells * @fragments: number of such fragments 38674e95caSDavid Howells */ 39674e95caSDavid Howells struct snd_compressed_buffer { 40674e95caSDavid Howells __u32 fragment_size; 41674e95caSDavid Howells __u32 fragments; 42674e95caSDavid Howells }; 43674e95caSDavid Howells 44674e95caSDavid Howells /** 45674e95caSDavid Howells * struct snd_compr_params: compressed stream params 46674e95caSDavid Howells * @buffer: buffer description 47674e95caSDavid Howells * @codec: codec parameters 48674e95caSDavid Howells * @no_wake_mode: dont wake on fragment elapsed 49674e95caSDavid Howells */ 50674e95caSDavid Howells struct snd_compr_params { 51674e95caSDavid Howells struct snd_compressed_buffer buffer; 52674e95caSDavid Howells struct snd_codec codec; 53674e95caSDavid Howells __u8 no_wake_mode; 54674e95caSDavid Howells }; 55674e95caSDavid Howells 56674e95caSDavid Howells /** 57674e95caSDavid Howells * struct snd_compr_tstamp: timestamp descriptor 58674e95caSDavid Howells * @byte_offset: Byte offset in ring buffer to DSP 59674e95caSDavid Howells * @copied_total: Total number of bytes copied from/to ring buffer to/by DSP 60674e95caSDavid Howells * @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by 61674e95caSDavid Howells * large steps and should only be used to monitor encoding/decoding 62674e95caSDavid Howells * progress. It shall not be used for timing estimates. 63674e95caSDavid Howells * @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio 64674e95caSDavid Howells * output/input. This field should be used for A/V sync or time estimates. 65674e95caSDavid Howells * @sampling_rate: sampling rate of audio 66674e95caSDavid Howells */ 67674e95caSDavid Howells struct snd_compr_tstamp { 68674e95caSDavid Howells __u32 byte_offset; 69674e95caSDavid Howells __u32 copied_total; 706733cf57STakashi Iwai __u32 pcm_frames; 716733cf57STakashi Iwai __u32 pcm_io_frames; 72674e95caSDavid Howells __u32 sampling_rate; 73674e95caSDavid Howells }; 74674e95caSDavid Howells 75674e95caSDavid Howells /** 76674e95caSDavid Howells * struct snd_compr_avail: avail descriptor 77674e95caSDavid Howells * @avail: Number of bytes available in ring buffer for writing/reading 78674e95caSDavid Howells * @tstamp: timestamp infomation 79674e95caSDavid Howells */ 80674e95caSDavid Howells struct snd_compr_avail { 81674e95caSDavid Howells __u64 avail; 82674e95caSDavid Howells struct snd_compr_tstamp tstamp; 83674e95caSDavid Howells }; 84674e95caSDavid Howells 85674e95caSDavid Howells enum snd_compr_direction { 86674e95caSDavid Howells SND_COMPRESS_PLAYBACK = 0, 87674e95caSDavid Howells SND_COMPRESS_CAPTURE 88674e95caSDavid Howells }; 89674e95caSDavid Howells 90674e95caSDavid Howells /** 91674e95caSDavid Howells * struct snd_compr_caps: caps descriptor 92674e95caSDavid Howells * @codecs: pointer to array of codecs 93674e95caSDavid Howells * @direction: direction supported. Of type snd_compr_direction 94674e95caSDavid Howells * @min_fragment_size: minimum fragment supported by DSP 95674e95caSDavid Howells * @max_fragment_size: maximum fragment supported by DSP 96674e95caSDavid Howells * @min_fragments: min fragments supported by DSP 97674e95caSDavid Howells * @max_fragments: max fragments supported by DSP 98674e95caSDavid Howells * @num_codecs: number of codecs supported 99674e95caSDavid Howells * @reserved: reserved field 100674e95caSDavid Howells */ 101674e95caSDavid Howells struct snd_compr_caps { 102674e95caSDavid Howells __u32 num_codecs; 103674e95caSDavid Howells __u32 direction; 104674e95caSDavid Howells __u32 min_fragment_size; 105674e95caSDavid Howells __u32 max_fragment_size; 106674e95caSDavid Howells __u32 min_fragments; 107674e95caSDavid Howells __u32 max_fragments; 108674e95caSDavid Howells __u32 codecs[MAX_NUM_CODECS]; 109674e95caSDavid Howells __u32 reserved[11]; 110674e95caSDavid Howells }; 111674e95caSDavid Howells 112674e95caSDavid Howells /** 113674e95caSDavid Howells * struct snd_compr_codec_caps: query capability of codec 114674e95caSDavid Howells * @codec: codec for which capability is queried 115674e95caSDavid Howells * @num_descriptors: number of codec descriptors 116674e95caSDavid Howells * @descriptor: array of codec capability descriptor 117674e95caSDavid Howells */ 118674e95caSDavid Howells struct snd_compr_codec_caps { 119674e95caSDavid Howells __u32 codec; 120674e95caSDavid Howells __u32 num_descriptors; 121674e95caSDavid Howells struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS]; 122674e95caSDavid Howells }; 123674e95caSDavid Howells 124674e95caSDavid Howells /** 1259727b490SJeeja KP * @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the 1269727b490SJeeja KP * end of the track 1279727b490SJeeja KP * @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the 1289727b490SJeeja KP * beginning of the track 1299727b490SJeeja KP */ 1309727b490SJeeja KP enum { 1319727b490SJeeja KP SNDRV_COMPRESS_ENCODER_PADDING = 1, 1329727b490SJeeja KP SNDRV_COMPRESS_ENCODER_DELAY = 2, 1339727b490SJeeja KP }; 1349727b490SJeeja KP 1359727b490SJeeja KP /** 1369727b490SJeeja KP * struct snd_compr_metadata: compressed stream metadata 1379727b490SJeeja KP * @key: key id 1389727b490SJeeja KP * @value: key value 1399727b490SJeeja KP */ 1409727b490SJeeja KP struct snd_compr_metadata { 1419727b490SJeeja KP __u32 key; 1429727b490SJeeja KP __u32 value[8]; 1439727b490SJeeja KP }; 1449727b490SJeeja KP 1459727b490SJeeja KP /** 146674e95caSDavid Howells * compress path ioctl definitions 147674e95caSDavid Howells * SNDRV_COMPRESS_GET_CAPS: Query capability of DSP 148674e95caSDavid Howells * SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec 149674e95caSDavid Howells * SNDRV_COMPRESS_SET_PARAMS: Set codec and stream parameters 150674e95caSDavid Howells * Note: only codec params can be changed runtime and stream params cant be 151674e95caSDavid Howells * SNDRV_COMPRESS_GET_PARAMS: Query codec params 152674e95caSDavid Howells * SNDRV_COMPRESS_TSTAMP: get the current timestamp value 153674e95caSDavid Howells * SNDRV_COMPRESS_AVAIL: get the current buffer avail value. 154674e95caSDavid Howells * This also queries the tstamp properties 155674e95caSDavid Howells * SNDRV_COMPRESS_PAUSE: Pause the running stream 156674e95caSDavid Howells * SNDRV_COMPRESS_RESUME: resume a paused stream 157674e95caSDavid Howells * SNDRV_COMPRESS_START: Start a stream 158674e95caSDavid Howells * SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content 159674e95caSDavid Howells * and the buffers currently with DSP 160674e95caSDavid Howells * SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that 161674e95caSDavid Howells * SNDRV_COMPRESS_IOCTL_VERSION: Query the API version 162674e95caSDavid Howells */ 163674e95caSDavid Howells #define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int) 164674e95caSDavid Howells #define SNDRV_COMPRESS_GET_CAPS _IOWR('C', 0x10, struct snd_compr_caps) 165674e95caSDavid Howells #define SNDRV_COMPRESS_GET_CODEC_CAPS _IOWR('C', 0x11,\ 166674e95caSDavid Howells struct snd_compr_codec_caps) 167674e95caSDavid Howells #define SNDRV_COMPRESS_SET_PARAMS _IOW('C', 0x12, struct snd_compr_params) 168674e95caSDavid Howells #define SNDRV_COMPRESS_GET_PARAMS _IOR('C', 0x13, struct snd_codec) 1699727b490SJeeja KP #define SNDRV_COMPRESS_SET_METADATA _IOW('C', 0x14,\ 1709727b490SJeeja KP struct snd_compr_metadata) 1719727b490SJeeja KP #define SNDRV_COMPRESS_GET_METADATA _IOWR('C', 0x15,\ 1729727b490SJeeja KP struct snd_compr_metadata) 173674e95caSDavid Howells #define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp) 174674e95caSDavid Howells #define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail) 175674e95caSDavid Howells #define SNDRV_COMPRESS_PAUSE _IO('C', 0x30) 176674e95caSDavid Howells #define SNDRV_COMPRESS_RESUME _IO('C', 0x31) 177674e95caSDavid Howells #define SNDRV_COMPRESS_START _IO('C', 0x32) 178674e95caSDavid Howells #define SNDRV_COMPRESS_STOP _IO('C', 0x33) 179674e95caSDavid Howells #define SNDRV_COMPRESS_DRAIN _IO('C', 0x34) 1809727b490SJeeja KP #define SNDRV_COMPRESS_NEXT_TRACK _IO('C', 0x35) 1819727b490SJeeja KP #define SNDRV_COMPRESS_PARTIAL_DRAIN _IO('C', 0x36) 182674e95caSDavid Howells /* 183674e95caSDavid Howells * TODO 184674e95caSDavid Howells * 1. add mmap support 185674e95caSDavid Howells * 186674e95caSDavid Howells */ 187674e95caSDavid Howells #define SND_COMPR_TRIGGER_DRAIN 7 /*FIXME move this to pcm.h */ 1889727b490SJeeja KP #define SND_COMPR_TRIGGER_NEXT_TRACK 8 1899727b490SJeeja KP #define SND_COMPR_TRIGGER_PARTIAL_DRAIN 9 190674e95caSDavid Howells #endif 191