Changeset 1348 for trunk/libffado/src/libieee1394
- Timestamp:
- 09/24/08 09:45:50 (12 years ago)
- Files:
-
- trunk/libffado/src/libieee1394/CycleTimerHelper.cpp (modified) (3 diffs)
- trunk/libffado/src/libieee1394/CycleTimerHelper.h (modified) (1 diff)
- trunk/libffado/src/libieee1394/ieee1394service.cpp (modified) (1 diff)
- trunk/libffado/src/libieee1394/ieee1394service.h (modified) (1 diff)
- trunk/libffado/src/libieee1394/IsoHandler.cpp (modified) (3 diffs)
- trunk/libffado/src/libieee1394/IsoHandler.h (modified) (1 diff)
- trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libieee1394/CycleTimerHelper.cpp
r1336 r1348 654 654 } 655 655 656 uint64_t 657 CycleTimerHelper::getSystemTimeForCycleTimerTicks(uint32_t ticks) 658 { 659 uint64_t retval; 660 struct compute_vars *my_vars; 661 662 // get pointer and copy the contents 663 // no locking should be needed since we have more than one 664 // of these vars available, and our use will always be finished before 665 // m_current_shadow_idx changes since this thread's priority should 666 // be higher than the one of the writer thread. Even if not, we only have to ensure 667 // that the used dataset is consistent. We can use an older dataset if it's consistent 668 // since it will also provide a fairly decent extrapolation. 669 my_vars = m_shadow_vars + m_current_shadow_idx; 670 671 // the number of ticks the request is ahead of the current CTR position 672 int64_t ticks_diff = diffTicks(ticks, my_vars->ticks); 673 // to how much time does this correspond? 674 double x_step_in_usec = ((double)ticks_diff) / my_vars->rate; 675 int64_t x_step_in_usec_int = (int64_t)x_step_in_usec; 676 retval = my_vars->usecs + x_step_in_usec_int; 677 678 return retval; 679 } 680 681 uint64_t 682 CycleTimerHelper::getSystemTimeForCycleTimer(uint32_t ctr) 683 { 684 uint32_t ticks = CYCLE_TIMER_TO_TICKS(ctr); 685 return getSystemTimeForCycleTimerTicks(ticks); 686 } 687 656 688 #else 657 689 … … 685 717 CycleTimerHelper::getCycleTimerTicks(uint64_t now) 686 718 { 687 debugWarning("not implemented!\n"); 688 return getCycleTimerTicks(); 719 debugWarning("untested code\n"); 720 #warning Untested code 721 uint32_t cycle_timer; 722 uint64_t local_time; 723 readCycleTimerWithRetry(&cycle_timer, &local_time, 10); 724 int64_t ticks = CYCLE_TIMER_TO_TICKS(cycle_timer); 725 726 int delta_t = now - local_time; // how far ahead is the request? 727 ticks += delta_t * getRate(); // add ticks 728 if (ticks >= TICKS_PER_SECOND * 128) ticks -= TICKS_PER_SECOND * 128; 729 else if (ticks < 0) ticks += TICKS_PER_SECOND * 128; 730 return ticks; 689 731 } 690 732 … … 701 743 CycleTimerHelper::getCycleTimer(uint64_t now) 702 744 { 745 return TICKS_TO_CYCLE_TIMER(getCycleTimerTicks(now)); 746 } 747 748 uint64_t 749 CycleTimerHelper::getSystemTimeForCycleTimerTicks(uint32_t ticks) 750 { 703 751 debugWarning("not implemented!\n"); 704 return getCycleTimer(); 752 return 0; 753 } 754 755 uint64_t 756 CycleTimerHelper::getSystemTimeForCycleTimer(uint32_t ctr) 757 { 758 uint32_t ticks = CYCLE_TIMER_TO_TICKS(ctr); 759 return getSystemTimeForCycleTimerTicks(ticks); 705 760 } 706 761 trunk/libffado/src/libieee1394/CycleTimerHelper.h
r1080 r1348 98 98 uint32_t getCycleTimer(uint64_t now); 99 99 100 /** 101 * @brief get the system time for a specific cycle timer value (in ticks) 102 * @note thread safe 103 */ 104 uint64_t getSystemTimeForCycleTimerTicks(uint32_t ticks); 105 106 /** 107 * @brief get the system time for a specific cycle timer value (in CTR format) 108 * @note thread safe 109 */ 110 uint64_t getSystemTimeForCycleTimer(uint32_t ctr); 111 100 112 float getRate(); 101 113 float getNominalRate(); trunk/libffado/src/libieee1394/ieee1394service.cpp
r1336 r1348 401 401 } 402 402 403 uint64_t 404 Ieee1394Service::getSystemTimeForCycleTimerTicks(uint32_t ticks) { 405 return m_pCTRHelper->getSystemTimeForCycleTimerTicks(ticks); 406 } 407 408 uint64_t 409 Ieee1394Service::getSystemTimeForCycleTimer(uint32_t ctr) { 410 return m_pCTRHelper->getSystemTimeForCycleTimer(ctr); 411 } 412 403 413 bool 404 414 Ieee1394Service::readCycleTimerReg(uint32_t *cycle_timer, uint64_t *local_time) trunk/libffado/src/libieee1394/ieee1394service.h
r1336 r1348 134 134 */ 135 135 uint32_t getCycleTimer(uint64_t t); 136 137 /** 138 * @brief get the system time for a specific cycle timer value (in ticks) 139 * @note thread safe 140 */ 141 uint64_t getSystemTimeForCycleTimerTicks(uint32_t ticks); 142 143 /** 144 * @brief get the system time for a specific cycle timer value (in CTR format) 145 * @note thread safe 146 */ 147 uint64_t getSystemTimeForCycleTimer(uint32_t ctr); 136 148 137 149 /** trunk/libffado/src/libieee1394/IsoHandler.cpp
r1336 r1348 475 475 // leave the offset field (for now?) 476 476 477 debugOutput (DEBUG_LEVEL_ULTRA_VERBOSE,477 debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, 478 478 "received packet: length=%d, channel=%d, cycle=%d, at %08X\n", 479 479 length, channel, cycle, pkt_ctr); … … 566 566 m_last_packet_handled_at = pkt_ctr; 567 567 } 568 debugOutput (DEBUG_LEVEL_ULTRA_VERBOSE,568 debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, 569 569 "sending packet: length=%d, cycle=%d, at %08X\n", 570 570 *length, cycle, pkt_ctr); … … 670 670 dumpInfo(); 671 671 if (getType() == eHT_Receive) { 672 if(m_irq_interval > 1) { 673 if(raw1394_iso_recv_init(m_handle, 674 iso_receive_handler, 675 m_buf_packets, 676 m_max_packet_size, 677 m_Client->getChannel(), 678 RAW1394_DMA_BUFFERFILL, 679 // RAW1394_DMA_PACKET_PER_BUFFER, 680 m_irq_interval)) { 681 debugFatal("Could not do receive initialisation (DMA_BUFFERFILL)!\n" ); 682 debugFatal(" %s\n",strerror(errno)); 683 return false; 684 } 685 } else { 686 if(raw1394_iso_recv_init(m_handle, 687 iso_receive_handler, 688 m_buf_packets, 689 m_max_packet_size, 690 m_Client->getChannel(), 691 RAW1394_DMA_PACKET_PER_BUFFER, 692 m_irq_interval)) { 693 debugFatal("Could not do receive initialisation (PACKET_PER_BUFFER)!\n" ); 694 debugFatal(" %s\n",strerror(errno)); 695 return false; 696 } 672 if(raw1394_iso_recv_init(m_handle, 673 iso_receive_handler, 674 m_buf_packets, 675 m_max_packet_size, 676 m_Client->getChannel(), 677 RAW1394_DMA_PACKET_PER_BUFFER, 678 m_irq_interval)) { 679 debugFatal("Could not do receive initialisation (DMA_BUFFERFILL)!\n" ); 680 debugFatal(" %s\n",strerror(errno)); 681 return false; 697 682 } 698 683 return true; trunk/libffado/src/libieee1394/IsoHandler.h
r1336 r1348 119 119 unsigned int getMaxPacketSize() { return m_max_packet_size;}; 120 120 unsigned int getNbBuffers() { return m_buf_packets;}; 121 int get PacketLatency() { return m_irq_interval;};121 int getIrqInterval() { return m_irq_interval;}; 122 122 123 123 unsigned int getPreBuffers() {return m_prebuffers;}; trunk/libffado/src/libieee1394/IsoHandlerManager.cpp
r1336 r1348 353 353 #ifdef DEBUG 354 354 if(m_poll_fds_shadow[i].revents) { 355 debugOutput (DEBUG_LEVEL_ULTRA_VERBOSE,355 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 356 356 "(%p, %s) received events: %08X for (%d/%d, %p, %s)\n", 357 357 this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive"), … … 761 761 // setup the optimal parameters for the raw1394 ISO buffering 762 762 unsigned int packets_per_period = stream->getPacketsPerPeriod(); 763 unsigned int max_packet_size = stream->getMaxPacketSize() ;764 unsigned int page_size = getpagesize() - 2; // for one reason or another this is necessary763 unsigned int max_packet_size = stream->getMaxPacketSize() + 8; // bufferfill takes another 8 bytes for headers 764 unsigned int page_size = getpagesize(); 765 765 766 766 // Ensure we don't request a packet size bigger than the 767 767 // kernel-enforced maximum which is currently 1 page. 768 // NOTE: PP: this is not really true AFAICT 768 769 if (max_packet_size > page_size) { 769 770 debugError("max packet size (%u) > page size (%u)\n", max_packet_size, page_size); … … 771 772 } 772 773 773 unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; 774 // the interrupt/wakeup interval prediction of raw1394 is a mess... 775 int irq_interval = (packets_per_period-1) / MINIMUM_INTERRUPTS_PER_PERIOD; 774 776 if(irq_interval <= 0) irq_interval=1; 775 777 776 778 // the receive buffer size doesn't matter for the latency, 777 779 // but it has a minimal value in order for libraw to operate correctly (300) … … 977 979 { 978 980 if((*it)->isStreamRegistered(stream)) { 979 return (*it)->get PacketLatency();981 return (*it)->getIrqInterval(); 980 982 } 981 983 }