linux/include/sound/pcm.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef __SOUND_PCM_H
#define __SOUND_PCM_H

/*
 *  Digital Audio (PCM) abstract layer
 *  Copyright (c) by Jaroslav Kysela <[email protected]>
 *                   Abramo Bagnara <[email protected]>
 */

#include <sound/asound.h>
#include <sound/memalloc.h>
#include <sound/minors.h>
#include <linux/poll.h>
#include <linux/mm.h>
#include <linux/bitops.h>
#include <linux/pm_qos.h>
#include <linux/refcount.h>
#include <linux/uio.h>

#define snd_pcm_substream_chip(substream)
#define snd_pcm_chip(pcm)

#if IS_ENABLED(CONFIG_SND_PCM_OSS)
#include <sound/pcm_oss.h>
#endif

/*
 *  Hardware (lowlevel) section
 */

struct snd_pcm_hardware {};

struct snd_pcm_status64;
struct snd_pcm_substream;

struct snd_pcm_audio_tstamp_config; /* definitions further down */
struct snd_pcm_audio_tstamp_report;

struct snd_pcm_ops {};

/*
 *
 */

#if defined(CONFIG_SND_DYNAMIC_MINORS)
#define SNDRV_PCM_DEVICES
#else
#define SNDRV_PCM_DEVICES
#endif

#define SNDRV_PCM_IOCTL1_RESET
/* 1 is absent slot. */
#define SNDRV_PCM_IOCTL1_CHANNEL_INFO
/* 3 is absent slot. */
#define SNDRV_PCM_IOCTL1_FIFO_SIZE
#define SNDRV_PCM_IOCTL1_SYNC_ID

#define SNDRV_PCM_TRIGGER_STOP
#define SNDRV_PCM_TRIGGER_START
#define SNDRV_PCM_TRIGGER_PAUSE_PUSH
#define SNDRV_PCM_TRIGGER_PAUSE_RELEASE
#define SNDRV_PCM_TRIGGER_SUSPEND
#define SNDRV_PCM_TRIGGER_RESUME
#define SNDRV_PCM_TRIGGER_DRAIN

#define SNDRV_PCM_POS_XRUN

/* If you change this don't forget to change rates[] table in pcm_native.c */
#define SNDRV_PCM_RATE_5512
#define SNDRV_PCM_RATE_8000
#define SNDRV_PCM_RATE_11025
#define SNDRV_PCM_RATE_16000
#define SNDRV_PCM_RATE_22050
#define SNDRV_PCM_RATE_32000
#define SNDRV_PCM_RATE_44100
#define SNDRV_PCM_RATE_48000
#define SNDRV_PCM_RATE_64000
#define SNDRV_PCM_RATE_88200
#define SNDRV_PCM_RATE_96000
#define SNDRV_PCM_RATE_176400
#define SNDRV_PCM_RATE_192000
#define SNDRV_PCM_RATE_352800
#define SNDRV_PCM_RATE_384000
#define SNDRV_PCM_RATE_705600
#define SNDRV_PCM_RATE_768000
/* extended rates since 6.12 */
#define SNDRV_PCM_RATE_12000
#define SNDRV_PCM_RATE_24000
#define SNDRV_PCM_RATE_128000

#define SNDRV_PCM_RATE_CONTINUOUS
#define SNDRV_PCM_RATE_KNOT

