Lines Matching refs:mgr

234 static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate,  in pcxhr_get_clock_reg()  argument
242 switch (mgr->use_clock_type) { in pcxhr_get_clock_reg()
271 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_get_clock_reg()
273 dev_err(&mgr->pci->dev, in pcxhr_get_clock_reg()
307 static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr, in pcxhr_sub_set_clock() argument
315 err = pcxhr_get_clock_reg(mgr, rate, &val, &realfreq); in pcxhr_sub_set_clock()
326 if (mgr->codec_speed != speed) { in pcxhr_sub_set_clock()
329 if (DSP_EXT_CMD_SET(mgr)) { in pcxhr_sub_set_clock()
333 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_set_clock()
341 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_set_clock()
346 dev_dbg(&mgr->pci->dev, "clock register : set %x\n", val); in pcxhr_sub_set_clock()
347 err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK, in pcxhr_sub_set_clock()
352 mgr->sample_rate_real = realfreq; in pcxhr_sub_set_clock()
353 mgr->cur_clock_type = mgr->use_clock_type; in pcxhr_sub_set_clock()
356 if (mgr->codec_speed != speed) { in pcxhr_sub_set_clock()
359 if (DSP_EXT_CMD_SET(mgr)) { in pcxhr_sub_set_clock()
363 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_set_clock()
366 mgr->codec_speed = speed; /* save new codec speed */ in pcxhr_sub_set_clock()
369 dev_dbg(&mgr->pci->dev, "%s to %dHz (realfreq=%d)\n", __func__, in pcxhr_sub_set_clock()
379 int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate) in pcxhr_set_clock() argument
387 if (mgr->is_hr_stereo) in pcxhr_set_clock()
388 err = hr222_sub_set_clock(mgr, rate, &changed); in pcxhr_set_clock()
390 err = pcxhr_sub_set_clock(mgr, rate, &changed); in pcxhr_set_clock()
404 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_set_clock()
412 static int pcxhr_sub_get_external_clock(struct pcxhr_mgr *mgr, in pcxhr_sub_get_external_clock() argument
445 if (mgr->last_reg_stat != reg) { in pcxhr_sub_get_external_clock()
447 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_get_external_clock()
451 mgr->last_reg_stat = reg; in pcxhr_sub_get_external_clock()
454 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_sub_get_external_clock()
469 dev_dbg(&mgr->pci->dev, "External clock is at %d Hz\n", rate); in pcxhr_sub_get_external_clock()
475 int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, in pcxhr_get_external_clock() argument
479 if (mgr->is_hr_stereo) in pcxhr_get_external_clock()
480 return hr222_get_external_clock(mgr, clock_type, in pcxhr_get_external_clock()
483 return pcxhr_sub_get_external_clock(mgr, clock_type, in pcxhr_get_external_clock()
524 err = pcxhr_send_msg(chip->mgr, &rmh); in pcxhr_set_stream_state()
577 sample_rate = chip->mgr->sample_rate; in pcxhr_set_format()
597 if (DSP_EXT_CMD_SET(chip->mgr)) in pcxhr_set_format()
604 if (DSP_EXT_CMD_SET(chip->mgr)) { in pcxhr_set_format()
615 err = pcxhr_send_msg(chip->mgr, &rmh); in pcxhr_set_format()
653 err = pcxhr_send_msg(chip->mgr, &rmh); in pcxhr_update_r_buffer()
671 err = pcxhr_send_msg(chip->mgr, &rmh);
691 static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr) in pcxhr_start_linked_stream() argument
704 mutex_lock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
707 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
708 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
723 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
724 dev_err(&mgr->pci->dev, "%s : no pipes\n", __func__); in pcxhr_start_linked_stream()
728 dev_dbg(&mgr->pci->dev, "%s : playback_mask=%x capture_mask=%x\n", in pcxhr_start_linked_stream()
732 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0); in pcxhr_start_linked_stream()
734 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
735 dev_err(&mgr->pci->dev, "%s : " in pcxhr_start_linked_stream()
742 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
744 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
761 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
763 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
777 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); in pcxhr_start_linked_stream()
779 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
780 dev_err(&mgr->pci->dev, "%s : " in pcxhr_start_linked_stream()
789 mutex_lock(&mgr->lock); in pcxhr_start_linked_stream()
790 for ( i =0; i < mgr->num_cards; i++) { in pcxhr_start_linked_stream()
792 chip = mgr->chip[i]; in pcxhr_start_linked_stream()
802 stream->timer_period_frag += mgr->granularity; in pcxhr_start_linked_stream()
807 mutex_unlock(&mgr->lock); in pcxhr_start_linked_stream()
809 mutex_unlock(&mgr->setup_mutex); in pcxhr_start_linked_stream()
814 dev_dbg(&mgr->pci->dev, "***TRIGGER START*** TIME = %ld (err = %x)\n", in pcxhr_start_linked_stream()
841 pcxhr_start_linked_stream(chip->mgr); in pcxhr_trigger()
878 static int pcxhr_hardware_timer(struct pcxhr_mgr *mgr, int start) in pcxhr_hardware_timer() argument
886 mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID; in pcxhr_hardware_timer()
887 rmh.cmd[0] |= mgr->granularity; in pcxhr_hardware_timer()
889 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_hardware_timer()
891 dev_err(&mgr->pci->dev, "error %s err(%x)\n", __func__, in pcxhr_hardware_timer()
902 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_prepare() local
910 mutex_lock(&mgr->setup_mutex); in pcxhr_prepare()
915 if (mgr->sample_rate != subs->runtime->rate) { in pcxhr_prepare()
916 err = pcxhr_set_clock(mgr, subs->runtime->rate); in pcxhr_prepare()
919 if (mgr->sample_rate == 0) in pcxhr_prepare()
921 err = pcxhr_hardware_timer(mgr, 1); in pcxhr_prepare()
922 mgr->sample_rate = subs->runtime->rate; in pcxhr_prepare()
926 mutex_unlock(&mgr->setup_mutex); in pcxhr_prepare()
939 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_hw_params() local
942 mutex_lock(&mgr->setup_mutex); in pcxhr_hw_params()
949 mutex_unlock(&mgr->setup_mutex); in pcxhr_hw_params()
988 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_open() local
993 mutex_lock(&mgr->setup_mutex); in pcxhr_open()
1005 if (mgr->mono_capture) in pcxhr_open()
1015 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1020 if (mgr->is_hr_stereo) in pcxhr_open()
1027 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1034 if (mgr->sample_rate) in pcxhr_open()
1035 runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate; in pcxhr_open()
1037 if (mgr->use_clock_type != PCXHR_CLOCK_TYPE_INTERNAL) { in pcxhr_open()
1039 if (pcxhr_get_external_clock(mgr, mgr->use_clock_type, in pcxhr_open()
1043 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1064 mgr->ref_count_rate++; in pcxhr_open()
1066 mutex_unlock(&mgr->setup_mutex); in pcxhr_open()
1074 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_close() local
1077 mutex_lock(&mgr->setup_mutex); in pcxhr_close()
1083 if (--mgr->ref_count_rate == 0) { in pcxhr_close()
1084 mgr->sample_rate = 0; /* the sample rate is no more locked */ in pcxhr_close()
1085 pcxhr_hardware_timer(mgr, 0); /* stop the DSP-timer */ in pcxhr_close()
1091 mutex_unlock(&mgr->setup_mutex); in pcxhr_close()
1105 mutex_lock(&chip->mgr->lock); in pcxhr_stream_pointer()
1111 mutex_unlock(&chip->mgr->lock); in pcxhr_stream_pointer()
1155 &chip->mgr->pci->dev, in pcxhr_create_pcm()
1176 static int pcxhr_create(struct pcxhr_mgr *mgr, in pcxhr_create() argument
1191 chip->mgr = mgr; in pcxhr_create()
1192 card->sync_irq = mgr->irq; in pcxhr_create()
1194 if (idx < mgr->playback_chips) in pcxhr_create()
1198 if (idx < mgr->capture_chips) { in pcxhr_create()
1199 if (mgr->mono_capture) in pcxhr_create()
1211 mgr->chip[idx] = chip; in pcxhr_create()
1221 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_info() local
1223 snd_iprintf(buffer, "\n%s\n", mgr->name); in pcxhr_proc_info()
1226 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { in pcxhr_proc_info()
1228 short ver_maj = (mgr->dsp_version >> 16) & 0xff; in pcxhr_proc_info()
1229 short ver_min = (mgr->dsp_version >> 8) & 0xff; in pcxhr_proc_info()
1230 short ver_build = mgr->dsp_version & 0xff; in pcxhr_proc_info()
1235 if (mgr->board_has_analog) in pcxhr_proc_info()
1242 if( ! pcxhr_send_msg(mgr, &rmh) ) { in pcxhr_proc_info()
1246 if (mgr->sample_rate_real != 0 && in pcxhr_proc_info()
1247 mgr->sample_rate_real != 48000) { in pcxhr_proc_info()
1249 mgr->sample_rate_real; in pcxhr_proc_info()
1250 if (mgr->sample_rate_real >= in pcxhr_proc_info()
1261 mgr->granularity); in pcxhr_proc_info()
1263 mgr->dsp_time_err); in pcxhr_proc_info()
1265 mgr->async_err_pipe_xrun); in pcxhr_proc_info()
1267 mgr->async_err_stream_xrun); in pcxhr_proc_info()
1269 mgr->async_err_other_last); in pcxhr_proc_info()
1276 if( ! pcxhr_send_msg(mgr, &rmh) ) { in pcxhr_proc_info()
1292 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_sync() local
1302 if (mgr->is_hr_stereo) { in pcxhr_proc_sync()
1310 snd_iprintf(buffer, "\n%s\n", mgr->name); in pcxhr_proc_sync()
1312 texts[mgr->cur_clock_type]); in pcxhr_proc_sync()
1314 mgr->sample_rate_real); in pcxhr_proc_sync()
1316 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { in pcxhr_proc_sync()
1319 err = pcxhr_get_external_clock(mgr, i, &sample_rate); in pcxhr_proc_sync()
1334 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_gpio_read() local
1336 if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { in pcxhr_proc_gpio_read()
1339 hr222_read_gpio(mgr, 1, &value); /* GPI */ in pcxhr_proc_gpio_read()
1341 hr222_read_gpio(mgr, 0, &value); /* GP0 */ in pcxhr_proc_gpio_read()
1351 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_gpo_write() local
1355 if (!(mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX))) in pcxhr_proc_gpo_write()
1360 hr222_write_gpo(mgr, value); /* GP0 */ in pcxhr_proc_gpo_write()
1379 struct pcxhr_mgr *mgr = chip->mgr; in pcxhr_proc_ltc() local
1384 if (!(mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX))) { in pcxhr_proc_ltc()
1388 if (!mgr->capture_ltc) { in pcxhr_proc_ltc()
1391 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_proc_ltc()
1396 if (mgr->is_hr_stereo) in pcxhr_proc_ltc()
1397 hr222_manage_timecode(mgr, 1); in pcxhr_proc_ltc()
1399 pcxhr_write_io_num_reg_cont(mgr, REG_CONT_VALSMPTE, in pcxhr_proc_ltc()
1401 mgr->capture_ltc = 1; in pcxhr_proc_ltc()
1404 err = pcxhr_send_msg(mgr, &rmh); in pcxhr_proc_ltc()
1430 if (chip->mgr->is_hr_stereo) in pcxhr_proc_init()
1441 static int pcxhr_free(struct pcxhr_mgr *mgr) in pcxhr_free() argument
1445 for (i = 0; i < mgr->num_cards; i++) { in pcxhr_free()
1446 if (mgr->chip[i]) in pcxhr_free()
1447 snd_card_free(mgr->chip[i]->card); in pcxhr_free()
1451 if(mgr->dsp_loaded) { in pcxhr_free()
1452 pcxhr_reset_board(mgr); in pcxhr_free()
1453 dev_dbg(&mgr->pci->dev, "reset pcxhr !\n"); in pcxhr_free()
1457 if (mgr->irq >= 0) in pcxhr_free()
1458 free_irq(mgr->irq, mgr); in pcxhr_free()
1460 pci_release_regions(mgr->pci); in pcxhr_free()
1463 if (mgr->hostport.area) { in pcxhr_free()
1464 snd_dma_free_pages(&mgr->hostport); in pcxhr_free()
1465 mgr->hostport.area = NULL; in pcxhr_free()
1468 kfree(mgr->prmh); in pcxhr_free()
1470 pci_disable_device(mgr->pci); in pcxhr_free()
1471 kfree(mgr); in pcxhr_free()
1482 struct pcxhr_mgr *mgr; in pcxhr_probe() local
1510 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); in pcxhr_probe()
1511 if (! mgr) { in pcxhr_probe()
1517 kfree(mgr); in pcxhr_probe()
1523 mgr->playback_chips = in pcxhr_probe()
1525 mgr->capture_chips = in pcxhr_probe()
1527 mgr->fw_file_set = in pcxhr_probe()
1529 mgr->firmware_num = in pcxhr_probe()
1531 mgr->mono_capture = mono[dev]; in pcxhr_probe()
1532 mgr->is_hr_stereo = (mgr->playback_chips == 1); in pcxhr_probe()
1533 mgr->board_has_aes1 = PCXHR_BOARD_HAS_AES1(mgr); in pcxhr_probe()
1534 mgr->board_aes_in_192k = !PCXHR_BOARD_AESIN_NO_192K(mgr); in pcxhr_probe()
1536 if (mgr->is_hr_stereo) in pcxhr_probe()
1537 mgr->granularity = PCXHR_GRANULARITY_HR22; in pcxhr_probe()
1539 mgr->granularity = PCXHR_GRANULARITY; in pcxhr_probe()
1544 kfree(mgr); in pcxhr_probe()
1549 mgr->port[i] = pci_resource_start(pci, i); in pcxhr_probe()
1551 mgr->pci = pci; in pcxhr_probe()
1552 mgr->irq = -1; in pcxhr_probe()
1556 KBUILD_MODNAME, mgr)) { in pcxhr_probe()
1558 pcxhr_free(mgr); in pcxhr_probe()
1561 mgr->irq = pci->irq; in pcxhr_probe()
1563 snprintf(mgr->name, sizeof(mgr->name), in pcxhr_probe()
1565 mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq); in pcxhr_probe()
1568 mutex_init(&mgr->lock); in pcxhr_probe()
1569 mutex_init(&mgr->msg_lock); in pcxhr_probe()
1572 mutex_init(&mgr->setup_mutex); in pcxhr_probe()
1574 mgr->prmh = kmalloc(sizeof(*mgr->prmh) + in pcxhr_probe()
1578 if (! mgr->prmh) { in pcxhr_probe()
1579 pcxhr_free(mgr); in pcxhr_probe()
1588 if (i >= max(mgr->playback_chips, mgr->capture_chips)) in pcxhr_probe()
1590 mgr->num_cards++; in pcxhr_probe()
1604 pcxhr_free(mgr); in pcxhr_probe()
1612 "%s [PCM #%d]", mgr->name, i); in pcxhr_probe()
1614 err = pcxhr_create(mgr, card, i); in pcxhr_probe()
1617 pcxhr_free(mgr); in pcxhr_probe()
1623 pcxhr_proc_init(mgr->chip[i]); in pcxhr_probe()
1627 pcxhr_free(mgr); in pcxhr_probe()
1635 size, &mgr->hostport) < 0) { in pcxhr_probe()
1636 pcxhr_free(mgr); in pcxhr_probe()
1640 memset(mgr->hostport.area, 0, size); in pcxhr_probe()
1643 err = pcxhr_setup_firmware(mgr); in pcxhr_probe()
1645 pcxhr_free(mgr); in pcxhr_probe()
1649 pci_set_drvdata(pci, mgr); in pcxhr_probe()