Lines Matching defs:mgr

235 static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate,
243 switch (mgr->use_clock_type) {
272 err = pcxhr_send_msg(mgr, &rmh);
274 dev_err(&mgr->pci->dev,
308 static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr,
316 err = pcxhr_get_clock_reg(mgr, rate, &val, &realfreq);
327 if (mgr->codec_speed != speed) {
330 if (DSP_EXT_CMD_SET(mgr)) {
334 err = pcxhr_send_msg(mgr, &rmh);
342 err = pcxhr_send_msg(mgr, &rmh);
347 dev_dbg(&mgr->pci->dev, "clock register : set %x\n", val);
348 err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK,
353 mgr->sample_rate_real = realfreq;
354 mgr->cur_clock_type = mgr->use_clock_type;
357 if (mgr->codec_speed != speed) {
360 if (DSP_EXT_CMD_SET(mgr)) {
364 err = pcxhr_send_msg(mgr, &rmh);
367 mgr->codec_speed = speed; /* save new codec speed */
370 dev_dbg(&mgr->pci->dev, "pcxhr_sub_set_clock to %dHz (realfreq=%d)\n",
380 int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate)
388 if (mgr->is_hr_stereo)
389 err = hr222_sub_set_clock(mgr, rate, &changed);
391 err = pcxhr_sub_set_clock(mgr, rate, &changed);
405 err = pcxhr_send_msg(mgr, &rmh);
413 static int pcxhr_sub_get_external_clock(struct pcxhr_mgr *mgr,
446 if (mgr->last_reg_stat != reg) {
448 err = pcxhr_send_msg(mgr, &rmh);
452 mgr->last_reg_stat = reg;
455 err = pcxhr_send_msg(mgr, &rmh);
470 dev_dbg(&mgr->pci->dev, "External clock is at %d Hz\n", rate);
476 int pcxhr_get_external_clock(struct pcxhr_mgr *mgr,
480 if (mgr->is_hr_stereo)
481 return hr222_get_external_clock(mgr, clock_type,
484 return pcxhr_sub_get_external_clock(mgr, clock_type,
525 err = pcxhr_send_msg(chip->mgr, &rmh);
578 sample_rate = chip->mgr->sample_rate;
598 if (DSP_EXT_CMD_SET(chip->mgr))
605 if (DSP_EXT_CMD_SET(chip->mgr)) {
616 err = pcxhr_send_msg(chip->mgr, &rmh);
654 err = pcxhr_send_msg(chip->mgr, &rmh);
672 err = pcxhr_send_msg(chip->mgr, &rmh);
692 static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr)
705 mutex_lock(&mgr->setup_mutex);
708 for (i = 0; i < mgr->num_cards; i++) {
709 chip = mgr->chip[i];
724 mutex_unlock(&mgr->setup_mutex);
725 dev_err(&mgr->pci->dev, "pcxhr_start_linked_stream : no pipes\n");
729 dev_dbg(&mgr->pci->dev, "pcxhr_start_linked_stream : "
734 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0);
736 mutex_unlock(&mgr->setup_mutex);
737 dev_err(&mgr->pci->dev, "pcxhr_start_linked_stream : "
744 for (i = 0; i < mgr->num_cards; i++) {
746 chip = mgr->chip[i];
763 for (i = 0; i < mgr->num_cards; i++) {
765 chip = mgr->chip[i];
779 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1);
781 mutex_unlock(&mgr->setup_mutex);
782 dev_err(&mgr->pci->dev, "pcxhr_start_linked_stream : "
791 mutex_lock(&mgr->lock);
792 for ( i =0; i < mgr->num_cards; i++) {
794 chip = mgr->chip[i];
804 stream->timer_period_frag += mgr->granularity;
809 mutex_unlock(&mgr->lock);
811 mutex_unlock(&mgr->setup_mutex);
816 dev_dbg(&mgr->pci->dev, "***TRIGGER START*** TIME = %ld (err = %x)\n",
843 pcxhr_start_linked_stream(chip->mgr);
880 static int pcxhr_hardware_timer(struct pcxhr_mgr *mgr, int start)
888 mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID;
889 rmh.cmd[0] |= mgr->granularity;
891 err = pcxhr_send_msg(mgr, &rmh);
893 dev_err(&mgr->pci->dev, "error pcxhr_hardware_timer err(%x)\n",
904 struct pcxhr_mgr *mgr = chip->mgr;
912 mutex_lock(&mgr->setup_mutex);
917 if (mgr->sample_rate != subs->runtime->rate) {
918 err = pcxhr_set_clock(mgr, subs->runtime->rate);
921 if (mgr->sample_rate == 0)
923 err = pcxhr_hardware_timer(mgr, 1);
924 mgr->sample_rate = subs->runtime->rate;
928 mutex_unlock(&mgr->setup_mutex);
941 struct pcxhr_mgr *mgr = chip->mgr;
944 mutex_lock(&mgr->setup_mutex);
951 mutex_unlock(&mgr->setup_mutex);
990 struct pcxhr_mgr *mgr = chip->mgr;
995 mutex_lock(&mgr->setup_mutex);
1007 if (mgr->mono_capture)
1017 mutex_unlock(&mgr->setup_mutex);
1022 if (mgr->is_hr_stereo)
1029 mutex_unlock(&mgr->setup_mutex);
1036 if (mgr->sample_rate)
1037 runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate;
1039 if (mgr->use_clock_type != PCXHR_CLOCK_TYPE_INTERNAL) {
1041 if (pcxhr_get_external_clock(mgr, mgr->use_clock_type,
1045 mutex_unlock(&mgr->setup_mutex);
1066 mgr->ref_count_rate++;
1068 mutex_unlock(&mgr->setup_mutex);
1076 struct pcxhr_mgr *mgr = chip->mgr;
1079 mutex_lock(&mgr->setup_mutex);
1085 if (--mgr->ref_count_rate == 0) {
1086 mgr->sample_rate = 0; /* the sample rate is no more locked */
1087 pcxhr_hardware_timer(mgr, 0); /* stop the DSP-timer */
1093 mutex_unlock(&mgr->setup_mutex);
1107 mutex_lock(&chip->mgr->lock);
1113 mutex_unlock(&chip->mgr->lock);
1156 &chip->mgr->pci->dev,
1177 static int pcxhr_create(struct pcxhr_mgr *mgr,
1192 chip->mgr = mgr;
1193 card->sync_irq = mgr->irq;
1195 if (idx < mgr->playback_chips)
1199 if (idx < mgr->capture_chips) {
1200 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;
1509 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
1510 if (! mgr) {
1516 kfree(mgr);
1522 mgr->playback_chips =
1524 mgr->capture_chips =
1526 mgr->fw_file_set =
1528 mgr->firmware_num =
1530 mgr->mono_capture = mono[dev];
1531 mgr->is_hr_stereo = (mgr->playback_chips == 1);
1532 mgr->board_has_aes1 = PCXHR_BOARD_HAS_AES1(mgr);
1533 mgr->board_aes_in_192k = !PCXHR_BOARD_AESIN_NO_192K(mgr);
1535 if (mgr->is_hr_stereo)
1536 mgr->granularity = PCXHR_GRANULARITY_HR22;
1538 mgr->granularity = PCXHR_GRANULARITY;
1542 kfree(mgr);
1547 mgr->port[i] = pci_resource_start(pci, i);
1549 mgr->pci = pci;
1550 mgr->irq = -1;
1554 KBUILD_MODNAME, mgr)) {
1556 pcxhr_free(mgr);
1559 mgr->irq = pci->irq;
1561 snprintf(mgr->name, sizeof(mgr->name),
1563 mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq);
1566 mutex_init(&mgr->lock);
1567 mutex_init(&mgr->msg_lock);
1570 mutex_init(&mgr->setup_mutex);
1572 mgr->prmh = kmalloc(sizeof(*mgr->prmh) +
1576 if (! mgr->prmh) {
1577 pcxhr_free(mgr);
1586 if (i >= max(mgr->playback_chips, mgr->capture_chips))
1588 mgr->num_cards++;
1602 pcxhr_free(mgr);
1610 "%s [PCM #%d]", mgr->name, i);
1612 if ((err = pcxhr_create(mgr, card, i)) < 0) {
1614 pcxhr_free(mgr);
1620 pcxhr_proc_init(mgr->chip[i]);
1623 pcxhr_free(mgr);
1631 size, &mgr->hostport) < 0) {
1632 pcxhr_free(mgr);
1636 memset(mgr->hostport.area, 0, size);
1639 err = pcxhr_setup_firmware(mgr);
1641 pcxhr_free(mgr);
1645 pci_set_drvdata(pci, mgr);