#define SNDRV_PCM_RATE_8000_44100
#define SNDRV_PCM_RATE_8000_48000
#define SNDRV_PCM_RATE_8000_96000
#define SNDRV_PCM_RATE_8000_192000
#define SNDRV_PCM_RATE_8000_384000
#define SNDRV_PCM_RATE_8000_768000
#define _SNDRV_PCM_FMTBIT(fmt)
#define SNDRV_PCM_FMTBIT_S8
#define SNDRV_PCM_FMTBIT_U8
#define SNDRV_PCM_FMTBIT_S16_LE
#define SNDRV_PCM_FMTBIT_S16_BE
#define SNDRV_PCM_FMTBIT_U16_LE
#define SNDRV_PCM_FMTBIT_U16_BE
#define SNDRV_PCM_FMTBIT_S24_LE
#define SNDRV_PCM_FMTBIT_S24_BE
#define SNDRV_PCM_FMTBIT_U24_LE
#define SNDRV_PCM_FMTBIT_U24_BE
// For S32/U32 formats, 'msbits' hardware parameter is often used to deliver information about the
// available bit count in most significant bit. It's for the case of so-called 'left-justified' or
// `right-padding` sample which has less width than 32 bit.
#define SNDRV_PCM_FMTBIT_S32_LE
#define SNDRV_PCM_FMTBIT_S32_BE
#define SNDRV_PCM_FMTBIT_U32_LE
#define SNDRV_PCM_FMTBIT_U32_BE
#define SNDRV_PCM_FMTBIT_FLOAT_LE
#define SNDRV_PCM_FMTBIT_FLOAT_BE
#define SNDRV_PCM_FMTBIT_FLOAT64_LE
#define SNDRV_PCM_FMTBIT_FLOAT64_BE
#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE
#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE
#define SNDRV_PCM_FMTBIT_MU_LAW
#define SNDRV_PCM_FMTBIT_A_LAW
#define SNDRV_PCM_FMTBIT_IMA_ADPCM
#define SNDRV_PCM_FMTBIT_MPEG
#define SNDRV_PCM_FMTBIT_GSM
#define SNDRV_PCM_FMTBIT_S20_LE
#define SNDRV_PCM_FMTBIT_U20_LE
#define SNDRV_PCM_FMTBIT_S20_BE
#define SNDRV_PCM_FMTBIT_U20_BE
#define SNDRV_PCM_FMTBIT_SPECIAL
#define SNDRV_PCM_FMTBIT_S24_3LE
#define SNDRV_PCM_FMTBIT_U24_3LE
#define SNDRV_PCM_FMTBIT_S24_3BE
#define SNDRV_PCM_FMTBIT_U24_3BE
#define SNDRV_PCM_FMTBIT_S20_3LE
#define SNDRV_PCM_FMTBIT_U20_3LE
#define SNDRV_PCM_FMTBIT_S20_3BE
#define SNDRV_PCM_FMTBIT_U20_3BE
#define SNDRV_PCM_FMTBIT_S18_3LE
#define SNDRV_PCM_FMTBIT_U18_3LE
#define SNDRV_PCM_FMTBIT_S18_3BE
#define SNDRV_PCM_FMTBIT_U18_3BE
#define SNDRV_PCM_FMTBIT_G723_24
#define SNDRV_PCM_FMTBIT_G723_24_1B
#define SNDRV_PCM_FMTBIT_G723_40
#define SNDRV_PCM_FMTBIT_G723_40_1B
#define SNDRV_PCM_FMTBIT_DSD_U8
#define SNDRV_PCM_FMTBIT_DSD_U16_LE
#define SNDRV_PCM_FMTBIT_DSD_U32_LE
#define SNDRV_PCM_FMTBIT_DSD_U16_BE
#define SNDRV_PCM_FMTBIT_DSD_U32_BE

#ifdef SNDRV_LITTLE_ENDIAN
#define SNDRV_PCM_FMTBIT_S16
#define SNDRV_PCM_FMTBIT_U16
#define SNDRV_PCM_FMTBIT_S24
#define SNDRV_PCM_FMTBIT_U24
#define SNDRV_PCM_FMTBIT_S32
#define SNDRV_PCM_FMTBIT_U32
#define SNDRV_PCM_FMTBIT_FLOAT
#define SNDRV_PCM_FMTBIT_FLOAT64
#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME
#define SNDRV_PCM_FMTBIT_S20
#define SNDRV_PCM_FMTBIT_U20
#endif
#ifdef SNDRV_BIG_ENDIAN
#define SNDRV_PCM_FMTBIT_S16
#define SNDRV_PCM_FMTBIT_U16
#define SNDRV_PCM_FMTBIT_S24
#define SNDRV_PCM_FMTBIT_U24
#define SNDRV_PCM_FMTBIT_S32
#define SNDRV_PCM_FMTBIT_U32
#define SNDRV_PCM_FMTBIT_FLOAT
#define SNDRV_PCM_FMTBIT_FLOAT64
#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME
#define SNDRV_PCM_FMTBIT_S20
#define SNDRV_PCM_FMTBIT_U20
#endif

#define _SNDRV_PCM_SUBFMTBIT(fmt)
#define SNDRV_PCM_SUBFMTBIT_STD
#define SNDRV_PCM_SUBFMTBIT_MSBITS_MAX
#define SNDRV_PCM_SUBFMTBIT_MSBITS_20
#define SNDRV_PCM_SUBFMTBIT_MSBITS_24

