Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *   ALSA sequencer Ports 
0004  *   Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
0005  */
0006 #ifndef __SND_SEQ_PORTS_H
0007 #define __SND_SEQ_PORTS_H
0008 
0009 #include <sound/seq_kernel.h>
0010 #include "seq_lock.h"
0011 
0012 /* list of 'exported' ports */
0013 
0014 /* Client ports that are not exported are still accessible, but are
0015  anonymous ports. 
0016  
0017  If a port supports SUBSCRIPTION, that port can send events to all
0018  subscribersto a special address, with address
0019  (queue==SNDRV_SEQ_ADDRESS_SUBSCRIBERS). The message is then send to all
0020  recipients that are registered in the subscription list. A typical
0021  application for these SUBSCRIPTION events is handling of incoming MIDI
0022  data. The port doesn't 'know' what other clients are interested in this
0023  message. If for instance a MIDI recording application would like to receive
0024  the events from that port, it will first have to subscribe with that port.
0025  
0026 */
0027 
0028 struct snd_seq_subscribers {
0029     struct snd_seq_port_subscribe info; /* additional info */
0030     struct list_head src_list;  /* link of sources */
0031     struct list_head dest_list; /* link of destinations */
0032     atomic_t ref_count;
0033 };
0034 
0035 struct snd_seq_port_subs_info {
0036     struct list_head list_head; /* list of subscribed ports */
0037     unsigned int count;     /* count of subscribers */
0038     unsigned int exclusive: 1;  /* exclusive mode */
0039     struct rw_semaphore list_mutex;
0040     rwlock_t list_lock;
0041     int (*open)(void *private_data, struct snd_seq_port_subscribe *info);
0042     int (*close)(void *private_data, struct snd_seq_port_subscribe *info);
0043 };
0044 
0045 struct snd_seq_client_port {
0046 
0047     struct snd_seq_addr addr;   /* client/port number */
0048     struct module *owner;       /* owner of this port */
0049     char name[64];          /* port name */ 
0050     struct list_head list;      /* port list */
0051     snd_use_lock_t use_lock;
0052 
0053     /* subscribers */
0054     struct snd_seq_port_subs_info c_src;    /* read (sender) list */
0055     struct snd_seq_port_subs_info c_dest;   /* write (dest) list */
0056 
0057     int (*event_input)(struct snd_seq_event *ev, int direct, void *private_data,
0058                int atomic, int hop);
0059     void (*private_free)(void *private_data);
0060     void *private_data;
0061     unsigned int closing : 1;
0062     unsigned int timestamping: 1;
0063     unsigned int time_real: 1;
0064     int time_queue;
0065     
0066     /* capability, inport, output, sync */
0067     unsigned int capability;    /* port capability bits */
0068     unsigned int type;      /* port type bits */
0069 
0070     /* supported channels */
0071     int midi_channels;
0072     int midi_voices;
0073     int synth_voices;
0074         
0075 };
0076 
0077 struct snd_seq_client;
0078 
0079 /* return pointer to port structure and lock port */
0080 struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client, int num);
0081 
0082 /* search for next port - port is locked if found */
0083 struct snd_seq_client_port *snd_seq_port_query_nearest(struct snd_seq_client *client,
0084                                struct snd_seq_port_info *pinfo);
0085 
0086 /* unlock the port */
0087 #define snd_seq_port_unlock(port) snd_use_lock_free(&(port)->use_lock)
0088 
0089 /* create a port, port number is returned (-1 on failure) */
0090 struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, int port_index);
0091 
0092 /* delete a port */
0093 int snd_seq_delete_port(struct snd_seq_client *client, int port);
0094 
0095 /* delete all ports */
0096 int snd_seq_delete_all_ports(struct snd_seq_client *client);
0097 
0098 /* set port info fields */
0099 int snd_seq_set_port_info(struct snd_seq_client_port *port,
0100               struct snd_seq_port_info *info);
0101 
0102 /* get port info fields */
0103 int snd_seq_get_port_info(struct snd_seq_client_port *port,
0104               struct snd_seq_port_info *info);
0105 
0106 /* add subscriber to subscription list */
0107 int snd_seq_port_connect(struct snd_seq_client *caller,
0108              struct snd_seq_client *s, struct snd_seq_client_port *sp,
0109              struct snd_seq_client *d, struct snd_seq_client_port *dp,
0110              struct snd_seq_port_subscribe *info);
0111 
0112 /* remove subscriber from subscription list */ 
0113 int snd_seq_port_disconnect(struct snd_seq_client *caller,
0114                 struct snd_seq_client *s, struct snd_seq_client_port *sp,
0115                 struct snd_seq_client *d, struct snd_seq_client_port *dp,
0116                 struct snd_seq_port_subscribe *info);
0117 
0118 /* subscribe port */
0119 int snd_seq_port_subscribe(struct snd_seq_client_port *port,
0120                struct snd_seq_port_subscribe *info);
0121 
0122 /* get matched subscriber */
0123 int snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp,
0124                   struct snd_seq_addr *dest_addr,
0125                   struct snd_seq_port_subscribe *subs);
0126 
0127 #endif