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 client_use_ptr() local
115 pr_debug("ALSA: seq: oops. Trying to get pointer to client %d\n", in client_use_ptr()
120 client = clientptr(clientid); in client_use_ptr()
121 if (client) in client_use_ptr()
141 request_module("snd-seq-client-%i", in client_use_ptr()
157 client = clientptr(clientid); in client_use_ptr()
158 if (client) in client_use_ptr()
166 snd_use_lock_use(&client->use_lock); in client_use_ptr()
168 return client; in client_use_ptr()
185 /* Take refcount and perform ioctl_mutex lock on the given client;
191 struct snd_seq_client *client; in snd_seq_client_ioctl_lock() local
193 client = client_load_and_use_ptr(clientid); in snd_seq_client_ioctl_lock()
194 if (!client) in snd_seq_client_ioctl_lock()
196 mutex_lock(&client->ioctl_mutex); in snd_seq_client_ioctl_lock()
197 /* The client isn't unrefed here; see snd_seq_client_ioctl_unlock() */ in snd_seq_client_ioctl_lock()
202 /* Unlock and unref the given client; for OSS sequencer use only */
205 struct snd_seq_client *client; in snd_seq_client_ioctl_unlock() local
207 client = snd_seq_client_use_ptr(clientid); in snd_seq_client_ioctl_unlock()
208 if (WARN_ON(!client)) in snd_seq_client_ioctl_unlock()
210 mutex_unlock(&client->ioctl_mutex); in snd_seq_client_ioctl_unlock()
215 snd_seq_client_unlock(client); in snd_seq_client_ioctl_unlock()
216 snd_seq_client_unlock(client); in snd_seq_client_ioctl_unlock()
235 /* zap out the client table */ in client_init_data()
245 struct snd_seq_client *client; in seq_create_client1() local
247 /* init client data */ in seq_create_client1()
248 client = kzalloc(sizeof(*client), GFP_KERNEL); in seq_create_client1()
249 if (client == NULL) in seq_create_client1()
251 client->pool = snd_seq_pool_new(poolsize); in seq_create_client1()
252 if (client->pool == NULL) { in seq_create_client1()
253 kfree(client); in seq_create_client1()
256 client->type = NO_CLIENT; in seq_create_client1()
257 snd_use_lock_init(&client->use_lock); in seq_create_client1()
258 rwlock_init(&client->ports_lock); in seq_create_client1()
259 mutex_init(&client->ports_mutex); in seq_create_client1()
260 INIT_LIST_HEAD(&client->ports_list_head); in seq_create_client1()
261 mutex_init(&client->ioctl_mutex); in seq_create_client1()
262 client->ump_endpoint_port = -1; in seq_create_client1()
264 /* find free slot in the client table */ in seq_create_client1()
272 clienttab[client->number = c] = client; in seq_create_client1()
274 return client; in seq_create_client1()
278 clienttab[client->number = client_index] = client; in seq_create_client1()
280 return client; in seq_create_client1()
284 snd_seq_pool_delete(&client->pool); in seq_create_client1()
285 kfree(client); in seq_create_client1()
290 static int seq_free_client1(struct snd_seq_client *client) in seq_free_client1() argument
292 if (!client) in seq_free_client1()
295 clienttablock[client->number] = 1; in seq_free_client1()
296 clienttab[client->number] = NULL; in seq_free_client1()
298 snd_seq_delete_all_ports(client); in seq_free_client1()
299 snd_seq_queue_client_leave(client->number); in seq_free_client1()
300 snd_use_lock_sync(&client->use_lock); in seq_free_client1()
301 if (client->pool) in seq_free_client1()
302 snd_seq_pool_delete(&client->pool); in seq_free_client1()
304 clienttablock[client->number] = 0; in seq_free_client1()
310 static void seq_free_client(struct snd_seq_client * client) in seq_free_client() argument
313 switch (client->type) { in seq_free_client()
315 pr_warn("ALSA: seq: Trying to free unused client %d\n", in seq_free_client()
316 client->number); in seq_free_client()
320 seq_free_client1(client); in seq_free_client()
325 pr_err("ALSA: seq: Trying to free client %d with undefined type = %d\n", in seq_free_client()
326 client->number, client->type); in seq_free_client()
330 snd_seq_system_client_ev_client_exit(client->number); in seq_free_client()
337 /* create a user client */
340 int c, mode; /* client id */ in snd_seq_open()
341 struct snd_seq_client *client; in snd_seq_open() local
350 client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS); in snd_seq_open()
351 if (!client) { in snd_seq_open()
358 client->accept_input = 1; in snd_seq_open()
360 client->accept_output = 1; in snd_seq_open()
362 user = &client->data.user; in snd_seq_open()
370 seq_free_client1(client); in snd_seq_open()
371 kfree(client); in snd_seq_open()
378 client->type = USER_CLIENT; in snd_seq_open()
381 c = client->number; in snd_seq_open()
382 file->private_data = client; in snd_seq_open()
384 /* fill client data */ in snd_seq_open()
386 sprintf(client->name, "Client-%d", c); in snd_seq_open()
387 client->data.user.owner = get_pid(task_pid(current)); in snd_seq_open()
389 /* make others aware this new client */ in snd_seq_open()
395 /* delete a user client */
398 struct snd_seq_client *client = file->private_data; in snd_seq_release() local
400 if (client) { in snd_seq_release()
401 seq_free_client(client); in snd_seq_release()
402 if (client->data.user.fifo) in snd_seq_release()
403 snd_seq_fifo_delete(&client->data.user.fifo); in snd_seq_release()
405 free_ump_info(client); in snd_seq_release()
407 put_pid(client->data.user.owner); in snd_seq_release()
408 kfree(client); in snd_seq_release()
414 static bool event_is_compatible(const struct snd_seq_client *client, in event_is_compatible() argument
417 if (snd_seq_ev_is_ump(ev) && !client->midi_version) in event_is_compatible()
424 /* handle client read() */
426 * -ENXIO invalid client or file open mode
434 struct snd_seq_client *client = file->private_data; in snd_seq_read() local
447 /* check client structures are in place */ in snd_seq_read()
448 if (snd_BUG_ON(!client)) in snd_seq_read()
451 if (!client->accept_input) in snd_seq_read()
453 fifo = client->data.user.fifo; in snd_seq_read()
468 if (IS_ENABLED(CONFIG_SND_SEQ_UMP) && client->midi_version > 0) in snd_seq_read()
481 if (!event_is_compatible(client, &cell->event)) { in snd_seq_read()
541 * check if the destination client is available, and return the pointer
542 * if filter is non-zero, client filter bitmap is tested.
549 dest = snd_seq_client_use_ptr(event->dest.client); in get_event_dest_client()
573 * If the receiver client is a user client, the original event is
577 * If the receiver client is a kernel client, the original event is
581 static int bounce_error_event(struct snd_seq_client *client, in bounce_error_event() argument
588 if (client == NULL || in bounce_error_event()
589 ! (client->filter & SNDRV_SEQ_FILTER_BOUNCE) || in bounce_error_event()
590 ! client->accept_input) in bounce_error_event()
598 bounce_ev.source.client = SNDRV_SEQ_CLIENT_SYSTEM; in bounce_error_event()
600 bounce_ev.dest.client = client->number; in bounce_error_event()
607 client->event_lost++; in bounce_error_event()
665 * if filter is non-zero, client filter bitmap is tested.
670 static int snd_seq_deliver_single_event(struct snd_seq_client *client, in snd_seq_deliver_single_event() argument
701 result = snd_seq_deliver_from_ump(client, dest, dest_port, in snd_seq_deliver_single_event()
711 result = snd_seq_deliver_to_ump(client, dest, dest_port, in snd_seq_deliver_single_event()
728 result = bounce_error_event(client, event, result, atomic, hop); in snd_seq_deliver_single_event()
737 static int __deliver_to_subscribers(struct snd_seq_client *client, in __deliver_to_subscribers() argument
767 err = snd_seq_deliver_single_event(client, event, in __deliver_to_subscribers()
787 static int deliver_to_subscribers(struct snd_seq_client *client, in deliver_to_subscribers() argument
794 src_port = snd_seq_port_use_ptr(client, event->source.port); in deliver_to_subscribers()
796 ret = __deliver_to_subscribers(client, event, src_port, atomic, hop); in deliver_to_subscribers()
800 if (client->ump_endpoint_port < 0 || in deliver_to_subscribers()
801 event->source.port == client->ump_endpoint_port) in deliver_to_subscribers()
804 src_port = snd_seq_port_use_ptr(client, client->ump_endpoint_port); in deliver_to_subscribers()
807 ret2 = __deliver_to_subscribers(client, event, src_port, atomic, hop); in deliver_to_subscribers()
817 * n == 0 : the event was not passed to any client.
820 static int snd_seq_deliver_event(struct snd_seq_client *client, struct snd_seq_event *event, in snd_seq_deliver_event() argument
828 event->source.client, event->source.port, in snd_seq_deliver_event()
829 event->dest.client, event->dest.port); in snd_seq_deliver_event()
838 event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) in snd_seq_deliver_event()
839 result = deliver_to_subscribers(client, event, atomic, hop); in snd_seq_deliver_event()
841 result = snd_seq_deliver_single_event(client, event, 0, atomic, hop); in snd_seq_deliver_event()
853 * n == 0 : the event was not passed to any client.
858 struct snd_seq_client *client; in snd_seq_dispatch_event() local
864 client = snd_seq_client_use_ptr(cell->event.source.client); in snd_seq_dispatch_event()
865 if (client == NULL) { in snd_seq_dispatch_event()
881 result = snd_seq_deliver_event(client, &tmpev, atomic, hop); in snd_seq_dispatch_event()
916 result = snd_seq_deliver_event(client, &cell->event, atomic, hop); in snd_seq_dispatch_event()
920 snd_seq_client_unlock(client); in snd_seq_dispatch_event()
925 /* Allocate a cell from client pool and enqueue it to queue:
929 static int snd_seq_client_enqueue_event(struct snd_seq_client *client, in snd_seq_client_enqueue_event() argument
940 event->dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS; in snd_seq_client_enqueue_event()
942 } else if (event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) { in snd_seq_client_enqueue_event()
944 struct snd_seq_client_port *src_port = snd_seq_port_use_ptr(client, event->source.port); in snd_seq_client_enqueue_event()
955 return snd_seq_deliver_event(client, event, atomic, hop); in snd_seq_client_enqueue_event()
959 if (snd_seq_queue_is_used(event->queue, client->number) <= 0) in snd_seq_client_enqueue_event()
961 if (! snd_seq_write_pool_allocated(client)) in snd_seq_client_enqueue_event()
965 err = snd_seq_event_dup(client->pool, event, &cell, !blocking || atomic, in snd_seq_client_enqueue_event()
1008 * -ENXIO invalid client or file open mode
1020 struct snd_seq_client *client = file->private_data; in snd_seq_write() local
1029 /* check client structures are in place */ in snd_seq_write()
1030 if (snd_BUG_ON(!client)) in snd_seq_write()
1033 if (!client->accept_output || client->pool == NULL) in snd_seq_write()
1039 mutex_lock(&client->ioctl_mutex); in snd_seq_write()
1040 if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) { in snd_seq_write()
1041 err = snd_seq_pool_init(client->pool); in snd_seq_write()
1067 ev->source.client = client->number; /* fill in client number */ in snd_seq_write()
1074 if (!event_is_compatible(client, ev)) { in snd_seq_write()
1102 if (client->convert32 && snd_seq_ev_is_varusr(ev)) in snd_seq_write()
1109 err = snd_seq_client_enqueue_event(client, ev, file, in snd_seq_write()
1111 0, 0, &client->ioctl_mutex); in snd_seq_write()
1124 mutex_unlock(&client->ioctl_mutex); in snd_seq_write()
1130 mutex_unlock(&client->ioctl_mutex); in snd_seq_write()
1140 struct snd_seq_client *client = file->private_data; in snd_seq_poll() local
1143 /* check client structures are in place */ in snd_seq_poll()
1144 if (snd_BUG_ON(!client)) in snd_seq_poll()
1148 client->data.user.fifo) { in snd_seq_poll()
1151 if (snd_seq_fifo_poll_wait(client->data.user.fifo, file, wait)) in snd_seq_poll()
1158 if (!snd_seq_write_pool_allocated(client) || in snd_seq_poll()
1159 snd_seq_pool_poll_wait(client->pool, file, wait)) in snd_seq_poll()
1169 static int snd_seq_ioctl_pversion(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_pversion() argument
1177 static int snd_seq_ioctl_user_pversion(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_user_pversion() argument
1179 client->user_pversion = *(unsigned int *)arg; in snd_seq_ioctl_user_pversion()
1183 static int snd_seq_ioctl_client_id(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_client_id() argument
1187 *client_id = client->number; in snd_seq_ioctl_client_id()
1192 static int snd_seq_ioctl_system_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_system_info() argument
1210 static int snd_seq_ioctl_running_mode(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_running_mode() argument
1216 /* requested client number */ in snd_seq_ioctl_running_mode()
1217 cptr = client_load_and_use_ptr(info->client); in snd_seq_ioctl_running_mode()
1247 info->client = cptr->number; in get_client_info()
1272 static int snd_seq_ioctl_get_client_info(struct snd_seq_client *client, in snd_seq_ioctl_get_client_info() argument
1278 /* requested client number */ in snd_seq_ioctl_get_client_info()
1279 cptr = client_load_and_use_ptr(client_info->client); in snd_seq_ioctl_get_client_info()
1291 static int snd_seq_ioctl_set_client_info(struct snd_seq_client *client, in snd_seq_ioctl_set_client_info() argument
1296 /* it is not allowed to set the info fields for an another client */ in snd_seq_ioctl_set_client_info()
1297 if (client->number != client_info->client) in snd_seq_ioctl_set_client_info()
1299 /* also client type must be set now */ in snd_seq_ioctl_set_client_info()
1300 if (client->type != client_info->type) in snd_seq_ioctl_set_client_info()
1303 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3)) { in snd_seq_ioctl_set_client_info()
1316 strscpy(client->name, client_info->name, sizeof(client->name)); in snd_seq_ioctl_set_client_info()
1318 client->filter = client_info->filter; in snd_seq_ioctl_set_client_info()
1319 client->event_lost = client_info->event_lost; in snd_seq_ioctl_set_client_info()
1320 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3)) in snd_seq_ioctl_set_client_info()
1321 client->midi_version = client_info->midi_version; in snd_seq_ioctl_set_client_info()
1322 memcpy(client->event_filter, client_info->event_filter, 32); in snd_seq_ioctl_set_client_info()
1323 client->group_filter = client_info->group_filter; in snd_seq_ioctl_set_client_info()
1331 static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_create_port() argument
1338 /* it is not allowed to create the port for an another client */ in snd_seq_ioctl_create_port()
1339 if (info->addr.client != client->number) in snd_seq_ioctl_create_port()
1341 if (client->type == USER_CLIENT && info->kernel) in snd_seq_ioctl_create_port()
1344 client->ump_endpoint_port >= 0) in snd_seq_ioctl_create_port()
1353 err = snd_seq_create_port(client, port_idx, &port); in snd_seq_ioctl_create_port()
1357 if (client->type == KERNEL_CLIENT) { in snd_seq_ioctl_create_port()
1376 client->ump_endpoint_port = port->addr.port; in snd_seq_ioctl_create_port()
1377 snd_seq_system_client_ev_port_start(port->addr.client, port->addr.port); in snd_seq_ioctl_create_port()
1386 static int snd_seq_ioctl_delete_port(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_delete_port() argument
1391 /* it is not allowed to remove the port for an another client */ in snd_seq_ioctl_delete_port()
1392 if (info->addr.client != client->number) in snd_seq_ioctl_delete_port()
1395 err = snd_seq_delete_port(client, info->addr.port); in snd_seq_ioctl_delete_port()
1397 if (client->ump_endpoint_port == info->addr.port) in snd_seq_ioctl_delete_port()
1398 client->ump_endpoint_port = -1; in snd_seq_ioctl_delete_port()
1399 snd_seq_system_client_ev_port_exit(client->number, info->addr.port); in snd_seq_ioctl_delete_port()
1406 * GET_PORT_INFO ioctl() (on any client)
1408 static int snd_seq_ioctl_get_port_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_get_port_info() argument
1414 cptr = client_load_and_use_ptr(info->addr.client); in snd_seq_ioctl_get_port_info()
1434 * SET_PORT_INFO ioctl() (only ports on this/own client)
1436 static int snd_seq_ioctl_set_port_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_set_port_info() argument
1441 if (info->addr.client != client->number) /* only set our own ports ! */ in snd_seq_ioctl_set_port_info()
1443 port = snd_seq_port_use_ptr(client, info->addr.port); in snd_seq_ioctl_set_port_info()
1458 static int check_subscription_permission(struct snd_seq_client *client, in check_subscription_permission() argument
1463 if (client->number != subs->sender.client && in check_subscription_permission()
1464 client->number != subs->dest.client) { in check_subscription_permission()
1465 /* connection by third client - check export permission */ in check_subscription_permission()
1473 /* if sender or receiver is the subscribing client itself, in check_subscription_permission()
1476 if (client->number != subs->sender.client) { in check_subscription_permission()
1481 if (client->number != subs->dest.client) { in check_subscription_permission()
1489 * send an subscription notify event to user client:
1490 * client must be user client.
1492 int snd_seq_client_notify_subscription(int client, int port, in snd_seq_client_notify_subscription() argument
1503 return snd_seq_system_notify(client, port, &event); /* non-atomic */ in snd_seq_client_notify_subscription()
1510 static int snd_seq_ioctl_subscribe_port(struct snd_seq_client *client, in snd_seq_ioctl_subscribe_port() argument
1518 receiver = client_load_and_use_ptr(subs->dest.client); in snd_seq_ioctl_subscribe_port()
1521 sender = client_load_and_use_ptr(subs->sender.client); in snd_seq_ioctl_subscribe_port()
1531 result = check_subscription_permission(client, sport, dport, subs); in snd_seq_ioctl_subscribe_port()
1536 result = snd_seq_port_connect(client, sender, sport, receiver, dport, subs); in snd_seq_ioctl_subscribe_port()
1556 static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client, in snd_seq_ioctl_unsubscribe_port() argument
1564 receiver = snd_seq_client_use_ptr(subs->dest.client); in snd_seq_ioctl_unsubscribe_port()
1567 sender = snd_seq_client_use_ptr(subs->sender.client); in snd_seq_ioctl_unsubscribe_port()
1577 result = check_subscription_permission(client, sport, dport, subs); in snd_seq_ioctl_unsubscribe_port()
1581 result = snd_seq_port_disconnect(client, sender, sport, receiver, dport, subs); in snd_seq_ioctl_unsubscribe_port()
1599 static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_create_queue() argument
1604 q = snd_seq_queue_alloc(client->number, info->locked, info->flags); in snd_seq_ioctl_create_queue()
1622 static int snd_seq_ioctl_delete_queue(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_delete_queue() argument
1626 return snd_seq_queue_delete(client->number, info->queue); in snd_seq_ioctl_delete_queue()
1630 static int snd_seq_ioctl_get_queue_info(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_info() argument
1651 static int snd_seq_ioctl_set_queue_info(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_info() argument
1657 if (info->owner != client->number) in snd_seq_ioctl_set_queue_info()
1661 if (snd_seq_queue_check_access(info->queue, client->number)) { in snd_seq_ioctl_set_queue_info()
1662 if (snd_seq_queue_set_owner(info->queue, client->number, info->locked) < 0) in snd_seq_ioctl_set_queue_info()
1665 snd_seq_queue_use(info->queue, client->number, 1); in snd_seq_ioctl_set_queue_info()
1673 if (q->owner != client->number) { in snd_seq_ioctl_set_queue_info()
1684 static int snd_seq_ioctl_get_named_queue(struct snd_seq_client *client, in snd_seq_ioctl_get_named_queue() argument
1702 static int snd_seq_ioctl_get_queue_status(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_status() argument
1731 static int snd_seq_ioctl_get_queue_tempo(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_tempo() argument
1757 int snd_seq_set_queue_tempo(int client, struct snd_seq_queue_tempo *tempo) in snd_seq_set_queue_tempo() argument
1759 if (!snd_seq_queue_check_access(tempo->queue, client)) in snd_seq_set_queue_tempo()
1761 return snd_seq_queue_timer_set_tempo(tempo->queue, client, tempo); in snd_seq_set_queue_tempo()
1765 static int snd_seq_ioctl_set_queue_tempo(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_tempo() argument
1771 result = snd_seq_set_queue_tempo(client->number, tempo); in snd_seq_ioctl_set_queue_tempo()
1777 static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_timer() argument
1806 static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_timer() argument
1815 if (snd_seq_queue_check_access(timer->queue, client->number)) { in snd_seq_ioctl_set_queue_timer()
1842 static int snd_seq_ioctl_get_queue_client(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_client() argument
1848 used = snd_seq_queue_is_used(info->queue, client->number); in snd_seq_ioctl_get_queue_client()
1852 info->client = client->number; in snd_seq_ioctl_get_queue_client()
1859 static int snd_seq_ioctl_set_queue_client(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_client() argument
1866 err = snd_seq_queue_use(info->queue, client->number, info->used); in snd_seq_ioctl_set_queue_client()
1871 return snd_seq_ioctl_get_queue_client(client, arg); in snd_seq_ioctl_set_queue_client()
1876 static int snd_seq_ioctl_get_client_pool(struct snd_seq_client *client, in snd_seq_ioctl_get_client_pool() argument
1882 cptr = client_load_and_use_ptr(info->client); in snd_seq_ioctl_get_client_pool()
1886 info->client = cptr->number; in snd_seq_ioctl_get_client_pool()
1905 static int snd_seq_ioctl_set_client_pool(struct snd_seq_client *client, in snd_seq_ioctl_set_client_pool() argument
1911 if (client->number != info->client) in snd_seq_ioctl_set_client_pool()
1915 (! snd_seq_write_pool_allocated(client) || in snd_seq_ioctl_set_client_pool()
1916 info->output_pool != client->pool->size)) { in snd_seq_ioctl_set_client_pool()
1917 if (snd_seq_write_pool_allocated(client)) { in snd_seq_ioctl_set_client_pool()
1919 if (atomic_read(&client->pool->counter)) in snd_seq_ioctl_set_client_pool()
1922 snd_seq_pool_mark_closing(client->pool); in snd_seq_ioctl_set_client_pool()
1923 snd_seq_pool_done(client->pool); in snd_seq_ioctl_set_client_pool()
1925 client->pool->size = info->output_pool; in snd_seq_ioctl_set_client_pool()
1926 rc = snd_seq_pool_init(client->pool); in snd_seq_ioctl_set_client_pool()
1930 if (client->type == USER_CLIENT && client->data.user.fifo != NULL && in snd_seq_ioctl_set_client_pool()
1933 info->input_pool != client->data.user.fifo_pool_size) { in snd_seq_ioctl_set_client_pool()
1935 rc = snd_seq_fifo_resize(client->data.user.fifo, info->input_pool); in snd_seq_ioctl_set_client_pool()
1938 client->data.user.fifo_pool_size = info->input_pool; in snd_seq_ioctl_set_client_pool()
1941 info->output_room <= client->pool->size) { in snd_seq_ioctl_set_client_pool()
1942 client->pool->room = info->output_room; in snd_seq_ioctl_set_client_pool()
1945 return snd_seq_ioctl_get_client_pool(client, arg); in snd_seq_ioctl_set_client_pool()
1950 static int snd_seq_ioctl_remove_events(struct snd_seq_client *client, in snd_seq_ioctl_remove_events() argument
1960 * No restrictions so for a user client we can clear in snd_seq_ioctl_remove_events()
1963 if (client->type == USER_CLIENT && client->data.user.fifo) in snd_seq_ioctl_remove_events()
1964 snd_seq_fifo_clear(client->data.user.fifo); in snd_seq_ioctl_remove_events()
1968 snd_seq_queue_remove_cells(client->number, info); in snd_seq_ioctl_remove_events()
1977 static int snd_seq_ioctl_get_subscription(struct snd_seq_client *client, in snd_seq_ioctl_get_subscription() argument
1986 sender = client_load_and_use_ptr(subs->sender.client); in snd_seq_ioctl_get_subscription()
2007 static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_query_subs() argument
2017 cptr = client_load_and_use_ptr(subs->root.client); in snd_seq_ioctl_query_subs()
2070 * query next client
2072 static int snd_seq_ioctl_query_next_client(struct snd_seq_client *client, in snd_seq_ioctl_query_next_client() argument
2078 /* search for next client */ in snd_seq_ioctl_query_next_client()
2079 if (info->client < INT_MAX) in snd_seq_ioctl_query_next_client()
2080 info->client++; in snd_seq_ioctl_query_next_client()
2081 if (info->client < 0) in snd_seq_ioctl_query_next_client()
2082 info->client = 0; in snd_seq_ioctl_query_next_client()
2083 for (; info->client < SNDRV_SEQ_MAX_CLIENTS; info->client++) { in snd_seq_ioctl_query_next_client()
2084 cptr = client_load_and_use_ptr(info->client); in snd_seq_ioctl_query_next_client()
2100 static int snd_seq_ioctl_query_next_port(struct snd_seq_client *client, in snd_seq_ioctl_query_next_port() argument
2107 cptr = client_load_and_use_ptr(info->addr.client); in snd_seq_ioctl_query_next_port()
2131 static void free_ump_info(struct snd_seq_client *client) in free_ump_info() argument
2135 if (!client->ump_info) in free_ump_info()
2138 kfree(client->ump_info[i]); in free_ump_info()
2139 kfree(client->ump_info); in free_ump_info()
2140 client->ump_info = NULL; in free_ump_info()
2156 struct snd_seq_client *client) in dump_ump_info() argument
2162 if (!client->ump_info) in dump_ump_info()
2164 ep = client->ump_info[SNDRV_SEQ_CLIENT_UMP_INFO_ENDPOINT]; in dump_ump_info()
2168 bp = client->ump_info[i + 1]; in dump_ump_info()
2189 int client, type, err = 0; in snd_seq_ioctl_client_ump_info() local
2193 if (get_user(client, &argp->client) || get_user(type, &argp->type)) in snd_seq_ioctl_client_ump_info()
2196 caller->number != client) in snd_seq_ioctl_client_ump_info()
2204 cptr = client_load_and_use_ptr(client); in snd_seq_ioctl_client_ump_info()
2261 int (*func)(struct snd_seq_client *client, void *arg);
2301 struct snd_seq_client *client = file->private_data; in snd_seq_ioctl() local
2324 if (snd_BUG_ON(!client)) in snd_seq_ioctl()
2332 return snd_seq_ioctl_client_ump_info(client, cmd, arg); in snd_seq_ioctl()
2355 mutex_lock(&client->ioctl_mutex); in snd_seq_ioctl()
2356 err = handler->func(client, &buf); in snd_seq_ioctl()
2357 mutex_unlock(&client->ioctl_mutex); in snd_seq_ioctl()
2383 struct snd_seq_client *client; in snd_seq_create_kernel_client() local
2404 client = seq_create_client1(client_index, 0); in snd_seq_create_kernel_client()
2405 if (client == NULL) { in snd_seq_create_kernel_client()
2411 client->accept_input = 1; in snd_seq_create_kernel_client()
2412 client->accept_output = 1; in snd_seq_create_kernel_client()
2413 client->data.kernel.card = card; in snd_seq_create_kernel_client()
2414 client->user_pversion = SNDRV_SEQ_VERSION; in snd_seq_create_kernel_client()
2417 vsnprintf(client->name, sizeof(client->name), name_fmt, args); in snd_seq_create_kernel_client()
2420 client->type = KERNEL_CLIENT; in snd_seq_create_kernel_client()
2423 /* make others aware this new client */ in snd_seq_create_kernel_client()
2424 snd_seq_system_client_ev_client_start(client->number); in snd_seq_create_kernel_client()
2426 /* return client number to caller */ in snd_seq_create_kernel_client()
2427 return client->number; in snd_seq_create_kernel_client()
2432 int snd_seq_delete_kernel_client(int client) in snd_seq_delete_kernel_client() argument
2439 ptr = clientptr(client); in snd_seq_delete_kernel_client()
2454 int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, in snd_seq_kernel_client_enqueue() argument
2470 /* fill in client number */ in snd_seq_kernel_client_enqueue()
2471 ev->source.client = client; in snd_seq_kernel_client_enqueue()
2476 cptr = client_load_and_use_ptr(client); in snd_seq_kernel_client_enqueue()
2502 int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event * ev, in snd_seq_kernel_client_dispatch() argument
2511 /* fill in client number */ in snd_seq_kernel_client_dispatch()
2513 ev->source.client = client; in snd_seq_kernel_client_dispatch()
2518 cptr = snd_seq_client_use_ptr(client); in snd_seq_kernel_client_dispatch()
2533 * snd_seq_kernel_client_ctl - operate a command for a client with data in
2535 * @clientid: A numerical ID for a client.
2539 * Against its name, both kernel/application client can be handled by this
2547 struct snd_seq_client *client; in snd_seq_kernel_client_ctl() local
2549 client = clientptr(clientid); in snd_seq_kernel_client_ctl()
2550 if (client == NULL) in snd_seq_kernel_client_ctl()
2555 return handler->func(client, arg); in snd_seq_kernel_client_ctl()
2567 struct snd_seq_client *client; in snd_seq_kernel_client_write_poll() local
2569 client = clientptr(clientid); in snd_seq_kernel_client_write_poll()
2570 if (client == NULL) in snd_seq_kernel_client_write_poll()
2573 if (! snd_seq_write_pool_allocated(client)) in snd_seq_kernel_client_write_poll()
2575 if (snd_seq_pool_poll_wait(client->pool, file, wait)) in snd_seq_kernel_client_write_poll()
2581 /* get a sequencer client object; for internal use from a kernel client */
2588 /* put a sequencer client object; for internal use from a kernel client */
2624 is_src ? s->info.dest.client : s->info.sender.client, in snd_seq_info_dump_subscribers()
2653 struct snd_seq_client *client) in snd_seq_info_dump_ports() argument
2657 mutex_lock(&client->ports_mutex); in snd_seq_info_dump_ports()
2658 list_for_each_entry(p, &client->ports_list_head, list) { in snd_seq_info_dump_ports()
2671 mutex_unlock(&client->ports_mutex); in snd_seq_info_dump_ports()
2693 struct snd_seq_client *client; in snd_seq_info_clients_read() local
2695 snd_iprintf(buffer, "Client info\n"); in snd_seq_info_clients_read()
2701 /* list the client table */ in snd_seq_info_clients_read()
2703 client = client_load_and_use_ptr(c); in snd_seq_info_clients_read()
2704 if (client == NULL) in snd_seq_info_clients_read()
2706 if (client->type == NO_CLIENT) { in snd_seq_info_clients_read()
2707 snd_seq_client_unlock(client); in snd_seq_info_clients_read()
2711 snd_iprintf(buffer, "Client %3d : \"%s\" [%s %s]\n", in snd_seq_info_clients_read()
2712 c, client->name, in snd_seq_info_clients_read()
2713 client->type == USER_CLIENT ? "User" : "Kernel", in snd_seq_info_clients_read()
2714 midi_version_string(client->midi_version)); in snd_seq_info_clients_read()
2716 dump_ump_info(buffer, client); in snd_seq_info_clients_read()
2718 snd_seq_info_dump_ports(buffer, client); in snd_seq_info_clients_read()
2719 if (snd_seq_write_pool_allocated(client)) { in snd_seq_info_clients_read()
2721 snd_seq_info_pool(buffer, client->pool, " "); in snd_seq_info_clients_read()
2723 if (client->type == USER_CLIENT && client->data.user.fifo && in snd_seq_info_clients_read()
2724 client->data.user.fifo->pool) { in snd_seq_info_clients_read()
2726 snd_seq_info_pool(buffer, client->data.user.fifo->pool, " "); in snd_seq_info_clients_read()
2728 snd_seq_client_unlock(client); in snd_seq_info_clients_read()