struct snd_pcm_file {};

struct snd_pcm_hw_rule;
snd_pcm_hw_rule_func_t;

struct snd_pcm_hw_rule {};

struct snd_pcm_hw_constraints {};

static inline struct snd_mask *constrs_mask(struct snd_pcm_hw_constraints *constrs,
					    snd_pcm_hw_param_t var)
{}

static inline struct snd_interval *constrs_interval(struct snd_pcm_hw_constraints *constrs,
						    snd_pcm_hw_param_t var)
{}

struct snd_ratnum {};

struct snd_ratden {};

struct snd_pcm_hw_constraint_ratnums {};

struct snd_pcm_hw_constraint_ratdens {};

struct snd_pcm_hw_constraint_list {};

struct snd_pcm_hw_constraint_ranges {};

/*
 * userspace-provided audio timestamp config to kernel,
 * structure is for internal use only and filled with dedicated unpack routine
 */
struct snd_pcm_audio_tstamp_config {};

static inline void snd_pcm_unpack_audio_tstamp_config(__u32 data,
						struct snd_pcm_audio_tstamp_config *config)
{}

/*
 * kernel-provided audio timestamp report to user-space
 * structure is for internal use only and read by dedicated pack routine
 */
struct snd_pcm_audio_tstamp_report {};

static inline void snd_pcm_pack_audio_tstamp_report(__u32 *data, __u32 *accuracy,
						const struct snd_pcm_audio_tstamp_report *report)
{}


struct snd_pcm_runtime {};

struct snd_pcm_group {};

struct pid;

struct snd_pcm_substream {};

#define SUBSTREAM_BUSY(substream)


struct snd_pcm_str {};

struct snd_pcm {};

/*
 *  Registering
 */

extern const struct file_operations snd_pcm_f_ops[2];

int snd_pcm_new(struct snd_card *card, const char *id, int device,
		int playback_count, int capture_count,
		struct snd_pcm **rpcm);
int snd_pcm_new_internal(struct snd_card *card, const char *id, int device,
		int playback_count, int capture_count,
		struct snd_pcm **rpcm);
int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count);

#if IS_ENABLED(CONFIG_SND_PCM_OSS)
struct snd_pcm_notify {};
int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree);
#endif

/*
 *  Native I/O
 */

int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info);
int snd_pcm_info_user(struct snd_pcm_substream *substream,
		      struct snd_pcm_info __user *info);
int snd_pcm_status64(struct snd_pcm_substream *substream,
		     struct snd_pcm_status64 *status);
int snd_pcm_start(struct snd_pcm_substream *substream);
int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
int snd_pcm_drain_done(struct snd_pcm_substream *substream);
int snd_pcm_stop_xrun(struct snd_pcm_substream *substream);
#ifdef CONFIG_PM
int snd_pcm_suspend_all(struct snd_pcm *pcm);
#else
static inline int snd_pcm_suspend_all(struct snd_pcm *pcm)
{
	return 0;
}
#endif
int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg);
int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, struct file *file,
			   struct snd_pcm_substream **rsubstream);
void snd_pcm_release_substream(struct snd_pcm_substream *substream);
int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, struct file *file,
			     struct snd_pcm_substream **rsubstream);
void snd_pcm_detach_substream(struct snd_pcm_substream *substream);
int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area);


#ifdef CONFIG_SND_DEBUG
void snd_pcm_debug_name(struct snd_pcm_substream *substream,
			   char *name, size_t len);
#else
static inline void
snd_pcm_debug_name(struct snd_pcm_substream *substream, char *buf, size_t size)
{
	*buf = 0;
}
#endif

/*
 *  PCM library
 */

/**
 * snd_pcm_stream_linked - Check whether the substream is linked with others
 * @substream: substream to check
 *
 * Return: true if the given substream is being linked with others
 */
static inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream)
{}

void snd_pcm_stream_lock(struct snd_pcm_substream *substream);
void snd_pcm_stream_unlock(struct snd_pcm_substream *substream);
void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream);
void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream);
unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream);
unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream);

/**
 * snd_pcm_stream_lock_irqsave - Lock the PCM stream
 * @substream: PCM substream
 * @flags: irq flags
 *
 * This locks the PCM stream like snd_pcm_stream_lock() but with the local
 * IRQ (only when nonatomic is false).  In nonatomic case, this is identical
 * as snd_pcm_stream_lock().
 */
