pcm.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Line 6 Linux USB driver
  4. *
  5. * Copyright (C) 2004-2010 Markus Grabner ([email protected])
  6. */
  7. #include <linux/slab.h>
  8. #include <linux/export.h>
  9. #include <sound/core.h>
  10. #include <sound/control.h>
  11. #include <sound/pcm.h>
  12. #include <sound/pcm_params.h>
  13. #include "capture.h"
  14. #include "driver.h"
  15. #include "playback.h"
  16. /* impulse response volume controls */
  17. static int snd_line6_impulse_volume_info(struct snd_kcontrol *kcontrol,
  18. struct snd_ctl_elem_info *uinfo)
  19. {
  20. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  21. uinfo->count = 1;
  22. uinfo->value.integer.min = 0;
  23. uinfo->value.integer.max = 255;
  24. return 0;
  25. }
  26. static int snd_line6_impulse_volume_get(struct snd_kcontrol *kcontrol,
  27. struct snd_ctl_elem_value *ucontrol)
  28. {
  29. struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
  30. ucontrol->value.integer.value[0] = line6pcm->impulse_volume;
  31. return 0;
  32. }
  33. static int snd_line6_impulse_volume_put(struct snd_kcontrol *kcontrol,
  34. struct snd_ctl_elem_value *ucontrol)
  35. {
  36. struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
  37. int value = ucontrol->value.integer.value[0];
  38. int err;
  39. if (line6pcm->impulse_volume == value)
  40. return 0;
  41. line6pcm->impulse_volume = value;
  42. if (value > 0) {
  43. err = line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE, true);
  44. if (err < 0) {
  45. line6pcm->impulse_volume = 0;
  46. return err;
  47. }
  48. } else {
  49. line6_pcm_release(line6pcm, LINE6_STREAM_IMPULSE);
  50. }
  51. return 1;
  52. }
  53. /* impulse response period controls */
  54. static int snd_line6_impulse_period_info(struct snd_kcontrol *kcontrol,
  55. struct snd_ctl_elem_info *uinfo)
  56. {
  57. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  58. uinfo->count = 1;
  59. uinfo->value.integer.min = 0;
  60. uinfo->value.integer.max = 2000;
  61. return 0;
  62. }
  63. static int snd_line6_impulse_period_get(struct snd_kcontrol *kcontrol,
  64. struct snd_ctl_elem_value *ucontrol)
  65. {
  66. struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
  67. ucontrol->value.integer.value[0] = line6pcm->impulse_period;
  68. return 0;
  69. }
  70. static int snd_line6_impulse_period_put(struct snd_kcontrol *kcontrol,
  71. struct snd_ctl_elem_value *ucontrol)
  72. {
  73. struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
  74. int value = ucontrol->value.integer.value[0];
  75. if (line6pcm->impulse_period == value)
  76. return 0;
  77. line6pcm->impulse_period = value;
  78. return 1;
  79. }
  80. /*
  81. Unlink all currently active URBs.
  82. */
  83. static void line6_unlink_audio_urbs(struct snd_line6_pcm *line6pcm,
  84. struct line6_pcm_stream *pcms)
  85. {
  86. int i;
  87. for (i = 0; i < line6pcm->line6->iso_buffers; i++) {
  88. if (test_bit(i, &pcms->active_urbs)) {
  89. if (!test_and_set_bit(i, &pcms->unlink_urbs))
  90. usb_unlink_urb(pcms->urbs[i]);
  91. }
  92. }
  93. }
  94. /*
  95. Wait until unlinking of all currently active URBs has been finished.
  96. */
  97. static void line6_wait_clear_audio_urbs(struct snd_line6_pcm *line6pcm,
  98. struct line6_pcm_stream *pcms)
  99. {
  100. int timeout = HZ;
  101. int i;
  102. int alive;
  103. do {
  104. alive = 0;
  105. for (i = 0; i < line6pcm->line6->iso_buffers; i++) {
  106. if (test_bit(i, &pcms->active_urbs))
  107. alive++;
  108. }
  109. if (!alive)
  110. break;
  111. set_current_state(TASK_UNINTERRUPTIBLE);
  112. schedule_timeout(1);
  113. } while (--timeout > 0);
  114. if (alive)
  115. dev_err(line6pcm->line6->ifcdev,
  116. "timeout: still %d active urbs..\n", alive);
  117. }
  118. static inline struct line6_pcm_stream *
  119. get_stream(struct snd_line6_pcm *line6pcm, int direction)
  120. {
  121. return (direction == SNDRV_PCM_STREAM_PLAYBACK) ?
  122. &line6pcm->out : &line6pcm->in;
  123. }
  124. /* allocate a buffer if not opened yet;
  125. * call this in line6pcm.state_mutex
  126. */
  127. static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,
  128. struct line6_pcm_stream *pstr, int direction, int type)
  129. {
  130. const int pkt_size =
  131. (direction == SNDRV_PCM_STREAM_PLAYBACK) ?
  132. line6pcm->max_packet_size_out :
  133. line6pcm->max_packet_size_in;
  134. /* Invoked multiple times in a row so allocate once only */
  135. if (!test_and_set_bit(type, &pstr->opened) && !pstr->buffer) {
  136. pstr->buffer =
  137. kmalloc(array3_size(line6pcm->line6->iso_buffers,
  138. LINE6_ISO_PACKETS, pkt_size),
  139. GFP_KERNEL);
  140. if (!pstr->buffer)
  141. return -ENOMEM;
  142. }
  143. return 0;
  144. }
  145. /* free a buffer if all streams are closed;
  146. * call this in line6pcm.state_mutex
  147. */
  148. static void line6_buffer_release(struct snd_line6_pcm *line6pcm,
  149. struct line6_pcm_stream *pstr, int type)
  150. {
  151. clear_bit(type, &pstr->opened);
  152. if (!pstr->opened) {
  153. line6_wait_clear_audio_urbs(line6pcm, pstr);
  154. kfree(pstr->buffer);
  155. pstr->buffer = NULL;
  156. }
  157. }
  158. /* start a PCM stream */
  159. static int line6_stream_start(struct snd_line6_pcm *line6pcm, int direction,
  160. int type)
  161. {
  162. unsigned long flags;
  163. struct line6_pcm_stream *pstr = get_stream(line6pcm, direction);
  164. int ret = 0;
  165. spin_lock_irqsave(&pstr->lock, flags);
  166. if (!test_and_set_bit(type, &pstr->running) &&
  167. !(pstr->active_urbs || pstr->unlink_urbs)) {
  168. pstr->count = 0;
  169. /* Submit all currently available URBs */
  170. if (direction == SNDRV_PCM_STREAM_PLAYBACK)
  171. ret = line6_submit_audio_out_all_urbs(line6pcm);
  172. else
  173. ret = line6_submit_audio_in_all_urbs(line6pcm);
  174. }
  175. if (ret < 0)
  176. clear_bit(type, &pstr->running);
  177. spin_unlock_irqrestore(&pstr->lock, flags);
  178. return ret;
  179. }
  180. /* stop a PCM stream; this doesn't sync with the unlinked URBs */
  181. static void line6_stream_stop(struct snd_line6_pcm *line6pcm, int direction,
  182. int type)
  183. {
  184. unsigned long flags;
  185. struct line6_pcm_stream *pstr = get_stream(line6pcm, direction);
  186. spin_lock_irqsave(&pstr->lock, flags);
  187. clear_bit(type, &pstr->running);
  188. if (!pstr->running) {
  189. spin_unlock_irqrestore(&pstr->lock, flags);
  190. line6_unlink_audio_urbs(line6pcm, pstr);
  191. spin_lock_irqsave(&pstr->lock, flags);
  192. if (direction == SNDRV_PCM_STREAM_CAPTURE) {
  193. line6pcm->prev_fbuf = NULL;
  194. line6pcm->prev_fsize = 0;
  195. }
  196. }
  197. spin_unlock_irqrestore(&pstr->lock, flags);
  198. }
  199. /* common PCM trigger callback */
  200. int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)
  201. {
  202. struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
  203. struct snd_pcm_substream *s;
  204. int err;
  205. clear_bit(LINE6_FLAG_PREPARED, &line6pcm->flags);
  206. snd_pcm_group_for_each_entry(s, substream) {
  207. if (s->pcm->card != substream->pcm->card)
  208. continue;
  209. switch (cmd) {
  210. case SNDRV_PCM_TRIGGER_START:
  211. case SNDRV_PCM_TRIGGER_RESUME:
  212. if (s->stream == SNDRV_PCM_STREAM_CAPTURE &&
  213. (line6pcm->line6->properties->capabilities &
  214. LINE6_CAP_IN_NEEDS_OUT)) {
  215. err = line6_stream_start(line6pcm, SNDRV_PCM_STREAM_PLAYBACK,
  216. LINE6_STREAM_CAPTURE_HELPER);
  217. if (err < 0)
  218. return err;
  219. }
  220. err = line6_stream_start(line6pcm, s->stream,
  221. LINE6_STREAM_PCM);
  222. if (err < 0)
  223. return err;
  224. break;
  225. case SNDRV_PCM_TRIGGER_STOP:
  226. case SNDRV_PCM_TRIGGER_SUSPEND:
  227. if (s->stream == SNDRV_PCM_STREAM_CAPTURE &&
  228. (line6pcm->line6->properties->capabilities &
  229. LINE6_CAP_IN_NEEDS_OUT)) {
  230. line6_stream_stop(line6pcm, SNDRV_PCM_STREAM_PLAYBACK,
  231. LINE6_STREAM_CAPTURE_HELPER);
  232. }
  233. line6_stream_stop(line6pcm, s->stream,
  234. LINE6_STREAM_PCM);
  235. break;
  236. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  237. if (s->stream != SNDRV_PCM_STREAM_PLAYBACK)
  238. return -EINVAL;
  239. set_bit(LINE6_FLAG_PAUSE_PLAYBACK, &line6pcm->flags);
  240. break;
  241. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  242. if (s->stream != SNDRV_PCM_STREAM_PLAYBACK)
  243. return -EINVAL;
  244. clear_bit(LINE6_FLAG_PAUSE_PLAYBACK, &line6pcm->flags);
  245. break;
  246. default:
  247. return -EINVAL;
  248. }
  249. }
  250. return 0;
  251. }
  252. /* common PCM pointer callback */
  253. snd_pcm_uframes_t snd_line6_pointer(struct snd_pcm_substream *substream)
  254. {
  255. struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
  256. struct line6_pcm_stream *pstr = get_stream(line6pcm, substream->stream);
  257. return pstr->pos_done;
  258. }
  259. /* Acquire and optionally start duplex streams:
  260. * type is either LINE6_STREAM_IMPULSE or LINE6_STREAM_MONITOR
  261. */
  262. int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int type, bool start)
  263. {
  264. struct line6_pcm_stream *pstr;
  265. int ret = 0, dir;
  266. /* TODO: We should assert SNDRV_PCM_STREAM_PLAYBACK/CAPTURE == 0/1 */
  267. mutex_lock(&line6pcm->state_mutex);
  268. for (dir = 0; dir < 2; dir++) {
  269. pstr = get_stream(line6pcm, dir);
  270. ret = line6_buffer_acquire(line6pcm, pstr, dir, type);
  271. if (ret < 0)
  272. goto error;
  273. if (!pstr->running)
  274. line6_wait_clear_audio_urbs(line6pcm, pstr);
  275. }
  276. if (start) {
  277. for (dir = 0; dir < 2; dir++) {
  278. ret = line6_stream_start(line6pcm, dir, type);
  279. if (ret < 0)
  280. goto error;
  281. }
  282. }
  283. error:
  284. mutex_unlock(&line6pcm->state_mutex);
  285. if (ret < 0)
  286. line6_pcm_release(line6pcm, type);
  287. return ret;
  288. }
  289. EXPORT_SYMBOL_GPL(line6_pcm_acquire);
  290. /* Stop and release duplex streams */
  291. void line6_pcm_release(struct snd_line6_pcm *line6pcm, int type)
  292. {
  293. struct line6_pcm_stream *pstr;
  294. int dir;
  295. mutex_lock(&line6pcm->state_mutex);
  296. for (dir = 0; dir < 2; dir++)
  297. line6_stream_stop(line6pcm, dir, type);
  298. for (dir = 0; dir < 2; dir++) {
  299. pstr = get_stream(line6pcm, dir);
  300. line6_buffer_release(line6pcm, pstr, type);
  301. }
  302. mutex_unlock(&line6pcm->state_mutex);
  303. }
  304. EXPORT_SYMBOL_GPL(line6_pcm_release);
  305. /* common PCM hw_params callback */
  306. int snd_line6_hw_params(struct snd_pcm_substream *substream,
  307. struct snd_pcm_hw_params *hw_params)
  308. {
  309. int ret;
  310. struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
  311. struct line6_pcm_stream *pstr = get_stream(line6pcm, substream->stream);
  312. mutex_lock(&line6pcm->state_mutex);
  313. ret = line6_buffer_acquire(line6pcm, pstr, substream->stream,
  314. LINE6_STREAM_PCM);
  315. if (ret < 0)
  316. goto error;
  317. pstr->period = params_period_bytes(hw_params);
  318. error:
  319. mutex_unlock(&line6pcm->state_mutex);
  320. return ret;
  321. }
  322. /* common PCM hw_free callback */
  323. int snd_line6_hw_free(struct snd_pcm_substream *substream)
  324. {
  325. struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
  326. struct line6_pcm_stream *pstr = get_stream(line6pcm, substream->stream);
  327. mutex_lock(&line6pcm->state_mutex);
  328. line6_buffer_release(line6pcm, pstr, LINE6_STREAM_PCM);
  329. mutex_unlock(&line6pcm->state_mutex);
  330. return 0;
  331. }
  332. /* control info callback */
  333. static int snd_line6_control_playback_info(struct snd_kcontrol *kcontrol,
  334. struct snd_ctl_elem_info *uinfo)
  335. {
  336. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  337. uinfo->count = 2;
  338. uinfo->value.integer.min = 0;
  339. uinfo->value.integer.max = 256;
  340. return 0;
  341. }
  342. /* control get callback */
  343. static int snd_line6_control_playback_get(struct snd_kcontrol *kcontrol,
  344. struct snd_ctl_elem_value *ucontrol)
  345. {
  346. int i;
  347. struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
  348. for (i = 0; i < 2; i++)
  349. ucontrol->value.integer.value[i] = line6pcm->volume_playback[i];
  350. return 0;
  351. }
  352. /* control put callback */
  353. static int snd_line6_control_playback_put(struct snd_kcontrol *kcontrol,
  354. struct snd_ctl_elem_value *ucontrol)
  355. {
  356. int i, changed = 0;
  357. struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
  358. for (i = 0; i < 2; i++)
  359. if (line6pcm->volume_playback[i] !=
  360. ucontrol->value.integer.value[i]) {
  361. line6pcm->volume_playback[i] =
  362. ucontrol->value.integer.value[i];
  363. changed = 1;
  364. }
  365. return changed;
  366. }
  367. /* control definition */
  368. static const struct snd_kcontrol_new line6_controls[] = {
  369. {
  370. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  371. .name = "PCM Playback Volume",
  372. .info = snd_line6_control_playback_info,
  373. .get = snd_line6_control_playback_get,
  374. .put = snd_line6_control_playback_put
  375. },
  376. {
  377. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  378. .name = "Impulse Response Volume",
  379. .info = snd_line6_impulse_volume_info,
  380. .get = snd_line6_impulse_volume_get,
  381. .put = snd_line6_impulse_volume_put
  382. },
  383. {
  384. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  385. .name = "Impulse Response Period",
  386. .info = snd_line6_impulse_period_info,
  387. .get = snd_line6_impulse_period_get,
  388. .put = snd_line6_impulse_period_put
  389. },
  390. };
  391. /*
  392. Cleanup the PCM device.
  393. */
  394. static void cleanup_urbs(struct line6_pcm_stream *pcms, int iso_buffers)
  395. {
  396. int i;
  397. /* Most likely impossible in current code... */
  398. if (pcms->urbs == NULL)
  399. return;
  400. for (i = 0; i < iso_buffers; i++) {
  401. if (pcms->urbs[i]) {
  402. usb_kill_urb(pcms->urbs[i]);
  403. usb_free_urb(pcms->urbs[i]);
  404. }
  405. }
  406. kfree(pcms->urbs);
  407. pcms->urbs = NULL;
  408. }
  409. static void line6_cleanup_pcm(struct snd_pcm *pcm)
  410. {
  411. struct snd_line6_pcm *line6pcm = snd_pcm_chip(pcm);
  412. cleanup_urbs(&line6pcm->out, line6pcm->line6->iso_buffers);
  413. cleanup_urbs(&line6pcm->in, line6pcm->line6->iso_buffers);
  414. kfree(line6pcm);
  415. }
  416. /* create a PCM device */
  417. static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret)
  418. {
  419. struct snd_pcm *pcm;
  420. int err;
  421. err = snd_pcm_new(line6->card, (char *)line6->properties->name,
  422. 0, 1, 1, pcm_ret);
  423. if (err < 0)
  424. return err;
  425. pcm = *pcm_ret;
  426. strcpy(pcm->name, line6->properties->name);
  427. /* set operators */
  428. snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
  429. &snd_line6_playback_ops);
  430. snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_line6_capture_ops);
  431. /* pre-allocation of buffers */
  432. snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
  433. NULL, 64 * 1024, 128 * 1024);
  434. return 0;
  435. }
  436. /*
  437. Sync with PCM stream stops.
  438. */
  439. void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm)
  440. {
  441. line6_unlink_audio_urbs(line6pcm, &line6pcm->out);
  442. line6_unlink_audio_urbs(line6pcm, &line6pcm->in);
  443. line6_wait_clear_audio_urbs(line6pcm, &line6pcm->out);
  444. line6_wait_clear_audio_urbs(line6pcm, &line6pcm->in);
  445. }
  446. /*
  447. Create and register the PCM device and mixer entries.
  448. Create URBs for playback and capture.
  449. */
  450. int line6_init_pcm(struct usb_line6 *line6,
  451. struct line6_pcm_properties *properties)
  452. {
  453. int i, err;
  454. unsigned ep_read = line6->properties->ep_audio_r;
  455. unsigned ep_write = line6->properties->ep_audio_w;
  456. struct snd_pcm *pcm;
  457. struct snd_line6_pcm *line6pcm;
  458. if (!(line6->properties->capabilities & LINE6_CAP_PCM))
  459. return 0; /* skip PCM initialization and report success */
  460. err = snd_line6_new_pcm(line6, &pcm);
  461. if (err < 0)
  462. return err;
  463. line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL);
  464. if (!line6pcm)
  465. return -ENOMEM;
  466. mutex_init(&line6pcm->state_mutex);
  467. line6pcm->pcm = pcm;
  468. line6pcm->properties = properties;
  469. line6pcm->volume_playback[0] = line6pcm->volume_playback[1] = 255;
  470. line6pcm->volume_monitor = 255;
  471. line6pcm->line6 = line6;
  472. spin_lock_init(&line6pcm->out.lock);
  473. spin_lock_init(&line6pcm->in.lock);
  474. line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD;
  475. line6->line6pcm = line6pcm;
  476. pcm->private_data = line6pcm;
  477. pcm->private_free = line6_cleanup_pcm;
  478. line6pcm->max_packet_size_in =
  479. usb_maxpacket(line6->usbdev,
  480. usb_rcvisocpipe(line6->usbdev, ep_read));
  481. line6pcm->max_packet_size_out =
  482. usb_maxpacket(line6->usbdev,
  483. usb_sndisocpipe(line6->usbdev, ep_write));
  484. if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) {
  485. dev_err(line6pcm->line6->ifcdev,
  486. "cannot get proper max packet size\n");
  487. return -EINVAL;
  488. }
  489. err = line6_create_audio_out_urbs(line6pcm);
  490. if (err < 0)
  491. return err;
  492. err = line6_create_audio_in_urbs(line6pcm);
  493. if (err < 0)
  494. return err;
  495. /* mixer: */
  496. for (i = 0; i < ARRAY_SIZE(line6_controls); i++) {
  497. err = snd_ctl_add(line6->card,
  498. snd_ctl_new1(&line6_controls[i], line6pcm));
  499. if (err < 0)
  500. return err;
  501. }
  502. return 0;
  503. }
  504. EXPORT_SYMBOL_GPL(line6_init_pcm);
  505. /* prepare pcm callback */
  506. int snd_line6_prepare(struct snd_pcm_substream *substream)
  507. {
  508. struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
  509. struct line6_pcm_stream *pstr = get_stream(line6pcm, substream->stream);
  510. mutex_lock(&line6pcm->state_mutex);
  511. if (!pstr->running)
  512. line6_wait_clear_audio_urbs(line6pcm, pstr);
  513. if (!test_and_set_bit(LINE6_FLAG_PREPARED, &line6pcm->flags)) {
  514. line6pcm->out.count = 0;
  515. line6pcm->out.pos = 0;
  516. line6pcm->out.pos_done = 0;
  517. line6pcm->out.bytes = 0;
  518. line6pcm->in.count = 0;
  519. line6pcm->in.pos_done = 0;
  520. line6pcm->in.bytes = 0;
  521. }
  522. mutex_unlock(&line6pcm->state_mutex);
  523. return 0;
  524. }