linux/sound/core/oss/pcm_oss.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  Digital Audio (PCM) abstract layer / OSS compatible
 *  Copyright (c) by Jaroslav Kysela <[email protected]>
 */

#if 0
#define PLUGIN_DEBUG
#endif
#if 0
#define OSS_DEBUG
#endif

#include <linux/init.h>
#include <linux/slab.h>
#include <linux/sched/signal.h>
#include <linux/time.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <linux/math64.h>
#include <linux/string.h>
#include <linux/compat.h>
#include <sound/core.h>
#include <sound/minors.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include "pcm_plugin.h"
#include <sound/info.h>
#include <linux/soundcard.h>
#include <sound/initval.h>
#include <sound/mixer_oss.h>

#define OSS_ALSAEMULVER

static int dsp_map[SNDRV_CARDS];
static int adsp_map[SNDRV_CARDS] =;
static bool nonblock_open =;

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param(nonblock_open, bool, 0644);
MODULE_PARM_DESC();
MODULE_ALIAS_SNDRV_MINOR();
MODULE_ALIAS_SNDRV_MINOR();

static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file);
static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file);
static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file);

/*
 * helper functions to process hw_params
 */
static int snd_interval_refine_min(struct snd_interval *i, unsigned int min, int openmin)
{}

static int snd_interval_refine_max(struct snd_interval *i, unsigned int max, int openmax)
{}

static int snd_interval_refine_set(struct snd_interval *i, unsigned int val)
{}

/**
 * snd_pcm_hw_param_value_min
 * @params: the hw_params instance
 * @var: parameter to retrieve
 * @dir: pointer to the direction (-1,0,1) or NULL
 *
 * Return the minimum value for field PAR.
 */
static unsigned int
snd_pcm_hw_param_value_min(const struct snd_pcm_hw_params *params,
			   snd_pcm_hw_param_t var, int *dir)
{}

/**
 * snd_pcm_hw_param_value_max
 * @params: the hw_params instance
 * @var: parameter to retrieve
 * @dir: pointer to the direction (-1,0,1) or NULL
 *
 * Return the maximum value for field PAR.
 */
static int
snd_pcm_hw_param_value_max(const struct snd_pcm_hw_params *params,
			   snd_pcm_hw_param_t var, int *dir)
{}

static int _snd_pcm_hw_param_mask(struct snd_pcm_hw_params *params,
				  snd_pcm_hw_param_t var,
				  const struct snd_mask *val)
{}

static int snd_pcm_hw_param_mask(struct snd_pcm_substream *pcm,
				 struct snd_pcm_hw_params *params,
				 snd_pcm_hw_param_t var,
				 const struct snd_mask *val)
{}

static int _snd_pcm_hw_param_min(struct snd_pcm_hw_params *params,
				 snd_pcm_hw_param_t var, unsigned int val,
				 int dir)
{}

/**
 * snd_pcm_hw_param_min
 * @pcm: PCM instance
 * @params: the hw_params instance
 * @var: parameter to retrieve
 * @val: minimal value
 * @dir: pointer to the direction (-1,0,1) or NULL
 *
 * Inside configuration space defined by PARAMS remove from PAR all 
 * values < VAL. Reduce configuration space accordingly.
 * Return new minimum or -EINVAL if the configuration space is empty
 */
static int snd_pcm_hw_param_min(struct snd_pcm_substream *pcm,
				struct snd_pcm_hw_params *params,
				snd_pcm_hw_param_t var, unsigned int val,
				int *dir)
{}

static int _snd_pcm_hw_param_max(struct snd_pcm_hw_params *params,
				 snd_pcm_hw_param_t var, unsigned int val,
				 int dir)
{}

/**
 * snd_pcm_hw_param_max
 * @pcm: PCM instance
 * @params: the hw_params instance
 * @var: parameter to retrieve
 * @val: maximal value
 * @dir: pointer to the direction (-1,0,1) or NULL
 *
 * Inside configuration space defined by PARAMS remove from PAR all 
 *  values >= VAL + 1. Reduce configuration space accordingly.
 *  Return new maximum or -EINVAL if the configuration space is empty
 */
static int snd_pcm_hw_param_max(struct snd_pcm_substream *pcm,
				struct snd_pcm_hw_params *params,
				snd_pcm_hw_param_t var, unsigned int val,
				int *dir)
{}

static int boundary_sub(int a, int adir,
			int b, int bdir,
			int *c, int *cdir)
{}

static int boundary_lt(unsigned int a, int adir,
		       unsigned int b, int bdir)
{}

/* Return 1 if min is nearer to best than max */
static int boundary_nearer(int min, int mindir,
			   int best, int bestdir,
			   int max, int maxdir)
{}

