1224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/* 2224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * compress_offload.h - compress offload header definations 3224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * 4224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * Copyright (C) 2011 Intel Corporation 5224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * Authors: Vinod Koul <vinod.koul@linux.intel.com> 6224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> 7224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * 9224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * This program is free software; you can redistribute it and/or modify 10224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * it under the terms of the GNU General Public License as published by 11224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * the Free Software Foundation; version 2 of the License. 12224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * 13224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * This program is distributed in the hope that it will be useful, but 14224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * WITHOUT ANY WARRANTY; without even the implied warranty of 15224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * General Public License for more details. 17224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * 18224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * You should have received a copy of the GNU General Public License along 19224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * with this program; if not, write to the Free Software Foundation, Inc., 20224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 21224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * 22224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * 24224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 25224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#ifndef __COMPRESS_OFFLOAD_H 26224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define __COMPRESS_OFFLOAD_H 27224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 28224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#include <linux/types.h> 29224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#include <sound/asound.h> 30224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#include <sound/compress_params.h> 31224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 32224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 33e084501669a4e4931c9d648351ecd7d595b81b79Christopher Ferris#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 1, 2) 34224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/** 3512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * struct snd_compressed_buffer - compressed buffer 36224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @fragment_size: size of buffer fragment in bytes 37224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @fragments: number of such fragments 38224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 39224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstruct snd_compressed_buffer { 40224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 fragment_size; 41224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 fragments; 42314752488cb92b9f86028836d0b8eabd8acb6a7cChristopher Ferris} __attribute__((packed, aligned(4))); 43224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 44224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/** 4512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * struct snd_compr_params - compressed stream params 46224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @buffer: buffer description 47224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @codec: codec parameters 48224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @no_wake_mode: dont wake on fragment elapsed 49224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 50224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstruct snd_compr_params { 51224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng struct snd_compressed_buffer buffer; 52224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng struct snd_codec codec; 53224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u8 no_wake_mode; 54314752488cb92b9f86028836d0b8eabd8acb6a7cChristopher Ferris} __attribute__((packed, aligned(4))); 55224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 56224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/** 5712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * struct snd_compr_tstamp - timestamp descriptor 58224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @byte_offset: Byte offset in ring buffer to DSP 59224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @copied_total: Total number of bytes copied from/to ring buffer to/by DSP 60224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by 61224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * large steps and should only be used to monitor encoding/decoding 62224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * progress. It shall not be used for timing estimates. 63224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio 64224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * output/input. This field should be used for A/V sync or time estimates. 65224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @sampling_rate: sampling rate of audio 66224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 67224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstruct snd_compr_tstamp { 68224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 byte_offset; 69224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 copied_total; 70e084501669a4e4931c9d648351ecd7d595b81b79Christopher Ferris __u32 pcm_frames; 71e084501669a4e4931c9d648351ecd7d595b81b79Christopher Ferris __u32 pcm_io_frames; 72224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 sampling_rate; 73314752488cb92b9f86028836d0b8eabd8acb6a7cChristopher Ferris} __attribute__((packed, aligned(4))); 74224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 75224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/** 7612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * struct snd_compr_avail - avail descriptor 77224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @avail: Number of bytes available in ring buffer for writing/reading 7812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * @tstamp: timestamp information 79224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 80224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstruct snd_compr_avail { 81224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u64 avail; 82224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng struct snd_compr_tstamp tstamp; 83314752488cb92b9f86028836d0b8eabd8acb6a7cChristopher Ferris} __attribute__((packed, aligned(4))); 84224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 85224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengenum snd_compr_direction { 86224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng SND_COMPRESS_PLAYBACK = 0, 87224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng SND_COMPRESS_CAPTURE 88224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng}; 89224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 90224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/** 9112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * struct snd_compr_caps - caps descriptor 92224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @codecs: pointer to array of codecs 93224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @direction: direction supported. Of type snd_compr_direction 94224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @min_fragment_size: minimum fragment supported by DSP 95224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @max_fragment_size: maximum fragment supported by DSP 96224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @min_fragments: min fragments supported by DSP 97224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @max_fragments: max fragments supported by DSP 98224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @num_codecs: number of codecs supported 99224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @reserved: reserved field 100224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 101224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstruct snd_compr_caps { 102224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 num_codecs; 103224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 direction; 104224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 min_fragment_size; 105224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 max_fragment_size; 106224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 min_fragments; 107224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 max_fragments; 108224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 codecs[MAX_NUM_CODECS]; 109224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 reserved[11]; 110314752488cb92b9f86028836d0b8eabd8acb6a7cChristopher Ferris} __attribute__((packed, aligned(4))); 111224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 112224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/** 11312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * struct snd_compr_codec_caps - query capability of codec 114224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @codec: codec for which capability is queried 115224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @num_descriptors: number of codec descriptors 116224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @descriptor: array of codec capability descriptor 117224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 118224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstruct snd_compr_codec_caps { 119224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 codec; 120224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 num_descriptors; 121224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS]; 122314752488cb92b9f86028836d0b8eabd8acb6a7cChristopher Ferris} __attribute__((packed, aligned(4))); 123224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 124224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/** 12512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * enum sndrv_compress_encoder 126224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the 127224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * end of the track 128224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the 129224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * beginning of the track 130224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 13112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisenum sndrv_compress_encoder { 132224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng SNDRV_COMPRESS_ENCODER_PADDING = 1, 133224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng SNDRV_COMPRESS_ENCODER_DELAY = 2, 134224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng}; 135224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 136224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/** 13712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * struct snd_compr_metadata - compressed stream metadata 138224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @key: key id 139224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * @value: key value 140224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 141224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstruct snd_compr_metadata { 142224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 key; 143224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng __u32 value[8]; 144314752488cb92b9f86028836d0b8eabd8acb6a7cChristopher Ferris} __attribute__((packed, aligned(4))); 145224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng 146224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/** 147224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * compress path ioctl definitions 148224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_GET_CAPS: Query capability of DSP 149224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec 150224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_SET_PARAMS: Set codec and stream parameters 151224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * Note: only codec params can be changed runtime and stream params cant be 152224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_GET_PARAMS: Query codec params 153224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_TSTAMP: get the current timestamp value 154224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_AVAIL: get the current buffer avail value. 155224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * This also queries the tstamp properties 156224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_PAUSE: Pause the running stream 157224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_RESUME: resume a paused stream 158224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_START: Start a stream 159224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content 160224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * and the buffers currently with DSP 161224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that 162224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * SNDRV_COMPRESS_IOCTL_VERSION: Query the API version 163224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 164224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int) 165224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_GET_CAPS _IOWR('C', 0x10, struct snd_compr_caps) 166224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_GET_CODEC_CAPS _IOWR('C', 0x11,\ 167224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng struct snd_compr_codec_caps) 168224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_SET_PARAMS _IOW('C', 0x12, struct snd_compr_params) 169224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_GET_PARAMS _IOR('C', 0x13, struct snd_codec) 170224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_SET_METADATA _IOW('C', 0x14,\ 171224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng struct snd_compr_metadata) 172224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_GET_METADATA _IOWR('C', 0x15,\ 173224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng struct snd_compr_metadata) 174224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp) 175224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail) 176224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_PAUSE _IO('C', 0x30) 177224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_RESUME _IO('C', 0x31) 178224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_START _IO('C', 0x32) 179224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_STOP _IO('C', 0x33) 180224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_DRAIN _IO('C', 0x34) 181224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_NEXT_TRACK _IO('C', 0x35) 182224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SNDRV_COMPRESS_PARTIAL_DRAIN _IO('C', 0x36) 183224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/* 184224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * TODO 185224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * 1. add mmap support 186224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng * 187224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng */ 188224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SND_COMPR_TRIGGER_DRAIN 7 /*FIXME move this to pcm.h */ 189224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SND_COMPR_TRIGGER_NEXT_TRACK 8 190224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SND_COMPR_TRIGGER_PARTIAL_DRAIN 9 191224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#endif 192