Changeset 1038
- Timestamp:
- 04/25/08 13:39:03 (13 years ago)
- Files:
-
- trunk/libffado/config.h.in (modified) (1 diff)
- trunk/libffado/src/libieee1394/cycletimer.h (modified) (1 diff)
- trunk/libffado/src/libieee1394/IsoHandler.cpp (modified) (6 diffs)
- trunk/libffado/src/libieee1394/IsoHandler.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/config.h.in
r1028 r1038 81 81 82 82 #define ISOHANDLER_DEATH_DETECT_TIMEOUT_USECS 1000000LL 83 84 #define ISOHANDLER_CHECK_CTR_RECONSTRUCTION 0 83 85 84 86 #define ISOHANDLERMANAGER_MAX_ISO_HANDLERS_PER_PORT 16 trunk/libffado/src/libieee1394/cycletimer.h
r1020 r1038 385 385 386 386 /** 387 * @brief Converts a received SYT timestamp to a full timestamp in ticks. 388 * 389 * 390 * @param syt_timestamp The SYT timestamp as present in the packet 391 * @param rcv_ctr The CTR value this timestamp was received on (offset can be 0) 392 * @return 393 */ 394 static inline uint64_t sytRecvToFullTicks2(uint64_t syt_timestamp, uint32_t rcv_ctr) { 395 uint64_t timestamp; 396 397 debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "SYT=%04llX RCV_CTR=%08X\n", 398 syt_timestamp, rcv_ctr); 399 400 // reconstruct the top part of the timestamp using the current cycle number 401 unsigned int rcv_cycle = CYCLE_TIMER_GET_CYCLES(rcv_ctr); 402 unsigned int rcv_cycle_masked = rcv_cycle & 0xF; 403 unsigned int syt_cycle = CYCLE_TIMER_GET_CYCLES(syt_timestamp); 404 405 // if this is true, wraparound has occurred, undo this wraparound 406 if(syt_cycle<rcv_cycle_masked) syt_cycle += 0x10; 407 408 // this is the difference in cycles wrt the cycle the 409 // timestamp was received 410 unsigned int delta_cycles = syt_cycle - rcv_cycle_masked; 411 412 // reconstruct the cycle part of the timestamp 413 rcv_cycle += delta_cycles; 414 415 // if the cycles cause a wraparound of the cycle timer, 416 // perform this wraparound 417 // and convert the timestamp into ticks 418 if(rcv_cycle<8000) { 419 timestamp = rcv_cycle * TICKS_PER_CYCLE; 420 } else { 421 rcv_cycle -= 8000; // wrap around 422 #ifdef DEBUG 423 if (rcv_cycle >= 8000) { 424 debugWarning("insufficient unwrapping\n"); 425 } 426 #endif 427 timestamp = rcv_cycle * TICKS_PER_CYCLE; 428 // add one second due to wraparound 429 timestamp += TICKS_PER_SECOND; 430 } 431 432 timestamp += CYCLE_TIMER_GET_OFFSET(syt_timestamp); 433 434 timestamp = addTicks(timestamp, CYCLE_TIMER_GET_SECS(rcv_ctr) * TICKS_PER_SECOND); 435 436 #ifdef DEBUG 437 if(( TICKS_TO_CYCLE_TIMER(timestamp) & 0xFFFF) != syt_timestamp) { 438 debugWarning("back-converted timestamp not equal to SYT\n"); 439 debugWarning("TS=%011llu TSC=%08lX SYT=%04X\n", 440 timestamp, TICKS_TO_CYCLE_TIMER(timestamp), syt_timestamp); 441 } 442 #endif 443 444 return timestamp; 445 } 446 447 /** 387 448 * @brief Converts a transmit SYT timestamp to a full timestamp in ticks. 388 449 * trunk/libffado/src/libieee1394/IsoHandler.cpp
r1032 r1038 91 91 , m_irq_interval( -1 ) 92 92 , m_last_cycle( -1 ) 93 , m_last_now( 0xFFFFFFFF ) 93 94 , m_Client( 0 ) 94 95 , m_speed( RAW1394_ISO_SPEED_400 ) … … 113 114 , m_irq_interval( irq ) 114 115 , m_last_cycle( -1 ) 116 , m_last_now( 0xFFFFFFFF ) 115 117 , m_Client( 0 ) 116 118 , m_speed( RAW1394_ISO_SPEED_400 ) … … 134 136 , m_max_packet_size( max_packet_size ) 135 137 , m_irq_interval( irq ) 138 , m_last_cycle( -1 ) 139 , m_last_now( 0xFFFFFFFF ) 136 140 , m_Client( 0 ) 137 141 , m_speed( speed ) … … 186 190 flush(); 187 191 #endif 192 m_last_now = m_manager.get1394Service().getCycleTimer(); 188 193 if(raw1394_loop_iterate(m_handle)) { 189 194 debugError( "IsoHandler (%p): Failed to iterate handler: %s\n", … … 363 368 unsigned int cycle, unsigned int dropped, unsigned int skipped) { 364 369 365 unsigned int pkt_ctr = cycle << 12; 370 uint32_t pkt_ctr = cycle << 12; 371 372 // if we assume that one iterate() loop doesn't take longer than 0.5 seconds, 373 // the seconds field won't change while the iterate loop runs 374 // this means that we can preset 'now' before running iterate() 375 uint32_t now_secs = CYCLE_TIMER_GET_SECS(m_last_now); 376 // causality results in the fact that 'now' is always after 'cycle' 377 if(CYCLE_TIMER_GET_CYCLES(m_last_now) < cycle) { 378 // the cycle field has wrapped, substract one second 379 if(now_secs == 0) { 380 now_secs = 127; 381 } else { 382 now_secs -= 1; 383 } 384 } 385 pkt_ctr |= (now_secs & 0x7F) << 25; 386 387 #if ISOHANDLER_CHECK_CTR_RECONSTRUCTION 388 // add a seconds field 389 uint32_t now = m_manager.get1394Service().getCycleTimer(); 390 uint32_t now_secs_ref = CYCLE_TIMER_GET_SECS(now); 391 // causality results in the fact that 'now' is always after 'cycle' 392 if(CYCLE_TIMER_GET_CYCLES(now) < cycle) { 393 // the cycle field has wrapped, substract one second 394 if(now_secs_ref == 0) { 395 now_secs_ref = 127; 396 } else { 397 now_secs_ref -= 1; 398 } 399 } 400 uint32_t pkt_ctr_ref = cycle << 12; 401 pkt_ctr_ref |= (now_secs_ref & 0x7F) << 25; 402 403 if(pkt_ctr != pkt_ctr_ref) { 404 debugWarning("reconstructed CTR counter discrepancy\n"); 405 pkt_ctr=pkt_ctr_ref; 406 } 407 #endif 408 409 // leave the offset field (for now?) 366 410 367 411 debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, … … 422 466 int cycle, unsigned int dropped, unsigned int skipped) { 423 467 424 u nsigned int pkt_ctr;468 uint32_t pkt_ctr; 425 469 if (cycle < 0) { 470 // mark invalid 426 471 pkt_ctr = 0xFFFFFFFF; 427 472 } else { 428 473 pkt_ctr = cycle << 12; 474 475 #if 0 // we don't need this for xmit 476 // if we assume that one iterate() loop doesn't take longer than 0.5 seconds, 477 // the seconds field won't change while the iterate loop runs 478 // this means that we can preset 'now' before running iterate() 479 uint32_t now_secs = CYCLE_TIMER_GET_SECS(m_last_now); 480 // causality results in the fact that 'now' is always after 'cycle' 481 if(CYCLE_TIMER_GET_CYCLES(m_last_now) > (unsigned int)cycle) { 482 // the cycle field has wrapped, add one second 483 now_secs += 1; 484 // no need for this: 485 //if(now_secs == 128) { 486 // now_secs = 0; 487 //} 488 // since we mask later on 489 } 490 pkt_ctr |= (now_secs & 0x7F) << 25; 491 492 #if ISOHANDLER_CHECK_CTR_RECONSTRUCTION 493 // add a seconds field 494 uint32_t now = m_manager.get1394Service().getCycleTimer(); 495 uint32_t now_secs_ref = CYCLE_TIMER_GET_SECS(now); 496 // causality results in the fact that 'now' is always after 'cycle' 497 if(CYCLE_TIMER_GET_CYCLES(now) > (unsigned int)cycle) { 498 // the cycle field has wrapped, add one second 499 now_secs_ref += 1; 500 // no need for this: 501 //if(now_secs == 128) { 502 // now_secs = 0; 503 //} 504 // since we mask later on 505 } 506 uint32_t pkt_ctr_ref = cycle << 12; 507 pkt_ctr_ref |= (now_secs_ref & 0x7F) << 25; 508 509 if(pkt_ctr != pkt_ctr_ref) { 510 debugWarning("reconstructed CTR counter discrepancy\n"); 511 pkt_ctr=pkt_ctr_ref; 512 } 513 #endif 514 #endif 429 515 } 430 516 trunk/libffado/src/libieee1394/IsoHandler.h
r1032 r1038 153 153 int m_irq_interval; 154 154 int m_last_cycle; 155 uint32_t m_last_now; 155 156 156 157 Streaming::StreamProcessor *m_Client; // FIXME: implement with functors