seq_ports.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /*
  2. * ALSA sequencer Ports
  3. * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
  4. * Jaroslav Kysela <perex@suse.cz>
  5. *
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. */
  22. #include <sound/driver.h>
  23. #include <sound/core.h>
  24. #include <linux/slab.h>
  25. #include "seq_system.h"
  26. #include "seq_ports.h"
  27. #include "seq_clientmgr.h"
  28. /*
  29. registration of client ports
  30. */
  31. /*
  32. NOTE: the current implementation of the port structure as a linked list is
  33. not optimal for clients that have many ports. For sending messages to all
  34. subscribers of a port we first need to find the address of the port
  35. structure, which means we have to traverse the list. A direct access table
  36. (array) would be better, but big preallocated arrays waste memory.
  37. Possible actions:
  38. 1) leave it this way, a client does normaly does not have more than a few
  39. ports
  40. 2) replace the linked list of ports by a array of pointers which is
  41. dynamicly kmalloced. When a port is added or deleted we can simply allocate
  42. a new array, copy the corresponding pointers, and delete the old one. We
  43. then only need a pointer to this array, and an integer that tells us how
  44. much elements are in array.
  45. */
  46. /* return pointer to port structure - port is locked if found */
  47. struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client,
  48. int num)
  49. {
  50. struct snd_seq_client_port *port;
  51. if (client == NULL)
  52. return NULL;
  53. read_lock(&client->ports_lock);
  54. list_for_each_entry(port, &client->ports_list_head, list) {
  55. if (port->addr.port == num) {
  56. if (port->closing)
  57. break; /* deleting now */
  58. snd_use_lock_use(&port->use_lock);
  59. read_unlock(&client->ports_lock);
  60. return port;
  61. }
  62. }
  63. read_unlock(&client->ports_lock);
  64. return NULL; /* not found */
  65. }
  66. /* search for the next port - port is locked if found */
  67. struct snd_seq_client_port *snd_seq_port_query_nearest(struct snd_seq_client *client,
  68. struct snd_seq_port_info *pinfo)
  69. {
  70. int num;
  71. struct snd_seq_client_port *port, *found;
  72. num = pinfo->addr.port;
  73. found = NULL;
  74. read_lock(&client->ports_lock);
  75. list_for_each_entry(port, &client->ports_list_head, list) {
  76. if (port->addr.port < num)
  77. continue;
  78. if (port->addr.port == num) {
  79. found = port;
  80. break;
  81. }
  82. if (found == NULL || port->addr.port < found->addr.port)
  83. found = port;
  84. }
  85. if (found) {
  86. if (found->closing)
  87. found = NULL;
  88. else
  89. snd_use_lock_use(&found->use_lock);
  90. }
  91. read_unlock(&client->ports_lock);
  92. return found;
  93. }
  94. /* initialize snd_seq_port_subs_info */
  95. static void port_subs_info_init(struct snd_seq_port_subs_info *grp)
  96. {
  97. INIT_LIST_HEAD(&grp->list_head);
  98. grp->count = 0;
  99. grp->exclusive = 0;
  100. rwlock_init(&grp->list_lock);
  101. init_rwsem(&grp->list_mutex);
  102. grp->open = NULL;
  103. grp->close = NULL;
  104. }
  105. /* create a port, port number is returned (-1 on failure) */
  106. struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
  107. int port)
  108. {
  109. unsigned long flags;
  110. struct snd_seq_client_port *new_port, *p;
  111. int num = -1;
  112. /* sanity check */
  113. snd_assert(client, return NULL);
  114. if (client->num_ports >= SNDRV_SEQ_MAX_PORTS - 1) {
  115. snd_printk(KERN_WARNING "too many ports for client %d\n", client->number);
  116. return NULL;
  117. }
  118. /* create a new port */
  119. new_port = kzalloc(sizeof(*new_port), GFP_KERNEL);
  120. if (! new_port) {
  121. snd_printd("malloc failed for registering client port\n");
  122. return NULL; /* failure, out of memory */
  123. }
  124. /* init port data */
  125. new_port->addr.client = client->number;
  126. new_port->addr.port = -1;
  127. new_port->owner = THIS_MODULE;
  128. sprintf(new_port->name, "port-%d", num);
  129. snd_use_lock_init(&new_port->use_lock);
  130. port_subs_info_init(&new_port->c_src);
  131. port_subs_info_init(&new_port->c_dest);
  132. num = port >= 0 ? port : 0;
  133. mutex_lock(&client->ports_mutex);
  134. write_lock_irqsave(&client->ports_lock, flags);
  135. list_for_each_entry(p, &client->ports_list_head, list) {
  136. if (p->addr.port > num)
  137. break;
  138. if (port < 0) /* auto-probe mode */
  139. num = p->addr.port + 1;
  140. }
  141. /* insert the new port */
  142. list_add_tail(&new_port->list, &p->list);
  143. client->num_ports++;
  144. new_port->addr.port = num; /* store the port number in the port */
  145. write_unlock_irqrestore(&client->ports_lock, flags);
  146. mutex_unlock(&client->ports_mutex);
  147. sprintf(new_port->name, "port-%d", num);
  148. return new_port;
  149. }
  150. /* */
  151. enum group_type {
  152. SRC_LIST, DEST_LIST
  153. };
  154. static int subscribe_port(struct snd_seq_client *client,
  155. struct snd_seq_client_port *port,
  156. struct snd_seq_port_subs_info *grp,
  157. struct snd_seq_port_subscribe *info, int send_ack);
  158. static int unsubscribe_port(struct snd_seq_client *client,
  159. struct snd_seq_client_port *port,
  160. struct snd_seq_port_subs_info *grp,
  161. struct snd_seq_port_subscribe *info, int send_ack);
  162. static struct snd_seq_client_port *get_client_port(struct snd_seq_addr *addr,
  163. struct snd_seq_client **cp)
  164. {
  165. struct snd_seq_client_port *p;
  166. *cp = snd_seq_client_use_ptr(addr->client);
  167. if (*cp) {
  168. p = snd_seq_port_use_ptr(*cp, addr->port);
  169. if (! p) {
  170. snd_seq_client_unlock(*cp);
  171. *cp = NULL;
  172. }
  173. return p;
  174. }
  175. return NULL;
  176. }
  177. /*
  178. * remove all subscribers on the list
  179. * this is called from port_delete, for each src and dest list.
  180. */
  181. static void clear_subscriber_list(struct snd_seq_client *client,
  182. struct snd_seq_client_port *port,
  183. struct snd_seq_port_subs_info *grp,
  184. int grptype)
  185. {
  186. struct list_head *p, *n;
  187. list_for_each_safe(p, n, &grp->list_head) {
  188. struct snd_seq_subscribers *subs;
  189. struct snd_seq_client *c;
  190. struct snd_seq_client_port *aport;
  191. if (grptype == SRC_LIST) {
  192. subs = list_entry(p, struct snd_seq_subscribers, src_list);
  193. aport = get_client_port(&subs->info.dest, &c);
  194. } else {
  195. subs = list_entry(p, struct snd_seq_subscribers, dest_list);
  196. aport = get_client_port(&subs->info.sender, &c);
  197. }
  198. list_del(p);
  199. unsubscribe_port(client, port, grp, &subs->info, 0);
  200. if (!aport) {
  201. /* looks like the connected port is being deleted.
  202. * we decrease the counter, and when both ports are deleted
  203. * remove the subscriber info
  204. */
  205. if (atomic_dec_and_test(&subs->ref_count))
  206. kfree(subs);
  207. } else {
  208. /* ok we got the connected port */
  209. struct snd_seq_port_subs_info *agrp;
  210. agrp = (grptype == SRC_LIST) ? &aport->c_dest : &aport->c_src;
  211. down_write(&agrp->list_mutex);
  212. if (grptype == SRC_LIST)
  213. list_del(&subs->dest_list);
  214. else
  215. list_del(&subs->src_list);
  216. up_write(&agrp->list_mutex);
  217. unsubscribe_port(c, aport, agrp, &subs->info, 1);
  218. kfree(subs);
  219. snd_seq_port_unlock(aport);
  220. snd_seq_client_unlock(c);
  221. }
  222. }
  223. }
  224. /* delete port data */
  225. static int port_delete(struct snd_seq_client *client,
  226. struct snd_seq_client_port *port)
  227. {
  228. /* set closing flag and wait for all port access are gone */
  229. port->closing = 1;
  230. snd_use_lock_sync(&port->use_lock);
  231. /* clear subscribers info */
  232. clear_subscriber_list(client, port, &port->c_src, SRC_LIST);
  233. clear_subscriber_list(client, port, &port->c_dest, DEST_LIST);
  234. if (port->private_free)
  235. port->private_free(port->private_data);
  236. snd_assert(port->c_src.count == 0,);
  237. snd_assert(port->c_dest.count == 0,);
  238. kfree(port);
  239. return 0;
  240. }
  241. /* delete a port with the given port id */
  242. int snd_seq_delete_port(struct snd_seq_client *client, int port)
  243. {
  244. unsigned long flags;
  245. struct snd_seq_client_port *found = NULL, *p;
  246. mutex_lock(&client->ports_mutex);
  247. write_lock_irqsave(&client->ports_lock, flags);
  248. list_for_each_entry(p, &client->ports_list_head, list) {
  249. if (p->addr.port == port) {
  250. /* ok found. delete from the list at first */
  251. list_del(&p->list);
  252. client->num_ports--;
  253. found = p;
  254. break;
  255. }
  256. }
  257. write_unlock_irqrestore(&client->ports_lock, flags);
  258. mutex_unlock(&client->ports_mutex);
  259. if (found)
  260. return port_delete(client, found);
  261. else
  262. return -ENOENT;
  263. }
  264. /* delete the all ports belonging to the given client */
  265. int snd_seq_delete_all_ports(struct snd_seq_client *client)
  266. {
  267. unsigned long flags;
  268. struct list_head deleted_list;
  269. struct snd_seq_client_port *port, *tmp;
  270. /* move the port list to deleted_list, and
  271. * clear the port list in the client data.
  272. */
  273. mutex_lock(&client->ports_mutex);
  274. write_lock_irqsave(&client->ports_lock, flags);
  275. if (! list_empty(&client->ports_list_head)) {
  276. list_add(&deleted_list, &client->ports_list_head);
  277. list_del_init(&client->ports_list_head);
  278. } else {
  279. INIT_LIST_HEAD(&deleted_list);
  280. }
  281. client->num_ports = 0;
  282. write_unlock_irqrestore(&client->ports_lock, flags);
  283. /* remove each port in deleted_list */
  284. list_for_each_entry_safe(port, tmp, &deleted_list, list) {
  285. list_del(&port->list);
  286. snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port);
  287. port_delete(client, port);
  288. }
  289. mutex_unlock(&client->ports_mutex);
  290. return 0;
  291. }
  292. /* set port info fields */
  293. int snd_seq_set_port_info(struct snd_seq_client_port * port,
  294. struct snd_seq_port_info * info)
  295. {
  296. snd_assert(port && info, return -EINVAL);
  297. /* set port name */
  298. if (info->name[0])
  299. strlcpy(port->name, info->name, sizeof(port->name));
  300. /* set capabilities */
  301. port->capability = info->capability;
  302. /* get port type */
  303. port->type = info->type;
  304. /* information about supported channels/voices */
  305. port->midi_channels = info->midi_channels;
  306. port->midi_voices = info->midi_voices;
  307. port->synth_voices = info->synth_voices;
  308. /* timestamping */
  309. port->timestamping = (info->flags & SNDRV_SEQ_PORT_FLG_TIMESTAMP) ? 1 : 0;
  310. port->time_real = (info->flags & SNDRV_SEQ_PORT_FLG_TIME_REAL) ? 1 : 0;
  311. port->time_queue = info->time_queue;
  312. return 0;
  313. }
  314. /* get port info fields */
  315. int snd_seq_get_port_info(struct snd_seq_client_port * port,
  316. struct snd_seq_port_info * info)
  317. {
  318. snd_assert(port && info, return -EINVAL);
  319. /* get port name */
  320. strlcpy(info->name, port->name, sizeof(info->name));
  321. /* get capabilities */
  322. info->capability = port->capability;
  323. /* get port type */
  324. info->type = port->type;
  325. /* information about supported channels/voices */
  326. info->midi_channels = port->midi_channels;
  327. info->midi_voices = port->midi_voices;
  328. info->synth_voices = port->synth_voices;
  329. /* get subscriber counts */
  330. info->read_use = port->c_src.count;
  331. info->write_use = port->c_dest.count;
  332. /* timestamping */
  333. info->flags = 0;
  334. if (port->timestamping) {
  335. info->flags |= SNDRV_SEQ_PORT_FLG_TIMESTAMP;
  336. if (port->time_real)
  337. info->flags |= SNDRV_SEQ_PORT_FLG_TIME_REAL;
  338. info->time_queue = port->time_queue;
  339. }
  340. return 0;
  341. }
  342. /*
  343. * call callback functions (if any):
  344. * the callbacks are invoked only when the first (for connection) or
  345. * the last subscription (for disconnection) is done. Second or later
  346. * subscription results in increment of counter, but no callback is
  347. * invoked.
  348. * This feature is useful if these callbacks are associated with
  349. * initialization or termination of devices (see seq_midi.c).
  350. *
  351. * If callback_all option is set, the callback function is invoked
  352. * at each connnection/disconnection.
  353. */
  354. static int subscribe_port(struct snd_seq_client *client,
  355. struct snd_seq_client_port *port,
  356. struct snd_seq_port_subs_info *grp,
  357. struct snd_seq_port_subscribe *info,
  358. int send_ack)
  359. {
  360. int err = 0;
  361. if (!try_module_get(port->owner))
  362. return -EFAULT;
  363. grp->count++;
  364. if (grp->open && (port->callback_all || grp->count == 1)) {
  365. err = grp->open(port->private_data, info);
  366. if (err < 0) {
  367. module_put(port->owner);
  368. grp->count--;
  369. }
  370. }
  371. if (err >= 0 && send_ack && client->type == USER_CLIENT)
  372. snd_seq_client_notify_subscription(port->addr.client, port->addr.port,
  373. info, SNDRV_SEQ_EVENT_PORT_SUBSCRIBED);
  374. return err;
  375. }
  376. static int unsubscribe_port(struct snd_seq_client *client,
  377. struct snd_seq_client_port *port,
  378. struct snd_seq_port_subs_info *grp,
  379. struct snd_seq_port_subscribe *info,
  380. int send_ack)
  381. {
  382. int err = 0;
  383. if (! grp->count)
  384. return -EINVAL;
  385. grp->count--;
  386. if (grp->close && (port->callback_all || grp->count == 0))
  387. err = grp->close(port->private_data, info);
  388. if (send_ack && client->type == USER_CLIENT)
  389. snd_seq_client_notify_subscription(port->addr.client, port->addr.port,
  390. info, SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED);
  391. module_put(port->owner);
  392. return err;
  393. }
  394. /* check if both addresses are identical */
  395. static inline int addr_match(struct snd_seq_addr *r, struct snd_seq_addr *s)
  396. {
  397. return (r->client == s->client) && (r->port == s->port);
  398. }
  399. /* check the two subscribe info match */
  400. /* if flags is zero, checks only sender and destination addresses */
  401. static int match_subs_info(struct snd_seq_port_subscribe *r,
  402. struct snd_seq_port_subscribe *s)
  403. {
  404. if (addr_match(&r->sender, &s->sender) &&
  405. addr_match(&r->dest, &s->dest)) {
  406. if (r->flags && r->flags == s->flags)
  407. return r->queue == s->queue;
  408. else if (! r->flags)
  409. return 1;
  410. }
  411. return 0;
  412. }
  413. /* connect two ports */
  414. int snd_seq_port_connect(struct snd_seq_client *connector,
  415. struct snd_seq_client *src_client,
  416. struct snd_seq_client_port *src_port,
  417. struct snd_seq_client *dest_client,
  418. struct snd_seq_client_port *dest_port,
  419. struct snd_seq_port_subscribe *info)
  420. {
  421. struct snd_seq_port_subs_info *src = &src_port->c_src;
  422. struct snd_seq_port_subs_info *dest = &dest_port->c_dest;
  423. struct snd_seq_subscribers *subs, *s;
  424. int err, src_called = 0;
  425. unsigned long flags;
  426. int exclusive;
  427. subs = kzalloc(sizeof(*subs), GFP_KERNEL);
  428. if (! subs)
  429. return -ENOMEM;
  430. subs->info = *info;
  431. atomic_set(&subs->ref_count, 2);
  432. down_write(&src->list_mutex);
  433. down_write_nested(&dest->list_mutex, SINGLE_DEPTH_NESTING);
  434. exclusive = info->flags & SNDRV_SEQ_PORT_SUBS_EXCLUSIVE ? 1 : 0;
  435. err = -EBUSY;
  436. if (exclusive) {
  437. if (! list_empty(&src->list_head) || ! list_empty(&dest->list_head))
  438. goto __error;
  439. } else {
  440. if (src->exclusive || dest->exclusive)
  441. goto __error;
  442. /* check whether already exists */
  443. list_for_each_entry(s, &src->list_head, src_list) {
  444. if (match_subs_info(info, &s->info))
  445. goto __error;
  446. }
  447. list_for_each_entry(s, &dest->list_head, dest_list) {
  448. if (match_subs_info(info, &s->info))
  449. goto __error;
  450. }
  451. }
  452. if ((err = subscribe_port(src_client, src_port, src, info,
  453. connector->number != src_client->number)) < 0)
  454. goto __error;
  455. src_called = 1;
  456. if ((err = subscribe_port(dest_client, dest_port, dest, info,
  457. connector->number != dest_client->number)) < 0)
  458. goto __error;
  459. /* add to list */
  460. write_lock_irqsave(&src->list_lock, flags);
  461. // write_lock(&dest->list_lock); // no other lock yet
  462. list_add_tail(&subs->src_list, &src->list_head);
  463. list_add_tail(&subs->dest_list, &dest->list_head);
  464. // write_unlock(&dest->list_lock); // no other lock yet
  465. write_unlock_irqrestore(&src->list_lock, flags);
  466. src->exclusive = dest->exclusive = exclusive;
  467. up_write(&dest->list_mutex);
  468. up_write(&src->list_mutex);
  469. return 0;
  470. __error:
  471. if (src_called)
  472. unsubscribe_port(src_client, src_port, src, info,
  473. connector->number != src_client->number);
  474. kfree(subs);
  475. up_write(&dest->list_mutex);
  476. up_write(&src->list_mutex);
  477. return err;
  478. }
  479. /* remove the connection */
  480. int snd_seq_port_disconnect(struct snd_seq_client *connector,
  481. struct snd_seq_client *src_client,
  482. struct snd_seq_client_port *src_port,
  483. struct snd_seq_client *dest_client,
  484. struct snd_seq_client_port *dest_port,
  485. struct snd_seq_port_subscribe *info)
  486. {
  487. struct snd_seq_port_subs_info *src = &src_port->c_src;
  488. struct snd_seq_port_subs_info *dest = &dest_port->c_dest;
  489. struct snd_seq_subscribers *subs;
  490. int err = -ENOENT;
  491. unsigned long flags;
  492. down_write(&src->list_mutex);
  493. down_write_nested(&dest->list_mutex, SINGLE_DEPTH_NESTING);
  494. /* look for the connection */
  495. list_for_each_entry(subs, &src->list_head, src_list) {
  496. if (match_subs_info(info, &subs->info)) {
  497. write_lock_irqsave(&src->list_lock, flags);
  498. // write_lock(&dest->list_lock); // no lock yet
  499. list_del(&subs->src_list);
  500. list_del(&subs->dest_list);
  501. // write_unlock(&dest->list_lock);
  502. write_unlock_irqrestore(&src->list_lock, flags);
  503. src->exclusive = dest->exclusive = 0;
  504. unsubscribe_port(src_client, src_port, src, info,
  505. connector->number != src_client->number);
  506. unsubscribe_port(dest_client, dest_port, dest, info,
  507. connector->number != dest_client->number);
  508. kfree(subs);
  509. err = 0;
  510. break;
  511. }
  512. }
  513. up_write(&dest->list_mutex);
  514. up_write(&src->list_mutex);
  515. return err;
  516. }
  517. /* get matched subscriber */
  518. struct snd_seq_subscribers *snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp,
  519. struct snd_seq_addr *dest_addr)
  520. {
  521. struct snd_seq_subscribers *s, *found = NULL;
  522. down_read(&src_grp->list_mutex);
  523. list_for_each_entry(s, &src_grp->list_head, src_list) {
  524. if (addr_match(dest_addr, &s->info.dest)) {
  525. found = s;
  526. break;
  527. }
  528. }
  529. up_read(&src_grp->list_mutex);
  530. return found;
  531. }
  532. /*
  533. * Attach a device driver that wants to receive events from the
  534. * sequencer. Returns the new port number on success.
  535. * A driver that wants to receive the events converted to midi, will
  536. * use snd_seq_midisynth_register_port().
  537. */
  538. /* exported */
  539. int snd_seq_event_port_attach(int client,
  540. struct snd_seq_port_callback *pcbp,
  541. int cap, int type, int midi_channels,
  542. int midi_voices, char *portname)
  543. {
  544. struct snd_seq_port_info portinfo;
  545. int ret;
  546. /* Set up the port */
  547. memset(&portinfo, 0, sizeof(portinfo));
  548. portinfo.addr.client = client;
  549. strlcpy(portinfo.name, portname ? portname : "Unamed port",
  550. sizeof(portinfo.name));
  551. portinfo.capability = cap;
  552. portinfo.type = type;
  553. portinfo.kernel = pcbp;
  554. portinfo.midi_channels = midi_channels;
  555. portinfo.midi_voices = midi_voices;
  556. /* Create it */
  557. ret = snd_seq_kernel_client_ctl(client,
  558. SNDRV_SEQ_IOCTL_CREATE_PORT,
  559. &portinfo);
  560. if (ret >= 0)
  561. ret = portinfo.addr.port;
  562. return ret;
  563. }
  564. EXPORT_SYMBOL(snd_seq_event_port_attach);
  565. /*
  566. * Detach the driver from a port.
  567. */
  568. /* exported */
  569. int snd_seq_event_port_detach(int client, int port)
  570. {
  571. struct snd_seq_port_info portinfo;
  572. int err;
  573. memset(&portinfo, 0, sizeof(portinfo));
  574. portinfo.addr.client = client;
  575. portinfo.addr.port = port;
  576. err = snd_seq_kernel_client_ctl(client,
  577. SNDRV_SEQ_IOCTL_DELETE_PORT,
  578. &portinfo);
  579. return err;
  580. }
  581. EXPORT_SYMBOL(snd_seq_event_port_detach);