1 |
/* |
---|
2 |
* Copyright (C) 2005-2008 by Pieter Palmers |
---|
3 |
* |
---|
4 |
* This file is part of FFADO |
---|
5 |
* FFADO = Free Firewire (pro-)audio drivers for linux |
---|
6 |
* |
---|
7 |
* FFADO is based upon FreeBoB |
---|
8 |
* |
---|
9 |
* This program is free software: you can redistribute it and/or modify |
---|
10 |
* it under the terms of the GNU General Public License as published by |
---|
11 |
* the Free Software Foundation, either version 2 of the License, or |
---|
12 |
* (at your option) version 3 of the License. |
---|
13 |
* |
---|
14 |
* This program is distributed in the hope that it will be useful, |
---|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 |
* GNU General Public License for more details. |
---|
18 |
* |
---|
19 |
* You should have received a copy of the GNU General Public License |
---|
20 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
21 |
* |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
#include "cycletimer.h" |
---|
25 |
#include "debugmodule/debugmodule.h" |
---|
26 |
#include <stdio.h> |
---|
27 |
|
---|
28 |
DECLARE_GLOBAL_DEBUG_MODULE; |
---|
29 |
|
---|
30 |
int main() { |
---|
31 |
setDebugLevel(DEBUG_LEVEL_VERY_VERBOSE); |
---|
32 |
printf("Cycle timer operation tests (incomplete)\n"); |
---|
33 |
|
---|
34 |
/* TEST 1 |
---|
35 |
* check reconstruction of SYT RECEIVE timestamp |
---|
36 |
* |
---|
37 |
* The now_ctr has wrapped, while the cycle and syt have not |
---|
38 |
* |
---|
39 |
*/ |
---|
40 |
|
---|
41 |
#ifdef DEBUG |
---|
42 |
uint32_t now_ctr = 0x140001DA; |
---|
43 |
uint64_t now = CYCLE_TIMER_TO_TICKS(0x140001DA); |
---|
44 |
unsigned int cycle = 7968; |
---|
45 |
uint16_t syt = 0x583B; |
---|
46 |
#endif |
---|
47 |
|
---|
48 |
debugOutput(DEBUG_LEVEL_VERBOSE,"NOW_CTR : %08X (%03us %04uc %04ut)\n", |
---|
49 |
now_ctr, |
---|
50 |
(unsigned int)CYCLE_TIMER_GET_SECS(now_ctr), |
---|
51 |
(unsigned int)CYCLE_TIMER_GET_CYCLES(now_ctr), |
---|
52 |
(unsigned int)CYCLE_TIMER_GET_OFFSET(now_ctr)); |
---|
53 |
|
---|
54 |
debugOutput(DEBUG_LEVEL_VERBOSE,"NOW : %011"PRIu64" (%03us %04uc %04ut)\n", |
---|
55 |
now, |
---|
56 |
(unsigned int)TICKS_TO_SECS(now), |
---|
57 |
(unsigned int)TICKS_TO_CYCLES(now), |
---|
58 |
(unsigned int)TICKS_TO_OFFSET(now)); |
---|
59 |
debugOutput(DEBUG_LEVEL_VERBOSE,"SYT : %08X (%03us %04uc %04ut)\n", |
---|
60 |
syt, |
---|
61 |
(unsigned int)CYCLE_TIMER_GET_SECS(syt), |
---|
62 |
(unsigned int)CYCLE_TIMER_GET_CYCLES(syt), |
---|
63 |
(unsigned int)CYCLE_TIMER_GET_OFFSET(syt)); |
---|
64 |
debugOutput(DEBUG_LEVEL_VERBOSE,"CYCLE : %uc\n", |
---|
65 |
cycle); |
---|
66 |
#ifdef DEBUG |
---|
67 |
uint64_t calc_ts = sytRecvToFullTicks(syt, cycle, now_ctr); |
---|
68 |
#endif |
---|
69 |
|
---|
70 |
debugOutput(DEBUG_LEVEL_VERBOSE,"CALC_TS : %011"PRIu64" (%03us %04uc %04ut)\n", |
---|
71 |
calc_ts, |
---|
72 |
(unsigned int)TICKS_TO_SECS(calc_ts), |
---|
73 |
(unsigned int)TICKS_TO_CYCLES(calc_ts), |
---|
74 |
(unsigned int)TICKS_TO_OFFSET(calc_ts)); |
---|
75 |
|
---|
76 |
|
---|
77 |
// BL: 1211722982: Debug (IsoHandler.cpp)[ 420] putPacket: received packet: length=168, channel=0, cycle=7968 |
---|
78 |
// BL: 1211723031: Debug (cycletimer.h)[ 308] sytRecvToFullTicks: SYT=583B CY=7968 CTR=140001DA |
---|
79 |
// BL: 1211723037: Debug (StreamProcessor.cpp)[ 346] putPacket: RECV: CY=7968 TS=00245679163 |
---|
80 |
// BL: 1211723043: Debug (AmdtpReceiveStreamProcessor.cpp)[ 135] processPacketData: STMP: 245679163ticks | syt_interval=8, tpf=557.254395 |
---|
81 |
// BL: 1211723051: Debug (TimestampedBuffer.cpp)[1153] incrementFrameCounter: nbframes: 8, m_update_period: 8 |
---|
82 |
// BL: 1211723052: Debug (AmdtpTransmitStreamProcessor.cpp)[ 250] generatePacketHeader: Too early: CY=0254, TC=0257, CUT=0003, TST=00271126073 (0257), TSP=00271137849 (0261) |
---|
83 |
// BL: 1211723055: Debug (TimestampedBuffer.cpp)[1155] incrementFrameCounter: tail TS: 270250705.174, next tail TS: 270255163.209 |
---|
84 |
// BL: 1211723062: Debug (TimestampedBuffer.cpp)[1157] incrementFrameCounter: new TS: 245679163.000, wrapped new TS: 245679163.000 |
---|
85 |
// |
---|
86 |
|
---|
87 |
} |
---|