Lines Matching +full:src +full:- +full:2
1 // SPDX-License-Identifier: GPL-2.0-only
28 #define MONO_SUM_SCALE 0x19a8 /* 2^(-0.5) in 14-bit floating format */
101 .public_name = "IEC958 Non-audio"},
115 [SRC] = { .create = (create_t)src_mgr_create,
140 if (!apcm->substream) in ct_map_audio_buffer()
143 runtime = apcm->substream->runtime; in ct_map_audio_buffer()
144 vm = atc->vm; 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()
149 return -ENOENT; in ct_map_audio_buffer()
158 if (!apcm->vm_block) in ct_unmap_audio_buffer()
161 vm = atc->vm; 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()
170 return atc->vm->get_ptp_phys(atc->vm, index); in atc_get_ptp_phys()
188 dev_err(card->dev, "not recognized snd format is %d\n", in convert_format()
200 /* get pitch and convert to fixed-point 8.24 format. */ in atc_get_pitch()
206 b--; in atc_get_pitch()
209 input_rate <<= (31 - b); in atc_get_pitch()
211 b = 24 - (31 - b); in atc_get_pitch()
215 input_rate >>= -b; in atc_get_pitch()
230 return 2; in select_rom()
232 /* pitch == 2 */ in select_rom()
238 return -ENOENT; in select_rom()
244 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_playback_prepare()
245 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in atc_pcm_playback_prepare()
248 struct src *src; in atc_pcm_playback_prepare() local
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()
258 /* Get SRC resource */ in atc_pcm_playback_prepare()
259 desc.multi = apcm->substream->runtime->channels; in atc_pcm_playback_prepare()
260 desc.msr = atc->msr; 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()
267 (atc->rsr * atc->msr)); in atc_pcm_playback_prepare()
268 src = apcm->src; in atc_pcm_playback_prepare()
269 src->ops->set_pitch(src, pitch); in atc_pcm_playback_prepare()
270 src->ops->set_rom(src, select_rom(pitch)); in atc_pcm_playback_prepare()
271 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in atc_pcm_playback_prepare()
272 atc->card)); in atc_pcm_playback_prepare()
273 src->ops->set_pm(src, (src->ops->next_interleave(src) != NULL)); in atc_pcm_playback_prepare()
276 n_amixer = (n_amixer < 2) ? 2 : n_amixer; 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()
279 err = -ENOMEM; in atc_pcm_playback_prepare()
282 mix_dsc.msr = atc->msr; in atc_pcm_playback_prepare()
283 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in atc_pcm_playback_prepare()
284 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc, 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()
298 src = apcm->src; in atc_pcm_playback_prepare()
300 amixer = apcm->amixers[i]; in atc_pcm_playback_prepare()
301 mutex_lock(&atc->atc_mutex); in atc_pcm_playback_prepare()
302 amixer->ops->setup(amixer, &src->rsc, in atc_pcm_playback_prepare()
303 INIT_VOL, atc->pcm[i+device*2]); in atc_pcm_playback_prepare()
304 mutex_unlock(&atc->atc_mutex); in atc_pcm_playback_prepare()
305 src = src->ops->next_interleave(src); in atc_pcm_playback_prepare()
306 if (!src) 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()
322 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_release_resources()
323 struct srcimp_mgr *srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_pcm_release_resources()
324 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in atc_pcm_release_resources()
325 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM]; in atc_pcm_release_resources()
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()
332 srcimp->ops->unmap(srcimp); in atc_pcm_release_resources()
333 srcimp_mgr->put_srcimp(srcimp_mgr, srcimp); 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()
371 apcm->vm_block = NULL; in atc_pcm_release_resources()
380 struct src *src = apcm->src; in atc_pcm_playback_start() local
382 if (apcm->started) in atc_pcm_playback_start()
384 apcm->started = 1; in atc_pcm_playback_start()
386 max_cisz = src->multi * src->rsc.msr; 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()
392 src->ops->set_cisz(src, max_cisz); in atc_pcm_playback_start()
394 src->ops->set_bm(src, 1); in atc_pcm_playback_start()
395 src->ops->set_state(src, SRC_STATE_INIT); in atc_pcm_playback_start()
396 src->ops->commit_write(src); in atc_pcm_playback_start()
398 ct_timer_start(apcm->timer); in atc_pcm_playback_start()
404 struct src *src; in atc_pcm_stop() local
407 ct_timer_stop(apcm->timer); in atc_pcm_stop()
409 src = apcm->src; in atc_pcm_stop()
410 src->ops->set_bm(src, 0); in atc_pcm_stop()
411 src->ops->set_state(src, SRC_STATE_OFF); in atc_pcm_stop()
412 src->ops->commit_write(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()
417 src->ops->set_bm(src, 0); in atc_pcm_stop()
418 src->ops->set_state(src, SRC_STATE_OFF); in atc_pcm_stop()
419 src->ops->commit_write(src); in atc_pcm_stop()
423 apcm->started = 0; in atc_pcm_stop()
431 struct src *src = apcm->src; in atc_pcm_playback_position() local
435 if (!src) in atc_pcm_playback_position()
437 position = src->ops->get_ca(src); in atc_pcm_playback_position()
439 if (position < apcm->vm_block->addr) { in atc_pcm_playback_position()
440 dev_dbg(atc->card->dev, in atc_pcm_playback_position()
441 "bad ca - ca=0x%08x, vba=0x%08x, vbs=0x%08x\n", 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()
447 max_cisz = src->multi * src->rsc.msr; in atc_pcm_playback_position()
450 return (position + size - max_cisz - apcm->vm_block->addr) % size; in atc_pcm_playback_position()
466 /* get pitch and convert to fixed-point 8.24 format. */ in setup_src_node_conf()
467 pitch = atc_get_pitch((atc->rsr * atc->msr), in setup_src_node_conf()
468 apcm->substream->runtime->rate); in setup_src_node_conf()
471 if (1 == atc->msr) { /* FIXME: do we really need SRC here if pitch==1 */ in setup_src_node_conf()
472 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
476 } else if (2 <= atc->msr) { in setup_src_node_conf()
478 /* Need two-stage SRCs, SRCIMPs and in setup_src_node_conf()
480 conf[0].pitch = (atc->msr << 24); in setup_src_node_conf()
482 conf[0].imp_msr = atc->msr; in setup_src_node_conf()
484 conf[1].pitch = atc_get_pitch(atc->rsr, 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()
490 /* Need one-stage SRCs, SRCIMPs and in setup_src_node_conf()
494 = conf[0].imp_msr = atc->msr; in setup_src_node_conf()
496 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
504 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_capture_get_resources()
505 struct srcimp_mgr *srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_pcm_capture_get_resources()
506 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in atc_pcm_capture_get_resources()
507 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM]; in atc_pcm_capture_get_resources()
509 struct src *src; in atc_pcm_capture_get_resources() local
517 struct src_node_conf_t src_node_conf[2] = {{0} }; in atc_pcm_capture_get_resources()
525 multi = apcm->substream->runtime->channels; in atc_pcm_capture_get_resources()
527 /* get pitch and convert to fixed-point 8.24 format. */ in atc_pcm_capture_get_resources()
528 pitch = atc_get_pitch((atc->rsr * atc->msr), in atc_pcm_capture_get_resources()
529 apcm->substream->runtime->rate); in atc_pcm_capture_get_resources()
533 n_amixer = n_sum * 2 + n_srcc; in atc_pcm_capture_get_resources()
538 n_amixer += multi * atc->msr; in atc_pcm_capture_get_resources()
539 n_srcimp += multi * atc->msr; 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()
547 return -ENOMEM; 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()
552 err = -ENOMEM; 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()
558 err = -ENOMEM; in atc_pcm_capture_get_resources()
565 for (i = 0, apcm->n_srcc = 0; i < n_srcc; i++) { in atc_pcm_capture_get_resources()
567 err = src_mgr->get_src(src_mgr, &src_dsc, 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()
574 src->ops->set_pitch(src, pitch); in atc_pcm_capture_get_resources()
575 src->ops->set_rom(src, select_rom(pitch)); in atc_pcm_capture_get_resources()
576 src->ops->set_vo(src, src_node_conf[i/multi].vo); 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()
583 if (i < (n_sum*2)) in atc_pcm_capture_get_resources()
584 mix_dsc.msr = atc->msr; in atc_pcm_capture_get_resources()
585 else if (i < (n_sum*2+n_srcc)) in atc_pcm_capture_get_resources()
586 mix_dsc.msr = src_node_conf[(i-n_sum*2)/multi].mix_msr; in atc_pcm_capture_get_resources()
590 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc, 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()
599 sum_dsc.msr = atc->msr; 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()
604 pitch = atc_get_pitch((atc->rsr * atc->msr), 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()
611 srcimp_dsc.msr = (pitch <= 0x8000000) ? atc->msr : 1; in atc_pcm_capture_get_resources()
615 err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc, &srcimp); 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()
623 /* Allocate a SRC for writing data to host memory */ 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()
632 src->ops->set_pitch(src, pitch); in atc_pcm_capture_get_resources()
648 struct src *src; in atc_pcm_capture_prepare() local
651 struct ct_mixer *mixer = atc->mixer; in atc_pcm_capture_prepare()
666 mixer->get_output_ports(mixer, MIX_PCMO_FRONT, 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()
672 for (i = 0; i < 2; i++) { in atc_pcm_capture_prepare()
673 amixer = apcm->amixers[i]; in atc_pcm_capture_prepare()
674 amixer->ops->setup(amixer, out_ports[i], in atc_pcm_capture_prepare()
677 out_ports[0] = &mono->rsc; in atc_pcm_capture_prepare()
679 mix_base = n_sum * 2; 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()
686 srcimp->ops->map(srcimp, src, out_ports[i%multi]); in atc_pcm_capture_prepare()
687 amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); in atc_pcm_capture_prepare()
688 out_ports[i%multi] = &amixer->rsc; in atc_pcm_capture_prepare()
691 pitch = atc_get_pitch((atc->rsr * atc->msr), in atc_pcm_capture_prepare()
692 apcm->substream->runtime->rate); in atc_pcm_capture_prepare()
698 out_ports[i]->ops->master(out_ports[i]); in atc_pcm_capture_prepare()
699 for (j = 0; j < atc->msr; j++) { in atc_pcm_capture_prepare()
700 amixer = apcm->amixers[apcm->n_srcc+j*multi+i]; in atc_pcm_capture_prepare()
701 amixer->ops->set_input(amixer, out_ports[i]); in atc_pcm_capture_prepare()
702 amixer->ops->set_scale(amixer, INIT_VOL); in atc_pcm_capture_prepare()
703 amixer->ops->set_sum(amixer, NULL); in atc_pcm_capture_prepare()
704 amixer->ops->commit_raw_write(amixer); in atc_pcm_capture_prepare()
705 out_ports[i]->ops->next_conj(out_ports[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()
709 &amixer->rsc); 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()
726 struct src *src; in atc_pcm_capture_start() local
727 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_capture_start()
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()
738 src->ops->set_pm(src, ((i%multi) != (multi-1))); in atc_pcm_capture_start()
739 src_mgr->src_disable(src_mgr, src); in atc_pcm_capture_start()
742 /* Set up recording SRC */ 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()
745 atc->card)); 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()
749 src_mgr->src_disable(src_mgr, src); in atc_pcm_capture_start()
752 src_mgr->commit_write(src_mgr); 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()
757 src->ops->set_state(src, SRC_STATE_RUN); in atc_pcm_capture_start()
758 src->ops->commit_write(src); in atc_pcm_capture_start()
759 src_mgr->src_enable_s(src_mgr, src); in atc_pcm_capture_start()
761 src = apcm->src; in atc_pcm_capture_start()
762 src->ops->set_bm(src, 1); in atc_pcm_capture_start()
763 src->ops->set_state(src, SRC_STATE_RUN); in atc_pcm_capture_start()
764 src->ops->commit_write(src); in atc_pcm_capture_start()
765 src_mgr->src_enable_s(src_mgr, src); in atc_pcm_capture_start()
768 src_mgr->commit_write(src_mgr); in atc_pcm_capture_start()
770 ct_timer_start(apcm->timer); in atc_pcm_capture_start()
777 struct src *src = apcm->src; in atc_pcm_capture_position() local
779 if (!src) in atc_pcm_capture_position()
781 return src->ops->get_ca(src) - apcm->vm_block->addr; in atc_pcm_capture_position()
787 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in spdif_passthru_playback_get_resources()
788 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in spdif_passthru_playback_get_resources()
791 struct src *src; in spdif_passthru_playback_get_resources() local
793 int n_amixer = apcm->substream->runtime->channels, i; in spdif_passthru_playback_get_resources()
794 unsigned int pitch, rsr = atc->pll_rate; in spdif_passthru_playback_get_resources()
799 /* Get SRC resource */ 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()
812 src->ops->set_pitch(src, pitch); in spdif_passthru_playback_get_resources()
813 src->ops->set_rom(src, select_rom(pitch)); in spdif_passthru_playback_get_resources()
814 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in spdif_passthru_playback_get_resources()
815 atc->card)); in spdif_passthru_playback_get_resources()
816 src->ops->set_pm(src, (src->ops->next_interleave(src) != NULL)); in spdif_passthru_playback_get_resources()
817 src->ops->set_bp(src, 1); in spdif_passthru_playback_get_resources()
820 n_amixer = (n_amixer < 2) ? 2 : n_amixer; 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()
823 err = -ENOMEM; in spdif_passthru_playback_get_resources()
827 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in spdif_passthru_playback_get_resources()
828 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc, 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()
850 struct hw *hw = atc->hw; in atc_pll_init()
852 err = hw->pll_init(hw, rate); in atc_pll_init()
853 atc->pll_rate = err ? 0 : rate; in atc_pll_init()
860 struct dao *dao = container_of(atc->daios[SPDIFOO], struct dao, daio); in spdif_passthru_playback_setup()
861 unsigned int rate = apcm->substream->runtime->rate; in spdif_passthru_playback_setup()
877 return -ENOENT; in spdif_passthru_playback_setup()
880 mutex_lock(&atc->atc_mutex); in spdif_passthru_playback_setup()
881 dao->ops->get_spos(dao, &status); in spdif_passthru_playback_setup()
885 dao->ops->set_spos(dao, status); in spdif_passthru_playback_setup()
886 dao->ops->commit_write(dao); in spdif_passthru_playback_setup()
888 if ((rate != atc->pll_rate) && (32000 != rate)) in spdif_passthru_playback_setup()
890 mutex_unlock(&atc->atc_mutex); in spdif_passthru_playback_setup()
898 struct src *src; in spdif_passthru_playback_prepare() local
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()
921 amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); in spdif_passthru_playback_prepare()
922 src = src->ops->next_interleave(src); in spdif_passthru_playback_prepare()
923 if (!src) in spdif_passthru_playback_prepare()
924 src = apcm->src; in spdif_passthru_playback_prepare()
927 mutex_lock(&atc->atc_mutex); in spdif_passthru_playback_prepare()
928 dao = container_of(atc->daios[SPDIFOO], struct dao, daio); in spdif_passthru_playback_prepare()
929 amixer = apcm->amixers[0]; in spdif_passthru_playback_prepare()
930 dao->ops->set_left_input(dao, &amixer->rsc); in spdif_passthru_playback_prepare()
931 amixer = apcm->amixers[1]; in spdif_passthru_playback_prepare()
932 dao->ops->set_right_input(dao, &amixer->rsc); in spdif_passthru_playback_prepare()
933 mutex_unlock(&atc->atc_mutex); in spdif_passthru_playback_prepare()
935 ct_timer_prepare(apcm->timer); in spdif_passthru_playback_prepare()
942 struct hw *hw = atc->hw; in atc_select_line_in()
943 struct ct_mixer *mixer = atc->mixer; in atc_select_line_in()
944 struct src *src; in atc_select_line_in() local
946 if (hw->is_adc_source_selected(hw, ADC_LINEIN)) in atc_select_line_in()
949 mixer->set_input_left(mixer, MIX_MIC_IN, NULL); in atc_select_line_in()
950 mixer->set_input_right(mixer, MIX_MIC_IN, NULL); in atc_select_line_in()
952 hw->select_adc_source(hw, ADC_LINEIN); in atc_select_line_in()
954 src = atc->srcs[2]; in atc_select_line_in()
955 mixer->set_input_left(mixer, MIX_LINE_IN, &src->rsc); in atc_select_line_in()
956 src = atc->srcs[3]; in atc_select_line_in()
957 mixer->set_input_right(mixer, MIX_LINE_IN, &src->rsc); in atc_select_line_in()
964 struct hw *hw = atc->hw; in atc_select_mic_in()
965 struct ct_mixer *mixer = atc->mixer; in atc_select_mic_in()
966 struct src *src; in atc_select_mic_in() local
968 if (hw->is_adc_source_selected(hw, ADC_MICIN)) in atc_select_mic_in()
971 mixer->set_input_left(mixer, MIX_LINE_IN, NULL); in atc_select_mic_in()
972 mixer->set_input_right(mixer, MIX_LINE_IN, NULL); in atc_select_mic_in()
974 hw->select_adc_source(hw, ADC_MICIN); in atc_select_mic_in()
976 src = atc->srcs[2]; in atc_select_mic_in()
977 mixer->set_input_left(mixer, MIX_MIC_IN, &src->rsc); in atc_select_mic_in()
978 src = atc->srcs[3]; in atc_select_mic_in()
979 mixer->set_input_right(mixer, MIX_MIC_IN, &src->rsc); in atc_select_mic_in()
986 struct hw *hw = atc->hw; in atc_capabilities()
988 return hw->capabilities(hw); in atc_capabilities()
993 struct hw *hw = atc->hw; in atc_output_switch_get()
995 return hw->output_switch_get(hw); in atc_output_switch_get()
1000 struct hw *hw = atc->hw; in atc_output_switch_put()
1002 return hw->output_switch_put(hw, position); in atc_output_switch_put()
1007 struct hw *hw = atc->hw; in atc_mic_source_switch_get()
1009 return hw->mic_source_switch_get(hw); in atc_mic_source_switch_get()
1014 struct hw *hw = atc->hw; in atc_mic_source_switch_put()
1016 return hw->mic_source_switch_put(hw, position); in atc_mic_source_switch_put()
1021 struct hw *hw = atc->hw; in atc_select_digit_io()
1023 if (hw->is_adc_source_selected(hw, ADC_NONE)) in atc_select_digit_io()
1026 hw->select_adc_source(hw, ADC_NONE); in atc_select_digit_io()
1033 struct daio_mgr *daio_mgr = atc->rsc_mgrs[DAIO]; in atc_daio_unmute()
1036 daio_mgr->daio_enable(daio_mgr, atc->daios[type]); in atc_daio_unmute()
1038 daio_mgr->daio_disable(daio_mgr, atc->daios[type]); in atc_daio_unmute()
1040 daio_mgr->commit_write(daio_mgr); in atc_daio_unmute()
1048 struct dao *dao = container_of(atc->daios[type], struct dao, daio); in atc_dao_get_status()
1049 return dao->ops->get_spos(dao, status); in atc_dao_get_status()
1055 struct dao *dao = container_of(atc->daios[type], struct dao, daio); in atc_dao_set_status()
1057 dao->ops->set_spos(dao, status); in atc_dao_set_status()
1058 dao->ops->commit_write(dao); in atc_dao_set_status()
1117 struct ct_mixer *mixer = atc->mixer; in atc_spdif_out_passthru()
1118 struct rsc *rscs[2] = {NULL}; in atc_spdif_out_passthru()
1121 mutex_lock(&atc->atc_mutex); in atc_spdif_out_passthru()
1122 dao = container_of(atc->daios[SPDIFOO], struct dao, daio); in atc_spdif_out_passthru()
1123 da_dsc.msr = state ? 1 : atc->msr; in atc_spdif_out_passthru()
1125 err = dao->ops->reinit(dao, &da_dsc); in atc_spdif_out_passthru()
1129 mixer->get_output_ports(mixer, MIX_SPDIF_OUT, in atc_spdif_out_passthru()
1131 dao->ops->set_left_input(dao, rscs[0]); in atc_spdif_out_passthru()
1132 dao->ops->set_right_input(dao, rscs[1]); in atc_spdif_out_passthru()
1133 /* Restore PLL to atc->rsr if needed. */ in atc_spdif_out_passthru()
1134 if (atc->pll_rate != atc->rsr) in atc_spdif_out_passthru()
1135 err = atc_pll_init(atc, atc->rsr); in atc_spdif_out_passthru()
1137 dao->ops->set_spos(dao, spos); in atc_spdif_out_passthru()
1138 dao->ops->commit_write(dao); in atc_spdif_out_passthru()
1139 mutex_unlock(&atc->atc_mutex); in atc_spdif_out_passthru()
1157 if (atc->mixer) { in atc_release_resources()
1158 mixer = atc->mixer; in atc_release_resources()
1159 mixer->set_input_left(mixer, MIX_LINE_IN, NULL); in atc_release_resources()
1160 mixer->set_input_right(mixer, MIX_LINE_IN, NULL); in atc_release_resources()
1161 mixer->set_input_left(mixer, MIX_MIC_IN, NULL); in atc_release_resources()
1162 mixer->set_input_right(mixer, MIX_MIC_IN, NULL); in atc_release_resources()
1163 mixer->set_input_left(mixer, MIX_SPDIF_IN, NULL); in atc_release_resources()
1164 mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL); in atc_release_resources()
1167 if (atc->daios) { in atc_release_resources()
1168 daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; in atc_release_resources()
1169 for (i = 0; i < atc->n_daio; i++) { in atc_release_resources()
1170 daio = atc->daios[i]; in atc_release_resources()
1171 if (daio->type < LINEIM) { in atc_release_resources()
1173 dao->ops->clear_left_input(dao); in atc_release_resources()
1174 dao->ops->clear_right_input(dao); in atc_release_resources()
1176 daio_mgr->put_daio(daio_mgr, daio); in atc_release_resources()
1178 kfree(atc->daios); in atc_release_resources()
1179 atc->daios = NULL; in atc_release_resources()
1182 if (atc->pcm) { in atc_release_resources()
1183 sum_mgr = atc->rsc_mgrs[SUM]; in atc_release_resources()
1184 for (i = 0; i < atc->n_pcm; i++) in atc_release_resources()
1185 sum_mgr->put_sum(sum_mgr, atc->pcm[i]); in atc_release_resources()
1187 kfree(atc->pcm); in atc_release_resources()
1188 atc->pcm = NULL; in atc_release_resources()
1191 if (atc->srcs) { in atc_release_resources()
1192 src_mgr = atc->rsc_mgrs[SRC]; in atc_release_resources()
1193 for (i = 0; i < atc->n_src; i++) in atc_release_resources()
1194 src_mgr->put_src(src_mgr, atc->srcs[i]); in atc_release_resources()
1196 kfree(atc->srcs); in atc_release_resources()
1197 atc->srcs = NULL; in atc_release_resources()
1200 if (atc->srcimps) { in atc_release_resources()
1201 srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_release_resources()
1202 for (i = 0; i < atc->n_srcimp; i++) { in atc_release_resources()
1203 srcimp = atc->srcimps[i]; in atc_release_resources()
1204 srcimp->ops->unmap(srcimp); in atc_release_resources()
1205 srcimp_mgr->put_srcimp(srcimp_mgr, atc->srcimps[i]); in atc_release_resources()
1207 kfree(atc->srcimps); in atc_release_resources()
1208 atc->srcimps = NULL; in atc_release_resources()
1221 if (atc->timer) { in ct_atc_destroy()
1222 ct_timer_free(atc->timer); in ct_atc_destroy()
1223 atc->timer = NULL; in ct_atc_destroy()
1229 if (atc->mixer) in ct_atc_destroy()
1230 ct_mixer_destroy(atc->mixer); in ct_atc_destroy()
1233 if (rsc_mgr_funcs[i].destroy && atc->rsc_mgrs[i]) in ct_atc_destroy()
1234 rsc_mgr_funcs[i].destroy(atc->rsc_mgrs[i]); in ct_atc_destroy()
1238 if (atc->hw) in ct_atc_destroy()
1239 destroy_hw_obj(atc->hw); in ct_atc_destroy()
1242 if (atc->vm) { in ct_atc_destroy()
1243 ct_vm_destroy(atc->vm); in ct_atc_destroy()
1244 atc->vm = NULL; in ct_atc_destroy()
1254 struct ct_atc *atc = dev->device_data; in atc_dev_free()
1264 switch (atc->chip_type) { in atc_identify_card()
1266 atc->chip_name = "20K1"; in atc_identify_card()
1270 atc->chip_name = "20K2"; in atc_identify_card()
1274 return -ENOENT; in atc_identify_card()
1280 vendor_id = atc->pci->subsystem_vendor; in atc_identify_card()
1281 device_id = atc->pci->subsystem_device; in atc_identify_card()
1285 if (p->value < 0) { in atc_identify_card()
1286 dev_err(atc->card->dev, in atc_identify_card()
1289 return -ENOENT; in atc_identify_card()
1291 atc->model = p->value; in atc_identify_card()
1293 if (atc->chip_type == ATC20K1) in atc_identify_card()
1294 atc->model = CT20K1_UNKNOWN; in atc_identify_card()
1296 atc->model = CT20K2_UNKNOWN; in atc_identify_card()
1298 atc->model_name = ct_subsys_name[atc->model]; in atc_identify_card()
1299 dev_info(atc->card->dev, "chip %s model %s (%04x:%04x) is found\n", in atc_identify_card()
1300 atc->chip_name, atc->model_name, in atc_identify_card()
1310 alsa_dev_funcs[MIXER].public_name = atc->chip_name; in ct_atc_create_alsa_devs()
1319 dev_err(atc->card->dev, in ct_atc_create_alsa_devs()
1334 err = create_hw_obj(atc->pci, atc->chip_type, atc->model, &hw); in atc_create_hw_devs()
1336 dev_err(atc->card->dev, "Failed to create hw obj!!!\n"); in atc_create_hw_devs()
1339 hw->card = atc->card; in atc_create_hw_devs()
1340 atc->hw = hw; in atc_create_hw_devs()
1343 info.rsr = atc->rsr; in atc_create_hw_devs()
1344 info.msr = atc->msr; in atc_create_hw_devs()
1346 err = hw->card_init(hw, &info); in atc_create_hw_devs()
1354 err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]); in atc_create_hw_devs()
1356 dev_err(atc->card->dev, in atc_create_hw_devs()
1377 num_daios = ((atc->model == CTSB1270) ? 8 : 7); in atc_get_resources()
1378 num_srcs = ((atc->model == CTSB1270) ? 6 : 4); in atc_get_resources()
1380 atc->daios = kcalloc(num_daios, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1381 if (!atc->daios) in atc_get_resources()
1382 return -ENOMEM; in atc_get_resources()
1384 atc->srcs = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1385 if (!atc->srcs) in atc_get_resources()
1386 return -ENOMEM; in atc_get_resources()
1388 atc->srcimps = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1389 if (!atc->srcimps) in atc_get_resources()
1390 return -ENOMEM; in atc_get_resources()
1392 atc->pcm = kcalloc(2 * 4, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1393 if (!atc->pcm) in atc_get_resources()
1394 return -ENOMEM; in atc_get_resources()
1396 daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; in atc_get_resources()
1397 da_desc.msr = atc->msr; in atc_get_resources()
1398 for (i = 0, atc->n_daio = 0; i < num_daios; i++) { in atc_get_resources()
1399 da_desc.type = (atc->model != CTSB073X) ? i : in atc_get_resources()
1401 err = daio_mgr->get_daio(daio_mgr, &da_desc, in atc_get_resources()
1402 (struct daio **)&atc->daios[i]); in atc_get_resources()
1404 dev_err(atc->card->dev, in atc_get_resources()
1409 atc->n_daio++; in atc_get_resources()
1412 src_mgr = atc->rsc_mgrs[SRC]; in atc_get_resources()
1414 src_dsc.msr = atc->msr; in atc_get_resources()
1416 for (i = 0, atc->n_src = 0; i < num_srcs; i++) { in atc_get_resources()
1417 err = src_mgr->get_src(src_mgr, &src_dsc, in atc_get_resources()
1418 (struct src **)&atc->srcs[i]); in atc_get_resources()
1422 atc->n_src++; in atc_get_resources()
1425 srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_get_resources()
1427 for (i = 0, atc->n_srcimp = 0; i < num_srcs; i++) { in atc_get_resources()
1428 err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc, in atc_get_resources()
1429 (struct srcimp **)&atc->srcimps[i]); in atc_get_resources()
1433 atc->n_srcimp++; in atc_get_resources()
1436 sum_mgr = atc->rsc_mgrs[SUM]; in atc_get_resources()
1437 sum_dsc.msr = atc->msr; in atc_get_resources()
1438 for (i = 0, atc->n_pcm = 0; i < (2*4); i++) { in atc_get_resources()
1439 err = sum_mgr->get_sum(sum_mgr, &sum_dsc, in atc_get_resources()
1440 (struct sum **)&atc->pcm[i]); in atc_get_resources()
1444 atc->n_pcm++; in atc_get_resources()
1452 struct src **srcs, struct srcimp **srcimps) in atc_connect_dai()
1454 struct rsc *rscs[2] = {NULL}; in atc_connect_dai()
1455 struct src *src; in atc_connect_dai() local
1459 rscs[0] = &dai->daio.rscl; in atc_connect_dai()
1460 rscs[1] = &dai->daio.rscr; in atc_connect_dai()
1461 for (i = 0; i < 2; i++) { in atc_connect_dai()
1462 src = srcs[i]; in atc_connect_dai()
1464 srcimp->ops->map(srcimp, src, rscs[i]); in atc_connect_dai()
1465 src_mgr->src_disable(src_mgr, src); in atc_connect_dai()
1468 src_mgr->commit_write(src_mgr); /* Actually disable SRCs */ in atc_connect_dai()
1470 src = srcs[0]; in atc_connect_dai()
1471 src->ops->set_pm(src, 1); in atc_connect_dai()
1472 for (i = 0; i < 2; i++) { in atc_connect_dai()
1473 src = srcs[i]; in atc_connect_dai()
1474 src->ops->set_state(src, SRC_STATE_RUN); in atc_connect_dai()
1475 src->ops->commit_write(src); in atc_connect_dai()
1476 src_mgr->src_enable_s(src_mgr, src); in atc_connect_dai()
1479 dai->ops->set_srt_srcl(dai, &(srcs[0]->rsc)); in atc_connect_dai()
1480 dai->ops->set_srt_srcr(dai, &(srcs[1]->rsc)); in atc_connect_dai()
1482 dai->ops->set_enb_src(dai, 1); in atc_connect_dai()
1483 dai->ops->set_enb_srt(dai, 1); in atc_connect_dai()
1484 dai->ops->commit_write(dai); in atc_connect_dai()
1486 src_mgr->commit_write(src_mgr); /* Synchronously enable SRCs */ in atc_connect_dai()
1493 struct src *src; in atc_connect_resources() local
1496 struct rsc *rscs[2] = {NULL}; in atc_connect_resources()
1499 mixer = atc->mixer; in atc_connect_resources()
1502 mixer->get_output_ports(mixer, i, &rscs[0], &rscs[1]); in atc_connect_resources()
1503 dao = container_of(atc->daios[j], struct dao, daio); in atc_connect_resources()
1504 dao->ops->set_left_input(dao, rscs[0]); in atc_connect_resources()
1505 dao->ops->set_right_input(dao, rscs[1]); in atc_connect_resources()
1508 dai = container_of(atc->daios[LINEIM], struct dai, daio); in atc_connect_resources()
1509 atc_connect_dai(atc->rsc_mgrs[SRC], dai, in atc_connect_resources()
1510 (struct src **)&atc->srcs[2], in atc_connect_resources()
1511 (struct srcimp **)&atc->srcimps[2]); in atc_connect_resources()
1512 src = atc->srcs[2]; in atc_connect_resources()
1513 mixer->set_input_left(mixer, MIX_LINE_IN, &src->rsc); in atc_connect_resources()
1514 src = atc->srcs[3]; in atc_connect_resources()
1515 mixer->set_input_right(mixer, MIX_LINE_IN, &src->rsc); in atc_connect_resources()
1517 if (atc->model == CTSB1270) { in atc_connect_resources()
1519 dai = container_of(atc->daios[MIC], struct dai, daio); in atc_connect_resources()
1520 atc_connect_dai(atc->rsc_mgrs[SRC], dai, in atc_connect_resources()
1521 (struct src **)&atc->srcs[4], in atc_connect_resources()
1522 (struct srcimp **)&atc->srcimps[4]); in atc_connect_resources()
1523 src = atc->srcs[4]; in atc_connect_resources()
1524 mixer->set_input_left(mixer, MIX_MIC_IN, &src->rsc); in atc_connect_resources()
1525 src = atc->srcs[5]; in atc_connect_resources()
1526 mixer->set_input_right(mixer, MIX_MIC_IN, &src->rsc); in atc_connect_resources()
1529 dai = container_of(atc->daios[SPDIFIO], struct dai, daio); in atc_connect_resources()
1530 atc_connect_dai(atc->rsc_mgrs[SRC], dai, in atc_connect_resources()
1531 (struct src **)&atc->srcs[0], in atc_connect_resources()
1532 (struct srcimp **)&atc->srcimps[0]); in atc_connect_resources()
1534 src = atc->srcs[0]; in atc_connect_resources()
1535 mixer->set_input_left(mixer, MIX_SPDIF_IN, &src->rsc); in atc_connect_resources()
1536 src = atc->srcs[1]; in atc_connect_resources()
1537 mixer->set_input_right(mixer, MIX_SPDIF_IN, &src->rsc); in atc_connect_resources()
1539 for (i = MIX_PCMI_FRONT, j = 0; i <= MIX_PCMI_SURROUND; i++, j += 2) { in atc_connect_resources()
1540 sum = atc->pcm[j]; in atc_connect_resources()
1541 mixer->set_input_left(mixer, i, &sum->rsc); in atc_connect_resources()
1542 sum = atc->pcm[j+1]; in atc_connect_resources()
1543 mixer->set_input_right(mixer, i, &sum->rsc); in atc_connect_resources()
1550 struct hw *hw = atc->hw; in atc_suspend()
1552 snd_power_change_state(atc->card, SNDRV_CTL_POWER_D3hot); in atc_suspend()
1556 hw->suspend(hw); in atc_suspend()
1563 struct hw *hw = atc->hw; in atc_hw_resume()
1566 /* Re-initialize card hardware. */ in atc_hw_resume()
1567 info.rsr = atc->rsr; in atc_hw_resume()
1568 info.msr = atc->msr; in atc_hw_resume()
1570 return hw->resume(hw, &info); in atc_hw_resume()
1588 mixer = atc->mixer; in atc_resources_resume()
1589 mixer->resume(mixer); in atc_resources_resume()
1601 dev_err(atc->card->dev, in atc_resume()
1603 snd_card_disconnect(atc->card); in atc_resume()
1611 snd_power_change_state(atc->card, SNDRV_CTL_POWER_D0); in atc_resume()
1657 * ct_atc_create - create and initialize a hardware manager
1687 return -ENOMEM; in ct_atc_create()
1692 atc->card = card; in ct_atc_create()
1693 atc->pci = pci; in ct_atc_create()
1694 atc->rsr = rsr; in ct_atc_create()
1695 atc->msr = msr; in ct_atc_create()
1696 atc->chip_type = chip_type; in ct_atc_create()
1698 mutex_init(&atc->atc_mutex); in ct_atc_create()
1703 dev_err(card->dev, "ctatc: Card not recognised\n"); in ct_atc_create()
1708 err = ct_vm_create(&atc->vm, pci); in ct_atc_create()
1717 err = ct_mixer_create(atc, (struct ct_mixer **)&atc->mixer); in ct_atc_create()
1719 dev_err(card->dev, "Failed to create mixer obj!!!\n"); in ct_atc_create()
1731 atc->timer = ct_timer_new(atc); in ct_atc_create()
1732 if (!atc->timer) { in ct_atc_create()
1733 err = -ENOMEM; in ct_atc_create()
1746 dev_err(card->dev, "Something wrong!!!\n"); in ct_atc_create()