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
763 err = snd_seq_deliver_single_event(client, event, atomic, hop); in __deliver_to_subscribers()
782 static int deliver_to_subscribers(struct snd_seq_client *client, in deliver_to_subscribers() argument
789 src_port = snd_seq_port_use_ptr(client, event->source.port); in deliver_to_subscribers()
791 ret = __deliver_to_subscribers(client, event, src_port, atomic, hop); in deliver_to_subscribers()
795 if (client->ump_endpoint_port < 0 || in deliver_to_subscribers()
796 event->source.port == client->ump_endpoint_port) in deliver_to_subscribers()
799 src_port = snd_seq_port_use_ptr(client, client->ump_endpoint_port); in deliver_to_subscribers()
802 ret2 = __deliver_to_subscribers(client, event, src_port, atomic, hop); in deliver_to_subscribers()
812 * n == 0 : the event was not passed to any client.
815 static int snd_seq_deliver_event(struct snd_seq_client *client, struct snd_seq_event *event, in snd_seq_deliver_event() argument
823 event->source.client, event->source.port, in snd_seq_deliver_event()
824 event->dest.client, event->dest.port); in snd_seq_deliver_event()
833 event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) in snd_seq_deliver_event()
834 result = deliver_to_subscribers(client, event, atomic, hop); in snd_seq_deliver_event()
836 result = snd_seq_deliver_single_event(client, event, atomic, hop); in snd_seq_deliver_event()
848 * n == 0 : the event was not passed to any client.
853 struct snd_seq_client *client; in snd_seq_dispatch_event() local
859 client = snd_seq_client_use_ptr(cell->event.source.client); in snd_seq_dispatch_event()
860 if (client == NULL) { in snd_seq_dispatch_event()
876 result = snd_seq_deliver_event(client, &tmpev, atomic, hop); in snd_seq_dispatch_event()
911 result = snd_seq_deliver_event(client, &cell->event, atomic, hop); in snd_seq_dispatch_event()
915 snd_seq_client_unlock(client); in snd_seq_dispatch_event()
920 /* Allocate a cell from client pool and enqueue it to queue:
924 static int snd_seq_client_enqueue_event(struct snd_seq_client *client, in snd_seq_client_enqueue_event() argument
935 event->dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS; in snd_seq_client_enqueue_event()
937 } else if (event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) { in snd_seq_client_enqueue_event()
939 struct snd_seq_client_port *src_port = snd_seq_port_use_ptr(client, event->source.port); in snd_seq_client_enqueue_event()
950 return snd_seq_deliver_event(client, event, atomic, hop); in snd_seq_client_enqueue_event()
954 if (snd_seq_queue_is_used(event->queue, client->number) <= 0) in snd_seq_client_enqueue_event()
956 if (! snd_seq_write_pool_allocated(client)) in snd_seq_client_enqueue_event()
960 err = snd_seq_event_dup(client->pool, event, &cell, !blocking || atomic, in snd_seq_client_enqueue_event()
1003 * -ENXIO invalid client or file open mode
1015 struct snd_seq_client *client = file->private_data; in snd_seq_write() local
1024 /* check client structures are in place */ in snd_seq_write()
1025 if (snd_BUG_ON(!client)) in snd_seq_write()
1028 if (!client->accept_output || client->pool == NULL) in snd_seq_write()
1034 mutex_lock(&client->ioctl_mutex); in snd_seq_write()
1035 if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) { in snd_seq_write()
1036 err = snd_seq_pool_init(client->pool); in snd_seq_write()
1062 ev->source.client = client->number; /* fill in client number */ in snd_seq_write()
1069 if (!event_is_compatible(client, ev)) { in snd_seq_write()
1097 if (client->convert32 && snd_seq_ev_is_varusr(ev)) in snd_seq_write()
1104 err = snd_seq_client_enqueue_event(client, ev, file, in snd_seq_write()
1106 0, 0, &client->ioctl_mutex); in snd_seq_write()
1119 mutex_unlock(&client->ioctl_mutex); in snd_seq_write()
1125 mutex_unlock(&client->ioctl_mutex); in snd_seq_write()
1135 struct snd_seq_client *client = file->private_data; in snd_seq_poll() local
1138 /* check client structures are in place */ in snd_seq_poll()
1139 if (snd_BUG_ON(!client)) in snd_seq_poll()
1143 client->data.user.fifo) { in snd_seq_poll()
1146 if (snd_seq_fifo_poll_wait(client->data.user.fifo, file, wait)) in snd_seq_poll()
1153 if (!snd_seq_write_pool_allocated(client) || in snd_seq_poll()
1154 snd_seq_pool_poll_wait(client->pool, file, wait)) in snd_seq_poll()
1164 static int snd_seq_ioctl_pversion(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_pversion() argument
1172 static int snd_seq_ioctl_user_pversion(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_user_pversion() argument
1174 client->user_pversion = *(unsigned int *)arg; in snd_seq_ioctl_user_pversion()
1178 static int snd_seq_ioctl_client_id(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_client_id() argument
1182 *client_id = client->number; in snd_seq_ioctl_client_id()
1187 static int snd_seq_ioctl_system_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_system_info() argument
1205 static int snd_seq_ioctl_running_mode(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_running_mode() argument
1211 /* requested client number */ in snd_seq_ioctl_running_mode()
1212 cptr = client_load_and_use_ptr(info->client); in snd_seq_ioctl_running_mode()
1242 info->client = cptr->number; in get_client_info()
1267 static int snd_seq_ioctl_get_client_info(struct snd_seq_client *client, in snd_seq_ioctl_get_client_info() argument
1273 /* requested client number */ in snd_seq_ioctl_get_client_info()
1274 cptr = client_load_and_use_ptr(client_info->client); in snd_seq_ioctl_get_client_info()
1286 static int snd_seq_ioctl_set_client_info(struct snd_seq_client *client, in snd_seq_ioctl_set_client_info() argument
1291 /* it is not allowed to set the info fields for an another client */ in snd_seq_ioctl_set_client_info()
1292 if (client->number != client_info->client) in snd_seq_ioctl_set_client_info()
1294 /* also client type must be set now */ in snd_seq_ioctl_set_client_info()
1295 if (client->type != client_info->type) in snd_seq_ioctl_set_client_info()
1298 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3)) { in snd_seq_ioctl_set_client_info()
1311 strscpy(client->name, client_info->name, sizeof(client->name)); in snd_seq_ioctl_set_client_info()
1313 client->filter = client_info->filter; in snd_seq_ioctl_set_client_info()
1314 client->event_lost = client_info->event_lost; in snd_seq_ioctl_set_client_info()
1315 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3)) in snd_seq_ioctl_set_client_info()
1316 client->midi_version = client_info->midi_version; in snd_seq_ioctl_set_client_info()
1317 memcpy(client->event_filter, client_info->event_filter, 32); in snd_seq_ioctl_set_client_info()
1318 client->group_filter = client_info->group_filter; in snd_seq_ioctl_set_client_info()
1321 snd_seq_system_client_ev_client_change(client->number); in snd_seq_ioctl_set_client_info()
1330 static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_create_port() argument
1337 /* it is not allowed to create the port for an another client */ in snd_seq_ioctl_create_port()
1338 if (info->addr.client != client->number) in snd_seq_ioctl_create_port()
1340 if (client->type == USER_CLIENT && info->kernel) in snd_seq_ioctl_create_port()
1343 client->ump_endpoint_port >= 0) in snd_seq_ioctl_create_port()
1352 err = snd_seq_create_port(client, port_idx, &port); in snd_seq_ioctl_create_port()
1356 if (client->type == KERNEL_CLIENT) { in snd_seq_ioctl_create_port()
1375 client->ump_endpoint_port = port->addr.port; in snd_seq_ioctl_create_port()
1376 snd_seq_system_client_ev_port_start(port->addr.client, port->addr.port); in snd_seq_ioctl_create_port()
1385 static int snd_seq_ioctl_delete_port(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_delete_port() argument
1390 /* it is not allowed to remove the port for an another client */ in snd_seq_ioctl_delete_port()
1391 if (info->addr.client != client->number) in snd_seq_ioctl_delete_port()
1394 err = snd_seq_delete_port(client, info->addr.port); in snd_seq_ioctl_delete_port()
1396 if (client->ump_endpoint_port == info->addr.port) in snd_seq_ioctl_delete_port()
1397 client->ump_endpoint_port = -1; in snd_seq_ioctl_delete_port()
1398 snd_seq_system_client_ev_port_exit(client->number, info->addr.port); in snd_seq_ioctl_delete_port()
1405 * GET_PORT_INFO ioctl() (on any client)
1407 static int snd_seq_ioctl_get_port_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_get_port_info() argument
1413 cptr = client_load_and_use_ptr(info->addr.client); in snd_seq_ioctl_get_port_info()
1433 * SET_PORT_INFO ioctl() (only ports on this/own client)
1435 static int snd_seq_ioctl_set_port_info(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_set_port_info() argument
1440 if (info->addr.client != client->number) /* only set our own ports ! */ in snd_seq_ioctl_set_port_info()
1442 port = snd_seq_port_use_ptr(client, info->addr.port); in snd_seq_ioctl_set_port_info()
1447 snd_seq_system_client_ev_port_change(info->addr.client, in snd_seq_ioctl_set_port_info()
1460 static int check_subscription_permission(struct snd_seq_client *client, in check_subscription_permission() argument
1465 if (client->number != subs->sender.client && in check_subscription_permission()
1466 client->number != subs->dest.client) { in check_subscription_permission()
1467 /* connection by third client - check export permission */ in check_subscription_permission()
1475 /* if sender or receiver is the subscribing client itself, in check_subscription_permission()
1478 if (client->number != subs->sender.client) { in check_subscription_permission()
1483 if (client->number != subs->dest.client) { in check_subscription_permission()
1491 * send an subscription notify event to user client:
1492 * client must be user client.
1494 int snd_seq_client_notify_subscription(int client, int port, in snd_seq_client_notify_subscription() argument
1505 return snd_seq_system_notify(client, port, &event, false); /* non-atomic */ in snd_seq_client_notify_subscription()
1512 static int snd_seq_ioctl_subscribe_port(struct snd_seq_client *client, in snd_seq_ioctl_subscribe_port() argument
1520 receiver = client_load_and_use_ptr(subs->dest.client); in snd_seq_ioctl_subscribe_port()
1523 sender = client_load_and_use_ptr(subs->sender.client); in snd_seq_ioctl_subscribe_port()
1533 result = check_subscription_permission(client, sport, dport, subs); in snd_seq_ioctl_subscribe_port()
1538 result = snd_seq_port_connect(client, sender, sport, receiver, dport, subs); in snd_seq_ioctl_subscribe_port()
1558 static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client, in snd_seq_ioctl_unsubscribe_port() argument
1566 receiver = snd_seq_client_use_ptr(subs->dest.client); in snd_seq_ioctl_unsubscribe_port()
1569 sender = snd_seq_client_use_ptr(subs->sender.client); in snd_seq_ioctl_unsubscribe_port()
1579 result = check_subscription_permission(client, sport, dport, subs); in snd_seq_ioctl_unsubscribe_port()
1583 result = snd_seq_port_disconnect(client, sender, sport, receiver, dport, subs); in snd_seq_ioctl_unsubscribe_port()
1601 static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_create_queue() argument
1606 q = snd_seq_queue_alloc(client->number, info->locked, info->flags); in snd_seq_ioctl_create_queue()
1624 static int snd_seq_ioctl_delete_queue(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_delete_queue() argument
1628 return snd_seq_queue_delete(client->number, info->queue); in snd_seq_ioctl_delete_queue()
1632 static int snd_seq_ioctl_get_queue_info(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_info() argument
1653 static int snd_seq_ioctl_set_queue_info(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_info() argument
1659 if (info->owner != client->number) in snd_seq_ioctl_set_queue_info()
1663 if (snd_seq_queue_check_access(info->queue, client->number)) { in snd_seq_ioctl_set_queue_info()
1664 if (snd_seq_queue_set_owner(info->queue, client->number, info->locked) < 0) in snd_seq_ioctl_set_queue_info()
1667 snd_seq_queue_use(info->queue, client->number, 1); in snd_seq_ioctl_set_queue_info()
1675 if (q->owner != client->number) { in snd_seq_ioctl_set_queue_info()
1686 static int snd_seq_ioctl_get_named_queue(struct snd_seq_client *client, in snd_seq_ioctl_get_named_queue() argument
1704 static int snd_seq_ioctl_get_queue_status(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_status() argument
1733 static int snd_seq_ioctl_get_queue_tempo(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_tempo() argument
1752 if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 4)) in snd_seq_ioctl_get_queue_tempo()
1761 int snd_seq_set_queue_tempo(int client, struct snd_seq_queue_tempo *tempo) in snd_seq_set_queue_tempo() argument
1763 if (!snd_seq_queue_check_access(tempo->queue, client)) in snd_seq_set_queue_tempo()
1765 return snd_seq_queue_timer_set_tempo(tempo->queue, client, tempo); in snd_seq_set_queue_tempo()
1769 static int snd_seq_ioctl_set_queue_tempo(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_tempo() argument
1775 if (client->user_pversion < SNDRV_PROTOCOL_VERSION(1, 0, 4)) in snd_seq_ioctl_set_queue_tempo()
1777 result = snd_seq_set_queue_tempo(client->number, tempo); in snd_seq_ioctl_set_queue_tempo()
1783 static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_timer() argument
1812 static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_timer() argument
1821 if (snd_seq_queue_check_access(timer->queue, client->number)) { in snd_seq_ioctl_set_queue_timer()
1848 static int snd_seq_ioctl_get_queue_client(struct snd_seq_client *client, in snd_seq_ioctl_get_queue_client() argument
1854 used = snd_seq_queue_is_used(info->queue, client->number); in snd_seq_ioctl_get_queue_client()
1858 info->client = client->number; in snd_seq_ioctl_get_queue_client()
1865 static int snd_seq_ioctl_set_queue_client(struct snd_seq_client *client, in snd_seq_ioctl_set_queue_client() argument
1872 err = snd_seq_queue_use(info->queue, client->number, info->used); in snd_seq_ioctl_set_queue_client()
1877 return snd_seq_ioctl_get_queue_client(client, arg); in snd_seq_ioctl_set_queue_client()
1882 static int snd_seq_ioctl_get_client_pool(struct snd_seq_client *client, in snd_seq_ioctl_get_client_pool() argument
1888 cptr = client_load_and_use_ptr(info->client); in snd_seq_ioctl_get_client_pool()
1892 info->client = cptr->number; in snd_seq_ioctl_get_client_pool()
1911 static int snd_seq_ioctl_set_client_pool(struct snd_seq_client *client, in snd_seq_ioctl_set_client_pool() argument
1917 if (client->number != info->client) in snd_seq_ioctl_set_client_pool()
1921 (! snd_seq_write_pool_allocated(client) || in snd_seq_ioctl_set_client_pool()
1922 info->output_pool != client->pool->size)) { in snd_seq_ioctl_set_client_pool()
1923 if (snd_seq_write_pool_allocated(client)) { in snd_seq_ioctl_set_client_pool()
1925 if (atomic_read(&client->pool->counter)) in snd_seq_ioctl_set_client_pool()
1928 snd_seq_pool_mark_closing(client->pool); in snd_seq_ioctl_set_client_pool()
1929 snd_seq_pool_done(client->pool); in snd_seq_ioctl_set_client_pool()
1931 client->pool->size = info->output_pool; in snd_seq_ioctl_set_client_pool()
1932 rc = snd_seq_pool_init(client->pool); in snd_seq_ioctl_set_client_pool()
1936 if (client->type == USER_CLIENT && client->data.user.fifo != NULL && in snd_seq_ioctl_set_client_pool()
1939 info->input_pool != client->data.user.fifo_pool_size) { in snd_seq_ioctl_set_client_pool()
1941 rc = snd_seq_fifo_resize(client->data.user.fifo, info->input_pool); in snd_seq_ioctl_set_client_pool()
1944 client->data.user.fifo_pool_size = info->input_pool; in snd_seq_ioctl_set_client_pool()
1947 info->output_room <= client->pool->size) { in snd_seq_ioctl_set_client_pool()
1948 client->pool->room = info->output_room; in snd_seq_ioctl_set_client_pool()
1951 return snd_seq_ioctl_get_client_pool(client, arg); in snd_seq_ioctl_set_client_pool()
1956 static int snd_seq_ioctl_remove_events(struct snd_seq_client *client, in snd_seq_ioctl_remove_events() argument
1966 * No restrictions so for a user client we can clear in snd_seq_ioctl_remove_events()
1969 if (client->type == USER_CLIENT && client->data.user.fifo) in snd_seq_ioctl_remove_events()
1970 snd_seq_fifo_clear(client->data.user.fifo); in snd_seq_ioctl_remove_events()
1974 snd_seq_queue_remove_cells(client->number, info); in snd_seq_ioctl_remove_events()
1983 static int snd_seq_ioctl_get_subscription(struct snd_seq_client *client, in snd_seq_ioctl_get_subscription() argument
1992 sender = client_load_and_use_ptr(subs->sender.client); in snd_seq_ioctl_get_subscription()
2013 static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg) in snd_seq_ioctl_query_subs() argument
2023 cptr = client_load_and_use_ptr(subs->root.client); in snd_seq_ioctl_query_subs()
2076 * query next client
2078 static int snd_seq_ioctl_query_next_client(struct snd_seq_client *client, in snd_seq_ioctl_query_next_client() argument
2084 /* search for next client */ in snd_seq_ioctl_query_next_client()
2085 if (info->client < INT_MAX) in snd_seq_ioctl_query_next_client()
2086 info->client++; in snd_seq_ioctl_query_next_client()
2087 if (info->client < 0) in snd_seq_ioctl_query_next_client()
2088 info->client = 0; in snd_seq_ioctl_query_next_client()
2089 for (; info->client < SNDRV_SEQ_MAX_CLIENTS; info->client++) { in snd_seq_ioctl_query_next_client()
2090 cptr = client_load_and_use_ptr(info->client); in snd_seq_ioctl_query_next_client()
2106 static int snd_seq_ioctl_query_next_port(struct snd_seq_client *client, in snd_seq_ioctl_query_next_port() argument
2113 cptr = client_load_and_use_ptr(info->addr.client); in snd_seq_ioctl_query_next_port()
2137 static void free_ump_info(struct snd_seq_client *client) in free_ump_info() argument
2141 if (!client->ump_info) in free_ump_info()
2144 kfree(client->ump_info[i]); in free_ump_info()
2145 kfree(client->ump_info); in free_ump_info()
2146 client->ump_info = NULL; in free_ump_info()
2162 struct snd_seq_client *client) in dump_ump_info() argument
2168 if (!client->ump_info) in dump_ump_info()
2170 ep = client->ump_info[SNDRV_SEQ_CLIENT_UMP_INFO_ENDPOINT]; in dump_ump_info()
2174 bp = client->ump_info[i + 1]; in dump_ump_info()
2195 int client, type, err = 0; in snd_seq_ioctl_client_ump_info() local
2199 if (get_user(client, &argp->client) || get_user(type, &argp->type)) in snd_seq_ioctl_client_ump_info()
2202 caller->number != client) in snd_seq_ioctl_client_ump_info()
2210 cptr = client_load_and_use_ptr(client); in snd_seq_ioctl_client_ump_info()
2261 snd_seq_system_ump_notify(client, 0, in snd_seq_ioctl_client_ump_info()
2265 snd_seq_system_ump_notify(client, type - 1, in snd_seq_ioctl_client_ump_info()
2277 int (*func)(struct snd_seq_client *client, void *arg);
2317 struct snd_seq_client *client = file->private_data; in snd_seq_ioctl() local
2340 if (snd_BUG_ON(!client)) in snd_seq_ioctl()
2348 return snd_seq_ioctl_client_ump_info(client, cmd, arg); in snd_seq_ioctl()
2371 mutex_lock(&client->ioctl_mutex); in snd_seq_ioctl()
2372 err = handler->func(client, &buf); in snd_seq_ioctl()
2373 mutex_unlock(&client->ioctl_mutex); in snd_seq_ioctl()
2399 struct snd_seq_client *client; in snd_seq_create_kernel_client() local
2420 client = seq_create_client1(client_index, 0); in snd_seq_create_kernel_client()
2421 if (client == NULL) { in snd_seq_create_kernel_client()
2427 client->accept_input = 1; in snd_seq_create_kernel_client()
2428 client->accept_output = 1; in snd_seq_create_kernel_client()
2429 client->data.kernel.card = card; in snd_seq_create_kernel_client()
2430 client->user_pversion = SNDRV_SEQ_VERSION; in snd_seq_create_kernel_client()
2433 vsnprintf(client->name, sizeof(client->name), name_fmt, args); in snd_seq_create_kernel_client()
2436 client->type = KERNEL_CLIENT; in snd_seq_create_kernel_client()
2439 /* make others aware this new client */ in snd_seq_create_kernel_client()
2440 snd_seq_system_client_ev_client_start(client->number); in snd_seq_create_kernel_client()
2442 /* return client number to caller */ in snd_seq_create_kernel_client()
2443 return client->number; in snd_seq_create_kernel_client()
2448 int snd_seq_delete_kernel_client(int client) in snd_seq_delete_kernel_client() argument
2455 ptr = clientptr(client); in snd_seq_delete_kernel_client()
2470 int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, in snd_seq_kernel_client_enqueue() argument
2486 /* fill in client number */ in snd_seq_kernel_client_enqueue()
2487 ev->source.client = client; in snd_seq_kernel_client_enqueue()
2492 cptr = client_load_and_use_ptr(client); in snd_seq_kernel_client_enqueue()
2518 int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event * ev, in snd_seq_kernel_client_dispatch() argument
2527 /* fill in client number */ in snd_seq_kernel_client_dispatch()
2529 ev->source.client = client; in snd_seq_kernel_client_dispatch()
2534 cptr = snd_seq_client_use_ptr(client); in snd_seq_kernel_client_dispatch()
2549 * snd_seq_kernel_client_ctl - operate a command for a client with data in
2551 * @clientid: A numerical ID for a client.
2555 * Against its name, both kernel/application client can be handled by this
2563 struct snd_seq_client *client; in snd_seq_kernel_client_ctl() local
2565 client = clientptr(clientid); in snd_seq_kernel_client_ctl()
2566 if (client == NULL) in snd_seq_kernel_client_ctl()
2571 return handler->func(client, arg); in snd_seq_kernel_client_ctl()
2583 struct snd_seq_client *client; in snd_seq_kernel_client_write_poll() local
2585 client = clientptr(clientid); in snd_seq_kernel_client_write_poll()
2586 if (client == NULL) in snd_seq_kernel_client_write_poll()
2589 if (! snd_seq_write_pool_allocated(client)) in snd_seq_kernel_client_write_poll()
2591 if (snd_seq_pool_poll_wait(client->pool, file, wait)) in snd_seq_kernel_client_write_poll()
2597 /* get a sequencer client object; for internal use from a kernel client */
2604 /* put a sequencer client object; for internal use from a kernel client */
2640 is_src ? s->info.dest.client : s->info.sender.client, in snd_seq_info_dump_subscribers()
2669 struct snd_seq_client *client) in snd_seq_info_dump_ports() argument
2673 mutex_lock(&client->ports_mutex); in snd_seq_info_dump_ports()
2674 list_for_each_entry(p, &client->ports_list_head, list) { in snd_seq_info_dump_ports()
2685 if (snd_seq_client_is_midi2(client) && p->is_midi1) in snd_seq_info_dump_ports()
2692 mutex_unlock(&client->ports_mutex); in snd_seq_info_dump_ports()
2714 struct snd_seq_client *client; in snd_seq_info_clients_read() local
2716 snd_iprintf(buffer, "Client info\n"); in snd_seq_info_clients_read()
2722 /* list the client table */ in snd_seq_info_clients_read()
2724 client = client_load_and_use_ptr(c); in snd_seq_info_clients_read()
2725 if (client == NULL) in snd_seq_info_clients_read()
2727 if (client->type == NO_CLIENT) { in snd_seq_info_clients_read()
2728 snd_seq_client_unlock(client); in snd_seq_info_clients_read()
2732 snd_iprintf(buffer, "Client %3d : \"%s\" [%s %s]\n", in snd_seq_info_clients_read()
2733 c, client->name, in snd_seq_info_clients_read()
2734 client->type == USER_CLIENT ? "User" : "Kernel", in snd_seq_info_clients_read()
2735 midi_version_string(client->midi_version)); in snd_seq_info_clients_read()
2737 dump_ump_info(buffer, client); in snd_seq_info_clients_read()
2739 snd_seq_info_dump_ports(buffer, client); in snd_seq_info_clients_read()
2740 if (snd_seq_write_pool_allocated(client)) { in snd_seq_info_clients_read()
2742 snd_seq_info_pool(buffer, client->pool, " "); in snd_seq_info_clients_read()
2744 if (client->type == USER_CLIENT && client->data.user.fifo && in snd_seq_info_clients_read()
2745 client->data.user.fifo->pool) { in snd_seq_info_clients_read()
2747 snd_seq_info_pool(buffer, client->data.user.fifo->pool, " "); in snd_seq_info_clients_read()
2749 snd_seq_client_unlock(client); in snd_seq_info_clients_read()