2017-11-01 15:09:13 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
2011-12-23 10:36:38 +05:30
|
|
|
/*
|
|
|
|
* compress_offload.h - compress offload header definations
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Intel Corporation
|
|
|
|
* Authors: Vinod Koul <vinod.koul@linux.intel.com>
|
|
|
|
* Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
|
|
|
|
*/
|
|
|
|
#ifndef __COMPRESS_OFFLOAD_H
|
|
|
|
#define __COMPRESS_OFFLOAD_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <sound/asound.h>
|
|
|
|
#include <sound/compress_params.h>
|
|
|
|
|
|
|
|
|
2024-10-02 11:39:04 +02:00
|
|
|
#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 3, 0)
|
2011-12-23 10:36:38 +05:30
|
|
|
/**
|
2014-10-29 08:22:05 +01:00
|
|
|
* struct snd_compressed_buffer - compressed buffer
|
2011-12-23 10:36:38 +05:30
|
|
|
* @fragment_size: size of buffer fragment in bytes
|
|
|
|
* @fragments: number of such fragments
|
|
|
|
*/
|
|
|
|
struct snd_compressed_buffer {
|
|
|
|
__u32 fragment_size;
|
|
|
|
__u32 fragments;
|
2014-06-19 14:41:00 +05:30
|
|
|
} __attribute__((packed, aligned(4)));
|
2011-12-23 10:36:38 +05:30
|
|
|
|
|
|
|
/**
|
2014-10-29 08:22:05 +01:00
|
|
|
* struct snd_compr_params - compressed stream params
|
2011-12-23 10:36:38 +05:30
|
|
|
* @buffer: buffer description
|
|
|
|
* @codec: codec parameters
|
|
|
|
* @no_wake_mode: dont wake on fragment elapsed
|
|
|
|
*/
|
|
|
|
struct snd_compr_params {
|
|
|
|
struct snd_compressed_buffer buffer;
|
|
|
|
struct snd_codec codec;
|
|
|
|
__u8 no_wake_mode;
|
2014-06-19 14:41:00 +05:30
|
|
|
} __attribute__((packed, aligned(4)));
|
2011-12-23 10:36:38 +05:30
|
|
|
|
|
|
|
/**
|
2014-10-29 08:22:05 +01:00
|
|
|
* struct snd_compr_tstamp - timestamp descriptor
|
2011-12-23 10:36:38 +05:30
|
|
|
* @byte_offset: Byte offset in ring buffer to DSP
|
|
|
|
* @copied_total: Total number of bytes copied from/to ring buffer to/by DSP
|
|
|
|
* @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by
|
|
|
|
* large steps and should only be used to monitor encoding/decoding
|
|
|
|
* progress. It shall not be used for timing estimates.
|
|
|
|
* @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio
|
|
|
|
* output/input. This field should be used for A/V sync or time estimates.
|
|
|
|
* @sampling_rate: sampling rate of audio
|
|
|
|
*/
|
|
|
|
struct snd_compr_tstamp {
|
|
|
|
__u32 byte_offset;
|
|
|
|
__u32 copied_total;
|
2013-12-10 12:15:52 +01:00
|
|
|
__u32 pcm_frames;
|
|
|
|
__u32 pcm_io_frames;
|
2011-12-23 10:36:38 +05:30
|
|
|
__u32 sampling_rate;
|
2014-06-19 14:41:00 +05:30
|
|
|
} __attribute__((packed, aligned(4)));
|
2011-12-23 10:36:38 +05:30
|
|
|
|
|
|
|
/**
|
2014-10-29 08:22:05 +01:00
|
|
|
* struct snd_compr_avail - avail descriptor
|
2011-12-23 10:36:38 +05:30
|
|
|
* @avail: Number of bytes available in ring buffer for writing/reading
|
2015-03-04 10:56:13 +09:00
|
|
|
* @tstamp: timestamp information
|
2011-12-23 10:36:38 +05:30
|
|
|
*/
|
|
|
|
struct snd_compr_avail {
|
|
|
|
__u64 avail;
|
|
|
|
struct snd_compr_tstamp tstamp;
|
2014-06-19 14:41:00 +05:30
|
|
|
} __attribute__((packed, aligned(4)));
|
2011-12-23 10:36:38 +05:30
|
|
|
|
|
|
|
enum snd_compr_direction {
|
|
|
|
SND_COMPRESS_PLAYBACK = 0,
|
2024-10-02 11:39:04 +02:00
|
|
|
SND_COMPRESS_CAPTURE,
|
|
|
|
SND_COMPRESS_ACCEL
|
2011-12-23 10:36:38 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-10-29 08:22:05 +01:00
|
|
|
* struct snd_compr_caps - caps descriptor
|
2011-12-23 10:36:38 +05:30
|
|
|
* @codecs: pointer to array of codecs
|
|
|
|
* @direction: direction supported. Of type snd_compr_direction
|
|
|
|
* @min_fragment_size: minimum fragment supported by DSP
|
|
|
|
* @max_fragment_size: maximum fragment supported by DSP
|
|
|
|
* @min_fragments: min fragments supported by DSP
|
|
|
|
* @max_fragments: max fragments supported by DSP
|
|
|
|
* @num_codecs: number of codecs supported
|
|
|
|
* @reserved: reserved field
|
|
|
|
*/
|
|
|
|
struct snd_compr_caps {
|
|
|
|
__u32 num_codecs;
|
|
|
|
__u32 direction;
|
|
|
|
__u32 min_fragment_size;
|
|
|
|
__u32 max_fragment_size;
|
|
|
|
__u32 min_fragments;
|
|
|
|
__u32 max_fragments;
|
|
|
|
__u32 codecs[MAX_NUM_CODECS];
|
|
|
|
__u32 reserved[11];
|
2014-06-19 14:41:00 +05:30
|
|
|
} __attribute__((packed, aligned(4)));
|
2011-12-23 10:36:38 +05:30
|
|
|
|
|
|
|
/**
|
2014-10-29 08:22:05 +01:00
|
|
|
* struct snd_compr_codec_caps - query capability of codec
|
2011-12-23 10:36:38 +05:30
|
|
|
* @codec: codec for which capability is queried
|
|
|
|
* @num_descriptors: number of codec descriptors
|
|
|
|
* @descriptor: array of codec capability descriptor
|
|
|
|
*/
|
|
|
|
struct snd_compr_codec_caps {
|
|
|
|
__u32 codec;
|
|
|
|
__u32 num_descriptors;
|
|
|
|
struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS];
|
2014-06-19 14:41:00 +05:30
|
|
|
} __attribute__((packed, aligned(4)));
|
2011-12-23 10:36:38 +05:30
|
|
|
|
2013-02-14 16:52:51 +05:30
|
|
|
/**
|
2022-07-13 12:47:56 +02:00
|
|
|
* enum sndrv_compress_encoder - encoder metadata key
|
2013-02-14 16:52:51 +05:30
|
|
|
* @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the
|
|
|
|
* end of the track
|
|
|
|
* @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the
|
|
|
|
* beginning of the track
|
|
|
|
*/
|
2014-10-29 08:22:05 +01:00
|
|
|
enum sndrv_compress_encoder {
|
2013-02-14 16:52:51 +05:30
|
|
|
SNDRV_COMPRESS_ENCODER_PADDING = 1,
|
|
|
|
SNDRV_COMPRESS_ENCODER_DELAY = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-10-29 08:22:05 +01:00
|
|
|
* struct snd_compr_metadata - compressed stream metadata
|
2013-02-14 16:52:51 +05:30
|
|
|
* @key: key id
|
|
|
|
* @value: key value
|
|
|
|
*/
|
|
|
|
struct snd_compr_metadata {
|
|
|
|
__u32 key;
|
|
|
|
__u32 value[8];
|
2014-06-19 14:41:00 +05:30
|
|
|
} __attribute__((packed, aligned(4)));
|
2013-02-14 16:52:51 +05:30
|
|
|
|
2024-10-02 11:39:04 +02:00
|
|
|
/* flags for struct snd_compr_task */
|
|
|
|
#define SND_COMPRESS_TFLG_NEW_STREAM (1<<0) /* mark for the new stream data */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct snd_compr_task - task primitive for non-realtime operation
|
|
|
|
* @seqno: sequence number (task identifier)
|
|
|
|
* @origin_seqno: previous sequence number (task identifier) - for reuse
|
|
|
|
* @input_fd: data input file descriptor (dma-buf)
|
|
|
|
* @output_fd: data output file descriptor (dma-buf)
|
|
|
|
* @input_size: filled data in bytes (from caller, must not exceed fragment size)
|
|
|
|
* @flags: see SND_COMPRESS_TFLG_* defines
|
2024-11-13 08:23:03 +01:00
|
|
|
* @reserved: reserved for future extension
|
2024-10-02 11:39:04 +02:00
|
|
|
*/
|
|
|
|
struct snd_compr_task {
|
|
|
|
__u64 seqno;
|
|
|
|
__u64 origin_seqno;
|
|
|
|
int input_fd;
|
|
|
|
int output_fd;
|
|
|
|
__u64 input_size;
|
|
|
|
__u32 flags;
|
|
|
|
__u8 reserved[16];
|
|
|
|
} __attribute__((packed, aligned(4)));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* enum snd_compr_state - task state
|
|
|
|
* @SND_COMPRESS_TASK_STATE_IDLE: task is not queued
|
|
|
|
* @SND_COMPRESS_TASK_STATE_ACTIVE: task is in the queue
|
|
|
|
* @SND_COMPRESS_TASK_STATE_FINISHED: task was processed, output is available
|
|
|
|
*/
|
|
|
|
enum snd_compr_state {
|
|
|
|
SND_COMPRESS_TASK_STATE_IDLE = 0,
|
|
|
|
SND_COMPRESS_TASK_STATE_ACTIVE,
|
|
|
|
SND_COMPRESS_TASK_STATE_FINISHED
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct snd_compr_task_status - task status
|
|
|
|
* @seqno: sequence number (task identifier)
|
|
|
|
* @input_size: filled data in bytes (from user space)
|
|
|
|
* @output_size: filled data in bytes (from driver)
|
|
|
|
* @output_flags: reserved for future (all zeros - from driver)
|
|
|
|
* @state: actual task state (SND_COMPRESS_TASK_STATE_*)
|
2024-11-13 08:23:03 +01:00
|
|
|
* @reserved: reserved for future extension
|
2024-10-02 11:39:04 +02:00
|
|
|
*/
|
|
|
|
struct snd_compr_task_status {
|
|
|
|
__u64 seqno;
|
|
|
|
__u64 input_size;
|
|
|
|
__u64 output_size;
|
|
|
|
__u32 output_flags;
|
|
|
|
__u8 state;
|
|
|
|
__u8 reserved[15];
|
|
|
|
} __attribute__((packed, aligned(4)));
|
|
|
|
|
2020-10-23 18:33:35 +02:00
|
|
|
/*
|
2011-12-23 10:36:38 +05:30
|
|
|
* compress path ioctl definitions
|
|
|
|
* SNDRV_COMPRESS_GET_CAPS: Query capability of DSP
|
|
|
|
* SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec
|
|
|
|
* SNDRV_COMPRESS_SET_PARAMS: Set codec and stream parameters
|
|
|
|
* Note: only codec params can be changed runtime and stream params cant be
|
|
|
|
* SNDRV_COMPRESS_GET_PARAMS: Query codec params
|
|
|
|
* SNDRV_COMPRESS_TSTAMP: get the current timestamp value
|
|
|
|
* SNDRV_COMPRESS_AVAIL: get the current buffer avail value.
|
|
|
|
* This also queries the tstamp properties
|
|
|
|
* SNDRV_COMPRESS_PAUSE: Pause the running stream
|
|
|
|
* SNDRV_COMPRESS_RESUME: resume a paused stream
|
|
|
|
* SNDRV_COMPRESS_START: Start a stream
|
|
|
|
* SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content
|
|
|
|
* and the buffers currently with DSP
|
|
|
|
* SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that
|
|
|
|
* SNDRV_COMPRESS_IOCTL_VERSION: Query the API version
|
|
|
|
*/
|
|
|
|
#define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int)
|
|
|
|
#define SNDRV_COMPRESS_GET_CAPS _IOWR('C', 0x10, struct snd_compr_caps)
|
|
|
|
#define SNDRV_COMPRESS_GET_CODEC_CAPS _IOWR('C', 0x11,\
|
|
|
|
struct snd_compr_codec_caps)
|
|
|
|
#define SNDRV_COMPRESS_SET_PARAMS _IOW('C', 0x12, struct snd_compr_params)
|
|
|
|
#define SNDRV_COMPRESS_GET_PARAMS _IOR('C', 0x13, struct snd_codec)
|
2013-02-14 16:52:51 +05:30
|
|
|
#define SNDRV_COMPRESS_SET_METADATA _IOW('C', 0x14,\
|
|
|
|
struct snd_compr_metadata)
|
|
|
|
#define SNDRV_COMPRESS_GET_METADATA _IOWR('C', 0x15,\
|
|
|
|
struct snd_compr_metadata)
|
2011-12-23 10:36:38 +05:30
|
|
|
#define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp)
|
|
|
|
#define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail)
|
|
|
|
#define SNDRV_COMPRESS_PAUSE _IO('C', 0x30)
|
|
|
|
#define SNDRV_COMPRESS_RESUME _IO('C', 0x31)
|
|
|
|
#define SNDRV_COMPRESS_START _IO('C', 0x32)
|
|
|
|
#define SNDRV_COMPRESS_STOP _IO('C', 0x33)
|
|
|
|
#define SNDRV_COMPRESS_DRAIN _IO('C', 0x34)
|
2013-02-14 16:52:51 +05:30
|
|
|
#define SNDRV_COMPRESS_NEXT_TRACK _IO('C', 0x35)
|
|
|
|
#define SNDRV_COMPRESS_PARTIAL_DRAIN _IO('C', 0x36)
|
2024-10-02 11:39:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
#define SNDRV_COMPRESS_TASK_CREATE _IOWR('C', 0x60, struct snd_compr_task)
|
|
|
|
#define SNDRV_COMPRESS_TASK_FREE _IOW('C', 0x61, __u64)
|
|
|
|
#define SNDRV_COMPRESS_TASK_START _IOWR('C', 0x62, struct snd_compr_task)
|
|
|
|
#define SNDRV_COMPRESS_TASK_STOP _IOW('C', 0x63, __u64)
|
|
|
|
#define SNDRV_COMPRESS_TASK_STATUS _IOWR('C', 0x68, struct snd_compr_task_status)
|
|
|
|
|
2011-12-23 10:36:38 +05:30
|
|
|
/*
|
|
|
|
* TODO
|
|
|
|
* 1. add mmap support
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define SND_COMPR_TRIGGER_DRAIN 7 /*FIXME move this to pcm.h */
|
2013-02-14 16:52:51 +05:30
|
|
|
#define SND_COMPR_TRIGGER_NEXT_TRACK 8
|
|
|
|
#define SND_COMPR_TRIGGER_PARTIAL_DRAIN 9
|
2011-12-23 10:36:38 +05:30
|
|
|
#endif
|