2 * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
4 * This source file is released under GPL v2 license (no other versions).
5 * See the COPYING file included in the main directory of this source
6 * distribution for the license terms and conditions.
11 * This file contains the implementation of the device resource management
21 #include "cthardware.h"
25 #include <linux/delay.h>
26 #include <sound/pcm.h>
27 #include <sound/control.h>
28 #include <sound/asoundef.h>
30 #define MONO_SUM_SCALE 0x19a8 /* 2^(-0.5) in 14-bit floating format */
32 #define MAX_MULTI_CHN 8
34 #define IEC958_DEFAULT_CON ((IEC958_AES0_NONAUDIO \
35 | IEC958_AES0_CON_NOT_COPYRIGHT) \
36 | ((IEC958_AES1_CON_MIXER \
37 | IEC958_AES1_CON_ORIGINAL) << 8) \
39 | ((IEC958_AES3_CON_FS_48000) << 24))
41 static const struct ct_atc_chip_sub_details atc_sub_details[NUM_CTCARDS] = {
42 [CTSB0760] = {.subsys = PCI_SUBDEVICE_ID_CREATIVE_SB0760,
43 .nm_model = "SB076x"},
44 [CTHENDRIX] = {.subsys = PCI_SUBDEVICE_ID_CREATIVE_HENDRIX,
45 .nm_model = "Hendrix"},
46 [CTSB08801] = {.subsys = PCI_SUBDEVICE_ID_CREATIVE_SB08801,
47 .nm_model = "SB0880"},
48 [CTSB08802] = {.subsys = PCI_SUBDEVICE_ID_CREATIVE_SB08802,
49 .nm_model = "SB0880"},
50 [CTSB08803] = {.subsys = PCI_SUBDEVICE_ID_CREATIVE_SB08803,
54 static struct ct_atc_chip_details atc_chip_details[] = {
55 {.vendor = PCI_VENDOR_ID_CREATIVE,
56 .device = PCI_DEVICE_ID_CREATIVE_20K1,
58 .nm_card = "X-Fi 20k1"},
59 {.vendor = PCI_VENDOR_ID_CREATIVE,
60 .device = PCI_DEVICE_ID_CREATIVE_20K2,
61 .sub_details = atc_sub_details,
62 .nm_card = "X-Fi 20k2"},
67 int (*create)(struct ct_atc *atc,
68 enum CTALSADEVS device, const char *device_name);
69 int (*destroy)(void *alsa_dev);
70 const char *public_name;
71 } alsa_dev_funcs[NUM_CTALSADEVS] = {
72 [FRONT] = { .create = ct_alsa_pcm_create,
74 .public_name = "Front/WaveIn"},
75 [REAR] = { .create = ct_alsa_pcm_create,
77 .public_name = "Rear"},
78 [CLFE] = { .create = ct_alsa_pcm_create,
80 .public_name = "Center/LFE"},
81 [SURROUND] = { .create = ct_alsa_pcm_create,
83 .public_name = "Surround"},
84 [IEC958] = { .create = ct_alsa_pcm_create,
86 .public_name = "IEC958 Non-audio"},
88 [MIXER] = { .create = ct_alsa_mix_create,
90 .public_name = "Mixer"}
93 typedef int (*create_t)(void *, void **);
94 typedef int (*destroy_t)(void *);
97 int (*create)(void *hw, void **rmgr);
98 int (*destroy)(void *mgr);
99 } rsc_mgr_funcs[NUM_RSCTYP] = {
100 [SRC] = { .create = (create_t)src_mgr_create,
101 .destroy = (destroy_t)src_mgr_destroy },
102 [SRCIMP] = { .create = (create_t)srcimp_mgr_create,
103 .destroy = (destroy_t)srcimp_mgr_destroy },
104 [AMIXER] = { .create = (create_t)amixer_mgr_create,
105 .destroy = (destroy_t)amixer_mgr_destroy },
106 [SUM] = { .create = (create_t)sum_mgr_create,
107 .destroy = (destroy_t)sum_mgr_destroy },
108 [DAIO] = { .create = (create_t)daio_mgr_create,
109 .destroy = (destroy_t)daio_mgr_destroy }
113 atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm);
116 * Only mono and interleaved modes are supported now.
117 * Always allocates a contiguous channel block.
120 static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm)
123 struct snd_pcm_runtime *runtime;
126 if (NULL == apcm->substream)
129 runtime = apcm->substream->runtime;
132 spin_lock_irqsave(&atc->vm_lock, flags);
133 apcm->vm_block = vm->map(vm, runtime->dma_area, runtime->dma_bytes);
134 spin_unlock_irqrestore(&atc->vm_lock, flags);
136 if (NULL == apcm->vm_block)
142 static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm)
147 if (NULL == apcm->vm_block)
152 spin_lock_irqsave(&atc->vm_lock, flags);
153 vm->unmap(vm, apcm->vm_block);
154 spin_unlock_irqrestore(&atc->vm_lock, flags);
156 apcm->vm_block = NULL;
159 static unsigned long atc_get_ptp_phys(struct ct_atc *atc, int index)
163 unsigned long phys_addr;
166 spin_lock_irqsave(&atc->vm_lock, flags);
168 kvirt_addr = vm->get_ptp_virt(vm, index);
169 if (kvirt_addr == NULL)
172 phys_addr = virt_to_phys(kvirt_addr);
174 spin_unlock_irqrestore(&atc->vm_lock, flags);
179 static unsigned int convert_format(snd_pcm_format_t snd_format)
181 switch (snd_format) {
182 case SNDRV_PCM_FORMAT_U8:
183 case SNDRV_PCM_FORMAT_S8:
185 case SNDRV_PCM_FORMAT_S16_LE:
186 case SNDRV_PCM_FORMAT_U16_LE:
188 case SNDRV_PCM_FORMAT_S24_3LE:
190 case SNDRV_PCM_FORMAT_S24_LE:
191 case SNDRV_PCM_FORMAT_S32_LE:
194 printk(KERN_ERR "ctxfi: not recognized snd format is %d \n",
201 atc_get_pitch(unsigned int input_rate, unsigned int output_rate)
203 unsigned int pitch = 0;
206 /* get pitch and convert to fixed-point 8.24 format. */
207 pitch = (input_rate / output_rate) << 24;
208 input_rate %= output_rate;
211 for (b = 31; ((b >= 0) && !(input_rate >> b)); )
215 input_rate <<= (31 - b);
216 input_rate /= output_rate;
229 static int select_rom(unsigned int pitch)
231 if ((pitch > 0x00428f5c) && (pitch < 0x01b851ec)) {
232 /* 0.26 <= pitch <= 1.72 */
234 } else if ((0x01d66666 == pitch) || (0x01d66667 == pitch)) {
235 /* pitch == 1.8375 */
237 } else if (0x02000000 == pitch) {
240 } else if ((pitch >= 0x0) && (pitch <= 0x08000000)) {
241 /* 0 <= pitch <= 8 */
248 static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
250 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC];
251 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER];
252 struct src_desc desc = {0};
253 struct amixer_desc mix_dsc = {0};
254 struct src *src = NULL;
255 struct amixer *amixer = NULL;
257 int n_amixer = apcm->substream->runtime->channels, i = 0;
258 int device = apcm->substream->pcm->device;
259 unsigned int pitch = 0;
262 if (NULL != apcm->src) {
263 /* Prepared pcm playback */
267 /* Get SRC resource */
268 desc.multi = apcm->substream->runtime->channels;
271 err = src_mgr->get_src(src_mgr, &desc, (struct src **)&apcm->src);
275 pitch = atc_get_pitch(apcm->substream->runtime->rate,
276 (atc->rsr * atc->msr));
278 src->ops->set_pitch(src, pitch);
279 src->ops->set_rom(src, select_rom(pitch));
280 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format));
281 src->ops->set_pm(src, (src->ops->next_interleave(src) != NULL));
283 /* Get AMIXER resource */
284 n_amixer = (n_amixer < 2) ? 2 : n_amixer;
285 apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
286 if (NULL == apcm->amixers) {
290 mix_dsc.msr = atc->msr;
291 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) {
292 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc,
293 (struct amixer **)&apcm->amixers[i]);
300 /* Set up device virtual mem map */
301 err = ct_map_audio_buffer(atc, apcm);
305 /* Connect resources */
307 for (i = 0; i < n_amixer; i++) {
308 amixer = apcm->amixers[i];
309 spin_lock_irqsave(&atc->atc_lock, flags);
310 amixer->ops->setup(amixer, &src->rsc,
311 INIT_VOL, atc->pcm[i+device*2]);
312 spin_unlock_irqrestore(&atc->atc_lock, flags);
313 src = src->ops->next_interleave(src);
321 atc_pcm_release_resources(atc, apcm);
326 atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
328 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC];
329 struct srcimp_mgr *srcimp_mgr = atc->rsc_mgrs[SRCIMP];
330 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER];
331 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM];
332 struct srcimp *srcimp = NULL;
335 if (NULL != apcm->srcimps) {
336 for (i = 0; i < apcm->n_srcimp; i++) {
337 srcimp = apcm->srcimps[i];
338 srcimp->ops->unmap(srcimp);
339 srcimp_mgr->put_srcimp(srcimp_mgr, srcimp);
340 apcm->srcimps[i] = NULL;
342 kfree(apcm->srcimps);
343 apcm->srcimps = NULL;
346 if (NULL != apcm->srccs) {
347 for (i = 0; i < apcm->n_srcc; i++) {
348 src_mgr->put_src(src_mgr, apcm->srccs[i]);
349 apcm->srccs[i] = NULL;
355 if (NULL != apcm->amixers) {
356 for (i = 0; i < apcm->n_amixer; i++) {
357 amixer_mgr->put_amixer(amixer_mgr, apcm->amixers[i]);
358 apcm->amixers[i] = NULL;
360 kfree(apcm->amixers);
361 apcm->amixers = NULL;
364 if (NULL != apcm->mono) {
365 sum_mgr->put_sum(sum_mgr, apcm->mono);
369 if (NULL != apcm->src) {
370 src_mgr->put_src(src_mgr, apcm->src);
374 if (NULL != apcm->vm_block) {
375 /* Undo device virtual mem map */
376 ct_unmap_audio_buffer(atc, apcm);
377 apcm->vm_block = NULL;
383 static int atc_pcm_playback_start(struct ct_atc *atc, struct ct_atc_pcm *apcm)
385 unsigned int max_cisz = 0;
386 struct src *src = apcm->src;
388 max_cisz = src->multi * src->rsc.msr;
389 max_cisz = 0x80 * (max_cisz < 8 ? max_cisz : 8);
391 src->ops->set_sa(src, apcm->vm_block->addr);
392 src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size);
393 src->ops->set_ca(src, apcm->vm_block->addr + max_cisz);
394 src->ops->set_cisz(src, max_cisz);
396 src->ops->set_bm(src, 1);
397 src->ops->set_state(src, SRC_STATE_INIT);
398 src->ops->commit_write(src);
403 static int atc_pcm_stop(struct ct_atc *atc, struct ct_atc_pcm *apcm)
405 struct src *src = NULL;
409 src->ops->set_bm(src, 0);
410 src->ops->set_state(src, SRC_STATE_OFF);
411 src->ops->commit_write(src);
413 if (NULL != apcm->srccs) {
414 for (i = 0; i < apcm->n_srcc; i++) {
415 src = apcm->srccs[i];
416 src->ops->set_bm(src, 0);
417 src->ops->set_state(src, SRC_STATE_OFF);
418 src->ops->commit_write(src);
428 atc_pcm_playback_position(struct ct_atc *atc, struct ct_atc_pcm *apcm)
430 struct src *src = apcm->src;
431 u32 size = 0, max_cisz = 0;
434 position = src->ops->get_ca(src);
436 size = apcm->vm_block->size;
437 max_cisz = src->multi * src->rsc.msr;
438 max_cisz = 128 * (max_cisz < 8 ? max_cisz : 8);
440 return (position + size - max_cisz - apcm->vm_block->addr) % size;
443 struct src_node_conf_t {
446 unsigned int mix_msr:8;
447 unsigned int imp_msr:8;
451 static void setup_src_node_conf(struct ct_atc *atc, struct ct_atc_pcm *apcm,
452 struct src_node_conf_t *conf, int *n_srcc)
454 unsigned int pitch = 0;
456 /* get pitch and convert to fixed-point 8.24 format. */
457 pitch = atc_get_pitch((atc->rsr * atc->msr),
458 apcm->substream->runtime->rate);
462 *n_srcc = apcm->substream->runtime->channels;
463 conf[0].pitch = pitch;
464 conf[0].mix_msr = conf[0].imp_msr = conf[0].msr = 1;
466 } else if (2 == atc->msr) {
467 if (0x8000000 < pitch) {
468 /* Need two-stage SRCs, SRCIMPs and
469 * AMIXERs for converting format */
470 conf[0].pitch = (atc->msr << 24);
471 conf[0].msr = conf[0].mix_msr = 1;
472 conf[0].imp_msr = atc->msr;
474 conf[1].pitch = atc_get_pitch(atc->rsr,
475 apcm->substream->runtime->rate);
476 conf[1].msr = conf[1].mix_msr = conf[1].imp_msr = 1;
478 *n_srcc = apcm->substream->runtime->channels * 2;
479 } else if (0x1000000 < pitch) {
480 /* Need one-stage SRCs, SRCIMPs and
481 * AMIXERs for converting format */
482 conf[0].pitch = pitch;
483 conf[0].msr = conf[0].mix_msr
484 = conf[0].imp_msr = atc->msr;
486 *n_srcc = apcm->substream->runtime->channels;
492 atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
494 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC];
495 struct srcimp_mgr *srcimp_mgr = atc->rsc_mgrs[SRCIMP];
496 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER];
497 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM];
498 struct src_desc src_dsc = {0};
499 struct src *src = NULL;
500 struct srcimp_desc srcimp_dsc = {0};
501 struct srcimp *srcimp = NULL;
502 struct amixer_desc mix_dsc = {0};
503 struct sum_desc sum_dsc = {0};
504 unsigned int pitch = 0;
505 int multi = 0, err = 0, i = 0;
506 int n_srcimp = 0, n_amixer = 0, n_srcc = 0, n_sum = 0;
507 struct src_node_conf_t src_node_conf[2] = {{0} };
509 /* The numbers of converting SRCs and SRCIMPs should be determined
512 multi = apcm->substream->runtime->channels;
514 /* get pitch and convert to fixed-point 8.24 format. */
515 pitch = atc_get_pitch((atc->rsr * atc->msr),
516 apcm->substream->runtime->rate);
518 setup_src_node_conf(atc, apcm, src_node_conf, &n_srcc);
519 n_sum = (1 == multi) ? 1 : 0;
520 n_amixer += n_sum * 2 + n_srcc;
522 if ((multi > 1) && (0x8000000 >= pitch)) {
523 /* Need extra AMIXERs and SRCIMPs for special treatment
524 * of interleaved recording of conjugate channels */
525 n_amixer += multi * atc->msr;
526 n_srcimp += multi * atc->msr;
532 apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL);
533 if (NULL == apcm->srccs)
537 apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
538 if (NULL == apcm->amixers) {
543 apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL);
544 if (NULL == apcm->srcimps) {
549 /* Allocate SRCs for sample rate conversion if needed */
551 src_dsc.mode = ARCRW;
552 for (i = 0, apcm->n_srcc = 0; i < n_srcc; i++) {
553 src_dsc.msr = src_node_conf[i/multi].msr;
554 err = src_mgr->get_src(src_mgr, &src_dsc,
555 (struct src **)&apcm->srccs[i]);
559 src = apcm->srccs[i];
560 pitch = src_node_conf[i/multi].pitch;
561 src->ops->set_pitch(src, pitch);
562 src->ops->set_rom(src, select_rom(pitch));
563 src->ops->set_vo(src, src_node_conf[i/multi].vo);
568 /* Allocate AMIXERs for routing SRCs of conversion if needed */
569 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) {
571 mix_dsc.msr = atc->msr;
572 else if (i < (n_sum*2+n_srcc))
573 mix_dsc.msr = src_node_conf[(i-n_sum*2)/multi].mix_msr;
577 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc,
578 (struct amixer **)&apcm->amixers[i]);
585 /* Allocate a SUM resource to mix all input channels together */
586 sum_dsc.msr = atc->msr;
587 err = sum_mgr->get_sum(sum_mgr, &sum_dsc, (struct sum **)&apcm->mono);
591 pitch = atc_get_pitch((atc->rsr * atc->msr),
592 apcm->substream->runtime->rate);
593 /* Allocate SRCIMP resources */
594 for (i = 0, apcm->n_srcimp = 0; i < n_srcimp; i++) {
596 srcimp_dsc.msr = src_node_conf[i/multi].imp_msr;
598 srcimp_dsc.msr = (pitch <= 0x8000000) ? atc->msr : 1;
602 err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc, &srcimp);
606 apcm->srcimps[i] = srcimp;
610 /* Allocate a SRC for writing data to host memory */
611 src_dsc.multi = apcm->substream->runtime->channels;
613 src_dsc.mode = MEMWR;
614 err = src_mgr->get_src(src_mgr, &src_dsc, (struct src **)&apcm->src);
619 src->ops->set_pitch(src, pitch);
621 /* Set up device virtual mem map */
622 err = ct_map_audio_buffer(atc, apcm);
629 atc_pcm_release_resources(atc, apcm);
633 static int atc_pcm_capture_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
635 struct src *src = NULL;
636 struct amixer *amixer = NULL;
637 struct srcimp *srcimp = NULL;
638 struct ct_mixer *mixer = atc->mixer;
639 struct sum *mono = NULL;
640 struct rsc *out_ports[8] = {NULL};
641 int err = 0, i = 0, j = 0, n_sum = 0, multi = 0;
642 unsigned int pitch = 0;
643 int mix_base = 0, imp_base = 0;
645 if (NULL != apcm->src) {
646 /* Prepared pcm capture */
650 /* Get needed resources. */
651 err = atc_pcm_capture_get_resources(atc, apcm);
655 /* Connect resources */
656 mixer->get_output_ports(mixer, MIX_PCMO_FRONT,
657 &out_ports[0], &out_ports[1]);
659 multi = apcm->substream->runtime->channels;
662 for (i = 0; i < 2; i++) {
663 amixer = apcm->amixers[i];
664 amixer->ops->setup(amixer, out_ports[i],
665 MONO_SUM_SCALE, mono);
667 out_ports[0] = &mono->rsc;
669 mix_base = n_sum * 2;
672 for (i = 0; i < apcm->n_srcc; i++) {
673 src = apcm->srccs[i];
674 srcimp = apcm->srcimps[imp_base+i];
675 amixer = apcm->amixers[mix_base+i];
676 srcimp->ops->map(srcimp, src, out_ports[i%multi]);
677 amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL);
678 out_ports[i%multi] = &amixer->rsc;
681 pitch = atc_get_pitch((atc->rsr * atc->msr),
682 apcm->substream->runtime->rate);
684 if ((multi > 1) && (pitch <= 0x8000000)) {
685 /* Special connection for interleaved
686 * recording with conjugate channels */
687 for (i = 0; i < multi; i++) {
688 out_ports[i]->ops->master(out_ports[i]);
689 for (j = 0; j < atc->msr; j++) {
690 amixer = apcm->amixers[apcm->n_srcc+j*multi+i];
691 amixer->ops->set_input(amixer, out_ports[i]);
692 amixer->ops->set_scale(amixer, INIT_VOL);
693 amixer->ops->set_sum(amixer, NULL);
694 amixer->ops->commit_raw_write(amixer);
695 out_ports[i]->ops->next_conj(out_ports[i]);
697 srcimp = apcm->srcimps[apcm->n_srcc+j*multi+i];
698 srcimp->ops->map(srcimp, apcm->src,
703 for (i = 0; i < multi; i++) {
704 srcimp = apcm->srcimps[apcm->n_srcc+i];
705 srcimp->ops->map(srcimp, apcm->src, out_ports[i]);
712 static int atc_pcm_capture_start(struct ct_atc *atc, struct ct_atc_pcm *apcm)
714 struct src *src = NULL;
715 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC];
716 int i = 0, multi = 0;
722 multi = apcm->substream->runtime->channels;
723 /* Set up converting SRCs */
724 for (i = 0; i < apcm->n_srcc; i++) {
725 src = apcm->srccs[i];
726 src->ops->set_pm(src, ((i%multi) != (multi-1)));
727 src_mgr->src_disable(src_mgr, src);
730 /* Set up recording SRC */
732 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format));
733 src->ops->set_sa(src, apcm->vm_block->addr);
734 src->ops->set_la(src, apcm->vm_block->addr + apcm->vm_block->size);
735 src->ops->set_ca(src, apcm->vm_block->addr);
736 src_mgr->src_disable(src_mgr, src);
738 /* Disable relevant SRCs firstly */
739 src_mgr->commit_write(src_mgr);
741 /* Enable SRCs respectively */
742 for (i = 0; i < apcm->n_srcc; i++) {
743 src = apcm->srccs[i];
744 src->ops->set_state(src, SRC_STATE_RUN);
745 src->ops->commit_write(src);
746 src_mgr->src_enable_s(src_mgr, src);
749 src->ops->set_bm(src, 1);
750 src->ops->set_state(src, SRC_STATE_RUN);
751 src->ops->commit_write(src);
752 src_mgr->src_enable_s(src_mgr, src);
754 /* Enable relevant SRCs synchronously */
755 src_mgr->commit_write(src_mgr);
761 atc_pcm_capture_position(struct ct_atc *atc, struct ct_atc_pcm *apcm)
763 struct src *src = apcm->src;
765 return src->ops->get_ca(src) - apcm->vm_block->addr;
768 static int spdif_passthru_playback_get_resources(struct ct_atc *atc,
769 struct ct_atc_pcm *apcm)
771 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC];
772 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER];
773 struct src_desc desc = {0};
774 struct amixer_desc mix_dsc = {0};
775 struct src *src = NULL;
777 int n_amixer = apcm->substream->runtime->channels, i = 0;
778 unsigned int pitch = 0, rsr = atc->pll_rate;
780 /* Get SRC resource */
781 desc.multi = apcm->substream->runtime->channels;
783 while (apcm->substream->runtime->rate > (rsr * desc.msr))
787 err = src_mgr->get_src(src_mgr, &desc, (struct src **)&apcm->src);
791 pitch = atc_get_pitch(apcm->substream->runtime->rate, (rsr * desc.msr));
793 src->ops->set_pitch(src, pitch);
794 src->ops->set_rom(src, select_rom(pitch));
795 src->ops->set_sf(src, convert_format(apcm->substream->runtime->format));
796 src->ops->set_pm(src, (src->ops->next_interleave(src) != NULL));
797 src->ops->set_bp(src, 1);
799 /* Get AMIXER resource */
800 n_amixer = (n_amixer < 2) ? 2 : n_amixer;
801 apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
802 if (NULL == apcm->amixers) {
806 mix_dsc.msr = desc.msr;
807 for (i = 0, apcm->n_amixer = 0; i < n_amixer; i++) {
808 err = amixer_mgr->get_amixer(amixer_mgr, &mix_dsc,
809 (struct amixer **)&apcm->amixers[i]);
816 /* Set up device virtual mem map */
817 err = ct_map_audio_buffer(atc, apcm);
824 atc_pcm_release_resources(atc, apcm);
829 spdif_passthru_playback_setup(struct ct_atc *atc, struct ct_atc_pcm *apcm)
831 struct dao *dao = container_of(atc->daios[SPDIFOO], struct dao, daio);
833 unsigned int rate = apcm->substream->runtime->rate;
834 unsigned int status = 0;
836 unsigned char iec958_con_fs = 0;
840 iec958_con_fs = IEC958_AES3_CON_FS_48000;
843 iec958_con_fs = IEC958_AES3_CON_FS_44100;
846 iec958_con_fs = IEC958_AES3_CON_FS_32000;
852 spin_lock_irqsave(&atc->atc_lock, flags);
853 dao->ops->get_spos(dao, &status);
854 if (((status >> 24) & IEC958_AES3_CON_FS) != iec958_con_fs) {
855 status &= ((~IEC958_AES3_CON_FS) << 24);
856 status |= (iec958_con_fs << 24);
857 dao->ops->set_spos(dao, status);
858 dao->ops->commit_write(dao);
860 if ((rate != atc->pll_rate) && (32000 != rate)) {
861 err = ((struct hw *)atc->hw)->pll_init(atc->hw, rate);
862 atc->pll_rate = err ? 0 : rate;
864 spin_unlock_irqrestore(&atc->atc_lock, flags);
870 spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
872 struct src *src = NULL;
873 struct amixer *amixer = NULL;
874 struct dao *dao = NULL;
879 if (NULL != apcm->src)
882 /* Configure SPDIFOO and PLL to passthrough mode;
883 * determine pll_rate. */
884 err = spdif_passthru_playback_setup(atc, apcm);
888 /* Get needed resources. */
889 err = spdif_passthru_playback_get_resources(atc, apcm);
893 /* Connect resources */
895 for (i = 0; i < apcm->n_amixer; i++) {
896 amixer = apcm->amixers[i];
897 amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL);
898 src = src->ops->next_interleave(src);
902 /* Connect to SPDIFOO */
903 spin_lock_irqsave(&atc->atc_lock, flags);
904 dao = container_of(atc->daios[SPDIFOO], struct dao, daio);
905 amixer = apcm->amixers[0];
906 dao->ops->set_left_input(dao, &amixer->rsc);
907 amixer = apcm->amixers[1];
908 dao->ops->set_right_input(dao, &amixer->rsc);
909 spin_unlock_irqrestore(&atc->atc_lock, flags);
914 static int atc_select_line_in(struct ct_atc *atc)
916 struct hw *hw = atc->hw;
917 struct ct_mixer *mixer = atc->mixer;
918 struct src *src = NULL;
920 if (hw->is_adc_source_selected(hw, ADC_LINEIN))
923 mixer->set_input_left(mixer, MIX_MIC_IN, NULL);
924 mixer->set_input_right(mixer, MIX_MIC_IN, NULL);
926 hw->select_adc_source(hw, ADC_LINEIN);
929 mixer->set_input_left(mixer, MIX_LINE_IN, &src->rsc);
931 mixer->set_input_right(mixer, MIX_LINE_IN, &src->rsc);
936 static int atc_select_mic_in(struct ct_atc *atc)
938 struct hw *hw = atc->hw;
939 struct ct_mixer *mixer = atc->mixer;
940 struct src *src = NULL;
942 if (hw->is_adc_source_selected(hw, ADC_MICIN))
945 mixer->set_input_left(mixer, MIX_LINE_IN, NULL);
946 mixer->set_input_right(mixer, MIX_LINE_IN, NULL);
948 hw->select_adc_source(hw, ADC_MICIN);
951 mixer->set_input_left(mixer, MIX_MIC_IN, &src->rsc);
953 mixer->set_input_right(mixer, MIX_MIC_IN, &src->rsc);
958 static int atc_have_digit_io_switch(struct ct_atc *atc)
960 struct hw *hw = atc->hw;
962 return hw->have_digit_io_switch(hw);
965 static int atc_select_digit_io(struct ct_atc *atc)
967 struct hw *hw = atc->hw;
969 if (hw->is_adc_source_selected(hw, ADC_NONE))
972 hw->select_adc_source(hw, ADC_NONE);
977 static int atc_daio_unmute(struct ct_atc *atc, unsigned char state, int type)
979 struct daio_mgr *daio_mgr = atc->rsc_mgrs[DAIO];
982 daio_mgr->daio_enable(daio_mgr, atc->daios[type]);
984 daio_mgr->daio_disable(daio_mgr, atc->daios[type]);
986 daio_mgr->commit_write(daio_mgr);
992 atc_dao_get_status(struct ct_atc *atc, unsigned int *status, int type)
994 struct dao *dao = container_of(atc->daios[type], struct dao, daio);
995 return dao->ops->get_spos(dao, status);
999 atc_dao_set_status(struct ct_atc *atc, unsigned int status, int type)
1001 struct dao *dao = container_of(atc->daios[type], struct dao, daio);
1003 dao->ops->set_spos(dao, status);
1004 dao->ops->commit_write(dao);
1008 static int atc_line_front_unmute(struct ct_atc *atc, unsigned char state)
1010 return atc_daio_unmute(atc, state, LINEO1);
1013 static int atc_line_surround_unmute(struct ct_atc *atc, unsigned char state)
1015 return atc_daio_unmute(atc, state, LINEO4);
1018 static int atc_line_clfe_unmute(struct ct_atc *atc, unsigned char state)
1020 return atc_daio_unmute(atc, state, LINEO3);
1023 static int atc_line_rear_unmute(struct ct_atc *atc, unsigned char state)
1025 return atc_daio_unmute(atc, state, LINEO2);
1028 static int atc_line_in_unmute(struct ct_atc *atc, unsigned char state)
1030 return atc_daio_unmute(atc, state, LINEIM);
1033 static int atc_spdif_out_unmute(struct ct_atc *atc, unsigned char state)
1035 return atc_daio_unmute(atc, state, SPDIFOO);
1038 static int atc_spdif_in_unmute(struct ct_atc *atc, unsigned char state)
1040 return atc_daio_unmute(atc, state, SPDIFIO);
1043 static int atc_spdif_out_get_status(struct ct_atc *atc, unsigned int *status)
1045 return atc_dao_get_status(atc, status, SPDIFOO);
1048 static int atc_spdif_out_set_status(struct ct_atc *atc, unsigned int status)
1050 return atc_dao_set_status(atc, status, SPDIFOO);
1053 static int atc_spdif_out_passthru(struct ct_atc *atc, unsigned char state)
1055 unsigned long flags;
1056 struct dao_desc da_dsc = {0};
1057 struct dao *dao = NULL;
1059 struct ct_mixer *mixer = atc->mixer;
1060 struct rsc *rscs[2] = {NULL};
1061 unsigned int spos = 0;
1063 spin_lock_irqsave(&atc->atc_lock, flags);
1064 dao = container_of(atc->daios[SPDIFOO], struct dao, daio);
1065 da_dsc.msr = state ? 1 : atc->msr;
1066 da_dsc.passthru = state ? 1 : 0;
1067 err = dao->ops->reinit(dao, &da_dsc);
1069 spos = IEC958_DEFAULT_CON;
1071 mixer->get_output_ports(mixer, MIX_SPDIF_OUT,
1072 &rscs[0], &rscs[1]);
1073 dao->ops->set_left_input(dao, rscs[0]);
1074 dao->ops->set_right_input(dao, rscs[1]);
1075 /* Restore PLL to atc->rsr if needed. */
1076 if (atc->pll_rate != atc->rsr) {
1077 err = ((struct hw *)atc->hw)->pll_init(atc->hw,
1079 atc->pll_rate = err ? 0 : atc->rsr;
1082 dao->ops->set_spos(dao, spos);
1083 dao->ops->commit_write(dao);
1084 spin_unlock_irqrestore(&atc->atc_lock, flags);
1089 static int ct_atc_destroy(struct ct_atc *atc)
1091 struct daio_mgr *daio_mgr = NULL;
1092 struct dao *dao = NULL;
1093 struct dai *dai = NULL;
1094 struct daio *daio = NULL;
1095 struct sum_mgr *sum_mgr = NULL;
1096 struct src_mgr *src_mgr = NULL;
1097 struct srcimp_mgr *srcimp_mgr = NULL;
1098 struct srcimp *srcimp = NULL;
1099 struct ct_mixer *mixer = NULL;
1105 /* Stop hardware and disable all interrupts */
1106 if (NULL != atc->hw)
1107 ((struct hw *)atc->hw)->card_stop(atc->hw);
1109 /* Destroy internal mixer objects */
1110 if (NULL != atc->mixer) {
1112 mixer->set_input_left(mixer, MIX_LINE_IN, NULL);
1113 mixer->set_input_right(mixer, MIX_LINE_IN, NULL);
1114 mixer->set_input_left(mixer, MIX_MIC_IN, NULL);
1115 mixer->set_input_right(mixer, MIX_MIC_IN, NULL);
1116 mixer->set_input_left(mixer, MIX_SPDIF_IN, NULL);
1117 mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL);
1118 ct_mixer_destroy(atc->mixer);
1121 if (NULL != atc->daios) {
1122 daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO];
1123 for (i = 0; i < atc->n_daio; i++) {
1124 daio = atc->daios[i];
1125 if (daio->type < LINEIM) {
1126 dao = container_of(daio, struct dao, daio);
1127 dao->ops->clear_left_input(dao);
1128 dao->ops->clear_right_input(dao);
1130 dai = container_of(daio, struct dai, daio);
1131 /* some thing to do for dai ... */
1133 daio_mgr->put_daio(daio_mgr, daio);
1138 if (NULL != atc->pcm) {
1139 sum_mgr = atc->rsc_mgrs[SUM];
1140 for (i = 0; i < atc->n_pcm; i++)
1141 sum_mgr->put_sum(sum_mgr, atc->pcm[i]);
1146 if (NULL != atc->srcs) {
1147 src_mgr = atc->rsc_mgrs[SRC];
1148 for (i = 0; i < atc->n_src; i++)
1149 src_mgr->put_src(src_mgr, atc->srcs[i]);
1154 if (NULL != atc->srcimps) {
1155 srcimp_mgr = atc->rsc_mgrs[SRCIMP];
1156 for (i = 0; i < atc->n_srcimp; i++) {
1157 srcimp = atc->srcimps[i];
1158 srcimp->ops->unmap(srcimp);
1159 srcimp_mgr->put_srcimp(srcimp_mgr, atc->srcimps[i]);
1161 kfree(atc->srcimps);
1164 for (i = 0; i < NUM_RSCTYP; i++) {
1165 if ((NULL != rsc_mgr_funcs[i].destroy) &&
1166 (NULL != atc->rsc_mgrs[i]))
1167 rsc_mgr_funcs[i].destroy(atc->rsc_mgrs[i]);
1171 if (NULL != atc->hw)
1172 destroy_hw_obj((struct hw *)atc->hw);
1174 /* Destroy device virtual memory manager object */
1175 if (NULL != atc->vm) {
1176 ct_vm_destroy(atc->vm);
1185 static int atc_dev_free(struct snd_device *dev)
1187 struct ct_atc *atc = dev->device_data;
1188 return ct_atc_destroy(atc);
1191 static int atc_identify_card(struct ct_atc *atc)
1195 struct pci_dev *pci = atc->pci;
1196 const struct ct_atc_chip_details *d;
1199 subsys = pci->subsystem_device;
1200 revision = pci->revision;
1201 atc->chip_details = NULL;
1202 atc->model = NUM_CTCARDS;
1203 for (d = atc_chip_details; d->vendor; d++) {
1204 if (d->vendor != pci->vendor || d->device != pci->device)
1207 if (NULL == d->sub_details) {
1208 atc->chip_details = d;
1211 for (i = 0; i < NUM_CTCARDS; i++) {
1212 if ((d->sub_details[i].subsys == subsys) ||
1213 (((subsys & 0x6000) == 0x6000) &&
1214 ((d->sub_details[i].subsys & 0x6000) == 0x6000))) {
1219 if (i >= NUM_CTCARDS)
1222 atc->chip_details = d;
1224 /* not take revision into consideration now */
1232 static int ct_create_alsa_devs(struct ct_atc *atc)
1235 struct hw *hw = atc->hw;
1238 switch (hw->get_chip_type(hw)) {
1240 alsa_dev_funcs[MIXER].public_name = "20K1";
1243 alsa_dev_funcs[MIXER].public_name = "20K2";
1246 alsa_dev_funcs[MIXER].public_name = "Unknown";
1250 for (i = 0; i < NUM_CTALSADEVS; i++) {
1251 if (NULL == alsa_dev_funcs[i].create)
1254 err = alsa_dev_funcs[i].create(atc, i,
1255 alsa_dev_funcs[i].public_name);
1257 printk(KERN_ERR "ctxfi: "
1258 "Creating alsa device %d failed!\n", i);
1266 static int atc_create_hw_devs(struct ct_atc *atc)
1268 struct hw *hw = NULL;
1269 struct card_conf info = {0};
1272 err = create_hw_obj(atc->pci, &hw);
1274 printk(KERN_ERR "Failed to create hw obj!!!\n");
1279 /* Initialize card hardware. */
1280 info.rsr = atc->rsr;
1281 info.msr = atc->msr;
1282 info.vm_pgt_phys = atc_get_ptp_phys(atc, 0);
1283 err = hw->card_init(hw, &info);
1287 for (i = 0; i < NUM_RSCTYP; i++) {
1288 if (NULL == rsc_mgr_funcs[i].create)
1291 err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]);
1293 printk(KERN_ERR "ctxfi: "
1294 "Failed to create rsc_mgr %d!!!\n", i);
1302 static int atc_get_resources(struct ct_atc *atc)
1304 struct daio_desc da_desc = {0};
1305 struct daio_mgr *daio_mgr = NULL;
1306 struct src_desc src_dsc = {0};
1307 struct src_mgr *src_mgr = NULL;
1308 struct srcimp_desc srcimp_dsc = {0};
1309 struct srcimp_mgr *srcimp_mgr = NULL;
1310 struct sum_desc sum_dsc = {0};
1311 struct sum_mgr *sum_mgr = NULL;
1313 unsigned short subsys_id;
1315 atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL);
1316 if (NULL == atc->daios)
1319 atc->srcs = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL);
1320 if (NULL == atc->srcs)
1323 atc->srcimps = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL);
1324 if (NULL == atc->srcimps)
1327 atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL);
1328 if (NULL == atc->pcm)
1331 daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO];
1332 da_desc.msr = atc->msr;
1333 for (i = 0, atc->n_daio = 0; i < DAIONUM-1; i++) {
1335 err = daio_mgr->get_daio(daio_mgr, &da_desc,
1336 (struct daio **)&atc->daios[i]);
1338 printk(KERN_ERR "ctxfi: Failed to get DAIO "
1339 "resource %d!!!\n", i);
1344 subsys_id = atc->pci->subsystem_device;
1345 if ((subsys_id == 0x0029) || (subsys_id == 0x0031)) {
1347 da_desc.type = SPDIFI1;
1349 da_desc.type = SPDIFIO;
1351 err = daio_mgr->get_daio(daio_mgr, &da_desc,
1352 (struct daio **)&atc->daios[i]);
1354 printk(KERN_ERR "ctxfi: Failed to get S/PDIF-in resource!!!\n");
1359 src_mgr = atc->rsc_mgrs[SRC];
1361 src_dsc.msr = atc->msr;
1362 src_dsc.mode = ARCRW;
1363 for (i = 0, atc->n_src = 0; i < (2*2); i++) {
1364 err = src_mgr->get_src(src_mgr, &src_dsc,
1365 (struct src **)&atc->srcs[i]);
1372 srcimp_mgr = atc->rsc_mgrs[SRCIMP];
1373 srcimp_dsc.msr = 8; /* SRCIMPs for S/PDIFIn SRT */
1374 for (i = 0, atc->n_srcimp = 0; i < (2*1); i++) {
1375 err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc,
1376 (struct srcimp **)&atc->srcimps[i]);
1382 srcimp_dsc.msr = 8; /* SRCIMPs for LINE/MICIn SRT */
1383 for (i = 0; i < (2*1); i++) {
1384 err = srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc,
1385 (struct srcimp **)&atc->srcimps[2*1+i]);
1392 sum_mgr = atc->rsc_mgrs[SUM];
1393 sum_dsc.msr = atc->msr;
1394 for (i = 0, atc->n_pcm = 0; i < (2*4); i++) {
1395 err = sum_mgr->get_sum(sum_mgr, &sum_dsc,
1396 (struct sum **)&atc->pcm[i]);
1403 err = ct_mixer_create(atc, (struct ct_mixer **)&atc->mixer);
1405 printk(KERN_ERR "ctxfi: Failed to create mixer obj!!!\n");
1413 atc_connect_dai(struct src_mgr *src_mgr, struct dai *dai,
1414 struct src **srcs, struct srcimp **srcimps)
1416 struct rsc *rscs[2] = {NULL};
1417 struct src *src = NULL;
1418 struct srcimp *srcimp = NULL;
1421 rscs[0] = &dai->daio.rscl;
1422 rscs[1] = &dai->daio.rscr;
1423 for (i = 0; i < 2; i++) {
1425 srcimp = srcimps[i];
1426 srcimp->ops->map(srcimp, src, rscs[i]);
1427 src_mgr->src_disable(src_mgr, src);
1430 src_mgr->commit_write(src_mgr); /* Actually disable SRCs */
1433 src->ops->set_pm(src, 1);
1434 for (i = 0; i < 2; i++) {
1436 src->ops->set_state(src, SRC_STATE_RUN);
1437 src->ops->commit_write(src);
1438 src_mgr->src_enable_s(src_mgr, src);
1441 dai->ops->set_srt_srcl(dai, &(srcs[0]->rsc));
1442 dai->ops->set_srt_srcr(dai, &(srcs[1]->rsc));
1444 dai->ops->set_enb_src(dai, 1);
1445 dai->ops->set_enb_srt(dai, 1);
1446 dai->ops->commit_write(dai);
1448 src_mgr->commit_write(src_mgr); /* Synchronously enable SRCs */
1451 static void atc_connect_resources(struct ct_atc *atc)
1453 struct dai *dai = NULL;
1454 struct dao *dao = NULL;
1455 struct src *src = NULL;
1456 struct sum *sum = NULL;
1457 struct ct_mixer *mixer = NULL;
1458 struct rsc *rscs[2] = {NULL};
1463 for (i = MIX_WAVE_FRONT, j = LINEO1; i <= MIX_SPDIF_OUT; i++, j++) {
1464 mixer->get_output_ports(mixer, i, &rscs[0], &rscs[1]);
1465 dao = container_of(atc->daios[j], struct dao, daio);
1466 dao->ops->set_left_input(dao, rscs[0]);
1467 dao->ops->set_right_input(dao, rscs[1]);
1470 dai = container_of(atc->daios[LINEIM], struct dai, daio);
1471 atc_connect_dai(atc->rsc_mgrs[SRC], dai,
1472 (struct src **)&atc->srcs[2],
1473 (struct srcimp **)&atc->srcimps[2]);
1475 mixer->set_input_left(mixer, MIX_LINE_IN, &src->rsc);
1477 mixer->set_input_right(mixer, MIX_LINE_IN, &src->rsc);
1479 dai = container_of(atc->daios[SPDIFIO], struct dai, daio);
1480 atc_connect_dai(atc->rsc_mgrs[SRC], dai,
1481 (struct src **)&atc->srcs[0],
1482 (struct srcimp **)&atc->srcimps[0]);
1485 mixer->set_input_left(mixer, MIX_SPDIF_IN, &src->rsc);
1487 mixer->set_input_right(mixer, MIX_SPDIF_IN, &src->rsc);
1489 for (i = MIX_PCMI_FRONT, j = 0; i <= MIX_PCMI_SURROUND; i++, j += 2) {
1491 mixer->set_input_left(mixer, i, &sum->rsc);
1492 sum = atc->pcm[j+1];
1493 mixer->set_input_right(mixer, i, &sum->rsc);
1497 static void atc_set_ops(struct ct_atc *atc)
1499 /* Set operations */
1500 atc->map_audio_buffer = ct_map_audio_buffer;
1501 atc->unmap_audio_buffer = ct_unmap_audio_buffer;
1502 atc->pcm_playback_prepare = atc_pcm_playback_prepare;
1503 atc->pcm_release_resources = atc_pcm_release_resources;
1504 atc->pcm_playback_start = atc_pcm_playback_start;
1505 atc->pcm_playback_stop = atc_pcm_stop;
1506 atc->pcm_playback_position = atc_pcm_playback_position;
1507 atc->pcm_capture_prepare = atc_pcm_capture_prepare;
1508 atc->pcm_capture_start = atc_pcm_capture_start;
1509 atc->pcm_capture_stop = atc_pcm_stop;
1510 atc->pcm_capture_position = atc_pcm_capture_position;
1511 atc->spdif_passthru_playback_prepare = spdif_passthru_playback_prepare;
1512 atc->get_ptp_phys = atc_get_ptp_phys;
1513 atc->select_line_in = atc_select_line_in;
1514 atc->select_mic_in = atc_select_mic_in;
1515 atc->select_digit_io = atc_select_digit_io;
1516 atc->line_front_unmute = atc_line_front_unmute;
1517 atc->line_surround_unmute = atc_line_surround_unmute;
1518 atc->line_clfe_unmute = atc_line_clfe_unmute;
1519 atc->line_rear_unmute = atc_line_rear_unmute;
1520 atc->line_in_unmute = atc_line_in_unmute;
1521 atc->spdif_out_unmute = atc_spdif_out_unmute;
1522 atc->spdif_in_unmute = atc_spdif_in_unmute;
1523 atc->spdif_out_get_status = atc_spdif_out_get_status;
1524 atc->spdif_out_set_status = atc_spdif_out_set_status;
1525 atc->spdif_out_passthru = atc_spdif_out_passthru;
1526 atc->have_digit_io_switch = atc_have_digit_io_switch;
1530 * ct_atc_create - create and initialize a hardware manager
1531 * @card: corresponding alsa card object
1532 * @pci: corresponding kernel pci device object
1533 * @ratc: return created object address in it
1535 * Creates and initializes a hardware manager.
1537 * Creates kmallocated ct_atc structure. Initializes hardware.
1538 * Returns 0 if suceeds, or negative error code if fails.
1541 int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
1542 unsigned int rsr, unsigned int msr, struct ct_atc **ratc)
1544 struct ct_atc *atc = NULL;
1545 static struct snd_device_ops ops = {
1546 .dev_free = atc_dev_free,
1552 atc = kzalloc(sizeof(*atc), GFP_KERNEL);
1561 /* Set operations */
1564 spin_lock_init(&atc->atc_lock);
1565 spin_lock_init(&atc->vm_lock);
1567 /* Find card model */
1568 err = atc_identify_card(atc);
1570 printk(KERN_ERR "ctatc: Card not recognised\n");
1574 /* Set up device virtual memory management object */
1575 err = ct_vm_create(&atc->vm);
1579 /* Create all atc hw devices */
1580 err = atc_create_hw_devs(atc);
1585 err = atc_get_resources(atc);
1589 /* Build topology */
1590 atc_connect_resources(atc);
1592 atc->create_alsa_devs = ct_create_alsa_devs;
1594 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, atc, &ops);
1598 snd_card_set_dev(card, &pci->dev);
1604 ct_atc_destroy(atc);
1605 printk(KERN_ERR "ctxfi: Something wrong!!!\n");