Lines Matching refs:apcm
125 atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm);
132 static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) in ct_map_audio_buffer() argument
137 if (!apcm->substream) in ct_map_audio_buffer()
140 runtime = apcm->substream->runtime; in ct_map_audio_buffer()
143 apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes); in ct_map_audio_buffer()
145 if (!apcm->vm_block) in ct_map_audio_buffer()
151 static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) in ct_unmap_audio_buffer() argument
155 if (!apcm->vm_block) in ct_unmap_audio_buffer()
160 vm->unmap(vm, apcm->vm_block); in ct_unmap_audio_buffer()
162 apcm->vm_block = NULL; in ct_unmap_audio_buffer()
239 static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_playback_prepare() argument
248 int n_amixer = apcm->substream->runtime->channels, i = 0; in atc_pcm_playback_prepare()
249 int device = apcm->substream->pcm->device; in atc_pcm_playback_prepare()
253 atc_pcm_release_resources(atc, apcm); in atc_pcm_playback_prepare()
256 desc.multi = apcm->substream->runtime->channels; in atc_pcm_playback_prepare()
259 err = src_mgr->get_src(src_mgr, &desc, (struct src **)&apcm->src); in atc_pcm_playback_prepare()
263 pitch = atc_get_pitch(apcm->substream->runtime->rate, in atc_pcm_playback_prepare()
265 src = apcm->src; in atc_pcm_playback_prepare()
268 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in atc_pcm_playback_prepare()
274 apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); in atc_pcm_playback_prepare()
275 if (!apcm->amixers) { in atc_pcm_playback_prepare()
280 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in atc_pcm_playback_prepare()
282 (struct amixer **)&apcm->amixers[i]); in atc_pcm_playback_prepare()
286 apcm->n_amixer++; in atc_pcm_playback_prepare()
290 err = ct_map_audio_buffer(atc, apcm); in atc_pcm_playback_prepare()
295 src = apcm->src; in atc_pcm_playback_prepare()
297 amixer = apcm->amixers[i]; in atc_pcm_playback_prepare()
304 src = apcm->src; in atc_pcm_playback_prepare()
307 ct_timer_prepare(apcm->timer); in atc_pcm_playback_prepare()
312 atc_pcm_release_resources(atc, apcm); in atc_pcm_playback_prepare()
317 atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_release_resources() argument
326 if (apcm->srcimps) { in atc_pcm_release_resources()
327 for (i = 0; i < apcm->n_srcimp; i++) { in atc_pcm_release_resources()
328 srcimp = apcm->srcimps[i]; in atc_pcm_release_resources()
331 apcm->srcimps[i] = NULL; in atc_pcm_release_resources()
333 kfree(apcm->srcimps); in atc_pcm_release_resources()
334 apcm->srcimps = NULL; in atc_pcm_release_resources()
337 if (apcm->srccs) { in atc_pcm_release_resources()
338 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_release_resources()
339 src_mgr->put_src(src_mgr, apcm->srccs[i]); in atc_pcm_release_resources()
340 apcm->srccs[i] = NULL; in atc_pcm_release_resources()
342 kfree(apcm->srccs); in atc_pcm_release_resources()
343 apcm->srccs = NULL; in atc_pcm_release_resources()
346 if (apcm->amixers) { in atc_pcm_release_resources()
347 for (i = 0; i < apcm->n_amixer; i++) { in atc_pcm_release_resources()
348 amixer_mgr->put_amixer(amixer_mgr, apcm->amixers[i]); in atc_pcm_release_resources()
349 apcm->amixers[i] = NULL; in atc_pcm_release_resources()
351 kfree(apcm->amixers); in atc_pcm_release_resources()
352 apcm->amixers = NULL; in atc_pcm_release_resources()
355 if (apcm->mono) { in atc_pcm_release_resources()
356 sum_mgr->put_sum(sum_mgr, apcm->mono); in atc_pcm_release_resources()
357 apcm->mono = NULL; in atc_pcm_release_resources()
360 if (apcm->src) { in atc_pcm_release_resources()
361 src_mgr->put_src(src_mgr, apcm->src); in atc_pcm_release_resources()
362 apcm->src = NULL; in atc_pcm_release_resources()
365 if (apcm->vm_block) { in atc_pcm_release_resources()
367 ct_unmap_audio_buffer(atc, apcm); in atc_pcm_release_resources()
368 apcm->vm_block = NULL; in atc_pcm_release_resources()
374 static int atc_pcm_playback_start(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_playback_start() argument
377 struct src *src = apcm->src; in atc_pcm_playback_start()
379 if (apcm->started) in atc_pcm_playback_start()
381 apcm->started = 1; in atc_pcm_playback_start()
386 src->ops->set_sa(src, apcm->vm_block->addr); in atc_pcm_playback_start()
387 src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size); in atc_pcm_playback_start()
388 src->ops->set_ca(src, apcm->vm_block->addr + max_cisz); in atc_pcm_playback_start()
395 ct_timer_start(apcm->timer); in atc_pcm_playback_start()
399 static int atc_pcm_stop(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_stop() argument
404 ct_timer_stop(apcm->timer); in atc_pcm_stop()
406 src = apcm->src; in atc_pcm_stop()
411 if (apcm->srccs) { in atc_pcm_stop()
412 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_stop()
413 src = apcm->srccs[i]; in atc_pcm_stop()
420 apcm->started = 0; in atc_pcm_stop()
426 atc_pcm_playback_position(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_playback_position() argument
428 struct src *src = apcm->src; in atc_pcm_playback_position()
436 if (position < apcm->vm_block->addr) { in atc_pcm_playback_position()
439 position, apcm->vm_block->addr, apcm->vm_block->size); in atc_pcm_playback_position()
440 position = apcm->vm_block->addr; in atc_pcm_playback_position()
443 size = apcm->vm_block->size; in atc_pcm_playback_position()
447 return (position + size - max_cisz - apcm->vm_block->addr) % size; in atc_pcm_playback_position()
458 static void setup_src_node_conf(struct ct_atc *atc, struct ct_atc_pcm *apcm, in setup_src_node_conf() argument
465 apcm->substream->runtime->rate); in setup_src_node_conf()
469 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
482 apcm->substream->runtime->rate); in setup_src_node_conf()
485 *n_srcc = apcm->substream->runtime->channels * 2; in setup_src_node_conf()
493 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
499 atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_get_resources() argument
517 atc_pcm_release_resources(atc, apcm); in atc_pcm_capture_get_resources()
522 multi = apcm->substream->runtime->channels; in atc_pcm_capture_get_resources()
526 apcm->substream->runtime->rate); in atc_pcm_capture_get_resources()
528 setup_src_node_conf(atc, apcm, src_node_conf, &n_srcc); in atc_pcm_capture_get_resources()
542 apcm->srccs = kcalloc(n_srcc, sizeof(void *), GFP_KERNEL); in atc_pcm_capture_get_resources()
543 if (!apcm->srccs) in atc_pcm_capture_get_resources()
547 apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); in atc_pcm_capture_get_resources()
548 if (!apcm->amixers) { in atc_pcm_capture_get_resources()
553 apcm->srcimps = kcalloc(n_srcimp, sizeof(void *), GFP_KERNEL); in atc_pcm_capture_get_resources()
554 if (!apcm->srcimps) { in atc_pcm_capture_get_resources()
562 for (i = 0, apcm->n_srcc = 0; i < n_srcc; i++) { in atc_pcm_capture_get_resources()
565 (struct src **)&apcm->srccs[i]); in atc_pcm_capture_get_resources()
569 src = apcm->srccs[i]; in atc_pcm_capture_get_resources()
575 apcm->n_srcc++; in atc_pcm_capture_get_resources()
579 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in atc_pcm_capture_get_resources()
588 (struct amixer **)&apcm->amixers[i]); in atc_pcm_capture_get_resources()
592 apcm->n_amixer++; in atc_pcm_capture_get_resources()
597 err = sum_mgr->get_sum(sum_mgr, &sum_dsc, (struct sum **)&apcm->mono); in atc_pcm_capture_get_resources()
602 apcm->substream->runtime->rate); in atc_pcm_capture_get_resources()
604 for (i = 0, apcm->n_srcimp = 0; i < n_srcimp; i++) { in atc_pcm_capture_get_resources()
616 apcm->srcimps[i] = srcimp; in atc_pcm_capture_get_resources()
617 apcm->n_srcimp++; in atc_pcm_capture_get_resources()
621 src_dsc.multi = apcm->substream->runtime->channels; in atc_pcm_capture_get_resources()
624 err = src_mgr->get_src(src_mgr, &src_dsc, (struct src **)&apcm->src); in atc_pcm_capture_get_resources()
628 src = apcm->src; in atc_pcm_capture_get_resources()
632 err = ct_map_audio_buffer(atc, apcm); in atc_pcm_capture_get_resources()
639 atc_pcm_release_resources(atc, apcm); in atc_pcm_capture_get_resources()
643 static int atc_pcm_capture_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_prepare() argument
655 atc_pcm_release_resources(atc, apcm); in atc_pcm_capture_prepare()
658 err = atc_pcm_capture_get_resources(atc, apcm); in atc_pcm_capture_prepare()
666 multi = apcm->substream->runtime->channels; in atc_pcm_capture_prepare()
668 mono = apcm->mono; in atc_pcm_capture_prepare()
670 amixer = apcm->amixers[i]; in atc_pcm_capture_prepare()
679 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_capture_prepare()
680 src = apcm->srccs[i]; in atc_pcm_capture_prepare()
681 srcimp = apcm->srcimps[imp_base+i]; in atc_pcm_capture_prepare()
682 amixer = apcm->amixers[mix_base+i]; in atc_pcm_capture_prepare()
689 apcm->substream->runtime->rate); in atc_pcm_capture_prepare()
697 amixer = apcm->amixers[apcm->n_srcc+j*multi+i]; in atc_pcm_capture_prepare()
704 srcimp = apcm->srcimps[apcm->n_srcc+j*multi+i]; in atc_pcm_capture_prepare()
705 srcimp->ops->map(srcimp, apcm->src, in atc_pcm_capture_prepare()
711 srcimp = apcm->srcimps[apcm->n_srcc+i]; in atc_pcm_capture_prepare()
712 srcimp->ops->map(srcimp, apcm->src, out_ports[i]); in atc_pcm_capture_prepare()
716 ct_timer_prepare(apcm->timer); in atc_pcm_capture_prepare()
721 static int atc_pcm_capture_start(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_start() argument
727 if (apcm->started) in atc_pcm_capture_start()
730 apcm->started = 1; in atc_pcm_capture_start()
731 multi = apcm->substream->runtime->channels; in atc_pcm_capture_start()
733 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_capture_start()
734 src = apcm->srccs[i]; in atc_pcm_capture_start()
740 src = apcm->src; in atc_pcm_capture_start()
741 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in atc_pcm_capture_start()
743 src->ops->set_sa(src, apcm->vm_block->addr); in atc_pcm_capture_start()
744 src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size); in atc_pcm_capture_start()
745 src->ops->set_ca(src, apcm->vm_block->addr); in atc_pcm_capture_start()
752 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_capture_start()
753 src = apcm->srccs[i]; in atc_pcm_capture_start()
758 src = apcm->src; in atc_pcm_capture_start()
767 ct_timer_start(apcm->timer); in atc_pcm_capture_start()
772 atc_pcm_capture_position(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_position() argument
774 struct src *src = apcm->src; in atc_pcm_capture_position()
778 return src->ops->get_ca(src) - apcm->vm_block->addr; in atc_pcm_capture_position()
782 struct ct_atc_pcm *apcm) in spdif_passthru_playback_get_resources() argument
790 int n_amixer = apcm->substream->runtime->channels, i; in spdif_passthru_playback_get_resources()
794 atc_pcm_release_resources(atc, apcm); in spdif_passthru_playback_get_resources()
797 desc.multi = apcm->substream->runtime->channels; in spdif_passthru_playback_get_resources()
799 while (apcm->substream->runtime->rate > (rsr * desc.msr)) in spdif_passthru_playback_get_resources()
803 err = src_mgr->get_src(src_mgr, &desc, (struct src **)&apcm->src); in spdif_passthru_playback_get_resources()
807 pitch = atc_get_pitch(apcm->substream->runtime->rate, (rsr * desc.msr)); in spdif_passthru_playback_get_resources()
808 src = apcm->src; in spdif_passthru_playback_get_resources()
811 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in spdif_passthru_playback_get_resources()
818 apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); in spdif_passthru_playback_get_resources()
819 if (!apcm->amixers) { in spdif_passthru_playback_get_resources()
824 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in spdif_passthru_playback_get_resources()
826 (struct amixer **)&apcm->amixers[i]); in spdif_passthru_playback_get_resources()
830 apcm->n_amixer++; in spdif_passthru_playback_get_resources()
834 err = ct_map_audio_buffer(atc, apcm); in spdif_passthru_playback_get_resources()
841 atc_pcm_release_resources(atc, apcm); in spdif_passthru_playback_get_resources()
855 spdif_passthru_playback_setup(struct ct_atc *atc, struct ct_atc_pcm *apcm) in spdif_passthru_playback_setup() argument
858 unsigned int rate = apcm->substream->runtime->rate; in spdif_passthru_playback_setup()
893 spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) in spdif_passthru_playback_prepare() argument
901 atc_pcm_release_resources(atc, apcm); in spdif_passthru_playback_prepare()
905 err = spdif_passthru_playback_setup(atc, apcm); in spdif_passthru_playback_prepare()
910 err = spdif_passthru_playback_get_resources(atc, apcm); in spdif_passthru_playback_prepare()
915 src = apcm->src; in spdif_passthru_playback_prepare()
916 for (i = 0; i < apcm->n_amixer; i++) { in spdif_passthru_playback_prepare()
917 amixer = apcm->amixers[i]; in spdif_passthru_playback_prepare()
921 src = apcm->src; in spdif_passthru_playback_prepare()
926 amixer = apcm->amixers[0]; in spdif_passthru_playback_prepare()
928 amixer = apcm->amixers[1]; in spdif_passthru_playback_prepare()
932 ct_timer_prepare(apcm->timer); in spdif_passthru_playback_prepare()