/**
 * snd_pcm_hw_param_near
 * @pcm: PCM instance
 * @params: the hw_params instance
 * @var: parameter to retrieve
 * @best: value to set
 * @dir: pointer to the direction (-1,0,1) or NULL
 *
 * Inside configuration space defined by PARAMS set PAR to the available value
 * nearest to VAL. Reduce configuration space accordingly.
 * This function cannot be called for SNDRV_PCM_HW_PARAM_ACCESS,
 * SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_SUBFORMAT.
 * Return the value found.
  */
static int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm,
				 struct snd_pcm_hw_params *params,
				 snd_pcm_hw_param_t var, unsigned int best,
				 int *dir)
{}

static int _snd_pcm_hw_param_set(struct snd_pcm_hw_params *params,
				 snd_pcm_hw_param_t var, unsigned int val,
				 int dir)
{}

/**
 * snd_pcm_hw_param_set
 * @pcm: PCM instance
 * @params: the hw_params instance
 * @var: parameter to retrieve
 * @val: value to set
 * @dir: pointer to the direction (-1,0,1) or NULL
 *
 * Inside configuration space defined by PARAMS remove from PAR all 
 * values != VAL. Reduce configuration space accordingly.
 *  Return VAL or -EINVAL if the configuration space is empty
 */
static int snd_pcm_hw_param_set(struct snd_pcm_substream *pcm,
				struct snd_pcm_hw_params *params,
				snd_pcm_hw_param_t var, unsigned int val,
				int dir)
{}

static int _snd_pcm_hw_param_setinteger(struct snd_pcm_hw_params *params,
					snd_pcm_hw_param_t var)
{}
	
/*
 * plugin
 */

#ifdef CONFIG_SND_PCM_OSS_PLUGINS
static int snd_pcm_oss_plugin_clear(struct snd_pcm_substream *substream)
{}

static int snd_pcm_plugin_insert(struct snd_pcm_plugin *plugin)
{}

int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin)
{}
#endif /* CONFIG_SND_PCM_OSS_PLUGINS */

static long snd_pcm_oss_bytes(struct snd_pcm_substream *substream, long frames)
{}

static long snd_pcm_alsa_frames(struct snd_pcm_substream *substream, long bytes)
{}

static inline
snd_pcm_uframes_t get_hw_ptr_period(struct snd_pcm_runtime *runtime)
{}

/* define extended formats in the recent OSS versions (if any) */
/* linear formats */
#define AFMT_S32_LE
#define AFMT_S32_BE
#define AFMT_S24_LE
#define AFMT_S24_BE
#define AFMT_S24_PACKED

/* other supported formats */
#define AFMT_FLOAT
#define AFMT_SPDIF_RAW

/* unsupported formats */
#define AFMT_AC3
#define AFMT_VORBIS

static snd_pcm_format_t snd_pcm_oss_format_from(int format)
{}

static int snd_pcm_oss_format_to(snd_pcm_format_t format)
{}

static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream, 
				   struct snd_pcm_hw_params *oss_params,
				   struct snd_pcm_hw_params *slave_params)
{}

static int choose_rate(struct snd_pcm_substream *substream,
		       struct snd_pcm_hw_params *params, unsigned int best_rate)
{}

/* parameter locking: returns immediately if tried during streaming */
static int lock_params(struct snd_pcm_runtime *runtime)
{}

static void unlock_params(struct snd_pcm_runtime *runtime)
{}

static void snd_pcm_oss_release_buffers(struct snd_pcm_substream *substream)
{}

/* call with params_lock held */
static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
{}

/* this one takes the lock by itself */
static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream,
				     bool trylock)
{}

static int snd_pcm_oss_get_active_substream(struct snd_pcm_oss_file *pcm_oss_file, struct snd_pcm_substream **r_substream)
{}

/* call with params_lock held */
/* NOTE: this always call PREPARE unconditionally no matter whether
 * runtime->oss.prepare is set or not
 */
static int snd_pcm_oss_prepare(struct snd_pcm_substream *substream)
{}

static int snd_pcm_oss_make_ready(struct snd_pcm_substream *substream)
{}

/* call with params_lock held */
static int snd_pcm_oss_make_ready_locked(struct snd_pcm_substream *substream)
{}

static int snd_pcm_oss_capture_position_fixup(struct snd_pcm_substream *substream, snd_pcm_sframes_t *delay)
{}

snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const char *ptr, snd_pcm_uframes_t frames, int in_kernel)
{}

snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *ptr, snd_pcm_uframes_t frames, int in_kernel)
{}

#ifdef CONFIG_SND_PCM_OSS_PLUGINS
snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream, void **bufs, snd_pcm_uframes_t frames)
{}
	
snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream, void **bufs, snd_pcm_uframes_t frames)
{}
#endif /* CONFIG_SND_PCM_OSS_PLUGINS */

static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const char *buf, size_t bytes, int in_kernel)
{}

static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const char __user *buf, size_t bytes)
{}

static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf, size_t bytes, int in_kernel)
{}

