[PATCH] fix semaphore handling in __unregister_chrdev_region
[linux/fpc-iii.git] / sound / core / seq / seq_ports.h
blob89fd4416f6fa3b9fe9cb709748c595d81b10aea0
1 /*
2 * ALSA sequencer Ports
3 * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
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.
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.
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
21 #ifndef __SND_SEQ_PORTS_H
22 #define __SND_SEQ_PORTS_H
24 #include <sound/seq_kernel.h>
25 #include "seq_lock.h"
27 /* list of 'exported' ports */
29 /* Client ports that are not exported are still accessible, but are
30 anonymous ports.
32 If a port supports SUBSCRIPTION, that port can send events to all
33 subscribersto a special address, with address
34 (queue==SNDRV_SEQ_ADDRESS_SUBSCRIBERS). The message is then send to all
35 recipients that are registered in the subscription list. A typical
36 application for these SUBSCRIPTION events is handling of incoming MIDI
37 data. The port doesn't 'know' what other clients are interested in this
38 message. If for instance a MIDI recording application would like to receive
39 the events from that port, it will first have to subscribe with that port.
43 typedef struct subscribers_t {
44 snd_seq_port_subscribe_t info; /* additional info */
45 struct list_head src_list; /* link of sources */
46 struct list_head dest_list; /* link of destinations */
47 atomic_t ref_count;
48 } subscribers_t;
50 typedef struct port_subs_info_t {
51 struct list_head list_head; /* list of subscribed ports */
52 unsigned int count; /* count of subscribers */
53 unsigned int exclusive: 1; /* exclusive mode */
54 struct rw_semaphore list_mutex;
55 rwlock_t list_lock;
56 snd_seq_kernel_port_open_t *open;
57 snd_seq_kernel_port_close_t *close;
58 } port_subs_info_t;
60 typedef struct client_port_t {
62 snd_seq_addr_t addr; /* client/port number */
63 struct module *owner; /* owner of this port */
64 char name[64]; /* port name */
65 struct list_head list; /* port list */
66 snd_use_lock_t use_lock;
68 /* subscribers */
69 port_subs_info_t c_src; /* read (sender) list */
70 port_subs_info_t c_dest; /* write (dest) list */
72 snd_seq_kernel_port_input_t *event_input;
73 snd_seq_kernel_port_private_free_t *private_free;
74 void *private_data;
75 unsigned int callback_all : 1;
76 unsigned int closing : 1;
77 unsigned int timestamping: 1;
78 unsigned int time_real: 1;
79 int time_queue;
81 /* capability, inport, output, sync */
82 unsigned int capability; /* port capability bits */
83 unsigned int type; /* port type bits */
85 /* supported channels */
86 int midi_channels;
87 int midi_voices;
88 int synth_voices;
90 } client_port_t;
92 /* return pointer to port structure and lock port */
93 client_port_t *snd_seq_port_use_ptr(client_t *client, int num);
95 /* search for next port - port is locked if found */
96 client_port_t *snd_seq_port_query_nearest(client_t *client, snd_seq_port_info_t *pinfo);
98 /* unlock the port */
99 #define snd_seq_port_unlock(port) snd_use_lock_free(&(port)->use_lock)
101 /* create a port, port number is returned (-1 on failure) */
102 client_port_t *snd_seq_create_port(client_t *client, int port_index);
104 /* delete a port */
105 int snd_seq_delete_port(client_t *client, int port);
107 /* delete all ports */
108 int snd_seq_delete_all_ports(client_t *client);
110 /* set port info fields */
111 int snd_seq_set_port_info(client_port_t *port, snd_seq_port_info_t *info);
113 /* get port info fields */
114 int snd_seq_get_port_info(client_port_t *port, snd_seq_port_info_t *info);
116 /* add subscriber to subscription list */
117 int snd_seq_port_connect(client_t *caller, client_t *s, client_port_t *sp, client_t *d, client_port_t *dp, snd_seq_port_subscribe_t *info);
119 /* remove subscriber from subscription list */
120 int snd_seq_port_disconnect(client_t *caller, client_t *s, client_port_t *sp, client_t *d, client_port_t *dp, snd_seq_port_subscribe_t *info);
122 /* subscribe port */
123 int snd_seq_port_subscribe(client_port_t *port, snd_seq_port_subscribe_t *info);
125 /* get matched subscriber */
126 subscribers_t *snd_seq_port_get_subscription(port_subs_info_t *src_grp, snd_seq_addr_t *dest_addr);
128 #endif