#define snd_pcm_stream_lock_irqsave(substream, flags)
void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
				      unsigned long flags);

/**
 * snd_pcm_stream_lock_irqsave_nested - Single-nested PCM stream locking
 * @substream: PCM substream
 * @flags: irq flags
 *
 * This locks the PCM stream like snd_pcm_stream_lock_irqsave() but with
 * the single-depth lockdep subclass.
 */
#define snd_pcm_stream_lock_irqsave_nested(substream, flags)

/* definitions for guard(); use like guard(pcm_stream_lock) */
DEFINE_LOCK_GUARD_1(pcm_stream_lock, struct snd_pcm_substream,
		    snd_pcm_stream_lock(_T->lock),
		    snd_pcm_stream_unlock(_T->lock))
DEFINE_LOCK_GUARD_1(pcm_stream_lock_irq, struct snd_pcm_substream,
		    snd_pcm_stream_lock_irq(_T->lock),
		    snd_pcm_stream_unlock_irq(_T->lock))
DEFINE_LOCK_GUARD_1(pcm_stream_lock_irqsave, struct snd_pcm_substream,
		    snd_pcm_stream_lock_irqsave(_T->lock, _T->flags),
		    snd_pcm_stream_unlock_irqrestore(_T->lock, _T->flags),
		    } 

/**
 * snd_pcm_group_for_each_entry - iterate over the linked substreams
 * @s: the iterator
 * @substream: the substream
 *
 * Iterate over the all linked substreams to the given @substream.
 * When @substream isn't linked with any others, this gives returns @substream
 * itself once.
 */
#define snd_pcm_group_for_each_entry(s, substream)

#define for_each_pcm_streams(stream)

/**
 * snd_pcm_running - Check whether the substream is in a running state
 * @substream: substream to check
 *
 * Return: true if the given substream is in the state RUNNING, or in the
 * state DRAINING for playback.
 */
static inline int snd_pcm_running(struct snd_pcm_substream *substream)
{}

/**
 * __snd_pcm_set_state - Change the current PCM state
 * @runtime: PCM runtime to set
 * @state: the current state to set
 *
 * Call within the stream lock
 */
static inline void __snd_pcm_set_state(struct snd_pcm_runtime *runtime,
				       snd_pcm_state_t state)
{}

/**
 * bytes_to_samples - Unit conversion of the size from bytes to samples
 * @runtime: PCM runtime instance
 * @size: size in bytes
 *
 * Return: the size in samples
 */
static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size)
{}

/**
 * bytes_to_frames - Unit conversion of the size from bytes to frames
 * @runtime: PCM runtime instance
 * @size: size in bytes
 *
 * Return: the size in frames
 */
static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size)
{}

/**
 * samples_to_bytes - Unit conversion of the size from samples to bytes
 * @runtime: PCM runtime instance
 * @size: size in samples
 *
 * Return: the byte size
 */
static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size)
{}

/**
 * frames_to_bytes - Unit conversion of the size from frames to bytes
 * @runtime: PCM runtime instance
 * @size: size in frames
 *
 * Return: the byte size
 */
static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size)
{}

/**
 * frame_aligned - Check whether the byte size is aligned to frames
 * @runtime: PCM runtime instance
 * @bytes: size in bytes
 *
 * Return: true if aligned, or false if not
 */
static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes)
{}

/**
 * snd_pcm_lib_buffer_bytes - Get the buffer size of the current PCM in bytes
 * @substream: PCM substream
 *
 * Return: buffer byte size
 */
static inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream)
{}

/**
 * snd_pcm_lib_period_bytes - Get the period size of the current PCM in bytes
 * @substream: PCM substream
 *
 * Return: period byte size
 */
static inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream)
{}

/**
 * snd_pcm_playback_avail - Get the available (writable) space for playback
 * @runtime: PCM runtime instance
 *
 * Result is between 0 ... (boundary - 1)
 *
 * Return: available frame size
 */
static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime)
{}

/**
 * snd_pcm_capture_avail - Get the available (readable) space for capture
 * @runtime: PCM runtime instance
 *
 * Result is between 0 ... (boundary - 1)
 *
 * Return: available frame size
 */
static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime)
{}

/**
 * snd_pcm_playback_hw_avail - Get the queued space for playback
 * @runtime: PCM runtime instance
 *
 * Return: available frame size
 */
static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(struct snd_pcm_runtime *runtime)
{}