static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __user *buf, size_t bytes)
{}

static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_post(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
{}

static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_set_rate(struct snd_pcm_oss_file *pcm_oss_file, int rate)
{}

static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_set_channels(struct snd_pcm_oss_file *pcm_oss_file, unsigned int channels)
{}

static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_get_block_size(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_set_format(struct snd_pcm_oss_file *pcm_oss_file, int format)
{}

static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_set_subdivide1(struct snd_pcm_substream *substream, int subdivide)
{}

static int snd_pcm_oss_set_subdivide(struct snd_pcm_oss_file *pcm_oss_file, int subdivide)
{}

static int snd_pcm_oss_set_fragment1(struct snd_pcm_substream *substream, unsigned int val)
{}

static int snd_pcm_oss_set_fragment(struct snd_pcm_oss_file *pcm_oss_file, unsigned int val)
{}

static int snd_pcm_oss_nonblock(struct file * file)
{}

static int snd_pcm_oss_get_caps1(struct snd_pcm_substream *substream, int res)
{}

static int snd_pcm_oss_get_caps(struct snd_pcm_oss_file *pcm_oss_file)
{}

static void snd_pcm_oss_simulate_fill(struct snd_pcm_substream *substream,
				      snd_pcm_uframes_t hw_ptr)
{}

static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int trigger)
{}

static int snd_pcm_oss_get_trigger(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_get_odelay(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream, struct count_info __user * _info)
{}

static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stream, struct audio_buf_info __user *_info)
{}

static int snd_pcm_oss_get_mapbuf(struct snd_pcm_oss_file *pcm_oss_file, int stream, struct buffmem_desc __user * _info)
{}

static const char *strip_task_path(const char *path)
{}

static void snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, int stream,
				      const char *task_name,
				      struct snd_pcm_oss_setup *rsetup)
{}

static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream)
{}

static void snd_pcm_oss_init_substream(struct snd_pcm_substream *substream,
				       struct snd_pcm_oss_setup *setup,
				       int minor)
{}

static int snd_pcm_oss_release_file(struct snd_pcm_oss_file *pcm_oss_file)
{}

static int snd_pcm_oss_open_file(struct file *file,
				 struct snd_pcm *pcm,
				 struct snd_pcm_oss_file **rpcm_oss_file,
				 int minor,
				 struct snd_pcm_oss_setup *setup)
{}


static int snd_task_name(struct task_struct *task, char *name, size_t size)
{}

static int snd_pcm_oss_open(struct inode *inode, struct file *file)
{}

static int snd_pcm_oss_release(struct inode *inode, struct file *file)
{}

static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{}

#ifdef CONFIG_COMPAT
/* all compatible */
static long snd_pcm_oss_ioctl_compat(struct file *file, unsigned int cmd,
				     unsigned long arg)
{}
#else
#define snd_pcm_oss_ioctl_compat
#endif

static ssize_t snd_pcm_oss_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
{}

static ssize_t snd_pcm_oss_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
{}

static int snd_pcm_oss_playback_ready(struct snd_pcm_substream *substream)
{}

static int snd_pcm_oss_capture_ready(struct snd_pcm_substream *substream)
{}

static __poll_t snd_pcm_oss_poll(struct file *file, poll_table * wait)
{}

static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area)
{}

#ifdef CONFIG_SND_VERBOSE_PROCFS
/*
 *  /proc interface
 */

static void snd_pcm_oss_proc_read(struct snd_info_entry *entry,
				  struct snd_info_buffer *buffer)
{}

static void snd_pcm_oss_proc_free_setup_list(struct snd_pcm_str * pstr)
{}

static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
				   struct snd_info_buffer *buffer)
{}

static void snd_pcm_oss_proc_init(struct snd_pcm *pcm)
{}

static void snd_pcm_oss_proc_done(struct snd_pcm *pcm)
{}
#else /* !CONFIG_SND_VERBOSE_PROCFS */
static inline void snd_pcm_oss_proc_init(struct snd_pcm *pcm)
{
}
static inline void snd_pcm_oss_proc_done(struct snd_pcm *pcm)
{
}
#endif /* CONFIG_SND_VERBOSE_PROCFS */

/*
 *  ENTRY functions
 */

static const struct file_operations snd_pcm_oss_f_reg =;

static void register_oss_dsp(struct snd_pcm *pcm, int index)
{}

static int snd_pcm_oss_register_minor(struct snd_pcm *pcm)
{}

static int snd_pcm_oss_disconnect_minor(struct snd_pcm *pcm)
{}

static int snd_pcm_oss_unregister_minor(struct snd_pcm *pcm)
{}

static struct snd_pcm_notify snd_pcm_oss_notify =;

static int __init alsa_pcm_oss_init(void)
{}

static void __exit alsa_pcm_oss_exit(void)
{}

module_init()
module_exit()