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
547 dest = snd_seq_client_use_ptr(event->dest.client); in get_event_dest_client()
569 * If the receiver client is a user client, the original event is
573 * If the receiver client is a kernel client, the original event is
577 static int bounce_error_event(struct snd_seq_client *client, in bounce_error_event() argument
584 if (client == NULL || in bounce_error_event()
585 ! (client->filter & SNDRV_SEQ_FILTER_BOUNCE) || in bounce_error_event()
586 ! client->accept_input) in bounce_error_event()
594 bounce_ev.source.client = SNDRV_SEQ_CLIENT_SYSTEM; in bounce_error_event()
596 bounce_ev.dest.client = client->number; in bounce_error_event()
603 client->event_lost++; in bounce_error_event()
661 * if filter is non-zero, client filter bitmap is tested.
666 static int snd_seq_deliver_single_event(struct snd_seq_client *client, in snd_seq_deliver_single_event() argument
697 result = snd_seq_deliver_from_ump(client, dest, dest_port, in snd_seq_deliver_single_event()
707 result = snd_seq_deliver_to_ump(client, dest, dest_port, in snd_seq_deliver_single_event()
724 result = bounce_error_event(client, event, result, atomic, hop); in snd_seq_deliver_single_event()
733 static int __deliver_to_subscribers(struct snd_seq_client *client, in __deliver_to_subscribers() argument
746 src_port = snd_seq_port_use_ptr(client, port); in __deliver_to_subscribers()
769 err = snd_seq_deliver_single_event(client, event, atomic, hop); in __deliver_to_subscribers()
789 static int deliver_to_subscribers(struct snd_seq_client *client, in deliver_to_subscribers() argument
798 ret = __deliver_to_subscribers(client, event, in deliver_to_subscribers()
801 if (!snd_seq_client_is_ump(client) || client->ump_endpoint_port < 0) in deliver_to_subscribers()
807 if (event->source.port == client->ump_endpoint_port) in deliver_to_subscribers()
808 ret2 = __deliver_to_subscribers(client, event, in deliver_to_subscribers()
812 ret2 = __deliver_to_subscribers(client, event, in deliver_to_subscribers()
813 client->ump_endpoint_port, in deliver_to_subscribers()
826 * n == 0 : the event was not passed to any client.
829 static int snd_seq_deliver_event(struct snd_seq_client *client, struct snd_seq_event *event, in snd_seq_deliver_event() argument
837 event->source.client, event->source.port, in snd_seq_deliver_event()
838 event->dest.client, event->dest.port); in snd_seq_deliver_event()
847 event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) in snd_seq_deliver_event()
848 result = deliver_to_subscribers(client, event, atomic, hop); in snd_seq_deliver_event()
850 result = snd_seq_deliver_single_event(client, event, atomic, hop); in snd_seq_deliver_event()
862 * n == 0 : the event was not passed to any client.
867 struct snd_seq_client *client; in snd_seq_dispatch_event() local
873 client = snd_seq_client_use_ptr(cell->event.source.client); in snd_seq_dispatch_event()
874 if (client == NULL) { in snd_seq_dispatch_event()
890 result = snd_seq_deliver_event(client, &tmpev, atomic, hop); in snd_seq_dispatch_event()
925 result = snd_seq_deliver_event(client, &cell->event, atomic, hop); in snd_seq_dispatch_event()
929 snd_seq_client_unlock(client); in snd_seq_dispatch_event()
934 /* Allocate a cell from client pool and enqueue it to queue:
938 static int snd_seq_client_enqueue_event(struct snd_seq_client *client, in snd_seq_client_enqueue_event() argument
949 event->dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS; in snd_seq_client_enqueue_event()
951 } else if (event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) { in snd_seq_client_enqueue_event()
953 struct snd_seq_client_port *src_port = snd_seq_port_use_ptr(client, event->source.port); in snd_seq_client_enqueue_event()
964 return snd_seq_deliver_event(client, event, atomic, hop); in snd_seq_client_enqueue_event()
968 if (snd_seq_queue_is_used(event->queue, client->number) <= 0) in snd_seq_client_enqueue_event()
970 if (! snd_seq_write_pool_allocated(client)) in snd_seq_client_enqueue_event()
974 err = snd_seq_event_dup(client->pool, event, &cell, !blocking || atomic, in snd_seq_client_enqueue_event()
1017 * -ENXIO invalid client or file open mode
1029 struct snd_seq_client *client = file->private_data; in snd_seq_write() local
1038 /* check client structures are in place */ in snd_seq_write()
1039 if (snd_BUG_ON(!client)) in snd_seq_write()
1042 if (!client->accept_output || client->pool == NULL) in snd_seq_write()
1048 mutex_lock(&client->ioctl_mutex); in snd_seq_write()
1049 if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) { in snd_seq_write()
1050 err = snd_seq_pool_init(client->pool); in snd_seq_write()
1076 ev->source.client = client->number; /* fill in client number */ in snd_seq_write()
1083 if (!event_is_compatible(client, ev)) { in snd_seq_write()
1111 if (client->convert32 && snd_seq_ev_is_varusr(ev)) in snd_seq_write()
1118 err = snd_seq_client_enqueue_event(client, ev, file, in snd_seq_write()
1120 0, 0, &client->ioctl_mutex); in snd_seq_write()
1133 mutex_unlock(&client->ioctl_mutex); in snd_seq_write()
1139 mutex_unlock(&client->ioctl_mutex); in snd_seq_write()
1149 struct snd_seq_client *client = file->private_data; in snd_seq_poll() local
1152 /* check client structures are in place */ in snd_seq_poll()
1153 if (snd_BUG_ON(!client)) in snd_seq_poll()
1157 client->data.user.fifo) { in snd_seq_poll()
1160 if (snd_seq_fifo_poll_wait(client->data.user.fifo, file, wait)) in snd_seq_poll()
1167 if (snd_seq_pool_poll_wait(client->pool, file, wait)) in snd_seq_poll()
1177 static int snd_seq_ioctl_pversion(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_pversion() argument
1185 static int snd_seq_ioctl_user_pversion(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_user_pversion() argument
1187 client->user_pversion = *(unsigned int *)arg; in snd_seq_ioctl_user_pversion()
1191 static int snd_seq_ioctl_client_id(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_client_id() argument
1195 *client_id = client->number; in snd_seq_ioctl_client_id()
1200 static int snd_seq_ioctl_system_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_system_info() argument
1218 static int snd_seq_ioctl_running_mode(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_running_mode() argument
1224 /* requested client number */ in snd_seq_ioctl_running_mode()
1225 cptr = client_load_and_use_ptr(info->client); in snd_seq_ioctl_running_mode()
1255 info->client = cptr->number; in get_client_info()
1280 static int snd_seq_ioctl_get_client_info(struct snd_seq_client *client, in snd_seq_ioctl_get_client_info() argument
1286 /* requested client number */ in snd_seq_ioctl_get_client_info()
1287 cptr = client_load_and_use_ptr(client_info->client); in snd_seq_ioctl_get_client_info()
1299 static int snd_seq_ioctl_set_client_info(struct snd_seq_client *client, in snd_seq_ioctl_set_client_info() argument
1304 /* it is not allowed to set the info fields for an another client */ in snd_seq_ioctl_set_client_info()
1305 if (client->number != client_info->client) in snd_seq_ioctl_set_client_info()
1307 /* also client type must be set now */ in snd_seq_ioctl_set_client_info()
1308 if (client->type != client_info->type) in snd_seq_ioctl_set_client_info()
1311 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3)) { in snd_seq_ioctl_set_client_info()
1324 strscpy(client->name, client_info->name, sizeof(client->name)); in snd_seq_ioctl_set_client_info()
1326 client->filter = client_info->filter; in snd_seq_ioctl_set_client_info()
1327 client->event_lost = client_info->event_lost; in snd_seq_ioctl_set_client_info()
1328 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3)) in snd_seq_ioctl_set_client_info()
1329 client->midi_version = client_info->midi_version; in snd_seq_ioctl_set_client_info()
1330 memcpy(client->event_filter, client_info->event_filter, 32); in snd_seq_ioctl_set_client_info()
1331 client->group_filter = client_info->group_filter; in snd_seq_ioctl_set_client_info()
1334 snd_seq_system_client_ev_client_change(client->number); in snd_seq_ioctl_set_client_info()
1343 static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_create_port() argument
1350 /* it is not allowed to create the port for an another client */ in snd_seq_ioctl_create_port()
1351 if (info->addr.client != client->number) in snd_seq_ioctl_create_port()
1353 if (client->type == USER_CLIENT && info->kernel) in snd_seq_ioctl_create_port()
1356 client->ump_endpoint_port >= 0) in snd_seq_ioctl_create_port()
1365 err = snd_seq_create_port(client, port_idx, &port); in snd_seq_ioctl_create_port()
1369 if (client->type == KERNEL_CLIENT) { in snd_seq_ioctl_create_port()
1388 client->ump_endpoint_port = port->addr.port; in snd_seq_ioctl_create_port()
1389 snd_seq_system_client_ev_port_start(port->addr.client, port->addr.port); in snd_seq_ioctl_create_port()
1398 static int snd_seq_ioctl_delete_port(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_delete_port() argument
1403 /* it is not allowed to remove the port for an another client */ in snd_seq_ioctl_delete_port()
1404 if (info->addr.client != client->number) in snd_seq_ioctl_delete_port()
1407 err = snd_seq_delete_port(client, info->addr.port); in snd_seq_ioctl_delete_port()
1409 if (client->ump_endpoint_port == info->addr.port) in snd_seq_ioctl_delete_port()
1410 client->ump_endpoint_port = -1; in snd_seq_ioctl_delete_port()
1411 snd_seq_system_client_ev_port_exit(client->number, info->addr.port); in snd_seq_ioctl_delete_port()
1418 * GET_PORT_INFO ioctl() (on any client)
1420 static int snd_seq_ioctl_get_port_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_get_port_info() argument
1426 cptr = client_load_and_use_ptr(info->addr.client); in snd_seq_ioctl_get_port_info()
1446 * SET_PORT_INFO ioctl() (only ports on this/own client)
1448 static int snd_seq_ioctl_set_port_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_set_port_info() argument
1453 if (info->addr.client != client->number) /* only set our own ports ! */ in snd_seq_ioctl_set_port_info()
1455 port = snd_seq_port_use_ptr(client, info->addr.port); in snd_seq_ioctl_set_port_info()
1460 snd_seq_system_client_ev_port_change(info->addr.client, in snd_seq_ioctl_set_port_info()
1473 static int check_subscription_permission(struct snd_seq_client *client, in check_subscription_permission() argument
1478 if (client->number != subs->sender.client && in check_subscription_permission()
1479 client->number != subs->dest.client) { in check_subscription_permission()
1480 /* connection by third client - check export permission */ in check_subscription_permission()
1488 /* if sender or receiver is the subscribing client itself, in check_subscription_permission()
1491 if (client->number != subs->sender.client) { in check_subscription_permission()
1496 if (client->number != subs->dest.client) { in check_subscription_permission()
1504 * send an subscription notify event to user client:
1505 * client must be user client.
1507 int snd_seq_client_notify_subscription(int client, int port, in snd_seq_client_notify_subscription() argument
1518 return snd_seq_system_notify(client, port, &event, false); /* non-atomic */ in snd_seq_client_notify_subscription()
1525 static int snd_seq_ioctl_subscribe_port(struct snd_seq_client *client, in snd_seq_ioctl_subscribe_port() argument
1533 receiver = client_load_and_use_ptr(subs->dest.client); in snd_seq_ioctl_subscribe_port()
1536 sender = client_load_and_use_ptr(subs->sender.client); in snd_seq_ioctl_subscribe_port()
1546 result = check_subscription_permission(client, sport, dport, subs); in snd_seq_ioctl_subscribe_port()
1551 result = snd_seq_port_connect(client, sender, sport, receiver, dport, subs); in snd_seq_ioctl_subscribe_port()
1571 static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client, in snd_seq_ioctl_unsubscribe_port() argument
1579 receiver = snd_seq_client_use_ptr(subs->dest.client); in snd_seq_ioctl_unsubscribe_port()
1582 sender = snd_seq_client_use_ptr(subs->sender.client); in snd_seq_ioctl_unsubscribe_port()
1592 result = check_subscription_permission(client, sport, dport, subs); in snd_seq_ioctl_unsubscribe_port()
1596 result = snd_seq_port_disconnect(client, sender, sport, receiver, dport, subs); in snd_seq_ioctl_unsubscribe_port()
1614 static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_create_queue() argument
1619 q = snd_seq_queue_alloc(client->number, info->locked, info->flags); in snd_seq_ioctl_create_queue()
1637 static int snd_seq_ioctl_delete_queue(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_delete_queue() argument
1641 return snd_seq_queue_delete(client->number, info->queue); in snd_seq_ioctl_delete_queue()
1645 static int snd_seq_ioctl_get_queue_info(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_info() argument
1666 static int snd_seq_ioctl_set_queue_info(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_info() argument
1672 if (info->owner != client->number) in snd_seq_ioctl_set_queue_info()
1676 if (snd_seq_queue_check_access(info->queue, client->number)) { in snd_seq_ioctl_set_queue_info()
1677 if (snd_seq_queue_set_owner(info->queue, client->number, info->locked) < 0) in snd_seq_ioctl_set_queue_info()
1680 snd_seq_queue_use(info->queue, client->number, 1); in snd_seq_ioctl_set_queue_info()
1688 if (q->owner != client->number) { in snd_seq_ioctl_set_queue_info()
1699 static int snd_seq_ioctl_get_named_queue(struct snd_seq_client *client, in snd_seq_ioctl_get_named_queue() argument
1717 static int snd_seq_ioctl_get_queue_status(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_status() argument
1746 static int snd_seq_ioctl_get_queue_tempo(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_tempo() argument
1765 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 4)) in snd_seq_ioctl_get_queue_tempo()
1774 int snd_seq_set_queue_tempo(int client, struct snd_seq_queue_tempo *tempo) in snd_seq_set_queue_tempo() argument
1776 if (!snd_seq_queue_check_access(tempo->queue, client)) in snd_seq_set_queue_tempo()
1778 return snd_seq_queue_timer_set_tempo(tempo->queue, client, tempo); in snd_seq_set_queue_tempo()
1782 static int snd_seq_ioctl_set_queue_tempo(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_tempo() argument
1788 if (client->user_pversion < SNDRV_PROTOCOL_VERSION(1, 0, 4)) in snd_seq_ioctl_set_queue_tempo()
1790 result = snd_seq_set_queue_tempo(client->number, tempo); in snd_seq_ioctl_set_queue_tempo()
1796 static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_timer() argument
1825 static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_timer() argument
1834 if (snd_seq_queue_check_access(timer->queue, client->number)) { in snd_seq_ioctl_set_queue_timer()
1861 static int snd_seq_ioctl_get_queue_client(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_client() argument
1867 used = snd_seq_queue_is_used(info->queue, client->number); in snd_seq_ioctl_get_queue_client()
1871 info->client = client->number; in snd_seq_ioctl_get_queue_client()
1878 static int snd_seq_ioctl_set_queue_client(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_client() argument
1885 err = snd_seq_queue_use(info->queue, client->number, info->used); in snd_seq_ioctl_set_queue_client()
1890 return snd_seq_ioctl_get_queue_client(client, arg); in snd_seq_ioctl_set_queue_client()
1895 static int snd_seq_ioctl_get_client_pool(struct snd_seq_client *client, in snd_seq_ioctl_get_client_pool() argument
1901 cptr = client_load_and_use_ptr(info->client); in snd_seq_ioctl_get_client_pool()
1905 info->client = cptr->number; in snd_seq_ioctl_get_client_pool()
1924 static int snd_seq_ioctl_set_client_pool(struct snd_seq_client *client, in snd_seq_ioctl_set_client_pool() argument
1930 if (client->number != info->client) in snd_seq_ioctl_set_client_pool()
1934 (! snd_seq_write_pool_allocated(client) || in snd_seq_ioctl_set_client_pool()
1935 info->output_pool != client->pool->size)) { in snd_seq_ioctl_set_client_pool()
1936 if (snd_seq_write_pool_allocated(client)) { in snd_seq_ioctl_set_client_pool()
1938 if (atomic_read(&client->pool->counter)) in snd_seq_ioctl_set_client_pool()
1941 snd_seq_pool_mark_closing(client->pool); in snd_seq_ioctl_set_client_pool()
1942 snd_seq_pool_done(client->pool); in snd_seq_ioctl_set_client_pool()
1944 client->pool->size = info->output_pool; in snd_seq_ioctl_set_client_pool()
1945 rc = snd_seq_pool_init(client->pool); in snd_seq_ioctl_set_client_pool()
1949 if (client->type == USER_CLIENT && client->data.user.fifo != NULL && in snd_seq_ioctl_set_client_pool()
1952 info->input_pool != client->data.user.fifo_pool_size) { in snd_seq_ioctl_set_client_pool()
1954 rc = snd_seq_fifo_resize(client->data.user.fifo, info->input_pool); in snd_seq_ioctl_set_client_pool()
1957 client->data.user.fifo_pool_size = info->input_pool; in snd_seq_ioctl_set_client_pool()
1960 info->output_room <= client->pool->size) { in snd_seq_ioctl_set_client_pool()
1961 client->pool->room = info->output_room; in snd_seq_ioctl_set_client_pool()
1964 return snd_seq_ioctl_get_client_pool(client, arg); in snd_seq_ioctl_set_client_pool()
1969 static int snd_seq_ioctl_remove_events(struct snd_seq_client *client, in snd_seq_ioctl_remove_events() argument
1979 * No restrictions so for a user client we can clear in snd_seq_ioctl_remove_events()
1982 if (client->type == USER_CLIENT && client->data.user.fifo) in snd_seq_ioctl_remove_events()
1983 snd_seq_fifo_clear(client->data.user.fifo); in snd_seq_ioctl_remove_events()
1987 snd_seq_queue_remove_cells(client->number, info); in snd_seq_ioctl_remove_events()
1996 static int snd_seq_ioctl_get_subscription(struct snd_seq_client *client, in snd_seq_ioctl_get_subscription() argument
2005 sender = client_load_and_use_ptr(subs->sender.client); in snd_seq_ioctl_get_subscription()
2026 static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_query_subs() argument
2036 cptr = client_load_and_use_ptr(subs->root.client); in snd_seq_ioctl_query_subs()
2089 * query next client
2091 static int snd_seq_ioctl_query_next_client(struct snd_seq_client *client, in snd_seq_ioctl_query_next_client() argument
2097 /* search for next client */ in snd_seq_ioctl_query_next_client()
2098 if (info->client < INT_MAX) in snd_seq_ioctl_query_next_client()
2099 info->client++; in snd_seq_ioctl_query_next_client()
2100 if (info->client < 0) in snd_seq_ioctl_query_next_client()
2101 info->client = 0; in snd_seq_ioctl_query_next_client()
2102 for (; info->client < SNDRV_SEQ_MAX_CLIENTS; info->client++) { in snd_seq_ioctl_query_next_client()
2103 cptr = client_load_and_use_ptr(info->client); in snd_seq_ioctl_query_next_client()
2119 static int snd_seq_ioctl_query_next_port(struct snd_seq_client *client, in snd_seq_ioctl_query_next_port() argument
2126 cptr = client_load_and_use_ptr(info->addr.client); in snd_seq_ioctl_query_next_port()
2150 static void free_ump_info(struct snd_seq_client *client) in free_ump_info() argument
2154 if (!client->ump_info) in free_ump_info()
2157 kfree(client->ump_info[i]); in free_ump_info()
2158 kfree(client->ump_info); in free_ump_info()
2159 client->ump_info = NULL; in free_ump_info()
2175 struct snd_seq_client *client) in dump_ump_info() argument
2181 if (!client->ump_info) in dump_ump_info()
2183 ep = client->ump_info[SNDRV_SEQ_CLIENT_UMP_INFO_ENDPOINT]; in dump_ump_info()
2187 bp = client->ump_info[i + 1]; in dump_ump_info()
2208 int client, type, err = 0; in snd_seq_ioctl_client_ump_info() local
2212 if (get_user(client, &argp->client) || get_user(type, &argp->type)) in snd_seq_ioctl_client_ump_info()
2215 caller->number != client) in snd_seq_ioctl_client_ump_info()
2223 cptr = client_load_and_use_ptr(client); in snd_seq_ioctl_client_ump_info()
2274 snd_seq_system_ump_notify(client, 0, in snd_seq_ioctl_client_ump_info()
2278 snd_seq_system_ump_notify(client, type - 1, in snd_seq_ioctl_client_ump_info()
2290 int (*func)(struct snd_seq_client *client, void *arg);
2330 struct snd_seq_client *client = file->private_data; in snd_seq_ioctl() local
2353 if (snd_BUG_ON(!client)) in snd_seq_ioctl()
2361 return snd_seq_ioctl_client_ump_info(client, cmd, arg); in snd_seq_ioctl()
2384 mutex_lock(&client->ioctl_mutex); in snd_seq_ioctl()
2385 err = handler->func(client, &buf); in snd_seq_ioctl()
2386 mutex_unlock(&client->ioctl_mutex); in snd_seq_ioctl()
2412 struct snd_seq_client *client; in snd_seq_create_kernel_client() local
2433 client = seq_create_client1(client_index, 0); in snd_seq_create_kernel_client()
2434 if (client == NULL) { in snd_seq_create_kernel_client()
2440 client->accept_input = 1; in snd_seq_create_kernel_client()
2441 client->accept_output = 1; in snd_seq_create_kernel_client()
2442 client->data.kernel.card = card; in snd_seq_create_kernel_client()
2443 client->user_pversion = SNDRV_SEQ_VERSION; in snd_seq_create_kernel_client()
2446 vsnprintf(client->name, sizeof(client->name), name_fmt, args); in snd_seq_create_kernel_client()
2449 client->type = KERNEL_CLIENT; in snd_seq_create_kernel_client()
2452 /* make others aware this new client */ in snd_seq_create_kernel_client()
2453 snd_seq_system_client_ev_client_start(client->number); in snd_seq_create_kernel_client()
2455 /* return client number to caller */ in snd_seq_create_kernel_client()
2456 return client->number; in snd_seq_create_kernel_client()
2461 int snd_seq_delete_kernel_client(int client) in snd_seq_delete_kernel_client() argument
2468 ptr = clientptr(client); in snd_seq_delete_kernel_client()
2483 int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, in snd_seq_kernel_client_enqueue() argument
2499 /* fill in client number */ in snd_seq_kernel_client_enqueue()
2500 ev->source.client = client; in snd_seq_kernel_client_enqueue()
2505 cptr = client_load_and_use_ptr(client); in snd_seq_kernel_client_enqueue()
2531 int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event * ev, in snd_seq_kernel_client_dispatch() argument
2540 /* fill in client number */ in snd_seq_kernel_client_dispatch()
2542 ev->source.client = client; in snd_seq_kernel_client_dispatch()
2547 cptr = snd_seq_client_use_ptr(client); in snd_seq_kernel_client_dispatch()
2562 * snd_seq_kernel_client_ctl - operate a command for a client with data in
2564 * @clientid: A numerical ID for a client.
2568 * Against its name, both kernel/application client can be handled by this
2576 struct snd_seq_client *client; in snd_seq_kernel_client_ctl() local
2578 client = clientptr(clientid); in snd_seq_kernel_client_ctl()
2579 if (client == NULL) in snd_seq_kernel_client_ctl()
2584 return handler->func(client, arg); in snd_seq_kernel_client_ctl()
2596 struct snd_seq_client *client; in snd_seq_kernel_client_write_poll() local
2598 client = clientptr(clientid); in snd_seq_kernel_client_write_poll()
2599 if (client == NULL) in snd_seq_kernel_client_write_poll()
2602 if (snd_seq_pool_poll_wait(client->pool, file, wait)) in snd_seq_kernel_client_write_poll()
2608 /* get a sequencer client object; for internal use from a kernel client */
2615 /* put a sequencer client object; for internal use from a kernel client */
2651 is_src ? s->info.dest.client : s->info.sender.client, in snd_seq_info_dump_subscribers()
2680 struct snd_seq_client *client) in snd_seq_info_dump_ports() argument
2684 mutex_lock(&client->ports_mutex); in snd_seq_info_dump_ports()
2685 list_for_each_entry(p, &client->ports_list_head, list) { in snd_seq_info_dump_ports()
2696 if (snd_seq_client_is_midi2(client) && p->is_midi1) in snd_seq_info_dump_ports()
2703 mutex_unlock(&client->ports_mutex); in snd_seq_info_dump_ports()
2725 struct snd_seq_client *client; in snd_seq_info_clients_read() local
2727 snd_iprintf(buffer, "Client info\n"); in snd_seq_info_clients_read()
2733 /* list the client table */ in snd_seq_info_clients_read()
2735 client = client_load_and_use_ptr(c); in snd_seq_info_clients_read()
2736 if (client == NULL) in snd_seq_info_clients_read()
2738 if (client->type == NO_CLIENT) { in snd_seq_info_clients_read()
2739 snd_seq_client_unlock(client); in snd_seq_info_clients_read()
2743 mutex_lock(&client->ioctl_mutex); in snd_seq_info_clients_read()
2744 snd_iprintf(buffer, "Client %3d : \"%s\" [%s %s]\n", in snd_seq_info_clients_read()
2745 c, client->name, in snd_seq_info_clients_read()
2746 client->type == USER_CLIENT ? "User" : "Kernel", in snd_seq_info_clients_read()
2747 midi_version_string(client->midi_version)); in snd_seq_info_clients_read()
2749 dump_ump_info(buffer, client); in snd_seq_info_clients_read()
2751 snd_seq_info_dump_ports(buffer, client); in snd_seq_info_clients_read()
2752 if (snd_seq_write_pool_allocated(client)) { in snd_seq_info_clients_read()
2754 snd_seq_info_pool(buffer, client->pool, " "); in snd_seq_info_clients_read()
2756 if (client->type == USER_CLIENT && client->data.user.fifo && in snd_seq_info_clients_read()
2757 client->data.user.fifo->pool) { in snd_seq_info_clients_read()
2759 snd_seq_info_pool(buffer, client->data.user.fifo->pool, " "); in snd_seq_info_clients_read()
2761 mutex_unlock(&client->ioctl_mutex); in snd_seq_info_clients_read()
2762 snd_seq_client_unlock(client); in snd_seq_info_clients_read()