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