Path: blob/master/include/uapi/sound/compress_offload.h
29278 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>1415#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 4, 1)16/**17* struct snd_compressed_buffer - compressed buffer18* @fragment_size: size of buffer fragment in bytes19* @fragments: number of such fragments20*/21struct snd_compressed_buffer {22__u32 fragment_size;23__u32 fragments;24} __attribute__((packed, aligned(4)));2526/**27* struct snd_compr_params - compressed stream params28* @buffer: buffer description29* @codec: codec parameters30* @no_wake_mode: dont wake on fragment elapsed31*/32struct snd_compr_params {33struct snd_compressed_buffer buffer;34struct snd_codec codec;35__u8 no_wake_mode;36} __attribute__((packed, aligned(4)));3738/**39* struct snd_compr_tstamp - timestamp descriptor40* @byte_offset: Byte offset in ring buffer to DSP41* @copied_total: Total number of bytes copied from/to ring buffer to/by DSP42* @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by43* large steps and should only be used to monitor encoding/decoding44* progress. It shall not be used for timing estimates.45* @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio46* output/input. This field should be used for A/V sync or time estimates.47* @sampling_rate: sampling rate of audio48*/49struct snd_compr_tstamp {50__u32 byte_offset;51__u32 copied_total;52__u32 pcm_frames;53__u32 pcm_io_frames;54__u32 sampling_rate;55} __attribute__((packed, aligned(4)));5657/**58* struct snd_compr_tstamp64 - timestamp descriptor with fields in 64 bit59* @byte_offset: Byte offset in ring buffer to DSP60* @copied_total: Total number of bytes copied from/to ring buffer to/by DSP61* @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by62* large steps and should only be used to monitor encoding/decoding63* progress. It shall not be used for timing estimates.64* @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio65* output/input. This field should be used for A/V sync or time estimates.66* @sampling_rate: sampling rate of audio67*/68struct snd_compr_tstamp64 {69__u32 byte_offset;70__u64 copied_total;71__u64 pcm_frames;72__u64 pcm_io_frames;73__u32 sampling_rate;74} __attribute__((packed, aligned(4)));7576/**77* struct snd_compr_avail - avail descriptor78* @avail: Number of bytes available in ring buffer for writing/reading79* @tstamp: timestamp information80*/81struct snd_compr_avail {82__u64 avail;83struct snd_compr_tstamp tstamp;84} __attribute__((packed, aligned(4)));8586/**87* struct snd_compr_avail64 - avail descriptor with tstamp in 64 bit format88* @avail: Number of bytes available in ring buffer for writing/reading89* @tstamp: timestamp information90*/91struct snd_compr_avail64 {92__u64 avail;93struct snd_compr_tstamp64 tstamp;94} __attribute__((packed, aligned(4)));9596enum snd_compr_direction {97SND_COMPRESS_PLAYBACK = 0,98SND_COMPRESS_CAPTURE,99SND_COMPRESS_ACCEL100};101102/**103* struct snd_compr_caps - caps descriptor104* @codecs: pointer to array of codecs105* @direction: direction supported. Of type snd_compr_direction106* @min_fragment_size: minimum fragment supported by DSP107* @max_fragment_size: maximum fragment supported by DSP108* @min_fragments: min fragments supported by DSP109* @max_fragments: max fragments supported by DSP110* @num_codecs: number of codecs supported111* @reserved: reserved field112*/113struct snd_compr_caps {114__u32 num_codecs;115__u32 direction;116__u32 min_fragment_size;117__u32 max_fragment_size;118__u32 min_fragments;119__u32 max_fragments;120__u32 codecs[MAX_NUM_CODECS];121__u32 reserved[11];122} __attribute__((packed, aligned(4)));123124/**125* struct snd_compr_codec_caps - query capability of codec126* @codec: codec for which capability is queried127* @num_descriptors: number of codec descriptors128* @descriptor: array of codec capability descriptor129*/130struct snd_compr_codec_caps {131__u32 codec;132__u32 num_descriptors;133struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS];134} __attribute__((packed, aligned(4)));135136/**137* enum sndrv_compress_encoder - encoder metadata key138* @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the139* end of the track140* @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the141* beginning of the track142*/143enum sndrv_compress_encoder {144SNDRV_COMPRESS_ENCODER_PADDING = 1,145SNDRV_COMPRESS_ENCODER_DELAY = 2,146};147148/**149* struct snd_compr_metadata - compressed stream metadata150* @key: key id151* @value: key value152*/153struct snd_compr_metadata {154__u32 key;155__u32 value[8];156} __attribute__((packed, aligned(4)));157158/* flags for struct snd_compr_task */159#define SND_COMPRESS_TFLG_NEW_STREAM (1<<0) /* mark for the new stream data */160161/**162* struct snd_compr_task - task primitive for non-realtime operation163* @seqno: sequence number (task identifier)164* @origin_seqno: previous sequence number (task identifier) - for reuse165* @input_fd: data input file descriptor (dma-buf)166* @output_fd: data output file descriptor (dma-buf)167* @input_size: filled data in bytes (from caller, must not exceed fragment size)168* @flags: see SND_COMPRESS_TFLG_* defines169* @reserved: reserved for future extension170*/171struct snd_compr_task {172__u64 seqno;173__u64 origin_seqno;174int input_fd;175int output_fd;176__u64 input_size;177__u32 flags;178__u8 reserved[16];179} __attribute__((packed, aligned(4)));180181/**182* enum snd_compr_state - task state183* @SND_COMPRESS_TASK_STATE_IDLE: task is not queued184* @SND_COMPRESS_TASK_STATE_ACTIVE: task is in the queue185* @SND_COMPRESS_TASK_STATE_FINISHED: task was processed, output is available186*/187enum snd_compr_state {188SND_COMPRESS_TASK_STATE_IDLE = 0,189SND_COMPRESS_TASK_STATE_ACTIVE,190SND_COMPRESS_TASK_STATE_FINISHED191};192193/**194* struct snd_compr_task_status - task status195* @seqno: sequence number (task identifier)196* @input_size: filled data in bytes (from user space)197* @output_size: filled data in bytes (from driver)198* @output_flags: reserved for future (all zeros - from driver)199* @state: actual task state (SND_COMPRESS_TASK_STATE_*)200* @reserved: reserved for future extension201*/202struct snd_compr_task_status {203__u64 seqno;204__u64 input_size;205__u64 output_size;206__u32 output_flags;207__u8 state;208__u8 reserved[15];209} __attribute__((packed, aligned(4)));210211/*212* compress path ioctl definitions213* SNDRV_COMPRESS_GET_CAPS: Query capability of DSP214* SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec215* SNDRV_COMPRESS_SET_PARAMS: Set codec and stream parameters216* Note: only codec params can be changed runtime and stream params cant be217* SNDRV_COMPRESS_GET_PARAMS: Query codec params218* SNDRV_COMPRESS_TSTAMP: get the current timestamp value219* SNDRV_COMPRESS_TSTAMP64: get the current timestamp value in 64 bit format220* SNDRV_COMPRESS_AVAIL: get the current buffer avail value.221* This also queries the tstamp properties222* SNDRV_COMPRESS_PAUSE: Pause the running stream223* SNDRV_COMPRESS_RESUME: resume a paused stream224* SNDRV_COMPRESS_START: Start a stream225* SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content226* and the buffers currently with DSP227* SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that228* SNDRV_COMPRESS_IOCTL_VERSION: Query the API version229*/230#define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int)231#define SNDRV_COMPRESS_GET_CAPS _IOWR('C', 0x10, struct snd_compr_caps)232#define SNDRV_COMPRESS_GET_CODEC_CAPS _IOWR('C', 0x11,\233struct snd_compr_codec_caps)234#define SNDRV_COMPRESS_SET_PARAMS _IOW('C', 0x12, struct snd_compr_params)235#define SNDRV_COMPRESS_GET_PARAMS _IOR('C', 0x13, struct snd_codec)236#define SNDRV_COMPRESS_SET_METADATA _IOW('C', 0x14,\237struct snd_compr_metadata)238#define SNDRV_COMPRESS_GET_METADATA _IOWR('C', 0x15,\239struct snd_compr_metadata)240#define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp)241#define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail)242#define SNDRV_COMPRESS_TSTAMP64 _IOR('C', 0x22, struct snd_compr_tstamp64)243#define SNDRV_COMPRESS_AVAIL64 _IOR('C', 0x23, struct snd_compr_avail64)244#define SNDRV_COMPRESS_PAUSE _IO('C', 0x30)245#define SNDRV_COMPRESS_RESUME _IO('C', 0x31)246#define SNDRV_COMPRESS_START _IO('C', 0x32)247#define SNDRV_COMPRESS_STOP _IO('C', 0x33)248#define SNDRV_COMPRESS_DRAIN _IO('C', 0x34)249#define SNDRV_COMPRESS_NEXT_TRACK _IO('C', 0x35)250#define SNDRV_COMPRESS_PARTIAL_DRAIN _IO('C', 0x36)251252253#define SNDRV_COMPRESS_TASK_CREATE _IOWR('C', 0x60, struct snd_compr_task)254#define SNDRV_COMPRESS_TASK_FREE _IOW('C', 0x61, __u64)255#define SNDRV_COMPRESS_TASK_START _IOWR('C', 0x62, struct snd_compr_task)256#define SNDRV_COMPRESS_TASK_STOP _IOW('C', 0x63, __u64)257#define SNDRV_COMPRESS_TASK_STATUS _IOWR('C', 0x68, struct snd_compr_task_status)258259/*260* TODO261* 1. add mmap support262*263*/264#define SND_COMPR_TRIGGER_DRAIN 7 /*FIXME move this to pcm.h */265#define SND_COMPR_TRIGGER_NEXT_TRACK 8266#define SND_COMPR_TRIGGER_PARTIAL_DRAIN 9267#endif268269270