Lines Matching refs:mgr
248 static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate, in pcxhr_get_clock_reg() argument
256 switch (mgr->use_clock_type) { in pcxhr_get_clock_reg()
285 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_get_clock_reg()
287 dev_err(&mgr->pci->dev, in pcxhr_get_clock_reg()
321 static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr, in pcxhr_sub_set_clock() argument
329 err = pcxhr_get_clock_reg(mgr, rate, &val, &realfreq); in pcxhr_sub_set_clock()
340 if (mgr->codec_speed != speed) { in pcxhr_sub_set_clock()
343 if (DSP_EXT_CMD_SET(mgr)) { in pcxhr_sub_set_clock()
347 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_set_clock()
355 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_set_clock()
360 dev_dbg(&mgr->pci->dev, "clock register : set %x\n", val); in pcxhr_sub_set_clock()
361 err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK, in pcxhr_sub_set_clock()
366 mgr->sample_rate_real = realfreq; in pcxhr_sub_set_clock()
367 mgr->cur_clock_type = mgr->use_clock_type; in pcxhr_sub_set_clock()
370 if (mgr->codec_speed != speed) { in pcxhr_sub_set_clock()
373 if (DSP_EXT_CMD_SET(mgr)) { in pcxhr_sub_set_clock()
377 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_set_clock()
380 mgr->codec_speed = speed; /* save new codec speed */ in pcxhr_sub_set_clock()
383 dev_dbg(&mgr->pci->dev, "pcxhr_sub_set_clock to %dHz (realfreq=%d)\n", in pcxhr_sub_set_clock()
393 int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate) in pcxhr_set_clock() argument
401 if (mgr->is_hr_stereo) in pcxhr_set_clock()
402 err = hr222_sub_set_clock(mgr, rate, &changed); in pcxhr_set_clock()
404 err = pcxhr_sub_set_clock(mgr, rate, &changed); in pcxhr_set_clock()
418 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_set_clock()
426 static int pcxhr_sub_get_external_clock(struct pcxhr_mgr *mgr, in pcxhr_sub_get_external_clock() argument
459 if (mgr->last_reg_stat != reg) { in pcxhr_sub_get_external_clock()
461 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_get_external_clock()
465 mgr->last_reg_stat = reg; in pcxhr_sub_get_external_clock()
468 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_get_external_clock()
483 dev_dbg(&mgr->pci->dev, "External clock is at %d Hz\n", rate); in pcxhr_sub_get_external_clock()
489 int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, in pcxhr_get_external_clock() argument
493 if (mgr->is_hr_stereo) in pcxhr_get_external_clock()
494 return hr222_get_external_clock(mgr, clock_type, in pcxhr_get_external_clock()
497 return pcxhr_sub_get_external_clock(mgr, clock_type, in pcxhr_get_external_clock()
538 err = pcxhr_send_msg(chip->mgr, &rmh); in pcxhr_set_stream_state()
591 sample_rate = chip->mgr->sample_rate; in pcxhr_set_format()
611 if (DSP_EXT_CMD_SET(chip->mgr)) in pcxhr_set_format()
618 if (DSP_EXT_CMD_SET(chip->mgr)) { in pcxhr_set_format()
629 err = pcxhr_send_msg(chip->mgr, &rmh); in pcxhr_set_format()
667 err = pcxhr_send_msg(chip->mgr, &rmh); in pcxhr_update_r_buffer()
685 err = pcxhr_send_msg(chip->mgr, &rmh);
705 static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr) in pcxhr_start_linked_stream() argument
718 mutex_lock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
721 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
722 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
737 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
738 dev_err(&mgr->pci->dev, "pcxhr_start_linked_stream : no pipes\n"); in pcxhr_start_linked_stream()
742 dev_dbg(&mgr->pci->dev, "pcxhr_start_linked_stream : " in pcxhr_start_linked_stream()
747 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0); in pcxhr_start_linked_stream()
749 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
750 dev_err(&mgr->pci->dev, "pcxhr_start_linked_stream : " in pcxhr_start_linked_stream()
757 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
759 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
776 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
778 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
792 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); in pcxhr_start_linked_stream()
794 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
795 dev_err(&mgr->pci->dev, "pcxhr_start_linked_stream : " in pcxhr_start_linked_stream()
804 mutex_lock(&mgr->lock); in pcxhr_start_linked_stream()
805 for ( i =0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
807 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
817 stream->timer_period_frag += mgr->granularity; in pcxhr_start_linked_stream()
822 mutex_unlock(&mgr->lock); in pcxhr_start_linked_stream()
824 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
829 dev_dbg(&mgr->pci->dev, "***TRIGGER START*** TIME = %ld (err = %x)\n", in pcxhr_start_linked_stream()
856 pcxhr_start_linked_stream(chip->mgr); in pcxhr_trigger()
893 static int pcxhr_hardware_timer(struct pcxhr_mgr *mgr, int start) in pcxhr_hardware_timer() argument
901 mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID; in pcxhr_hardware_timer()
902 rmh.cmd[0] |= mgr->granularity; in pcxhr_hardware_timer()
904 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_hardware_timer()
906 dev_err(&mgr->pci->dev, "error pcxhr_hardware_timer err(%x)\n", in pcxhr_hardware_timer()
917 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_prepare() local
925 mutex_lock(&mgr->setup_mutex); in pcxhr_prepare()
930 if (mgr->sample_rate != subs->runtime->rate) { in pcxhr_prepare()
931 err = pcxhr_set_clock(mgr, subs->runtime->rate); in pcxhr_prepare()
934 if (mgr->sample_rate == 0) in pcxhr_prepare()
936 err = pcxhr_hardware_timer(mgr, 1); in pcxhr_prepare()
937 mgr->sample_rate = subs->runtime->rate; in pcxhr_prepare()
941 mutex_unlock(&mgr->setup_mutex); in pcxhr_prepare()
954 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_hw_params() local
966 mutex_lock(&mgr->setup_mutex); in pcxhr_hw_params()
974 mutex_unlock(&mgr->setup_mutex); in pcxhr_hw_params()
1019 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_open() local
1024 mutex_lock(&mgr->setup_mutex); in pcxhr_open()
1036 if (mgr->mono_capture) in pcxhr_open()
1046 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1051 if (mgr->is_hr_stereo) in pcxhr_open()
1058 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1065 if (mgr->sample_rate) in pcxhr_open()
1066 runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate; in pcxhr_open()
1068 if (mgr->use_clock_type != PCXHR_CLOCK_TYPE_INTERNAL) { in pcxhr_open()
1070 if (pcxhr_get_external_clock(mgr, mgr->use_clock_type, in pcxhr_open()
1074 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1095 mgr->ref_count_rate++; in pcxhr_open()
1097 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1105 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_close() local
1108 mutex_lock(&mgr->setup_mutex); in pcxhr_close()
1114 if (--mgr->ref_count_rate == 0) { in pcxhr_close()
1115 mgr->sample_rate = 0; /* the sample rate is no more locked */ in pcxhr_close()
1116 pcxhr_hardware_timer(mgr, 0); /* stop the DSP-timer */ in pcxhr_close()
1122 mutex_unlock(&mgr->setup_mutex); in pcxhr_close()
1136 mutex_lock(&chip->mgr->lock); in pcxhr_stream_pointer()
1142 mutex_unlock(&chip->mgr->lock); in pcxhr_stream_pointer()
1187 snd_dma_pci_data(chip->mgr->pci), in pcxhr_create_pcm()
1208 static int pcxhr_create(struct pcxhr_mgr *mgr, in pcxhr_create() argument
1225 chip->mgr = mgr; in pcxhr_create()
1227 if (idx < mgr->playback_chips) in pcxhr_create()
1231 if (idx < mgr->capture_chips) { in pcxhr_create()
1232 if (mgr->mono_capture) in pcxhr_create()
1243 mgr->chip[idx] = chip; in pcxhr_create()
1253 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_info() local
1255 snd_iprintf(buffer, "\n%s\n", mgr->longname); in pcxhr_proc_info()
1258 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { in pcxhr_proc_info()
1260 short ver_maj = (mgr->dsp_version >> 16) & 0xff; in pcxhr_proc_info()
1261 short ver_min = (mgr->dsp_version >> 8) & 0xff; in pcxhr_proc_info()
1262 short ver_build = mgr->dsp_version & 0xff; in pcxhr_proc_info()
1267 if (mgr->board_has_analog) in pcxhr_proc_info()
1274 if( ! pcxhr_send_msg(mgr, &rmh) ) { in pcxhr_proc_info()
1278 if (mgr->sample_rate_real != 0 && in pcxhr_proc_info()
1279 mgr->sample_rate_real != 48000) { in pcxhr_proc_info()
1281 mgr->sample_rate_real; in pcxhr_proc_info()
1282 if (mgr->sample_rate_real >= in pcxhr_proc_info()
1293 mgr->granularity); in pcxhr_proc_info()
1295 mgr->dsp_time_err); in pcxhr_proc_info()
1297 mgr->async_err_pipe_xrun); in pcxhr_proc_info()
1299 mgr->async_err_stream_xrun); in pcxhr_proc_info()
1301 mgr->async_err_other_last); in pcxhr_proc_info()
1308 if( ! pcxhr_send_msg(mgr, &rmh) ) { in pcxhr_proc_info()
1324 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_sync() local
1334 if (mgr->is_hr_stereo) { in pcxhr_proc_sync()
1342 snd_iprintf(buffer, "\n%s\n", mgr->longname); in pcxhr_proc_sync()
1344 texts[mgr->cur_clock_type]); in pcxhr_proc_sync()
1346 mgr->sample_rate_real); in pcxhr_proc_sync()
1348 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { in pcxhr_proc_sync()
1351 err = pcxhr_get_external_clock(mgr, i, &sample_rate); in pcxhr_proc_sync()
1366 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_gpio_read() local
1368 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { in pcxhr_proc_gpio_read()
1371 hr222_read_gpio(mgr, 1, &value); /* GPI */ in pcxhr_proc_gpio_read()
1373 hr222_read_gpio(mgr, 0, &value); /* GP0 */ in pcxhr_proc_gpio_read()
1383 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_gpo_write() local
1387 if (!(mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX))) in pcxhr_proc_gpo_write()
1392 hr222_write_gpo(mgr, value); /* GP0 */ in pcxhr_proc_gpo_write()
1411 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_ltc() local
1416 if (!(mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX))) { in pcxhr_proc_ltc()
1420 if (!mgr->capture_ltc) { in pcxhr_proc_ltc()
1423 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_proc_ltc()
1428 if (mgr->is_hr_stereo) in pcxhr_proc_ltc()
1429 hr222_manage_timecode(mgr, 1); in pcxhr_proc_ltc()
1431 pcxhr_write_io_num_reg_cont(mgr, REG_CONT_VALSMPTE, in pcxhr_proc_ltc()
1433 mgr->capture_ltc = 1; in pcxhr_proc_ltc()
1436 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_proc_ltc()
1466 if (chip->mgr->is_hr_stereo && in pcxhr_proc_init()
1480 static int pcxhr_free(struct pcxhr_mgr *mgr) in pcxhr_free() argument
1484 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_free()
1485 if (mgr->chip[i]) in pcxhr_free()
1486 snd_card_free(mgr->chip[i]->card); in pcxhr_free()
1490 if(mgr->dsp_loaded) { in pcxhr_free()
1491 pcxhr_reset_board(mgr); in pcxhr_free()
1492 dev_dbg(&mgr->pci->dev, "reset pcxhr !\n"); in pcxhr_free()
1496 if (mgr->irq >= 0) in pcxhr_free()
1497 free_irq(mgr->irq, mgr); in pcxhr_free()
1499 pci_release_regions(mgr->pci); in pcxhr_free()
1502 if (mgr->hostport.area) { in pcxhr_free()
1503 snd_dma_free_pages(&mgr->hostport); in pcxhr_free()
1504 mgr->hostport.area = NULL; in pcxhr_free()
1507 kfree(mgr->prmh); in pcxhr_free()
1509 pci_disable_device(mgr->pci); in pcxhr_free()
1510 kfree(mgr); in pcxhr_free()
1521 struct pcxhr_mgr *mgr; in pcxhr_probe() local
1548 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); in pcxhr_probe()
1549 if (! mgr) { in pcxhr_probe()
1555 kfree(mgr); in pcxhr_probe()
1561 mgr->playback_chips = in pcxhr_probe()
1563 mgr->capture_chips = in pcxhr_probe()
1565 mgr->fw_file_set = in pcxhr_probe()
1567 mgr->firmware_num = in pcxhr_probe()
1569 mgr->mono_capture = mono[dev]; in pcxhr_probe()
1570 mgr->is_hr_stereo = (mgr->playback_chips == 1); in pcxhr_probe()
1571 mgr->board_has_aes1 = PCXHR_BOARD_HAS_AES1(mgr); in pcxhr_probe()
1572 mgr->board_aes_in_192k = !PCXHR_BOARD_AESIN_NO_192K(mgr); in pcxhr_probe()
1574 if (mgr->is_hr_stereo) in pcxhr_probe()
1575 mgr->granularity = PCXHR_GRANULARITY_HR22; in pcxhr_probe()
1577 mgr->granularity = PCXHR_GRANULARITY; in pcxhr_probe()
1581 kfree(mgr); in pcxhr_probe()
1586 mgr->port[i] = pci_resource_start(pci, i); in pcxhr_probe()
1588 mgr->pci = pci; in pcxhr_probe()
1589 mgr->irq = -1; in pcxhr_probe()
1593 KBUILD_MODNAME, mgr)) { in pcxhr_probe()
1595 pcxhr_free(mgr); in pcxhr_probe()
1598 mgr->irq = pci->irq; in pcxhr_probe()
1600 sprintf(mgr->shortname, "Digigram %s", card_name); in pcxhr_probe()
1601 sprintf(mgr->longname, "%s at 0x%lx & 0x%lx, 0x%lx irq %i", in pcxhr_probe()
1602 mgr->shortname, in pcxhr_probe()
1603 mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq); in pcxhr_probe()
1606 mutex_init(&mgr->lock); in pcxhr_probe()
1607 mutex_init(&mgr->msg_lock); in pcxhr_probe()
1610 mutex_init(&mgr->setup_mutex); in pcxhr_probe()
1612 mgr->prmh = kmalloc(sizeof(*mgr->prmh) + in pcxhr_probe()
1616 if (! mgr->prmh) { in pcxhr_probe()
1617 pcxhr_free(mgr); in pcxhr_probe()
1626 if (i >= max(mgr->playback_chips, mgr->capture_chips)) in pcxhr_probe()
1628 mgr->num_cards++; in pcxhr_probe()
1642 pcxhr_free(mgr); in pcxhr_probe()
1647 sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i); in pcxhr_probe()
1648 sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); in pcxhr_probe()
1650 if ((err = pcxhr_create(mgr, card, i)) < 0) { in pcxhr_probe()
1652 pcxhr_free(mgr); in pcxhr_probe()
1658 pcxhr_proc_init(mgr->chip[i]); in pcxhr_probe()
1661 pcxhr_free(mgr); in pcxhr_probe()
1669 size, &mgr->hostport) < 0) { in pcxhr_probe()
1670 pcxhr_free(mgr); in pcxhr_probe()
1674 memset(mgr->hostport.area, 0, size); in pcxhr_probe()
1677 err = pcxhr_setup_firmware(mgr); in pcxhr_probe()
1679 pcxhr_free(mgr); in pcxhr_probe()
1683 pci_set_drvdata(pci, mgr); in pcxhr_probe()