Lines Matching full:client

3  *  ALSA sequencer Client Manager
30 /* Client Manager
37 * There are four ranges of client numbers (last two shared):
39 * 16..127: statically allocated client numbers for cards 0..27
40 * 128..191: dynamically allocated client numbers for cards 28..31
41 * 128..191: dynamically allocated client numbers for applications
48 /* dynamically allocated client numbers (both kernel drivers and user space) */
59 * client table
68 static int bounce_error_event(struct snd_seq_client *client,
71 static int snd_seq_deliver_single_event(struct snd_seq_client *client,
76 static void free_ump_info(struct snd_seq_client *client);
93 static inline int snd_seq_write_pool_allocated(struct snd_seq_client *client) in snd_seq_write_pool_allocated() argument
95 return snd_seq_total_cells(client->pool) > 0; in snd_seq_write_pool_allocated()
98 /* return pointer to client structure for specified id */
102 pr_debug("ALSA: seq: oops. Trying to get pointer to client %d\n", in clientptr()
112 struct snd_seq_client *client; in snd_seq_client_use_ptr() local
115 pr_debug("ALSA: seq: oops. Trying to get pointer to client %d\n", in snd_seq_client_use_ptr()
120 client = clientptr(clientid); in snd_seq_client_use_ptr()
121 if (client) in snd_seq_client_use_ptr()
141 request_module("snd-seq-client-%i", in snd_seq_client_use_ptr()
157 client = clientptr(clientid); in snd_seq_client_use_ptr()
158 if (client) in snd_seq_client_use_ptr()
166 snd_use_lock_use(&client->use_lock); in snd_seq_client_use_ptr()
168 return client; in snd_seq_client_use_ptr()
171 /* Take refcount and perform ioctl_mutex lock on the given client;
177 struct snd_seq_client *client; in snd_seq_client_ioctl_lock() local
179 client = snd_seq_client_use_ptr(clientid); in snd_seq_client_ioctl_lock()
180 if (!client) in snd_seq_client_ioctl_lock()
182 mutex_lock(&client->ioctl_mutex); in snd_seq_client_ioctl_lock()
183 /* The client isn't unrefed here; see snd_seq_client_ioctl_unlock() */ in snd_seq_client_ioctl_lock()
188 /* Unlock and unref the given client; for OSS sequencer use only */
191 struct snd_seq_client *client; in snd_seq_client_ioctl_unlock() local
193 client = snd_seq_client_use_ptr(clientid); in snd_seq_client_ioctl_unlock()
194 if (WARN_ON(!client)) in snd_seq_client_ioctl_unlock()
196 mutex_unlock(&client->ioctl_mutex); in snd_seq_client_ioctl_unlock()
201 snd_seq_client_unlock(client); in snd_seq_client_ioctl_unlock()
202 snd_seq_client_unlock(client); in snd_seq_client_ioctl_unlock()
221 /* zap out the client table */ in client_init_data()
231 struct snd_seq_client *client; in seq_create_client1() local
233 /* init client data */ in seq_create_client1()
234 client = kzalloc(sizeof(*client), GFP_KERNEL); in seq_create_client1()
235 if (client == NULL) in seq_create_client1()
237 client->pool = snd_seq_pool_new(poolsize); in seq_create_client1()
238 if (client->pool == NULL) { in seq_create_client1()
239 kfree(client); in seq_create_client1()
242 client->type = NO_CLIENT; in seq_create_client1()
243 snd_use_lock_init(&client->use_lock); in seq_create_client1()
244 rwlock_init(&client->ports_lock); in seq_create_client1()
245 mutex_init(&client->ports_mutex); in seq_create_client1()
246 INIT_LIST_HEAD(&client->ports_list_head); in seq_create_client1()
247 mutex_init(&client->ioctl_mutex); in seq_create_client1()
248 client->ump_endpoint_port = -1; in seq_create_client1()
250 /* find free slot in the client table */ in seq_create_client1()
258 clienttab[client->number = c] = client; in seq_create_client1()
260 return client; in seq_create_client1()
264 clienttab[client->number = client_index] = client; in seq_create_client1()
266 return client; in seq_create_client1()
270 snd_seq_pool_delete(&client->pool); in seq_create_client1()
271 kfree(client); in seq_create_client1()
276 static int seq_free_client1(struct snd_seq_client *client) in seq_free_client1() argument
278 if (!client) in seq_free_client1()
281 clienttablock[client->number] = 1; in seq_free_client1()
282 clienttab[client->number] = NULL; in seq_free_client1()
284 snd_seq_delete_all_ports(client); in seq_free_client1()
285 snd_seq_queue_client_leave(client->number); in seq_free_client1()
286 snd_use_lock_sync(&client->use_lock); in seq_free_client1()
287 if (client->pool) in seq_free_client1()
288 snd_seq_pool_delete(&client->pool); in seq_free_client1()
290 clienttablock[client->number] = 0; in seq_free_client1()
296 static void seq_free_client(struct snd_seq_client * client) in seq_free_client() argument
299 switch (client->type) { in seq_free_client()
301 pr_warn("ALSA: seq: Trying to free unused client %d\n", in seq_free_client()
302 client->number); in seq_free_client()
306 seq_free_client1(client); in seq_free_client()
311 pr_err("ALSA: seq: Trying to free client %d with undefined type = %d\n", in seq_free_client()
312 client->number, client->type); in seq_free_client()
316 snd_seq_system_client_ev_client_exit(client->number); in seq_free_client()
323 /* create a user client */
326 int c, mode; /* client id */ in snd_seq_open()
327 struct snd_seq_client *client; in snd_seq_open() local
336 client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS); in snd_seq_open()
337 if (!client) { in snd_seq_open()
344 client->accept_input = 1; in snd_seq_open()
346 client->accept_output = 1; in snd_seq_open()
348 user = &client->data.user; in snd_seq_open()
356 seq_free_client1(client); in snd_seq_open()
357 kfree(client); in snd_seq_open()
364 client->type = USER_CLIENT; in snd_seq_open()
367 c = client->number; in snd_seq_open()
368 file->private_data = client; in snd_seq_open()
370 /* fill client data */ in snd_seq_open()
372 sprintf(client->name, "Client-%d", c); in snd_seq_open()
373 client->data.user.owner = get_pid(task_pid(current)); in snd_seq_open()
375 /* make others aware this new client */ in snd_seq_open()
381 /* delete a user client */
384 struct snd_seq_client *client = file->private_data; in snd_seq_release() local
386 if (client) { in snd_seq_release()
387 seq_free_client(client); in snd_seq_release()
388 if (client->data.user.fifo) in snd_seq_release()
389 snd_seq_fifo_delete(&client->data.user.fifo); in snd_seq_release()
391 free_ump_info(client); in snd_seq_release()
393 put_pid(client->data.user.owner); in snd_seq_release()
394 kfree(client); in snd_seq_release()
400 static bool event_is_compatible(const struct snd_seq_client *client, in event_is_compatible() argument
403 if (snd_seq_ev_is_ump(ev) && !client->midi_version) in event_is_compatible()
410 /* handle client read() */
412 * -ENXIO invalid client or file open mode
420 struct snd_seq_client *client = file->private_data; in snd_seq_read() local
433 /* check client structures are in place */ in snd_seq_read()
434 if (snd_BUG_ON(!client)) in snd_seq_read()
437 if (!client->accept_input) in snd_seq_read()
439 fifo = client->data.user.fifo; in snd_seq_read()
454 if (IS_ENABLED(CONFIG_SND_SEQ_UMP) && client->midi_version > 0) in snd_seq_read()
467 if (!event_is_compatible(client, &cell->event)) { in snd_seq_read()
527 * check if the destination client is available, and return the pointer
533 dest = snd_seq_client_use_ptr(event->dest.client); in get_event_dest_client()
555 * If the receiver client is a user client, the original event is
559 * If the receiver client is a kernel client, the original event is
563 static int bounce_error_event(struct snd_seq_client *client, in bounce_error_event() argument
570 if (client == NULL || in bounce_error_event()
571 ! (client->filter & SNDRV_SEQ_FILTER_BOUNCE) || in bounce_error_event()
572 ! client->accept_input) in bounce_error_event()
580 bounce_ev.source.client = SNDRV_SEQ_CLIENT_SYSTEM; in bounce_error_event()
582 bounce_ev.dest.client = client->number; in bounce_error_event()
589 client->event_lost++; in bounce_error_event()
647 * if filter is non-zero, client filter bitmap is tested.
652 static int snd_seq_deliver_single_event(struct snd_seq_client *client, in snd_seq_deliver_single_event() argument
683 result = snd_seq_deliver_from_ump(client, dest, dest_port, in snd_seq_deliver_single_event()
687 result = snd_seq_deliver_to_ump(client, dest, dest_port, in snd_seq_deliver_single_event()
704 result = bounce_error_event(client, event, result, atomic, hop); in snd_seq_deliver_single_event()
713 static int __deliver_to_subscribers(struct snd_seq_client *client, in __deliver_to_subscribers() argument
743 err = snd_seq_deliver_single_event(client, event, atomic, hop); in __deliver_to_subscribers()
762 static int deliver_to_subscribers(struct snd_seq_client *client, in deliver_to_subscribers() argument
769 src_port = snd_seq_port_use_ptr(client, event->source.port); in deliver_to_subscribers()
771 ret = __deliver_to_subscribers(client, event, src_port, atomic, hop); in deliver_to_subscribers()
775 if (client->ump_endpoint_port < 0 || in deliver_to_subscribers()
776 event->source.port == client->ump_endpoint_port) in deliver_to_subscribers()
779 src_port = snd_seq_port_use_ptr(client, client->ump_endpoint_port); in deliver_to_subscribers()
782 ret2 = __deliver_to_subscribers(client, event, src_port, atomic, hop); in deliver_to_subscribers()
792 * n == 0 : the event was not passed to any client.
795 static int snd_seq_deliver_event(struct snd_seq_client *client, struct snd_seq_event *event, in snd_seq_deliver_event() argument
803 event->source.client, event->source.port, in snd_seq_deliver_event()
804 event->dest.client, event->dest.port); in snd_seq_deliver_event()
813 event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) in snd_seq_deliver_event()
814 result = deliver_to_subscribers(client, event, atomic, hop); in snd_seq_deliver_event()
816 result = snd_seq_deliver_single_event(client, event, atomic, hop); in snd_seq_deliver_event()
828 * n == 0 : the event was not passed to any client.
833 struct snd_seq_client *client; in snd_seq_dispatch_event() local
839 client = snd_seq_client_use_ptr(cell->event.source.client); in snd_seq_dispatch_event()
840 if (client == NULL) { in snd_seq_dispatch_event()
856 result = snd_seq_deliver_event(client, &tmpev, atomic, hop); in snd_seq_dispatch_event()
891 result = snd_seq_deliver_event(client, &cell->event, atomic, hop); in snd_seq_dispatch_event()
895 snd_seq_client_unlock(client); in snd_seq_dispatch_event()
900 /* Allocate a cell from client pool and enqueue it to queue:
904 static int snd_seq_client_enqueue_event(struct snd_seq_client *client, in snd_seq_client_enqueue_event() argument
915 event->dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS; in snd_seq_client_enqueue_event()
917 } else if (event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) { in snd_seq_client_enqueue_event()
919 struct snd_seq_client_port *src_port = snd_seq_port_use_ptr(client, event->source.port); in snd_seq_client_enqueue_event()
930 return snd_seq_deliver_event(client, event, atomic, hop); in snd_seq_client_enqueue_event()
934 if (snd_seq_queue_is_used(event->queue, client->number) <= 0) in snd_seq_client_enqueue_event()
936 if (! snd_seq_write_pool_allocated(client)) in snd_seq_client_enqueue_event()
940 err = snd_seq_event_dup(client->pool, event, &cell, !blocking || atomic, in snd_seq_client_enqueue_event()
983 * -ENXIO invalid client or file open mode
995 struct snd_seq_client *client = file->private_data; in snd_seq_write() local
1004 /* check client structures are in place */ in snd_seq_write()
1005 if (snd_BUG_ON(!client)) in snd_seq_write()
1008 if (!client->accept_output || client->pool == NULL) in snd_seq_write()
1014 mutex_lock(&client->ioctl_mutex); in snd_seq_write()
1015 if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) { in snd_seq_write()
1016 err = snd_seq_pool_init(client->pool); in snd_seq_write()
1042 ev->source.client = client->number; /* fill in client number */ in snd_seq_write()
1049 if (!event_is_compatible(client, ev)) { in snd_seq_write()
1077 if (client->convert32 && snd_seq_ev_is_varusr(ev)) in snd_seq_write()
1084 err = snd_seq_client_enqueue_event(client, ev, file, in snd_seq_write()
1086 0, 0, &client->ioctl_mutex); in snd_seq_write()
1099 mutex_unlock(&client->ioctl_mutex); in snd_seq_write()
1105 mutex_unlock(&client->ioctl_mutex); in snd_seq_write()
1115 struct snd_seq_client *client = file->private_data; in snd_seq_poll() local
1118 /* check client structures are in place */ in snd_seq_poll()
1119 if (snd_BUG_ON(!client)) in snd_seq_poll()
1123 client->data.user.fifo) { in snd_seq_poll()
1126 if (snd_seq_fifo_poll_wait(client->data.user.fifo, file, wait)) in snd_seq_poll()
1133 if (!snd_seq_write_pool_allocated(client) || in snd_seq_poll()
1134 snd_seq_pool_poll_wait(client->pool, file, wait)) in snd_seq_poll()
1144 static int snd_seq_ioctl_pversion(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_pversion() argument
1152 static int snd_seq_ioctl_user_pversion(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_user_pversion() argument
1154 client->user_pversion = *(unsigned int *)arg; in snd_seq_ioctl_user_pversion()
1158 static int snd_seq_ioctl_client_id(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_client_id() argument
1162 *client_id = client->number; in snd_seq_ioctl_client_id()
1167 static int snd_seq_ioctl_system_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_system_info() argument
1185 static int snd_seq_ioctl_running_mode(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_running_mode() argument
1191 /* requested client number */ in snd_seq_ioctl_running_mode()
1192 cptr = snd_seq_client_use_ptr(info->client); in snd_seq_ioctl_running_mode()
1222 info->client = cptr->number; in get_client_info()
1247 static int snd_seq_ioctl_get_client_info(struct snd_seq_client *client, in snd_seq_ioctl_get_client_info() argument
1253 /* requested client number */ in snd_seq_ioctl_get_client_info()
1254 cptr = snd_seq_client_use_ptr(client_info->client); in snd_seq_ioctl_get_client_info()
1266 static int snd_seq_ioctl_set_client_info(struct snd_seq_client *client, in snd_seq_ioctl_set_client_info() argument
1271 /* it is not allowed to set the info fields for an another client */ in snd_seq_ioctl_set_client_info()
1272 if (client->number != client_info->client) in snd_seq_ioctl_set_client_info()
1274 /* also client type must be set now */ in snd_seq_ioctl_set_client_info()
1275 if (client->type != client_info->type) in snd_seq_ioctl_set_client_info()
1279 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3) && in snd_seq_ioctl_set_client_info()
1285 strscpy(client->name, client_info->name, sizeof(client->name)); in snd_seq_ioctl_set_client_info()
1287 client->filter = client_info->filter; in snd_seq_ioctl_set_client_info()
1288 client->event_lost = client_info->event_lost; in snd_seq_ioctl_set_client_info()
1289 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3)) in snd_seq_ioctl_set_client_info()
1290 client->midi_version = client_info->midi_version; in snd_seq_ioctl_set_client_info()
1291 memcpy(client->event_filter, client_info->event_filter, 32); in snd_seq_ioctl_set_client_info()
1292 client->group_filter = client_info->group_filter; in snd_seq_ioctl_set_client_info()
1300 static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_create_port() argument
1307 /* it is not allowed to create the port for an another client */ in snd_seq_ioctl_create_port()
1308 if (info->addr.client != client->number) in snd_seq_ioctl_create_port()
1310 if (client->type == USER_CLIENT && info->kernel) in snd_seq_ioctl_create_port()
1313 client->ump_endpoint_port >= 0) in snd_seq_ioctl_create_port()
1322 err = snd_seq_create_port(client, port_idx, &port); in snd_seq_ioctl_create_port()
1326 if (client->type == KERNEL_CLIENT) { in snd_seq_ioctl_create_port()
1345 client->ump_endpoint_port = port->addr.port; in snd_seq_ioctl_create_port()
1346 snd_seq_system_client_ev_port_start(port->addr.client, port->addr.port); in snd_seq_ioctl_create_port()
1355 static int snd_seq_ioctl_delete_port(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_delete_port() argument
1360 /* it is not allowed to remove the port for an another client */ in snd_seq_ioctl_delete_port()
1361 if (info->addr.client != client->number) in snd_seq_ioctl_delete_port()
1364 err = snd_seq_delete_port(client, info->addr.port); in snd_seq_ioctl_delete_port()
1366 if (client->ump_endpoint_port == info->addr.port) in snd_seq_ioctl_delete_port()
1367 client->ump_endpoint_port = -1; in snd_seq_ioctl_delete_port()
1368 snd_seq_system_client_ev_port_exit(client->number, info->addr.port); in snd_seq_ioctl_delete_port()
1375 * GET_PORT_INFO ioctl() (on any client)
1377 static int snd_seq_ioctl_get_port_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_get_port_info() argument
1383 cptr = snd_seq_client_use_ptr(info->addr.client); in snd_seq_ioctl_get_port_info()
1403 * SET_PORT_INFO ioctl() (only ports on this/own client)
1405 static int snd_seq_ioctl_set_port_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_set_port_info() argument
1410 if (info->addr.client != client->number) /* only set our own ports ! */ in snd_seq_ioctl_set_port_info()
1412 port = snd_seq_port_use_ptr(client, info->addr.port); in snd_seq_ioctl_set_port_info()
1427 static int check_subscription_permission(struct snd_seq_client *client, in check_subscription_permission() argument
1432 if (client->number != subs->sender.client && in check_subscription_permission()
1433 client->number != subs->dest.client) { in check_subscription_permission()
1434 /* connection by third client - check export permission */ in check_subscription_permission()
1442 /* if sender or receiver is the subscribing client itself, in check_subscription_permission()
1445 if (client->number != subs->sender.client) { in check_subscription_permission()
1450 if (client->number != subs->dest.client) { in check_subscription_permission()
1458 * send an subscription notify event to user client:
1459 * client must be user client.
1461 int snd_seq_client_notify_subscription(int client, int port, in snd_seq_client_notify_subscription() argument
1472 return snd_seq_system_notify(client, port, &event); /* non-atomic */ in snd_seq_client_notify_subscription()
1479 static int snd_seq_ioctl_subscribe_port(struct snd_seq_client *client, in snd_seq_ioctl_subscribe_port() argument
1487 receiver = snd_seq_client_use_ptr(subs->dest.client); in snd_seq_ioctl_subscribe_port()
1490 sender = snd_seq_client_use_ptr(subs->sender.client); in snd_seq_ioctl_subscribe_port()
1500 result = check_subscription_permission(client, sport, dport, subs); in snd_seq_ioctl_subscribe_port()
1505 result = snd_seq_port_connect(client, sender, sport, receiver, dport, subs); in snd_seq_ioctl_subscribe_port()
1525 static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client, in snd_seq_ioctl_unsubscribe_port() argument
1533 receiver = snd_seq_client_use_ptr(subs->dest.client); in snd_seq_ioctl_unsubscribe_port()
1536 sender = snd_seq_client_use_ptr(subs->sender.client); in snd_seq_ioctl_unsubscribe_port()
1546 result = check_subscription_permission(client, sport, dport, subs); in snd_seq_ioctl_unsubscribe_port()
1550 result = snd_seq_port_disconnect(client, sender, sport, receiver, dport, subs); in snd_seq_ioctl_unsubscribe_port()
1568 static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_create_queue() argument
1573 q = snd_seq_queue_alloc(client->number, info->locked, info->flags); in snd_seq_ioctl_create_queue()
1591 static int snd_seq_ioctl_delete_queue(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_delete_queue() argument
1595 return snd_seq_queue_delete(client->number, info->queue); in snd_seq_ioctl_delete_queue()
1599 static int snd_seq_ioctl_get_queue_info(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_info() argument
1620 static int snd_seq_ioctl_set_queue_info(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_info() argument
1626 if (info->owner != client->number) in snd_seq_ioctl_set_queue_info()
1630 if (snd_seq_queue_check_access(info->queue, client->number)) { in snd_seq_ioctl_set_queue_info()
1631 if (snd_seq_queue_set_owner(info->queue, client->number, info->locked) < 0) in snd_seq_ioctl_set_queue_info()
1634 snd_seq_queue_use(info->queue, client->number, 1); in snd_seq_ioctl_set_queue_info()
1642 if (q->owner != client->number) { in snd_seq_ioctl_set_queue_info()
1653 static int snd_seq_ioctl_get_named_queue(struct snd_seq_client *client, in snd_seq_ioctl_get_named_queue() argument
1671 static int snd_seq_ioctl_get_queue_status(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_status() argument
1700 static int snd_seq_ioctl_get_queue_tempo(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_tempo() argument
1719 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 4)) in snd_seq_ioctl_get_queue_tempo()
1728 int snd_seq_set_queue_tempo(int client, struct snd_seq_queue_tempo *tempo) in snd_seq_set_queue_tempo() argument
1730 if (!snd_seq_queue_check_access(tempo->queue, client)) in snd_seq_set_queue_tempo()
1732 return snd_seq_queue_timer_set_tempo(tempo->queue, client, tempo); in snd_seq_set_queue_tempo()
1736 static int snd_seq_ioctl_set_queue_tempo(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_tempo() argument
1742 if (client->user_pversion < SNDRV_PROTOCOL_VERSION(1, 0, 4)) in snd_seq_ioctl_set_queue_tempo()
1744 result = snd_seq_set_queue_tempo(client->number, tempo); in snd_seq_ioctl_set_queue_tempo()
1750 static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_timer() argument
1779 static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_timer() argument
1788 if (snd_seq_queue_check_access(timer->queue, client->number)) { in snd_seq_ioctl_set_queue_timer()
1815 static int snd_seq_ioctl_get_queue_client(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_client() argument
1821 used = snd_seq_queue_is_used(info->queue, client->number); in snd_seq_ioctl_get_queue_client()
1825 info->client = client->number; in snd_seq_ioctl_get_queue_client()
1832 static int snd_seq_ioctl_set_queue_client(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_client() argument
1839 err = snd_seq_queue_use(info->queue, client->number, info->used); in snd_seq_ioctl_set_queue_client()
1844 return snd_seq_ioctl_get_queue_client(client, arg); in snd_seq_ioctl_set_queue_client()
1849 static int snd_seq_ioctl_get_client_pool(struct snd_seq_client *client, in snd_seq_ioctl_get_client_pool() argument
1855 cptr = snd_seq_client_use_ptr(info->client); in snd_seq_ioctl_get_client_pool()
1859 info->client = cptr->number; in snd_seq_ioctl_get_client_pool()
1878 static int snd_seq_ioctl_set_client_pool(struct snd_seq_client *client, in snd_seq_ioctl_set_client_pool() argument
1884 if (client->number != info->client) in snd_seq_ioctl_set_client_pool()
1888 (! snd_seq_write_pool_allocated(client) || in snd_seq_ioctl_set_client_pool()
1889 info->output_pool != client->pool->size)) { in snd_seq_ioctl_set_client_pool()
1890 if (snd_seq_write_pool_allocated(client)) { in snd_seq_ioctl_set_client_pool()
1892 if (atomic_read(&client->pool->counter)) in snd_seq_ioctl_set_client_pool()
1895 snd_seq_pool_mark_closing(client->pool); in snd_seq_ioctl_set_client_pool()
1896 snd_seq_pool_done(client->pool); in snd_seq_ioctl_set_client_pool()
1898 client->pool->size = info->output_pool; in snd_seq_ioctl_set_client_pool()
1899 rc = snd_seq_pool_init(client->pool); in snd_seq_ioctl_set_client_pool()
1903 if (client->type == USER_CLIENT && client->data.user.fifo != NULL && in snd_seq_ioctl_set_client_pool()
1906 info->input_pool != client->data.user.fifo_pool_size) { in snd_seq_ioctl_set_client_pool()
1908 rc = snd_seq_fifo_resize(client->data.user.fifo, info->input_pool); in snd_seq_ioctl_set_client_pool()
1911 client->data.user.fifo_pool_size = info->input_pool; in snd_seq_ioctl_set_client_pool()
1914 info->output_room <= client->pool->size) { in snd_seq_ioctl_set_client_pool()
1915 client->pool->room = info->output_room; in snd_seq_ioctl_set_client_pool()
1918 return snd_seq_ioctl_get_client_pool(client, arg); in snd_seq_ioctl_set_client_pool()
1923 static int snd_seq_ioctl_remove_events(struct snd_seq_client *client, in snd_seq_ioctl_remove_events() argument
1933 * No restrictions so for a user client we can clear in snd_seq_ioctl_remove_events()
1936 if (client->type == USER_CLIENT && client->data.user.fifo) in snd_seq_ioctl_remove_events()
1937 snd_seq_fifo_clear(client->data.user.fifo); in snd_seq_ioctl_remove_events()
1941 snd_seq_queue_remove_cells(client->number, info); in snd_seq_ioctl_remove_events()
1950 static int snd_seq_ioctl_get_subscription(struct snd_seq_client *client, in snd_seq_ioctl_get_subscription() argument
1959 sender = snd_seq_client_use_ptr(subs->sender.client); in snd_seq_ioctl_get_subscription()
1980 static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_query_subs() argument
1990 cptr = snd_seq_client_use_ptr(subs->root.client); in snd_seq_ioctl_query_subs()
2043 * query next client
2045 static int snd_seq_ioctl_query_next_client(struct snd_seq_client *client, in snd_seq_ioctl_query_next_client() argument
2051 /* search for next client */ in snd_seq_ioctl_query_next_client()
2052 if (info->client < INT_MAX) in snd_seq_ioctl_query_next_client()
2053 info->client++; in snd_seq_ioctl_query_next_client()
2054 if (info->client < 0) in snd_seq_ioctl_query_next_client()
2055 info->client = 0; in snd_seq_ioctl_query_next_client()
2056 for (; info->client < SNDRV_SEQ_MAX_CLIENTS; info->client++) { in snd_seq_ioctl_query_next_client()
2057 cptr = snd_seq_client_use_ptr(info->client); in snd_seq_ioctl_query_next_client()
2073 static int snd_seq_ioctl_query_next_port(struct snd_seq_client *client, in snd_seq_ioctl_query_next_port() argument
2080 cptr = snd_seq_client_use_ptr(info->addr.client); in snd_seq_ioctl_query_next_port()
2104 static void free_ump_info(struct snd_seq_client *client) in free_ump_info() argument
2108 if (!client->ump_info) in free_ump_info()
2111 kfree(client->ump_info[i]); in free_ump_info()
2112 kfree(client->ump_info); in free_ump_info()
2113 client->ump_info = NULL; in free_ump_info()
2129 struct snd_seq_client *client) in dump_ump_info() argument
2135 if (!client->ump_info) in dump_ump_info()
2137 ep = client->ump_info[SNDRV_SEQ_CLIENT_UMP_INFO_ENDPOINT]; in dump_ump_info()
2141 bp = client->ump_info[i + 1]; in dump_ump_info()
2162 int client, type, err = 0; in snd_seq_ioctl_client_ump_info() local
2166 if (get_user(client, &argp->client) || get_user(type, &argp->type)) in snd_seq_ioctl_client_ump_info()
2169 caller->number != client) in snd_seq_ioctl_client_ump_info()
2177 cptr = snd_seq_client_use_ptr(client); in snd_seq_ioctl_client_ump_info()
2234 int (*func)(struct snd_seq_client *client, void *arg);
2274 struct snd_seq_client *client = file->private_data; in snd_seq_ioctl() local
2297 if (snd_BUG_ON(!client)) in snd_seq_ioctl()
2305 return snd_seq_ioctl_client_ump_info(client, cmd, arg); in snd_seq_ioctl()
2328 mutex_lock(&client->ioctl_mutex); in snd_seq_ioctl()
2329 err = handler->func(client, &buf); in snd_seq_ioctl()
2330 mutex_unlock(&client->ioctl_mutex); in snd_seq_ioctl()
2356 struct snd_seq_client *client; in snd_seq_create_kernel_client() local
2377 client = seq_create_client1(client_index, 0); in snd_seq_create_kernel_client()
2378 if (client == NULL) { in snd_seq_create_kernel_client()
2384 client->accept_input = 1; in snd_seq_create_kernel_client()
2385 client->accept_output = 1; in snd_seq_create_kernel_client()
2386 client->data.kernel.card = card; in snd_seq_create_kernel_client()
2387 client->user_pversion = SNDRV_SEQ_VERSION; in snd_seq_create_kernel_client()
2390 vsnprintf(client->name, sizeof(client->name), name_fmt, args); in snd_seq_create_kernel_client()
2393 client->type = KERNEL_CLIENT; in snd_seq_create_kernel_client()
2396 /* make others aware this new client */ in snd_seq_create_kernel_client()
2397 snd_seq_system_client_ev_client_start(client->number); in snd_seq_create_kernel_client()
2399 /* return client number to caller */ in snd_seq_create_kernel_client()
2400 return client->number; in snd_seq_create_kernel_client()
2405 int snd_seq_delete_kernel_client(int client) in snd_seq_delete_kernel_client() argument
2412 ptr = clientptr(client); in snd_seq_delete_kernel_client()
2427 int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, in snd_seq_kernel_client_enqueue() argument
2443 /* fill in client number */ in snd_seq_kernel_client_enqueue()
2444 ev->source.client = client; in snd_seq_kernel_client_enqueue()
2449 cptr = snd_seq_client_use_ptr(client); in snd_seq_kernel_client_enqueue()
2475 int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event * ev, in snd_seq_kernel_client_dispatch() argument
2484 /* fill in client number */ in snd_seq_kernel_client_dispatch()
2486 ev->source.client = client; in snd_seq_kernel_client_dispatch()
2491 cptr = snd_seq_client_use_ptr(client); in snd_seq_kernel_client_dispatch()
2506 * snd_seq_kernel_client_ctl - operate a command for a client with data in
2508 * @clientid: A numerical ID for a client.
2512 * Against its name, both kernel/application client can be handled by this
2520 struct snd_seq_client *client; in snd_seq_kernel_client_ctl() local
2522 client = clientptr(clientid); in snd_seq_kernel_client_ctl()
2523 if (client == NULL) in snd_seq_kernel_client_ctl()
2528 return handler->func(client, arg); in snd_seq_kernel_client_ctl()
2540 struct snd_seq_client *client; in snd_seq_kernel_client_write_poll() local
2542 client = clientptr(clientid); in snd_seq_kernel_client_write_poll()
2543 if (client == NULL) in snd_seq_kernel_client_write_poll()
2546 if (! snd_seq_write_pool_allocated(client)) in snd_seq_kernel_client_write_poll()
2548 if (snd_seq_pool_poll_wait(client->pool, file, wait)) in snd_seq_kernel_client_write_poll()
2554 /* get a sequencer client object; for internal use from a kernel client */
2561 /* put a sequencer client object; for internal use from a kernel client */
2597 is_src ? s->info.dest.client : s->info.sender.client, in snd_seq_info_dump_subscribers()
2626 struct snd_seq_client *client) in snd_seq_info_dump_ports() argument
2630 mutex_lock(&client->ports_mutex); in snd_seq_info_dump_ports()
2631 list_for_each_entry(p, &client->ports_list_head, list) { in snd_seq_info_dump_ports()
2642 if (snd_seq_client_is_midi2(client) && p->is_midi1) in snd_seq_info_dump_ports()
2649 mutex_unlock(&client->ports_mutex); in snd_seq_info_dump_ports()
2671 struct snd_seq_client *client; in snd_seq_info_clients_read() local
2673 snd_iprintf(buffer, "Client info\n"); in snd_seq_info_clients_read()
2679 /* list the client table */ in snd_seq_info_clients_read()
2681 client = snd_seq_client_use_ptr(c); in snd_seq_info_clients_read()
2682 if (client == NULL) in snd_seq_info_clients_read()
2684 if (client->type == NO_CLIENT) { in snd_seq_info_clients_read()
2685 snd_seq_client_unlock(client); in snd_seq_info_clients_read()
2689 snd_iprintf(buffer, "Client %3d : \"%s\" [%s %s]\n", in snd_seq_info_clients_read()
2690 c, client->name, in snd_seq_info_clients_read()
2691 client->type == USER_CLIENT ? "User" : "Kernel", in snd_seq_info_clients_read()
2692 midi_version_string(client->midi_version)); in snd_seq_info_clients_read()
2694 dump_ump_info(buffer, client); in snd_seq_info_clients_read()
2696 snd_seq_info_dump_ports(buffer, client); in snd_seq_info_clients_read()
2697 if (snd_seq_write_pool_allocated(client)) { in snd_seq_info_clients_read()
2699 snd_seq_info_pool(buffer, client->pool, " "); in snd_seq_info_clients_read()
2701 if (client->type == USER_CLIENT && client->data.user.fifo && in snd_seq_info_clients_read()
2702 client->data.user.fifo->pool) { in snd_seq_info_clients_read()
2704 snd_seq_info_pool(buffer, client->data.user.fifo->pool, " "); in snd_seq_info_clients_read()
2706 snd_seq_client_unlock(client); in snd_seq_info_clients_read()