Path: blob/master/include/uapi/sound/compress_offload.h
26289 views
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */1/*2* compress_offload.h - compress offload header definations3*4* Copyright (C) 2011 Intel Corporation5* Authors: Vinod Koul <[email protected]>6* Pierre-Louis Bossart <[email protected]>7*/8#ifndef __COMPRESS_OFFLOAD_H9#define __COMPRESS_OFFLOAD_H1011#include <linux/types.h>12#include <sound/asound.h>13#include <sound/compress_params.h>141516#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 3, 0)17/**18* struct snd_compressed_buffer - compressed buffer19* @fragment_size: size of buffer fragment in bytes20* @fragments: number of such fragments21*/22struct snd_compressed_buffer {23__u32 fragment_size;24__u32 fragments;25} __attribute__((packed, aligned(4)));2627/**28* struct snd_compr_params - compressed stream params29* @buffer: buffer description30* @codec: codec parameters31* @no_wake_mode: dont wake on fragment elapsed32*/33struct snd_compr_params {34struct snd_compressed_buffer buffer;35struct snd_codec codec;36__u8 no_wake_mode;37} __attribute__((packed, aligned(4)));3839/**40* struct snd_compr_tstamp - timestamp descriptor41* @byte_offset: Byte offset in ring buffer to DSP42* @copied_total: Total number of bytes copied from/to ring buffer to/by DSP43* @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by44* large steps and should only be used to monitor encoding/decoding45* progress. It shall not be used for timing estimates.46* @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio47* output/input. This field should be used for A/V sync or time estimates.48* @sampling_rate: sampling rate of audio49*/50struct 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)));5758/**59* struct snd_compr_avail - avail descriptor60* @avail: Number of bytes available in ring buffer for writing/reading61* @tstamp: timestamp information62*/63struct snd_compr_avail {64__u64 avail;65struct snd_compr_tstamp tstamp;66} __attribute__((packed, aligned(4)));6768enum snd_compr_direction {69SND_COMPRESS_PLAYBACK = 0,70SND_COMPRESS_CAPTURE,71SND_COMPRESS_ACCEL72};7374/**75* struct snd_compr_caps - caps descriptor76* @codecs: pointer to array of codecs77* @direction: direction supported. Of type snd_compr_direction78* @min_fragment_size: minimum fragment supported by DSP79* @max_fragment_size: maximum fragment supported by DSP80* @min_fragments: min fragments supported by DSP81* @max_fragments: max fragments supported by DSP82* @num_codecs: number of codecs supported83* @reserved: reserved field84*/85struct snd_compr_caps {86__u32 num_codecs;87__u32 direction;88__u32 min_fragment_size;89__u32 max_fragment_size;90__u32 min_fragments;91__u32 max_fragments;92__u32 codecs[MAX_NUM_CODECS];93__u32 reserved[11];94} __attribute__((packed, aligned(4)));9596/**97* struct snd_compr_codec_caps - query capability of codec98* @codec: codec for which capability is queried99* @num_descriptors: number of codec descriptors100* @descriptor: array of codec capability descriptor101*/102struct snd_compr_codec_caps {103__u32 codec;104__u32 num_descriptors;105struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS];106} __attribute__((packed, aligned(4)));107108/**109* enum sndrv_compress_encoder - encoder metadata key110* @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the111* end of the track112* @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the113* beginning of the track114*/115enum sndrv_compress_encoder {116SNDRV_COMPRESS_ENCODER_PADDING = 1,117SNDRV_COMPRESS_ENCODER_DELAY = 2,118};119120/**121* struct snd_compr_metadata - compressed stream metadata122* @key: key id123* @value: key value124*/125struct snd_compr_metadata {126__u32 key;127__u32 value[8];128} __attribute__((packed, aligned(4)));129130/* flags for struct snd_compr_task */131#define SND_COMPRESS_TFLG_NEW_STREAM (1<<0) /* mark for the new stream data */132133/**134* struct snd_compr_task - task primitive for non-realtime operation135* @seqno: sequence number (task identifier)136* @origin_seqno: previous sequence number (task identifier) - for reuse137* @input_fd: data input file descriptor (dma-buf)138* @output_fd: data output file descriptor (dma-buf)139* @input_size: filled data in bytes (from caller, must not exceed fragment size)140* @flags: see SND_COMPRESS_TFLG_* defines141* @reserved: reserved for future extension142*/143struct snd_compr_task {144__u64 seqno;145__u64 origin_seqno;146int input_fd;147int output_fd;148__u64 input_size;149__u32 flags;150__u8 reserved[16];151} __attribute__((packed, aligned(4)));152153/**154* enum snd_compr_state - task state155* @SND_COMPRESS_TASK_STATE_IDLE: task is not queued156* @SND_COMPRESS_TASK_STATE_ACTIVE: task is in the queue157* @SND_COMPRESS_TASK_STATE_FINISHED: task was processed, output is available158*/159enum snd_compr_state {160SND_COMPRESS_TASK_STATE_IDLE = 0,161SND_COMPRESS_TASK_STATE_ACTIVE,162SND_COMPRESS_TASK_STATE_FINISHED163};164165/**166* struct snd_compr_task_status - task status167* @seqno: sequence number (task identifier)168* @input_size: filled data in bytes (from user space)169* @output_size: filled data in bytes (from driver)170* @output_flags: reserved for future (all zeros - from driver)171* @state: actual task state (SND_COMPRESS_TASK_STATE_*)172* @reserved: reserved for future extension173*/174struct snd_compr_task_status {175__u64 seqno;176__u64 input_size;177__u64 output_size;178__u32 output_flags;179__u8 state;180__u8 reserved[15];181} __attribute__((packed, aligned(4)));182183/*184* compress path ioctl definitions185* SNDRV_COMPRESS_GET_CAPS: Query capability of DSP186* SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec187* SNDRV_COMPRESS_SET_PARAMS: Set codec and stream parameters188* Note: only codec params can be changed runtime and stream params cant be189* SNDRV_COMPRESS_GET_PARAMS: Query codec params190* SNDRV_COMPRESS_TSTAMP: get the current timestamp value191* SNDRV_COMPRESS_AVAIL: get the current buffer avail value.192* This also queries the tstamp properties193* SNDRV_COMPRESS_PAUSE: Pause the running stream194* SNDRV_COMPRESS_RESUME: resume a paused stream195* SNDRV_COMPRESS_START: Start a stream196* SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content197* and the buffers currently with DSP198* SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that199* SNDRV_COMPRESS_IOCTL_VERSION: Query the API version200*/201#define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int)202#define SNDRV_COMPRESS_GET_CAPS _IOWR('C', 0x10, struct snd_compr_caps)203#define SNDRV_COMPRESS_GET_CODEC_CAPS _IOWR('C', 0x11,\204struct snd_compr_codec_caps)205#define SNDRV_COMPRESS_SET_PARAMS _IOW('C', 0x12, struct snd_compr_params)206#define SNDRV_COMPRESS_GET_PARAMS _IOR('C', 0x13, struct snd_codec)207#define SNDRV_COMPRESS_SET_METADATA _IOW('C', 0x14,\208struct snd_compr_metadata)209#define SNDRV_COMPRESS_GET_METADATA _IOWR('C', 0x15,\210struct snd_compr_metadata)211#define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp)212#define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail)213#define SNDRV_COMPRESS_PAUSE _IO('C', 0x30)214#define SNDRV_COMPRESS_RESUME _IO('C', 0x31)215#define SNDRV_COMPRESS_START _IO('C', 0x32)216#define SNDRV_COMPRESS_STOP _IO('C', 0x33)217#define SNDRV_COMPRESS_DRAIN _IO('C', 0x34)218#define SNDRV_COMPRESS_NEXT_TRACK _IO('C', 0x35)219#define SNDRV_COMPRESS_PARTIAL_DRAIN _IO('C', 0x36)220221222#define SNDRV_COMPRESS_TASK_CREATE _IOWR('C', 0x60, struct snd_compr_task)223#define SNDRV_COMPRESS_TASK_FREE _IOW('C', 0x61, __u64)224#define SNDRV_COMPRESS_TASK_START _IOWR('C', 0x62, struct snd_compr_task)225#define SNDRV_COMPRESS_TASK_STOP _IOW('C', 0x63, __u64)226#define SNDRV_COMPRESS_TASK_STATUS _IOWR('C', 0x68, struct snd_compr_task_status)227228/*229* TODO230* 1. add mmap support231*232*/233#define SND_COMPR_TRIGGER_DRAIN 7 /*FIXME move this to pcm.h */234#define SND_COMPR_TRIGGER_NEXT_TRACK 8235#define SND_COMPR_TRIGGER_PARTIAL_DRAIN 9236#endif237238239