Show
Ignore:
Timestamp:
09/24/08 09:45:50 (12 years ago)
Author:
ppalmers
Message:

merge 2.0 branch changes to trunk. svn merge -r 1337:HEAD svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libieee1394/CycleTimerHelper.cpp

    r1336 r1348  
    654654} 
    655655 
     656uint64_t 
     657CycleTimerHelper::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 
     681uint64_t 
     682CycleTimerHelper::getSystemTimeForCycleTimer(uint32_t ctr) 
     683{ 
     684    uint32_t ticks = CYCLE_TIMER_TO_TICKS(ctr); 
     685    return getSystemTimeForCycleTimerTicks(ticks); 
     686} 
     687 
    656688#else 
    657689 
     
    685717CycleTimerHelper::getCycleTimerTicks(uint64_t now) 
    686718{ 
    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; 
    689731} 
    690732 
     
    701743CycleTimerHelper::getCycleTimer(uint64_t now) 
    702744{ 
     745    return TICKS_TO_CYCLE_TIMER(getCycleTimerTicks(now)); 
     746} 
     747 
     748uint64_t 
     749CycleTimerHelper::getSystemTimeForCycleTimerTicks(uint32_t ticks) 
     750{ 
    703751    debugWarning("not implemented!\n"); 
    704     return getCycleTimer(); 
     752    return 0; 
     753
     754 
     755uint64_t 
     756CycleTimerHelper::getSystemTimeForCycleTimer(uint32_t ctr) 
     757
     758    uint32_t ticks = CYCLE_TIMER_TO_TICKS(ctr); 
     759    return getSystemTimeForCycleTimerTicks(ticks); 
    705760} 
    706761 
  • trunk/libffado/src/libieee1394/CycleTimerHelper.h

    r1080 r1348  
    9898    uint32_t getCycleTimer(uint64_t now); 
    9999 
     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 
    100112    float getRate(); 
    101113    float getNominalRate(); 
  • trunk/libffado/src/libieee1394/ieee1394service.cpp

    r1336 r1348  
    401401} 
    402402 
     403uint64_t 
     404Ieee1394Service::getSystemTimeForCycleTimerTicks(uint32_t ticks) { 
     405    return m_pCTRHelper->getSystemTimeForCycleTimerTicks(ticks); 
     406} 
     407 
     408uint64_t 
     409Ieee1394Service::getSystemTimeForCycleTimer(uint32_t ctr) { 
     410    return m_pCTRHelper->getSystemTimeForCycleTimer(ctr); 
     411} 
     412 
    403413bool 
    404414Ieee1394Service::readCycleTimerReg(uint32_t *cycle_timer, uint64_t *local_time) 
  • trunk/libffado/src/libieee1394/ieee1394service.h

    r1336 r1348  
    134134     */ 
    135135    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); 
    136148 
    137149    /** 
  • trunk/libffado/src/libieee1394/IsoHandler.cpp

    r1336 r1348  
    475475    // leave the offset field (for now?) 
    476476 
    477     debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, 
     477    debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, 
    478478                "received packet: length=%d, channel=%d, cycle=%d, at %08X\n", 
    479479                length, channel, cycle, pkt_ctr); 
     
    566566        m_last_packet_handled_at = pkt_ctr; 
    567567    } 
    568     debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, 
     568    debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, 
    569569                "sending packet: length=%d, cycle=%d, at %08X\n", 
    570570                *length, cycle, pkt_ctr); 
     
    670670    dumpInfo(); 
    671671    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; 
    697682        } 
    698683        return true; 
  • trunk/libffado/src/libieee1394/IsoHandler.h

    r1336 r1348  
    119119    unsigned int getMaxPacketSize() { return m_max_packet_size;}; 
    120120    unsigned int getNbBuffers() { return m_buf_packets;}; 
    121     int getPacketLatency() { return m_irq_interval;}; 
     121    int getIrqInterval() { return m_irq_interval;}; 
    122122 
    123123    unsigned int getPreBuffers() {return m_prebuffers;}; 
  • trunk/libffado/src/libieee1394/IsoHandlerManager.cpp

    r1336 r1348  
    353353        #ifdef DEBUG 
    354354        if(m_poll_fds_shadow[i].revents) { 
    355             debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, 
     355            debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 
    356356                        "(%p, %s) received events: %08X for (%d/%d, %p, %s)\n", 
    357357                        this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive"), 
     
    761761        // setup the optimal parameters for the raw1394 ISO buffering 
    762762        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 necessary 
     763        unsigned int max_packet_size = stream->getMaxPacketSize() + 8; // bufferfill takes another 8 bytes for headers 
     764        unsigned int page_size = getpagesize(); 
    765765 
    766766        // Ensure we don't request a packet size bigger than the 
    767767        // kernel-enforced maximum which is currently 1 page. 
     768        // NOTE: PP: this is not really true AFAICT 
    768769        if (max_packet_size > page_size) { 
    769770            debugError("max packet size (%u) > page size (%u)\n", max_packet_size, page_size); 
     
    771772        } 
    772773 
    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; 
    774776        if(irq_interval <= 0) irq_interval=1; 
    775          
     777 
    776778        // the receive buffer size doesn't matter for the latency, 
    777779        // but it has a minimal value in order for libraw to operate correctly (300) 
     
    977979    { 
    978980        if((*it)->isStreamRegistered(stream)) { 
    979             return (*it)->getPacketLatency(); 
     981            return (*it)->getIrqInterval(); 
    980982        } 
    981983    }