/**
 * snd_pcm_capture_hw_avail - Get the free space for capture
 * @runtime: PCM runtime instance
 *
 * Return: available frame size
 */
static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime *runtime)
{}

/**
 * snd_pcm_playback_ready - check whether the playback buffer is available
 * @substream: the pcm substream instance
 *
 * Checks whether enough free space is available on the playback buffer.
 *
 * Return: Non-zero if available, or zero if not.
 */
static inline int snd_pcm_playback_ready(struct snd_pcm_substream *substream)
{}

/**
 * snd_pcm_capture_ready - check whether the capture buffer is available
 * @substream: the pcm substream instance
 *
 * Checks whether enough capture data is available on the capture buffer.
 *
 * Return: Non-zero if available, or zero if not.
 */
static inline int snd_pcm_capture_ready(struct snd_pcm_substream *substream)
{}

/**
 * snd_pcm_playback_data - check whether any data exists on the playback buffer
 * @substream: the pcm substream instance
 *
 * Checks whether any data exists on the playback buffer.
 *
 * Return: Non-zero if any data exists, or zero if not. If stop_threshold
 * is bigger or equal to boundary, then this function returns always non-zero.
 */
static inline int snd_pcm_playback_data(struct snd_pcm_substream *substream)
{}

/**
 * snd_pcm_playback_empty - check whether the playback buffer is empty
 * @substream: the pcm substream instance
 *
 * Checks whether the playback buffer is empty.
 *
 * Return: Non-zero if empty, or zero if not.
 */
static inline int snd_pcm_playback_empty(struct snd_pcm_substream *substream)
{}

/**
 * snd_pcm_capture_empty - check whether the capture buffer is empty
 * @substream: the pcm substream instance
 *
 * Checks whether the capture buffer is empty.
 *
 * Return: Non-zero if empty, or zero if not.
 */
static inline int snd_pcm_capture_empty(struct snd_pcm_substream *substream)
{}

/**
 * snd_pcm_trigger_done - Mark the master substream
 * @substream: the pcm substream instance
 * @master: the linked master substream
 *
 * When multiple substreams of the same card are linked and the hardware
 * supports the single-shot operation, the driver calls this in the loop
 * in snd_pcm_group_for_each_entry() for marking the substream as "done".
 * Then most of trigger operations are performed only to the given master
 * substream.
 *
 * The trigger_master mark is cleared at timestamp updates at the end
 * of trigger operations.
 */
static inline void snd_pcm_trigger_done(struct snd_pcm_substream *substream, 
					struct snd_pcm_substream *master)
{}

static inline int hw_is_mask(int var)
{}

static inline int hw_is_interval(int var)
{}

static inline struct snd_mask *hw_param_mask(struct snd_pcm_hw_params *params,
				     snd_pcm_hw_param_t var)
{}

static inline struct snd_interval *hw_param_interval(struct snd_pcm_hw_params *params,
					     snd_pcm_hw_param_t var)
{}

static inline const struct snd_mask *hw_param_mask_c(const struct snd_pcm_hw_params *params,
					     snd_pcm_hw_param_t var)
{}

static inline const struct snd_interval *hw_param_interval_c(const struct snd_pcm_hw_params *params,
						     snd_pcm_hw_param_t var)
{}

/**
 * params_channels - Get the number of channels from the hw params
 * @p: hw params
 *
 * Return: the number of channels
 */
static inline unsigned int params_channels(const struct snd_pcm_hw_params *p)
{}

/**
 * params_rate - Get the sample rate from the hw params
 * @p: hw params
 *
 * Return: the sample rate
 */
static inline unsigned int params_rate(const struct snd_pcm_hw_params *p)
{}

/**
 * params_period_size - Get the period size (in frames) from the hw params
 * @p: hw params
 *
 * Return: the period size in frames
 */
static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p)
{}

/**
 * params_periods - Get the number of periods from the hw params
 * @p: hw params
 *
 * Return: the number of periods
 */
static inline unsigned int params_periods(const struct snd_pcm_hw_params *p)
{}

/**
 * params_buffer_size - Get the buffer size (in frames) from the hw params
 * @p: hw params
 *
 * Return: the buffer size in frames
 */
static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p)
{}

/**
 * params_buffer_bytes - Get the buffer size (in bytes) from the hw params
 * @p: hw params
 *
 * Return: the buffer size in bytes
 */
static inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p)
{}

