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
528 * if filter is non-zero, client filter bitmap is tested.
535 dest = snd_seq_client_use_ptr(event->dest.client); in get_event_dest_client()
556 * If the receiver client is a user client, the original event is
560 * If the receiver client is a kernel client, the original event is
564 static int bounce_error_event(struct snd_seq_client *client, in bounce_error_event() argument
571 if (client == NULL || in bounce_error_event()
572 ! (client->filter & SNDRV_SEQ_FILTER_BOUNCE) || in bounce_error_event()
573 ! client->accept_input) in bounce_error_event()
581 bounce_ev.source.client = SNDRV_SEQ_CLIENT_SYSTEM; in bounce_error_event()
583 bounce_ev.dest.client = client->number; in bounce_error_event()
590 client->event_lost++; in bounce_error_event()
648 * if filter is non-zero, client filter bitmap is tested.
653 static int snd_seq_deliver_single_event(struct snd_seq_client *client, in snd_seq_deliver_single_event() argument
684 result = snd_seq_deliver_from_ump(client, dest, dest_port, in snd_seq_deliver_single_event()
688 result = snd_seq_deliver_to_ump(client, dest, dest_port, in snd_seq_deliver_single_event()
705 result = bounce_error_event(client, event, result, atomic, hop); in snd_seq_deliver_single_event()
714 static int __deliver_to_subscribers(struct snd_seq_client *client, in __deliver_to_subscribers() argument
744 err = snd_seq_deliver_single_event(client, event, in __deliver_to_subscribers()
764 static int deliver_to_subscribers(struct snd_seq_client *client, in deliver_to_subscribers() argument
771 src_port = snd_seq_port_use_ptr(client, event->source.port); in deliver_to_subscribers()
773 ret = __deliver_to_subscribers(client, event, src_port, atomic, hop); in deliver_to_subscribers()
777 if (client->ump_endpoint_port < 0 || in deliver_to_subscribers()
778 event->source.port == client->ump_endpoint_port) in deliver_to_subscribers()
781 src_port = snd_seq_port_use_ptr(client, client->ump_endpoint_port); in deliver_to_subscribers()
784 ret2 = __deliver_to_subscribers(client, event, src_port, atomic, hop); in deliver_to_subscribers()
794 * n == 0 : the event was not passed to any client.
797 static int snd_seq_deliver_event(struct snd_seq_client *client, struct snd_seq_event *event, in snd_seq_deliver_event() argument
805 event->source.client, event->source.port, in snd_seq_deliver_event()
806 event->dest.client, event->dest.port); in snd_seq_deliver_event()
815 event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) in snd_seq_deliver_event()
816 result = deliver_to_subscribers(client, event, atomic, hop); in snd_seq_deliver_event()
818 result = snd_seq_deliver_single_event(client, event, 0, atomic, hop); in snd_seq_deliver_event()
830 * n == 0 : the event was not passed to any client.
835 struct snd_seq_client *client; in snd_seq_dispatch_event() local
841 client = snd_seq_client_use_ptr(cell->event.source.client); in snd_seq_dispatch_event()
842 if (client == NULL) { in snd_seq_dispatch_event()
858 result = snd_seq_deliver_event(client, &tmpev, atomic, hop); in snd_seq_dispatch_event()
893 result = snd_seq_deliver_event(client, &cell->event, atomic, hop); in snd_seq_dispatch_event()
897 snd_seq_client_unlock(client); in snd_seq_dispatch_event()
902 /* Allocate a cell from client pool and enqueue it to queue:
906 static int snd_seq_client_enqueue_event(struct snd_seq_client *client, in snd_seq_client_enqueue_event() argument
917 event->dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS; in snd_seq_client_enqueue_event()
919 } else if (event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) { in snd_seq_client_enqueue_event()
921 struct snd_seq_client_port *src_port = snd_seq_port_use_ptr(client, event->source.port); in snd_seq_client_enqueue_event()
932 return snd_seq_deliver_event(client, event, atomic, hop); in snd_seq_client_enqueue_event()
936 if (snd_seq_queue_is_used(event->queue, client->number) <= 0) in snd_seq_client_enqueue_event()
938 if (! snd_seq_write_pool_allocated(client)) in snd_seq_client_enqueue_event()
942 err = snd_seq_event_dup(client->pool, event, &cell, !blocking || atomic, in snd_seq_client_enqueue_event()
985 * -ENXIO invalid client or file open mode
997 struct snd_seq_client *client = file->private_data; in snd_seq_write() local
1006 /* check client structures are in place */ in snd_seq_write()
1007 if (snd_BUG_ON(!client)) in snd_seq_write()
1010 if (!client->accept_output || client->pool == NULL) in snd_seq_write()
1016 mutex_lock(&client->ioctl_mutex); in snd_seq_write()
1017 if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) { in snd_seq_write()
1018 err = snd_seq_pool_init(client->pool); in snd_seq_write()
1044 ev->source.client = client->number; /* fill in client number */ in snd_seq_write()
1051 if (!event_is_compatible(client, ev)) { in snd_seq_write()
1079 if (client->convert32 && snd_seq_ev_is_varusr(ev)) in snd_seq_write()
1086 err = snd_seq_client_enqueue_event(client, ev, file, in snd_seq_write()
1088 0, 0, &client->ioctl_mutex); in snd_seq_write()
1101 mutex_unlock(&client->ioctl_mutex); in snd_seq_write()
1107 mutex_unlock(&client->ioctl_mutex); in snd_seq_write()
1117 struct snd_seq_client *client = file->private_data; in snd_seq_poll() local
1120 /* check client structures are in place */ in snd_seq_poll()
1121 if (snd_BUG_ON(!client)) in snd_seq_poll()
1125 client->data.user.fifo) { in snd_seq_poll()
1128 if (snd_seq_fifo_poll_wait(client->data.user.fifo, file, wait)) in snd_seq_poll()
1135 if (!snd_seq_write_pool_allocated(client) || in snd_seq_poll()
1136 snd_seq_pool_poll_wait(client->pool, file, wait)) in snd_seq_poll()
1146 static int snd_seq_ioctl_pversion(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_pversion() argument
1154 static int snd_seq_ioctl_user_pversion(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_user_pversion() argument
1156 client->user_pversion = *(unsigned int *)arg; in snd_seq_ioctl_user_pversion()
1160 static int snd_seq_ioctl_client_id(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_client_id() argument
1164 *client_id = client->number; in snd_seq_ioctl_client_id()
1169 static int snd_seq_ioctl_system_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_system_info() argument
1187 static int snd_seq_ioctl_running_mode(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_running_mode() argument
1193 /* requested client number */ in snd_seq_ioctl_running_mode()
1194 cptr = snd_seq_client_use_ptr(info->client); in snd_seq_ioctl_running_mode()
1224 info->client = cptr->number; in get_client_info()
1249 static int snd_seq_ioctl_get_client_info(struct snd_seq_client *client, in snd_seq_ioctl_get_client_info() argument
1255 /* requested client number */ in snd_seq_ioctl_get_client_info()
1256 cptr = snd_seq_client_use_ptr(client_info->client); in snd_seq_ioctl_get_client_info()
1268 static int snd_seq_ioctl_set_client_info(struct snd_seq_client *client, in snd_seq_ioctl_set_client_info() argument
1273 /* it is not allowed to set the info fields for an another client */ in snd_seq_ioctl_set_client_info()
1274 if (client->number != client_info->client) in snd_seq_ioctl_set_client_info()
1276 /* also client type must be set now */ in snd_seq_ioctl_set_client_info()
1277 if (client->type != client_info->type) in snd_seq_ioctl_set_client_info()
1281 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3) && in snd_seq_ioctl_set_client_info()
1287 strscpy(client->name, client_info->name, sizeof(client->name)); in snd_seq_ioctl_set_client_info()
1289 client->filter = client_info->filter; in snd_seq_ioctl_set_client_info()
1290 client->event_lost = client_info->event_lost; in snd_seq_ioctl_set_client_info()
1291 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3)) in snd_seq_ioctl_set_client_info()
1292 client->midi_version = client_info->midi_version; in snd_seq_ioctl_set_client_info()
1293 memcpy(client->event_filter, client_info->event_filter, 32); in snd_seq_ioctl_set_client_info()
1294 client->group_filter = client_info->group_filter; in snd_seq_ioctl_set_client_info()
1302 static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_create_port() argument
1309 /* it is not allowed to create the port for an another client */ in snd_seq_ioctl_create_port()
1310 if (info->addr.client != client->number) in snd_seq_ioctl_create_port()
1312 if (client->type == USER_CLIENT && info->kernel) in snd_seq_ioctl_create_port()
1315 client->ump_endpoint_port >= 0) in snd_seq_ioctl_create_port()
1324 err = snd_seq_create_port(client, port_idx, &port); in snd_seq_ioctl_create_port()
1328 if (client->type == KERNEL_CLIENT) { in snd_seq_ioctl_create_port()
1347 client->ump_endpoint_port = port->addr.port; in snd_seq_ioctl_create_port()
1348 snd_seq_system_client_ev_port_start(port->addr.client, port->addr.port); in snd_seq_ioctl_create_port()
1357 static int snd_seq_ioctl_delete_port(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_delete_port() argument
1362 /* it is not allowed to remove the port for an another client */ in snd_seq_ioctl_delete_port()
1363 if (info->addr.client != client->number) in snd_seq_ioctl_delete_port()
1366 err = snd_seq_delete_port(client, info->addr.port); in snd_seq_ioctl_delete_port()
1368 if (client->ump_endpoint_port == info->addr.port) in snd_seq_ioctl_delete_port()
1369 client->ump_endpoint_port = -1; in snd_seq_ioctl_delete_port()
1370 snd_seq_system_client_ev_port_exit(client->number, info->addr.port); in snd_seq_ioctl_delete_port()
1377 * GET_PORT_INFO ioctl() (on any client)
1379 static int snd_seq_ioctl_get_port_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_get_port_info() argument
1385 cptr = snd_seq_client_use_ptr(info->addr.client); in snd_seq_ioctl_get_port_info()
1405 * SET_PORT_INFO ioctl() (only ports on this/own client)
1407 static int snd_seq_ioctl_set_port_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_set_port_info() argument
1412 if (info->addr.client != client->number) /* only set our own ports ! */ in snd_seq_ioctl_set_port_info()
1414 port = snd_seq_port_use_ptr(client, info->addr.port); in snd_seq_ioctl_set_port_info()
1429 static int check_subscription_permission(struct snd_seq_client *client, in check_subscription_permission() argument
1434 if (client->number != subs->sender.client && in check_subscription_permission()
1435 client->number != subs->dest.client) { in check_subscription_permission()
1436 /* connection by third client - check export permission */ in check_subscription_permission()
1444 /* if sender or receiver is the subscribing client itself, in check_subscription_permission()
1447 if (client->number != subs->sender.client) { in check_subscription_permission()
1452 if (client->number != subs->dest.client) { in check_subscription_permission()
1460 * send an subscription notify event to user client:
1461 * client must be user client.
1463 int snd_seq_client_notify_subscription(int client, int port, in snd_seq_client_notify_subscription() argument
1474 return snd_seq_system_notify(client, port, &event); /* non-atomic */ in snd_seq_client_notify_subscription()
1481 static int snd_seq_ioctl_subscribe_port(struct snd_seq_client *client, in snd_seq_ioctl_subscribe_port() argument
1489 receiver = snd_seq_client_use_ptr(subs->dest.client); in snd_seq_ioctl_subscribe_port()
1492 sender = snd_seq_client_use_ptr(subs->sender.client); in snd_seq_ioctl_subscribe_port()
1502 result = check_subscription_permission(client, sport, dport, subs); in snd_seq_ioctl_subscribe_port()
1507 result = snd_seq_port_connect(client, sender, sport, receiver, dport, subs); in snd_seq_ioctl_subscribe_port()
1527 static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client, in snd_seq_ioctl_unsubscribe_port() argument
1535 receiver = snd_seq_client_use_ptr(subs->dest.client); in snd_seq_ioctl_unsubscribe_port()
1538 sender = snd_seq_client_use_ptr(subs->sender.client); in snd_seq_ioctl_unsubscribe_port()
1548 result = check_subscription_permission(client, sport, dport, subs); in snd_seq_ioctl_unsubscribe_port()
1552 result = snd_seq_port_disconnect(client, sender, sport, receiver, dport, subs); in snd_seq_ioctl_unsubscribe_port()
1570 static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_create_queue() argument
1575 q = snd_seq_queue_alloc(client->number, info->locked, info->flags); in snd_seq_ioctl_create_queue()
1593 static int snd_seq_ioctl_delete_queue(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_delete_queue() argument
1597 return snd_seq_queue_delete(client->number, info->queue); in snd_seq_ioctl_delete_queue()
1601 static int snd_seq_ioctl_get_queue_info(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_info() argument
1622 static int snd_seq_ioctl_set_queue_info(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_info() argument
1628 if (info->owner != client->number) in snd_seq_ioctl_set_queue_info()
1632 if (snd_seq_queue_check_access(info->queue, client->number)) { in snd_seq_ioctl_set_queue_info()
1633 if (snd_seq_queue_set_owner(info->queue, client->number, info->locked) < 0) in snd_seq_ioctl_set_queue_info()
1636 snd_seq_queue_use(info->queue, client->number, 1); in snd_seq_ioctl_set_queue_info()
1644 if (q->owner != client->number) { in snd_seq_ioctl_set_queue_info()
1655 static int snd_seq_ioctl_get_named_queue(struct snd_seq_client *client, in snd_seq_ioctl_get_named_queue() argument
1673 static int snd_seq_ioctl_get_queue_status(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_status() argument
1702 static int snd_seq_ioctl_get_queue_tempo(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_tempo() argument
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 result = snd_seq_set_queue_tempo(client->number, tempo); in snd_seq_ioctl_set_queue_tempo()
1748 static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_timer() argument
1777 static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_timer() argument
1786 if (snd_seq_queue_check_access(timer->queue, client->number)) { in snd_seq_ioctl_set_queue_timer()
1813 static int snd_seq_ioctl_get_queue_client(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_client() argument
1819 used = snd_seq_queue_is_used(info->queue, client->number); in snd_seq_ioctl_get_queue_client()
1823 info->client = client->number; in snd_seq_ioctl_get_queue_client()
1830 static int snd_seq_ioctl_set_queue_client(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_client() argument
1837 err = snd_seq_queue_use(info->queue, client->number, info->used); in snd_seq_ioctl_set_queue_client()
1842 return snd_seq_ioctl_get_queue_client(client, arg); in snd_seq_ioctl_set_queue_client()
1847 static int snd_seq_ioctl_get_client_pool(struct snd_seq_client *client, in snd_seq_ioctl_get_client_pool() argument
1853 cptr = snd_seq_client_use_ptr(info->client); in snd_seq_ioctl_get_client_pool()
1857 info->client = cptr->number; in snd_seq_ioctl_get_client_pool()
1876 static int snd_seq_ioctl_set_client_pool(struct snd_seq_client *client, in snd_seq_ioctl_set_client_pool() argument
1882 if (client->number != info->client) in snd_seq_ioctl_set_client_pool()
1886 (! snd_seq_write_pool_allocated(client) || in snd_seq_ioctl_set_client_pool()
1887 info->output_pool != client->pool->size)) { in snd_seq_ioctl_set_client_pool()
1888 if (snd_seq_write_pool_allocated(client)) { in snd_seq_ioctl_set_client_pool()
1890 if (atomic_read(&client->pool->counter)) in snd_seq_ioctl_set_client_pool()
1893 snd_seq_pool_mark_closing(client->pool); in snd_seq_ioctl_set_client_pool()
1894 snd_seq_pool_done(client->pool); in snd_seq_ioctl_set_client_pool()
1896 client->pool->size = info->output_pool; in snd_seq_ioctl_set_client_pool()
1897 rc = snd_seq_pool_init(client->pool); in snd_seq_ioctl_set_client_pool()
1901 if (client->type == USER_CLIENT && client->data.user.fifo != NULL && in snd_seq_ioctl_set_client_pool()
1904 info->input_pool != client->data.user.fifo_pool_size) { in snd_seq_ioctl_set_client_pool()
1906 rc = snd_seq_fifo_resize(client->data.user.fifo, info->input_pool); in snd_seq_ioctl_set_client_pool()
1909 client->data.user.fifo_pool_size = info->input_pool; in snd_seq_ioctl_set_client_pool()
1912 info->output_room <= client->pool->size) { in snd_seq_ioctl_set_client_pool()
1913 client->pool->room = info->output_room; in snd_seq_ioctl_set_client_pool()
1916 return snd_seq_ioctl_get_client_pool(client, arg); in snd_seq_ioctl_set_client_pool()
1921 static int snd_seq_ioctl_remove_events(struct snd_seq_client *client, in snd_seq_ioctl_remove_events() argument
1931 * No restrictions so for a user client we can clear in snd_seq_ioctl_remove_events()
1934 if (client->type == USER_CLIENT && client->data.user.fifo) in snd_seq_ioctl_remove_events()
1935 snd_seq_fifo_clear(client->data.user.fifo); in snd_seq_ioctl_remove_events()
1939 snd_seq_queue_remove_cells(client->number, info); in snd_seq_ioctl_remove_events()
1948 static int snd_seq_ioctl_get_subscription(struct snd_seq_client *client, in snd_seq_ioctl_get_subscription() argument
1957 sender = snd_seq_client_use_ptr(subs->sender.client); in snd_seq_ioctl_get_subscription()
1978 static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_query_subs() argument
1988 cptr = snd_seq_client_use_ptr(subs->root.client); in snd_seq_ioctl_query_subs()
2041 * query next client
2043 static int snd_seq_ioctl_query_next_client(struct snd_seq_client *client, in snd_seq_ioctl_query_next_client() argument
2049 /* search for next client */ in snd_seq_ioctl_query_next_client()
2050 if (info->client < INT_MAX) in snd_seq_ioctl_query_next_client()
2051 info->client++; in snd_seq_ioctl_query_next_client()
2052 if (info->client < 0) in snd_seq_ioctl_query_next_client()
2053 info->client = 0; in snd_seq_ioctl_query_next_client()
2054 for (; info->client < SNDRV_SEQ_MAX_CLIENTS; info->client++) { in snd_seq_ioctl_query_next_client()
2055 cptr = snd_seq_client_use_ptr(info->client); in snd_seq_ioctl_query_next_client()
2071 static int snd_seq_ioctl_query_next_port(struct snd_seq_client *client, in snd_seq_ioctl_query_next_port() argument
2078 cptr = snd_seq_client_use_ptr(info->addr.client); in snd_seq_ioctl_query_next_port()
2102 static void free_ump_info(struct snd_seq_client *client) in free_ump_info() argument
2106 if (!client->ump_info) in free_ump_info()
2109 kfree(client->ump_info[i]); in free_ump_info()
2110 kfree(client->ump_info); in free_ump_info()
2111 client->ump_info = NULL; in free_ump_info()
2127 struct snd_seq_client *client) in dump_ump_info() argument
2133 if (!client->ump_info) in dump_ump_info()
2135 ep = client->ump_info[SNDRV_SEQ_CLIENT_UMP_INFO_ENDPOINT]; in dump_ump_info()
2139 bp = client->ump_info[i + 1]; in dump_ump_info()
2160 int client, type, err = 0; in snd_seq_ioctl_client_ump_info() local
2164 if (get_user(client, &argp->client) || get_user(type, &argp->type)) in snd_seq_ioctl_client_ump_info()
2167 caller->number != client) in snd_seq_ioctl_client_ump_info()
2175 cptr = snd_seq_client_use_ptr(client); in snd_seq_ioctl_client_ump_info()
2232 int (*func)(struct snd_seq_client *client, void *arg);
2272 struct snd_seq_client *client = file->private_data; in snd_seq_ioctl() local
2295 if (snd_BUG_ON(!client)) in snd_seq_ioctl()
2303 return snd_seq_ioctl_client_ump_info(client, cmd, arg); in snd_seq_ioctl()
2326 mutex_lock(&client->ioctl_mutex); in snd_seq_ioctl()
2327 err = handler->func(client, &buf); in snd_seq_ioctl()
2328 mutex_unlock(&client->ioctl_mutex); in snd_seq_ioctl()
2354 struct snd_seq_client *client; in snd_seq_create_kernel_client() local
2375 client = seq_create_client1(client_index, 0); in snd_seq_create_kernel_client()
2376 if (client == NULL) { in snd_seq_create_kernel_client()
2382 client->accept_input = 1; in snd_seq_create_kernel_client()
2383 client->accept_output = 1; in snd_seq_create_kernel_client()
2384 client->data.kernel.card = card; in snd_seq_create_kernel_client()
2385 client->user_pversion = SNDRV_SEQ_VERSION; in snd_seq_create_kernel_client()
2388 vsnprintf(client->name, sizeof(client->name), name_fmt, args); in snd_seq_create_kernel_client()
2391 client->type = KERNEL_CLIENT; in snd_seq_create_kernel_client()
2394 /* make others aware this new client */ in snd_seq_create_kernel_client()
2395 snd_seq_system_client_ev_client_start(client->number); in snd_seq_create_kernel_client()
2397 /* return client number to caller */ in snd_seq_create_kernel_client()
2398 return client->number; in snd_seq_create_kernel_client()
2403 int snd_seq_delete_kernel_client(int client) in snd_seq_delete_kernel_client() argument
2410 ptr = clientptr(client); in snd_seq_delete_kernel_client()
2425 int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, in snd_seq_kernel_client_enqueue() argument
2441 /* fill in client number */ in snd_seq_kernel_client_enqueue()
2442 ev->source.client = client; in snd_seq_kernel_client_enqueue()
2447 cptr = snd_seq_client_use_ptr(client); in snd_seq_kernel_client_enqueue()
2473 int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event * ev, in snd_seq_kernel_client_dispatch() argument
2482 /* fill in client number */ in snd_seq_kernel_client_dispatch()
2484 ev->source.client = client; in snd_seq_kernel_client_dispatch()
2489 cptr = snd_seq_client_use_ptr(client); in snd_seq_kernel_client_dispatch()
2504 * snd_seq_kernel_client_ctl - operate a command for a client with data in
2506 * @clientid: A numerical ID for a client.
2510 * Against its name, both kernel/application client can be handled by this
2518 struct snd_seq_client *client; in snd_seq_kernel_client_ctl() local
2520 client = clientptr(clientid); in snd_seq_kernel_client_ctl()
2521 if (client == NULL) in snd_seq_kernel_client_ctl()
2526 return handler->func(client, arg); in snd_seq_kernel_client_ctl()
2538 struct snd_seq_client *client; in snd_seq_kernel_client_write_poll() local
2540 client = clientptr(clientid); in snd_seq_kernel_client_write_poll()
2541 if (client == NULL) in snd_seq_kernel_client_write_poll()
2544 if (! snd_seq_write_pool_allocated(client)) in snd_seq_kernel_client_write_poll()
2546 if (snd_seq_pool_poll_wait(client->pool, file, wait)) in snd_seq_kernel_client_write_poll()
2552 /* get a sequencer client object; for internal use from a kernel client */
2559 /* put a sequencer client object; for internal use from a kernel client */
2595 is_src ? s->info.dest.client : s->info.sender.client, in snd_seq_info_dump_subscribers()
2624 struct snd_seq_client *client) in snd_seq_info_dump_ports() argument
2628 mutex_lock(&client->ports_mutex); in snd_seq_info_dump_ports()
2629 list_for_each_entry(p, &client->ports_list_head, list) { in snd_seq_info_dump_ports()
2642 mutex_unlock(&client->ports_mutex); in snd_seq_info_dump_ports()
2664 struct snd_seq_client *client; in snd_seq_info_clients_read() local
2666 snd_iprintf(buffer, "Client info\n"); in snd_seq_info_clients_read()
2672 /* list the client table */ in snd_seq_info_clients_read()
2674 client = snd_seq_client_use_ptr(c); in snd_seq_info_clients_read()
2675 if (client == NULL) in snd_seq_info_clients_read()
2677 if (client->type == NO_CLIENT) { in snd_seq_info_clients_read()
2678 snd_seq_client_unlock(client); in snd_seq_info_clients_read()
2682 snd_iprintf(buffer, "Client %3d : \"%s\" [%s %s]\n", in snd_seq_info_clients_read()
2683 c, client->name, in snd_seq_info_clients_read()
2684 client->type == USER_CLIENT ? "User" : "Kernel", in snd_seq_info_clients_read()
2685 midi_version_string(client->midi_version)); in snd_seq_info_clients_read()
2687 dump_ump_info(buffer, client); in snd_seq_info_clients_read()
2689 snd_seq_info_dump_ports(buffer, client); in snd_seq_info_clients_read()
2690 if (snd_seq_write_pool_allocated(client)) { in snd_seq_info_clients_read()
2692 snd_seq_info_pool(buffer, client->pool, " "); in snd_seq_info_clients_read()
2694 if (client->type == USER_CLIENT && client->data.user.fifo && in snd_seq_info_clients_read()
2695 client->data.user.fifo->pool) { in snd_seq_info_clients_read()
2697 snd_seq_info_pool(buffer, client->data.user.fifo->pool, " "); in snd_seq_info_clients_read()
2699 snd_seq_client_unlock(client); in snd_seq_info_clients_read()