Lines Matching refs:mgr

160 static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate,
168 switch (mgr->use_clock_type) {
197 err = pcxhr_send_msg(mgr, &rmh);
220 int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate)
229 err = pcxhr_get_clock_reg(mgr, rate, &val, &realfreq);
240 if (mgr->codec_speed != speed) {
243 err = pcxhr_send_msg(mgr, &rmh);
251 err = pcxhr_send_msg(mgr, &rmh);
257 err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK, val, &changed);
260 mgr->sample_rate_real = realfreq;
261 mgr->cur_clock_type = mgr->use_clock_type;
264 if (mgr->codec_speed != speed) {
267 err = pcxhr_send_msg(mgr, &rmh);
270 mgr->codec_speed = speed; /* save new codec speed */
282 err = pcxhr_send_msg(mgr, &rmh);
291 int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, enum pcxhr_clock_type clock_type,
310 if (mgr->last_reg_stat != reg) {
312 err = pcxhr_send_msg(mgr, &rmh);
316 mgr->last_reg_stat = reg;
319 err = pcxhr_send_msg(mgr, &rmh);
375 err = pcxhr_send_msg(chip->mgr, &rmh);
423 sample_rate = chip->mgr->sample_rate;
444 err = pcxhr_send_msg(chip->mgr, &rmh);
474 err = pcxhr_send_msg(chip->mgr, &rmh);
498 struct pcxhr_mgr *mgr = (struct pcxhr_mgr*)(arg);
506 mutex_lock(&mgr->setup_mutex);
509 for (i = 0; i < mgr->num_cards; i++) {
510 chip = mgr->chip[i];
525 mutex_unlock(&mgr->setup_mutex);
534 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0);
536 mutex_unlock(&mgr->setup_mutex);
543 for (i = 0; i < mgr->num_cards; i++) {
545 chip = mgr->chip[i];
562 for (i = 0; i < mgr->num_cards; i++) {
564 chip = mgr->chip[i];
578 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1);
580 mutex_unlock(&mgr->setup_mutex);
587 spin_lock_irqsave(&mgr->lock, flags);
588 for ( i =0; i < mgr->num_cards; i++) {
590 chip = mgr->chip[i];
605 spin_unlock_irqrestore(&mgr->lock, flags);
607 mutex_unlock(&mgr->setup_mutex);
636 tasklet_hi_schedule(&chip->mgr->trigger_taskq);
672 static int pcxhr_hardware_timer(struct pcxhr_mgr *mgr, int start)
679 mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID; /* last dsp time invalid */
682 err = pcxhr_send_msg(mgr, &rmh);
694 struct pcxhr_mgr *mgr = chip->mgr;
712 mutex_lock(&mgr->setup_mutex);
728 if (mgr->sample_rate != subs->runtime->rate) {
729 err = pcxhr_set_clock(mgr, subs->runtime->rate);
732 if (mgr->sample_rate == 0)
734 err = pcxhr_hardware_timer(mgr, 1);
735 mgr->sample_rate = subs->runtime->rate;
739 mutex_unlock(&mgr->setup_mutex);
752 struct pcxhr_mgr *mgr = chip->mgr;
764 mutex_lock(&mgr->setup_mutex);
773 mutex_unlock(&mgr->setup_mutex);
785 mutex_unlock(&mgr->setup_mutex);
826 struct pcxhr_mgr *mgr = chip->mgr;
831 mutex_lock(&mgr->setup_mutex);
845 if (mgr->mono_capture)
855 mutex_unlock(&mgr->setup_mutex);
862 if (mgr->sample_rate)
863 runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate;
865 if (mgr->use_clock_type != PCXHR_CLOCK_TYPE_INTERNAL) {
867 if (pcxhr_get_external_clock(mgr, mgr->use_clock_type,
871 mutex_unlock(&mgr->setup_mutex);
887 mgr->ref_count_rate++;
889 mutex_unlock(&mgr->setup_mutex);
897 struct pcxhr_mgr *mgr = chip->mgr;
900 mutex_lock(&mgr->setup_mutex);
905 if (--mgr->ref_count_rate == 0) {
906 mgr->sample_rate = 0; /* the sample rate is no more locked */
907 pcxhr_hardware_timer(mgr, 0); /* stop the DSP-timer */
913 mutex_unlock(&mgr->setup_mutex);
928 spin_lock_irqsave(&chip->mgr->lock, flags);
934 spin_unlock_irqrestore(&chip->mgr->lock, flags);
978 snd_dma_pci_data(chip->mgr->pci),
999 static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card, int idx)
1007 mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1015 chip->mgr = mgr;
1017 if (idx < mgr->playback_chips)
1021 if (idx < mgr->capture_chips) {
1022 if (mgr->mono_capture)
1033 snd_card_set_dev(card, &mgr->pci->dev);
1042 struct pcxhr_mgr *mgr = chip->mgr;
1044 snd_iprintf(buffer, "\n%s\n", mgr->longname);
1047 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) {
1049 short ver_maj = (mgr->dsp_version >> 16) & 0xff;
1050 short ver_min = (mgr->dsp_version >> 8) & 0xff;
1051 short ver_build = mgr->dsp_version & 0xff;
1054 if (mgr->board_has_analog)
1061 if( ! pcxhr_send_msg(mgr, &rmh) ) {
1065 if (mgr->sample_rate_real != 0 &&
1066 mgr->sample_rate_real != 48000) {
1067 ref = (ref * 48000) / mgr->sample_rate_real;
1068 if (mgr->sample_rate_real >= PCXHR_IRQ_TIMER_FREQ)
1078 snd_iprintf(buffer, "dsp time errors : %d\n", mgr->dsp_time_err);
1080 mgr->async_err_pipe_xrun);
1082 mgr->async_err_stream_xrun);
1084 mgr->async_err_other_last);
1091 if( ! pcxhr_send_msg(mgr, &rmh) ) {
1103 struct pcxhr_mgr *mgr = chip->mgr;
1108 snd_iprintf(buffer, "\n%s\n", mgr->longname);
1109 snd_iprintf(buffer, "Current Sample Clock\t: %s\n", texts[mgr->cur_clock_type]);
1110 snd_iprintf(buffer, "Current Sample Rate\t= %d\n", mgr->sample_rate_real);
1113 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) {
1115 for (i = PCXHR_CLOCK_TYPE_WORD_CLOCK; i< (3 + mgr->capture_chips); i++) {
1116 err = pcxhr_get_external_clock(mgr, i, &sample_rate);
1140 static int pcxhr_free(struct pcxhr_mgr *mgr)
1144 for (i = 0; i < mgr->num_cards; i++) {
1145 if (mgr->chip[i])
1146 snd_card_free(mgr->chip[i]->card);
1150 if(mgr->dsp_loaded) {
1151 pcxhr_reset_board(mgr);
1156 if (mgr->irq >= 0)
1157 free_irq(mgr->irq, mgr);
1159 pci_release_regions(mgr->pci);
1162 if (mgr->hostport.area) {
1163 snd_dma_free_pages(&mgr->hostport);
1164 mgr->hostport.area = NULL;
1167 kfree(mgr->prmh);
1169 pci_disable_device(mgr->pci);
1170 kfree(mgr);
1180 struct pcxhr_mgr *mgr;
1206 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
1207 if (! mgr) {
1214 mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips;
1215 mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips;
1216 mgr->firmware_num = pcxhr_board_params[pci_id->driver_data].firmware_num;
1217 mgr->mono_capture = mono[dev];
1221 kfree(mgr);
1226 mgr->port[i] = pci_resource_start(pci, i);
1228 mgr->pci = pci;
1229 mgr->irq = -1;
1232 card_name, mgr)) {
1234 pcxhr_free(mgr);
1237 mgr->irq = pci->irq;
1239 sprintf(mgr->shortname, "Digigram %s", card_name);
1240 sprintf(mgr->longname, "%s at 0x%lx & 0x%lx, 0x%lx irq %i", mgr->shortname,
1241 mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq);
1244 spin_lock_init(&mgr->lock);
1245 spin_lock_init(&mgr->msg_lock);
1248 mutex_init(&mgr->setup_mutex);
1251 tasklet_init(&mgr->msg_taskq, pcxhr_msg_tasklet, (unsigned long) mgr);
1252 tasklet_init(&mgr->trigger_taskq, pcxhr_trigger_tasklet, (unsigned long) mgr);
1253 mgr->prmh = kmalloc(sizeof(*mgr->prmh) +
1256 if (! mgr->prmh) {
1257 pcxhr_free(mgr);
1266 if (i >= max(mgr->playback_chips, mgr->capture_chips))
1268 mgr->num_cards++;
1280 pcxhr_free(mgr);
1285 sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i);
1286 sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i);
1288 if ((err = pcxhr_create(mgr, card, i)) < 0) {
1289 pcxhr_free(mgr);
1295 pcxhr_proc_init(mgr->chip[i]);
1298 pcxhr_free(mgr);
1306 size, &mgr->hostport) < 0) {
1307 pcxhr_free(mgr);
1311 memset(mgr->hostport.area, 0, size);
1314 err = pcxhr_setup_firmware(mgr);
1316 pcxhr_free(mgr);
1320 pci_set_drvdata(pci, mgr);