int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v);
int snd_interval_list(struct snd_interval *i, unsigned int count,
		      const unsigned int *list, unsigned int mask);
int snd_interval_ranges(struct snd_interval *i, unsigned int count,
			const struct snd_interval *list, unsigned int mask);
int snd_interval_ratnum(struct snd_interval *i,
			unsigned int rats_count, const struct snd_ratnum *rats,
			unsigned int *nump, unsigned int *denp);

void _snd_pcm_hw_params_any(struct snd_pcm_hw_params *params);
void _snd_pcm_hw_param_setempty(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var);

int snd_pcm_hw_refine(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params);

int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
				 u_int64_t mask);
int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
				 unsigned int min, unsigned int max);
int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var);
int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, 
			       unsigned int cond,
			       snd_pcm_hw_param_t var,
			       const struct snd_pcm_hw_constraint_list *l);
int snd_pcm_hw_constraint_ranges(struct snd_pcm_runtime *runtime,
				 unsigned int cond,
				 snd_pcm_hw_param_t var,
				 const struct snd_pcm_hw_constraint_ranges *r);
int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, 
				  unsigned int cond,
				  snd_pcm_hw_param_t var,
				  const struct snd_pcm_hw_constraint_ratnums *r);
int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, 
				  unsigned int cond,
				  snd_pcm_hw_param_t var,
				  const struct snd_pcm_hw_constraint_ratdens *r);
int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, 
				 unsigned int cond,
				 unsigned int width,
				 unsigned int msbits);
int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime,
			       unsigned int cond,
			       snd_pcm_hw_param_t var,
			       unsigned long step);
int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime,
			       unsigned int cond,
			       snd_pcm_hw_param_t var);
int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime,
			       unsigned int base_rate);
int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime,
			unsigned int cond,
			int var,
			snd_pcm_hw_rule_func_t func, void *private,
			int dep, ...);

/**
 * snd_pcm_hw_constraint_single() - Constrain parameter to a single value
 * @runtime: PCM runtime instance
 * @var: The hw_params variable to constrain
 * @val: The value to constrain to
 *
 * Return: Positive if the value is changed, zero if it's not changed, or a
 * negative error code.
 */
static inline int snd_pcm_hw_constraint_single(
	struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
	unsigned int val)
{}

int snd_pcm_format_signed(snd_pcm_format_t format);
int snd_pcm_format_unsigned(snd_pcm_format_t format);
int snd_pcm_format_linear(snd_pcm_format_t format);
int snd_pcm_format_little_endian(snd_pcm_format_t format);
int snd_pcm_format_big_endian(snd_pcm_format_t format);
#if 0 /* just for kernel-doc */
/**
 * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian
 * @format: the format to check
 *
 * Return: 1 if the given PCM format is CPU-endian, 0 if
 * opposite, or a negative error code if endian not specified.
 */
int snd_pcm_format_cpu_endian(snd_pcm_format_t format);
#endif /* DocBook */
#ifdef SNDRV_LITTLE_ENDIAN
#define snd_pcm_format_cpu_endian(format)
#else
#define snd_pcm_format_cpu_endian
#endif
int snd_pcm_format_width(snd_pcm_format_t format);			/* in bits */
int snd_pcm_format_physical_width(snd_pcm_format_t format);		/* in bits */
ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format);
int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames);

void snd_pcm_set_ops(struct snd_pcm * pcm, int direction,
		     const struct snd_pcm_ops *ops);
void snd_pcm_set_sync_per_card(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params,
			       const unsigned char *id, unsigned int len);
/**
 * snd_pcm_set_sync - set the PCM sync id
 * @substream: the pcm substream
 *
 * Use the default PCM sync identifier for the specific card.
 */
static inline void snd_pcm_set_sync(struct snd_pcm_substream *substream)
{}
int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream,
		      unsigned int cmd, void *arg);                      
void snd_pcm_period_elapsed_under_stream_lock(struct snd_pcm_substream *substream);
void snd_pcm_period_elapsed(struct snd_pcm_substream *substream);
snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
				     void *buf, bool interleaved,
				     snd_pcm_uframes_t frames, bool in_kernel);

static inline snd_pcm_sframes_t
snd_pcm_lib_write(struct snd_pcm_substream *substream,
		  const void __user *buf, snd_pcm_uframes_t frames)
{}

static inline snd_pcm_sframes_t
snd_pcm_lib_read(struct snd_pcm_substream *substream,
		 void __user *buf, snd_pcm_uframes_t frames)
{}

