blob: c6614254ef8af2f56b68193dc4ce4d35d49b3773 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * ALSA sequencer Client Manager
3 * Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
4 *
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21#ifndef __SND_SEQ_CLIENTMGR_H
22#define __SND_SEQ_CLIENTMGR_H
23
24#include <sound/seq_kernel.h>
25#include <linux/bitops.h>
26#include "seq_fifo.h"
27#include "seq_ports.h"
28#include "seq_lock.h"
29
30
31/* client manager */
32
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010033struct snd_seq_user_client {
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 struct file *file; /* file struct of client */
35 /* ... */
Martin Koeglera1ce94d2016-03-02 19:26:28 +010036 struct pid *owner;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38 /* fifo */
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010039 struct snd_seq_fifo *fifo; /* queue for incoming events */
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 int fifo_pool_size;
41};
42
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010043struct snd_seq_kernel_client {
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 /* ... */
Martin Koeglera1ce94d2016-03-02 19:26:28 +010045 struct snd_card *card;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046};
47
48
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010049struct snd_seq_client {
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 snd_seq_client_type_t type;
51 unsigned int accept_input: 1,
52 accept_output: 1;
53 char name[64]; /* client name */
54 int number; /* client number */
55 unsigned int filter; /* filter flags */
56 DECLARE_BITMAP(event_filter, 256);
57 snd_use_lock_t use_lock;
58 int event_lost;
59 /* ports */
60 int num_ports; /* number of ports */
61 struct list_head ports_list_head;
62 rwlock_t ports_lock;
Ingo Molnar1a60d4c2006-01-16 16:29:08 +010063 struct mutex ports_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 int convert32; /* convert 32->64bit */
65
66 /* output pool */
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010067 struct snd_seq_pool *pool; /* memory pool for this client */
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69 union {
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010070 struct snd_seq_user_client user;
71 struct snd_seq_kernel_client kernel;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 } data;
73};
74
75/* usage statistics */
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010076struct snd_seq_usage {
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 int cur;
78 int peak;
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010079};
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010082int client_init_data(void);
83int snd_sequencer_device_init(void);
84void snd_sequencer_device_done(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
86/* get locked pointer to client */
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010087struct snd_seq_client *snd_seq_client_use_ptr(int clientid);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
89/* unlock pointer to client */
90#define snd_seq_client_unlock(client) snd_use_lock_free(&(client)->use_lock)
91
92/* dispatch event to client(s) */
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010093int snd_seq_dispatch_event(struct snd_seq_event_cell *cell, int atomic, int hop);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95/* exported to other modules */
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010096int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop);
97int snd_seq_kernel_client_enqueue_blocking(int client, struct snd_seq_event * ev,
98 struct file *file, int atomic, int hop);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099int snd_seq_kernel_client_write_poll(int clientid, struct file *file, poll_table *wait);
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +0100100int snd_seq_client_notify_subscription(int client, int port,
101 struct snd_seq_port_subscribe *info, int evtype);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
Marcin Ĺšlusarz3b378e12007-12-14 12:59:50 +0100103extern int seq_client_load[15];
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#endif