Lines Matching +full:src +full:-

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"},
112 [SRC] = { .create = src_mgr_create,
137 if (!apcm->substream) in ct_map_audio_buffer()
140 runtime = apcm->substream->runtime; in ct_map_audio_buffer()
141 vm = atc->vm; 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()
146 return -ENOENT; in ct_map_audio_buffer()
155 if (!apcm->vm_block) in ct_unmap_audio_buffer()
158 vm = atc->vm; 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()
167 return atc->vm->get_ptp_phys(atc->vm, index); in atc_get_ptp_phys()
185 dev_err(card->dev, "not recognized snd format is %d\n", in convert_format()
197 /* get pitch and convert to fixed-point 8.24 format. */ in atc_get_pitch()
203 b--; in atc_get_pitch()
206 input_rate <<= (31 - b); in atc_get_pitch()
208 b = 24 - (31 - b); in atc_get_pitch()
212 input_rate >>= -b; in atc_get_pitch()
235 return -ENOENT; in select_rom()
241 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_playback_prepare()
242 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in atc_pcm_playback_prepare()
245 struct src *src; in atc_pcm_playback_prepare() local
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()
255 /* Get SRC resource */ in atc_pcm_playback_prepare()
256 desc.multi = apcm->substream->runtime->channels; in atc_pcm_playback_prepare()
257 desc.msr = atc->msr; 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()
264 (atc->rsr * atc->msr)); in atc_pcm_playback_prepare()
265 src = apcm->src; in atc_pcm_playback_prepare()
266 src->ops->set_pitch(src, pitch); in atc_pcm_playback_prepare()
267 src->ops->set_rom(src, select_rom(pitch)); in atc_pcm_playback_prepare()
268 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in atc_pcm_playback_prepare()
269 atc->card)); in atc_pcm_playback_prepare()
270 src->ops->set_pm(src, (src->ops->next_interleave(src) != NULL)); 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()
276 err = -ENOMEM; in atc_pcm_playback_prepare()
279 mix_dsc.msr = atc->msr; in atc_pcm_playback_prepare()
280 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in atc_pcm_playback_prepare()
281 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc, 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()
295 src = apcm->src; in atc_pcm_playback_prepare()
297 amixer = apcm->amixers[i]; in atc_pcm_playback_prepare()
298 mutex_lock(&atc->atc_mutex); in atc_pcm_playback_prepare()
299 amixer->ops->setup(amixer, &src->rsc, in atc_pcm_playback_prepare()
300 INIT_VOL, atc->pcm[i+device*2]); in atc_pcm_playback_prepare()
301 mutex_unlock(&atc->atc_mutex); in atc_pcm_playback_prepare()
302 src = src->ops->next_interleave(src); in atc_pcm_playback_prepare()
303 if (!src) 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()
319 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_release_resources()
320 struct srcimp_mgr *srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_pcm_release_resources()
321 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in atc_pcm_release_resources()
322 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM]; in atc_pcm_release_resources()
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()
329 srcimp->ops->unmap(srcimp); in atc_pcm_release_resources()
330 srcimp_mgr->put_srcimp(srcimp_mgr, srcimp); 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()
368 apcm->vm_block = NULL; in atc_pcm_release_resources()
377 struct src *src = apcm->src; in atc_pcm_playback_start() local
379 if (apcm->started) in atc_pcm_playback_start()
381 apcm->started = 1; in atc_pcm_playback_start()
383 max_cisz = src->multi * src->rsc.msr; 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()
389 src->ops->set_cisz(src, max_cisz); in atc_pcm_playback_start()
391 src->ops->set_bm(src, 1); in atc_pcm_playback_start()
392 src->ops->set_state(src, SRC_STATE_INIT); in atc_pcm_playback_start()
393 src->ops->commit_write(src); in atc_pcm_playback_start()
395 ct_timer_start(apcm->timer); in atc_pcm_playback_start()
401 struct src *src; in atc_pcm_stop() local
404 ct_timer_stop(apcm->timer); in atc_pcm_stop()
406 src = apcm->src; in atc_pcm_stop()
407 src->ops->set_bm(src, 0); in atc_pcm_stop()
408 src->ops->set_state(src, SRC_STATE_OFF); in atc_pcm_stop()
409 src->ops->commit_write(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()
414 src->ops->set_bm(src, 0); in atc_pcm_stop()
415 src->ops->set_state(src, SRC_STATE_OFF); in atc_pcm_stop()
416 src->ops->commit_write(src); in atc_pcm_stop()
420 apcm->started = 0; in atc_pcm_stop()
428 struct src *src = apcm->src; in atc_pcm_playback_position() local
432 if (!src) in atc_pcm_playback_position()
434 position = src->ops->get_ca(src); in atc_pcm_playback_position()
436 if (position < apcm->vm_block->addr) { in atc_pcm_playback_position()
437 dev_dbg(atc->card->dev, in atc_pcm_playback_position()
438 "bad ca - ca=0x%08x, vba=0x%08x, vbs=0x%08x\n", 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()
444 max_cisz = src->multi * src->rsc.msr; in atc_pcm_playback_position()
447 return (position + size - max_cisz - apcm->vm_block->addr) % size; in atc_pcm_playback_position()
463 /* get pitch and convert to fixed-point 8.24 format. */ in setup_src_node_conf()
464 pitch = atc_get_pitch((atc->rsr * atc->msr), in setup_src_node_conf()
465 apcm->substream->runtime->rate); in setup_src_node_conf()
468 if (1 == atc->msr) { /* FIXME: do we really need SRC here if pitch==1 */ in setup_src_node_conf()
469 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
473 } else if (2 <= atc->msr) { in setup_src_node_conf()
475 /* Need two-stage SRCs, SRCIMPs and in setup_src_node_conf()
477 conf[0].pitch = (atc->msr << 24); in setup_src_node_conf()
479 conf[0].imp_msr = atc->msr; in setup_src_node_conf()
481 conf[1].pitch = atc_get_pitch(atc->rsr, 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()
487 /* Need one-stage SRCs, SRCIMPs and in setup_src_node_conf()
491 = conf[0].imp_msr = atc->msr; in setup_src_node_conf()
493 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
501 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_capture_get_resources()
502 struct srcimp_mgr *srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_pcm_capture_get_resources()
503 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in atc_pcm_capture_get_resources()
504 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM]; in atc_pcm_capture_get_resources()
506 struct src *src; in atc_pcm_capture_get_resources() local
522 multi = apcm->substream->runtime->channels; in atc_pcm_capture_get_resources()
524 /* get pitch and convert to fixed-point 8.24 format. */ in atc_pcm_capture_get_resources()
525 pitch = atc_get_pitch((atc->rsr * atc->msr), in atc_pcm_capture_get_resources()
526 apcm->substream->runtime->rate); in atc_pcm_capture_get_resources()
535 n_amixer += multi * atc->msr; in atc_pcm_capture_get_resources()
536 n_srcimp += multi * atc->msr; 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()
544 return -ENOMEM; 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()
549 err = -ENOMEM; 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()
555 err = -ENOMEM; in atc_pcm_capture_get_resources()
562 for (i = 0, apcm->n_srcc = 0; i < n_srcc; i++) { in atc_pcm_capture_get_resources()
564 err = src_mgr->get_src(src_mgr, &src_dsc, 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()
571 src->ops->set_pitch(src, pitch); in atc_pcm_capture_get_resources()
572 src->ops->set_rom(src, select_rom(pitch)); in atc_pcm_capture_get_resources()
573 src->ops->set_vo(src, src_node_conf[i/multi].vo); 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()
581 mix_dsc.msr = atc->msr; in atc_pcm_capture_get_resources()
583 mix_dsc.msr = src_node_conf[(i-n_sum*2)/multi].mix_msr; in atc_pcm_capture_get_resources()
587 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc, 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()
596 sum_dsc.msr = atc->msr; 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()
601 pitch = atc_get_pitch((atc->rsr * atc->msr), 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()
608 srcimp_dsc.msr = (pitch <= 0x8000000) ? atc->msr : 1; in atc_pcm_capture_get_resources()
612 err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc, &srcimp); 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()
620 /* Allocate a SRC for writing data to host memory */ 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()
629 src->ops->set_pitch(src, pitch); in atc_pcm_capture_get_resources()
645 struct src *src; in atc_pcm_capture_prepare() local
648 struct ct_mixer *mixer = atc->mixer; in atc_pcm_capture_prepare()
663 mixer->get_output_ports(mixer, MIX_PCMO_FRONT, 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()
671 amixer->ops->setup(amixer, out_ports[i], in atc_pcm_capture_prepare()
674 out_ports[0] = &mono->rsc; 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()
683 srcimp->ops->map(srcimp, src, out_ports[i%multi]); in atc_pcm_capture_prepare()
684 amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); in atc_pcm_capture_prepare()
685 out_ports[i%multi] = &amixer->rsc; in atc_pcm_capture_prepare()
688 pitch = atc_get_pitch((atc->rsr * atc->msr), in atc_pcm_capture_prepare()
689 apcm->substream->runtime->rate); in atc_pcm_capture_prepare()
695 out_ports[i]->ops->master(out_ports[i]); in atc_pcm_capture_prepare()
696 for (j = 0; j < atc->msr; j++) { in atc_pcm_capture_prepare()
697 amixer = apcm->amixers[apcm->n_srcc+j*multi+i]; in atc_pcm_capture_prepare()
698 amixer->ops->set_input(amixer, out_ports[i]); in atc_pcm_capture_prepare()
699 amixer->ops->set_scale(amixer, INIT_VOL); in atc_pcm_capture_prepare()
700 amixer->ops->set_sum(amixer, NULL); in atc_pcm_capture_prepare()
701 amixer->ops->commit_raw_write(amixer); in atc_pcm_capture_prepare()
702 out_ports[i]->ops->next_conj(out_ports[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()
706 &amixer->rsc); 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()
723 struct src *src; in atc_pcm_capture_start() local
724 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_capture_start()
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()
735 src->ops->set_pm(src, ((i%multi) != (multi-1))); in atc_pcm_capture_start()
736 src_mgr->src_disable(src_mgr, src); in atc_pcm_capture_start()
739 /* Set up recording SRC */ 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()
742 atc->card)); 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()
746 src_mgr->src_disable(src_mgr, src); in atc_pcm_capture_start()
749 src_mgr->commit_write(src_mgr); 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()
754 src->ops->set_state(src, SRC_STATE_RUN); in atc_pcm_capture_start()
755 src->ops->commit_write(src); in atc_pcm_capture_start()
756 src_mgr->src_enable_s(src_mgr, src); in atc_pcm_capture_start()
758 src = apcm->src; in atc_pcm_capture_start()
759 src->ops->set_bm(src, 1); in atc_pcm_capture_start()
760 src->ops->set_state(src, SRC_STATE_RUN); in atc_pcm_capture_start()
761 src->ops->commit_write(src); in atc_pcm_capture_start()
762 src_mgr->src_enable_s(src_mgr, src); in atc_pcm_capture_start()
765 src_mgr->commit_write(src_mgr); in atc_pcm_capture_start()
767 ct_timer_start(apcm->timer); in atc_pcm_capture_start()
774 struct src *src = apcm->src; in atc_pcm_capture_position() local
776 if (!src) in atc_pcm_capture_position()
778 return src->ops->get_ca(src) - apcm->vm_block->addr; in atc_pcm_capture_position()
784 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in spdif_passthru_playback_get_resources()
785 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in spdif_passthru_playback_get_resources()
788 struct src *src; in spdif_passthru_playback_get_resources() local
790 int n_amixer = apcm->substream->runtime->channels, i; in spdif_passthru_playback_get_resources()
791 unsigned int pitch, rsr = atc->pll_rate; in spdif_passthru_playback_get_resources()
796 /* Get SRC resource */ 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()
809 src->ops->set_pitch(src, pitch); in spdif_passthru_playback_get_resources()
810 src->ops->set_rom(src, select_rom(pitch)); in spdif_passthru_playback_get_resources()
811 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in spdif_passthru_playback_get_resources()
812 atc->card)); in spdif_passthru_playback_get_resources()
813 src->ops->set_pm(src, (src->ops->next_interleave(src) != NULL)); in spdif_passthru_playback_get_resources()
814 src->ops->set_bp(src, 1); 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()
820 err = -ENOMEM; in spdif_passthru_playback_get_resources()
824 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in spdif_passthru_playback_get_resources()
825 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc, 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()
847 struct hw *hw = atc->hw; in atc_pll_init()
849 err = hw->pll_init(hw, rate); in atc_pll_init()
850 atc->pll_rate = err ? 0 : rate; in atc_pll_init()
857 struct dao *dao = container_of(atc->daios[SPDIFOO], struct dao, daio); in spdif_passthru_playback_setup()
858 unsigned int rate = apcm->substream->runtime->rate; in spdif_passthru_playback_setup()
874 return -ENOENT; in spdif_passthru_playback_setup()
877 mutex_lock(&atc->atc_mutex); in spdif_passthru_playback_setup()
878 dao->ops->get_spos(dao, &status); in spdif_passthru_playback_setup()
882 dao->ops->set_spos(dao, status); in spdif_passthru_playback_setup()
883 dao->ops->commit_write(dao); in spdif_passthru_playback_setup()
885 if ((rate != atc->pll_rate) && (32000 != rate)) in spdif_passthru_playback_setup()
887 mutex_unlock(&atc->atc_mutex); in spdif_passthru_playback_setup()
895 struct src *src; in spdif_passthru_playback_prepare() local
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()
918 amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); in spdif_passthru_playback_prepare()
919 src = src->ops->next_interleave(src); in spdif_passthru_playback_prepare()
920 if (!src) in spdif_passthru_playback_prepare()
921 src = apcm->src; in spdif_passthru_playback_prepare()
924 mutex_lock(&atc->atc_mutex); in spdif_passthru_playback_prepare()
925 dao = container_of(atc->daios[SPDIFOO], struct dao, daio); in spdif_passthru_playback_prepare()
926 amixer = apcm->amixers[0]; in spdif_passthru_playback_prepare()
927 dao->ops->set_left_input(dao, &amixer->rsc); in spdif_passthru_playback_prepare()
928 amixer = apcm->amixers[1]; in spdif_passthru_playback_prepare()
929 dao->ops->set_right_input(dao, &amixer->rsc); in spdif_passthru_playback_prepare()
930 mutex_unlock(&atc->atc_mutex); in spdif_passthru_playback_prepare()
932 ct_timer_prepare(apcm->timer); in spdif_passthru_playback_prepare()
939 struct hw *hw = atc->hw; in atc_select_line_in()
940 struct ct_mixer *mixer = atc->mixer; in atc_select_line_in()
941 struct src *src; in atc_select_line_in() local
943 if (hw->is_adc_source_selected(hw, ADC_LINEIN)) in atc_select_line_in()
946 mixer->set_input_left(mixer, MIX_MIC_IN, NULL); in atc_select_line_in()
947 mixer->set_input_right(mixer, MIX_MIC_IN, NULL); in atc_select_line_in()
949 hw->select_adc_source(hw, ADC_LINEIN); in atc_select_line_in()
951 src = atc->srcs[2]; in atc_select_line_in()
952 mixer->set_input_left(mixer, MIX_LINE_IN, &src->rsc); in atc_select_line_in()
953 src = atc->srcs[3]; in atc_select_line_in()
954 mixer->set_input_right(mixer, MIX_LINE_IN, &src->rsc); in atc_select_line_in()
961 struct hw *hw = atc->hw; in atc_select_mic_in()
962 struct ct_mixer *mixer = atc->mixer; in atc_select_mic_in()
963 struct src *src; in atc_select_mic_in() local
965 if (hw->is_adc_source_selected(hw, ADC_MICIN)) in atc_select_mic_in()
968 mixer->set_input_left(mixer, MIX_LINE_IN, NULL); in atc_select_mic_in()
969 mixer->set_input_right(mixer, MIX_LINE_IN, NULL); in atc_select_mic_in()
971 hw->select_adc_source(hw, ADC_MICIN); in atc_select_mic_in()
973 src = atc->srcs[2]; in atc_select_mic_in()
974 mixer->set_input_left(mixer, MIX_MIC_IN, &src->rsc); in atc_select_mic_in()
975 src = atc->srcs[3]; in atc_select_mic_in()
976 mixer->set_input_right(mixer, MIX_MIC_IN, &src->rsc); in atc_select_mic_in()
983 struct hw *hw = atc->hw; in atc_capabilities()
985 return hw->capabilities(hw); in atc_capabilities()
990 struct hw *hw = atc->hw; in atc_output_switch_get()
992 return hw->output_switch_get(hw); in atc_output_switch_get()
997 struct hw *hw = atc->hw; in atc_output_switch_put()
999 return hw->output_switch_put(hw, position); in atc_output_switch_put()
1004 struct hw *hw = atc->hw; in atc_mic_source_switch_get()
1006 return hw->mic_source_switch_get(hw); in atc_mic_source_switch_get()
1011 struct hw *hw = atc->hw; in atc_mic_source_switch_put()
1013 return hw->mic_source_switch_put(hw, position); in atc_mic_source_switch_put()
1018 struct hw *hw = atc->hw; in atc_select_digit_io()
1020 if (hw->is_adc_source_selected(hw, ADC_NONE)) in atc_select_digit_io()
1023 hw->select_adc_source(hw, ADC_NONE); in atc_select_digit_io()
1030 struct daio_mgr *daio_mgr = atc->rsc_mgrs[DAIO]; in atc_daio_unmute()
1033 daio_mgr->daio_enable(daio_mgr, atc->daios[type]); in atc_daio_unmute()
1035 daio_mgr->daio_disable(daio_mgr, atc->daios[type]); in atc_daio_unmute()
1037 daio_mgr->commit_write(daio_mgr); in atc_daio_unmute()
1045 struct dao *dao = container_of(atc->daios[type], struct dao, daio); in atc_dao_get_status()
1046 return dao->ops->get_spos(dao, status); in atc_dao_get_status()
1052 struct dao *dao = container_of(atc->daios[type], struct dao, daio); in atc_dao_set_status()
1054 dao->ops->set_spos(dao, status); in atc_dao_set_status()
1055 dao->ops->commit_write(dao); in atc_dao_set_status()
1114 struct ct_mixer *mixer = atc->mixer; in atc_spdif_out_passthru()
1118 mutex_lock(&atc->atc_mutex); in atc_spdif_out_passthru()
1119 dao = container_of(atc->daios[SPDIFOO], struct dao, daio); in atc_spdif_out_passthru()
1120 da_dsc.msr = state ? 1 : atc->msr; in atc_spdif_out_passthru()
1122 err = dao->ops->reinit(dao, &da_dsc); in atc_spdif_out_passthru()
1126 mixer->get_output_ports(mixer, MIX_SPDIF_OUT, in atc_spdif_out_passthru()
1128 dao->ops->set_left_input(dao, rscs[0]); in atc_spdif_out_passthru()
1129 dao->ops->set_right_input(dao, rscs[1]); in atc_spdif_out_passthru()
1130 /* Restore PLL to atc->rsr if needed. */ in atc_spdif_out_passthru()
1131 if (atc->pll_rate != atc->rsr) in atc_spdif_out_passthru()
1132 err = atc_pll_init(atc, atc->rsr); in atc_spdif_out_passthru()
1134 dao->ops->set_spos(dao, spos); in atc_spdif_out_passthru()
1135 dao->ops->commit_write(dao); in atc_spdif_out_passthru()
1136 mutex_unlock(&atc->atc_mutex); in atc_spdif_out_passthru()
1154 if (atc->mixer) { in atc_release_resources()
1155 mixer = atc->mixer; in atc_release_resources()
1156 mixer->set_input_left(mixer, MIX_LINE_IN, NULL); in atc_release_resources()
1157 mixer->set_input_right(mixer, MIX_LINE_IN, NULL); in atc_release_resources()
1158 mixer->set_input_left(mixer, MIX_MIC_IN, NULL); in atc_release_resources()
1159 mixer->set_input_right(mixer, MIX_MIC_IN, NULL); in atc_release_resources()
1160 mixer->set_input_left(mixer, MIX_SPDIF_IN, NULL); in atc_release_resources()
1161 mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL); in atc_release_resources()
1164 if (atc->daios) { in atc_release_resources()
1165 daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; in atc_release_resources()
1166 for (i = 0; i < atc->n_daio; i++) { in atc_release_resources()
1167 daio = atc->daios[i]; in atc_release_resources()
1168 if (daio->type < LINEIM) { in atc_release_resources()
1170 dao->ops->clear_left_input(dao); in atc_release_resources()
1171 dao->ops->clear_right_input(dao); in atc_release_resources()
1173 daio_mgr->put_daio(daio_mgr, daio); in atc_release_resources()
1175 kfree(atc->daios); in atc_release_resources()
1176 atc->daios = NULL; in atc_release_resources()
1179 if (atc->pcm) { in atc_release_resources()
1180 sum_mgr = atc->rsc_mgrs[SUM]; in atc_release_resources()
1181 for (i = 0; i < atc->n_pcm; i++) in atc_release_resources()
1182 sum_mgr->put_sum(sum_mgr, atc->pcm[i]); in atc_release_resources()
1184 kfree(atc->pcm); in atc_release_resources()
1185 atc->pcm = NULL; in atc_release_resources()
1188 if (atc->srcs) { in atc_release_resources()
1189 src_mgr = atc->rsc_mgrs[SRC]; in atc_release_resources()
1190 for (i = 0; i < atc->n_src; i++) in atc_release_resources()
1191 src_mgr->put_src(src_mgr, atc->srcs[i]); in atc_release_resources()
1193 kfree(atc->srcs); in atc_release_resources()
1194 atc->srcs = NULL; in atc_release_resources()
1197 if (atc->srcimps) { in atc_release_resources()
1198 srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_release_resources()
1199 for (i = 0; i < atc->n_srcimp; i++) { in atc_release_resources()
1200 srcimp = atc->srcimps[i]; in atc_release_resources()
1201 srcimp->ops->unmap(srcimp); in atc_release_resources()
1202 srcimp_mgr->put_srcimp(srcimp_mgr, atc->srcimps[i]); in atc_release_resources()
1204 kfree(atc->srcimps); in atc_release_resources()
1205 atc->srcimps = NULL; in atc_release_resources()
1218 if (atc->timer) { in ct_atc_destroy()
1219 ct_timer_free(atc->timer); in ct_atc_destroy()
1220 atc->timer = NULL; in ct_atc_destroy()
1226 if (atc->mixer) in ct_atc_destroy()
1227 ct_mixer_destroy(atc->mixer); in ct_atc_destroy()
1230 if (rsc_mgr_funcs[i].destroy && atc->rsc_mgrs[i]) in ct_atc_destroy()
1231 rsc_mgr_funcs[i].destroy(atc->rsc_mgrs[i]); in ct_atc_destroy()
1235 if (atc->hw) in ct_atc_destroy()
1236 destroy_hw_obj(atc->hw); in ct_atc_destroy()
1239 if (atc->vm) { in ct_atc_destroy()
1240 ct_vm_destroy(atc->vm); in ct_atc_destroy()
1241 atc->vm = NULL; in ct_atc_destroy()
1251 struct ct_atc *atc = dev->device_data; in atc_dev_free()
1261 switch (atc->chip_type) { in atc_identify_card()
1263 atc->chip_name = "20K1"; in atc_identify_card()
1267 atc->chip_name = "20K2"; in atc_identify_card()
1271 return -ENOENT; in atc_identify_card()
1277 vendor_id = atc->pci->subsystem_vendor; in atc_identify_card()
1278 device_id = atc->pci->subsystem_device; in atc_identify_card()
1282 if (p->value < 0) { in atc_identify_card()
1283 dev_err(atc->card->dev, in atc_identify_card()
1286 return -ENOENT; in atc_identify_card()
1288 atc->model = p->value; in atc_identify_card()
1290 if (atc->chip_type == ATC20K1) in atc_identify_card()
1291 atc->model = CT20K1_UNKNOWN; in atc_identify_card()
1293 atc->model = CT20K2_UNKNOWN; in atc_identify_card()
1295 atc->model_name = ct_subsys_name[atc->model]; in atc_identify_card()
1296 dev_info(atc->card->dev, "chip %s model %s (%04x:%04x) is found\n", in atc_identify_card()
1297 atc->chip_name, atc->model_name, in atc_identify_card()
1307 alsa_dev_funcs[MIXER].public_name = atc->chip_name; in ct_atc_create_alsa_devs()
1316 dev_err(atc->card->dev, in ct_atc_create_alsa_devs()
1331 err = create_hw_obj(atc->pci, atc->chip_type, atc->model, &hw); in atc_create_hw_devs()
1333 dev_err(atc->card->dev, "Failed to create hw obj!!!\n"); in atc_create_hw_devs()
1336 hw->card = atc->card; in atc_create_hw_devs()
1337 atc->hw = hw; in atc_create_hw_devs()
1340 info.rsr = atc->rsr; in atc_create_hw_devs()
1341 info.msr = atc->msr; in atc_create_hw_devs()
1343 err = hw->card_init(hw, &info); in atc_create_hw_devs()
1351 err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]); in atc_create_hw_devs()
1353 dev_err(atc->card->dev, in atc_create_hw_devs()
1374 num_daios = ((atc->model == CTSB1270) ? 8 : 7); in atc_get_resources()
1375 num_srcs = ((atc->model == CTSB1270) ? 6 : 4); in atc_get_resources()
1377 atc->daios = kcalloc(num_daios, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1378 if (!atc->daios) in atc_get_resources()
1379 return -ENOMEM; in atc_get_resources()
1381 atc->srcs = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1382 if (!atc->srcs) in atc_get_resources()
1383 return -ENOMEM; in atc_get_resources()
1385 atc->srcimps = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1386 if (!atc->srcimps) in atc_get_resources()
1387 return -ENOMEM; in atc_get_resources()
1389 atc->pcm = kcalloc(2 * 4, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1390 if (!atc->pcm) in atc_get_resources()
1391 return -ENOMEM; in atc_get_resources()
1393 daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; in atc_get_resources()
1394 da_desc.msr = atc->msr; in atc_get_resources()
1395 for (i = 0, atc->n_daio = 0; i < num_daios; i++) { in atc_get_resources()
1396 da_desc.type = (atc->model != CTSB073X) ? i : in atc_get_resources()
1398 err = daio_mgr->get_daio(daio_mgr, &da_desc, in atc_get_resources()
1399 (struct daio **)&atc->daios[i]); in atc_get_resources()
1401 dev_err(atc->card->dev, in atc_get_resources()
1406 atc->n_daio++; in atc_get_resources()
1409 src_mgr = atc->rsc_mgrs[SRC]; in atc_get_resources()
1411 src_dsc.msr = atc->msr; in atc_get_resources()
1413 for (i = 0, atc->n_src = 0; i < num_srcs; i++) { in atc_get_resources()
1414 err = src_mgr->get_src(src_mgr, &src_dsc, in atc_get_resources()
1415 (struct src **)&atc->srcs[i]); in atc_get_resources()
1419 atc->n_src++; in atc_get_resources()
1422 srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_get_resources()
1424 for (i = 0, atc->n_srcimp = 0; i < num_srcs; i++) { in atc_get_resources()
1425 err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc, in atc_get_resources()
1426 (struct srcimp **)&atc->srcimps[i]); in atc_get_resources()
1430 atc->n_srcimp++; in atc_get_resources()
1433 sum_mgr = atc->rsc_mgrs[SUM]; in atc_get_resources()
1434 sum_dsc.msr = atc->msr; in atc_get_resources()
1435 for (i = 0, atc->n_pcm = 0; i < (2*4); i++) { in atc_get_resources()
1436 err = sum_mgr->get_sum(sum_mgr, &sum_dsc, in atc_get_resources()
1437 (struct sum **)&atc->pcm[i]); in atc_get_resources()
1441 atc->n_pcm++; in atc_get_resources()
1449 struct src **srcs, struct srcimp **srcimps) in atc_connect_dai()
1452 struct src *src; in atc_connect_dai() local
1456 rscs[0] = &dai->daio.rscl; in atc_connect_dai()
1457 rscs[1] = &dai->daio.rscr; in atc_connect_dai()
1459 src = srcs[i]; in atc_connect_dai()
1461 srcimp->ops->map(srcimp, src, rscs[i]); in atc_connect_dai()
1462 src_mgr->src_disable(src_mgr, src); in atc_connect_dai()
1465 src_mgr->commit_write(src_mgr); /* Actually disable SRCs */ in atc_connect_dai()
1467 src = srcs[0]; in atc_connect_dai()
1468 src->ops->set_pm(src, 1); in atc_connect_dai()
1470 src = srcs[i]; in atc_connect_dai()
1471 src->ops->set_state(src, SRC_STATE_RUN); in atc_connect_dai()
1472 src->ops->commit_write(src); in atc_connect_dai()
1473 src_mgr->src_enable_s(src_mgr, src); in atc_connect_dai()
1476 dai->ops->set_srt_srcl(dai, &(srcs[0]->rsc)); in atc_connect_dai()
1477 dai->ops->set_srt_srcr(dai, &(srcs[1]->rsc)); in atc_connect_dai()
1479 dai->ops->set_enb_src(dai, 1); in atc_connect_dai()
1480 dai->ops->set_enb_srt(dai, 1); in atc_connect_dai()
1481 dai->ops->commit_write(dai); in atc_connect_dai()
1483 src_mgr->commit_write(src_mgr); /* Synchronously enable SRCs */ in atc_connect_dai()
1490 struct src *src; in atc_connect_resources() local
1496 mixer = atc->mixer; in atc_connect_resources()
1499 mixer->get_output_ports(mixer, i, &rscs[0], &rscs[1]); in atc_connect_resources()
1500 dao = container_of(atc->daios[j], struct dao, daio); in atc_connect_resources()
1501 dao->ops->set_left_input(dao, rscs[0]); in atc_connect_resources()
1502 dao->ops->set_right_input(dao, rscs[1]); in atc_connect_resources()
1505 dai = container_of(atc->daios[LINEIM], struct dai, daio); in atc_connect_resources()
1506 atc_connect_dai(atc->rsc_mgrs[SRC], dai, in atc_connect_resources()
1507 (struct src **)&atc->srcs[2], in atc_connect_resources()
1508 (struct srcimp **)&atc->srcimps[2]); in atc_connect_resources()
1509 src = atc->srcs[2]; in atc_connect_resources()
1510 mixer->set_input_left(mixer, MIX_LINE_IN, &src->rsc); in atc_connect_resources()
1511 src = atc->srcs[3]; in atc_connect_resources()
1512 mixer->set_input_right(mixer, MIX_LINE_IN, &src->rsc); in atc_connect_resources()
1514 if (atc->model == CTSB1270) { in atc_connect_resources()
1516 dai = container_of(atc->daios[MIC], struct dai, daio); in atc_connect_resources()
1517 atc_connect_dai(atc->rsc_mgrs[SRC], dai, in atc_connect_resources()
1518 (struct src **)&atc->srcs[4], in atc_connect_resources()
1519 (struct srcimp **)&atc->srcimps[4]); in atc_connect_resources()
1520 src = atc->srcs[4]; in atc_connect_resources()
1521 mixer->set_input_left(mixer, MIX_MIC_IN, &src->rsc); in atc_connect_resources()
1522 src = atc->srcs[5]; in atc_connect_resources()
1523 mixer->set_input_right(mixer, MIX_MIC_IN, &src->rsc); in atc_connect_resources()
1526 dai = container_of(atc->daios[SPDIFIO], struct dai, daio); in atc_connect_resources()
1527 atc_connect_dai(atc->rsc_mgrs[SRC], dai, in atc_connect_resources()
1528 (struct src **)&atc->srcs[0], in atc_connect_resources()
1529 (struct srcimp **)&atc->srcimps[0]); in atc_connect_resources()
1531 src = atc->srcs[0]; in atc_connect_resources()
1532 mixer->set_input_left(mixer, MIX_SPDIF_IN, &src->rsc); in atc_connect_resources()
1533 src = atc->srcs[1]; in atc_connect_resources()
1534 mixer->set_input_right(mixer, MIX_SPDIF_IN, &src->rsc); in atc_connect_resources()
1537 sum = atc->pcm[j]; in atc_connect_resources()
1538 mixer->set_input_left(mixer, i, &sum->rsc); in atc_connect_resources()
1539 sum = atc->pcm[j+1]; in atc_connect_resources()
1540 mixer->set_input_right(mixer, i, &sum->rsc); in atc_connect_resources()
1547 struct hw *hw = atc->hw; in atc_suspend()
1549 snd_power_change_state(atc->card, SNDRV_CTL_POWER_D3hot); in atc_suspend()
1553 hw->suspend(hw); in atc_suspend()
1560 struct hw *hw = atc->hw; in atc_hw_resume()
1563 /* Re-initialize card hardware. */ in atc_hw_resume()
1564 info.rsr = atc->rsr; in atc_hw_resume()
1565 info.msr = atc->msr; in atc_hw_resume()
1567 return hw->resume(hw, &info); in atc_hw_resume()
1585 mixer = atc->mixer; in atc_resources_resume()
1586 mixer->resume(mixer); in atc_resources_resume()
1598 dev_err(atc->card->dev, in atc_resume()
1600 snd_card_disconnect(atc->card); in atc_resume()
1608 snd_power_change_state(atc->card, SNDRV_CTL_POWER_D0); in atc_resume()
1654 * ct_atc_create - create and initialize a hardware manager
1684 return -ENOMEM; in ct_atc_create()
1689 atc->card = card; in ct_atc_create()
1690 atc->pci = pci; in ct_atc_create()
1691 atc->rsr = rsr; in ct_atc_create()
1692 atc->msr = msr; in ct_atc_create()
1693 atc->chip_type = chip_type; in ct_atc_create()
1695 mutex_init(&atc->atc_mutex); in ct_atc_create()
1700 dev_err(card->dev, "ctatc: Card not recognised\n"); in ct_atc_create()
1705 err = ct_vm_create(&atc->vm, pci); in ct_atc_create()
1714 err = ct_mixer_create(atc, (struct ct_mixer **)&atc->mixer); in ct_atc_create()
1716 dev_err(card->dev, "Failed to create mixer obj!!!\n"); in ct_atc_create()
1728 atc->timer = ct_timer_new(atc); in ct_atc_create()
1729 if (!atc->timer) { in ct_atc_create()
1730 err = -ENOMEM; in ct_atc_create()
1743 dev_err(card->dev, "Something wrong!!!\n"); in ct_atc_create()