static inline snd_pcm_sframes_t
snd_pcm_lib_writev(struct snd_pcm_substream *substream,
		   void __user **bufs, snd_pcm_uframes_t frames)
{}

static inline snd_pcm_sframes_t
snd_pcm_lib_readv(struct snd_pcm_substream *substream,
		  void __user **bufs, snd_pcm_uframes_t frames)
{}

static inline snd_pcm_sframes_t
snd_pcm_kernel_write(struct snd_pcm_substream *substream,
		     const void *buf, snd_pcm_uframes_t frames)
{}

static inline snd_pcm_sframes_t
snd_pcm_kernel_read(struct snd_pcm_substream *substream,
		    void *buf, snd_pcm_uframes_t frames)
{}

static inline snd_pcm_sframes_t
snd_pcm_kernel_writev(struct snd_pcm_substream *substream,
		      void **bufs, snd_pcm_uframes_t frames)
{}

static inline snd_pcm_sframes_t
snd_pcm_kernel_readv(struct snd_pcm_substream *substream,
		     void **bufs, snd_pcm_uframes_t frames)
{}

int snd_pcm_hw_limit_rates(struct snd_pcm_hardware *hw);

static inline int
snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime)
{}

unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate);
unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit);
unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
					 unsigned int rates_b);
unsigned int snd_pcm_rate_range_to_bits(unsigned int rate_min,
					unsigned int rate_max);

/**
 * snd_pcm_set_runtime_buffer - Set the PCM runtime buffer
 * @substream: PCM substream to set
 * @bufp: the buffer information, NULL to clear
 *
 * Copy the buffer information to runtime->dma_buffer when @bufp is non-NULL.
 * Otherwise it clears the current buffer information.
 */
static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream,
					      struct snd_dma_buffer *bufp)
{}

/**
 * snd_pcm_gettime - Fill the timespec64 depending on the timestamp mode
 * @runtime: PCM runtime instance
 * @tv: timespec64 to fill
 */
static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime,
				   struct timespec64 *tv)
{}

/*
 *  Memory
 */

void snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream);
void snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm);
void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
				  int type, struct device *data,
				  size_t size, size_t max);
void snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm,
					  int type, void *data,
					  size_t size, size_t max);
int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size);
int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream);

int snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type,
			       struct device *data, size_t size, size_t max);
int snd_pcm_set_managed_buffer_all(struct snd_pcm *pcm, int type,
				   struct device *data,
				   size_t size, size_t max);

/**
 * snd_pcm_set_fixed_buffer - Preallocate and set up the fixed size PCM buffer
 * @substream: the pcm substream instance
 * @type: DMA type (SNDRV_DMA_TYPE_*)
 * @data: DMA type dependent data
 * @size: the requested pre-allocation size in bytes
 *
 * This is a variant of snd_pcm_set_managed_buffer(), but this pre-allocates
 * only the given sized buffer and doesn't allow re-allocation nor dynamic
 * allocation of a larger buffer unlike the standard one.
 * The function may return -ENOMEM error, hence the caller must check it.
 *
 * Return: zero if successful, or a negative error code
 */
static inline int __must_check
snd_pcm_set_fixed_buffer(struct snd_pcm_substream *substream, int type,
				 struct device *data, size_t size)
{}

/**
 * snd_pcm_set_fixed_buffer_all - Preallocate and set up the fixed size PCM buffer
 * @pcm: the pcm instance
 * @type: DMA type (SNDRV_DMA_TYPE_*)
 * @data: DMA type dependent data
 * @size: the requested pre-allocation size in bytes
 *
 * Apply the set up of the fixed buffer via snd_pcm_set_fixed_buffer() for
 * all substream.  If any of allocation fails, it returns -ENOMEM, hence the
 * caller must check the return value.
 *
 * Return: zero if successful, or a negative error code
 */
static inline int __must_check
snd_pcm_set_fixed_buffer_all(struct snd_pcm *pcm, int type,
			     struct device *data, size_t size)
{}

#define snd_pcm_get_dma_buf(substream)

/**
 * snd_pcm_sgbuf_get_addr - Get the DMA address at the corresponding offset
 * @substream: PCM substream
 * @ofs: byte offset
 *
 * Return: DMA address
 */
static inline dma_addr_t
snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs)
{}

