Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *   ALSA sequencer Queue handling
0004  *   Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
0005  */
0006 #ifndef __SND_SEQ_QUEUE_H
0007 #define __SND_SEQ_QUEUE_H
0008 
0009 #include "seq_memory.h"
0010 #include "seq_prioq.h"
0011 #include "seq_timer.h"
0012 #include "seq_lock.h"
0013 #include <linux/interrupt.h>
0014 #include <linux/list.h>
0015 #include <linux/bitops.h>
0016 
0017 #define SEQ_QUEUE_NO_OWNER (-1)
0018 
0019 struct snd_seq_queue {
0020     int queue;      /* queue number */
0021 
0022     char name[64];      /* name of this queue */
0023 
0024     struct snd_seq_prioq    *tickq;     /* midi tick event queue */
0025     struct snd_seq_prioq    *timeq;     /* real-time event queue */ 
0026     
0027     struct snd_seq_timer *timer;    /* time keeper for this queue */
0028     int owner;      /* client that 'owns' the timer */
0029     bool    locked;     /* timer is only accesibble by owner if set */
0030     bool    klocked;    /* kernel lock (after START) */
0031     bool    check_again;    /* concurrent access happened during check */
0032     bool    check_blocked;  /* queue being checked */
0033 
0034     unsigned int flags;     /* status flags */
0035     unsigned int info_flags;    /* info for sync */
0036 
0037     spinlock_t owner_lock;
0038     spinlock_t check_lock;
0039 
0040     /* clients which uses this queue (bitmap) */
0041     DECLARE_BITMAP(clients_bitmap, SNDRV_SEQ_MAX_CLIENTS);
0042     unsigned int clients;   /* users of this queue */
0043     struct mutex timer_mutex;
0044 
0045     snd_use_lock_t use_lock;
0046 };
0047 
0048 
0049 /* get the number of current queues */
0050 int snd_seq_queue_get_cur_queues(void);
0051 
0052 /* delete queues */ 
0053 void snd_seq_queues_delete(void);
0054 
0055 
0056 /* create new queue (constructor) */
0057 struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int flags);
0058 
0059 /* delete queue (destructor) */
0060 int snd_seq_queue_delete(int client, int queueid);
0061 
0062 /* final stage */
0063 void snd_seq_queue_client_leave(int client);
0064 
0065 /* enqueue a event received from one the clients */
0066 int snd_seq_enqueue_event(struct snd_seq_event_cell *cell, int atomic, int hop);
0067 
0068 /* Remove events */
0069 void snd_seq_queue_client_leave_cells(int client);
0070 void snd_seq_queue_remove_cells(int client, struct snd_seq_remove_events *info);
0071 
0072 /* return pointer to queue structure for specified id */
0073 struct snd_seq_queue *queueptr(int queueid);
0074 /* unlock */
0075 #define queuefree(q) snd_use_lock_free(&(q)->use_lock)
0076 
0077 /* return the (first) queue matching with the specified name */
0078 struct snd_seq_queue *snd_seq_queue_find_name(char *name);
0079 
0080 /* check single queue and dispatch events */
0081 void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop);
0082 
0083 /* access to queue's parameters */
0084 int snd_seq_queue_check_access(int queueid, int client);
0085 int snd_seq_queue_timer_set_tempo(int queueid, int client, struct snd_seq_queue_tempo *info);
0086 int snd_seq_queue_set_owner(int queueid, int client, int locked);
0087 int snd_seq_queue_set_locked(int queueid, int client, int locked);
0088 int snd_seq_queue_timer_open(int queueid);
0089 int snd_seq_queue_timer_close(int queueid);
0090 int snd_seq_queue_use(int queueid, int client, int use);
0091 int snd_seq_queue_is_used(int queueid, int client);
0092 
0093 int snd_seq_control_queue(struct snd_seq_event *ev, int atomic, int hop);
0094 
0095 #endif