seq_ports.c 18 KB

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