linux/sound/core/timer.c

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

#include <linux/delay.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/mutex.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/sched/signal.h>
#include <linux/anon_inodes.h>
#include <linux/idr.h>
#include <sound/core.h>
#include <sound/timer.h>
#include <sound/control.h>
#include <sound/info.h>
#include <sound/minors.h>
#include <sound/initval.h>
#include <linux/kmod.h>

/* internal flags */
#define SNDRV_TIMER_IFLG_PAUSED
#define SNDRV_TIMER_IFLG_DEAD

#if IS_ENABLED(CONFIG_SND_HRTIMER)
#define DEFAULT_TIMER_LIMIT
#else
#define DEFAULT_TIMER_LIMIT
#endif

static int timer_limit =;
static int timer_tstamp_monotonic =;
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
module_param(timer_limit, int, 0444);
MODULE_PARM_DESC();
module_param(timer_tstamp_monotonic, int, 0444);
MODULE_PARM_DESC();

MODULE_ALIAS_CHARDEV();
MODULE_ALIAS();

enum timer_tread_format {};

struct snd_timer_tread32 {};

struct snd_timer_tread64 {};

struct snd_timer_user {};

struct snd_timer_status32 {};

#define SNDRV_TIMER_IOCTL_STATUS32

struct snd_timer_status64 {};

#ifdef CONFIG_SND_UTIMER
#define SNDRV_UTIMERS_MAX_COUNT
/* Internal data structure for keeping the state of the userspace-driven timer */
struct snd_utimer {};
#endif

#define SNDRV_TIMER_IOCTL_STATUS64

/* list of timers */
static LIST_HEAD(snd_timer_list);

/* list of slave instances */
static LIST_HEAD(snd_timer_slave_list);

/* lock for slave active lists */
static DEFINE_SPINLOCK(slave_active_lock);

#define MAX_SLAVE_INSTANCES
static int num_slaves;

static DEFINE_MUTEX(register_mutex);

static int snd_timer_free(struct snd_timer *timer);
static int snd_timer_dev_free(struct snd_device *device);
static int snd_timer_dev_register(struct snd_device *device);
static int snd_timer_dev_disconnect(struct snd_device *device);

static void snd_timer_reschedule(struct snd_timer * timer, unsigned long ticks_left);

/*
 * create a timer instance with the given owner string.
 */
struct snd_timer_instance *snd_timer_instance_new(const char *owner)
{}
EXPORT_SYMBOL();

void snd_timer_instance_free(struct snd_timer_instance *timeri)
{}
EXPORT_SYMBOL();

/*
 * find a timer instance from the given timer id
 */
static struct snd_timer *snd_timer_find(struct snd_timer_id *tid)
{}

#ifdef CONFIG_MODULES

static void snd_timer_request(struct snd_timer_id *tid)
{}

#endif

/* move the slave if it belongs to the master; return 1 if match */
static int check_matching_master_slave(struct snd_timer_instance *master,
				       struct snd_timer_instance *slave)
{}

/*
 * look for a master instance matching with the slave id of the given slave.
 * when found, relink the open_link of the slave.
 *
 * call this with register_mutex down.
 */
static int snd_timer_check_slave(struct snd_timer_instance *slave)
{}

/*
 * look for slave instances matching with the slave id of the given master.
 * when found, relink the open_link of slaves.
 *
 * call this with register_mutex down.
 */
static int snd_timer_check_master(struct snd_timer_instance *master)
{}

static void snd_timer_close_locked(struct snd_timer_instance *timeri,
				   struct device **card_devp_to_put);

/*
 * open a timer instance
 * when opening a master, the slave id must be here given.
 */
int snd_timer_open(struct snd_timer_instance *timeri,
		   struct snd_timer_id *tid,
		   unsigned int slave_id)
{}
EXPORT_SYMBOL();

/* remove slave links, called from snd_timer_close_locked() below */
static void remove_slave_links(struct snd_timer_instance *timeri,
			       struct snd_timer *timer)
{}

/*
 * close a timer instance
 * call this with register_mutex down.
 */
static void snd_timer_close_locked(struct snd_timer_instance *timeri,
				   struct device **card_devp_to_put)
{}

/*
 * close a timer instance
 */
