Changeset 880

Show
Ignore:
Timestamp:
02/20/08 11:24:27 (16 years ago)
Author:
ppalmers
Message:

- switch over from a high-bandwidth DLL to a low-bandwidth DLL after initial settling. Prediction performance is better than 100ticks (20 on average).

Files:

Legend:

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

    r879 r880  
    2828#include "libutil/PosixThread.h" 
    2929 
    30 #define DLL_BANDWIDTH (0.1) 
    3130#define DLL_PI        (3.141592653589793238) 
    3231#define DLL_SQRT2     (1.414213562373095049) 
     32 
     33// the high-bandwidth coefficients are used 
     34// to speed up inital tracking 
     35#define DLL_BANDWIDTH_HIGH (0.1) 
     36#define DLL_OMEGA_HIGH     (2.0*DLL_PI*DLL_BANDWIDTH_HIGH) 
     37#define DLL_COEFF_B_HIGH   (DLL_SQRT2 * DLL_OMEGA_HIGH) 
     38#define DLL_COEFF_C_HIGH   (DLL_OMEGA_HIGH * DLL_OMEGA_HIGH) 
     39 
     40// the low-bandwidth coefficients are used once we have a 
     41// good estimate of the internal parameters 
     42#define DLL_BANDWIDTH (0.01) 
    3343#define DLL_OMEGA     (2.0*DLL_PI*DLL_BANDWIDTH) 
    3444#define DLL_COEFF_B   (DLL_SQRT2 * DLL_OMEGA) 
    3545#define DLL_COEFF_C   (DLL_OMEGA * DLL_OMEGA) 
    3646 
    37 #define OFFSET_AVERAGE_COEFF 0.01 
     47#define UPDATES_WITH_HIGH_BANDWIDTH 200 
     48 
    3849/* 
    3950#define ENTER_CRITICAL_SECTION { \ 
     
    6778    , m_cycle_timer_prev ( 0 ) 
    6879    , m_cycle_timer_ticks_prev ( 0 ) 
     80    , m_high_bw_updates ( UPDATES_WITH_HIGH_BANDWIDTH ) 
    6981    , m_Thread ( NULL ) 
    7082    , m_realtime ( false ) 
     
    88100    , m_cycle_timer_prev ( 0 ) 
    89101    , m_cycle_timer_ticks_prev ( 0 ) 
     102    , m_high_bw_updates ( UPDATES_WITH_HIGH_BANDWIDTH ) 
    90103    , m_Thread ( NULL ) 
    91104    , m_realtime ( rt ) 
     
    108121    debugOutput( DEBUG_LEVEL_VERBOSE, "Start %p...\n", this); 
    109122#if IEEE1394SERVICE_USE_CYCLETIMER_DLL 
     123    m_high_bw_updates = UPDATES_WITH_HIGH_BANDWIDTH; 
    110124    m_Thread = new Util::PosixThread(this, m_realtime, m_priority,  
    111125                                     PTHREAD_CANCEL_DEFERRED); 
     
    264278        m_current_time_ticks = m_next_time_ticks; 
    265279 
     280        // decide what coefficients to use 
     281        double coeff_b, coeff_c; 
     282        if (m_high_bw_updates > 0) { 
     283            coeff_b = DLL_COEFF_B_HIGH; 
     284            coeff_c = DLL_COEFF_C_HIGH; 
     285            m_high_bw_updates--; 
     286            if (m_high_bw_updates == 0) { 
     287                debugOutput(DEBUG_LEVEL_VERBOSE, "Switching to low-bandwidth coefficients\n"); 
     288            } 
     289        } else { 
     290            coeff_b = DLL_COEFF_B; 
     291            coeff_c = DLL_COEFF_C; 
     292        } 
     293 
    266294        // do the calculation in 'tick space' 
    267         int64_t tmp = (uint64_t)(DLL_COEFF_B * diff_ticks_corr); 
     295        int64_t tmp = (uint64_t)(coeff_b * diff_ticks_corr); 
    268296        if(m_dll_e2 > 0) { 
    269297            tmp = addTicks(tmp, (uint64_t)m_dll_e2); 
     
    278306        // it should be ok to not do this in tick space since it's value 
    279307        // is approx equal to the rate, being 24.576 ticks/usec 
    280         m_dll_e2 += DLL_COEFF_C * diff_ticks_corr; 
     308        m_dll_e2 += coeff_c * diff_ticks_corr; 
    281309 
    282310        // For jitter graphs 
    283         //debugOutputShort(DEBUG_LEVEL_NORMAL, "0123456789 %f %f %f %lld %lld %lld\n",  
    284         //                 diff_ticks, diff_ticks_corr, m_dll_e2, cycle_timer_ticks, (int64_t)m_next_time_ticks, usecs_late); 
     311        debugOutputShort(DEBUG_LEVEL_NORMAL, "0123456789 %f %f %f %lld %lld %lld\n",  
     312                         diff_ticks, diff_ticks_corr, m_dll_e2, cycle_timer_ticks, (int64_t)m_next_time_ticks, usecs_late); 
    285313 
    286314        // update the y-axis values 
  • trunk/libffado/src/libieee1394/CycleTimerHelper.h

    r879 r880  
    123123    uint32_t m_cycle_timer_prev; 
    124124    uint64_t m_cycle_timer_ticks_prev; 
     125    int m_high_bw_updates; 
    125126 
    126127    // cached vars used for computation