^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * compress_offload.h - compress offload header definations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2011 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Authors: Vinod Koul <vinod.koul@linux.intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * the Free Software Foundation; version 2 of the License.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * This program is distributed in the hope that it will be useful, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * You should have received a copy of the GNU General Public License along
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * with this program; if not, write to the Free Software Foundation, Inc.,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #ifndef __COMPRESS_OFFLOAD_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define __COMPRESS_OFFLOAD_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <sound/asound.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <sound/compress_params.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 2, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * struct snd_compressed_buffer - compressed buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * @fragment_size: size of buffer fragment in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * @fragments: number of such fragments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct snd_compressed_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) __u32 fragment_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) __u32 fragments;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) } __attribute__((packed, aligned(4)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * struct snd_compr_params - compressed stream params
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * @buffer: buffer description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * @codec: codec parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * @no_wake_mode: dont wake on fragment elapsed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct snd_compr_params {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct snd_compressed_buffer buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct snd_codec codec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) __u8 no_wake_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) } __attribute__((packed, aligned(4)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * struct snd_compr_tstamp - timestamp descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * @byte_offset: Byte offset in ring buffer to DSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * @copied_total: Total number of bytes copied from/to ring buffer to/by DSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * large steps and should only be used to monitor encoding/decoding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * progress. It shall not be used for timing estimates.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * output/input. This field should be used for A/V sync or time estimates.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * @sampling_rate: sampling rate of audio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct snd_compr_tstamp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) __u32 byte_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) __u32 copied_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) __u32 pcm_frames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) __u32 pcm_io_frames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) __u32 sampling_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) } __attribute__((packed, aligned(4)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * struct snd_compr_avail - avail descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * @avail: Number of bytes available in ring buffer for writing/reading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * @tstamp: timestamp information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct snd_compr_avail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) __u64 avail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct snd_compr_tstamp tstamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) } __attribute__((packed, aligned(4)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) enum snd_compr_direction {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) SND_COMPRESS_PLAYBACK = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) SND_COMPRESS_CAPTURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * struct snd_compr_caps - caps descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * @codecs: pointer to array of codecs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * @direction: direction supported. Of type snd_compr_direction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * @min_fragment_size: minimum fragment supported by DSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * @max_fragment_size: maximum fragment supported by DSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * @min_fragments: min fragments supported by DSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * @max_fragments: max fragments supported by DSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * @num_codecs: number of codecs supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * @reserved: reserved field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct snd_compr_caps {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) __u32 num_codecs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) __u32 direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) __u32 min_fragment_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) __u32 max_fragment_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) __u32 min_fragments;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) __u32 max_fragments;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) __u32 codecs[MAX_NUM_CODECS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) __u32 reserved[11];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) } __attribute__((packed, aligned(4)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * struct snd_compr_codec_caps - query capability of codec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * @codec: codec for which capability is queried
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * @num_descriptors: number of codec descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * @descriptor: array of codec capability descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct snd_compr_codec_caps {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) __u32 codec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) __u32 num_descriptors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) } __attribute__((packed, aligned(4)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * enum sndrv_compress_encoder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * end of the track
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * beginning of the track
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) enum sndrv_compress_encoder {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) SNDRV_COMPRESS_ENCODER_PADDING = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) SNDRV_COMPRESS_ENCODER_DELAY = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * struct snd_compr_metadata - compressed stream metadata
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * @key: key id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * @value: key value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct snd_compr_metadata {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) __u32 key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) __u32 value[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) } __attribute__((packed, aligned(4)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * compress path ioctl definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * SNDRV_COMPRESS_GET_CAPS: Query capability of DSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * SNDRV_COMPRESS_SET_PARAMS: Set codec and stream parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * Note: only codec params can be changed runtime and stream params cant be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * SNDRV_COMPRESS_GET_PARAMS: Query codec params
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * SNDRV_COMPRESS_TSTAMP: get the current timestamp value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * SNDRV_COMPRESS_AVAIL: get the current buffer avail value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * This also queries the tstamp properties
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * SNDRV_COMPRESS_PAUSE: Pause the running stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * SNDRV_COMPRESS_RESUME: resume a paused stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * SNDRV_COMPRESS_START: Start a stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * and the buffers currently with DSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * SNDRV_COMPRESS_IOCTL_VERSION: Query the API version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #define SNDRV_COMPRESS_GET_CAPS _IOWR('C', 0x10, struct snd_compr_caps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #define SNDRV_COMPRESS_GET_CODEC_CAPS _IOWR('C', 0x11,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct snd_compr_codec_caps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) #define SNDRV_COMPRESS_SET_PARAMS _IOW('C', 0x12, struct snd_compr_params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #define SNDRV_COMPRESS_GET_PARAMS _IOR('C', 0x13, struct snd_codec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #define SNDRV_COMPRESS_SET_METADATA _IOW('C', 0x14,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct snd_compr_metadata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #define SNDRV_COMPRESS_GET_METADATA _IOWR('C', 0x15,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct snd_compr_metadata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) #define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #define SNDRV_COMPRESS_PAUSE _IO('C', 0x30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) #define SNDRV_COMPRESS_RESUME _IO('C', 0x31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #define SNDRV_COMPRESS_START _IO('C', 0x32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #define SNDRV_COMPRESS_STOP _IO('C', 0x33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) #define SNDRV_COMPRESS_DRAIN _IO('C', 0x34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #define SNDRV_COMPRESS_NEXT_TRACK _IO('C', 0x35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #define SNDRV_COMPRESS_PARTIAL_DRAIN _IO('C', 0x36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * TODO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * 1. add mmap support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #define SND_COMPR_TRIGGER_DRAIN 7 /*FIXME move this to pcm.h */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #define SND_COMPR_TRIGGER_NEXT_TRACK 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #define SND_COMPR_TRIGGER_PARTIAL_DRAIN 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) #endif