aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ctxfi/ctatc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/ctxfi/ctatc.c')
-rw-r--r--sound/pci/ctxfi/ctatc.c164
1 files changed, 84 insertions, 80 deletions
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index 9b1324544db0..7898a375df0e 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -190,8 +190,8 @@ static unsigned int convert_format(snd_pcm_format_t snd_format)
190static unsigned int 190static unsigned int
191atc_get_pitch(unsigned int input_rate, unsigned int output_rate) 191atc_get_pitch(unsigned int input_rate, unsigned int output_rate)
192{ 192{
193 unsigned int pitch = 0; 193 unsigned int pitch;
194 int b = 0; 194 int b;
195 195
196 /* get pitch and convert to fixed-point 8.24 format. */ 196 /* get pitch and convert to fixed-point 8.24 format. */
197 pitch = (input_rate / output_rate) << 24; 197 pitch = (input_rate / output_rate) << 24;
@@ -241,12 +241,12 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
241 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; 241 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER];
242 struct src_desc desc = {0}; 242 struct src_desc desc = {0};
243 struct amixer_desc mix_dsc = {0}; 243 struct amixer_desc mix_dsc = {0};
244 struct src *src = NULL; 244 struct src *src;
245 struct amixer *amixer = NULL; 245 struct amixer *amixer;
246 int err = 0; 246 int err;
247 int n_amixer = apcm->substream->runtime->channels, i = 0; 247 int n_amixer = apcm->substream->runtime->channels, i = 0;
248 int device = apcm->substream->pcm->device; 248 int device = apcm->substream->pcm->device;
249 unsigned int pitch = 0; 249 unsigned int pitch;
250 unsigned long flags; 250 unsigned long flags;
251 251
252 if (NULL != apcm->src) { 252 if (NULL != apcm->src) {
@@ -324,8 +324,8 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
324 struct srcimp_mgr *srcimp_mgr = atc->rsc_mgrs[SRCIMP]; 324 struct srcimp_mgr *srcimp_mgr = atc->rsc_mgrs[SRCIMP];
325 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; 325 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER];
326 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM]; 326 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM];
327 struct srcimp *srcimp = NULL; 327 struct srcimp *srcimp;
328 int i = 0; 328 int i;
329 329
330 if (NULL != apcm->srcimps) { 330 if (NULL != apcm->srcimps) {
331 for (i = 0; i < apcm->n_srcimp; i++) { 331 for (i = 0; i < apcm->n_srcimp; i++) {
@@ -377,7 +377,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
377 377
378static int atc_pcm_playback_start(struct ct_atc *atc, struct ct_atc_pcm *apcm) 378static int atc_pcm_playback_start(struct ct_atc *atc, struct ct_atc_pcm *apcm)
379{ 379{
380 unsigned int max_cisz = 0; 380 unsigned int max_cisz;
381 struct src *src = apcm->src; 381 struct src *src = apcm->src;
382 382
383 max_cisz = src->multi * src->rsc.msr; 383 max_cisz = src->multi * src->rsc.msr;
@@ -398,8 +398,8 @@ static int atc_pcm_playback_start(struct ct_atc *atc, struct ct_atc_pcm *apcm)
398 398
399static int atc_pcm_stop(struct ct_atc *atc, struct ct_atc_pcm *apcm) 399static int atc_pcm_stop(struct ct_atc *atc, struct ct_atc_pcm *apcm)
400{ 400{
401 struct src *src = NULL; 401 struct src *src;
402 int i = 0; 402 int i;
403 403
404 ct_timer_stop(apcm->timer); 404 ct_timer_stop(apcm->timer);
405 405
@@ -426,8 +426,8 @@ static int
426atc_pcm_playback_position(struct ct_atc *atc, struct ct_atc_pcm *apcm) 426atc_pcm_playback_position(struct ct_atc *atc, struct ct_atc_pcm *apcm)
427{ 427{
428 struct src *src = apcm->src; 428 struct src *src = apcm->src;
429 u32 size = 0, max_cisz = 0; 429 u32 size, max_cisz;
430 int position = 0; 430 int position;
431 431
432 position = src->ops->get_ca(src); 432 position = src->ops->get_ca(src);
433 433
@@ -449,7 +449,7 @@ struct src_node_conf_t {
449static void setup_src_node_conf(struct ct_atc *atc, struct ct_atc_pcm *apcm, 449static void setup_src_node_conf(struct ct_atc *atc, struct ct_atc_pcm *apcm,
450 struct src_node_conf_t *conf, int *n_srcc) 450 struct src_node_conf_t *conf, int *n_srcc)
451{ 451{
452 unsigned int pitch = 0; 452 unsigned int pitch;
453 453
454 /* get pitch and convert to fixed-point 8.24 format. */ 454 /* get pitch and convert to fixed-point 8.24 format. */
455 pitch = atc_get_pitch((atc->rsr * atc->msr), 455 pitch = atc_get_pitch((atc->rsr * atc->msr),
@@ -494,14 +494,14 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
494 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; 494 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER];
495 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM]; 495 struct sum_mgr *sum_mgr = atc->rsc_mgrs[SUM];
496 struct src_desc src_dsc = {0}; 496 struct src_desc src_dsc = {0};
497 struct src *src = NULL; 497 struct src *src;
498 struct srcimp_desc srcimp_dsc = {0}; 498 struct srcimp_desc srcimp_dsc = {0};
499 struct srcimp *srcimp = NULL; 499 struct srcimp *srcimp;
500 struct amixer_desc mix_dsc = {0}; 500 struct amixer_desc mix_dsc = {0};
501 struct sum_desc sum_dsc = {0}; 501 struct sum_desc sum_dsc = {0};
502 unsigned int pitch = 0; 502 unsigned int pitch;
503 int multi = 0, err = 0, i = 0; 503 int multi, err, i;
504 int n_srcimp = 0, n_amixer = 0, n_srcc = 0, n_sum = 0; 504 int n_srcimp, n_amixer, n_srcc, n_sum;
505 struct src_node_conf_t src_node_conf[2] = {{0} }; 505 struct src_node_conf_t src_node_conf[2] = {{0} };
506 506
507 /* first release old resources */ 507 /* first release old resources */
@@ -518,8 +518,8 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
518 518
519 setup_src_node_conf(atc, apcm, src_node_conf, &n_srcc); 519 setup_src_node_conf(atc, apcm, src_node_conf, &n_srcc);
520 n_sum = (1 == multi) ? 1 : 0; 520 n_sum = (1 == multi) ? 1 : 0;
521 n_amixer += n_sum * 2 + n_srcc; 521 n_amixer = n_sum * 2 + n_srcc;
522 n_srcimp += n_srcc; 522 n_srcimp = n_srcc;
523 if ((multi > 1) && (0x8000000 >= pitch)) { 523 if ((multi > 1) && (0x8000000 >= pitch)) {
524 /* Need extra AMIXERs and SRCIMPs for special treatment 524 /* Need extra AMIXERs and SRCIMPs for special treatment
525 * of interleaved recording of conjugate channels */ 525 * of interleaved recording of conjugate channels */
@@ -633,14 +633,14 @@ error1:
633 633
634static int atc_pcm_capture_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) 634static int atc_pcm_capture_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
635{ 635{
636 struct src *src = NULL; 636 struct src *src;
637 struct amixer *amixer = NULL; 637 struct amixer *amixer;
638 struct srcimp *srcimp = NULL; 638 struct srcimp *srcimp;
639 struct ct_mixer *mixer = atc->mixer; 639 struct ct_mixer *mixer = atc->mixer;
640 struct sum *mono = NULL; 640 struct sum *mono;
641 struct rsc *out_ports[8] = {NULL}; 641 struct rsc *out_ports[8] = {NULL};
642 int err = 0, i = 0, j = 0, n_sum = 0, multi = 0; 642 int err, i, j, n_sum, multi;
643 unsigned int pitch = 0; 643 unsigned int pitch;
644 int mix_base = 0, imp_base = 0; 644 int mix_base = 0, imp_base = 0;
645 645
646 if (NULL != apcm->src) { 646 if (NULL != apcm->src) {
@@ -714,9 +714,9 @@ static int atc_pcm_capture_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
714 714
715static int atc_pcm_capture_start(struct ct_atc *atc, struct ct_atc_pcm *apcm) 715static int atc_pcm_capture_start(struct ct_atc *atc, struct ct_atc_pcm *apcm)
716{ 716{
717 struct src *src = NULL; 717 struct src *src;
718 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC]; 718 struct src_mgr *src_mgr = atc->rsc_mgrs[SRC];
719 int i = 0, multi = 0; 719 int i, multi;
720 720
721 if (apcm->started) 721 if (apcm->started)
722 return 0; 722 return 0;
@@ -776,10 +776,10 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc,
776 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER]; 776 struct amixer_mgr *amixer_mgr = atc->rsc_mgrs[AMIXER];
777 struct src_desc desc = {0}; 777 struct src_desc desc = {0};
778 struct amixer_desc mix_dsc = {0}; 778 struct amixer_desc mix_dsc = {0};
779 struct src *src = NULL; 779 struct src *src;
780 int err = 0; 780 int err;
781 int n_amixer = apcm->substream->runtime->channels, i = 0; 781 int n_amixer = apcm->substream->runtime->channels, i;
782 unsigned int pitch = 0, rsr = atc->pll_rate; 782 unsigned int pitch, rsr = atc->pll_rate;
783 783
784 /* first release old resources */ 784 /* first release old resources */
785 atc->pcm_release_resources(atc, apcm); 785 atc->pcm_release_resources(atc, apcm);
@@ -832,15 +832,24 @@ error1:
832 return err; 832 return err;
833} 833}
834 834
835static int atc_pll_init(struct ct_atc *atc, int rate)
836{
837 struct hw *hw = atc->hw;
838 int err;
839 err = hw->pll_init(hw, rate);
840 atc->pll_rate = err ? 0 : rate;
841 return err;
842}
843
835static int 844static int
836spdif_passthru_playback_setup(struct ct_atc *atc, struct ct_atc_pcm *apcm) 845spdif_passthru_playback_setup(struct ct_atc *atc, struct ct_atc_pcm *apcm)
837{ 846{
838 struct dao *dao = container_of(atc->daios[SPDIFOO], struct dao, daio); 847 struct dao *dao = container_of(atc->daios[SPDIFOO], struct dao, daio);
839 unsigned long flags; 848 unsigned long flags;
840 unsigned int rate = apcm->substream->runtime->rate; 849 unsigned int rate = apcm->substream->runtime->rate;
841 unsigned int status = 0; 850 unsigned int status;
842 int err = 0; 851 int err;
843 unsigned char iec958_con_fs = 0; 852 unsigned char iec958_con_fs;
844 853
845 switch (rate) { 854 switch (rate) {
846 case 48000: 855 case 48000:
@@ -864,10 +873,8 @@ spdif_passthru_playback_setup(struct ct_atc *atc, struct ct_atc_pcm *apcm)
864 dao->ops->set_spos(dao, status); 873 dao->ops->set_spos(dao, status);
865 dao->ops->commit_write(dao); 874 dao->ops->commit_write(dao);
866 } 875 }
867 if ((rate != atc->pll_rate) && (32000 != rate)) { 876 if ((rate != atc->pll_rate) && (32000 != rate))
868 err = ((struct hw *)atc->hw)->pll_init(atc->hw, rate); 877 err = atc_pll_init(atc, rate);
869 atc->pll_rate = err ? 0 : rate;
870 }
871 spin_unlock_irqrestore(&atc->atc_lock, flags); 878 spin_unlock_irqrestore(&atc->atc_lock, flags);
872 879
873 return err; 880 return err;
@@ -876,11 +883,11 @@ spdif_passthru_playback_setup(struct ct_atc *atc, struct ct_atc_pcm *apcm)
876static int 883static int
877spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) 884spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
878{ 885{
879 struct src *src = NULL; 886 struct src *src;
880 struct amixer *amixer = NULL; 887 struct amixer *amixer;
881 struct dao *dao = NULL; 888 struct dao *dao;
882 int err = 0; 889 int err;
883 int i = 0; 890 int i;
884 unsigned long flags; 891 unsigned long flags;
885 892
886 if (NULL != apcm->src) 893 if (NULL != apcm->src)
@@ -924,7 +931,7 @@ static int atc_select_line_in(struct ct_atc *atc)
924{ 931{
925 struct hw *hw = atc->hw; 932 struct hw *hw = atc->hw;
926 struct ct_mixer *mixer = atc->mixer; 933 struct ct_mixer *mixer = atc->mixer;
927 struct src *src = NULL; 934 struct src *src;
928 935
929 if (hw->is_adc_source_selected(hw, ADC_LINEIN)) 936 if (hw->is_adc_source_selected(hw, ADC_LINEIN))
930 return 0; 937 return 0;
@@ -946,7 +953,7 @@ static int atc_select_mic_in(struct ct_atc *atc)
946{ 953{
947 struct hw *hw = atc->hw; 954 struct hw *hw = atc->hw;
948 struct ct_mixer *mixer = atc->mixer; 955 struct ct_mixer *mixer = atc->mixer;
949 struct src *src = NULL; 956 struct src *src;
950 957
951 if (hw->is_adc_source_selected(hw, ADC_MICIN)) 958 if (hw->is_adc_source_selected(hw, ADC_MICIN))
952 return 0; 959 return 0;
@@ -1063,8 +1070,8 @@ static int atc_spdif_out_passthru(struct ct_atc *atc, unsigned char state)
1063{ 1070{
1064 unsigned long flags; 1071 unsigned long flags;
1065 struct dao_desc da_dsc = {0}; 1072 struct dao_desc da_dsc = {0};
1066 struct dao *dao = NULL; 1073 struct dao *dao;
1067 int err = 0; 1074 int err;
1068 struct ct_mixer *mixer = atc->mixer; 1075 struct ct_mixer *mixer = atc->mixer;
1069 struct rsc *rscs[2] = {NULL}; 1076 struct rsc *rscs[2] = {NULL};
1070 unsigned int spos = 0; 1077 unsigned int spos = 0;
@@ -1082,11 +1089,8 @@ static int atc_spdif_out_passthru(struct ct_atc *atc, unsigned char state)
1082 dao->ops->set_left_input(dao, rscs[0]); 1089 dao->ops->set_left_input(dao, rscs[0]);
1083 dao->ops->set_right_input(dao, rscs[1]); 1090 dao->ops->set_right_input(dao, rscs[1]);
1084 /* Restore PLL to atc->rsr if needed. */ 1091 /* Restore PLL to atc->rsr if needed. */
1085 if (atc->pll_rate != atc->rsr) { 1092 if (atc->pll_rate != atc->rsr)
1086 err = ((struct hw *)atc->hw)->pll_init(atc->hw, 1093 err = atc_pll_init(atc, atc->rsr);
1087 atc->rsr);
1088 atc->pll_rate = err ? 0 : atc->rsr;
1089 }
1090 } 1094 }
1091 dao->ops->set_spos(dao, spos); 1095 dao->ops->set_spos(dao, spos);
1092 dao->ops->commit_write(dao); 1096 dao->ops->commit_write(dao);
@@ -1097,15 +1101,15 @@ static int atc_spdif_out_passthru(struct ct_atc *atc, unsigned char state)
1097 1101
1098static int ct_atc_destroy(struct ct_atc *atc) 1102static int ct_atc_destroy(struct ct_atc *atc)
1099{ 1103{
1100 struct daio_mgr *daio_mgr = NULL; 1104 struct daio_mgr *daio_mgr;
1101 struct dao *dao = NULL; 1105 struct dao *dao;
1102 struct dai *dai = NULL; 1106 struct dai *dai;
1103 struct daio *daio = NULL; 1107 struct daio *daio;
1104 struct sum_mgr *sum_mgr = NULL; 1108 struct sum_mgr *sum_mgr;
1105 struct src_mgr *src_mgr = NULL; 1109 struct src_mgr *src_mgr;
1106 struct srcimp_mgr *srcimp_mgr = NULL; 1110 struct srcimp_mgr *srcimp_mgr;
1107 struct srcimp *srcimp = NULL; 1111 struct srcimp *srcimp;
1108 struct ct_mixer *mixer = NULL; 1112 struct ct_mixer *mixer;
1109 int i = 0; 1113 int i = 0;
1110 1114
1111 if (NULL == atc) 1115 if (NULL == atc)
@@ -1279,9 +1283,9 @@ int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc)
1279 1283
1280static int __devinit atc_create_hw_devs(struct ct_atc *atc) 1284static int __devinit atc_create_hw_devs(struct ct_atc *atc)
1281{ 1285{
1282 struct hw *hw = NULL; 1286 struct hw *hw;
1283 struct card_conf info = {0}; 1287 struct card_conf info = {0};
1284 int i = 0, err = 0; 1288 int i, err;
1285 1289
1286 err = create_hw_obj(atc->pci, &hw); 1290 err = create_hw_obj(atc->pci, &hw);
1287 if (err) { 1291 if (err) {
@@ -1316,14 +1320,14 @@ static int __devinit atc_create_hw_devs(struct ct_atc *atc)
1316static int __devinit atc_get_resources(struct ct_atc *atc) 1320static int __devinit atc_get_resources(struct ct_atc *atc)
1317{ 1321{
1318 struct daio_desc da_desc = {0}; 1322 struct daio_desc da_desc = {0};
1319 struct daio_mgr *daio_mgr = NULL; 1323 struct daio_mgr *daio_mgr;
1320 struct src_desc src_dsc = {0}; 1324 struct src_desc src_dsc = {0};
1321 struct src_mgr *src_mgr = NULL; 1325 struct src_mgr *src_mgr;
1322 struct srcimp_desc srcimp_dsc = {0}; 1326 struct srcimp_desc srcimp_dsc = {0};
1323 struct srcimp_mgr *srcimp_mgr = NULL; 1327 struct srcimp_mgr *srcimp_mgr;
1324 struct sum_desc sum_dsc = {0}; 1328 struct sum_desc sum_dsc = {0};
1325 struct sum_mgr *sum_mgr = NULL; 1329 struct sum_mgr *sum_mgr;
1326 int err = 0, i = 0; 1330 int err, i;
1327 unsigned short subsys_id; 1331 unsigned short subsys_id;
1328 1332
1329 atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL); 1333 atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL);
@@ -1428,8 +1432,8 @@ atc_connect_dai(struct src_mgr *src_mgr, struct dai *dai,
1428 struct src **srcs, struct srcimp **srcimps) 1432 struct src **srcs, struct srcimp **srcimps)
1429{ 1433{
1430 struct rsc *rscs[2] = {NULL}; 1434 struct rsc *rscs[2] = {NULL};
1431 struct src *src = NULL; 1435 struct src *src;
1432 struct srcimp *srcimp = NULL; 1436 struct srcimp *srcimp;
1433 int i = 0; 1437 int i = 0;
1434 1438
1435 rscs[0] = &dai->daio.rscl; 1439 rscs[0] = &dai->daio.rscl;
@@ -1464,13 +1468,13 @@ atc_connect_dai(struct src_mgr *src_mgr, struct dai *dai,
1464 1468
1465static void __devinit atc_connect_resources(struct ct_atc *atc) 1469static void __devinit atc_connect_resources(struct ct_atc *atc)
1466{ 1470{
1467 struct dai *dai = NULL; 1471 struct dai *dai;
1468 struct dao *dao = NULL; 1472 struct dao *dao;
1469 struct src *src = NULL; 1473 struct src *src;
1470 struct sum *sum = NULL; 1474 struct sum *sum;
1471 struct ct_mixer *mixer = NULL; 1475 struct ct_mixer *mixer;
1472 struct rsc *rscs[2] = {NULL}; 1476 struct rsc *rscs[2] = {NULL};
1473 int i = 0, j = 0; 1477 int i, j;
1474 1478
1475 mixer = atc->mixer; 1479 mixer = atc->mixer;
1476 1480
@@ -1553,11 +1557,11 @@ static struct ct_atc atc_preset __devinitdata = {
1553int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, 1557int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci,
1554 unsigned int rsr, unsigned int msr, struct ct_atc **ratc) 1558 unsigned int rsr, unsigned int msr, struct ct_atc **ratc)
1555{ 1559{
1556 struct ct_atc *atc = NULL; 1560 struct ct_atc *atc;
1557 static struct snd_device_ops ops = { 1561 static struct snd_device_ops ops = {
1558 .dev_free = atc_dev_free, 1562 .dev_free = atc_dev_free,
1559 }; 1563 };
1560 int err = 0; 1564 int err;
1561 1565
1562 *ratc = NULL; 1566 *ratc = NULL;
1563 1567