Lines Matching refs:apcm

126 atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm);
133 static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) in ct_map_audio_buffer() argument
138 if (!apcm->substream) in ct_map_audio_buffer()
141 runtime = apcm->substream->runtime; in ct_map_audio_buffer()
144 apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes); in ct_map_audio_buffer()
146 if (!apcm->vm_block) in ct_map_audio_buffer()
152 static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) in ct_unmap_audio_buffer() argument
156 if (!apcm->vm_block) in ct_unmap_audio_buffer()
161 vm->unmap(vm, apcm->vm_block); in ct_unmap_audio_buffer()
163 apcm->vm_block = NULL; in ct_unmap_audio_buffer()
240 static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_playback_prepare() argument
249 int n_amixer = apcm->substream->runtime->channels, i = 0; in atc_pcm_playback_prepare()
250 int device = apcm->substream->pcm->device; in atc_pcm_playback_prepare()
254 atc_pcm_release_resources(atc, apcm); in atc_pcm_playback_prepare()
257 desc.multi = apcm->substream->runtime->channels; in atc_pcm_playback_prepare()
260 err = src_mgr->get_src(src_mgr, &desc, (struct src **)&apcm->src); in atc_pcm_playback_prepare()
264 pitch = atc_get_pitch(apcm->substream->runtime->rate, in atc_pcm_playback_prepare()
266 src = apcm->src; in atc_pcm_playback_prepare()
269 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in atc_pcm_playback_prepare()
275 apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); in atc_pcm_playback_prepare()
276 if (!apcm->amixers) { in atc_pcm_playback_prepare()
281 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in atc_pcm_playback_prepare()
283 (struct amixer **)&apcm->amixers[i]); in atc_pcm_playback_prepare()
287 apcm->n_amixer++; in atc_pcm_playback_prepare()
291 err = ct_map_audio_buffer(atc, apcm); in atc_pcm_playback_prepare()
296 src = apcm->src; in atc_pcm_playback_prepare()
298 amixer = apcm->amixers[i]; in atc_pcm_playback_prepare()
305 src = apcm->src; in atc_pcm_playback_prepare()
308 ct_timer_prepare(apcm->timer); in atc_pcm_playback_prepare()
313 atc_pcm_release_resources(atc, apcm); in atc_pcm_playback_prepare()
318 atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_release_resources() argument
327 if (apcm->srcimps) { in atc_pcm_release_resources()
328 for (i = 0; i < apcm->n_srcimp; i++) { in atc_pcm_release_resources()
329 srcimp = apcm->srcimps[i]; in atc_pcm_release_resources()
332 apcm->srcimps[i] = NULL; in atc_pcm_release_resources()
334 kfree(apcm->srcimps); in atc_pcm_release_resources()
335 apcm->srcimps = NULL; in atc_pcm_release_resources()
338 if (apcm->srccs) { in atc_pcm_release_resources()
339 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_release_resources()
340 src_mgr->put_src(src_mgr, apcm->srccs[i]); in atc_pcm_release_resources()
341 apcm->srccs[i] = NULL; in atc_pcm_release_resources()
343 kfree(apcm->srccs); in atc_pcm_release_resources()
344 apcm->srccs = NULL; in atc_pcm_release_resources()
347 if (apcm->amixers) { in atc_pcm_release_resources()
348 for (i = 0; i < apcm->n_amixer; i++) { in atc_pcm_release_resources()
349 amixer_mgr->put_amixer(amixer_mgr, apcm->amixers[i]); in atc_pcm_release_resources()
350 apcm->amixers[i] = NULL; in atc_pcm_release_resources()
352 kfree(apcm->amixers); in atc_pcm_release_resources()
353 apcm->amixers = NULL; in atc_pcm_release_resources()
356 if (apcm->mono) { in atc_pcm_release_resources()
357 sum_mgr->put_sum(sum_mgr, apcm->mono); in atc_pcm_release_resources()
358 apcm->mono = NULL; in atc_pcm_release_resources()
361 if (apcm->src) { in atc_pcm_release_resources()
362 src_mgr->put_src(src_mgr, apcm->src); in atc_pcm_release_resources()
363 apcm->src = NULL; in atc_pcm_release_resources()
366 if (apcm->vm_block) { in atc_pcm_release_resources()
368 ct_unmap_audio_buffer(atc, apcm); in atc_pcm_release_resources()
369 apcm->vm_block = NULL; in atc_pcm_release_resources()
375 static int atc_pcm_playback_start(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_playback_start() argument
378 struct src *src = apcm->src; in atc_pcm_playback_start()
380 if (apcm->started) in atc_pcm_playback_start()
382 apcm->started = 1; in atc_pcm_playback_start()
387 src->ops->set_sa(src, apcm->vm_block->addr); in atc_pcm_playback_start()
388 src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size); in atc_pcm_playback_start()
389 src->ops->set_ca(src, apcm->vm_block->addr + max_cisz); in atc_pcm_playback_start()
396 ct_timer_start(apcm->timer); in atc_pcm_playback_start()
400 static int atc_pcm_stop(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_stop() argument
405 ct_timer_stop(apcm->timer); in atc_pcm_stop()
407 src = apcm->src; in atc_pcm_stop()
412 if (apcm->srccs) { in atc_pcm_stop()
413 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_stop()
414 src = apcm->srccs[i]; in atc_pcm_stop()
421 apcm->started = 0; in atc_pcm_stop()
427 atc_pcm_playback_position(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_playback_position() argument
429 struct src *src = apcm->src; in atc_pcm_playback_position()
437 if (position < apcm->vm_block->addr) { in atc_pcm_playback_position()
440 position, apcm->vm_block->addr, apcm->vm_block->size); in atc_pcm_playback_position()
441 position = apcm->vm_block->addr; in atc_pcm_playback_position()
444 size = apcm->vm_block->size; in atc_pcm_playback_position()
448 return (position + size - max_cisz - apcm->vm_block->addr) % size; in atc_pcm_playback_position()
459 static void setup_src_node_conf(struct ct_atc *atc, struct ct_atc_pcm *apcm, in setup_src_node_conf() argument
466 apcm->substream->runtime->rate); in setup_src_node_conf()
470 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
483 apcm->substream->runtime->rate); in setup_src_node_conf()
486 *n_srcc = apcm->substream->runtime->channels * 2; in setup_src_node_conf()
494 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
500 atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_get_resources() argument
518 atc_pcm_release_resources(atc, apcm); in atc_pcm_capture_get_resources()
523 multi = apcm->substream->runtime->channels; in atc_pcm_capture_get_resources()
527 apcm->substream->runtime->rate); in atc_pcm_capture_get_resources()
529 setup_src_node_conf(atc, apcm, src_node_conf, &n_srcc); in atc_pcm_capture_get_resources()
543 apcm->srccs = kcalloc(n_srcc, sizeof(void *), GFP_KERNEL); in atc_pcm_capture_get_resources()
544 if (!apcm->srccs) in atc_pcm_capture_get_resources()
548 apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); in atc_pcm_capture_get_resources()
549 if (!apcm->amixers) { in atc_pcm_capture_get_resources()
554 apcm->srcimps = kcalloc(n_srcimp, sizeof(void *), GFP_KERNEL); in atc_pcm_capture_get_resources()
555 if (!apcm->srcimps) { in atc_pcm_capture_get_resources()
563 for (i = 0, apcm->n_srcc = 0; i < n_srcc; i++) { in atc_pcm_capture_get_resources()
566 (struct src **)&apcm->srccs[i]); in atc_pcm_capture_get_resources()
570 src = apcm->srccs[i]; in atc_pcm_capture_get_resources()
576 apcm->n_srcc++; in atc_pcm_capture_get_resources()
580 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in atc_pcm_capture_get_resources()
589 (struct amixer **)&apcm->amixers[i]); in atc_pcm_capture_get_resources()
593 apcm->n_amixer++; in atc_pcm_capture_get_resources()
598 err = sum_mgr->get_sum(sum_mgr, &sum_dsc, (struct sum **)&apcm->mono); in atc_pcm_capture_get_resources()
603 apcm->substream->runtime->rate); in atc_pcm_capture_get_resources()
605 for (i = 0, apcm->n_srcimp = 0; i < n_srcimp; i++) { in atc_pcm_capture_get_resources()
617 apcm->srcimps[i] = srcimp; in atc_pcm_capture_get_resources()
618 apcm->n_srcimp++; in atc_pcm_capture_get_resources()
622 src_dsc.multi = apcm->substream->runtime->channels; in atc_pcm_capture_get_resources()
625 err = src_mgr->get_src(src_mgr, &src_dsc, (struct src **)&apcm->src); in atc_pcm_capture_get_resources()
629 src = apcm->src; in atc_pcm_capture_get_resources()
633 err = ct_map_audio_buffer(atc, apcm); in atc_pcm_capture_get_resources()
640 atc_pcm_release_resources(atc, apcm); in atc_pcm_capture_get_resources()
644 static int atc_pcm_capture_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_prepare() argument
656 atc_pcm_release_resources(atc, apcm); in atc_pcm_capture_prepare()
659 err = atc_pcm_capture_get_resources(atc, apcm); in atc_pcm_capture_prepare()
667 multi = apcm->substream->runtime->channels; in atc_pcm_capture_prepare()
669 mono = apcm->mono; in atc_pcm_capture_prepare()
671 amixer = apcm->amixers[i]; in atc_pcm_capture_prepare()
680 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_capture_prepare()
681 src = apcm->srccs[i]; in atc_pcm_capture_prepare()
682 srcimp = apcm->srcimps[imp_base+i]; in atc_pcm_capture_prepare()
683 amixer = apcm->amixers[mix_base+i]; in atc_pcm_capture_prepare()
690 apcm->substream->runtime->rate); in atc_pcm_capture_prepare()
698 amixer = apcm->amixers[apcm->n_srcc+j*multi+i]; in atc_pcm_capture_prepare()
705 srcimp = apcm->srcimps[apcm->n_srcc+j*multi+i]; in atc_pcm_capture_prepare()
706 srcimp->ops->map(srcimp, apcm->src, in atc_pcm_capture_prepare()
712 srcimp = apcm->srcimps[apcm->n_srcc+i]; in atc_pcm_capture_prepare()
713 srcimp->ops->map(srcimp, apcm->src, out_ports[i]); in atc_pcm_capture_prepare()
717 ct_timer_prepare(apcm->timer); in atc_pcm_capture_prepare()
722 static int atc_pcm_capture_start(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_start() argument
728 if (apcm->started) in atc_pcm_capture_start()
731 apcm->started = 1; in atc_pcm_capture_start()
732 multi = apcm->substream->runtime->channels; in atc_pcm_capture_start()
734 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_capture_start()
735 src = apcm->srccs[i]; in atc_pcm_capture_start()
741 src = apcm->src; in atc_pcm_capture_start()
742 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in atc_pcm_capture_start()
744 src->ops->set_sa(src, apcm->vm_block->addr); in atc_pcm_capture_start()
745 src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size); in atc_pcm_capture_start()
746 src->ops->set_ca(src, apcm->vm_block->addr); in atc_pcm_capture_start()
753 for (i = 0; i < apcm->n_srcc; i++) { in atc_pcm_capture_start()
754 src = apcm->srccs[i]; in atc_pcm_capture_start()
759 src = apcm->src; in atc_pcm_capture_start()
768 ct_timer_start(apcm->timer); in atc_pcm_capture_start()
773 atc_pcm_capture_position(struct ct_atc *atc, struct ct_atc_pcm *apcm) in atc_pcm_capture_position() argument
775 struct src *src = apcm->src; in atc_pcm_capture_position()
779 return src->ops->get_ca(src) - apcm->vm_block->addr; in atc_pcm_capture_position()
783 struct ct_atc_pcm *apcm) in spdif_passthru_playback_get_resources() argument
791 int n_amixer = apcm->substream->runtime->channels, i; in spdif_passthru_playback_get_resources()
795 atc_pcm_release_resources(atc, apcm); in spdif_passthru_playback_get_resources()
798 desc.multi = apcm->substream->runtime->channels; in spdif_passthru_playback_get_resources()
800 while (apcm->substream->runtime->rate > (rsr * desc.msr)) in spdif_passthru_playback_get_resources()
804 err = src_mgr->get_src(src_mgr, &desc, (struct src **)&apcm->src); in spdif_passthru_playback_get_resources()
808 pitch = atc_get_pitch(apcm->substream->runtime->rate, (rsr * desc.msr)); in spdif_passthru_playback_get_resources()
809 src = apcm->src; in spdif_passthru_playback_get_resources()
812 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in spdif_passthru_playback_get_resources()
819 apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); in spdif_passthru_playback_get_resources()
820 if (!apcm->amixers) { in spdif_passthru_playback_get_resources()
825 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in spdif_passthru_playback_get_resources()
827 (struct amixer **)&apcm->amixers[i]); in spdif_passthru_playback_get_resources()
831 apcm->n_amixer++; in spdif_passthru_playback_get_resources()
835 err = ct_map_audio_buffer(atc, apcm); in spdif_passthru_playback_get_resources()
842 atc_pcm_release_resources(atc, apcm); in spdif_passthru_playback_get_resources()
856 spdif_passthru_playback_setup(struct ct_atc *atc, struct ct_atc_pcm *apcm) in spdif_passthru_playback_setup() argument
859 unsigned int rate = apcm->substream->runtime->rate; in spdif_passthru_playback_setup()
894 spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) in spdif_passthru_playback_prepare() argument
902 atc_pcm_release_resources(atc, apcm); in spdif_passthru_playback_prepare()
906 err = spdif_passthru_playback_setup(atc, apcm); in spdif_passthru_playback_prepare()
911 err = spdif_passthru_playback_get_resources(atc, apcm); in spdif_passthru_playback_prepare()
916 src = apcm->src; in spdif_passthru_playback_prepare()
917 for (i = 0; i < apcm->n_amixer; i++) { in spdif_passthru_playback_prepare()
918 amixer = apcm->amixers[i]; in spdif_passthru_playback_prepare()
922 src = apcm->src; in spdif_passthru_playback_prepare()
927 amixer = apcm->amixers[0]; in spdif_passthru_playback_prepare()
929 amixer = apcm->amixers[1]; in spdif_passthru_playback_prepare()
933 ct_timer_prepare(apcm->timer); in spdif_passthru_playback_prepare()