Lines Matching refs:apcm
128 atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm);
135 static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) in ct_map_audio_buffer() argument
140 if (!apcm->substream) in ct_map_audio_buffer()
143 runtime = apcm->substream->runtime; in ct_map_audio_buffer()
146 apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes); in ct_map_audio_buffer()
148 if (!apcm->vm_block) in ct_map_audio_buffer()
154 static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) in ct_unmap_audio_buffer() argument
158 if (!apcm->vm_block) in ct_unmap_audio_buffer()
163 vm->unmap(vm, apcm->vm_block); in ct_unmap_audio_buffer()
165 apcm->vm_block = NULL; in ct_unmap_audio_buffer()
242 static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_playback_prepare() argument
251 int n_amixer = apcm->substream->runtime->channels, i = 0; in atc_pcm_playback_prepare()
252 int device = apcm->substream->pcm->device; in atc_pcm_playback_prepare()
256 atc_pcm_release_resources(atc, apcm); in atc_pcm_playback_prepare()
259 desc.multi = apcm->substream->runtime->channels; in atc_pcm_playback_prepare()
262 err = src_mgr->get_src(src_mgr, &desc, (struct src **)&apcm->src); in atc_pcm_playback_prepare()
266 pitch = atc_get_pitch(apcm->substream->runtime->rate, in atc_pcm_playback_prepare()
268 src = apcm->src; in atc_pcm_playback_prepare()
271 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in atc_pcm_playback_prepare()
277 apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); in atc_pcm_playback_prepare()
278 if (!apcm->amixers) { in atc_pcm_playback_prepare()
283 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in atc_pcm_playback_prepare()
285 (struct amixer **)&apcm->amixers[i]); in atc_pcm_playback_prepare()
289 apcm->n_amixer++; in atc_pcm_playback_prepare()
293 err = ct_map_audio_buffer(atc, apcm); in atc_pcm_playback_prepare()
298 src = apcm->src; in atc_pcm_playback_prepare()
300 amixer = apcm->amixers[i]; in atc_pcm_playback_prepare()
307 src = apcm->src; in atc_pcm_playback_prepare()
310 ct_timer_prepare(apcm->timer); in atc_pcm_playback_prepare()
315 atc_pcm_release_resources(atc, apcm); in atc_pcm_playback_prepare()
320 atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_release_resources() argument
329 if (apcm->srcimps) { in atc_pcm_release_resources()
330 for (i = 0; i < apcm->n_srcimp; i++) { in atc_pcm_release_resources()
331 srcimp = apcm->srcimps[i]; in atc_pcm_release_resources()
334 apcm->srcimps[i] = NULL; in atc_pcm_release_resources()
336 kfree(apcm->srcimps); in atc_pcm_release_resources()
337 apcm->srcimps = NULL; in atc_pcm_release_resources()
340 if (apcm->srccs) { in atc_pcm_release_resources()
341 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_release_resources()
342 src_mgr->put_src(src_mgr, apcm->srccs[i]); in atc_pcm_release_resources()
343 apcm->srccs[i] = NULL; in atc_pcm_release_resources()
345 kfree(apcm->srccs); in atc_pcm_release_resources()
346 apcm->srccs = NULL; in atc_pcm_release_resources()
349 if (apcm->amixers) { in atc_pcm_release_resources()
350 for (i = 0; i < apcm->n_amixer; i++) { in atc_pcm_release_resources()
351 amixer_mgr->put_amixer(amixer_mgr, apcm->amixers[i]); in atc_pcm_release_resources()
352 apcm->amixers[i] = NULL; in atc_pcm_release_resources()
354 kfree(apcm->amixers); in atc_pcm_release_resources()
355 apcm->amixers = NULL; in atc_pcm_release_resources()
358 if (apcm->mono) { in atc_pcm_release_resources()
359 sum_mgr->put_sum(sum_mgr, apcm->mono); in atc_pcm_release_resources()
360 apcm->mono = NULL; in atc_pcm_release_resources()
363 if (apcm->src) { in atc_pcm_release_resources()
364 src_mgr->put_src(src_mgr, apcm->src); in atc_pcm_release_resources()
365 apcm->src = NULL; in atc_pcm_release_resources()
368 if (apcm->vm_block) { in atc_pcm_release_resources()
370 ct_unmap_audio_buffer(atc, apcm); in atc_pcm_release_resources()
371 apcm->vm_block = NULL; in atc_pcm_release_resources()
377 static int atc_pcm_playback_start(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_playback_start() argument
380 struct src *src = apcm->src; in atc_pcm_playback_start()
382 if (apcm->started) in atc_pcm_playback_start()
384 apcm->started = 1; in atc_pcm_playback_start()
389 src->ops->set_sa(src, apcm->vm_block->addr); in atc_pcm_playback_start()
390 src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size); in atc_pcm_playback_start()
391 src->ops->set_ca(src, apcm->vm_block->addr + max_cisz); in atc_pcm_playback_start()
398 ct_timer_start(apcm->timer); in atc_pcm_playback_start()
402 static int atc_pcm_stop(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_stop() argument
407 ct_timer_stop(apcm->timer); in atc_pcm_stop()
409 src = apcm->src; in atc_pcm_stop()
414 if (apcm->srccs) { in atc_pcm_stop()
415 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_stop()
416 src = apcm->srccs[i]; in atc_pcm_stop()
423 apcm->started = 0; in atc_pcm_stop()
429 atc_pcm_playback_position(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_playback_position() argument
431 struct src *src = apcm->src; in atc_pcm_playback_position()
439 if (position < apcm->vm_block->addr) { in atc_pcm_playback_position()
442 position, apcm->vm_block->addr, apcm->vm_block->size); in atc_pcm_playback_position()
443 position = apcm->vm_block->addr; in atc_pcm_playback_position()
446 size = apcm->vm_block->size; in atc_pcm_playback_position()
450 return (position + size - max_cisz - apcm->vm_block->addr) % size; in atc_pcm_playback_position()
461 static void setup_src_node_conf(struct ct_atc *atc, struct ct_atc_pcm *apcm, in setup_src_node_conf() argument
468 apcm->substream->runtime->rate); in setup_src_node_conf()
472 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
485 apcm->substream->runtime->rate); in setup_src_node_conf()
488 *n_srcc = apcm->substream->runtime->channels * 2; in setup_src_node_conf()
496 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
502 atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_get_resources() argument
520 atc_pcm_release_resources(atc, apcm); in atc_pcm_capture_get_resources()
525 multi = apcm->substream->runtime->channels; in atc_pcm_capture_get_resources()
529 apcm->substream->runtime->rate); in atc_pcm_capture_get_resources()
531 setup_src_node_conf(atc, apcm, src_node_conf, &n_srcc); in atc_pcm_capture_get_resources()
545 apcm->srccs = kcalloc(n_srcc, sizeof(void *), GFP_KERNEL); in atc_pcm_capture_get_resources()
546 if (!apcm->srccs) in atc_pcm_capture_get_resources()
550 apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); in atc_pcm_capture_get_resources()
551 if (!apcm->amixers) { in atc_pcm_capture_get_resources()
556 apcm->srcimps = kcalloc(n_srcimp, sizeof(void *), GFP_KERNEL); in atc_pcm_capture_get_resources()
557 if (!apcm->srcimps) { in atc_pcm_capture_get_resources()
565 for (i = 0, apcm->n_srcc = 0; i < n_srcc; i++) { in atc_pcm_capture_get_resources()
568 (struct src **)&apcm->srccs[i]); in atc_pcm_capture_get_resources()
572 src = apcm->srccs[i]; in atc_pcm_capture_get_resources()
578 apcm->n_srcc++; in atc_pcm_capture_get_resources()
582 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in atc_pcm_capture_get_resources()
591 (struct amixer **)&apcm->amixers[i]); in atc_pcm_capture_get_resources()
595 apcm->n_amixer++; in atc_pcm_capture_get_resources()
600 err = sum_mgr->get_sum(sum_mgr, &sum_dsc, (struct sum **)&apcm->mono); in atc_pcm_capture_get_resources()
605 apcm->substream->runtime->rate); in atc_pcm_capture_get_resources()
607 for (i = 0, apcm->n_srcimp = 0; i < n_srcimp; i++) { in atc_pcm_capture_get_resources()
619 apcm->srcimps[i] = srcimp; in atc_pcm_capture_get_resources()
620 apcm->n_srcimp++; in atc_pcm_capture_get_resources()
624 src_dsc.multi = apcm->substream->runtime->channels; in atc_pcm_capture_get_resources()
627 err = src_mgr->get_src(src_mgr, &src_dsc, (struct src **)&apcm->src); in atc_pcm_capture_get_resources()
631 src = apcm->src; in atc_pcm_capture_get_resources()
635 err = ct_map_audio_buffer(atc, apcm); in atc_pcm_capture_get_resources()
642 atc_pcm_release_resources(atc, apcm); in atc_pcm_capture_get_resources()
646 static int atc_pcm_capture_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_prepare() argument
658 atc_pcm_release_resources(atc, apcm); in atc_pcm_capture_prepare()
661 err = atc_pcm_capture_get_resources(atc, apcm); in atc_pcm_capture_prepare()
669 multi = apcm->substream->runtime->channels; in atc_pcm_capture_prepare()
671 mono = apcm->mono; in atc_pcm_capture_prepare()
673 amixer = apcm->amixers[i]; in atc_pcm_capture_prepare()
682 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_capture_prepare()
683 src = apcm->srccs[i]; in atc_pcm_capture_prepare()
684 srcimp = apcm->srcimps[imp_base+i]; in atc_pcm_capture_prepare()
685 amixer = apcm->amixers[mix_base+i]; in atc_pcm_capture_prepare()
692 apcm->substream->runtime->rate); in atc_pcm_capture_prepare()
700 amixer = apcm->amixers[apcm->n_srcc+j*multi+i]; in atc_pcm_capture_prepare()
707 srcimp = apcm->srcimps[apcm->n_srcc+j*multi+i]; in atc_pcm_capture_prepare()
708 srcimp->ops->map(srcimp, apcm->src, in atc_pcm_capture_prepare()
714 srcimp = apcm->srcimps[apcm->n_srcc+i]; in atc_pcm_capture_prepare()
715 srcimp->ops->map(srcimp, apcm->src, out_ports[i]); in atc_pcm_capture_prepare()
719 ct_timer_prepare(apcm->timer); in atc_pcm_capture_prepare()
724 static int atc_pcm_capture_start(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_start() argument
730 if (apcm->started) in atc_pcm_capture_start()
733 apcm->started = 1; in atc_pcm_capture_start()
734 multi = apcm->substream->runtime->channels; in atc_pcm_capture_start()
736 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_capture_start()
737 src = apcm->srccs[i]; in atc_pcm_capture_start()
743 src = apcm->src; in atc_pcm_capture_start()
744 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in atc_pcm_capture_start()
746 src->ops->set_sa(src, apcm->vm_block->addr); in atc_pcm_capture_start()
747 src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size); in atc_pcm_capture_start()
748 src->ops->set_ca(src, apcm->vm_block->addr); in atc_pcm_capture_start()
755 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_capture_start()
756 src = apcm->srccs[i]; in atc_pcm_capture_start()
761 src = apcm->src; in atc_pcm_capture_start()
770 ct_timer_start(apcm->timer); in atc_pcm_capture_start()
775 atc_pcm_capture_position(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_position() argument
777 struct src *src = apcm->src; in atc_pcm_capture_position()
781 return src->ops->get_ca(src) - apcm->vm_block->addr; in atc_pcm_capture_position()
785 struct ct_atc_pcm *apcm) in spdif_passthru_playback_get_resources() argument
793 int n_amixer = apcm->substream->runtime->channels, i; in spdif_passthru_playback_get_resources()
797 atc_pcm_release_resources(atc, apcm); in spdif_passthru_playback_get_resources()
800 desc.multi = apcm->substream->runtime->channels; in spdif_passthru_playback_get_resources()
802 while (apcm->substream->runtime->rate > (rsr * desc.msr)) in spdif_passthru_playback_get_resources()
806 err = src_mgr->get_src(src_mgr, &desc, (struct src **)&apcm->src); in spdif_passthru_playback_get_resources()
810 pitch = atc_get_pitch(apcm->substream->runtime->rate, (rsr * desc.msr)); in spdif_passthru_playback_get_resources()
811 src = apcm->src; in spdif_passthru_playback_get_resources()
814 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in spdif_passthru_playback_get_resources()
821 apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); in spdif_passthru_playback_get_resources()
822 if (!apcm->amixers) { in spdif_passthru_playback_get_resources()
827 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in spdif_passthru_playback_get_resources()
829 (struct amixer **)&apcm->amixers[i]); in spdif_passthru_playback_get_resources()
833 apcm->n_amixer++; in spdif_passthru_playback_get_resources()
837 err = ct_map_audio_buffer(atc, apcm); in spdif_passthru_playback_get_resources()
844 atc_pcm_release_resources(atc, apcm); in spdif_passthru_playback_get_resources()
858 spdif_passthru_playback_setup(struct ct_atc *atc, struct ct_atc_pcm *apcm) in spdif_passthru_playback_setup() argument
861 unsigned int rate = apcm->substream->runtime->rate; in spdif_passthru_playback_setup()
896 spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) in spdif_passthru_playback_prepare() argument
904 atc_pcm_release_resources(atc, apcm); in spdif_passthru_playback_prepare()
908 err = spdif_passthru_playback_setup(atc, apcm); in spdif_passthru_playback_prepare()
913 err = spdif_passthru_playback_get_resources(atc, apcm); in spdif_passthru_playback_prepare()
918 src = apcm->src; in spdif_passthru_playback_prepare()
919 for (i = 0; i < apcm->n_amixer; i++) { in spdif_passthru_playback_prepare()
920 amixer = apcm->amixers[i]; in spdif_passthru_playback_prepare()
924 src = apcm->src; in spdif_passthru_playback_prepare()
929 amixer = apcm->amixers[0]; in spdif_passthru_playback_prepare()
931 amixer = apcm->amixers[1]; in spdif_passthru_playback_prepare()
935 ct_timer_prepare(apcm->timer); in spdif_passthru_playback_prepare()