Lines Matching +full:multi +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
28 #define MONO_SUM_SCALE 0x19a8 /* 2^(-0.5) in 14-bit floating format */
99 .public_name = "IEC958 Non-audio"},
138 if (!apcm->substream) in ct_map_audio_buffer()
141 runtime = apcm->substream->runtime; in ct_map_audio_buffer()
142 vm = atc->vm; 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()
147 return -ENOENT; in ct_map_audio_buffer()
156 if (!apcm->vm_block) in ct_unmap_audio_buffer()
159 vm = atc->vm; 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()
168 return atc->vm->get_ptp_phys(atc->vm, index); in atc_get_ptp_phys()
186 dev_err(card->dev, "not recognized snd format is %d\n", in convert_format()
198 /* get pitch and convert to fixed-point 8.24 format. */ in atc_get_pitch()
204 b--; in atc_get_pitch()
207 input_rate <<= (31 - b); in atc_get_pitch()
209 b = 24 - (31 - b); in atc_get_pitch()
213 input_rate >>= -b; in atc_get_pitch()
236 return -ENOENT; in select_rom()
242 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_playback_prepare()
243 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in atc_pcm_playback_prepare()
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()
257 desc.multi = apcm->substream->runtime->channels; in atc_pcm_playback_prepare()
258 desc.msr = atc->msr; 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()
265 (atc->rsr * atc->msr)); in atc_pcm_playback_prepare()
266 src = apcm->src; in atc_pcm_playback_prepare()
267 src->ops->set_pitch(src, pitch); in atc_pcm_playback_prepare()
268 src->ops->set_rom(src, select_rom(pitch)); in atc_pcm_playback_prepare()
269 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in atc_pcm_playback_prepare()
270 atc->card)); in atc_pcm_playback_prepare()
271 src->ops->set_pm(src, (src->ops->next_interleave(src) != NULL)); 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()
277 err = -ENOMEM; in atc_pcm_playback_prepare()
280 mix_dsc.msr = atc->msr; in atc_pcm_playback_prepare()
281 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in atc_pcm_playback_prepare()
282 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc, 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()
296 src = apcm->src; in atc_pcm_playback_prepare()
298 amixer = apcm->amixers[i]; in atc_pcm_playback_prepare()
299 mutex_lock(&atc->atc_mutex); in atc_pcm_playback_prepare()
300 amixer->ops->setup(amixer, &src->rsc, in atc_pcm_playback_prepare()
301 INIT_VOL, atc->pcm[i+device*2]); in atc_pcm_playback_prepare()
302 mutex_unlock(&atc->atc_mutex); in atc_pcm_playback_prepare()
303 src = src->ops->next_interleave(src); 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()
320 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_release_resources()
321 struct srcimp_mgr *srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_pcm_release_resources()
322 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in atc_pcm_release_resources()
323 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM]; in atc_pcm_release_resources()
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()
330 srcimp->ops->unmap(srcimp); in atc_pcm_release_resources()
331 srcimp_mgr->put_srcimp(srcimp_mgr, srcimp); 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()
369 apcm->vm_block = NULL; in atc_pcm_release_resources()
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()
384 max_cisz = src->multi * src->rsc.msr; 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()
390 src->ops->set_cisz(src, max_cisz); in atc_pcm_playback_start()
392 src->ops->set_bm(src, 1); in atc_pcm_playback_start()
393 src->ops->set_state(src, SRC_STATE_INIT); in atc_pcm_playback_start()
394 src->ops->commit_write(src); in atc_pcm_playback_start()
396 ct_timer_start(apcm->timer); in atc_pcm_playback_start()
405 ct_timer_stop(apcm->timer); in atc_pcm_stop()
407 src = apcm->src; in atc_pcm_stop()
408 src->ops->set_bm(src, 0); in atc_pcm_stop()
409 src->ops->set_state(src, SRC_STATE_OFF); in atc_pcm_stop()
410 src->ops->commit_write(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()
415 src->ops->set_bm(src, 0); in atc_pcm_stop()
416 src->ops->set_state(src, SRC_STATE_OFF); in atc_pcm_stop()
417 src->ops->commit_write(src); in atc_pcm_stop()
421 apcm->started = 0; in atc_pcm_stop()
429 struct src *src = apcm->src; in atc_pcm_playback_position()
435 position = src->ops->get_ca(src); in atc_pcm_playback_position()
437 if (position < apcm->vm_block->addr) { in atc_pcm_playback_position()
438 dev_dbg(atc->card->dev, in atc_pcm_playback_position()
439 "bad ca - ca=0x%08x, vba=0x%08x, vbs=0x%08x\n", 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()
445 max_cisz = src->multi * src->rsc.msr; in atc_pcm_playback_position()
448 return (position + size - max_cisz - apcm->vm_block->addr) % size; in atc_pcm_playback_position()
464 /* get pitch and convert to fixed-point 8.24 format. */ in setup_src_node_conf()
465 pitch = atc_get_pitch((atc->rsr * atc->msr), in setup_src_node_conf()
466 apcm->substream->runtime->rate); in setup_src_node_conf()
469 if (1 == atc->msr) { /* FIXME: do we really need SRC here if pitch==1 */ in setup_src_node_conf()
470 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
474 } else if (2 <= atc->msr) { in setup_src_node_conf()
476 /* Need two-stage SRCs, SRCIMPs and in setup_src_node_conf()
478 conf[0].pitch = (atc->msr << 24); in setup_src_node_conf()
480 conf[0].imp_msr = atc->msr; in setup_src_node_conf()
482 conf[1].pitch = atc_get_pitch(atc->rsr, 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()
488 /* Need one-stage SRCs, SRCIMPs and in setup_src_node_conf()
492 = conf[0].imp_msr = atc->msr; in setup_src_node_conf()
494 *n_srcc = apcm->substream->runtime->channels; in setup_src_node_conf()
502 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_capture_get_resources()
503 struct srcimp_mgr *srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_pcm_capture_get_resources()
504 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in atc_pcm_capture_get_resources()
505 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM]; in atc_pcm_capture_get_resources()
513 int multi, err, i; in atc_pcm_capture_get_resources() local
523 multi = apcm->substream->runtime->channels; in atc_pcm_capture_get_resources()
525 /* get pitch and convert to fixed-point 8.24 format. */ in atc_pcm_capture_get_resources()
526 pitch = atc_get_pitch((atc->rsr * atc->msr), in atc_pcm_capture_get_resources()
527 apcm->substream->runtime->rate); in atc_pcm_capture_get_resources()
530 n_sum = (1 == multi) ? 1 : 0; in atc_pcm_capture_get_resources()
533 if ((multi > 1) && (0x8000000 >= pitch)) { in atc_pcm_capture_get_resources()
536 n_amixer += multi * atc->msr; in atc_pcm_capture_get_resources()
537 n_srcimp += multi * atc->msr; in atc_pcm_capture_get_resources()
539 n_srcimp += multi; 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()
545 return -ENOMEM; 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()
550 err = -ENOMEM; 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()
556 err = -ENOMEM; in atc_pcm_capture_get_resources()
561 src_dsc.multi = 1; in atc_pcm_capture_get_resources()
563 for (i = 0, apcm->n_srcc = 0; i < n_srcc; i++) { in atc_pcm_capture_get_resources()
564 src_dsc.msr = src_node_conf[i/multi].msr; in atc_pcm_capture_get_resources()
565 err = src_mgr->get_src(src_mgr, &src_dsc, 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()
571 pitch = src_node_conf[i/multi].pitch; in atc_pcm_capture_get_resources()
572 src->ops->set_pitch(src, pitch); in atc_pcm_capture_get_resources()
573 src->ops->set_rom(src, select_rom(pitch)); in atc_pcm_capture_get_resources()
574 src->ops->set_vo(src, src_node_conf[i/multi].vo); 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()
582 mix_dsc.msr = atc->msr; in atc_pcm_capture_get_resources()
584 mix_dsc.msr = src_node_conf[(i-n_sum*2)/multi].mix_msr; in atc_pcm_capture_get_resources()
588 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc, 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()
597 sum_dsc.msr = atc->msr; 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()
602 pitch = atc_get_pitch((atc->rsr * atc->msr), 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()
607 srcimp_dsc.msr = src_node_conf[i/multi].imp_msr; in atc_pcm_capture_get_resources()
608 else if (1 == multi) in atc_pcm_capture_get_resources()
609 srcimp_dsc.msr = (pitch <= 0x8000000) ? atc->msr : 1; in atc_pcm_capture_get_resources()
613 err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc, &srcimp); 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()
630 src->ops->set_pitch(src, pitch); in atc_pcm_capture_get_resources()
649 struct ct_mixer *mixer = atc->mixer; in atc_pcm_capture_prepare()
652 int err, i, j, n_sum, multi; in atc_pcm_capture_prepare() local
664 mixer->get_output_ports(mixer, MIX_PCMO_FRONT, in atc_pcm_capture_prepare()
667 multi = apcm->substream->runtime->channels; in atc_pcm_capture_prepare()
668 if (1 == multi) { in atc_pcm_capture_prepare()
669 mono = apcm->mono; in atc_pcm_capture_prepare()
671 amixer = apcm->amixers[i]; in atc_pcm_capture_prepare()
672 amixer->ops->setup(amixer, out_ports[i], in atc_pcm_capture_prepare()
675 out_ports[0] = &mono->rsc; 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()
684 srcimp->ops->map(srcimp, src, out_ports[i%multi]); in atc_pcm_capture_prepare()
685 amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); in atc_pcm_capture_prepare()
686 out_ports[i%multi] = &amixer->rsc; in atc_pcm_capture_prepare()
689 pitch = atc_get_pitch((atc->rsr * atc->msr), in atc_pcm_capture_prepare()
690 apcm->substream->runtime->rate); in atc_pcm_capture_prepare()
692 if ((multi > 1) && (pitch <= 0x8000000)) { in atc_pcm_capture_prepare()
695 for (i = 0; i < multi; i++) { in atc_pcm_capture_prepare()
696 out_ports[i]->ops->master(out_ports[i]); in atc_pcm_capture_prepare()
697 for (j = 0; j < atc->msr; j++) { in atc_pcm_capture_prepare()
698 amixer = apcm->amixers[apcm->n_srcc+j*multi+i]; in atc_pcm_capture_prepare()
699 amixer->ops->set_input(amixer, out_ports[i]); in atc_pcm_capture_prepare()
700 amixer->ops->set_scale(amixer, INIT_VOL); in atc_pcm_capture_prepare()
701 amixer->ops->set_sum(amixer, NULL); in atc_pcm_capture_prepare()
702 amixer->ops->commit_raw_write(amixer); in atc_pcm_capture_prepare()
703 out_ports[i]->ops->next_conj(out_ports[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()
707 &amixer->rsc); in atc_pcm_capture_prepare()
711 for (i = 0; i < multi; i++) { 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()
725 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in atc_pcm_capture_start()
726 int i, multi; in atc_pcm_capture_start() local
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()
736 src->ops->set_pm(src, ((i%multi) != (multi-1))); in atc_pcm_capture_start()
737 src_mgr->src_disable(src_mgr, src); 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()
743 atc->card)); 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()
747 src_mgr->src_disable(src_mgr, src); in atc_pcm_capture_start()
750 src_mgr->commit_write(src_mgr); 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()
755 src->ops->set_state(src, SRC_STATE_RUN); in atc_pcm_capture_start()
756 src->ops->commit_write(src); in atc_pcm_capture_start()
757 src_mgr->src_enable_s(src_mgr, src); in atc_pcm_capture_start()
759 src = apcm->src; in atc_pcm_capture_start()
760 src->ops->set_bm(src, 1); in atc_pcm_capture_start()
761 src->ops->set_state(src, SRC_STATE_RUN); in atc_pcm_capture_start()
762 src->ops->commit_write(src); in atc_pcm_capture_start()
763 src_mgr->src_enable_s(src_mgr, src); in atc_pcm_capture_start()
766 src_mgr->commit_write(src_mgr); in atc_pcm_capture_start()
768 ct_timer_start(apcm->timer); in atc_pcm_capture_start()
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()
785 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; in spdif_passthru_playback_get_resources()
786 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; in spdif_passthru_playback_get_resources()
791 int n_amixer = apcm->substream->runtime->channels, i; in spdif_passthru_playback_get_resources()
792 unsigned int pitch, rsr = atc->pll_rate; 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()
810 src->ops->set_pitch(src, pitch); in spdif_passthru_playback_get_resources()
811 src->ops->set_rom(src, select_rom(pitch)); in spdif_passthru_playback_get_resources()
812 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format, in spdif_passthru_playback_get_resources()
813 atc->card)); in spdif_passthru_playback_get_resources()
814 src->ops->set_pm(src, (src->ops->next_interleave(src) != NULL)); in spdif_passthru_playback_get_resources()
815 src->ops->set_bp(src, 1); 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()
821 err = -ENOMEM; in spdif_passthru_playback_get_resources()
825 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) { in spdif_passthru_playback_get_resources()
826 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc, 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()
848 struct hw *hw = atc->hw; in atc_pll_init()
850 err = hw->pll_init(hw, rate); in atc_pll_init()
851 atc->pll_rate = err ? 0 : rate; in atc_pll_init()
858 struct dao *dao = container_of(atc->daios[SPDIFOO], struct dao, daio); in spdif_passthru_playback_setup()
859 unsigned int rate = apcm->substream->runtime->rate; in spdif_passthru_playback_setup()
875 return -ENOENT; in spdif_passthru_playback_setup()
878 mutex_lock(&atc->atc_mutex); in spdif_passthru_playback_setup()
879 dao->ops->get_spos(dao, &status); in spdif_passthru_playback_setup()
883 dao->ops->set_spos(dao, status); in spdif_passthru_playback_setup()
884 dao->ops->commit_write(dao); in spdif_passthru_playback_setup()
886 if ((rate != atc->pll_rate) && (32000 != rate)) in spdif_passthru_playback_setup()
888 mutex_unlock(&atc->atc_mutex); in spdif_passthru_playback_setup()
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()
919 amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); in spdif_passthru_playback_prepare()
920 src = src->ops->next_interleave(src); in spdif_passthru_playback_prepare()
922 src = apcm->src; in spdif_passthru_playback_prepare()
925 mutex_lock(&atc->atc_mutex); in spdif_passthru_playback_prepare()
926 dao = container_of(atc->daios[SPDIFOO], struct dao, daio); in spdif_passthru_playback_prepare()
927 amixer = apcm->amixers[0]; in spdif_passthru_playback_prepare()
928 dao->ops->set_left_input(dao, &amixer->rsc); in spdif_passthru_playback_prepare()
929 amixer = apcm->amixers[1]; in spdif_passthru_playback_prepare()
930 dao->ops->set_right_input(dao, &amixer->rsc); in spdif_passthru_playback_prepare()
931 mutex_unlock(&atc->atc_mutex); in spdif_passthru_playback_prepare()
933 ct_timer_prepare(apcm->timer); in spdif_passthru_playback_prepare()
940 struct hw *hw = atc->hw; in atc_select_line_in()
941 struct ct_mixer *mixer = atc->mixer; in atc_select_line_in()
944 if (hw->is_adc_source_selected(hw, ADC_LINEIN)) in atc_select_line_in()
947 mixer->set_input_left(mixer, MIX_MIC_IN, NULL); in atc_select_line_in()
948 mixer->set_input_right(mixer, MIX_MIC_IN, NULL); in atc_select_line_in()
950 hw->select_adc_source(hw, ADC_LINEIN); in atc_select_line_in()
952 src = atc->srcs[2]; in atc_select_line_in()
953 mixer->set_input_left(mixer, MIX_LINE_IN, &src->rsc); in atc_select_line_in()
954 src = atc->srcs[3]; in atc_select_line_in()
955 mixer->set_input_right(mixer, MIX_LINE_IN, &src->rsc); in atc_select_line_in()
962 struct hw *hw = atc->hw; in atc_select_mic_in()
963 struct ct_mixer *mixer = atc->mixer; in atc_select_mic_in()
966 if (hw->is_adc_source_selected(hw, ADC_MICIN)) in atc_select_mic_in()
969 mixer->set_input_left(mixer, MIX_LINE_IN, NULL); in atc_select_mic_in()
970 mixer->set_input_right(mixer, MIX_LINE_IN, NULL); in atc_select_mic_in()
972 hw->select_adc_source(hw, ADC_MICIN); in atc_select_mic_in()
974 src = atc->srcs[2]; in atc_select_mic_in()
975 mixer->set_input_left(mixer, MIX_MIC_IN, &src->rsc); in atc_select_mic_in()
976 src = atc->srcs[3]; in atc_select_mic_in()
977 mixer->set_input_right(mixer, MIX_MIC_IN, &src->rsc); in atc_select_mic_in()
984 struct hw *hw = atc->hw; in atc_capabilities()
986 return hw->capabilities(hw); in atc_capabilities()
991 struct hw *hw = atc->hw; in atc_output_switch_get()
993 return hw->output_switch_get(hw); in atc_output_switch_get()
998 struct hw *hw = atc->hw; in atc_output_switch_put()
1000 return hw->output_switch_put(hw, position); in atc_output_switch_put()
1005 struct hw *hw = atc->hw; in atc_mic_source_switch_get()
1007 return hw->mic_source_switch_get(hw); in atc_mic_source_switch_get()
1012 struct hw *hw = atc->hw; in atc_mic_source_switch_put()
1014 return hw->mic_source_switch_put(hw, position); in atc_mic_source_switch_put()
1019 struct hw *hw = atc->hw; in atc_select_digit_io()
1021 if (hw->is_adc_source_selected(hw, ADC_NONE)) in atc_select_digit_io()
1024 hw->select_adc_source(hw, ADC_NONE); in atc_select_digit_io()
1031 struct daio_mgr *daio_mgr = atc->rsc_mgrs[DAIO]; in atc_daio_unmute()
1034 daio_mgr->daio_enable(daio_mgr, atc->daios[type]); in atc_daio_unmute()
1036 daio_mgr->daio_disable(daio_mgr, atc->daios[type]); in atc_daio_unmute()
1038 daio_mgr->commit_write(daio_mgr); in atc_daio_unmute()
1046 struct dao *dao = container_of(atc->daios[type], struct dao, daio); in atc_dao_get_status()
1047 return dao->ops->get_spos(dao, status); in atc_dao_get_status()
1053 struct dao *dao = container_of(atc->daios[type], struct dao, daio); in atc_dao_set_status()
1055 dao->ops->set_spos(dao, status); in atc_dao_set_status()
1056 dao->ops->commit_write(dao); in atc_dao_set_status()
1115 struct ct_mixer *mixer = atc->mixer; in atc_spdif_out_passthru()
1119 mutex_lock(&atc->atc_mutex); in atc_spdif_out_passthru()
1120 dao = container_of(atc->daios[SPDIFOO], struct dao, daio); in atc_spdif_out_passthru()
1121 da_dsc.msr = state ? 1 : atc->msr; in atc_spdif_out_passthru()
1123 err = dao->ops->reinit(dao, &da_dsc); in atc_spdif_out_passthru()
1127 mixer->get_output_ports(mixer, MIX_SPDIF_OUT, in atc_spdif_out_passthru()
1129 dao->ops->set_left_input(dao, rscs[0]); in atc_spdif_out_passthru()
1130 dao->ops->set_right_input(dao, rscs[1]); in atc_spdif_out_passthru()
1131 /* Restore PLL to atc->rsr if needed. */ in atc_spdif_out_passthru()
1132 if (atc->pll_rate != atc->rsr) in atc_spdif_out_passthru()
1133 err = atc_pll_init(atc, atc->rsr); in atc_spdif_out_passthru()
1135 dao->ops->set_spos(dao, spos); in atc_spdif_out_passthru()
1136 dao->ops->commit_write(dao); in atc_spdif_out_passthru()
1137 mutex_unlock(&atc->atc_mutex); in atc_spdif_out_passthru()
1155 if (atc->mixer) { in atc_release_resources()
1156 mixer = atc->mixer; in atc_release_resources()
1157 mixer->set_input_left(mixer, MIX_LINE_IN, NULL); in atc_release_resources()
1158 mixer->set_input_right(mixer, MIX_LINE_IN, NULL); in atc_release_resources()
1159 mixer->set_input_left(mixer, MIX_MIC_IN, NULL); in atc_release_resources()
1160 mixer->set_input_right(mixer, MIX_MIC_IN, NULL); in atc_release_resources()
1161 mixer->set_input_left(mixer, MIX_SPDIF_IN, NULL); in atc_release_resources()
1162 mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL); in atc_release_resources()
1165 if (atc->daios) { in atc_release_resources()
1166 daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; in atc_release_resources()
1167 for (i = 0; i < atc->n_daio; i++) { in atc_release_resources()
1168 daio = atc->daios[i]; in atc_release_resources()
1169 if (daio->type < LINEIM) { in atc_release_resources()
1171 dao->ops->clear_left_input(dao); in atc_release_resources()
1172 dao->ops->clear_right_input(dao); in atc_release_resources()
1174 daio_mgr->put_daio(daio_mgr, daio); in atc_release_resources()
1176 kfree(atc->daios); in atc_release_resources()
1177 atc->daios = NULL; in atc_release_resources()
1180 if (atc->pcm) { in atc_release_resources()
1181 sum_mgr = atc->rsc_mgrs[SUM]; in atc_release_resources()
1182 for (i = 0; i < atc->n_pcm; i++) in atc_release_resources()
1183 sum_mgr->put_sum(sum_mgr, atc->pcm[i]); in atc_release_resources()
1185 kfree(atc->pcm); in atc_release_resources()
1186 atc->pcm = NULL; in atc_release_resources()
1189 if (atc->srcs) { in atc_release_resources()
1190 src_mgr = atc->rsc_mgrs[SRC]; in atc_release_resources()
1191 for (i = 0; i < atc->n_src; i++) in atc_release_resources()
1192 src_mgr->put_src(src_mgr, atc->srcs[i]); in atc_release_resources()
1194 kfree(atc->srcs); in atc_release_resources()
1195 atc->srcs = NULL; in atc_release_resources()
1198 if (atc->srcimps) { in atc_release_resources()
1199 srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_release_resources()
1200 for (i = 0; i < atc->n_srcimp; i++) { in atc_release_resources()
1201 srcimp = atc->srcimps[i]; in atc_release_resources()
1202 srcimp->ops->unmap(srcimp); in atc_release_resources()
1203 srcimp_mgr->put_srcimp(srcimp_mgr, atc->srcimps[i]); in atc_release_resources()
1205 kfree(atc->srcimps); in atc_release_resources()
1206 atc->srcimps = NULL; in atc_release_resources()
1219 if (atc->timer) { in ct_atc_destroy()
1220 ct_timer_free(atc->timer); in ct_atc_destroy()
1221 atc->timer = NULL; in ct_atc_destroy()
1227 if (atc->mixer) in ct_atc_destroy()
1228 ct_mixer_destroy(atc->mixer); in ct_atc_destroy()
1231 if (rsc_mgr_funcs[i].destroy && atc->rsc_mgrs[i]) in ct_atc_destroy()
1232 rsc_mgr_funcs[i].destroy(atc->rsc_mgrs[i]); in ct_atc_destroy()
1236 if (atc->hw) in ct_atc_destroy()
1237 destroy_hw_obj(atc->hw); in ct_atc_destroy()
1240 if (atc->vm) { in ct_atc_destroy()
1241 ct_vm_destroy(atc->vm); in ct_atc_destroy()
1242 atc->vm = NULL; in ct_atc_destroy()
1252 struct ct_atc *atc = dev->device_data; in atc_dev_free()
1262 switch (atc->chip_type) { in atc_identify_card()
1264 atc->chip_name = "20K1"; in atc_identify_card()
1268 atc->chip_name = "20K2"; in atc_identify_card()
1272 return -ENOENT; in atc_identify_card()
1278 vendor_id = atc->pci->subsystem_vendor; in atc_identify_card()
1279 device_id = atc->pci->subsystem_device; in atc_identify_card()
1283 if (p->value < 0) { in atc_identify_card()
1284 dev_err(atc->card->dev, in atc_identify_card()
1287 return -ENOENT; in atc_identify_card()
1289 atc->model = p->value; in atc_identify_card()
1291 if (atc->chip_type == ATC20K1) in atc_identify_card()
1292 atc->model = CT20K1_UNKNOWN; in atc_identify_card()
1294 atc->model = CT20K2_UNKNOWN; in atc_identify_card()
1296 atc->model_name = ct_subsys_name[atc->model]; in atc_identify_card()
1297 dev_info(atc->card->dev, "chip %s model %s (%04x:%04x) is found\n", in atc_identify_card()
1298 atc->chip_name, atc->model_name, in atc_identify_card()
1308 alsa_dev_funcs[MIXER].public_name = atc->chip_name; in ct_atc_create_alsa_devs()
1317 dev_err(atc->card->dev, in ct_atc_create_alsa_devs()
1332 err = create_hw_obj(atc->pci, atc->chip_type, atc->model, &hw); in atc_create_hw_devs()
1334 dev_err(atc->card->dev, "Failed to create hw obj!!!\n"); in atc_create_hw_devs()
1337 hw->card = atc->card; in atc_create_hw_devs()
1338 atc->hw = hw; in atc_create_hw_devs()
1341 info.rsr = atc->rsr; in atc_create_hw_devs()
1342 info.msr = atc->msr; in atc_create_hw_devs()
1344 err = hw->card_init(hw, &info); in atc_create_hw_devs()
1352 err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]); in atc_create_hw_devs()
1354 dev_err(atc->card->dev, in atc_create_hw_devs()
1375 num_daios = ((atc->model == CTSB1270) ? 8 : 7); in atc_get_resources()
1376 num_srcs = ((atc->model == CTSB1270) ? 6 : 4); in atc_get_resources()
1378 atc->daios = kcalloc(num_daios, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1379 if (!atc->daios) in atc_get_resources()
1380 return -ENOMEM; in atc_get_resources()
1382 atc->srcs = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1383 if (!atc->srcs) in atc_get_resources()
1384 return -ENOMEM; in atc_get_resources()
1386 atc->srcimps = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1387 if (!atc->srcimps) in atc_get_resources()
1388 return -ENOMEM; in atc_get_resources()
1390 atc->pcm = kcalloc(2 * 4, sizeof(void *), GFP_KERNEL); in atc_get_resources()
1391 if (!atc->pcm) in atc_get_resources()
1392 return -ENOMEM; in atc_get_resources()
1394 daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; in atc_get_resources()
1395 da_desc.msr = atc->msr; in atc_get_resources()
1396 for (i = 0, atc->n_daio = 0; i < num_daios; i++) { in atc_get_resources()
1397 da_desc.type = (atc->model != CTSB073X) ? i : in atc_get_resources()
1399 err = daio_mgr->get_daio(daio_mgr, &da_desc, in atc_get_resources()
1400 (struct daio **)&atc->daios[i]); in atc_get_resources()
1402 dev_err(atc->card->dev, in atc_get_resources()
1407 atc->n_daio++; in atc_get_resources()
1410 src_mgr = atc->rsc_mgrs[SRC]; in atc_get_resources()
1411 src_dsc.multi = 1; in atc_get_resources()
1412 src_dsc.msr = atc->msr; in atc_get_resources()
1414 for (i = 0, atc->n_src = 0; i < num_srcs; i++) { in atc_get_resources()
1415 err = src_mgr->get_src(src_mgr, &src_dsc, in atc_get_resources()
1416 (struct src **)&atc->srcs[i]); in atc_get_resources()
1420 atc->n_src++; in atc_get_resources()
1423 srcimp_mgr = atc->rsc_mgrs[SRCIMP]; in atc_get_resources()
1425 for (i = 0, atc->n_srcimp = 0; i < num_srcs; i++) { in atc_get_resources()
1426 err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc, in atc_get_resources()
1427 (struct srcimp **)&atc->srcimps[i]); in atc_get_resources()
1431 atc->n_srcimp++; in atc_get_resources()
1434 sum_mgr = atc->rsc_mgrs[SUM]; in atc_get_resources()
1435 sum_dsc.msr = atc->msr; in atc_get_resources()
1436 for (i = 0, atc->n_pcm = 0; i < (2*4); i++) { in atc_get_resources()
1437 err = sum_mgr->get_sum(sum_mgr, &sum_dsc, in atc_get_resources()
1438 (struct sum **)&atc->pcm[i]); in atc_get_resources()
1442 atc->n_pcm++; in atc_get_resources()
1457 rscs[0] = &dai->daio.rscl; in atc_connect_dai()
1458 rscs[1] = &dai->daio.rscr; in atc_connect_dai()
1462 srcimp->ops->map(srcimp, src, rscs[i]); in atc_connect_dai()
1463 src_mgr->src_disable(src_mgr, src); in atc_connect_dai()
1466 src_mgr->commit_write(src_mgr); /* Actually disable SRCs */ in atc_connect_dai()
1469 src->ops->set_pm(src, 1); in atc_connect_dai()
1472 src->ops->set_state(src, SRC_STATE_RUN); in atc_connect_dai()
1473 src->ops->commit_write(src); in atc_connect_dai()
1474 src_mgr->src_enable_s(src_mgr, src); in atc_connect_dai()
1477 dai->ops->set_srt_srcl(dai, &(srcs[0]->rsc)); in atc_connect_dai()
1478 dai->ops->set_srt_srcr(dai, &(srcs[1]->rsc)); in atc_connect_dai()
1480 dai->ops->set_enb_src(dai, 1); in atc_connect_dai()
1481 dai->ops->set_enb_srt(dai, 1); in atc_connect_dai()
1482 dai->ops->commit_write(dai); in atc_connect_dai()
1484 src_mgr->commit_write(src_mgr); /* Synchronously enable SRCs */ in atc_connect_dai()
1497 mixer = atc->mixer; in atc_connect_resources()
1500 mixer->get_output_ports(mixer, i, &rscs[0], &rscs[1]); in atc_connect_resources()
1501 dao = container_of(atc->daios[j], struct dao, daio); in atc_connect_resources()
1502 dao->ops->set_left_input(dao, rscs[0]); in atc_connect_resources()
1503 dao->ops->set_right_input(dao, rscs[1]); in atc_connect_resources()
1506 dai = container_of(atc->daios[LINEIM], struct dai, daio); in atc_connect_resources()
1507 atc_connect_dai(atc->rsc_mgrs[SRC], dai, in atc_connect_resources()
1508 (struct src **)&atc->srcs[2], in atc_connect_resources()
1509 (struct srcimp **)&atc->srcimps[2]); in atc_connect_resources()
1510 src = atc->srcs[2]; in atc_connect_resources()
1511 mixer->set_input_left(mixer, MIX_LINE_IN, &src->rsc); in atc_connect_resources()
1512 src = atc->srcs[3]; in atc_connect_resources()
1513 mixer->set_input_right(mixer, MIX_LINE_IN, &src->rsc); in atc_connect_resources()
1515 if (atc->model == CTSB1270) { in atc_connect_resources()
1517 dai = container_of(atc->daios[MIC], struct dai, daio); in atc_connect_resources()
1518 atc_connect_dai(atc->rsc_mgrs[SRC], dai, in atc_connect_resources()
1519 (struct src **)&atc->srcs[4], in atc_connect_resources()
1520 (struct srcimp **)&atc->srcimps[4]); in atc_connect_resources()
1521 src = atc->srcs[4]; in atc_connect_resources()
1522 mixer->set_input_left(mixer, MIX_MIC_IN, &src->rsc); in atc_connect_resources()
1523 src = atc->srcs[5]; in atc_connect_resources()
1524 mixer->set_input_right(mixer, MIX_MIC_IN, &src->rsc); in atc_connect_resources()
1527 dai = container_of(atc->daios[SPDIFIO], struct dai, daio); in atc_connect_resources()
1528 atc_connect_dai(atc->rsc_mgrs[SRC], dai, in atc_connect_resources()
1529 (struct src **)&atc->srcs[0], in atc_connect_resources()
1530 (struct srcimp **)&atc->srcimps[0]); in atc_connect_resources()
1532 src = atc->srcs[0]; in atc_connect_resources()
1533 mixer->set_input_left(mixer, MIX_SPDIF_IN, &src->rsc); in atc_connect_resources()
1534 src = atc->srcs[1]; in atc_connect_resources()
1535 mixer->set_input_right(mixer, MIX_SPDIF_IN, &src->rsc); in atc_connect_resources()
1538 sum = atc->pcm[j]; in atc_connect_resources()
1539 mixer->set_input_left(mixer, i, &sum->rsc); in atc_connect_resources()
1540 sum = atc->pcm[j+1]; in atc_connect_resources()
1541 mixer->set_input_right(mixer, i, &sum->rsc); in atc_connect_resources()
1548 struct hw *hw = atc->hw; in atc_suspend()
1550 snd_power_change_state(atc->card, SNDRV_CTL_POWER_D3hot); in atc_suspend()
1554 hw->suspend(hw); in atc_suspend()
1561 struct hw *hw = atc->hw; in atc_hw_resume()
1564 /* Re-initialize card hardware. */ in atc_hw_resume()
1565 info.rsr = atc->rsr; in atc_hw_resume()
1566 info.msr = atc->msr; in atc_hw_resume()
1568 return hw->resume(hw, &info); in atc_hw_resume()
1586 mixer = atc->mixer; in atc_resources_resume()
1587 mixer->resume(mixer); in atc_resources_resume()
1599 dev_err(atc->card->dev, in atc_resume()
1601 snd_card_disconnect(atc->card); in atc_resume()
1609 snd_power_change_state(atc->card, SNDRV_CTL_POWER_D0); in atc_resume()
1655 * ct_atc_create - create and initialize a hardware manager
1685 return -ENOMEM; in ct_atc_create()
1690 atc->card = card; in ct_atc_create()
1691 atc->pci = pci; in ct_atc_create()
1692 atc->rsr = rsr; in ct_atc_create()
1693 atc->msr = msr; in ct_atc_create()
1694 atc->chip_type = chip_type; in ct_atc_create()
1696 mutex_init(&atc->atc_mutex); in ct_atc_create()
1701 dev_err(card->dev, "ctatc: Card not recognised\n"); in ct_atc_create()
1706 err = ct_vm_create(&atc->vm, pci); in ct_atc_create()
1715 err = ct_mixer_create(atc, (struct ct_mixer **)&atc->mixer); in ct_atc_create()
1717 dev_err(card->dev, "Failed to create mixer obj!!!\n"); in ct_atc_create()
1729 atc->timer = ct_timer_new(atc); in ct_atc_create()
1730 if (!atc->timer) { in ct_atc_create()
1731 err = -ENOMEM; in ct_atc_create()
1744 dev_err(card->dev, "Something wrong!!!\n"); in ct_atc_create()