Changeset 394
- Timestamp:
- 02/14/07 01:31:54 (17 years ago)
- Files:
-
- branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp (modified) (4 diffs)
- branches/streaming-rework/src/libstreaming/cycletimer.h (modified) (3 diffs)
- branches/streaming-rework/src/libstreaming/IsoHandler.cpp (modified) (7 diffs)
- branches/streaming-rework/src/libstreaming/StreamProcessor.h (modified) (1 diff)
- branches/streaming-rework/tests/test-cycletimer.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp
r393 r394 235 235 #ifdef DEBUG 236 236 if(!m_is_disabled) { 237 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " > TS=%11llu, CTR=%11llu, FC=%5d\n",238 timestamp, cycle_timer, fc237 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "R: TS=%011llu, NOW=%011llu, CYN=%04d, CYT=%04d\n", 238 timestamp, cycle_timer, now_cycles, cycle 239 239 ); 240 240 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " UTN=%11lld\n", … … 246 246 } 247 247 #endif 248 248 249 #ifdef DEBUG 250 if((cycle % 1000) == 0) { 251 uint32_t timestamp_u=timestamp; 252 uint32_t syt = TICKS_TO_SYT(addTicks(timestamp_u, TRANSMIT_TRANSFER_DELAY)); 253 uint32_t now=m_handler->getCycleTimer(); 254 uint32_t now_ticks=CYCLE_TIMER_TO_TICKS(now); 255 256 uint32_t test_ts=sytXmitToFullTicks(syt, cycle, now); 257 258 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "T %04d: SYT=%08X, CY=%02d OFF=%04d\n", 259 cycle, syt, CYCLE_TIMER_GET_CYCLES(syt), CYCLE_TIMER_GET_OFFSET(syt) 260 ); 261 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "T %04d: NOW=%011lu, SEC=%03u CY=%02u OFF=%04u\n", 262 cycle, now_ticks, CYCLE_TIMER_GET_SECS(now), CYCLE_TIMER_GET_CYCLES(now), CYCLE_TIMER_GET_OFFSET(now) 263 ); 264 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "T %04d: TSS=%011lu, SEC=%03u CY=%02u OFF=%04u\n", 265 cycle, test_ts, TICKS_TO_SECS(test_ts), TICKS_TO_CYCLES(test_ts), TICKS_TO_OFFSET(test_ts) 266 ); 267 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "T %04d: TSO=%011lu, SEC=%03u CY=%02u OFF=%04u\n", 268 cycle, timestamp_u, TICKS_TO_SECS(timestamp_u), TICKS_TO_CYCLES(timestamp_u), TICKS_TO_OFFSET(timestamp_u) 269 ); 270 } 271 #endif 249 272 // don't process the stream when it is not enabled, not running 250 273 // or when the next sample is not due yet. … … 918 941 919 942 //=> convert the SYT to a full timestamp in ticks 920 m_last_timestamp=syt ToFullTicks((uint32_t)ntohs(packet->syt),943 m_last_timestamp=sytRecvToFullTicks((uint32_t)ntohs(packet->syt), 921 944 cycle, m_handler->getCycleTimer()); 922 945 … … 1017 1040 return RAW1394_ISO_DEFER; 1018 1041 } 1042 1043 #ifdef DEBUG 1044 if((cycle % 1000) == 0) { 1045 uint32_t syt = (uint32_t)ntohs(packet->syt); 1046 uint32_t now=m_handler->getCycleTimer(); 1047 uint32_t now_ticks=CYCLE_TIMER_TO_TICKS(now); 1048 1049 uint32_t test_ts=sytRecvToFullTicks(syt, cycle, now); 1050 1051 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "R %04d: SYT=%08X, CY=%02d OFF=%04d\n", 1052 cycle, syt, CYCLE_TIMER_GET_CYCLES(syt), CYCLE_TIMER_GET_OFFSET(syt) 1053 ); 1054 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "R %04d: NOW=%011lu, SEC=%03u CY=%02u OFF=%04u\n", 1055 cycle, now_ticks, CYCLE_TIMER_GET_SECS(now), CYCLE_TIMER_GET_CYCLES(now), CYCLE_TIMER_GET_OFFSET(now) 1056 ); 1057 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "R %04d: TSS=%011lu, SEC=%03u CY=%02u OFF=%04u\n", 1058 cycle, test_ts, TICKS_TO_SECS(test_ts), TICKS_TO_CYCLES(test_ts), TICKS_TO_OFFSET(test_ts) 1059 ); 1060 } 1061 #endif 1019 1062 1020 1063 //=> process the packet branches/streaming-rework/src/libstreaming/cycletimer.h
r393 r394 75 75 76 76 /** 77 * @brief Converts a SYT timestamp to a full timestamp in ticks. 78 * 79 * 77 * @brief Converts a received SYT timestamp to a full timestamp in ticks. 78 * 80 79 * 81 80 * @param syt_timestamp The SYT timestamp as present in the packet … … 84 83 * @return 85 84 */ 86 static inline uint32_t syt ToFullTicks(uint32_t syt_timestamp, unsigned int rcv_cycle, uint32_t ctr_now) {85 static inline uint32_t sytRecvToFullTicks(uint32_t syt_timestamp, unsigned int rcv_cycle, uint32_t ctr_now) { 87 86 uint32_t timestamp; 88 87 88 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"SYT=%08X CY=%04X CTR=%08X\n", 89 syt_timestamp,rcv_cycle,ctr_now); 90 89 91 // reconstruct the full cycle 90 92 uint32_t cc_cycles=CYCLE_TIMER_GET_CYCLES(ctr_now); … … 140 142 141 143 timestamp += CYCLE_TIMER_GET_OFFSET(syt_timestamp); 144 142 145 timestamp += cc_seconds * TICKS_PER_SECOND; 146 147 #ifdef DEBUG 148 if(( TICKS_TO_CYCLE_TIMER(timestamp) & 0xFFFF) != syt_timestamp) { 149 debugWarning("back-converted timestamp not equal to SYT\n"); 150 debugWarning("TS=%011llu TSC=%08X SYT=%04X\n", 151 timestamp, TICKS_TO_CYCLE_TIMER(timestamp), syt_timestamp); 152 } 153 #endif 154 155 return timestamp; 156 } 157 158 /** 159 * @brief Converts a transmit SYT timestamp to a full timestamp in ticks. 160 * 161 * The difference between sytRecvToFullTicks and sytXmitToFullTicks is 162 * the way SYT cycle wraparound is detected: in the receive version, 163 * wraparound is present if rcv_cycle > current_cycle. In the xmit 164 * version this is when current_cycle > xmt_cycle. 165 * 166 * @param syt_timestamp The SYT timestamp as present in the packet 167 * @param xmt_cycle The cycle this timestamp was received on 168 * @param ctr_now The current value of the cycle timer ('now') 169 * @return 170 */ 171 static inline uint32_t sytXmitToFullTicks(uint32_t syt_timestamp, unsigned int xmt_cycle, uint32_t ctr_now) { 172 uint32_t timestamp; 173 174 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"SYT=%08X CY=%04X CTR=%08X\n", 175 syt_timestamp,xmt_cycle,ctr_now); 176 177 // reconstruct the full cycle 178 uint32_t cc_cycles=CYCLE_TIMER_GET_CYCLES(ctr_now); 179 uint32_t cc_seconds=CYCLE_TIMER_GET_SECS(ctr_now); 180 181 // the cycletimer has wrapped since this packet was received 182 // we want cc_seconds to reflect the 'seconds' at the point this 183 // is to be transmitted 184 if (xmt_cycle<cc_cycles) { 185 if (cc_seconds) { 186 cc_seconds--; 187 } else { 188 // seconds has wrapped around, so we'd better not substract 1 189 // the good value is 127 190 cc_seconds=127; 191 } 192 } 193 194 // reconstruct the top part of the timestamp using the current cycle number 195 uint32_t xmt_cycle_masked=xmt_cycle & 0xF; 196 uint32_t syt_cycle=CYCLE_TIMER_GET_CYCLES(syt_timestamp); 197 198 // if this is true, wraparound has occurred, undo this wraparound 199 if(syt_cycle<xmt_cycle_masked) syt_cycle += 0x10; 200 201 // this is the difference in cycles wrt the cycle the 202 // timestamp was received 203 uint32_t delta_cycles=syt_cycle-xmt_cycle_masked; 204 205 // reconstruct the cycle part of the timestamp 206 uint32_t new_cycles=xmt_cycle + delta_cycles; 207 208 // if the cycles cause a wraparound of the cycle timer, 209 // perform this wraparound 210 // and convert the timestamp into ticks 211 if(new_cycles<8000) { 212 timestamp = new_cycles * TICKS_PER_CYCLE; 213 } else { 214 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, 215 "Detected wraparound: %d + %d = %d\n", 216 xmt_cycle,delta_cycles,new_cycles); 217 218 new_cycles-=8000; // wrap around 219 #ifdef DEBUG 220 if (new_cycles >= 8000) { 221 debugWarning("insufficient unwrapping\n"); 222 } 223 #endif 224 timestamp = new_cycles * TICKS_PER_CYCLE; 225 // add one second due to wraparound 226 timestamp += TICKS_PER_SECOND; 227 } 228 229 timestamp += CYCLE_TIMER_GET_OFFSET(syt_timestamp); 230 231 timestamp += cc_seconds * TICKS_PER_SECOND; 232 233 #ifdef DEBUG 234 if(( TICKS_TO_CYCLE_TIMER(timestamp) & 0xFFFF) != syt_timestamp) { 235 debugWarning("back-converted timestamp not equal to SYT\n"); 236 debugWarning("TS=%011llu TSC=%08X SYT=%04X\n", 237 timestamp, TICKS_TO_CYCLE_TIMER(timestamp), syt_timestamp); 238 } 239 #endif 240 143 241 return timestamp; 144 242 } branches/streaming-rework/src/libstreaming/IsoHandler.cpp
r391 r394 170 170 debugError("libraw1394 not compatible\n"); 171 171 } else { 172 debugError("Could not get 1394 handle: %s ", strerror(errno) );173 debugError("Are ieee1394 and raw1394 drivers loaded? ");172 debugError("Could not get 1394 handle: %s\n", strerror(errno) ); 173 debugError("Are ieee1394 and raw1394 drivers loaded?\n"); 174 174 } 175 175 return false; … … 183 183 debugError("libraw1394 not compatible\n"); 184 184 } else { 185 debugError("Could not get 1394 handle: %s ", strerror(errno) );186 debugError("Are ieee1394 and raw1394 drivers loaded? ");185 debugError("Could not get 1394 handle: %s\n", strerror(errno) ); 186 debugError("Are ieee1394 and raw1394 drivers loaded?\n"); 187 187 } 188 188 … … 340 340 err=raw1394_read_cycle_timer(m_handle_util, &ctr); 341 341 if(err) { 342 debugWarning("raw1394_read_cycle_timer: %s ", strerror(err));342 debugWarning("raw1394_read_cycle_timer: %s\n", strerror(err)); 343 343 } 344 344 return CYCLE_TIMER_TO_TICKS(ctr.cycle_timer); … … 370 370 err=raw1394_read_cycle_timer(m_handle_util, &ctr); 371 371 if(err) { 372 debugWarning("raw1394_read_cycle_timer: %s ", strerror(err));372 debugWarning("raw1394_read_cycle_timer: %s\n", strerror(err)); 373 373 } 374 374 return ctr.cycle_timer; … … 494 494 err=raw1394_read_cycle_timer(m_handle_util, &ctr); 495 495 if(err) { 496 debugWarning("raw1394_read_cycle_timer: %s ", strerror(err));496 debugWarning("raw1394_read_cycle_timer: %s\n", strerror(err)); 497 497 } 498 498 new_usecs=(freebob_microsecs_t)ctr.local_time; … … 643 643 err=raw1394_read_cycle_timer(m_handle_util, &ctr); 644 644 if(err) { 645 debugWarning("raw1394_read_cycle_timer: %s ", strerror(err));645 debugWarning("raw1394_read_cycle_timer: %s\n", strerror(err)); 646 646 } 647 647 prev_usecs=(freebob_microsecs_t)ctr.local_time; … … 665 665 err=raw1394_read_cycle_timer(m_handle_util, &ctr); 666 666 if(err) { 667 debugWarning("raw1394_read_cycle_timer: %s ", strerror(err));667 debugWarning("raw1394_read_cycle_timer: %s\n", strerror(err)); 668 668 } 669 669 new_usecs=(freebob_microsecs_t)ctr.local_time; branches/streaming-rework/src/libstreaming/StreamProcessor.h
r392 r394 140 140 public: 141 141 /** 142 * @brief Can this StreamProcessor handle a nframes offrames?143 * 144 * this function indicates if the streamprocessor can handle nframes145 * offrames. It is used to detect underruns-to-be.146 * 147 * @param nframes number of frames 142 * @brief Can this StreamProcessor handle a transfer of nframes frames? 143 * 144 * this function indicates if the streamprocessor can handle a transfer of 145 * nframes frames. It is used to detect underruns-to-be. 146 * 147 * @param nframes number of frames 148 148 * @return true if the StreamProcessor can handle this amount of frames 149 149 * false if it can't branches/streaming-rework/tests/test-cycletimer.cpp
r393 r394 196 196 subs=substractTicks(10, TICKS_PER_SECOND*128L + 12); 197 197 if (subs != -2) { 198 debugOutput(DEBUG_LEVEL_NORMAL, " substractTicks(10, TICKS_PER_SECOND*128L + 12) != -2 : %ld\n", 199 subs); 200 failures++; 201 } 198 debugOutput(DEBUG_LEVEL_NORMAL, " substractTicks(10, TICKS_PER_SECOND*128L + 12) != -2 : %l011llu\n", 199 subs); 200 failures++; 201 } 202 203 //--------- 204 // now = 10sec, 1380cy, 640ticks 205 206 uint32_t st=sytRecvToFullTicks(0x1234, 1000, 0x14564280); 207 if (st != 248860212LLU) { 208 debugOutput(DEBUG_LEVEL_NORMAL, " sytToRecvFullTicks(0x1234, 1000, 0x14564280) != 248860212 : %011lu\n", 209 st); 210 failures++; 211 } 212 213 st=sytRecvToFullTicks(0xB2B6, 7000, TICKS_TO_CYCLE_TIMER(3118082282LU)); 214 if (st != 3118089910LLU) { 215 debugOutput(DEBUG_LEVEL_NORMAL, " sytToRecvFullTicks(0x1234, 1000, %08X) != 3118089910 : %011lu\n", 216 TICKS_TO_CYCLE_TIMER(3118082282LU), st); 217 failures++; 218 } 219 220 st=sytXmitToFullTicks(0xC4EA, 3000, TICKS_TO_CYCLE_TIMER(2958285668LU)); 221 if (st != 2958349546LLU) { 222 debugOutput(DEBUG_LEVEL_NORMAL, " sytToXmitFullTicks(0x1234, 1000, %08X) != 2958349546 : %011lu\n", 223 TICKS_TO_CYCLE_TIMER(2958285668LU), st); 224 failures++; 225 } 202 226 203 227 if (failures) {