void snd_timer_close(struct snd_timer_instance *timeri)
{}
EXPORT_SYMBOL();

static unsigned long snd_timer_hw_resolution(struct snd_timer *timer)
{}

unsigned long snd_timer_resolution(struct snd_timer_instance *timeri)
{}
EXPORT_SYMBOL();

static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
{}

/* start/continue a master timer */
static int snd_timer_start1(struct snd_timer_instance *timeri,
			    bool start, unsigned long ticks)
{}

/* start/continue a slave timer */
static int snd_timer_start_slave(struct snd_timer_instance *timeri,
				 bool start)
{}

/* stop/pause a master timer */
static int snd_timer_stop1(struct snd_timer_instance *timeri, bool stop)
{}

/* stop/pause a slave timer */
static int snd_timer_stop_slave(struct snd_timer_instance *timeri, bool stop)
{}

/*
 *  start the timer instance
 */
int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks)
{}
EXPORT_SYMBOL();

/*
 * stop the timer instance.
 *
 * do not call this from the timer callback!
 */
int snd_timer_stop(struct snd_timer_instance *timeri)
{}
EXPORT_SYMBOL();

/*
 * start again..  the tick is kept.
 */
int snd_timer_continue(struct snd_timer_instance *timeri)
{}
EXPORT_SYMBOL();

/*
 * pause.. remember the ticks left
 */
int snd_timer_pause(struct snd_timer_instance * timeri)
{}
EXPORT_SYMBOL();

/*
 * reschedule the timer
 *
 * start pending instances and check the scheduling ticks.
 * when the scheduling ticks is changed set CHANGE flag to reprogram the timer.
 */
static void snd_timer_reschedule(struct snd_timer * timer, unsigned long ticks_left)
{}

/* call callbacks in timer ack list */
static void snd_timer_process_callbacks(struct snd_timer *timer,
					struct list_head *head)
{}

/* clear pending instances from ack list */
static void snd_timer_clear_callbacks(struct snd_timer *timer,
				      struct list_head *head)
{}

/*
 * timer work
 *
 */
static void snd_timer_work(struct work_struct *work)
{}

/*
 * timer interrupt
 *
 * ticks_left is usually equal to timer->sticks.
 *
 */
void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
{}
EXPORT_SYMBOL();

/*

 */

int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid,
		  struct snd_timer **rtimer)
{}
EXPORT_SYMBOL();

static int snd_timer_free(struct snd_timer *timer)
{}

static int snd_timer_dev_free(struct snd_device *device)
{}

static int snd_timer_dev_register(struct snd_device *dev)
{}

static int snd_timer_dev_disconnect(struct snd_device *device)
{}

void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp)
{}
EXPORT_SYMBOL();

/*
 * exported functions for global timers
 */
int snd_timer_global_new(char *id, int device, struct snd_timer **rtimer)
{}
EXPORT_SYMBOL();

int snd_timer_global_free(struct snd_timer *timer)
{}
EXPORT_SYMBOL();

int snd_timer_global_register(struct snd_timer *timer)
{}
EXPORT_SYMBOL();

/*
 *  System timer
 */

struct snd_timer_system_private {};

static void snd_timer_s_function(struct timer_list *t)
{}

static int snd_timer_s_start(struct snd_timer * timer)
{}

static int snd_timer_s_stop(struct snd_timer * timer)
{}

static int snd_timer_s_close(struct snd_timer *timer)
{}

static const struct snd_timer_hardware snd_timer_system =;

static void snd_timer_free_system(struct snd_timer *timer)
{}

static int snd_timer_register_system(void)
{}

#ifdef CONFIG_SND_PROC_FS
/*
 *  Info interface
 */

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

static struct snd_info_entry *snd_timer_proc_entry;

static void __init snd_timer_proc_init(void)
{}

static void __exit snd_timer_proc_done(void)
{}
#else /* !CONFIG_SND_PROC_FS */
#define snd_timer_proc_init
#define snd_timer_proc_done
#endif

/*
 *  USER SPACE interface
 */

static void snd_timer_user_interrupt(struct snd_timer_instance *timeri,
				     unsigned long resolution,
				     unsigned long ticks)
{}