/**
 * snd_pcm_sgbuf_get_chunk_size - Compute the max size that fits within the
 * contig. page from the given size
 * @substream: PCM substream
 * @ofs: byte offset
 * @size: byte size to examine
 *
 * Return: chunk size
 */
static inline unsigned int
snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream,
			     unsigned int ofs, unsigned int size)
{}

/**
 * snd_pcm_mmap_data_open - increase the mmap counter
 * @area: VMA
 *
 * PCM mmap callback should handle this counter properly
 */
static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area)
{}

/**
 * snd_pcm_mmap_data_close - decrease the mmap counter
 * @area: VMA
 *
 * PCM mmap callback should handle this counter properly
 */
static inline void snd_pcm_mmap_data_close(struct vm_area_struct *area)
{}

int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream,
			     struct vm_area_struct *area);
/* mmap for io-memory area */
#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA)
#define SNDRV_PCM_INFO_MMAP_IOMEM
int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_struct *area);
#else
#define SNDRV_PCM_INFO_MMAP_IOMEM
#define snd_pcm_lib_mmap_iomem
#endif

/**
 * snd_pcm_limit_isa_dma_size - Get the max size fitting with ISA DMA transfer
 * @dma: DMA number
 * @max: pointer to store the max size
 */
static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max)
{}

/*
 *  Misc
 */

#define SNDRV_PCM_DEFAULT_CON_SPDIF

const char *snd_pcm_format_name(snd_pcm_format_t format);

/**
 * snd_pcm_direction_name - Get a string naming the direction of a stream
 * @direction: Stream's direction, one of SNDRV_PCM_STREAM_XXX
 *
 * Returns a string naming the direction of the stream.
 */
static inline const char *snd_pcm_direction_name(int direction)
{}

/**
 * snd_pcm_stream_str - Get a string naming the direction of a stream
 * @substream: the pcm substream instance
 *
 * Return: A string naming the direction of the stream.
 */
static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream)
{}

/*
 * PCM channel-mapping control API
 */
/* array element of channel maps */
struct snd_pcm_chmap_elem {};

/* channel map information; retrieved via snd_kcontrol_chip() */
struct snd_pcm_chmap {};

/**
 * snd_pcm_chmap_substream - get the PCM substream assigned to the given chmap info
 * @info: chmap information
 * @idx: the substream number index
 *
 * Return: the matched PCM substream, or NULL if not found
 */
static inline struct snd_pcm_substream *
snd_pcm_chmap_substream(struct snd_pcm_chmap *info, unsigned int idx)
{}

/* ALSA-standard channel maps (RL/RR prior to C/LFE) */
extern const struct snd_pcm_chmap_elem snd_pcm_std_chmaps[];
/* Other world's standard channel maps (C/LFE prior to RL/RR) */
extern const struct snd_pcm_chmap_elem snd_pcm_alt_chmaps[];

/* bit masks to be passed to snd_pcm_chmap.channel_mask field */
#define SND_PCM_CHMAP_MASK_24
#define SND_PCM_CHMAP_MASK_246
#define SND_PCM_CHMAP_MASK_2468

int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream,
			   const struct snd_pcm_chmap_elem *chmap,
			   int max_channels,
			   unsigned long private_value,
			   struct snd_pcm_chmap **info_ret);

/**
 * pcm_format_to_bits - Strong-typed conversion of pcm_format to bitwise
 * @pcm_format: PCM format
 *
 * Return: 64bit mask corresponding to the given PCM format
 */
static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
{}

/**
 * pcm_for_each_format - helper to iterate for each format type
 * @f: the iterator variable in snd_pcm_format_t type
 */
#define pcm_for_each_format(f)

/* printk helpers */
#define pcm_err(pcm, fmt, args...)
#define pcm_warn(pcm, fmt, args...)
#define pcm_dbg(pcm, fmt, args...)

/* helpers for copying between iov_iter and iomem */
int copy_to_iter_fromio(struct iov_iter *itert, const void __iomem *src,
			size_t count);
int copy_from_iter_toio(void __iomem *dst, struct iov_iter *iter, size_t count);

struct snd_pcm_status64 {};

#define SNDRV_PCM_IOCTL_STATUS64
#define SNDRV_PCM_IOCTL_STATUS_EXT64

struct snd_pcm_status32 {};

#define SNDRV_PCM_IOCTL_STATUS32
#define SNDRV_PCM_IOCTL_STATUS_EXT32

#endif /* __SOUND_PCM_H */