Lines Matching refs:mgr
235 static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate, in pcxhr_get_clock_reg() argument
243 switch (mgr->use_clock_type) { in pcxhr_get_clock_reg()
272 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_get_clock_reg()
274 dev_err(&mgr->pci->dev, in pcxhr_get_clock_reg()
308 static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr, in pcxhr_sub_set_clock() argument
316 err = pcxhr_get_clock_reg(mgr, rate, &val, &realfreq); in pcxhr_sub_set_clock()
327 if (mgr->codec_speed != speed) { in pcxhr_sub_set_clock()
330 if (DSP_EXT_CMD_SET(mgr)) { in pcxhr_sub_set_clock()
334 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_set_clock()
342 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_set_clock()
347 dev_dbg(&mgr->pci->dev, "clock register : set %x\n", val); in pcxhr_sub_set_clock()
348 err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK, in pcxhr_sub_set_clock()
353 mgr->sample_rate_real = realfreq; in pcxhr_sub_set_clock()
354 mgr->cur_clock_type = mgr->use_clock_type; in pcxhr_sub_set_clock()
357 if (mgr->codec_speed != speed) { in pcxhr_sub_set_clock()
360 if (DSP_EXT_CMD_SET(mgr)) { in pcxhr_sub_set_clock()
364 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_set_clock()
367 mgr->codec_speed = speed; /* save new codec speed */ in pcxhr_sub_set_clock()
370 dev_dbg(&mgr->pci->dev, "pcxhr_sub_set_clock to %dHz (realfreq=%d)\n", in pcxhr_sub_set_clock()
380 int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate) in pcxhr_set_clock() argument
388 if (mgr->is_hr_stereo) in pcxhr_set_clock()
389 err = hr222_sub_set_clock(mgr, rate, &changed); in pcxhr_set_clock()
391 err = pcxhr_sub_set_clock(mgr, rate, &changed); in pcxhr_set_clock()
405 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_set_clock()
413 static int pcxhr_sub_get_external_clock(struct pcxhr_mgr *mgr, in pcxhr_sub_get_external_clock() argument
446 if (mgr->last_reg_stat != reg) { in pcxhr_sub_get_external_clock()
448 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_get_external_clock()
452 mgr->last_reg_stat = reg; in pcxhr_sub_get_external_clock()
455 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_get_external_clock()
470 dev_dbg(&mgr->pci->dev, "External clock is at %d Hz\n", rate); in pcxhr_sub_get_external_clock()
476 int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, in pcxhr_get_external_clock() argument
480 if (mgr->is_hr_stereo) in pcxhr_get_external_clock()
481 return hr222_get_external_clock(mgr, clock_type, in pcxhr_get_external_clock()
484 return pcxhr_sub_get_external_clock(mgr, clock_type, in pcxhr_get_external_clock()
525 err = pcxhr_send_msg(chip->mgr, &rmh); in pcxhr_set_stream_state()
578 sample_rate = chip->mgr->sample_rate; in pcxhr_set_format()
598 if (DSP_EXT_CMD_SET(chip->mgr)) in pcxhr_set_format()
605 if (DSP_EXT_CMD_SET(chip->mgr)) { in pcxhr_set_format()
616 err = pcxhr_send_msg(chip->mgr, &rmh); in pcxhr_set_format()
654 err = pcxhr_send_msg(chip->mgr, &rmh); in pcxhr_update_r_buffer()
672 err = pcxhr_send_msg(chip->mgr, &rmh);
692 static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr) in pcxhr_start_linked_stream() argument
705 mutex_lock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
708 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
709 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
724 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
725 dev_err(&mgr->pci->dev, "pcxhr_start_linked_stream : no pipes\n"); in pcxhr_start_linked_stream()
729 dev_dbg(&mgr->pci->dev, "pcxhr_start_linked_stream : " in pcxhr_start_linked_stream()
734 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0); in pcxhr_start_linked_stream()
736 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
737 dev_err(&mgr->pci->dev, "pcxhr_start_linked_stream : " in pcxhr_start_linked_stream()
744 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
746 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
763 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
765 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
779 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); in pcxhr_start_linked_stream()
781 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
782 dev_err(&mgr->pci->dev, "pcxhr_start_linked_stream : " in pcxhr_start_linked_stream()
791 mutex_lock(&mgr->lock); in pcxhr_start_linked_stream()
792 for ( i =0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
794 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
804 stream->timer_period_frag += mgr->granularity; in pcxhr_start_linked_stream()
809 mutex_unlock(&mgr->lock); in pcxhr_start_linked_stream()
811 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
816 dev_dbg(&mgr->pci->dev, "***TRIGGER START*** TIME = %ld (err = %x)\n", in pcxhr_start_linked_stream()
843 pcxhr_start_linked_stream(chip->mgr); in pcxhr_trigger()
880 static int pcxhr_hardware_timer(struct pcxhr_mgr *mgr, int start) in pcxhr_hardware_timer() argument
888 mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID; in pcxhr_hardware_timer()
889 rmh.cmd[0] |= mgr->granularity; in pcxhr_hardware_timer()
891 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_hardware_timer()
893 dev_err(&mgr->pci->dev, "error pcxhr_hardware_timer err(%x)\n", in pcxhr_hardware_timer()
904 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_prepare() local
912 mutex_lock(&mgr->setup_mutex); in pcxhr_prepare()
917 if (mgr->sample_rate != subs->runtime->rate) { in pcxhr_prepare()
918 err = pcxhr_set_clock(mgr, subs->runtime->rate); in pcxhr_prepare()
921 if (mgr->sample_rate == 0) in pcxhr_prepare()
923 err = pcxhr_hardware_timer(mgr, 1); in pcxhr_prepare()
924 mgr->sample_rate = subs->runtime->rate; in pcxhr_prepare()
928 mutex_unlock(&mgr->setup_mutex); in pcxhr_prepare()
941 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_hw_params() local
953 mutex_lock(&mgr->setup_mutex); in pcxhr_hw_params()
961 mutex_unlock(&mgr->setup_mutex); in pcxhr_hw_params()
1006 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_open() local
1011 mutex_lock(&mgr->setup_mutex); in pcxhr_open()
1023 if (mgr->mono_capture) in pcxhr_open()
1033 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1038 if (mgr->is_hr_stereo) in pcxhr_open()
1045 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1052 if (mgr->sample_rate) in pcxhr_open()
1053 runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate; in pcxhr_open()
1055 if (mgr->use_clock_type != PCXHR_CLOCK_TYPE_INTERNAL) { in pcxhr_open()
1057 if (pcxhr_get_external_clock(mgr, mgr->use_clock_type, in pcxhr_open()
1061 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1082 mgr->ref_count_rate++; in pcxhr_open()
1084 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1092 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_close() local
1095 mutex_lock(&mgr->setup_mutex); in pcxhr_close()
1101 if (--mgr->ref_count_rate == 0) { in pcxhr_close()
1102 mgr->sample_rate = 0; /* the sample rate is no more locked */ in pcxhr_close()
1103 pcxhr_hardware_timer(mgr, 0); /* stop the DSP-timer */ in pcxhr_close()
1109 mutex_unlock(&mgr->setup_mutex); in pcxhr_close()
1123 mutex_lock(&chip->mgr->lock); in pcxhr_stream_pointer()
1129 mutex_unlock(&chip->mgr->lock); in pcxhr_stream_pointer()
1174 snd_dma_pci_data(chip->mgr->pci), in pcxhr_create_pcm()
1195 static int pcxhr_create(struct pcxhr_mgr *mgr, in pcxhr_create() argument
1210 chip->mgr = mgr; in pcxhr_create()
1212 if (idx < mgr->playback_chips) in pcxhr_create()
1216 if (idx < mgr->capture_chips) { in pcxhr_create()
1217 if (mgr->mono_capture) in pcxhr_create()
1228 mgr->chip[idx] = chip; in pcxhr_create()
1238 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_info() local
1240 snd_iprintf(buffer, "\n%s\n", mgr->name); in pcxhr_proc_info()
1243 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { in pcxhr_proc_info()
1245 short ver_maj = (mgr->dsp_version >> 16) & 0xff; in pcxhr_proc_info()
1246 short ver_min = (mgr->dsp_version >> 8) & 0xff; in pcxhr_proc_info()
1247 short ver_build = mgr->dsp_version & 0xff; in pcxhr_proc_info()
1252 if (mgr->board_has_analog) in pcxhr_proc_info()
1259 if( ! pcxhr_send_msg(mgr, &rmh) ) { in pcxhr_proc_info()
1263 if (mgr->sample_rate_real != 0 && in pcxhr_proc_info()
1264 mgr->sample_rate_real != 48000) { in pcxhr_proc_info()
1266 mgr->sample_rate_real; in pcxhr_proc_info()
1267 if (mgr->sample_rate_real >= in pcxhr_proc_info()
1278 mgr->granularity); in pcxhr_proc_info()
1280 mgr->dsp_time_err); in pcxhr_proc_info()
1282 mgr->async_err_pipe_xrun); in pcxhr_proc_info()
1284 mgr->async_err_stream_xrun); in pcxhr_proc_info()
1286 mgr->async_err_other_last); in pcxhr_proc_info()
1293 if( ! pcxhr_send_msg(mgr, &rmh) ) { in pcxhr_proc_info()
1309 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_sync() local
1319 if (mgr->is_hr_stereo) { in pcxhr_proc_sync()
1327 snd_iprintf(buffer, "\n%s\n", mgr->name); in pcxhr_proc_sync()
1329 texts[mgr->cur_clock_type]); in pcxhr_proc_sync()
1331 mgr->sample_rate_real); in pcxhr_proc_sync()
1333 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { in pcxhr_proc_sync()
1336 err = pcxhr_get_external_clock(mgr, i, &sample_rate); in pcxhr_proc_sync()
1351 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_gpio_read() local
1353 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { in pcxhr_proc_gpio_read()
1356 hr222_read_gpio(mgr, 1, &value); /* GPI */ in pcxhr_proc_gpio_read()
1358 hr222_read_gpio(mgr, 0, &value); /* GP0 */ in pcxhr_proc_gpio_read()
1368 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_gpo_write() local
1372 if (!(mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX))) in pcxhr_proc_gpo_write()
1377 hr222_write_gpo(mgr, value); /* GP0 */ in pcxhr_proc_gpo_write()
1396 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_ltc() local
1401 if (!(mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX))) { in pcxhr_proc_ltc()
1405 if (!mgr->capture_ltc) { in pcxhr_proc_ltc()
1408 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_proc_ltc()
1413 if (mgr->is_hr_stereo) in pcxhr_proc_ltc()
1414 hr222_manage_timecode(mgr, 1); in pcxhr_proc_ltc()
1416 pcxhr_write_io_num_reg_cont(mgr, REG_CONT_VALSMPTE, in pcxhr_proc_ltc()
1418 mgr->capture_ltc = 1; in pcxhr_proc_ltc()
1421 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_proc_ltc()
1447 if (chip->mgr->is_hr_stereo) in pcxhr_proc_init()
1458 static int pcxhr_free(struct pcxhr_mgr *mgr) in pcxhr_free() argument
1462 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_free()
1463 if (mgr->chip[i]) in pcxhr_free()
1464 snd_card_free(mgr->chip[i]->card); in pcxhr_free()
1468 if(mgr->dsp_loaded) { in pcxhr_free()
1469 pcxhr_reset_board(mgr); in pcxhr_free()
1470 dev_dbg(&mgr->pci->dev, "reset pcxhr !\n"); in pcxhr_free()
1474 if (mgr->irq >= 0) in pcxhr_free()
1475 free_irq(mgr->irq, mgr); in pcxhr_free()
1477 pci_release_regions(mgr->pci); in pcxhr_free()
1480 if (mgr->hostport.area) { in pcxhr_free()
1481 snd_dma_free_pages(&mgr->hostport); in pcxhr_free()
1482 mgr->hostport.area = NULL; in pcxhr_free()
1485 kfree(mgr->prmh); in pcxhr_free()
1487 pci_disable_device(mgr->pci); in pcxhr_free()
1488 kfree(mgr); in pcxhr_free()
1499 struct pcxhr_mgr *mgr; in pcxhr_probe() local
1526 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); in pcxhr_probe()
1527 if (! mgr) { in pcxhr_probe()
1533 kfree(mgr); in pcxhr_probe()
1539 mgr->playback_chips = in pcxhr_probe()
1541 mgr->capture_chips = in pcxhr_probe()
1543 mgr->fw_file_set = in pcxhr_probe()
1545 mgr->firmware_num = in pcxhr_probe()
1547 mgr->mono_capture = mono[dev]; in pcxhr_probe()
1548 mgr->is_hr_stereo = (mgr->playback_chips == 1); in pcxhr_probe()
1549 mgr->board_has_aes1 = PCXHR_BOARD_HAS_AES1(mgr); in pcxhr_probe()
1550 mgr->board_aes_in_192k = !PCXHR_BOARD_AESIN_NO_192K(mgr); in pcxhr_probe()
1552 if (mgr->is_hr_stereo) in pcxhr_probe()
1553 mgr->granularity = PCXHR_GRANULARITY_HR22; in pcxhr_probe()
1555 mgr->granularity = PCXHR_GRANULARITY; in pcxhr_probe()
1559 kfree(mgr); in pcxhr_probe()
1564 mgr->port[i] = pci_resource_start(pci, i); in pcxhr_probe()
1566 mgr->pci = pci; in pcxhr_probe()
1567 mgr->irq = -1; in pcxhr_probe()
1571 KBUILD_MODNAME, mgr)) { in pcxhr_probe()
1573 pcxhr_free(mgr); in pcxhr_probe()
1576 mgr->irq = pci->irq; in pcxhr_probe()
1578 snprintf(mgr->name, sizeof(mgr->name), in pcxhr_probe()
1580 mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq); in pcxhr_probe()
1583 mutex_init(&mgr->lock); in pcxhr_probe()
1584 mutex_init(&mgr->msg_lock); in pcxhr_probe()
1587 mutex_init(&mgr->setup_mutex); in pcxhr_probe()
1589 mgr->prmh = kmalloc(sizeof(*mgr->prmh) + in pcxhr_probe()
1593 if (! mgr->prmh) { in pcxhr_probe()
1594 pcxhr_free(mgr); in pcxhr_probe()
1603 if (i >= max(mgr->playback_chips, mgr->capture_chips)) in pcxhr_probe()
1605 mgr->num_cards++; in pcxhr_probe()
1619 pcxhr_free(mgr); in pcxhr_probe()
1627 "%s [PCM #%d]", mgr->name, i); in pcxhr_probe()
1629 if ((err = pcxhr_create(mgr, card, i)) < 0) { in pcxhr_probe()
1631 pcxhr_free(mgr); in pcxhr_probe()
1637 pcxhr_proc_init(mgr->chip[i]); in pcxhr_probe()
1640 pcxhr_free(mgr); in pcxhr_probe()
1648 size, &mgr->hostport) < 0) { in pcxhr_probe()
1649 pcxhr_free(mgr); in pcxhr_probe()
1653 memset(mgr->hostport.area, 0, size); in pcxhr_probe()
1656 err = pcxhr_setup_firmware(mgr); in pcxhr_probe()
1658 pcxhr_free(mgr); in pcxhr_probe()
1662 pci_set_drvdata(pci, mgr); in pcxhr_probe()