static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu,
					    struct snd_timer_tread64 *tread)
{}

static void snd_timer_user_ccallback(struct snd_timer_instance *timeri,
				     int event,
				     struct timespec64 *tstamp,
				     unsigned long resolution)
{}

static void snd_timer_user_disconnect(struct snd_timer_instance *timeri)
{}

static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
				      unsigned long resolution,
				      unsigned long ticks)
{}

static int realloc_user_queue(struct snd_timer_user *tu, int size)
{}

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

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

static void snd_timer_user_zero_id(struct snd_timer_id *id)
{}

static void snd_timer_user_copy_id(struct snd_timer_id *id, struct snd_timer *timer)
{}

static int snd_timer_user_next_device(struct snd_timer_id __user *_tid)
{}

static int snd_timer_user_ginfo(struct file *file,
				struct snd_timer_ginfo __user *_ginfo)
{}

static int timer_set_gparams(struct snd_timer_gparams *gparams)
{}

static int snd_timer_user_gparams(struct file *file,
				  struct snd_timer_gparams __user *_gparams)
{}

static int snd_timer_user_gstatus(struct file *file,
				  struct snd_timer_gstatus __user *_gstatus)
{}

static int snd_timer_user_tselect(struct file *file,
				  struct snd_timer_select __user *_tselect)
{}

static int snd_timer_user_info(struct file *file,
			       struct snd_timer_info __user *_info)
{}

static int snd_timer_user_params(struct file *file,
				 struct snd_timer_params __user *_params)
{}

static int snd_timer_user_status32(struct file *file,
				   struct snd_timer_status32 __user *_status)
 {}

static int snd_timer_user_status64(struct file *file,
				   struct snd_timer_status64 __user *_status)
{}

static int snd_timer_user_start(struct file *file)
{}

static int snd_timer_user_stop(struct file *file)
{}

static int snd_timer_user_continue(struct file *file)
{}

static int snd_timer_user_pause(struct file *file)
{}

static int snd_timer_user_tread(void __user *argp, struct snd_timer_user *tu,
				unsigned int cmd, bool compat)
{}

enum {};

#ifdef CONFIG_SND_UTIMER
/*
 * Since userspace-driven timers are passed to userspace, we need to have an identifier
 * which will allow us to use them (basically, the subdevice number of udriven timer).
 */
static DEFINE_IDA(snd_utimer_ids);

static void snd_utimer_put_id(struct snd_utimer *utimer)
{}

static int snd_utimer_take_id(void)
{}

static void snd_utimer_free(struct snd_utimer *utimer)
{}

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

static int snd_utimer_trigger(struct file *file)
{}

static long snd_utimer_ioctl(struct file *file, unsigned int ioctl, unsigned long arg)
{}

static const struct file_operations snd_utimer_fops =;

static int snd_utimer_start(struct snd_timer *t)
{}

static int snd_utimer_stop(struct snd_timer *t)
{}

static int snd_utimer_open(struct snd_timer *t)
{}

static int snd_utimer_close(struct snd_timer *t)
{}

static const struct snd_timer_hardware timer_hw =;

static int snd_utimer_create(struct snd_timer_uinfo *utimer_info,
			     struct snd_utimer **r_utimer)
{}

static int snd_utimer_ioctl_create(struct file *file,
				   struct snd_timer_uinfo __user *_utimer_info)
{}

#else

static int snd_utimer_ioctl_create(struct file *file,
				   struct snd_timer_uinfo __user *_utimer_info)
{
	return -ENOTTY;
}

#endif

static long __snd_timer_user_ioctl(struct file *file, unsigned int cmd,
				 unsigned long arg, bool compat)
{}

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

static int snd_timer_user_fasync(int fd, struct file * file, int on)
{}

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

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

#ifdef CONFIG_COMPAT
#include "timer_compat.c"
#else
#define snd_timer_user_ioctl_compat
#endif

static const struct file_operations snd_timer_f_ops =;

/* unregister the system timer */
static void snd_timer_free_all(void)
{}

static struct device *timer_dev;

/*
 *  ENTRY functions
 */

static int __init alsa_timer_init(void)
{}

static void __exit alsa_timer_exit(void)
{}

module_init()
module_exit()