projects/linux·blob master · refs

129 lines · 3.3 KiB

1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * ALSA sequencer Client Manager
4 * Copyright (c) 1998-1999 by Frank van de Pol <[email protected]>
5 */
6#ifndef __SND_SEQ_CLIENTMGR_H
7#define __SND_SEQ_CLIENTMGR_H
8
9#include <sound/seq_kernel.h>
10#include <linux/bitops.h>
11#include "seq_fifo.h"
12#include "seq_ports.h"
13#include "seq_lock.h"
14
15/* client manager */
16
17#define SND_SEQ_GROUP_FILTER_MASK GENMASK(SNDRV_UMP_MAX_GROUPS, 0)
18#define SND_SEQ_GROUP_FILTER_GROUPS GENMASK(SNDRV_UMP_MAX_GROUPS, 1)
19
20struct snd_seq_user_client {
21 struct file *file; /* file struct of client */
22 /* ... */
23 struct pid *owner;
24
25 /* fifo */
26 struct snd_seq_fifo *fifo; /* queue for incoming events */
27 int fifo_pool_size;
28};
29
30struct snd_seq_kernel_client {
31 /* ... */
32 struct snd_card *card;
33};
34
35
36struct snd_seq_client {
37 snd_seq_client_type_t type;
38 unsigned int accept_input: 1,
39 accept_output: 1;
40 unsigned int midi_version;
41 unsigned int user_pversion;
42 char name[64]; /* client name */
43 int number; /* client number */
44 unsigned int filter; /* filter flags */
45 DECLARE_BITMAP(event_filter, 256);
46 unsigned int group_filter;
47 snd_use_lock_t use_lock;
48 int event_lost;
49 /* ports */
50 int num_ports; /* number of ports */
51 struct list_head ports_list_head;
52 struct mutex ports_mutex;
53 struct mutex ioctl_mutex;
54 int convert32; /* convert 32->64bit */
55 int ump_endpoint_port;
56
57 /* output pool */
58 struct snd_seq_pool *pool; /* memory pool for this client */
59
60 union {
61 struct snd_seq_user_client user;
62 struct snd_seq_kernel_client kernel;
63 } data;
64
65 /* for UMP */
66 void **ump_info;
67};
68
69/* usage statistics */
70struct snd_seq_usage {
71 int cur;
72 int peak;
73};
74
75
76int client_init_data(void);
77int snd_sequencer_device_init(void);
78void snd_sequencer_device_done(void);
79
80/* get locked pointer to client */
81struct snd_seq_client *snd_seq_client_use_ptr(int clientid);
82
83static inline struct snd_seq_client *
84snd_seq_client_ref(struct snd_seq_client *client)
85{
86 snd_use_lock_use(&client->use_lock);
87 return client;
88}
89
90/* unlock pointer to client */
91static inline void snd_seq_client_unref(struct snd_seq_client *client)
92{
93 snd_use_lock_free(&client->use_lock);
94}
95
96DEFINE_FREE(snd_seq_client, struct snd_seq_client *, if (!IS_ERR_OR_NULL(_T)) snd_seq_client_unref(_T))
97
98/* dispatch event to client(s) */
99int snd_seq_dispatch_event(struct snd_seq_event_cell *cell, int atomic, int hop);
100
101int snd_seq_kernel_client_write_poll(int clientid, struct file *file, poll_table *wait);
102int snd_seq_client_notify_subscription(int client, int port,
103 struct snd_seq_port_subscribe *info, int evtype);
104
105int __snd_seq_deliver_single_event(struct snd_seq_client *dest,
106 struct snd_seq_client_port *dest_port,
107 struct snd_seq_event *event,
108 int atomic, int hop);
109
110/* only for OSS sequencer */
111int snd_seq_kernel_client_ioctl(int clientid, unsigned int cmd, void *arg);
112
113extern int seq_client_load[15];
114
115/* for internal use between kernel sequencer clients */
116struct snd_seq_client *snd_seq_kernel_client_get(int client);
117void snd_seq_kernel_client_put(struct snd_seq_client *cptr);
118
119static inline bool snd_seq_client_is_ump(struct snd_seq_client *c)
120{
121 return c->midi_version != SNDRV_SEQ_CLIENT_LEGACY_MIDI;
122}
123
124static inline bool snd_seq_client_is_midi2(struct snd_seq_client *c)
125{
126 return c->midi_version == SNDRV_SEQ_CLIENT_UMP_MIDI_2_0;
127}
128
129#endif