seq_instr.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. /*
  2. * Generic Instrument routines for ALSA sequencer
  3. * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. */
  20. #include <sound/driver.h>
  21. #include <linux/init.h>
  22. #include <linux/slab.h>
  23. #include <sound/core.h>
  24. #include "seq_clientmgr.h"
  25. #include <sound/seq_instr.h>
  26. #include <sound/initval.h>
  27. MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
  28. MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer instrument library.");
  29. MODULE_LICENSE("GPL");
  30. static void snd_instr_lock_ops(snd_seq_kinstr_list_t *list)
  31. {
  32. if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) {
  33. spin_lock_irqsave(&list->ops_lock, list->ops_flags);
  34. } else {
  35. down(&list->ops_mutex);
  36. }
  37. }
  38. static void snd_instr_unlock_ops(snd_seq_kinstr_list_t *list)
  39. {
  40. if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) {
  41. spin_unlock_irqrestore(&list->ops_lock, list->ops_flags);
  42. } else {
  43. up(&list->ops_mutex);
  44. }
  45. }
  46. static snd_seq_kinstr_t *snd_seq_instr_new(int add_len, int atomic)
  47. {
  48. snd_seq_kinstr_t *instr;
  49. instr = kcalloc(1, sizeof(snd_seq_kinstr_t) + add_len, atomic ? GFP_ATOMIC : GFP_KERNEL);
  50. if (instr == NULL)
  51. return NULL;
  52. instr->add_len = add_len;
  53. return instr;
  54. }
  55. static int snd_seq_instr_free(snd_seq_kinstr_t *instr, int atomic)
  56. {
  57. int result = 0;
  58. if (instr == NULL)
  59. return -EINVAL;
  60. if (instr->ops && instr->ops->remove)
  61. result = instr->ops->remove(instr->ops->private_data, instr, 1);
  62. if (!result)
  63. kfree(instr);
  64. return result;
  65. }
  66. snd_seq_kinstr_list_t *snd_seq_instr_list_new(void)
  67. {
  68. snd_seq_kinstr_list_t *list;
  69. list = kcalloc(1, sizeof(snd_seq_kinstr_list_t), GFP_KERNEL);
  70. if (list == NULL)
  71. return NULL;
  72. spin_lock_init(&list->lock);
  73. spin_lock_init(&list->ops_lock);
  74. init_MUTEX(&list->ops_mutex);
  75. list->owner = -1;
  76. return list;
  77. }
  78. void snd_seq_instr_list_free(snd_seq_kinstr_list_t **list_ptr)
  79. {
  80. snd_seq_kinstr_list_t *list;
  81. snd_seq_kinstr_t *instr;
  82. snd_seq_kcluster_t *cluster;
  83. int idx;
  84. unsigned long flags;
  85. if (list_ptr == NULL)
  86. return;
  87. list = *list_ptr;
  88. *list_ptr = NULL;
  89. if (list == NULL)
  90. return;
  91. for (idx = 0; idx < SNDRV_SEQ_INSTR_HASH_SIZE; idx++) {
  92. while ((instr = list->hash[idx]) != NULL) {
  93. list->hash[idx] = instr->next;
  94. list->count--;
  95. spin_lock_irqsave(&list->lock, flags);
  96. while (instr->use) {
  97. spin_unlock_irqrestore(&list->lock, flags);
  98. set_current_state(TASK_INTERRUPTIBLE);
  99. schedule_timeout(1);
  100. spin_lock_irqsave(&list->lock, flags);
  101. }
  102. spin_unlock_irqrestore(&list->lock, flags);
  103. if (snd_seq_instr_free(instr, 0)<0)
  104. snd_printk(KERN_WARNING "instrument free problem\n");
  105. }
  106. while ((cluster = list->chash[idx]) != NULL) {
  107. list->chash[idx] = cluster->next;
  108. list->ccount--;
  109. kfree(cluster);
  110. }
  111. }
  112. kfree(list);
  113. }
  114. static int instr_free_compare(snd_seq_kinstr_t *instr,
  115. snd_seq_instr_header_t *ifree,
  116. unsigned int client)
  117. {
  118. switch (ifree->cmd) {
  119. case SNDRV_SEQ_INSTR_FREE_CMD_ALL:
  120. /* all, except private for other clients */
  121. if ((instr->instr.std & 0xff000000) == 0)
  122. return 0;
  123. if (((instr->instr.std >> 24) & 0xff) == client)
  124. return 0;
  125. return 1;
  126. case SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE:
  127. /* all my private instruments */
  128. if ((instr->instr.std & 0xff000000) == 0)
  129. return 1;
  130. if (((instr->instr.std >> 24) & 0xff) == client)
  131. return 0;
  132. return 1;
  133. case SNDRV_SEQ_INSTR_FREE_CMD_CLUSTER:
  134. /* all my private instruments */
  135. if ((instr->instr.std & 0xff000000) == 0) {
  136. if (instr->instr.cluster == ifree->id.cluster)
  137. return 0;
  138. return 1;
  139. }
  140. if (((instr->instr.std >> 24) & 0xff) == client) {
  141. if (instr->instr.cluster == ifree->id.cluster)
  142. return 0;
  143. }
  144. return 1;
  145. }
  146. return 1;
  147. }
  148. int snd_seq_instr_list_free_cond(snd_seq_kinstr_list_t *list,
  149. snd_seq_instr_header_t *ifree,
  150. int client,
  151. int atomic)
  152. {
  153. snd_seq_kinstr_t *instr, *prev, *next, *flist;
  154. int idx;
  155. unsigned long flags;
  156. snd_instr_lock_ops(list);
  157. for (idx = 0; idx < SNDRV_SEQ_INSTR_HASH_SIZE; idx++) {
  158. spin_lock_irqsave(&list->lock, flags);
  159. instr = list->hash[idx];
  160. prev = flist = NULL;
  161. while (instr) {
  162. while (instr && instr_free_compare(instr, ifree, (unsigned int)client)) {
  163. prev = instr;
  164. instr = instr->next;
  165. }
  166. if (instr == NULL)
  167. continue;
  168. if (instr->ops && instr->ops->notify)
  169. instr->ops->notify(instr->ops->private_data, instr, SNDRV_SEQ_INSTR_NOTIFY_REMOVE);
  170. next = instr->next;
  171. if (prev == NULL) {
  172. list->hash[idx] = next;
  173. } else {
  174. prev->next = next;
  175. }
  176. list->count--;
  177. instr->next = flist;
  178. flist = instr;
  179. instr = next;
  180. }
  181. spin_unlock_irqrestore(&list->lock, flags);
  182. while (flist) {
  183. instr = flist;
  184. flist = instr->next;
  185. while (instr->use) {
  186. set_current_state(TASK_INTERRUPTIBLE);
  187. schedule_timeout(1);
  188. }
  189. if (snd_seq_instr_free(instr, atomic)<0)
  190. snd_printk(KERN_WARNING "instrument free problem\n");
  191. instr = next;
  192. }
  193. }
  194. snd_instr_unlock_ops(list);
  195. return 0;
  196. }
  197. static int compute_hash_instr_key(snd_seq_instr_t *instr)
  198. {
  199. int result;
  200. result = instr->bank | (instr->prg << 16);
  201. result += result >> 24;
  202. result += result >> 16;
  203. result += result >> 8;
  204. return result & (SNDRV_SEQ_INSTR_HASH_SIZE-1);
  205. }
  206. #if 0
  207. static int compute_hash_cluster_key(snd_seq_instr_cluster_t cluster)
  208. {
  209. int result;
  210. result = cluster;
  211. result += result >> 24;
  212. result += result >> 16;
  213. result += result >> 8;
  214. return result & (SNDRV_SEQ_INSTR_HASH_SIZE-1);
  215. }
  216. #endif
  217. static int compare_instr(snd_seq_instr_t *i1, snd_seq_instr_t *i2, int exact)
  218. {
  219. if (exact) {
  220. if (i1->cluster != i2->cluster ||
  221. i1->bank != i2->bank ||
  222. i1->prg != i2->prg)
  223. return 1;
  224. if ((i1->std & 0xff000000) != (i2->std & 0xff000000))
  225. return 1;
  226. if (!(i1->std & i2->std))
  227. return 1;
  228. return 0;
  229. } else {
  230. unsigned int client_check;
  231. if (i2->cluster && i1->cluster != i2->cluster)
  232. return 1;
  233. client_check = i2->std & 0xff000000;
  234. if (client_check) {
  235. if ((i1->std & 0xff000000) != client_check)
  236. return 1;
  237. } else {
  238. if ((i1->std & i2->std) != i2->std)
  239. return 1;
  240. }
  241. return i1->bank != i2->bank || i1->prg != i2->prg;
  242. }
  243. }
  244. snd_seq_kinstr_t *snd_seq_instr_find(snd_seq_kinstr_list_t *list,
  245. snd_seq_instr_t *instr,
  246. int exact,
  247. int follow_alias)
  248. {
  249. unsigned long flags;
  250. int depth = 0;
  251. snd_seq_kinstr_t *result;
  252. if (list == NULL || instr == NULL)
  253. return NULL;
  254. spin_lock_irqsave(&list->lock, flags);
  255. __again:
  256. result = list->hash[compute_hash_instr_key(instr)];
  257. while (result) {
  258. if (!compare_instr(&result->instr, instr, exact)) {
  259. if (follow_alias && (result->type == SNDRV_SEQ_INSTR_ATYPE_ALIAS)) {
  260. instr = (snd_seq_instr_t *)KINSTR_DATA(result);
  261. if (++depth > 10)
  262. goto __not_found;
  263. goto __again;
  264. }
  265. result->use++;
  266. spin_unlock_irqrestore(&list->lock, flags);
  267. return result;
  268. }
  269. result = result->next;
  270. }
  271. __not_found:
  272. spin_unlock_irqrestore(&list->lock, flags);
  273. return NULL;
  274. }
  275. void snd_seq_instr_free_use(snd_seq_kinstr_list_t *list,
  276. snd_seq_kinstr_t *instr)
  277. {
  278. unsigned long flags;
  279. if (list == NULL || instr == NULL)
  280. return;
  281. spin_lock_irqsave(&list->lock, flags);
  282. if (instr->use <= 0) {
  283. snd_printk(KERN_ERR "free_use: fatal!!! use = %i, name = '%s'\n", instr->use, instr->name);
  284. } else {
  285. instr->use--;
  286. }
  287. spin_unlock_irqrestore(&list->lock, flags);
  288. }
  289. static snd_seq_kinstr_ops_t *instr_ops(snd_seq_kinstr_ops_t *ops, char *instr_type)
  290. {
  291. while (ops) {
  292. if (!strcmp(ops->instr_type, instr_type))
  293. return ops;
  294. ops = ops->next;
  295. }
  296. return NULL;
  297. }
  298. static int instr_result(snd_seq_event_t *ev,
  299. int type, int result,
  300. int atomic)
  301. {
  302. snd_seq_event_t sev;
  303. memset(&sev, 0, sizeof(sev));
  304. sev.type = SNDRV_SEQ_EVENT_RESULT;
  305. sev.flags = SNDRV_SEQ_TIME_STAMP_REAL | SNDRV_SEQ_EVENT_LENGTH_FIXED |
  306. SNDRV_SEQ_PRIORITY_NORMAL;
  307. sev.source = ev->dest;
  308. sev.dest = ev->source;
  309. sev.data.result.event = type;
  310. sev.data.result.result = result;
  311. #if 0
  312. printk("instr result - type = %i, result = %i, queue = %i, source.client:port = %i:%i, dest.client:port = %i:%i\n",
  313. type, result,
  314. sev.queue,
  315. sev.source.client, sev.source.port,
  316. sev.dest.client, sev.dest.port);
  317. #endif
  318. return snd_seq_kernel_client_dispatch(sev.source.client, &sev, atomic, 0);
  319. }
  320. static int instr_begin(snd_seq_kinstr_ops_t *ops,
  321. snd_seq_kinstr_list_t *list,
  322. snd_seq_event_t *ev,
  323. int atomic, int hop)
  324. {
  325. unsigned long flags;
  326. spin_lock_irqsave(&list->lock, flags);
  327. if (list->owner >= 0 && list->owner != ev->source.client) {
  328. spin_unlock_irqrestore(&list->lock, flags);
  329. return instr_result(ev, SNDRV_SEQ_EVENT_INSTR_BEGIN, -EBUSY, atomic);
  330. }
  331. list->owner = ev->source.client;
  332. spin_unlock_irqrestore(&list->lock, flags);
  333. return instr_result(ev, SNDRV_SEQ_EVENT_INSTR_BEGIN, 0, atomic);
  334. }
  335. static int instr_end(snd_seq_kinstr_ops_t *ops,
  336. snd_seq_kinstr_list_t *list,
  337. snd_seq_event_t *ev,
  338. int atomic, int hop)
  339. {
  340. unsigned long flags;
  341. /* TODO: timeout handling */
  342. spin_lock_irqsave(&list->lock, flags);
  343. if (list->owner == ev->source.client) {
  344. list->owner = -1;
  345. spin_unlock_irqrestore(&list->lock, flags);
  346. return instr_result(ev, SNDRV_SEQ_EVENT_INSTR_END, 0, atomic);
  347. }
  348. spin_unlock_irqrestore(&list->lock, flags);
  349. return instr_result(ev, SNDRV_SEQ_EVENT_INSTR_END, -EINVAL, atomic);
  350. }
  351. static int instr_info(snd_seq_kinstr_ops_t *ops,
  352. snd_seq_kinstr_list_t *list,
  353. snd_seq_event_t *ev,
  354. int atomic, int hop)
  355. {
  356. return -ENXIO;
  357. }
  358. static int instr_format_info(snd_seq_kinstr_ops_t *ops,
  359. snd_seq_kinstr_list_t *list,
  360. snd_seq_event_t *ev,
  361. int atomic, int hop)
  362. {
  363. return -ENXIO;
  364. }
  365. static int instr_reset(snd_seq_kinstr_ops_t *ops,
  366. snd_seq_kinstr_list_t *list,
  367. snd_seq_event_t *ev,
  368. int atomic, int hop)
  369. {
  370. return -ENXIO;
  371. }
  372. static int instr_status(snd_seq_kinstr_ops_t *ops,
  373. snd_seq_kinstr_list_t *list,
  374. snd_seq_event_t *ev,
  375. int atomic, int hop)
  376. {
  377. return -ENXIO;
  378. }
  379. static int instr_put(snd_seq_kinstr_ops_t *ops,
  380. snd_seq_kinstr_list_t *list,
  381. snd_seq_event_t *ev,
  382. int atomic, int hop)
  383. {
  384. unsigned long flags;
  385. snd_seq_instr_header_t put;
  386. snd_seq_kinstr_t *instr;
  387. int result = -EINVAL, len, key;
  388. if ((ev->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) != SNDRV_SEQ_EVENT_LENGTH_VARUSR)
  389. goto __return;
  390. if (ev->data.ext.len < sizeof(snd_seq_instr_header_t))
  391. goto __return;
  392. if (copy_from_user(&put, (void __user *)ev->data.ext.ptr, sizeof(snd_seq_instr_header_t))) {
  393. result = -EFAULT;
  394. goto __return;
  395. }
  396. snd_instr_lock_ops(list);
  397. if (put.id.instr.std & 0xff000000) { /* private instrument */
  398. put.id.instr.std &= 0x00ffffff;
  399. put.id.instr.std |= (unsigned int)ev->source.client << 24;
  400. }
  401. if ((instr = snd_seq_instr_find(list, &put.id.instr, 1, 0))) {
  402. snd_seq_instr_free_use(list, instr);
  403. snd_instr_unlock_ops(list);
  404. result = -EBUSY;
  405. goto __return;
  406. }
  407. ops = instr_ops(ops, put.data.data.format);
  408. if (ops == NULL) {
  409. snd_instr_unlock_ops(list);
  410. goto __return;
  411. }
  412. len = ops->add_len;
  413. if (put.data.type == SNDRV_SEQ_INSTR_ATYPE_ALIAS)
  414. len = sizeof(snd_seq_instr_t);
  415. instr = snd_seq_instr_new(len, atomic);
  416. if (instr == NULL) {
  417. snd_instr_unlock_ops(list);
  418. result = -ENOMEM;
  419. goto __return;
  420. }
  421. instr->ops = ops;
  422. instr->instr = put.id.instr;
  423. strlcpy(instr->name, put.data.name, sizeof(instr->name));
  424. instr->type = put.data.type;
  425. if (instr->type == SNDRV_SEQ_INSTR_ATYPE_DATA) {
  426. result = ops->put(ops->private_data,
  427. instr,
  428. (void __user *)ev->data.ext.ptr + sizeof(snd_seq_instr_header_t),
  429. ev->data.ext.len - sizeof(snd_seq_instr_header_t),
  430. atomic,
  431. put.cmd);
  432. if (result < 0) {
  433. snd_seq_instr_free(instr, atomic);
  434. snd_instr_unlock_ops(list);
  435. goto __return;
  436. }
  437. }
  438. key = compute_hash_instr_key(&instr->instr);
  439. spin_lock_irqsave(&list->lock, flags);
  440. instr->next = list->hash[key];
  441. list->hash[key] = instr;
  442. list->count++;
  443. spin_unlock_irqrestore(&list->lock, flags);
  444. snd_instr_unlock_ops(list);
  445. result = 0;
  446. __return:
  447. instr_result(ev, SNDRV_SEQ_EVENT_INSTR_PUT, result, atomic);
  448. return result;
  449. }
  450. static int instr_get(snd_seq_kinstr_ops_t *ops,
  451. snd_seq_kinstr_list_t *list,
  452. snd_seq_event_t *ev,
  453. int atomic, int hop)
  454. {
  455. return -ENXIO;
  456. }
  457. static int instr_free(snd_seq_kinstr_ops_t *ops,
  458. snd_seq_kinstr_list_t *list,
  459. snd_seq_event_t *ev,
  460. int atomic, int hop)
  461. {
  462. snd_seq_instr_header_t ifree;
  463. snd_seq_kinstr_t *instr, *prev;
  464. int result = -EINVAL;
  465. unsigned long flags;
  466. unsigned int hash;
  467. if ((ev->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) != SNDRV_SEQ_EVENT_LENGTH_VARUSR)
  468. goto __return;
  469. if (ev->data.ext.len < sizeof(snd_seq_instr_header_t))
  470. goto __return;
  471. if (copy_from_user(&ifree, (void __user *)ev->data.ext.ptr, sizeof(snd_seq_instr_header_t))) {
  472. result = -EFAULT;
  473. goto __return;
  474. }
  475. if (ifree.cmd == SNDRV_SEQ_INSTR_FREE_CMD_ALL ||
  476. ifree.cmd == SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE ||
  477. ifree.cmd == SNDRV_SEQ_INSTR_FREE_CMD_CLUSTER) {
  478. result = snd_seq_instr_list_free_cond(list, &ifree, ev->dest.client, atomic);
  479. goto __return;
  480. }
  481. if (ifree.cmd == SNDRV_SEQ_INSTR_FREE_CMD_SINGLE) {
  482. if (ifree.id.instr.std & 0xff000000) {
  483. ifree.id.instr.std &= 0x00ffffff;
  484. ifree.id.instr.std |= (unsigned int)ev->source.client << 24;
  485. }
  486. hash = compute_hash_instr_key(&ifree.id.instr);
  487. snd_instr_lock_ops(list);
  488. spin_lock_irqsave(&list->lock, flags);
  489. instr = list->hash[hash];
  490. prev = NULL;
  491. while (instr) {
  492. if (!compare_instr(&instr->instr, &ifree.id.instr, 1))
  493. goto __free_single;
  494. prev = instr;
  495. instr = instr->next;
  496. }
  497. result = -ENOENT;
  498. spin_unlock_irqrestore(&list->lock, flags);
  499. snd_instr_unlock_ops(list);
  500. goto __return;
  501. __free_single:
  502. if (prev) {
  503. prev->next = instr->next;
  504. } else {
  505. list->hash[hash] = instr->next;
  506. }
  507. if (instr->ops && instr->ops->notify)
  508. instr->ops->notify(instr->ops->private_data, instr, SNDRV_SEQ_INSTR_NOTIFY_REMOVE);
  509. while (instr->use) {
  510. spin_unlock_irqrestore(&list->lock, flags);
  511. set_current_state(TASK_INTERRUPTIBLE);
  512. schedule_timeout(1);
  513. spin_lock_irqsave(&list->lock, flags);
  514. }
  515. spin_unlock_irqrestore(&list->lock, flags);
  516. result = snd_seq_instr_free(instr, atomic);
  517. snd_instr_unlock_ops(list);
  518. goto __return;
  519. }
  520. __return:
  521. instr_result(ev, SNDRV_SEQ_EVENT_INSTR_FREE, result, atomic);
  522. return result;
  523. }
  524. static int instr_list(snd_seq_kinstr_ops_t *ops,
  525. snd_seq_kinstr_list_t *list,
  526. snd_seq_event_t *ev,
  527. int atomic, int hop)
  528. {
  529. return -ENXIO;
  530. }
  531. static int instr_cluster(snd_seq_kinstr_ops_t *ops,
  532. snd_seq_kinstr_list_t *list,
  533. snd_seq_event_t *ev,
  534. int atomic, int hop)
  535. {
  536. return -ENXIO;
  537. }
  538. int snd_seq_instr_event(snd_seq_kinstr_ops_t *ops,
  539. snd_seq_kinstr_list_t *list,
  540. snd_seq_event_t *ev,
  541. int client,
  542. int atomic,
  543. int hop)
  544. {
  545. int direct = 0;
  546. snd_assert(ops != NULL && list != NULL && ev != NULL, return -EINVAL);
  547. if (snd_seq_ev_is_direct(ev)) {
  548. direct = 1;
  549. switch (ev->type) {
  550. case SNDRV_SEQ_EVENT_INSTR_BEGIN:
  551. return instr_begin(ops, list, ev, atomic, hop);
  552. case SNDRV_SEQ_EVENT_INSTR_END:
  553. return instr_end(ops, list, ev, atomic, hop);
  554. }
  555. }
  556. if ((list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT) && !direct)
  557. return -EINVAL;
  558. switch (ev->type) {
  559. case SNDRV_SEQ_EVENT_INSTR_INFO:
  560. return instr_info(ops, list, ev, atomic, hop);
  561. case SNDRV_SEQ_EVENT_INSTR_FINFO:
  562. return instr_format_info(ops, list, ev, atomic, hop);
  563. case SNDRV_SEQ_EVENT_INSTR_RESET:
  564. return instr_reset(ops, list, ev, atomic, hop);
  565. case SNDRV_SEQ_EVENT_INSTR_STATUS:
  566. return instr_status(ops, list, ev, atomic, hop);
  567. case SNDRV_SEQ_EVENT_INSTR_PUT:
  568. return instr_put(ops, list, ev, atomic, hop);
  569. case SNDRV_SEQ_EVENT_INSTR_GET:
  570. return instr_get(ops, list, ev, atomic, hop);
  571. case SNDRV_SEQ_EVENT_INSTR_FREE:
  572. return instr_free(ops, list, ev, atomic, hop);
  573. case SNDRV_SEQ_EVENT_INSTR_LIST:
  574. return instr_list(ops, list, ev, atomic, hop);
  575. case SNDRV_SEQ_EVENT_INSTR_CLUSTER:
  576. return instr_cluster(ops, list, ev, atomic, hop);
  577. }
  578. return -EINVAL;
  579. }
  580. /*
  581. * Init part
  582. */
  583. static int __init alsa_seq_instr_init(void)
  584. {
  585. return 0;
  586. }
  587. static void __exit alsa_seq_instr_exit(void)
  588. {
  589. }
  590. module_init(alsa_seq_instr_init)
  591. module_exit(alsa_seq_instr_exit)
  592. EXPORT_SYMBOL(snd_seq_instr_list_new);
  593. EXPORT_SYMBOL(snd_seq_instr_list_free);
  594. EXPORT_SYMBOL(snd_seq_instr_list_free_cond);
  595. EXPORT_SYMBOL(snd_seq_instr_find);
  596. EXPORT_SYMBOL(snd_seq_instr_free_use);
  597. EXPORT_SYMBOL(snd_seq_instr_event);