627 | | // Ensure the transmit processor is ready to start streaming. |
---|
628 | | m_transmitProcessor->resetForStreaming(); |
---|
629 | | |
---|
630 | | // FIXME: this may yet move back into prepare(). |
---|
| 627 | signed int iso_rx; |
---|
| 628 | unsigned int stat[4]; |
---|
| 629 | signed int i; |
---|
| 630 | |
---|
| 631 | // Ensure the transmit processor is ready to start streaming. When |
---|
| 632 | // this function is called from prepare() the transmit processor |
---|
| 633 | // won't be allocated. |
---|
| 634 | if (m_transmitProcessor != NULL) |
---|
| 635 | m_transmitProcessor->resetForStreaming(); |
---|
| 636 | |
---|
| 637 | // Whenever streaming is restarted hardware_init_streaming() needs to be |
---|
| 638 | // called. Otherwise the device won't start sending data when data is |
---|
| 639 | // sent to it and the rx stream will fail to start. |
---|
| 645 | |
---|
| 646 | i = 0; |
---|
| 647 | while (i < 100) { |
---|
| 648 | err = (get_hardware_streaming_status(stat, 4) != 0); |
---|
| 649 | if (err) { |
---|
| 650 | debugFatal("error reading status register\n"); |
---|
| 651 | break; |
---|
| 652 | } |
---|
| 653 | |
---|
| 654 | // FIXME: this can probably go once the driver matures. |
---|
| 655 | debugOutput(DEBUG_LEVEL_NORMAL, "init stat: %08x %08x %08x %08x\n", |
---|
| 656 | stat[0], stat[1], stat[2], stat[3]); |
---|
| 657 | |
---|
| 658 | if (m_rme_model == RME_MODEL_FIREFACE400) { |
---|
| 659 | break; |
---|
| 660 | } |
---|
| 661 | |
---|
| 662 | // The Fireface-800 chooses its tx channel (our rx channel). Wait |
---|
| 663 | // for the device busy flag to clear, then confirm that the rx iso |
---|
| 664 | // channel hasn't changed (it shouldn't across a restart). |
---|
| 665 | if (stat[2] == 0xffffffff) { |
---|
| 666 | // Device not ready; wait 5 ms and try again |
---|
| 667 | usleep(5000); |
---|
| 668 | } else { |
---|
| 669 | iso_rx = stat[2] & 63; |
---|
| 670 | if (iso_rx!=iso_rx_channel && iso_rx_channel!=-1) |
---|
| 671 | debugOutput(DEBUG_LEVEL_WARNING, "rx iso: now %d, was %d\n", |
---|
| 672 | iso_rx, iso_rx_channel); |
---|
| 673 | iso_rx_channel = iso_rx; |
---|
| 674 | |
---|
| 675 | // Even if the rx channel has changed, the device takes care of |
---|
| 676 | // registering the channel itself, so we don't have to (neither |
---|
| 677 | // do we have to release the old one). If we try to call |
---|
| 678 | // raw1394_channel_modify() on the returned channel we'll get an |
---|
| 679 | // error. |
---|
| 680 | // iso_rx_channel = get1394Service().allocateFixedIsoChannelGeneric(iso_rx_channel, bandwidth); |
---|
| 681 | break; |
---|
| 682 | } |
---|
| 683 | } |
---|
| 684 | if (i==100 || err) |
---|
| 685 | return false; |
---|
707 | | // err = hardware_init_streaming(dev_config->hardware_freq, iso_tx_channel) != 0; |
---|
708 | | // if (err) { |
---|
709 | | // debugFatal("Could not intialise device streaming system\n"); |
---|
710 | | // } |
---|
711 | | |
---|
712 | | if (err == 0) { |
---|
713 | | signed int i; |
---|
714 | | for (i=0; i<100; i++) { |
---|
715 | | err = (get_hardware_streaming_status(stat, 4) != 0); |
---|
716 | | if (err) { |
---|
717 | | debugFatal("error reading status register\n"); |
---|
718 | | break; |
---|
719 | | } |
---|
720 | | |
---|
721 | | // FIXME: this can probably go once the driver matures. |
---|
722 | | debugOutput(DEBUG_LEVEL_NORMAL, "init stat: %08x %08x %08x %08x\n", |
---|
723 | | stat[0], stat[1], stat[2], stat[3]); |
---|
724 | | |
---|
725 | | if (m_rme_model == RME_MODEL_FIREFACE400) { |
---|
726 | | iso_rx_channel = get1394Service().allocateIsoChannelGeneric(bandwidth); |
---|
727 | | break; |
---|
728 | | } |
---|
729 | | // The Fireface-800 chooses its tx channel (our rx channel). |
---|
730 | | if (stat[2] == 0xffffffff) { |
---|
731 | | // Device not ready; wait 5 ms and try again |
---|
732 | | usleep(5000); |
---|
733 | | } else { |
---|
734 | | iso_rx_channel = stat[2] & 63; |
---|
735 | | |
---|
736 | | // The device seems to register this channel itself. raw1394_channel_modify() |
---|
737 | | // returns an error if used on the returned channel. |
---|
738 | | // iso_rx_channel = get1394Service().allocateFixedIsoChannelGeneric(iso_rx_channel, bandwidth); |
---|
739 | | break; |
---|
740 | | } |
---|
741 | | } |
---|
742 | | if (iso_rx_channel < 0) { |
---|
743 | | debugFatal("Could not allocate/determine iso rx channel\n"); |
---|
744 | | err = 1; |
---|
745 | | } |
---|
746 | | } |
---|
| 757 | // Call this to initialise the device's streaming system and, in the |
---|
| 758 | // case of the FF800, obtain the rx iso channel to use. Having that |
---|
| 759 | // functionality in resetForStreaming() means it's effectively done |
---|
| 760 | // twice when FFADO is first started, but this does no harm. |
---|
| 761 | resetForStreaming(); |
---|