Index: /trunk/libffado/src/libieee1394/test-cyclecalc.cpp =================================================================== --- /trunk/libffado/src/libieee1394/test-cyclecalc.cpp (revision 1047) +++ /trunk/libffado/src/libieee1394/test-cyclecalc.cpp (revision 1763) @@ -52,5 +52,5 @@ (unsigned int)CYCLE_TIMER_GET_OFFSET(now_ctr)); - debugOutput(DEBUG_LEVEL_VERBOSE,"NOW : %011llu (%03us %04uc %04ut)\n", + debugOutput(DEBUG_LEVEL_VERBOSE,"NOW : %011"PRIu64" (%03us %04uc %04ut)\n", now, (unsigned int)TICKS_TO_SECS(now), @@ -68,5 +68,5 @@ #endif - debugOutput(DEBUG_LEVEL_VERBOSE,"CALC_TS : %011llu (%03us %04uc %04ut)\n", + debugOutput(DEBUG_LEVEL_VERBOSE,"CALC_TS : %011"PRIu64" (%03us %04uc %04ut)\n", calc_ts, (unsigned int)TICKS_TO_SECS(calc_ts), Index: /trunk/libffado/src/libieee1394/CycleTimerHelper.cpp =================================================================== --- /trunk/libffado/src/libieee1394/CycleTimerHelper.cpp (revision 1531) +++ /trunk/libffado/src/libieee1394/CycleTimerHelper.cpp (revision 1763) @@ -164,8 +164,8 @@ m_cycle_timer_prev, maxtries2); } - debugOutput( DEBUG_LEVEL_VERBOSE, " read : CTR: %11lu, local: %17llu\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " read : CTR: %11u, local: %17"PRIu64"\n", m_cycle_timer_prev, local_time); debugOutput(DEBUG_LEVEL_VERBOSE, - " ctr : 0x%08X %11llu (%03us %04ucy %04uticks)\n", + " ctr : 0x%08X %11"PRIu64" (%03us %04ucy %04uticks)\n", (uint32_t)m_cycle_timer_prev, (uint64_t)CYCLE_TIMER_TO_TICKS(m_cycle_timer_prev), (unsigned int)CYCLE_TIMER_GET_SECS( m_cycle_timer_prev ), @@ -291,8 +291,8 @@ cycle_timer_ticks = CYCLE_TIMER_TO_TICKS(cycle_timer); - debugOutputExtreme( DEBUG_LEVEL_VERY_VERBOSE, " read : CTR: %11lu, local: %17llu\n", + debugOutputExtreme( DEBUG_LEVEL_VERY_VERBOSE, " read : CTR: %11u, local: %17"PRIu64"\n", cycle_timer, local_time); debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - " ctr : 0x%08X %11llu (%03us %04ucy %04uticks)\n", + " ctr : 0x%08X %11"PRIu64" (%03us %04ucy %04uticks)\n", (uint32_t)cycle_timer, (uint64_t)cycle_timer_ticks, (unsigned int)TICKS_TO_SECS( (uint64_t)cycle_timer_ticks ), @@ -310,5 +310,5 @@ bw_abs, bw_rel); debugOutput(DEBUG_LEVEL_VERBOSE, - " usecs/update: %lu, ticks/update: %lu, m_dll_e2: %f\n", + " usecs/update: %u, ticks/update: %u, m_dll_e2: %f\n", m_usecs_per_update, m_ticks_per_update, m_dll_e2); debugOutput(DEBUG_LEVEL_VERBOSE, @@ -351,5 +351,5 @@ ffado_microsecs_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); int sleep_time = m_sleep_until - now; - debugOutput( DEBUG_LEVEL_ULTRA_VERBOSE, "(%p) Sleep until %lld/%f (now: %lld, diff=%d) ...\n", + debugOutput( DEBUG_LEVEL_ULTRA_VERBOSE, "(%p) Sleep until %"PRId64"/%f (now: %"PRId64", diff=%d) ...\n", this, m_sleep_until, m_next_time_usecs, now, sleep_time); #endif @@ -390,8 +390,8 @@ if(not_good) { debugOutput(DEBUG_LEVEL_VERBOSE, - "(%p) have to retry CTR read, diff unrealistic: diff: %lld, max: +/- %ld (try: %d) %lld\n", + "(%p) have to retry CTR read, diff unrealistic: diff: %"PRId64", max: +/- %u (try: %d) %"PRId64"\n", this, err_ticks, 1*TICKS_PER_CYCLE, ntries, expected_ticks); // sleep half a cycle to make sure the hardware moved on - Util::SystemTimeSource::SleepUsecRelative(USECS_PER_CYCLE); + Util::SystemTimeSource::SleepUsecRelative(USECS_PER_CYCLE / 2); } @@ -409,5 +409,5 @@ // // simulate a random scheduling delay between (0-10ms) // ffado_microsecs_t tmp = Util::SystemTimeSource::SleepUsecRandom(10000); - // debugOutput( DEBUG_LEVEL_VERBOSE, " (%p) random sleep of %llu usecs...\n", this, tmp); + // debugOutput( DEBUG_LEVEL_VERBOSE, " (%p) random sleep of %u usecs...\n", this, tmp); if(m_unhandled_busreset) { @@ -419,8 +419,8 @@ } - debugOutputExtreme( DEBUG_LEVEL_ULTRA_VERBOSE, " read : CTR: %11lu, local: %17llu\n", + debugOutputExtreme( DEBUG_LEVEL_ULTRA_VERBOSE, " read : CTR: %11u, local: %17"PRIu64"\n", cycle_timer, local_time); debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, - " ctr : 0x%08X %11llu (%03us %04ucy %04uticks)\n", + " ctr : 0x%08X %11"PRIu64" (%03us %04ucy %04uticks)\n", (uint32_t)cycle_timer, (uint64_t)cycle_timer_ticks, (unsigned int)TICKS_TO_SECS( (uint64_t)cycle_timer_ticks ), @@ -436,5 +436,5 @@ } else if (diff_ticks > m_ticks_per_update * 20) { debugOutput(DEBUG_LEVEL_VERBOSE, - "re-init dll due to too large tick diff: %lld >> %f\n", + "re-init dll due to too large tick diff: %"PRId64" >> %f\n", diff_ticks, (float)(m_ticks_per_update * 20)); if(!initDLL()) { @@ -462,5 +462,5 @@ diff_ticks_corr = diff_ticks - ticks_late; debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, - "diff_ticks_corr=%lld, diff_ticks = %lld, ticks_late = %lld\n", + "diff_ticks_corr=%"PRId64", diff_ticks = %"PRId64", ticks_late = %"PRId64"\n", diff_ticks_corr, diff_ticks, ticks_late); } else { @@ -473,5 +473,5 @@ // makes no sense if not running realtime if(m_realtime && usecs_late > 1000) { - debugOutput(DEBUG_LEVEL_VERBOSE, "Rather late wakeup: %lld usecs\n", usecs_late); + debugOutput(DEBUG_LEVEL_VERBOSE, "Rather late wakeup: %"PRId64" usecs\n", usecs_late); } #endif @@ -526,11 +526,11 @@ debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - " usecs: current: %f next: %f usecs_late=%lld ticks_late=%lld\n", + " usecs: current: %f next: %f usecs_late=%"PRId64" ticks_late=%"PRId64"\n", m_current_time_usecs, m_next_time_usecs, usecs_late, ticks_late); debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - " ticks: current: %f next: %f diff=%lld\n", + " ticks: current: %f next: %f diff=%"PRId64"\n", m_current_time_ticks, m_next_time_ticks, diff_ticks); debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - " ticks: current: %011llu (%03us %04ucy %04uticks)\n", + " ticks: current: %011"PRIu64" (%03us %04ucy %04uticks)\n", (uint64_t)m_current_time_ticks, (unsigned int)TICKS_TO_SECS( (uint64_t)m_current_time_ticks ), @@ -538,5 +538,5 @@ (unsigned int)TICKS_TO_OFFSET( (uint64_t)m_current_time_ticks ) ); debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - " ticks: next : %011llu (%03us %04ucy %04uticks)\n", + " ticks: next : %011"PRIu64" (%03us %04ucy %04uticks)\n", (uint64_t)m_next_time_ticks, (unsigned int)TICKS_TO_SECS( (uint64_t)m_next_time_ticks ), @@ -545,5 +545,5 @@ debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - " state: local: %11llu, dll_e2: %f, rate: %f\n", + " state: local: %11"PRIu64", dll_e2: %f, rate: %f\n", local_time, m_dll_e2, getRate()); } @@ -589,5 +589,5 @@ } int32_t ctr_diff = cycle_timer_ticks-dll_time; - debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, "(%p) CTR DIFF: HW %010llu - DLL %010lu = %010ld (%s)\n", + debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, "(%p) CTR DIFF: HW %010"PRIu64" - DLL %010u = %010d (%s)\n", this, cycle_timer_ticks, dll_time, ctr_diff, (ctr_diff>0?"lag":"lead")); #endif @@ -625,5 +625,5 @@ if (y_step_in_ticks_int > 0) { retval = addTicks(offset_in_ticks_int, y_step_in_ticks_int); -/* debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "y_step_in_ticks_int > 0: %lld, time_diff: %f, rate: %f, retval: %lu\n", +/* debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "y_step_in_ticks_int > 0: %d, time_diff: %f, rate: %f, retval: %u\n", y_step_in_ticks_int, time_diff, my_vars.rate, retval);*/ } else { @@ -631,5 +631,5 @@ // this can happen if the update thread was woken up earlier than it should have been -/* debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "y_step_in_ticks_int <= 0: %lld, time_diff: %f, rate: %f, retval: %lu\n", +/* debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "y_step_in_ticks_int <= 0: %d, time_diff: %f, rate: %f, retval: %u\n", y_step_in_ticks_int, time_diff, my_vars.rate, retval);*/ } @@ -792,5 +792,5 @@ if (diffTicks(cycle_timer_ticks, m_cycle_timer_ticks_prev) < 0) { debugOutput( DEBUG_LEVEL_VERY_VERBOSE, - "non-monotonic CTR (try %02d): %llu -> %llu\n", + "non-monotonic CTR (try %02d): %"PRIu64" -> %"PRIu64"\n", maxtries, m_cycle_timer_ticks_prev, cycle_timer_ticks); debugOutput( DEBUG_LEVEL_VERY_VERBOSE, @@ -798,5 +798,5 @@ m_cycle_timer_prev, *cycle_timer); debugOutput( DEBUG_LEVEL_VERY_VERBOSE, - " current: %011llu (%03us %04ucy %04uticks)\n", + " current: %011"PRIu64" (%03us %04ucy %04uticks)\n", cycle_timer_ticks, (unsigned int)TICKS_TO_SECS( cycle_timer_ticks ), @@ -804,5 +804,5 @@ (unsigned int)TICKS_TO_OFFSET( cycle_timer_ticks ) ); debugOutput( DEBUG_LEVEL_VERY_VERBOSE, - " prev : %011llu (%03us %04ucy %04uticks)\n", + " prev : %011"PRIu64" (%03us %04ucy %04uticks)\n", m_cycle_timer_ticks_prev, (unsigned int)TICKS_TO_SECS( m_cycle_timer_ticks_prev ), Index: /trunk/libffado/src/libieee1394/cycletimer.h =================================================================== --- /trunk/libffado/src/libieee1394/cycletimer.h (revision 1531) +++ /trunk/libffado/src/libieee1394/cycletimer.h (revision 1763) @@ -95,5 +95,5 @@ #ifdef DEBUG if (x >= TICKS_PER_SECOND * 128L) { - debugWarning("insufficient wrapping: %llu\n",x); + debugWarning("insufficient wrapping: %"PRIu64"\n",x); } #endif @@ -118,5 +118,5 @@ #ifdef DEBUG if (x < 0) { - debugWarning("insufficient wrapping: %lld\n",x); + debugWarning("insufficient wrapping: %"PRId64"\n",x); } #endif @@ -145,8 +145,8 @@ #ifdef DEBUG if (x >= (int64_t)(TICKS_PER_SECOND * 128L)) { - debugWarning("insufficient wrapping (max): %llu\n",x); + debugWarning("insufficient wrapping (max): %"PRIu64"\n",x); } if (x < 0) { - debugWarning("insufficient wrapping (min): %lld\n",x); + debugWarning("insufficient wrapping (min): %"PRId64"\n",x); } #endif @@ -249,5 +249,5 @@ if(diff > max || diff < -max) { debugWarning("difference does not make any sense\n"); - debugWarning("diff=%lld max=%lld\n", diff, max); + debugWarning("diff=%"PRId64" max=%"PRId64"\n", diff, max); } @@ -302,5 +302,5 @@ uint64_t timestamp; - debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "SYT=%04llX CY=%u CTR=%08llX\n", + debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "SYT=%"PRIX64" CY=%u CTR=%08"PRIX64"\n", syt_timestamp, rcv_cycle, ctr_now); @@ -313,5 +313,5 @@ int diff_cycles = diffCycles(cc_cycles, rcv_cycle); if (diff_cycles<0) { - debugWarning("current cycle timer not ahead of receive cycle: rcv: %u / cc: %llu (%d)\n", + debugWarning("current cycle timer not ahead of receive cycle: rcv: %u / cc: %"PRIu64" (%d)\n", rcv_cycle, cc_cycles, diff_cycles); } @@ -351,5 +351,5 @@ } else { debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "Detected wraparound: %d + %d = %d\n", + "Detected wraparound: %u + %"PRId64" = %"PRId64"\n", rcv_cycle, delta_cycles, new_cycles); @@ -372,5 +372,5 @@ if(( TICKS_TO_CYCLE_TIMER(timestamp) & 0xFFFF) != syt_timestamp) { debugWarning("back-converted timestamp not equal to SYT\n"); - debugWarning("TS=%011llu TSC=%08lX SYT=%04X\n", + debugWarning("TS=%011"PRIu64" TSC=%08"PRIX64" SYT=%04"PRIX64"\n", timestamp, TICKS_TO_CYCLE_TIMER(timestamp), syt_timestamp); } @@ -391,5 +391,5 @@ uint64_t timestamp; - debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "SYT=%04llX RCV_CTR=%08X\n", + debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "SYT=%04"PRIX64" RCV_CTR=%08X\n", syt_timestamp, rcv_ctr); @@ -433,5 +433,5 @@ if(( TICKS_TO_CYCLE_TIMER(timestamp) & 0xFFFF) != syt_timestamp) { debugWarning("back-converted timestamp not equal to SYT\n"); - debugWarning("TS=%011llu TSC=%08lX SYT=%04X\n", + debugWarning("TS=%011"PRIu64" TSC=%08"PRIX64" SYT=%04"PRIX64"\n", timestamp, TICKS_TO_CYCLE_TIMER(timestamp), syt_timestamp); } @@ -457,5 +457,5 @@ uint64_t timestamp; - debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "SYT=%08llX CY=%04X CTR=%08llX\n", + debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, "SYT=%08"PRIX64" CY=%04X CTR=%08"PRIX64"\n", syt_timestamp, xmt_cycle, ctr_now); @@ -467,5 +467,5 @@ int diff_cycles = diffCycles(xmt_cycle, cc_cycles); if (diff_cycles<0) { - debugWarning("xmit cycle not ahead of current cycle: xmt: %u / cc: %llu (%d)\n", + debugWarning("xmit cycle not ahead of current cycle: xmt: %u / cc: %"PRIu64" (%d)\n", xmt_cycle, cc_cycles, diff_cycles); } @@ -505,5 +505,5 @@ } else { debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "Detected wraparound: %d + %d = %d\n", + "Detected wraparound: %u + %"PRId64" = %"PRId64"\n", xmt_cycle, delta_cycles, new_cycles); @@ -526,5 +526,5 @@ if(( TICKS_TO_CYCLE_TIMER(timestamp) & 0xFFFF) != syt_timestamp) { debugWarning("back-converted timestamp not equal to SYT\n"); - debugWarning("TS=%011llu TSC=%08lX SYT=%04X\n", + debugWarning("TS=%011"PRIu64" TSC=%08"PRIX64" SYT=%04"PRIX64"\n", timestamp, TICKS_TO_CYCLE_TIMER(timestamp), syt_timestamp); } Index: /trunk/libffado/src/libieee1394/ieee1394service.cpp =================================================================== --- /trunk/libffado/src/libieee1394/ieee1394service.cpp (revision 1660) +++ /trunk/libffado/src/libieee1394/ieee1394service.cpp (revision 1763) @@ -57,5 +57,5 @@ , m_armHelperRealtime( NULL ) , m_handle( 0 ) - , m_handle_lock( new Util::PosixMutex("SRCVHND") ) + , m_handle_lock( new Util::PosixMutex("SRVCHND") ) , m_util_handle( 0 ) , m_port( -1 ) @@ -85,5 +85,5 @@ , m_armHelperRealtime( NULL ) , m_handle( 0 ) - , m_handle_lock( new Util::PosixMutex("SRCVHND") ) + , m_handle_lock( new Util::PosixMutex("SRVCHND") ) , m_util_handle( 0 ) , m_port( -1 ) @@ -122,9 +122,9 @@ ++it ) { - debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler for 0x%016llX\n", (*it)->getStart()); + debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler for 0x%016"PRIX64"\n", (*it)->getStart()); if(m_armHelperNormal) { int err = raw1394_arm_unregister(m_armHelperNormal->get1394Handle(), (*it)->getStart()); if (err) { - debugError(" Failed to unregister ARM handler for 0x%016llX\n", (*it)->getStart()); + debugError(" Failed to unregister ARM handler for 0x%016"PRIX64"\n", (*it)->getStart()); debugError(" Error: %s\n", strerror(errno)); } @@ -557,5 +557,5 @@ #ifdef DEBUG debugOutput(DEBUG_LEVEL_VERY_VERBOSE, - "read: node 0x%hX, addr = 0x%016llX, length = %u\n", + "read: node 0x%hX, addr = 0x%016"PRIX64", length = %zd\n", nodeId, addr, length); printBuffer( DEBUG_LEVEL_VERY_VERBOSE, length, buffer ); @@ -566,5 +566,5 @@ #ifdef DEBUG debugOutput(DEBUG_LEVEL_VERBOSE, - "raw1394_read failed: node 0x%hX, addr = 0x%016llX, length = %u\n", + "raw1394_read failed: node 0x%hX, addr = 0x%016"PRIX64", length = %zd\n", nodeId, addr, length); #endif @@ -612,5 +612,5 @@ #ifdef DEBUG - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"write: node 0x%hX, addr = 0x%016llX, length = %d\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"write: node 0x%hX, addr = 0x%016"PRIX64", length = %zd\n", nodeId, addr, length); printBuffer( DEBUG_LEVEL_VERY_VERBOSE, length, data ); @@ -649,7 +649,7 @@ } #ifdef DEBUG - debugOutput(DEBUG_LEVEL_VERBOSE,"lockCompareSwap64: node 0x%X, addr = 0x%016llX\n", + debugOutput(DEBUG_LEVEL_VERBOSE,"lockCompareSwap64: node 0x%X, addr = 0x%016"PRIX64"\n", nodeId, addr); - debugOutput(DEBUG_LEVEL_VERBOSE," if (*(addr)==0x%016llX) *(addr)=0x%016llX\n", + debugOutput(DEBUG_LEVEL_VERBOSE," if (*(addr)==0x%016"PRIX64") *(addr)=0x%016"PRIX64"\n", compare_value, swap_value); fb_octlet_t buffer; @@ -657,5 +657,5 @@ debugWarning("Could not read register\n"); } else { - debugOutput(DEBUG_LEVEL_VERBOSE,"before = 0x%016llX\n", buffer); + debugOutput(DEBUG_LEVEL_VERBOSE,"before = 0x%016"PRIX64"\n", buffer); } #endif @@ -681,5 +681,5 @@ debugWarning("Could not read register\n"); } else { - debugOutput(DEBUG_LEVEL_VERBOSE,"after = 0x%016llX\n", buffer); + debugOutput(DEBUG_LEVEL_VERBOSE,"after = 0x%016"PRIX64"\n", buffer); } #endif @@ -831,4 +831,17 @@ } + // check the request and figure out what happened + if(m_fcp_block.status == eFS_Waiting) { + debugOutput(DEBUG_LEVEL_VERBOSE, "FCP response timed out\n"); + retval = false; + goto out; + } + if(m_fcp_block.status == eFS_Error) { + debugError("FCP request/response error\n"); + retval = false; + goto out; + } + +out: // stop listening for FCP responses err = raw1394_stop_fcp_listen(m_handle); @@ -836,20 +849,6 @@ debugOutput(DEBUG_LEVEL_VERBOSE, "could not stop FCP listen (err=%d, errno=%d)\n", err, errno); retval = false; - goto out; - } - - // check the request and figure out what happened - if(m_fcp_block.status == eFS_Waiting) { - debugOutput(DEBUG_LEVEL_VERBOSE, "FCP response timed out\n"); - retval = false; - goto out; - } - if(m_fcp_block.status == eFS_Error) { - debugError("FCP request/response error\n"); - retval = false; - goto out; - } - -out: + } + m_fcp_block.status = eFS_Empty; return retval; @@ -876,5 +875,5 @@ fb_quadlet_t *data_quads = (fb_quadlet_t *)data; #ifdef DEBUG - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"fcp response: node 0x%hX, response = %d, length = %d bytes\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"fcp response: node 0x%hX, response = %d, length = %zd bytes\n", nodeid, response, length); printBuffer(DEBUG_LEVEL_VERY_VERBOSE, (length+3)/4, data_quads ); @@ -906,5 +905,5 @@ } else if(FCP_MASK_SUBUNIT_AND_OPCODE(first_quadlet) != FCP_MASK_SUBUNIT_AND_OPCODE(CondSwapFromBus32(m_fcp_block.request[0]))) { - debugOutput(DEBUG_LEVEL_VERBOSE, "FCP response not for this request: %08lX != %08lX\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "FCP response not for this request: %08X != %08X\n", FCP_MASK_SUBUNIT_AND_OPCODE(first_quadlet), FCP_MASK_SUBUNIT_AND_OPCODE(CondSwapFromBus32(m_fcp_block.request[0]))); @@ -970,5 +969,5 @@ return 0; } - debugOutput(DEBUG_LEVEL_VERBOSE, " READ HI: 0x%08lX\n", split_timeout_hi); + debugOutput(DEBUG_LEVEL_VERBOSE, " READ HI: 0x%08X\n", split_timeout_hi); if(!readNoLock( 0xffc0 | nodeId, CSR_REGISTER_BASE + CSR_SPLIT_TIMEOUT_LO, 1, @@ -977,5 +976,5 @@ return 0; } - debugOutput(DEBUG_LEVEL_VERBOSE, " READ LO: 0x%08lX\n", split_timeout_low); + debugOutput(DEBUG_LEVEL_VERBOSE, " READ LO: 0x%08X\n", split_timeout_low); split_timeout_hi = CondSwapFromBus32(split_timeout_hi); @@ -1073,6 +1072,7 @@ bool Ieee1394Service::registerARMHandler(ARMHandler *h) { - debugOutput(DEBUG_LEVEL_VERBOSE, "Registering ARM handler (%p) for 0x%016llX, length %u\n", - h, h->getStart(), h->getLength()); + debugOutput(DEBUG_LEVEL_VERBOSE, + "Registering ARM handler (%p) for 0x%016"PRIX64", length %zu\n", + h, h->getStart(), h->getLength()); // FIXME: note that this will result in the ARM handlers not running in a realtime context @@ -1083,5 +1083,5 @@ h->getClientTransactions()); if (err) { - debugError("Failed to register ARM handler for 0x%016llX\n", h->getStart()); + debugError("Failed to register ARM handler for 0x%016"PRIX64"\n", h->getStart()); debugError(" Error: %s\n", strerror(errno)); return false; @@ -1092,5 +1092,5 @@ bool Ieee1394Service::unregisterARMHandler( ARMHandler *h ) { - debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler (%p) for 0x%016llX\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler (%p) for 0x%016"PRIX64"\n", h, h->getStart()); @@ -1123,6 +1123,7 @@ */ nodeaddr_t Ieee1394Service::findFreeARMBlock( nodeaddr_t start, size_t length, size_t step ) { - debugOutput(DEBUG_LEVEL_VERBOSE, "Finding free ARM block of %d bytes, from 0x%016llX in steps of %d bytes\n", - length, start, step); + debugOutput(DEBUG_LEVEL_VERBOSE, + "Finding free ARM block of %zd bytes, from 0x%016"PRIX64" in steps of %zd bytes\n", + length, start, step); int cnt=0; @@ -1135,9 +1136,9 @@ if (err) { - debugOutput(DEBUG_LEVEL_VERBOSE, " -> cannot use 0x%016llX\n", start); + debugOutput(DEBUG_LEVEL_VERBOSE, " -> cannot use 0x%016"PRIX64"\n", start); debugError(" Error: %s\n", strerror(errno)); start += step; } else { - debugOutput(DEBUG_LEVEL_VERBOSE, " -> use 0x%016llX\n", start); + debugOutput(DEBUG_LEVEL_VERBOSE, " -> use 0x%016"PRIX64"\n", start); err = raw1394_arm_unregister(m_handle, start); if (err) { @@ -1188,5 +1189,5 @@ raw1394_arm_response_t arm_resp = arm_req_resp->response; - debugOutput(DEBUG_LEVEL_VERBOSE,"ARM handler for address 0x%016llX called\n", + debugOutput(DEBUG_LEVEL_VERBOSE,"ARM handler for address 0x%016"PRIX64" called\n", (*it)->getStart()); debugOutput(DEBUG_LEVEL_VERBOSE," request type : 0x%02X\n", request_type); @@ -1583,5 +1584,5 @@ debugOutput( DEBUG_LEVEL_VERBOSE, " CycleTimerHelper: %p, IsoManager: %p, WatchDog: %p\n", m_pCTRHelper, m_pIsoManager, m_pWatchdog ); - debugOutput( DEBUG_LEVEL_VERBOSE, " Time: %011llu (%03us %04ucy %04uticks)\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " Time: %011"PRIu64" (%03us %04ucy %04uticks)\n", ctr, (unsigned int)TICKS_TO_SECS( ctr ), Index: /trunk/libffado/src/libieee1394/ARMHandler.cpp =================================================================== --- /trunk/libffado/src/libieee1394/ARMHandler.cpp (revision 1550) +++ /trunk/libffado/src/libieee1394/ARMHandler.cpp (revision 1763) @@ -123,7 +123,7 @@ debugOutput(DEBUG_LEVEL_VERBOSE, " tlabel: 0x%02X, tcode: 0x%02X, extended tcode: 0x%02X\n", arm_req->tlabel, arm_req->tcode, arm_req->extended_transaction_code); - debugOutput(DEBUG_LEVEL_VERBOSE, " generation: %lu\n", + debugOutput(DEBUG_LEVEL_VERBOSE, " generation: %u\n", arm_req->generation); - debugOutput(DEBUG_LEVEL_VERBOSE, " buffer length: %lu\n", + debugOutput(DEBUG_LEVEL_VERBOSE, " buffer length: %u\n", arm_req->buffer_length); printBufferBytes(DEBUG_LEVEL_VERBOSE, arm_req->buffer_length, arm_req->buffer); Index: /trunk/libffado/src/libieee1394/configrom.cpp =================================================================== --- /trunk/libffado/src/libieee1394/configrom.cpp (revision 1336) +++ /trunk/libffado/src/libieee1394/configrom.cpp (revision 1763) @@ -486,5 +486,5 @@ { debugOutput( DEBUG_LEVEL_VERBOSE, - "Checking for updated node id for device with GUID 0x%016llX...\n", + "Checking for updated node id for device with GUID 0x%016"PRIX64"...\n", getGuid()); @@ -517,5 +517,5 @@ debugOutput( DEBUG_LEVEL_VERBOSE, - " Node has GUID 0x%016llX\n", + " Node has GUID 0x%016"PRIX64"\n", guid); @@ -524,5 +524,5 @@ if ( nodeId != getNodeId() ) { debugOutput( DEBUG_LEVEL_VERBOSE, - "Device with GUID 0x%016llX changed node id " + "Device with GUID 0x%016"PRIX64" changed node id " "from %d to %d\n", getGuid(), @@ -532,5 +532,5 @@ } else { debugOutput( DEBUG_LEVEL_VERBOSE, - "Device with GUID 0x%016llX kept node id %d\n", + "Device with GUID 0x%016"PRIX64" kept node id %d\n", getGuid(), getNodeId()); @@ -549,5 +549,5 @@ debugOutput( DEBUG_LEVEL_VERBOSE, - "Device with GUID 0x%016llX could not be found on " + "Device with GUID 0x%016"PRIX64" could not be found on " "the bus anymore (removed?)\n", getGuid() ); @@ -562,5 +562,5 @@ debugOutput(DEBUG_LEVEL_NORMAL, "Config ROM\n" ); debugOutput(DEBUG_LEVEL_NORMAL, "\tCurrent Node Id:\t%d\n", getNodeId() ); - debugOutput(DEBUG_LEVEL_NORMAL, "\tGUID:\t\t\t0x%016llX\n", getGuid()); + debugOutput(DEBUG_LEVEL_NORMAL, "\tGUID:\t\t\t0x%016"PRIX64"\n", getGuid()); debugOutput(DEBUG_LEVEL_NORMAL, "\tVendor Name:\t\t%s\n", getVendorName().c_str() ); debugOutput(DEBUG_LEVEL_NORMAL, "\tModel Name:\t\t%s\n", getModelName().c_str() ); @@ -583,5 +583,5 @@ printMessage("Config ROM\n" ); printMessage("\tCurrent Node Id:\t%d\n", getNodeId() ); - printMessage("\tGUID:\t\t\t0x%016llX\n", getGuid()); + printMessage("\tGUID:\t\t\t0x%016"PRIX64"\n", getGuid()); printMessage("\tVendor Name:\t\t%s\n", getVendorName().c_str() ); printMessage("\tModel Name:\t\t%s\n", getModelName().c_str() ); Index: /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp =================================================================== --- /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (revision 1731) +++ /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (revision 1763) @@ -114,5 +114,5 @@ if (!h->handleBusReset()) { - debugWarning("Failed to handle busreset on %p\n"); + debugWarning("Failed to handle busreset on %p\n", h); retval = false; } @@ -261,5 +261,5 @@ if(no_one_to_poll) { - debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "(%p, %s) No one to poll, waiting for something to happen\n", this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive")); @@ -325,9 +325,9 @@ debugOutputExtreme(DEBUG_LEVEL_VERBOSE, - "(%p, %s) check handler %d: diff = %lld, max = %lld, now: %08lX, last: %08lX\n", + "(%p, %s) check handler %d: diff = %"PRId64", max = %"PRId64", now: %08X, last: %08X\n", this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive"), i, measured_diff_ticks, max_diff_ticks, ctr_at_poll_return, last_packet_seen); if(measured_diff_ticks > max_diff_ticks) { - debugFatal("(%p, %s) Handler died: now: %08lX, last: %08lX, diff: %lld (max: %lld)\n", + debugFatal("(%p, %s) Handler died: now: %08X, last: %08X, diff: %"PRId64" (max: %"PRId64")\n", this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive"), ctr_at_poll_return, last_packet_seen, measured_diff_ticks, max_diff_ticks); @@ -410,12 +410,14 @@ debugError("(%p) sem_timedwait error (result=%d errno=EINVAL)\n", this, result); - debugError("(%p) timeout_nsec=%lld ts.sec=%d ts.nsec=%lld\n", - this, m_activity_wait_timeout_nsec, ts.tv_sec, ts.tv_nsec); + debugError("(%p) timeout_nsec=%lld ts.sec=%"PRId64" ts.nsec=%"PRId64"\n", + this, m_activity_wait_timeout_nsec, + (int64_t)ts.tv_sec, (int64_t)ts.tv_nsec); return eAR_Error; } else { debugError("(%p) sem_timedwait error (result=%d errno=%d)\n", this, result, errno); - debugError("(%p) timeout_nsec=%lld ts.sec=%d ts.nsec=%lld\n", - this, m_activity_wait_timeout_nsec, ts.tv_sec, ts.tv_nsec); + debugError("(%p) timeout_nsec=%lld ts.sec=%"PRId64" ts.nsec=%"PRId64"\n", + this, m_activity_wait_timeout_nsec, + (int64_t)ts.tv_sec, (int64_t)ts.tv_nsec); return eAR_Error; } @@ -885,5 +887,5 @@ m_StreamProcessors.push_back(stream); - debugOutput( DEBUG_LEVEL_VERBOSE, " %d streams, %d handlers registered\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " %zd streams, %zd handlers registered\n", m_StreamProcessors.size(), m_IsoHandlers.size()); return true; Index: /trunk/libffado/src/libieee1394/IsoHandler.cpp =================================================================== --- /trunk/libffado/src/libieee1394/IsoHandler.cpp (revision 1731) +++ /trunk/libffado/src/libieee1394/IsoHandler.cpp (revision 1763) @@ -261,5 +261,5 @@ // wake ourselves up - raw1394_wake_up(m_handle); + if(m_handle) raw1394_wake_up(m_handle); } @@ -396,7 +396,11 @@ if((pkt_ctr & ~0x0FFFL) != pkt_ctr_ref) { debugWarning("reconstructed CTR counter discrepancy\n"); - debugWarning(" ingredients: %X, %lX, %lX, %lX, %lX, %ld, %ld, %ld, %lld\n", - cycle, pkt_ctr_ref, pkt_ctr, now, m_last_now, now_secs_ref, CYCLE_TIMER_GET_SECS(now), CYCLE_TIMER_GET_SECS(m_last_now), tmp); - debugWarning(" diffcy = %ld \n", diff_cycles); + debugWarning(" ingredients: %X, %X, %X, %X, %X, %d, %ld, %ld, %"PRId64"\n", + cycle, pkt_ctr_ref, pkt_ctr, + now, m_last_now, now_secs_ref, + (long int)CYCLE_TIMER_GET_SECS(now), + (long int)CYCLE_TIMER_GET_SECS(m_last_now), + tmp); + debugWarning(" diffcy = %"PRId64" \n", diff_cycles); } #endif @@ -475,7 +479,11 @@ if(((pkt_ctr & ~0x0FFFL) != pkt_ctr_ref) && (m_packets > m_buf_packets)) { debugWarning("reconstructed CTR counter discrepancy\n"); - debugWarning(" ingredients: %X, %lX, %lX, %lX, %lX, %ld, %ld, %ld, %lld\n", - cycle, pkt_ctr_ref, pkt_ctr, now, m_last_now, now_secs_ref, CYCLE_TIMER_GET_SECS(now), CYCLE_TIMER_GET_SECS(m_last_now), tmp); - debugWarning(" diffcy = %ld \n", diff_cycles); + debugWarning(" ingredients: %X, %X, %X, %X, %X, %d, %ld, %ld, %"PRId64"\n", + cycle, pkt_ctr_ref, pkt_ctr, + now, m_last_now, now_secs_ref, + (long int)CYCLE_TIMER_GET_SECS(now), + (long int)CYCLE_TIMER_GET_SECS(m_last_now), + tmp); + debugWarning(" diffcy = %"PRId64" \n", diff_cycles); } #endif Index: /trunk/libffado/src/devicemanager.h =================================================================== --- /trunk/libffado/src/devicemanager.h (revision 1336) +++ /trunk/libffado/src/devicemanager.h (revision 1763) @@ -90,5 +90,7 @@ bool prepareStreaming(); bool finishStreaming(); + bool startStreamingOnDevice(FFADODevice *device); bool startStreaming(); + bool stopStreamingOnDevice(FFADODevice *device); bool stopStreaming(); bool resetStreaming(); Index: /trunk/libffado/src/libstreaming/amdtp-oxford/AmdtpOxfordReceiveStreamProcessor.cpp =================================================================== --- /trunk/libffado/src/libstreaming/amdtp-oxford/AmdtpOxfordReceiveStreamProcessor.cpp (revision 1535) +++ /trunk/libffado/src/libstreaming/amdtp-oxford/AmdtpOxfordReceiveStreamProcessor.cpp (revision 1763) @@ -190,5 +190,5 @@ m_dll_e2 += m_dll_c * err; - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Generated TSP: %16llu %lld %d %d\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Generated TSP: %16"PRIu64" %"PRId64" %"PRId32" %"PRId64"\n", m_next_packet_timestamp, m_next_packet_timestamp-m_last_timestamp, frames_in_tempbuffer, ((length / sizeof (quadlet_t)) - 2) / m_dimension); Index: /trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp =================================================================== --- /trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp (revision 1498) +++ /trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp (revision 1763) @@ -207,5 +207,5 @@ // we are too late debugOutput(DEBUG_LEVEL_VERBOSE, - "Too late: CY=%04u, TC=%04u, CUT=%04d, TSP=%011llu (%04u)\n", + "Too late: CY=%04u, TC=%04u, CUT=%04d, TSP=%011"PRIu64" (%04u)\n", cycle, transmit_at_cycle, cycles_until_transmit, @@ -242,5 +242,5 @@ { debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, - "Too early: CY=%04u, TC=%04u, CUT=%04d, TST=%011llu (%04u), TSP=%011llu (%04u)\n", + "Too early: CY=%04u, TC=%04u, CUT=%04d, TST=%011"PRIu64" (%04u), TSP=%011"PRIu64" (%04u)\n", cycle, transmit_at_cycle, cycles_until_transmit, @@ -251,5 +251,5 @@ { debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, - "Way too early: CY=%04u, TC=%04u, CUT=%04d, TST=%011llu (%04u), TSP=%011llu (%04u)\n", + "Way too early: CY=%04u, TC=%04u, CUT=%04d, TST=%011"PRIu64" (%04u), TSP=%011"PRIu64" (%04u)\n", cycle, transmit_at_cycle, cycles_until_transmit, @@ -330,6 +330,6 @@ uint32_t pkt_ctr ) { - debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, "XMIT EMPTY: CY=%04u, TSP=%011llu (%04u)\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp, + debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, "XMIT EMPTY: CY=%04d, TSP=%011"PRIu64" (%04u)\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp, ( unsigned int ) TICKS_TO_CYCLES ( m_last_timestamp ) ); @@ -359,5 +359,5 @@ unsigned int cycle = CYCLE_TIMER_GET_CYCLES(pkt_ctr); - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "XMIT SILENT: CY=%04u, TSP=%011llu (%04u)\n", + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "XMIT SILENT: CY=%04u, TSP=%011"PRIu64" (%04u)\n", cycle, m_last_timestamp, ( unsigned int ) TICKS_TO_CYCLES ( m_last_timestamp ) ); Index: /trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp =================================================================== --- /trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp (revision 1498) +++ /trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp (revision 1763) @@ -187,5 +187,5 @@ #ifdef DEBUG if(isRunning()) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"STMP: %lluticks | tpf=%f\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"STMP: %"PRIu64"ticks | tpf=%f\n", m_last_timestamp, getTicksPerFrame()); } Index: /trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp =================================================================== --- /trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (revision 1531) +++ /trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (revision 1763) @@ -96,5 +96,5 @@ debugOutputExtreme( DEBUG_LEVEL_ULTRA_VERBOSE, - "Try for cycle %d\n", CYCLE_TIMER_GET_CYCLES(pkt_ctr) ); + "Try for cycle %d\n", (int) CYCLE_TIMER_GET_CYCLES(pkt_ctr) ); // check whether the packet buffer has packets for us to send. // the base timestamp is the one of the next sample in the buffer @@ -142,6 +142,6 @@ { debugOutput( DEBUG_LEVEL_NORMAL, - "Insufficient frames (P): N=%02d, CY=%04u, TC=%04u, CUT=%04d\n", - fc, CYCLE_TIMER_GET_CYCLES(pkt_ctr), + "Insufficient frames (P): N=%02d, CY=%04d, TC=%04u, CUT=%04d\n", + fc, (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), transmit_at_cycle, cycles_until_transmit ); // we are too late @@ -154,6 +154,6 @@ debugOutputExtreme(DEBUG_LEVEL_VERBOSE, - "Insufficient frames (NP): N=%02d, CY=%04u, TC=%04u, CUT=%04d, NOW=%04d\n", - fc, CYCLE_TIMER_GET_CYCLES(pkt_ctr), + "Insufficient frames (NP): N=%02d, CY=%04d, TC=%04u, CUT=%04d, NOW=%04d\n", + fc, (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), transmit_at_cycle, cycles_until_transmit, now_cycle ); #endif @@ -201,6 +201,6 @@ // we are too late debugOutput(DEBUG_LEVEL_VERBOSE, - "Too late: CY=%04u, TC=%04u, CUT=%04d, TSP=%011llu (%04u)\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), + "Too late: CY=%04d, TC=%04u, CUT=%04d, TSP=%011"PRIu64" (%04u)\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), transmit_at_cycle, cycles_until_transmit, presentation_time, (unsigned int)TICKS_TO_CYCLES(presentation_time) ); @@ -230,5 +230,5 @@ // for timestamp tracing debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "XMIT PKT: TSP= %011llu (%04u) (%04u) (%04u)\n", + "XMIT PKT: TSP= %011"PRIu64" (%04u) (%04u) (%04u)\n", presentation_time, (unsigned int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), @@ -240,6 +240,6 @@ { debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "Too early: CY=%04u, TC=%04u, CUT=%04d, TST=%011llu (%04u), TSP=%011llu (%04u)\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), + "Too early: CY=%04u, TC=%04u, CUT=%04d, TST=%011"PRIu64" (%04u), TSP=%011"PRId64" (%04u)\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), transmit_at_cycle, cycles_until_transmit, transmit_at_time, (unsigned int)TICKS_TO_CYCLES(transmit_at_time), @@ -249,6 +249,6 @@ { debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "Way too early: CY=%04u, TC=%04u, CUT=%04d, TST=%011llu (%04u), TSP=%011llu (%04u)\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), + "Way too early: CY=%04u, TC=%04u, CUT=%04d, TST=%011"PRIu64" (%04u), TSP=%011"PRId64"(%04u)\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), transmit_at_cycle, cycles_until_transmit, transmit_at_time, (unsigned int)TICKS_TO_CYCLES(transmit_at_time), @@ -269,8 +269,24 @@ if (m_data_buffer->readFrames(m_syt_interval, (char *)(data + 8))) { - debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "XMIT DATA: TSP= %011llu (%04u)\n", + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, + "XMIT DATA: TSP= %011"PRIu64" (%04u)\n", m_last_timestamp, (unsigned int)TICKS_TO_CYCLES(m_last_timestamp)); + #if 0 + // debug code to output the packet content + char tmpbuff[8192]; + int cnt=0; + quadlet_t *tmp = (quadlet_t *)((char *)(data + 8)); + + for(int i=0; isid = m_local_node_id; @@ -1036,8 +1052,8 @@ *target_event = CondSwapToBus32(tmpval); -// debugOutput ( DEBUG_LEVEL_VERBOSE, "MIDI port %s, pos=%u, loc=%u, nevents=%u, dim=%d\n", -// p.port->getName().c_str(), p.position, p.location, nevents, m_dimension ); -// debugOutput ( DEBUG_LEVEL_VERBOSE, "base=%p, target=%p, value=%08X\n", -// data, target_event, tmpval ); + debugOutputExtreme( DEBUG_LEVEL_VERBOSE, "MIDI port %s, pos=%u, loc=%u, nevents=%u, dim=%d\n", + p.port->getName().c_str(), p.position, p.location, nevents, m_dimension ); + debugOutputExtreme( DEBUG_LEVEL_VERBOSE, "base=%p, target=%p, value=%08X\n", + data, target_event, tmpval ); } else { // can't send a byte, either because there is no byte, Index: /trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp =================================================================== --- /trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (revision 1531) +++ /trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (revision 1763) @@ -148,8 +148,8 @@ if(isRunning()) { debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "STMP: %lluticks | syt_interval=%d, tpf=%f\n", + "STMP: %"PRIu64"ticks | syt_interval=%d, tpf=%f\n", m_last_timestamp, m_syt_interval, getTicksPerFrame()); /* debugOutput(DEBUG_LEVEL_NORMAL, - "STMP: %12llu ticks | delta_t: %5lld | bufferfill: %5d\n", + "STMP: %12"PRIu64" ticks | delta_t: %5"PRId64" | bufferfill: %5d\n", m_last_timestamp, now_t-last_t, m_data_buffer->getBufferFill());*/ } @@ -378,4 +378,5 @@ sample_int |= 0x01000000; // flag that there is a midi event present *buffer = sample_int; + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "(%p) MIDI [%d]: %08X\n", this, i, sample_int); } else if(IEC61883_AM824_HAS_LABEL(sample_int, IEC61883_AM824_LABEL_MIDI_2X) || IEC61883_AM824_HAS_LABEL(sample_int, IEC61883_AM824_LABEL_MIDI_3X) ) { Index: /trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h =================================================================== --- /trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h (revision 1531) +++ /trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h (revision 1763) @@ -30,28 +30,5 @@ #include "config.h" -#include "debugmodule/debugmodule.h" - -#include "../generic/StreamProcessor.h" -#include "../util/cip.h" - -#include -#include - -#define AMDTP_MAX_PACKET_SIZE 2048 - -#define IEC61883_STREAM_TYPE_MIDI 0x0D -#define IEC61883_STREAM_TYPE_SPDIF 0x00 -#define IEC61883_STREAM_TYPE_MBLA 0x06 - -#define IEC61883_AM824_LABEL_MASK 0xFF000000 -#define IEC61883_AM824_GET_LABEL(x) (((x) & 0xFF000000) >> 24) -#define IEC61883_AM824_SET_LABEL(x,y) ((x) | ((y)<<24)) - -#define IEC61883_AM824_LABEL_MIDI_NO_DATA 0x80 -#define IEC61883_AM824_LABEL_MIDI_1X 0x81 -#define IEC61883_AM824_LABEL_MIDI_2X 0x82 -#define IEC61883_AM824_LABEL_MIDI_3X 0x83 - -#define IEC61883_AM824_HAS_LABEL(x, lbl) (((x) & 0xFF000000) == (((quadlet_t)(lbl))<<24)) +#include "AmdtpStreamProcessor-common.h" namespace Streaming { Index: /trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h =================================================================== --- /trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h (revision 1535) +++ /trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h (revision 1763) @@ -29,28 +29,5 @@ */ -#include "debugmodule/debugmodule.h" - -#include "../generic/StreamProcessor.h" -#include "../util/cip.h" - -#include -#include - -#define AMDTP_MAX_PACKET_SIZE 2048 - -#define IEC61883_STREAM_TYPE_MIDI 0x0D -#define IEC61883_STREAM_TYPE_SPDIF 0x00 -#define IEC61883_STREAM_TYPE_MBLA 0x06 - -#define IEC61883_AM824_LABEL_MASK 0xFF000000 -#define IEC61883_AM824_GET_LABEL(x) (((x) & 0xFF000000) >> 24) -#define IEC61883_AM824_SET_LABEL(x,y) ((x) | ((y)<<24)) - -#define IEC61883_AM824_LABEL_MIDI_NO_DATA 0x80 -#define IEC61883_AM824_LABEL_MIDI_1X 0x81 -#define IEC61883_AM824_LABEL_MIDI_2X 0x82 -#define IEC61883_AM824_LABEL_MIDI_3X 0x83 - -#define IEC61883_AM824_HAS_LABEL(x, lbl) (((x) & 0xFF000000) == (((quadlet_t)(lbl))<<24)) +#include "AmdtpStreamProcessor-common.h" namespace Streaming { Index: /trunk/libffado/src/libstreaming/amdtp/AmdtpStreamProcessor-common.h =================================================================== --- /trunk/libffado/src/libstreaming/amdtp/AmdtpStreamProcessor-common.h (revision 1763) +++ /trunk/libffado/src/libstreaming/amdtp/AmdtpStreamProcessor-common.h (revision 1763) @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2005-2009 by Pieter Palmers et. al. + * Copyright (C) 2009 by Adrian Knoth + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#ifndef __FFADO_AMDTPTRANSMITSTREAMPROCESSOR_COMMON__ +#define __FFADO_AMDTPTRANSMITSTREAMPROCESSOR_COMMON__ + +#include "config.h" + +#include "debugmodule/debugmodule.h" + +#include "../generic/StreamProcessor.h" +#include "../util/cip.h" + +#include +#include + +#define AMDTP_MAX_PACKET_SIZE 2048 + +#define IEC61883_STREAM_TYPE_MIDI 0x0D +#define IEC61883_STREAM_TYPE_SPDIF 0x00 +#define IEC61883_STREAM_TYPE_MBLA 0x06 + +#define IEC61883_AM824_LABEL_MASK 0xFF000000 +#define IEC61883_AM824_GET_LABEL(x) (((x) & 0xFF000000) >> 24) +#define IEC61883_AM824_SET_LABEL(x,y) ((x) | ((y)<<24)) + +#define IEC61883_AM824_LABEL_MIDI_NO_DATA 0x80 +#define IEC61883_AM824_LABEL_MIDI_1X 0x81 +#define IEC61883_AM824_LABEL_MIDI_2X 0x82 +#define IEC61883_AM824_LABEL_MIDI_3X 0x83 + +#define IEC61883_AM824_HAS_LABEL(x, lbl) (((x) & 0xFF000000) == (((quadlet_t)(lbl))<<24)) +#endif /* __FFADO_AMDTPTRANSMITSTREAMPROCESSOR_COMMON__ */ Index: /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp =================================================================== --- /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (revision 1531) +++ /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (revision 1763) @@ -53,4 +53,5 @@ , m_nb_buffers( 0 ) , m_period( 0 ) + , m_sync_delay( 0 ) , m_audio_datatype( eADT_Float ) , m_nominal_framerate ( 0 ) @@ -77,4 +78,5 @@ , m_nb_buffers(nb_buffers) , m_period(period) + , m_sync_delay( 0 ) , m_audio_datatype( eADT_Float ) , m_nominal_framerate ( framerate ) @@ -191,12 +193,14 @@ debugError("(%p) sem_[timed]wait error (result=%d errno=EINVAL)\n", this, result); - debugError("(%p) timeout_nsec=%lld ts.sec=%d ts.nsec=%lld\n", - this, m_activity_wait_timeout_nsec, ts.tv_sec, ts.tv_nsec); + debugError("(%p) timeout_nsec=%"PRId64" ts.sec=%"PRId64" ts.nsec=%"PRId64"\n", + this, m_activity_wait_timeout_nsec, + (int64_t)ts.tv_sec, (int64_t)ts.tv_nsec); return eAR_Error; } else { debugError("(%p) sem_[timed]wait error (result=%d errno=%d)\n", this, result, errno); - debugError("(%p) timeout_nsec=%lld ts.sec=%d ts.nsec=%lld\n", - this, m_activity_wait_timeout_nsec, ts.tv_sec, ts.tv_nsec); + debugError("(%p) timeout_nsec=%"PRId64" ts.sec=%"PRId64" ts.nsec=%"PRId64"\n", + this, m_activity_wait_timeout_nsec, + (int64_t)ts.tv_sec, (int64_t)ts.tv_nsec); return eAR_Error; } @@ -472,4 +476,5 @@ // get the options int signal_delay_ticks = STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS; + int xmit_prebuffer_frames = STREAMPROCESSORMANAGER_XMIT_PREBUFFER_FRAMES; int sync_wait_time_msec = STREAMPROCESSORMANAGER_SYNC_WAIT_TIME_MSEC; int cycles_for_startup = STREAMPROCESSORMANAGER_CYCLES_FOR_STARTUP; @@ -478,4 +483,5 @@ Util::Configuration &config = m_parent.getConfiguration(); config.getValueForSetting("streaming.spm.signal_delay_ticks", signal_delay_ticks); + config.getValueForSetting("streaming.spm.xmit_prebuffer_frames", xmit_prebuffer_frames); config.getValueForSetting("streaming.spm.sync_wait_time_msec", sync_wait_time_msec); config.getValueForSetting("streaming.spm.cycles_for_startup", cycles_for_startup); @@ -514,16 +520,5 @@ // at which the buffer is transfer()'ed. This makes things somewhat // more robust. - max_of_min_delay += signal_delay_ticks; - - // Note that the equivalent number of frames is added to the - // transmit buffer to ensure that it keeps a good buffer fill, no matter - // what the sync delay is. - m_SyncSource->setSyncDelay(max_of_min_delay); - unsigned int syncdelay = m_SyncSource->getSyncDelay(); - debugOutput( DEBUG_LEVEL_VERBOSE, " sync delay = %d => %d ticks (%03us %04uc %04ut)...\n", - max_of_min_delay, syncdelay, - (unsigned int)TICKS_TO_SECS(syncdelay), - (unsigned int)TICKS_TO_CYCLES(syncdelay), - (unsigned int)TICKS_TO_OFFSET(syncdelay)); + m_sync_delay = max_of_min_delay + signal_delay_ticks; //STEP X: when we implement such a function, we can wait for a signal from the devices that they @@ -540,13 +535,23 @@ nb_sync_runs /= getPeriodSize(); - int64_t time_till_next_period; while(nb_sync_runs--) { // or while not sync-ed? // check if we were woken up too soon - time_till_next_period = m_SyncSource->getTimeUntilNextPeriodSignalUsecs(); - debugOutput( DEBUG_LEVEL_VERBOSE, "waiting for %d usecs...\n", time_till_next_period); - if(time_till_next_period > 0) { - // wait for the period - SleepRelativeUsec(time_till_next_period); - } + uint64_t ticks_at_period = m_SyncSource->getTimeAtPeriod(); + uint64_t ticks_at_period_margin = ticks_at_period + m_sync_delay; + uint64_t pred_system_time_at_xfer = m_SyncSource->getParent().get1394Service().getSystemTimeForCycleTimerTicks(ticks_at_period_margin); + + #ifdef DEBUG + int64_t now = Util::SystemTimeSource::getCurrentTime(); + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "CTR pred: %"PRId64", syncdelay: %"PRId64", diff: %"PRId64"\n", ticks_at_period, ticks_at_period_margin, ticks_at_period_margin-ticks_at_period ); + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "PREWAIT pred: %"PRId64", now: %"PRId64", wait: %"PRId64"\n", pred_system_time_at_xfer, now, pred_system_time_at_xfer-now ); + #endif + + // wait until it's time to transfer + Util::SystemTimeSource::SleepUsecAbsolute(pred_system_time_at_xfer); + + #ifdef DEBUG + now = Util::SystemTimeSource::getCurrentTime(); + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "POSTWAIT pred: %"PRId64", now: %"PRId64", excess: %"PRId64"\n", pred_system_time_at_xfer, now, now-pred_system_time_at_xfer ); + #endif } @@ -564,17 +569,9 @@ debugOutput( DEBUG_LEVEL_VERBOSE, " sync source frame rate: %f fps (%f tpf)\n", syncrate, tpf); - m_SyncSource->setSyncDelay(max_of_min_delay); - syncdelay = m_SyncSource->getSyncDelay(); - debugOutput( DEBUG_LEVEL_VERBOSE, " updated sync delay = %d => %d ticks (%f frames) (%03us %04uc %04ut)...\n", - max_of_min_delay, syncdelay, syncdelay/tpf, - (unsigned int)TICKS_TO_SECS(syncdelay), - (unsigned int)TICKS_TO_CYCLES(syncdelay), - (unsigned int)TICKS_TO_OFFSET(syncdelay)); - // we now should have decent sync info on the sync source // determine a point in time where the system should start // figure out where we are now uint64_t time_of_first_sample = m_SyncSource->getTimeAtPeriod(); - debugOutput( DEBUG_LEVEL_VERBOSE, " sync at TS=%011llu (%03us %04uc %04ut)...\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " sync at TS=%011"PRIu64" (%03us %04uc %04ut)...\n", time_of_first_sample, (unsigned int)TICKS_TO_SECS(time_of_first_sample), @@ -593,8 +590,8 @@ time_of_first_sample = addTicks(time_of_first_sample, time_for_startup_ticks); - debugOutput( DEBUG_LEVEL_VERBOSE, " add %d frames (%011llu ticks)...\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " add %d frames (%011"PRIu64" ticks)...\n", time_for_startup_frames, time_for_startup_ticks); - debugOutput( DEBUG_LEVEL_VERBOSE, " => first sample at TS=%011llu (%03us %04uc %04ut)...\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " => first sample at TS=%011"PRIu64" (%03us %04uc %04ut)...\n", time_of_first_sample, (unsigned int)TICKS_TO_SECS(time_of_first_sample), @@ -609,14 +606,47 @@ uint64_t time_to_start_recv = substractTicks(time_of_first_sample, prestart_cycles_for_recv * TICKS_PER_CYCLE); - debugOutput( DEBUG_LEVEL_VERBOSE, " => xmit starts at TS=%011llu (%03us %04uc %04ut)...\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " => xmit starts at TS=%011"PRIu64" (%03us %04uc %04ut)...\n", time_to_start_xmit, (unsigned int)TICKS_TO_SECS(time_to_start_xmit), (unsigned int)TICKS_TO_CYCLES(time_to_start_xmit), (unsigned int)TICKS_TO_OFFSET(time_to_start_xmit)); - debugOutput( DEBUG_LEVEL_VERBOSE, " => recv starts at TS=%011llu (%03us %04uc %04ut)...\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " => recv starts at TS=%011"PRIu64" (%03us %04uc %04ut)...\n", time_to_start_recv, (unsigned int)TICKS_TO_SECS(time_to_start_recv), (unsigned int)TICKS_TO_CYCLES(time_to_start_recv), (unsigned int)TICKS_TO_OFFSET(time_to_start_recv)); + + // print the sync delay + int sync_delay_frames = (int)((float)m_sync_delay / m_SyncSource->getTicksPerFrame()); + debugOutput( DEBUG_LEVEL_VERBOSE, " sync delay: %d = %d + %d ticks (%03us %04uc %04ut) [%d frames]...\n", + m_sync_delay, max_of_min_delay, signal_delay_ticks, + (unsigned int)TICKS_TO_SECS(m_sync_delay), + (unsigned int)TICKS_TO_CYCLES(m_sync_delay), + (unsigned int)TICKS_TO_OFFSET(m_sync_delay), + sync_delay_frames); + + // the amount of prebuffer frames should be a multiple of the common block size + // as otherwise the position of MIDI is messed up + if(xmit_prebuffer_frames % max_packet_size_frames) { + int tmp = 0; + while(tmp < xmit_prebuffer_frames) { + tmp += max_packet_size_frames; + } + debugOutput(DEBUG_LEVEL_VERBOSE, + "The number of prebuffer frames (%d) is not a multiple of the common block size (%d), increased to %d...\n", + xmit_prebuffer_frames, max_packet_size_frames, tmp); + xmit_prebuffer_frames = tmp; + } + + // check if this can even work. + // the worst case point where we can receive a period is at 1 period + sync delay + // this means that the number of frames in the xmit buffer has to be at least + // 1 period + sync delay + if(xmit_prebuffer_frames + m_period * m_nb_buffers < m_period + sync_delay_frames) { + debugWarning("The amount of transmit buffer frames (%d) is too small (< %d). " + "This will most likely cause xruns.\n", + xmit_prebuffer_frames + m_period * m_nb_buffers, + m_period + sync_delay_frames); + } // at this point the buffer head timestamp of the transmit buffers can be set @@ -625,10 +655,30 @@ it != m_TransmitProcessors.end(); ++it ) { + // set the number of prebuffer frames + (*it)->setExtraBufferFrames(xmit_prebuffer_frames); + + // set the TSP of the first sample in the buffer (*it)->setBufferHeadTimestamp(time_of_first_sample); ffado_timestamp_t ts; signed int fc; (*it)->getBufferHeadTimestamp ( &ts, &fc ); - debugOutput( DEBUG_LEVEL_VERBOSE, " transmit buffer tail %010lld => head TS %010lld, fc=%d...\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " transmit buffer tail %010"PRId64" => head TS %010"PRIu64", fc=%d...\n", time_of_first_sample, (uint64_t)ts, fc); + } + + // the receive processors can be delayed by sync_delay ticks + // this means that in the worst case we have to be able to accomodate + // an extra sync_delay ticks worth of frames in the receive SP buffer + // the sync delay should be rounded to an integer amount of max_packet_size + int tmp = sync_delay_frames / max_packet_size_frames; + tmp = tmp + 1; + sync_delay_frames = tmp * max_packet_size_frames; + if (sync_delay_frames < 1024) sync_delay_frames = 1024; //HACK + + for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); + it != m_ReceiveProcessors.end(); + ++it ) { + // set the number of extra buffer frames + (*it)->setExtraBufferFrames(sync_delay_frames); } @@ -643,5 +693,5 @@ } if(!m_SyncSource->scheduleStartRunning(time_to_start_sync)) { - debugError("m_SyncSource->scheduleStartRunning(%11llu) failed\n", time_to_start_sync); + debugError("m_SyncSource->scheduleStartRunning(%11"PRIu64") failed\n", time_to_start_sync); return false; } @@ -653,5 +703,5 @@ if(*it != m_SyncSource) { if(!(*it)->scheduleStartRunning(time_to_start_recv)) { - debugError("%p->scheduleStartRunning(%11llu) failed\n", *it, time_to_start_recv); + debugError("%p->scheduleStartRunning(%11"PRIu64") failed\n", *it, time_to_start_recv); return false; } @@ -663,5 +713,5 @@ if(*it != m_SyncSource) { if(!(*it)->scheduleStartRunning(time_to_start_xmit)) { - debugError("%p->scheduleStartRunning(%11llu) failed\n", *it, time_to_start_xmit); + debugError("%p->scheduleStartRunning(%11"PRIu64") failed\n", *it, time_to_start_xmit); return false; } @@ -696,11 +746,10 @@ #endif - debugOutput( DEBUG_LEVEL_VERBOSE, " initial time of transfer %010lld, rate %f...\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " initial time of transfer %010"PRId64", rate %f...\n", m_time_of_transfer, rate); - int64_t delay_in_ticks = (int64_t)(((float)((m_nb_buffers-1) * m_period)) * rate); - // also add the sync delay - delay_in_ticks = addTicks(delay_in_ticks, m_SyncSource->getSyncDelay()); - + // FIXME: ideally we'd want the SP itself to account for the xmit_prebuffer_frames + // but that would also require to use a different approach to setting the initial TSP's + int64_t delay_in_ticks = (int64_t)(((float)((m_nb_buffers-1) * m_period + xmit_prebuffer_frames)) * rate); // then use this information to initialize the xmit handlers @@ -709,11 +758,12 @@ // to the period transfer time instant plus what's nb_buffers - 1 // in ticks. This due to the fact that we (should) have received one period - // worth of ticks at t=m_time_of_transfer + // worth of ticks at t = m_time_of_transfer // hence one period of frames should also have been transmitted, which means // that there should be (nb_buffers - 1) * periodsize of frames in the xmit buffer + // there are also xmit_prebuffer_frames frames extra present in the buffer // that allows us to calculate the tail timestamp for the buffer. int64_t transmit_tail_timestamp = addTicks(m_time_of_transfer, delay_in_ticks); - debugOutput( DEBUG_LEVEL_VERBOSE, " preset transmit tail TS %010lld, rate %f...\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " preset transmit tail TS %010"PRId64", rate %f...\n", transmit_tail_timestamp, rate); @@ -726,5 +776,5 @@ signed int fc; (*it)->getBufferHeadTimestamp ( &ts, &fc ); - debugOutput( DEBUG_LEVEL_VERBOSE, " => transmit head TS %010lld, fc=%d...\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " => transmit head TS %010"PRId64", fc=%d...\n", (uint64_t)ts, fc); } @@ -783,5 +833,5 @@ StreamProcessor *s = m_ReceiveProcessors.at(i); diff = diffTicks(m_SyncSource->getTimeAtPeriod(), s->getTimeAtPeriod()); - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " offset between SyncSP %p and SP %p is %lld ticks...\n", + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " offset between SyncSP %p and SP %p is %"PRId64" ticks...\n", m_SyncSource, s, diff); if ( nb_sync_runs == periods_per_align_try ) { @@ -805,5 +855,5 @@ diff_between_streams[i] /= periods_per_align_try; diff_between_streams_frames[i] = (int)roundf(diff_between_streams[i] / s->getTicksPerFrame()); - debugOutput( DEBUG_LEVEL_VERBOSE, " avg offset between SyncSP %p and SP %p is %lld ticks, %d frames...\n", + debugOutput( DEBUG_LEVEL_VERBOSE, " avg offset between SyncSP %p and SP %p is %"PRId64" ticks, %d frames...\n", m_SyncSource, s, diff_between_streams[i], diff_between_streams_frames[i]); @@ -1078,10 +1128,11 @@ m_SyncSource->getBufferFill()); uint64_t ticks_at_period = m_SyncSource->getTimeAtPeriod(); - uint64_t ticks_at_period_margin = ticks_at_period + m_SyncSource->getSyncDelay(); + uint64_t ticks_at_period_margin = ticks_at_period + m_sync_delay; uint64_t pred_system_time_at_xfer = m_SyncSource->getParent().get1394Service().getSystemTimeForCycleTimerTicks(ticks_at_period_margin); #ifdef DEBUG int64_t now = Util::SystemTimeSource::getCurrentTime(); - debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "pred: %lld, now: %lld, wait: %lld\n", pred_system_time_at_xfer, now, pred_system_time_at_xfer-now ); + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "CTR pred: %"PRId64", syncdelay: %"PRId64", diff: %"PRId64"\n", ticks_at_period, ticks_at_period_margin, ticks_at_period_margin-ticks_at_period ); + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "PREWAIT pred: %"PRId64", now: %"PRId64", wait: %"PRId64"\n", pred_system_time_at_xfer, now, pred_system_time_at_xfer-now ); #endif @@ -1091,8 +1142,35 @@ #ifdef DEBUG now = Util::SystemTimeSource::getCurrentTime(); - debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "pred: %lld now: %lld, excess: %lld\n", pred_system_time_at_xfer, now, now-pred_system_time_at_xfer ); + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "POSTWAIT pred: %"PRId64", now: %"PRId64", excess: %"PRId64"\n", pred_system_time_at_xfer, now, now-pred_system_time_at_xfer ); #endif // the period should be ready now + #ifdef DEBUG + int rcv_fills[10]; + int xmt_fills[10]; + int i; + i=0; + for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); + it != m_ReceiveProcessors.end(); + ++it ) { + rcv_fills[i] = (*it)->getBufferFill(); + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "RECV SP %p bufferfill: %05d\n", *it, rcv_fills[i]); + i++; + } + i=0; + for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); + it != m_TransmitProcessors.end(); + ++it ) { + xmt_fills[i] = (*it)->getBufferFill(); + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "XMIT SP %p bufferfill: %05d\n", *it, xmt_fills[i]); + i++; + } + for(i=0;i<1;i++) { + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "SP %02d RECV: %05d [%05d] XMIT: %05d [%05d] DIFF: %05d\n", i, + rcv_fills[i], rcv_fills[i] - m_period, + xmt_fills[i], xmt_fills[i] - m_period, + rcv_fills[i] - xmt_fills[i]); + } + #endif #if STREAMPROCESSORMANAGER_ALLOW_DELAYED_PERIOD_SIGNAL @@ -1194,5 +1272,5 @@ // so 50 ticks = 10%, which is a rather large jitter value. if(diff-ticks_per_period > 50 || diff-ticks_per_period < -50) { - debugOutput(DEBUG_LEVEL_VERBOSE, "rather large TSP difference TS=%011llu => TS=%011llu (%d, nom %d)\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "rather large TSP difference TS=%011"PRIu64" => TS=%011"PRIu64" (%d, nom %d)\n", m_time_of_transfer2, m_time_of_transfer, diff, ticks_per_period); } @@ -1201,14 +1279,8 @@ debugOutputExtreme(DEBUG_LEVEL_VERBOSE, - "transfer period %d at %llu ticks...\n", + "transfer period %d at %"PRIu64" ticks...\n", m_nbperiods, m_time_of_transfer); - // this is to notify the client of the delay that we introduced by waiting - m_delayed_usecs = - m_SyncSource->getTimeUntilNextPeriodSignalUsecs(); - debugOutputExtreme(DEBUG_LEVEL_VERBOSE, - "delayed for %d usecs...\n", - m_delayed_usecs); - -#ifdef DEBUG + #ifdef DEBUG int rcv_bf=0, xmt_bf=0; for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); @@ -1223,5 +1295,5 @@ } debugOutputExtreme( DEBUG_LEVEL_VERY_VERBOSE, - "XF at %011llu ticks, RBF=%d, XBF=%d, SUM=%d...\n", + "XF at %011"PRIu64" ticks, RBF=%d, XBF=%d, SUM=%d...\n", m_time_of_transfer, rcv_bf, xmt_bf, rcv_bf+xmt_bf); @@ -1255,6 +1327,15 @@ } } -#endif + #endif m_nbperiods++; + + // this is to notify the client of the delay that we introduced by waiting + pred_system_time_at_xfer = m_SyncSource->getParent().get1394Service().getSystemTimeForCycleTimerTicks(m_time_of_transfer); + + m_delayed_usecs = Util::SystemTimeSource::getCurrentTime() - pred_system_time_at_xfer; + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, + "delayed for %d usecs...\n", + m_delayed_usecs); + // now we can signal the client that we are (should be) ready return !xrun_occurred; @@ -1287,5 +1368,5 @@ if(m_SyncSource == NULL) return false; debugOutputExtreme( DEBUG_LEVEL_VERY_VERBOSE, - "transfer(%d) at TS=%011llu (%03us %04uc %04ut)...\n", + "transfer(%d) at TS=%011"PRIu64" (%03us %04uc %04ut)...\n", t, m_time_of_transfer, (unsigned int)TICKS_TO_SECS(m_time_of_transfer), @@ -1301,5 +1382,5 @@ ++it ) { if(!(*it)->getFrames(m_period, m_time_of_transfer)) { - debugWarning("could not getFrames(%u, %11llu) from stream processor (%p)\n", + debugWarning("could not getFrames(%u, %11"PRIu64") from stream processor (%p)\n", m_period, m_time_of_transfer,*it); retval &= false; // buffer underrun @@ -1310,21 +1391,19 @@ // 1394 time float rate = m_SyncSource->getTicksPerFrame(); - int64_t one_ringbuffer_in_ticks=(int64_t)(((float)((m_nb_buffers * m_period))) * rate); - - // the data we are putting into the buffer is intended to be transmitted - // one ringbuffer size after it has been received - - // we also add one syncdelay as a safety margin, since that's the amount of time we can get - // postponed. - int syncdelay = m_SyncSource->getSyncDelay(); - int64_t transmit_timestamp = addTicks(m_time_of_transfer, one_ringbuffer_in_ticks + syncdelay); for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); it != m_TransmitProcessors.end(); ++it ) { - // FIXME: in the SPM it would be nice to have system time instead of - // 1394 time + // this is the delay in frames between the point where a frame is received and + // when it is transmitted again + unsigned int one_ringbuffer_in_frames = m_nb_buffers * m_period + (*it)->getExtraBufferFrames(); + int64_t one_ringbuffer_in_ticks = (int64_t)(((float)one_ringbuffer_in_frames) * rate); + + // the data we are putting into the buffer is intended to be transmitted + // one ringbuffer size after it has been received + int64_t transmit_timestamp = addTicks(m_time_of_transfer, one_ringbuffer_in_ticks); + if(!(*it)->putFrames(m_period, transmit_timestamp)) { - debugWarning("could not putFrames(%u,%llu) to stream processor (%p)\n", + debugWarning("could not putFrames(%u,%"PRIu64") to stream processor (%p)\n", m_period, transmit_timestamp, *it); retval &= false; // buffer underrun @@ -1367,5 +1446,5 @@ if(m_SyncSource == NULL) return false; debugOutput( DEBUG_LEVEL_VERY_VERBOSE, - "transferSilence(%d) at TS=%011llu (%03us %04uc %04ut)...\n", + "transferSilence(%d) at TS=%011"PRIu64" (%03us %04uc %04ut)...\n", t, m_time_of_transfer, (unsigned int)TICKS_TO_SECS(m_time_of_transfer), @@ -1381,5 +1460,5 @@ ++it ) { if(!(*it)->dropFrames(m_period, m_time_of_transfer)) { - debugWarning("could not dropFrames(%u, %11llu) from stream processor (%p)\n", + debugWarning("could not dropFrames(%u, %11"PRIu64") from stream processor (%p)\n", m_period, m_time_of_transfer,*it); retval &= false; // buffer underrun @@ -1390,20 +1469,19 @@ // 1394 time float rate = m_SyncSource->getTicksPerFrame(); - int64_t one_ringbuffer_in_ticks=(int64_t)(((float)(m_nb_buffers * m_period)) * rate); - - // the data we are putting into the buffer is intended to be transmitted - // one ringbuffer size after it has been received - // we also add one syncdelay as a safety margin, since that's the amount of time we can get - // postponed. - int syncdelay = m_SyncSource->getSyncDelay(); - int64_t transmit_timestamp = addTicks(m_time_of_transfer, one_ringbuffer_in_ticks + syncdelay); for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); it != m_TransmitProcessors.end(); ++it ) { - // FIXME: in the SPM it would be nice to have system time instead of - // 1394 time + // this is the delay in frames between the point where a frame is received and + // when it is transmitted again + unsigned int one_ringbuffer_in_frames = m_nb_buffers * m_period + (*it)->getExtraBufferFrames(); + int64_t one_ringbuffer_in_ticks = (int64_t)(((float)one_ringbuffer_in_frames) * rate); + + // the data we are putting into the buffer is intended to be transmitted + // one ringbuffer size after it has been received + int64_t transmit_timestamp = addTicks(m_time_of_transfer, one_ringbuffer_in_ticks); + if(!(*it)->putSilenceFrames(m_period, transmit_timestamp)) { - debugWarning("could not putSilenceFrames(%u,%llu) to stream processor (%p)\n", + debugWarning("could not putSilenceFrames(%u,%"PRIu64") to stream processor (%p)\n", m_period, transmit_timestamp, *it); retval &= false; // buffer underrun @@ -1578,5 +1656,5 @@ #ifdef DEBUG if(idx >= (int)m_CapturePorts_shadow.size()) { - debugError("Capture port %d out of range (%d)\n", idx, m_CapturePorts_shadow.size()); + debugError("Capture port %d out of range (%zd)\n", idx, m_CapturePorts_shadow.size()); return NULL; } @@ -1586,5 +1664,5 @@ #ifdef DEBUG if(idx >= (int)m_PlaybackPorts_shadow.size()) { - debugError("Playback port %d out of range (%d)\n", idx, m_PlaybackPorts_shadow.size()); + debugError("Playback port %d out of range (%zd)\n", idx, m_PlaybackPorts_shadow.size()); return NULL; } Index: /trunk/libffado/src/libstreaming/StreamProcessorManager.h =================================================================== --- /trunk/libffado/src/libstreaming/StreamProcessorManager.h (revision 1531) +++ /trunk/libffado/src/libstreaming/StreamProcessorManager.h (revision 1763) @@ -190,4 +190,5 @@ unsigned int m_nb_buffers; unsigned int m_period; + unsigned int m_sync_delay; enum eADT_AudioDataType m_audio_datatype; unsigned int m_nominal_framerate; Index: /trunk/libffado/src/libstreaming/generic/StreamProcessor.h =================================================================== --- /trunk/libffado/src/libstreaming/generic/StreamProcessor.h (revision 1531) +++ /trunk/libffado/src/libstreaming/generic/StreamProcessor.h (revision 1763) @@ -298,13 +298,9 @@ //--- data buffering and accounting public: - void getBufferHeadTimestamp ( ffado_timestamp_t *ts, signed int *fc ) - {m_data_buffer->getBufferHeadTimestamp(ts, fc);}; - void getBufferTailTimestamp ( ffado_timestamp_t *ts, signed int *fc ) - {m_data_buffer->getBufferTailTimestamp(ts, fc);}; - - void setBufferTailTimestamp ( ffado_timestamp_t new_timestamp ) - {m_data_buffer->setBufferTailTimestamp(new_timestamp);}; - void setBufferHeadTimestamp ( ffado_timestamp_t new_timestamp ) - {m_data_buffer->setBufferHeadTimestamp(new_timestamp);}; + void getBufferHeadTimestamp ( ffado_timestamp_t *ts, signed int *fc ); + void getBufferTailTimestamp ( ffado_timestamp_t *ts, signed int *fc ); + + void setBufferTailTimestamp ( ffado_timestamp_t new_timestamp ); + void setBufferHeadTimestamp ( ffado_timestamp_t new_timestamp ); protected: Util::TimestampedBuffer *m_data_buffer; @@ -332,55 +328,30 @@ /** - * \brief return the time until the next period boundary should be signaled (in microseconds) - * - * Return the time until the next period boundary signal. If this StreamProcessor - * is the current synchronization source, this function is called to - * determine when a buffer transfer can be made. When this value is - * smaller than 0, a period boundary is assumed to be crossed, hence a - * transfer can be made. - * - * \return the time in usecs - */ - int64_t getTimeUntilNextPeriodSignalUsecs(); - /** - * \brief return the time of the next period boundary (in microseconds) - * - * Returns the time of the next period boundary, in microseconds. The - * goal of this function is to determine the exact point of the period + * \brief return the time of the next period boundary (in internal units) + * + * Returns the time of the next period boundary, in internal units, i.e. + * in ticks of the 1394 clock of the bus the device is attached to. + * The goal of this function is to determine the exact point of the period * boundary. This is assumed to be the point at which the buffer transfer should * take place, meaning that it can be used as a reference timestamp for transmitting * StreamProcessors * - * \return the time in usecs - */ - uint64_t getTimeAtPeriodUsecs(); - - /** - * \brief return the time of the next period boundary (in internal units) - * - * The same as getTimeAtPeriodUsecs() but in internal units. - * * @return the time in internal units */ uint64_t getTimeAtPeriod(); - uint64_t getTimeNow(); // FIXME: should disappear - - - /** - * Returns the sync delay. This is the time a syncsource - * delays a period signal, e.g. to cope with buffering. - * @return the sync delay (in ticks) - */ - unsigned int getSyncDelay(); - unsigned int getSyncDelayFrames(); - /** - * sets the sync delay - * - * note: will be rounded to an integer number of packets - * - * @param d sync delay - */ - void setSyncDelay(unsigned int ticks); + /** + * For RECEIVE: + * this is the extra amount of space in the receive buffer + * + * For XMIT: + * Sets the number of frames that should be prebuffered + * into the ISO transmit buffers. A higher number here means + * more reliable operation. It also means higher latency + * + * @param frames + */ + void setExtraBufferFrames(unsigned int frames); + unsigned int getExtraBufferFrames(); /** @@ -453,5 +424,5 @@ float m_ticks_per_frame; float m_dll_bandwidth_hz; - unsigned int m_sync_delay_frames; + unsigned int m_extra_buffer_frames; private: bool m_in_xrun; Index: /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp =================================================================== --- /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (revision 1535) +++ /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (revision 1763) @@ -77,5 +77,5 @@ , m_ticks_per_frame( 0 ) , m_dll_bandwidth_hz ( STREAMPROCESSOR_DLL_BW_HZ ) - , m_sync_delay_frames( 0 ) + , m_extra_buffer_frames( 0 ) , m_in_xrun( false ) { @@ -130,8 +130,4 @@ m_in_xrun = true; SIGNAL_ACTIVITY_ALL; -} - -uint64_t StreamProcessor::getTimeNow() { - return m_1394service.getCycleTimerTicks(); } @@ -172,4 +168,26 @@ * Buffer management and manipulation * ***********************************************/ +void +StreamProcessor::getBufferHeadTimestamp(ffado_timestamp_t *ts, signed int *fc) +{ + m_data_buffer->getBufferHeadTimestamp(ts, fc); +} + +void +StreamProcessor::getBufferTailTimestamp(ffado_timestamp_t *ts, signed int *fc) +{ + m_data_buffer->getBufferTailTimestamp(ts, fc); +} + +void StreamProcessor::setBufferTailTimestamp(ffado_timestamp_t new_timestamp) +{ + m_data_buffer->setBufferTailTimestamp(new_timestamp); +} + +void +StreamProcessor::setBufferHeadTimestamp(ffado_timestamp_t new_timestamp) +{ + m_data_buffer->setBufferHeadTimestamp(new_timestamp); +} int StreamProcessor::getBufferFill() { @@ -177,69 +195,17 @@ } -int64_t -StreamProcessor::getTimeUntilNextPeriodSignalUsecs() -{ - uint64_t time_at_period=getTimeAtPeriod(); - - // we delay the period signal with the sync delay - // this makes that the period signals lag a little compared to reality - // ISO buffering causes the packets to be received at max - // m_handler->getWakeupInterval() later than the time they were received. - // hence their payload is available this amount of time later. However, the - // period boundary is predicted based upon earlier samples, and therefore can - // pass before these packets are processed. Adding this extra term makes that - // the period boundary is signalled later - time_at_period = addTicks(time_at_period, m_StreamProcessorManager.getSyncSource().getSyncDelay()); - - uint64_t cycle_timer=m_1394service.getCycleTimerTicks(); - - // calculate the time until the next period - int32_t until_next=diffTicks(time_at_period,cycle_timer); - - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> TAP=%11llu, CTR=%11llu, UTN=%11ld\n", - time_at_period, cycle_timer, until_next - ); - - // now convert to usecs - // don't use the mapping function because it only works - // for absolute times, not the relative time we are - // using here (which can also be negative). - return (int64_t)(((float)until_next) / TICKS_PER_USEC); -} - void -StreamProcessor::setSyncDelay(unsigned int ticks) { - - // round the sync delay to an integer number of packets now we know the frame rate - int frames = (int)((float)ticks / getTicksPerFrame()); - frames = (frames / getNominalFramesPerPacket()) + 1; - frames *= getNominalFramesPerPacket(); - - #ifdef DEBUG - float ticks2 = frames * getTicksPerFrame(); - debugOutput(DEBUG_LEVEL_VERBOSE, "Setting SP %p SyncDelay to %u ticks => rounded to %u frames, %f ticks\n", - this, ticks, frames, ticks2); - #endif - m_sync_delay_frames = frames; +StreamProcessor::setExtraBufferFrames(unsigned int frames) { + debugOutput(DEBUG_LEVEL_VERBOSE, "Setting extra buffer to %d frames\n", frames); + m_extra_buffer_frames = frames; } unsigned int -StreamProcessor::getSyncDelayFrames() { - return m_sync_delay_frames; -} - -unsigned int -StreamProcessor::getSyncDelay() { - return (unsigned int)(m_sync_delay_frames * getTicksPerFrame()); +StreamProcessor::getExtraBufferFrames() { + return m_extra_buffer_frames; } uint64_t -StreamProcessor::getTimeAtPeriodUsecs() -{ - return (uint64_t)((float)getTimeAtPeriod() * TICKS_PER_USEC); -} - -uint64_t -StreamProcessor::getTimeAtPeriod() +StreamProcessor::getTimeAtPeriod() { if (getType() == ePT_Receive) { @@ -412,5 +378,5 @@ if (m_last_timestamp > 0 && m_last_timestamp2 > 0) { int64_t tsp_diff = diffTicks(m_last_timestamp, m_last_timestamp2); - debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "TSP diff: %lld\n", tsp_diff); + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "TSP diff: %"PRId64"\n", tsp_diff); double tsp_diff_d = tsp_diff; double fs_syt = 1.0/tsp_diff_d; @@ -433,6 +399,6 @@ if(diff-ticks_per_packet > 50 || diff-ticks_per_packet < -50) { debugOutput(DEBUG_LEVEL_VERBOSE, - "cy %04u rather large TSP difference TS=%011llu => TS=%011llu (%d, nom %d)\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, + "cy %04d rather large TSP difference TS=%011"PRIu64" => TS=%011"PRIu64" (%d, nom %d)\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, m_last_timestamp, diff, ticks_per_packet); // !!!HACK!!! FIXME: this is the result of a failure in wrapping/unwrapping somewhere @@ -444,6 +410,6 @@ diff = diffTicks(last_timestamp_fixed, m_last_timestamp2); if(diff-ticks_per_packet < 50 && diff-ticks_per_packet > -50) { - debugWarning("cy %04u rather large TSP difference TS=%011llu => TS=%011llu (%d, nom %d)\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, + debugWarning("cy %04d rather large TSP difference TS=%011"PRIu64" => TS=%011"PRIu64" (%d, nom %d)\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, m_last_timestamp, diff, ticks_per_packet); debugWarning("HACK: fixed by adding one second of ticks. This is a bug being run-time fixed.\n"); @@ -454,6 +420,6 @@ diff = diffTicks(last_timestamp_fixed, m_last_timestamp2); if(diff-ticks_per_packet < 50 && diff-ticks_per_packet > -50) { - debugWarning("cy %04u rather large TSP difference TS=%011llu => TS=%011llu (%d, nom %d)\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, + debugWarning("cy %04d rather large TSP difference TS=%011"PRIu64" => TS=%011"PRIu64" (%d, nom %d)\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, m_last_timestamp, diff, ticks_per_packet); debugWarning("HACK: fixed by subtracing one second of ticks. This is a bug being run-time fixed.\n"); @@ -463,6 +429,6 @@ } debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "%04u %011llu %011llu %d %d\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), + "%04u %011"PRIu64" %011"PRIu64" %d %d\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, m_last_timestamp, diff, ticks_per_packet); @@ -471,6 +437,6 @@ debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "RECV: CY=%04u TS=%011llu\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), + "RECV: CY=%04u TS=%011"PRIu64"\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp); @@ -640,6 +606,6 @@ if (result == eCRV_Packet) { debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "XMIT SILENT: CY=%04u TS=%011llu\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp); + "XMIT SILENT: CY=%04u TS=%011"PRIu64"\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp); // assumed not to xrun @@ -691,6 +657,6 @@ if (result == eCRV_Packet || result == eCRV_Defer) { debugOutputExtreme(DEBUG_LEVEL_VERBOSE, - "XMIT: CY=%04u TS=%011llu\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp); + "XMIT: CY=%04u TS=%011"PRIu64"\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp); // valid packet timestamp @@ -728,5 +694,5 @@ if (m_last_timestamp > 0 && m_last_timestamp2 > 0) { int64_t tsp_diff = diffTicks(m_last_timestamp, m_last_timestamp2); - debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "TSP diff: %lld\n", tsp_diff); + debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "TSP diff: %"PRId64"\n", tsp_diff); double tsp_diff_d = tsp_diff; double fs_syt = 1.0/tsp_diff_d; @@ -737,5 +703,5 @@ debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "Nom fs: %12f, Instantanous fs: %12f, diff: %12f (%12f)\n", fs_nom, fs_syt, fs_diff, fs_diff_norm); -// debugOutput(DEBUG_LEVEL_VERBOSE, "Diff fs: %12f, m_last_timestamp: %011llu, m_last_timestamp2: %011llu\n", +// debugOutput(DEBUG_LEVEL_VERBOSE, "Diff fs: %12f, m_last_timestamp: %011"PRIu64", m_last_timestamp2: %011"PRIu64"\n", // fs_diff, m_last_timestamp, m_last_timestamp2); if (fs_diff_norm > 0.01 || fs_diff_norm < -0.01) { @@ -750,11 +716,11 @@ if(diff-ticks_per_packet > 50 || diff-ticks_per_packet < -50) { debugOutput(DEBUG_LEVEL_VERBOSE, - "cy %04d, rather large TSP difference TS=%011llu => TS=%011llu (%d, nom %d)\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, + "cy %04d, rather large TSP difference TS=%011"PRIu64" => TS=%011"PRIu64" (%d, nom %d)\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, m_last_timestamp, diff, ticks_per_packet); } debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "%04d %011llu %011llu %d %d\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, + "%04d %011"PRIu64" %011"PRIu64" %d %d\n", + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp2, m_last_timestamp, diff, ticks_per_packet); } @@ -791,5 +757,5 @@ goto send_empty_packet; } else if (result == eCRV_Again) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "have to retry cycle %d\n", CYCLE_TIMER_GET_CYCLES(pkt_ctr)); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "have to retry cycle %d\n", (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr)); if(m_state != m_next_state) { debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state from %s to %s\n", @@ -826,5 +792,5 @@ debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "XMIT EMPTY: CY=%04u\n", - CYCLE_TIMER_GET_CYCLES(pkt_ctr)); + (int)CYCLE_TIMER_GET_CYCLES(pkt_ctr)); generateEmptyPacketHeader(data, length, tag, sy, pkt_ctr); @@ -843,5 +809,5 @@ bool result; debugOutputExtreme( DEBUG_LEVEL_VERBOSE, - "(%p, %s) getFrames(%d, %11llu)\n", + "(%p, %s) getFrames(%d, %11"PRIu64")\n", this, getTypeString(), nbframes, ts); assert( getType() == ePT_Receive ); @@ -874,13 +840,13 @@ lag_frames = (((float)lag_ticks) / srate); debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "stream (%p): drifts %6d ticks = %10.5f frames (rate=%10.5f), %lld, %llu, %d\n", + "stream (%p): drifts %6d ticks = %10.5f frames (rate=%10.5f), %"PRId64", %"PRIu64", %d\n", this, lag_ticks, lag_frames, srate, ts, ts_expected, fc); if (lag_frames >= 1.0) { // the stream lags - debugOutput(DEBUG_LEVEL_VERBOSE, "stream (%p): lags with %6d ticks = %10.5f frames (rate=%10.5f), %lld, %llu, %d\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "stream (%p): lags with %6d ticks = %10.5f frames (rate=%10.5f), %"PRId64", %"PRIu64", %d\n", this, lag_ticks, lag_frames, srate, ts, ts_expected, fc); } else if (lag_frames <= -1.0) { // the stream leads - debugOutput(DEBUG_LEVEL_VERBOSE, "stream (%p): leads with %6d ticks = %10.5f frames (rate=%10.5f), %lld, %llu, %d\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "stream (%p): leads with %6d ticks = %10.5f frames (rate=%10.5f), %"PRId64", %"PRIu64", %d\n", this, lag_ticks, lag_frames, srate, ts, ts_expected, fc); } @@ -896,5 +862,5 @@ { debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, - "stream (%p): dry run %d frames (@ ts=%lld)\n", + "stream (%p): dry run %d frames (@ ts=%"PRId64")\n", this, nbframes, ts); // dry run on this side means that we put silence in all enabled ports @@ -907,5 +873,5 @@ { bool result; - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "StreamProcessor::dropFrames(%d, %lld)\n", nbframes, ts); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "StreamProcessor::dropFrames(%d, %"PRId64")\n", nbframes, ts); result = m_data_buffer->dropFrames(nbframes); SIGNAL_ACTIVITY_ISO_RECV; @@ -917,5 +883,5 @@ bool result; debugOutputExtreme( DEBUG_LEVEL_VERBOSE, - "(%p, %s) putFrames(%d, %11llu)\n", + "(%p, %s) putFrames(%d, %11"PRIu64")\n", this, getTypeString(), nbframes, ts); assert( getType() == ePT_Transmit ); @@ -930,10 +896,10 @@ { debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, - "StreamProcessor::putFramesWet(%d, %llu)\n", + "StreamProcessor::putFramesWet(%d, %"PRIu64")\n", nbframes, ts); // transfer the data m_data_buffer->blockProcessWriteFrames(nbframes, ts); debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, - " New timestamp: %llu\n", ts); + " New timestamp: %"PRIu64"\n", ts); return true; // FIXME: what about failure? } @@ -943,5 +909,5 @@ { debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, - "StreamProcessor::putFramesDry(%d, %llu)\n", + "StreamProcessor::putFramesDry(%d, %"PRIu64")\n", nbframes, ts); // do nothing @@ -953,5 +919,5 @@ { debugOutput(DEBUG_LEVEL_VERY_VERBOSE, - "StreamProcessor::putSilenceFrames(%d, %llu)\n", + "StreamProcessor::putSilenceFrames(%d, %"PRIu64")\n", nbframes, ts); @@ -1104,5 +1070,5 @@ // make the scratch buffer one period of frames long m_scratch_buffer_size_bytes = m_StreamProcessorManager.getPeriodSize() * getEventsPerFrame() * getEventSize(); - debugOutput( DEBUG_LEVEL_VERBOSE, " Allocate scratch buffer of %d quadlets\n"); + debugOutput( DEBUG_LEVEL_VERBOSE, " Allocate scratch buffer of %zd quadlets\n", m_scratch_buffer_size_bytes); if(m_scratch_buffer) delete[] m_scratch_buffer; m_scratch_buffer = new byte_t[m_scratch_buffer_size_bytes]; @@ -1193,10 +1159,10 @@ #ifdef DEBUG uint64_t now = m_1394service.getCycleTimerTicks(); - debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011llu (%03us %04uc %04ut)\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011"PRIu64" (%03us %04uc %04ut)\n", now, (unsigned int)TICKS_TO_SECS(now), (unsigned int)TICKS_TO_CYCLES(now), (unsigned int)TICKS_TO_OFFSET(now)); - debugOutput(DEBUG_LEVEL_VERBOSE," Start at : %011llu (%03us %04uc %04ut)\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Start at : %011"PRIu64" (%03us %04uc %04ut)\n", tx, (unsigned int)TICKS_TO_SECS(tx), @@ -1239,10 +1205,10 @@ #ifdef DEBUG uint64_t now = m_1394service.getCycleTimerTicks(); - debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011llu (%03us %04uc %04ut)\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011"PRIu64" (%03us %04uc %04ut)\n", now, (unsigned int)TICKS_TO_SECS(now), (unsigned int)TICKS_TO_CYCLES(now), (unsigned int)TICKS_TO_OFFSET(now)); - debugOutput(DEBUG_LEVEL_VERBOSE," Start at : %011llu (%03us %04uc %04ut)\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Start at : %011"PRIu64" (%03us %04uc %04ut)\n", tx, (unsigned int)TICKS_TO_SECS(tx), @@ -1263,10 +1229,10 @@ #ifdef DEBUG uint64_t now = m_1394service.getCycleTimerTicks(); - debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011llu (%03us %04uc %04ut)\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011"PRIu64" (%03us %04uc %04ut)\n", now, (unsigned int)TICKS_TO_SECS(now), (unsigned int)TICKS_TO_CYCLES(now), (unsigned int)TICKS_TO_OFFSET(now)); - debugOutput(DEBUG_LEVEL_VERBOSE," Stop at : %011llu (%03us %04uc %04ut)\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Stop at : %011"PRIu64" (%03us %04uc %04ut)\n", tx, (unsigned int)TICKS_TO_SECS(tx), @@ -1288,10 +1254,10 @@ #ifdef DEBUG uint64_t now = m_1394service.getCycleTimerTicks(); - debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011llu (%03us %04uc %04ut)\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Now : %011"PRIu64" (%03us %04uc %04ut)\n", now, (unsigned int)TICKS_TO_SECS(now), (unsigned int)TICKS_TO_CYCLES(now), (unsigned int)TICKS_TO_OFFSET(now)); - debugOutput(DEBUG_LEVEL_VERBOSE," Stop at : %011llu (%03us %04uc %04ut)\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Stop at : %011"PRIu64" (%03us %04uc %04ut)\n", tx, (unsigned int)TICKS_TO_SECS(tx), @@ -1384,6 +1350,10 @@ StreamProcessor::doStop() { + assert(m_data_buffer); + float ticks_per_frame; - unsigned int ringbuffer_size_frames = (m_StreamProcessorManager.getNbBuffers() + 1) * m_StreamProcessorManager.getPeriodSize(); + unsigned int ringbuffer_size_frames = m_StreamProcessorManager.getNbBuffers() * m_StreamProcessorManager.getPeriodSize(); + ringbuffer_size_frames += m_extra_buffer_frames; + ringbuffer_size_frames += 1; // to ensure that we can fit it all in there debugOutput(DEBUG_LEVEL_VERBOSE, "Enter from state: %s\n", ePSToString(m_state)); @@ -1392,6 +1362,4 @@ switch(m_state) { case ePS_Created: - assert(m_data_buffer); - // prepare the framerate estimate ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_StreamProcessorManager.getNominalRate()); @@ -1399,10 +1367,10 @@ m_local_node_id= m_1394service.getLocalNodeId() & 0x3f; m_correct_last_timestamp = false; - + debugOutput(DEBUG_LEVEL_VERBOSE, "Initializing remote ticks/frame to %f\n", ticks_per_frame); - + // initialize internal buffer result &= m_data_buffer->setBufferSize(ringbuffer_size_frames); - + result &= m_data_buffer->setEventSize( getEventSize() ); result &= m_data_buffer->setEventsPerFrame( getEventsPerFrame() ); @@ -1413,5 +1381,5 @@ } result &= m_data_buffer->setNominalRate(ticks_per_frame); - result &= m_data_buffer->setWrapValue(128L*TICKS_PER_SECOND); + result &= m_data_buffer->setWrapValue(128L * TICKS_PER_SECOND); result &= m_data_buffer->setBandwidth(STREAMPROCESSOR_DLL_FAST_BW_HZ / (double)TICKS_PER_SECOND); result &= m_data_buffer->prepare(); // FIXME: the name @@ -1419,5 +1387,4 @@ debugOutput(DEBUG_LEVEL_VERBOSE, "DLL info: nominal tpf: %f, update period: %d, bandwidth: %e 1/ticks (%e Hz)\n", m_data_buffer->getNominalRate(), m_data_buffer->getUpdatePeriod(), m_data_buffer->getBandwidth(), m_data_buffer->getBandwidth() * TICKS_PER_SECOND); - break; case ePS_DryRunning: @@ -1432,5 +1399,6 @@ } - result &= m_data_buffer->clearBuffer(); // FIXME: don't like the reset() name + // clear all data + result &= m_data_buffer->clearBuffer(); // make the buffer transparent m_data_buffer->setTransparent(true); @@ -1549,5 +1517,9 @@ { debugOutput(DEBUG_LEVEL_VERBOSE, "Enter from state: %s\n", ePSToString(m_state)); - unsigned int ringbuffer_size_frames; + + unsigned int ringbuffer_size_frames = m_StreamProcessorManager.getNbBuffers() * m_StreamProcessorManager.getPeriodSize(); + ringbuffer_size_frames += m_extra_buffer_frames; + ringbuffer_size_frames += 1; // to ensure that we can fit it all in there + switch(m_state) { case ePS_DryRunning: @@ -1556,17 +1528,17 @@ // be picked up by the packet iterator - if(!m_data_buffer->clearBuffer()) { - debugError("Could not reset data buffer\n"); + // clear the buffer / resize it to the most recent + // size setting + if(!m_data_buffer->resizeBuffer(ringbuffer_size_frames)) { + debugError("Could not resize data buffer\n"); return false; } + if (getType() == ePT_Transmit) { ringbuffer_size_frames = m_StreamProcessorManager.getNbBuffers() * m_StreamProcessorManager.getPeriodSize(); - - // add sync delay - int syncdelay_in_frames = m_StreamProcessorManager.getSyncSource().getSyncDelayFrames(); - ringbuffer_size_frames += syncdelay_in_frames; - - debugOutput(DEBUG_LEVEL_VERBOSE, "Prefill transmit SP %p with %u frames (sync_delay_frames = %d)\n", - this, ringbuffer_size_frames, syncdelay_in_frames); + ringbuffer_size_frames += m_extra_buffer_frames; + + debugOutput(DEBUG_LEVEL_VERBOSE, "Prefill transmit SP %p with %u frames (xmit prebuffer = %d)\n", + this, ringbuffer_size_frames, m_extra_buffer_frames); // prefill the buffer if(!transferSilence(ringbuffer_size_frames)) { @@ -1929,5 +1901,5 @@ } uint64_t now = m_1394service.getCycleTimerTicks(); - debugOutputShort( DEBUG_LEVEL_NORMAL, " Now : %011llu (%03us %04uc %04ut)\n", + debugOutputShort( DEBUG_LEVEL_NORMAL, " Now : %011"PRIu64" (%03us %04uc %04ut)\n", now, (unsigned int)TICKS_TO_SECS(now), @@ -1948,8 +1920,4 @@ 24576000.0/m_StreamProcessorManager.getSyncSource().m_data_buffer->getRate(), 24576000.0/m_data_buffer->getRate()); - float d = getSyncDelay(); - debugOutputShort(DEBUG_LEVEL_NORMAL, " Sync delay : %f ticks (%f frames, %f cy)\n", - d, d/getTicksPerFrame(), - d/((float)TICKS_PER_CYCLE)); #endif m_data_buffer->dumpInfo(); Index: /trunk/libffado/src/DeviceStringParser.cpp =================================================================== --- /trunk/libffado/src/DeviceStringParser.cpp (revision 1147) +++ /trunk/libffado/src/DeviceStringParser.cpp (revision 1763) @@ -160,5 +160,5 @@ DeviceStringParser::DeviceString::match(ConfigRom& configRom) { - debugOutput(DEBUG_LEVEL_VERBOSE, "match %p\n", &configRom); + debugOutput(DEBUG_LEVEL_VERBOSE, "match %p (%s)\n", &configRom, configRom.getGuidString().c_str()); bool match; switch(m_Type) { @@ -172,11 +172,18 @@ match &= ((configRom.getNodeId() & 0x3F) == m_node); } + if(match) { + debugOutput(DEBUG_LEVEL_VERBOSE, "(eBusNode) device matches device string %s\n", m_String.c_str()); + } return match; case eGUID: //GUID should not be 0 - return m_guid && (m_guid == configRom.getGuid()); + match = m_guid && (m_guid == configRom.getGuid()); + if(match) { + debugOutput(DEBUG_LEVEL_VERBOSE, "(eGUID) device matches device string %s\n", m_String.c_str()); + } + return match; case eInvalid: default: - debugOutput(DEBUG_LEVEL_VERBOSE, "no match %p\n", &configRom); + debugError("invalid DeviceString type (%d)\n", m_Type); return false; } @@ -196,5 +203,5 @@ case eGUID: retval = m_guid && (m_guid == x.m_guid); - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "eGUID 0x%016X == 0x%016X? %d\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "eGUID 0x%016"PRIX64" == 0x%016"PRIX64"? %d\n", m_guid, x.m_guid, retval); return retval; @@ -218,5 +225,5 @@ case eGUID: debugOutput(DEBUG_LEVEL_INFO, "type: eGUID\n"); - debugOutput(DEBUG_LEVEL_INFO, " GUID: %016LLX\n", m_guid); + debugOutput(DEBUG_LEVEL_INFO, " GUID: %016"PRIX64"\n", m_guid); break; case eInvalid: @@ -282,4 +289,11 @@ DeviceStringParser::match(ConfigRom& c) { + return matchPosition(c) != -1; +} + +int +DeviceStringParser::matchPosition(ConfigRom& c) +{ + int pos = 0; for ( DeviceStringVectorIterator it = m_DeviceStrings.begin(); it != m_DeviceStrings.end(); @@ -287,9 +301,11 @@ { if((*it)->match(c)) { - return true; - } - } - return false; -} + return pos; + } + pos++; + } + return -1; +} + bool DeviceStringParser::addDeviceString(DeviceString *o) @@ -370,5 +386,4 @@ } - void DeviceStringParser::show() Index: /trunk/libffado/src/motu/motu_avdevice.h =================================================================== --- /trunk/libffado/src/motu/motu_avdevice.h (revision 1531) +++ /trunk/libffado/src/motu/motu_avdevice.h (revision 1763) @@ -35,4 +35,5 @@ #include "motu_controls.h" +#include "motu_mark3_controls.h" #define MOTU_BASE_ADDR 0xfffff0000000ULL @@ -88,4 +89,56 @@ #define MOTU_REG_INPUT_GAIN_PHINV1 0x0c74 #define MOTU_REG_INPUT_GAIN_PHINV2 0x0c78 + +/* Device register definitions for the earliest generation devices */ +#define MOTU_G1_REG_CONFIG 0x0b00 +#define MOTU_G1_REG_ISOCTRL 0x0b10 + +/* There's an unknown subtlety regarding the optical mode of the "generation + * 1" devices such as the 828Mk1. It seems that the same configuration + * register setting is used for "off" and "adat" modes. There must be more + * to this though because the number of audio channels sent presumedly + * changes when adat mode is selected; there must be some way that the + * device deduces the mode. + */ +#define MOTU_G1_OPT_IN_MODE_MASK 0x8000 +#define MOTU_G1_OPT_IN_MODE_BIT0 15 +#define MOTU_G1_OPT_OUT_MODE_MASK 0x4000 +#define MOTU_G1_OPT_OUT_MODE_BIT0 14 +#define MOTU_G1_OPTICAL_OFF 0x0000 +#define MOTU_G1_OPTICAL_TOSLINK 0x0001 +#define MOTU_G1_OPTICAL_ADAT 0x0000 + +#define MOTU_G1_RATE_MASK 0x0004 +#define MOTU_G1_RATE_44100 0x0000 +#define MOTU_G1_RATE_48000 0x0004 + +#define MOTU_G1_CLKSRC_MASK 0x0003 +#define MOTU_G1_CLKSRC_INTERNAL 0x0000 +#define MOTU_G1_CLKSRC_ADAT_9PIN 0x0001 +#define MOTU_G1_CLKSRC_SPDIF 0x0002 +#define MOTU_G1_CLKSRC_UNCHANGED MOTU_CLKSRC_UNCHANGED + +#define MOTU_G1_MONIN_MASK 0x3f00 +#define MOTU_G1_MONIN_L_SRC_MASK 0x0600 +#define MOTU_G1_MONIN_R_SRC_MASK 0x3000 +#define MOTU_G1_MONIN_L_MUTE_MASK 0x0100 // Yes, the sense of these 2 bits +#define MOTU_G1_MONIN_R_EN_MASK 0x0800 // really are reversed +#define MOTU_G1_MONIN_L_MUTE 0x0100 +#define MOTU_G1_MONIN_L_ENABLE 0x0000 +#define MOTU_G1_MONIN_R_MUTE 0x0000 +#define MOTU_G1_MONIN_R_ENABLE 0x0800 +#define MOTU_G1_MONIN_L_CH1 0x0000 +#define MOTU_G1_MONIN_L_CH3 0x0020 +#define MOTU_G1_MONIN_L_CH5 0x0040 +#define MOTU_G1_MONIN_L_CH7 0x0060 +#define MOTU_G1_MONIN_R_CH2 0x0000 +#define MOTU_G1_MONIN_R_CH4 0x1000 +#define MOTU_G1_MONIN_R_CH6 0x2000 +#define MOTU_G1_MONIN_R_CH8 0x3000 + +/* Mark3 device registers - these don't have MOTU_BASE_ADDR as the base + * address so for now we'll define them as absolute addresses. + */ +#define MOTU_MARK3_REG_MIXER 0xffff00010000LL /* Port Active Flags (ports declaration) */ @@ -122,12 +175,13 @@ enum EMotuModel { - MOTU_MODEL_NONE = 0x0000, - MOTU_MODEL_828mkII = 0x0001, - MOTU_MODEL_TRAVELER = 0x0002, - MOTU_MODEL_ULTRALITE= 0x0003, - MOTU_MODEL_8PRE = 0x0004, - MOTU_MODEL_828MkI = 0x0005, - MOTU_MODEL_896HD = 0x0006, - MOTU_MODEL_828mk3 = 0x0007, + MOTU_MODEL_NONE = 0x0000, + MOTU_MODEL_828mkII = 0x0001, + MOTU_MODEL_TRAVELER = 0x0002, + MOTU_MODEL_ULTRALITE = 0x0003, + MOTU_MODEL_8PRE = 0x0004, + MOTU_MODEL_828MkI = 0x0005, + MOTU_MODEL_896HD = 0x0006, + MOTU_MODEL_828mk3 = 0x0007, + MOTU_MODEL_ULTRALITEmk3 = 0x0008, }; @@ -148,4 +202,5 @@ }; +// Structures used for pre-Mark3 device mixer definitions struct MixerCtrl { const char *name, *label, *desc; @@ -153,10 +208,8 @@ unsigned int dev_register; }; - struct MatrixMixBus { const char *name; unsigned int address; }; - struct MatrixMixChannel { const char *name; @@ -164,5 +217,4 @@ unsigned int addr_ofs; }; - struct MotuMixer { const MixerCtrl *mixer_ctrl; @@ -174,11 +226,19 @@ }; +// Structures used for devices which use the "Mark3" mixer protocol +struct MotuMark3Mixer { +}; + struct DevicePropertyEntry { const PortEntry* port_entry; unsigned int n_port_entries; signed int MaxSampleRate; + // A device will set at most one of the *mixer fields const struct MotuMixer *mixer; + const struct MotuMark3Mixer *m3mixer; // Others features can be added here like MIDI port presence. }; + +extern const DevicePropertyEntry DevicesProperty[]; /* Macro to calculate the size of an array */ @@ -244,4 +304,5 @@ private: bool buildMixerAudioControls(void); + bool buildMark3MixerAudioControls(void); bool addPort(Streaming::StreamProcessor *s_processor, char *name, Index: /trunk/libffado/src/motu/motu_mixerdefs.h =================================================================== --- /trunk/libffado/src/motu/motu_mixerdefs.h (revision 1763) +++ /trunk/libffado/src/motu/motu_mixerdefs.h (revision 1763) @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2005-2008 by Pieter Palmers + * Copyright (C) 2005-2009 by Jonathan Woithe + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/* Provide access to mixer details for devices which utilise the + * original "pre-Mark3" mixer control protocol. + */ + +#ifndef MOTU_MIXERDEFS_H +#define MOTU_MIXERDEFS_H + +#include "motu/motu_avdevice.h" + +namespace Motu { + +extern const MotuMixer Mixer_Traveler; +extern const MotuMixer Mixer_Ultralite; +extern const MotuMixer Mixer_828Mk2; +extern const MotuMixer Mixer_896HD; +extern const MotuMixer Mixer_8pre; + +} + +#endif Index: /trunk/libffado/src/motu/motu_mark3_controls.cpp =================================================================== --- /trunk/libffado/src/motu/motu_mark3_controls.cpp (revision 1763) +++ /trunk/libffado/src/motu/motu_mark3_controls.cpp (revision 1763) @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2005-2008 by Pieter Palmers + * Copyright (C) 2008-2009 by Jonathan Woithe + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/* DBus controls associated with Mark3 mixer controls */ + +// This also includes motu_mark3_controls.h +#include "motu_avdevice.h" + +namespace Motu { + +} Index: /trunk/libffado/src/motu/motu_controls.cpp =================================================================== --- /trunk/libffado/src/motu/motu_controls.cpp (revision 1531) +++ /trunk/libffado/src/motu/motu_controls.cpp (revision 1763) @@ -301,5 +301,5 @@ if (v > 0x80) v = 0x80; - debugOutput(DEBUG_LEVEL_VERBOSE, "ChannelFader setValue for row %d col %d to %lf (%ld)\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "ChannelFader setValue for row %d col %d to %lf (%d)\n", row, col, val, v); reg = getCellRegister(row,col); @@ -331,5 +331,5 @@ val = m_parent.ReadRegister(reg) & 0xff; - debugOutput(DEBUG_LEVEL_VERBOSE, "ChannelFader getValue for row %d col %d = %lu\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "ChannelFader getValue for row %d col %d = %u\n", row, col, val); return val; @@ -353,5 +353,5 @@ v = 0x80; - debugOutput(DEBUG_LEVEL_VERBOSE, "ChannelPan setValue for row %d col %d to %lf (%ld)\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "ChannelPan setValue for row %d col %d to %lf (%d)\n", row, col, val, v); reg = getCellRegister(row,col); @@ -387,5 +387,5 @@ val = ((val >> 8) & 0xff) - 0x40; - debugOutput(DEBUG_LEVEL_VERBOSE, "ChannelPan getValue for row %d col %d = %lu\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "ChannelPan getValue for row %d col %d = %u\n", row, col, val); return val; @@ -414,5 +414,5 @@ uint32_t v, reg; - debugOutput(DEBUG_LEVEL_VERBOSE, "BinSw setValue for row %d col %d to %lf (%ld)\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "BinSw setValue for row %d col %d to %lf (%d)\n", row, col, val, val==0?0:1); reg = getCellRegister(row,col); @@ -460,5 +460,5 @@ val = (val & m_value_mask) != 0; - debugOutput(DEBUG_LEVEL_VERBOSE, "BinSw getValue for row %d col %d = %lu\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "BinSw getValue for row %d col %d = %u\n", row, col, val); return val; Index: /trunk/libffado/src/motu/motu_mark3_mixerdefs.cpp =================================================================== --- /trunk/libffado/src/motu/motu_mark3_mixerdefs.cpp (revision 1763) +++ /trunk/libffado/src/motu/motu_mark3_mixerdefs.cpp (revision 1763) @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2005-2008 by Pieter Palmers + * Copyright (C) 2005-2009 by Jonathan Woithe + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/* This module contains definitions of mixers on devices which utilise the + * "Mark3" mixer control protocol. + */ + +#include "motu/motu_avdevice.h" +#include "motu/motu_mark3_mixerdefs.h" + +namespace Motu { + +} Index: /trunk/libffado/src/motu/motu_mixer.cpp =================================================================== --- /trunk/libffado/src/motu/motu_mixer.cpp (revision 1763) +++ /trunk/libffado/src/motu/motu_mixer.cpp (revision 1763) @@ -0,0 +1,393 @@ +/* + * Copyright (C) 2005-2008 by Pieter Palmers + * Copyright (C) 2005-2009 by Jonathan Woithe + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/* This file collects together everything associated with the management + * of mixer controls in the MOTU device object. + */ + +#include "motu/motu_avdevice.h" +#include "motu/motu_mixerdefs.h" +#include "motu/motu_mark3_mixerdefs.h" + +namespace Motu { + +bool +MotuDevice::buildMixerAudioControls(void) { + + bool result = true; + MotuMatrixMixer *fader_mmixer = NULL; + MotuMatrixMixer *pan_mmixer = NULL; + MotuMatrixMixer *solo_mmixer = NULL; + MotuMatrixMixer *mute_mmixer = NULL; + const struct MatrixMixBus *buses = NULL; + const struct MatrixMixChannel *channels = NULL; + unsigned int bus, ch, i; + + if (DevicesProperty[m_motu_model-1].mixer == NULL) { + debugOutput(DEBUG_LEVEL_INFO, "No pre-Mark3 mixer controls defined for model %d\n", m_motu_model); + result = false; + } else { + buses = DevicesProperty[m_motu_model-1].mixer->mixer_buses; + if (buses == NULL) { + debugOutput(DEBUG_LEVEL_WARNING, "No buses defined for model %d\n", m_motu_model); + result = false; + } + channels = DevicesProperty[m_motu_model-1].mixer->mixer_channels; + if (channels == NULL) { + debugOutput(DEBUG_LEVEL_WARNING, "No channels defined for model %d\n", m_motu_model); + result = false; + } + } + if (result == false) { + return true; + } + + /* Create the top-level matrix mixers */ + fader_mmixer = new ChannelFaderMatrixMixer(*this, "fader"); + result &= m_MixerContainer->addElement(fader_mmixer); + pan_mmixer = new ChannelPanMatrixMixer(*this, "pan"); + result &= m_MixerContainer->addElement(pan_mmixer); + solo_mmixer = new ChannelBinSwMatrixMixer(*this, "solo", + MOTU_CTRL_MASK_SOLO_VALUE, MOTU_CTRL_MASK_SOLO_SETENABLE); + result &= m_MixerContainer->addElement(solo_mmixer); + mute_mmixer = new ChannelBinSwMatrixMixer(*this, "mute", + MOTU_CTRL_MASK_MUTE_VALUE, MOTU_CTRL_MASK_MUTE_SETENABLE); + result &= m_MixerContainer->addElement(mute_mmixer); + + for (bus=0; busn_mixer_buses; bus++) { + fader_mmixer->addRowInfo(buses[bus].name, 0, buses[bus].address); + pan_mmixer->addRowInfo(buses[bus].name, 0, buses[bus].address); + solo_mmixer->addRowInfo(buses[bus].name, 0, buses[bus].address); + mute_mmixer->addRowInfo(buses[bus].name, 0, buses[bus].address); + } + + for (ch=0; chn_mixer_channels; ch++) { + uint32_t flags = channels[ch].flags; + if (flags & MOTU_CTRL_CHANNEL_FADER) + fader_mmixer->addColInfo(channels[ch].name, 0, channels[ch].addr_ofs); + if (flags & MOTU_CTRL_CHANNEL_PAN) + pan_mmixer->addColInfo(channels[ch].name, 0, channels[ch].addr_ofs); + if (flags & MOTU_CTRL_CHANNEL_SOLO) + solo_mmixer->addColInfo(channels[ch].name, 0, channels[ch].addr_ofs); + if (flags & MOTU_CTRL_CHANNEL_MUTE) + mute_mmixer->addColInfo(channels[ch].name, 0, channels[ch].addr_ofs); + flags &= ~(MOTU_CTRL_CHANNEL_FADER|MOTU_CTRL_CHANNEL_PAN|MOTU_CTRL_CHANNEL_SOLO|MOTU_CTRL_CHANNEL_MUTE); + if (flags) { + debugOutput(DEBUG_LEVEL_WARNING, "Control %s: unknown flag bits 0x%08x\n", channels[ch].name, flags); + } + } + + // Single non-matrixed mixer controls get added here. Channel controls are supported + // here, but usually these will be a part of a matrix mixer. + for (i=0; in_mixer_ctrls; i++) { + const struct MixerCtrl *ctrl = &DevicesProperty[m_motu_model-1].mixer->mixer_ctrl[i]; + unsigned int type; + char name[100]; + char label[100]; + + if (ctrl == NULL) { + debugOutput(DEBUG_LEVEL_WARNING, "NULL control at index %d for model %d\n", i, m_motu_model); + continue; + } + type = ctrl->type; + if (type & MOTU_CTRL_CHANNEL_FADER) { + snprintf(name, 100, "%s%s", ctrl->name, "fader"); + snprintf(label,100, "%s%s", ctrl->label,"fader"); + result &= m_MixerContainer->addElement( + new ChannelFader(*this, ctrl->dev_register, name, label, ctrl->desc)); + type &= ~MOTU_CTRL_CHANNEL_FADER; + } + if (type & MOTU_CTRL_CHANNEL_PAN) { + snprintf(name, 100, "%s%s", ctrl->name, "pan"); + snprintf(label,100, "%s%s", ctrl->label,"pan"); + result &= m_MixerContainer->addElement( + new ChannelPan(*this, + ctrl->dev_register, + name, label, + ctrl->desc)); + type &= ~MOTU_CTRL_CHANNEL_PAN; + } + if (type & MOTU_CTRL_CHANNEL_MUTE) { + snprintf(name, 100, "%s%s", ctrl->name, "mute"); + snprintf(label,100, "%s%s", ctrl->label,"mute"); + result &= m_MixerContainer->addElement( + new MotuBinarySwitch(*this, ctrl->dev_register, + MOTU_CTRL_MASK_MUTE_VALUE, MOTU_CTRL_MASK_MUTE_SETENABLE, + name, label, ctrl->desc)); + type &= ~MOTU_CTRL_CHANNEL_MUTE; + } + if (type & MOTU_CTRL_CHANNEL_SOLO) { + snprintf(name, 100, "%s%s", ctrl->name, "solo"); + snprintf(label,100, "%s%s", ctrl->label,"solo"); + result &= m_MixerContainer->addElement( + new MotuBinarySwitch(*this, ctrl->dev_register, + MOTU_CTRL_MASK_SOLO_VALUE, MOTU_CTRL_MASK_SOLO_SETENABLE, + name, label, ctrl->desc)); + type &= ~MOTU_CTRL_CHANNEL_SOLO; + } + + if (type & MOTU_CTRL_MIX_FADER) { + snprintf(name, 100, "%s%s", ctrl->name, "fader"); + snprintf(label,100, "%s%s", ctrl->label,"fader"); + result &= m_MixerContainer->addElement( + new MixFader(*this, ctrl->dev_register, name, label, ctrl->desc)); + type &= ~MOTU_CTRL_MIX_FADER; + } + if (type & MOTU_CTRL_MIX_MUTE) { + snprintf(name, 100, "%s%s", ctrl->name, "mute"); + snprintf(label,100, "%s%s", ctrl->label,"mute"); + result &= m_MixerContainer->addElement( + new MixMute(*this, ctrl->dev_register, name, label, ctrl->desc)); + type &= ~MOTU_CTRL_MIX_MUTE; + } + if (type & MOTU_CTRL_MIX_DEST) { + snprintf(name, 100, "%s%s", ctrl->name, "dest"); + snprintf(label,100, "%s%s", ctrl->label,"dest"); + result &= m_MixerContainer->addElement( + new MixDest(*this, ctrl->dev_register, name, label, ctrl->desc)); + type &= ~MOTU_CTRL_MIX_DEST; + } + + if (type & MOTU_CTRL_INPUT_UL_GAIN) { + snprintf(name, 100, "%s%s", ctrl->name, "trimgain"); + snprintf(label,100, "%s%s", ctrl->label,"trimgain"); + result &= m_MixerContainer->addElement( + new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_UL_GAIN, + name, label, ctrl->desc)); + type &= ~MOTU_CTRL_INPUT_UL_GAIN; + } + if (type & MOTU_CTRL_INPUT_PHASE_INV) { + snprintf(name, 100, "%s%s", ctrl->name, "invert"); + snprintf(label,100, "%s%s", ctrl->label,"invert"); + result &= m_MixerContainer->addElement( + new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_PHASE_INV, + name, label, ctrl->desc)); + type &= ~MOTU_CTRL_INPUT_PHASE_INV; + } + if (type & MOTU_CTRL_INPUT_TRIMGAIN) { + snprintf(name, 100, "%s%s", ctrl->name, "trimgain"); + snprintf(label,100, "%s%s", ctrl->label,"trimgain"); + result &= m_MixerContainer->addElement( + new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_TRIMGAIN, + name, label, ctrl->desc)); + type &= ~MOTU_CTRL_INPUT_TRIMGAIN; + } + if (type & MOTU_CTRL_INPUT_PAD) { + snprintf(name, 100, "%s%s", ctrl->name, "pad"); + snprintf(label,100, "%s%s", ctrl->label,"pad"); + result &= m_MixerContainer->addElement( + new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_PAD, + name, label, ctrl->desc)); + type &= ~MOTU_CTRL_INPUT_PAD; + } + + if (type & MOTU_CTRL_INPUT_LEVEL) { + snprintf(name, 100, "%s%s", ctrl->name, "level"); + snprintf(label,100, "%s%s", ctrl->label,"level"); + result &= m_MixerContainer->addElement( + new MotuBinarySwitch(*this, MOTU_REG_INPUT_LEVEL, + 1<dev_register, 0, name, label, ctrl->desc)); + type &= ~MOTU_CTRL_INPUT_LEVEL; + } + if (type & MOTU_CTRL_INPUT_BOOST) { + snprintf(name, 100, "%s%s", ctrl->name, "boost"); + snprintf(label,100, "%s%s", ctrl->label,"boost"); + result &= m_MixerContainer->addElement( + new MotuBinarySwitch(*this, MOTU_REG_INPUT_BOOST, + 1<dev_register, 0, name, label, ctrl->desc)); + type &= ~MOTU_CTRL_INPUT_BOOST; + } + if (type & MOTU_CTRL_PHONES_SRC) { + snprintf(name, 100, "%s%s", ctrl->name, "src"); + snprintf(label,100, "%s%s", ctrl->label,"src"); + result &= m_MixerContainer->addElement( + new PhonesSrc(*this, name, label, ctrl->desc)); + type &= ~MOTU_CTRL_PHONES_SRC; + } + if (type & MOTU_CTRL_OPTICAL_MODE) { + result &= m_MixerContainer->addElement( + new OpticalMode(*this, ctrl->dev_register, + ctrl->name, ctrl->label, ctrl->desc)); + type &= ~MOTU_CTRL_OPTICAL_MODE; + } + if (type & MOTU_CTRL_METER) { + if (ctrl->dev_register & MOTU_CTRL_METER_PEAKHOLD) { + snprintf(name, 100, "%s%s", ctrl->name, "peakhold_time"); + snprintf(label,100, "%s%s", ctrl->label,"peakhold time"); + result &= m_MixerContainer->addElement( + new MeterControl(*this, MOTU_METER_PEAKHOLD_MASK, + MOTU_METER_PEAKHOLD_SHIFT, name, label, ctrl->desc)); + } + if (ctrl->dev_register & MOTU_CTRL_METER_CLIPHOLD) { + snprintf(name, 100, "%s%s", ctrl->name, "cliphold_time"); + snprintf(label,100, "%s%s", ctrl->label,"cliphold time"); + result &= m_MixerContainer->addElement( + new MeterControl(*this, MOTU_METER_CLIPHOLD_MASK, + MOTU_METER_CLIPHOLD_SHIFT, name, label, ctrl->desc)); + } + if (ctrl->dev_register & MOTU_CTRL_METER_AESEBU_SRC) { + snprintf(name, 100, "%s%s", ctrl->name, "aesebu_src"); + snprintf(label,100, "%s%s", ctrl->label,"AESEBU source"); + result &= m_MixerContainer->addElement( + new MeterControl(*this, MOTU_METER_AESEBU_SRC_MASK, + MOTU_METER_AESEBU_SRC_SHIFT, name, label, ctrl->desc)); + } + if (ctrl->dev_register & MOTU_CTRL_METER_PROG_SRC) { + snprintf(name, 100, "%s%s", ctrl->name, "src"); + snprintf(label,100, "%s%s", ctrl->label,"source"); + result &= m_MixerContainer->addElement( + new MeterControl(*this, MOTU_METER_PROG_SRC_MASK, + MOTU_METER_PROG_SRC_SHIFT, name, label, ctrl->desc)); + } + type &= ~MOTU_CTRL_METER; + } + + if (type) { + debugOutput(DEBUG_LEVEL_WARNING, "Unknown mixer control type flag bits 0x%08x\n", ctrl->type); + } + } + return result; +} + +bool +MotuDevice::buildMark3MixerAudioControls(void) { + + bool result = true; + + if (DevicesProperty[m_motu_model-1].m3mixer == NULL) { + debugOutput(DEBUG_LEVEL_INFO, "No Mark3 mixer controls defined for model %d\n", m_motu_model); + return false; + } + + // FIXME: Details to come + result = false; + + return result; +} + +bool +MotuDevice::buildMixer() { + bool result = true; + debugOutput(DEBUG_LEVEL_VERBOSE, "Building a MOTU mixer...\n"); + + destroyMixer(); + + // create the mixer object container + m_MixerContainer = new Control::Container(this, "Mixer"); + if (!m_MixerContainer) { + debugError("Could not create mixer container...\n"); + return false; + } + + if (DevicesProperty[m_motu_model-1].mixer != NULL && + DevicesProperty[m_motu_model-1].m3mixer != NULL) { + debugError("MOTU model %d has pre-Mark3 and Mark3 mixer descriptions\n", m_motu_model); + return false; + } + + // Create and populate the top-level matrix mixers + result = buildMixerAudioControls() || buildMark3MixerAudioControls(); + + /* Now add some general device information controls. These may yet + * become device-specific if it turns out to be easier that way. + */ + result &= m_MixerContainer->addElement( + new InfoElement(*this, MOTU_INFO_MODEL, "Info/Model", "Model identifier", "")); + result &= m_MixerContainer->addElement( + new InfoElement(*this, MOTU_INFO_IS_STREAMING, "Info/IsStreaming", "Is device streaming", "")); + result &= m_MixerContainer->addElement( + new InfoElement(*this, MOTU_INFO_SAMPLE_RATE, "Info/SampleRate", "Device sample rate", "")); + + if (!addElement(m_MixerContainer)) { + debugWarning("Could not register mixer to device\n"); + // clean up + destroyMixer(); + return false; + } + + // Special controls + m_ControlContainer = new Control::Container(this, "Control"); + if (!m_ControlContainer) { + debugError("Could not create control container...\n"); + return false; + } + + // Special controls get added here + + if (!result) { + debugWarning("One or more device control elements could not be created."); + // clean up those that couldn't be created + destroyMixer(); + return false; + } + if (!addElement(m_ControlContainer)) { + debugWarning("Could not register controls to device\n"); + // clean up + destroyMixer(); + return false; + } + + return true; +} + + +bool +MotuDevice::destroyMixer() { + debugOutput(DEBUG_LEVEL_VERBOSE, "destroy mixer...\n"); + + if (m_MixerContainer == NULL) { + debugOutput(DEBUG_LEVEL_VERBOSE, "no mixer to destroy...\n"); + return true; + } + + if (!deleteElement(m_MixerContainer)) { + debugError("Mixer present but not registered to the avdevice\n"); + return false; + } + + // remove and delete (as in free) child control elements + m_MixerContainer->clearElements(true); + delete m_MixerContainer; + m_MixerContainer = NULL; + + // remove control container + if (m_ControlContainer == NULL) { + debugOutput(DEBUG_LEVEL_VERBOSE, "no controls to destroy...\n"); + return true; + } + + if (!deleteElement(m_ControlContainer)) { + debugError("Controls present but not registered to the avdevice\n"); + return false; + } + + // remove and delete (as in free) child control elements + m_ControlContainer->clearElements(true); + delete m_ControlContainer; + m_ControlContainer = NULL; + + return true; +} + +} Index: /trunk/libffado/src/motu/motu_mark3_controls.h =================================================================== --- /trunk/libffado/src/motu/motu_mark3_controls.h (revision 1763) +++ /trunk/libffado/src/motu/motu_mark3_controls.h (revision 1763) @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2005-2008 by Daniel Wagner + * Copyright (C) 2005-2008 by Pieter Palmers + * Copyright (C) 2008-2009 by Jonathan Woithe + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/* DBus controls associated with Mark3 mixer controls */ + +#include "debugmodule/debugmodule.h" + +#include "libcontrol/BasicElements.h" +#include "libcontrol/MatrixMixer.h" + +namespace Motu { + +class MotuDevice; + + +} Index: /trunk/libffado/src/motu/motu_avdevice.cpp =================================================================== --- /trunk/libffado/src/motu/motu_avdevice.cpp (revision 1605) +++ /trunk/libffado/src/motu/motu_avdevice.cpp (revision 1763) @@ -26,4 +26,6 @@ #include "motu/motu_avdevice.h" +#include "motu/motu_mixerdefs.h" +#include "motu/motu_mark3_mixerdefs.h" #include "devicemanager.h" @@ -67,4 +69,5 @@ {FW_VENDORID_MOTU, 0, 0x00000005, 0x000001f2, MOTU_MODEL_896HD, "MOTU", "896HD"}, {FW_VENDORID_MOTU, 0, 0x00000015, 0x000001f2, MOTU_MODEL_828mk3, "MOTU", "828Mk3"}, + {FW_VENDORID_MOTU, 0, 0x00000019, 0x000001f2, MOTU_MODEL_ULTRALITEmk3, "MOTU", "UltraLineMk3"}, }; @@ -202,6 +205,6 @@ const PortEntry Ports_ULTRALITE[] = { - {"Main-L", MOTU_PA_INOUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 40}, - {"Main-R", MOTU_PA_INOUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 43}, + {"Main-L", MOTU_PA_OUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 40}, + {"Main-R", MOTU_PA_OUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 43}, {"Mix-L", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 10}, {"Mix-R", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 13}, @@ -218,4 +221,6 @@ {"Phones-L", MOTU_PA_OUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 10}, {"Phones-R", MOTU_PA_OUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 13}, + {"SPDIF1", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 40}, + {"SPDIF2", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 43}, {"Padding1", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY|MOTU_PA_PADDING, 46}, {"Padding2", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY|MOTU_PA_PADDING, 49}, @@ -306,237 +311,29 @@ }; -// Mixer registers -const MatrixMixBus MixerBuses_Traveler[] = { - {"Mix 1", 0x4000, }, - {"Mix 2", 0x4100, }, - {"Mix 3", 0x4200, }, - {"Mix 4", 0x4300, }, +const PortEntry Ports_ULTRALITEmk3[] = +{ + {"Main-L", MOTU_PA_OUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 40}, + {"Main-R", MOTU_PA_OUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 43}, + {"Mix-L", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 10}, + {"Mix-R", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 13}, + {"Mic1", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 16}, + {"Mic2", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 19}, + {"Analog1", MOTU_PA_OUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 16}, + {"Analog2", MOTU_PA_OUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 19}, + {"Analog3", MOTU_PA_INOUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 22}, + {"Analog4", MOTU_PA_INOUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 25}, + {"Analog5", MOTU_PA_INOUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 28}, + {"Analog6", MOTU_PA_INOUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 31}, + {"Analog7", MOTU_PA_INOUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 34}, + {"Analog8", MOTU_PA_INOUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 37}, + {"Phones-L", MOTU_PA_OUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 10}, + {"Phones-R", MOTU_PA_OUT | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY, 13}, + {"SPDIF1", MOTU_PA_IN | MOTU_PA_RATE_1x2x|MOTU_PA_OPTICAL_ANY, 40}, + {"SPDIF2", MOTU_PA_IN | MOTU_PA_RATE_1x2x|MOTU_PA_OPTICAL_ANY, 43}, + {"Padding1", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY|MOTU_PA_PADDING, 46}, + {"Padding2", MOTU_PA_IN | MOTU_PA_RATE_ANY|MOTU_PA_OPTICAL_ANY|MOTU_PA_PADDING, 49}, + {"SPDIF1", MOTU_PA_OUT | MOTU_PA_RATE_1x2x|MOTU_PA_OPTICAL_ANY, 46}, + {"SPDIF2", MOTU_PA_OUT | MOTU_PA_RATE_1x2x|MOTU_PA_OPTICAL_ANY, 49}, }; - -const MatrixMixChannel MixerChannels_Traveler[] = { - {"Analog 1", MOTU_CTRL_STD_CHANNEL, 0x0000, }, - {"Analog 2", MOTU_CTRL_STD_CHANNEL, 0x0004, }, - {"Analog 3", MOTU_CTRL_STD_CHANNEL, 0x0008, }, - {"Analog 4", MOTU_CTRL_STD_CHANNEL, 0x000c, }, - {"Analog 5", MOTU_CTRL_STD_CHANNEL, 0x0010, }, - {"Analog 6", MOTU_CTRL_STD_CHANNEL, 0x0014, }, - {"Analog 7", MOTU_CTRL_STD_CHANNEL, 0x0018, }, - {"Analog 8", MOTU_CTRL_STD_CHANNEL, 0x001c, }, - {"AES/EBU 1", MOTU_CTRL_STD_CHANNEL, 0x0020, }, - {"AES/EBU 2", MOTU_CTRL_STD_CHANNEL, 0x0024, }, - {"SPDIF 1", MOTU_CTRL_STD_CHANNEL, 0x0028, }, - {"SPDIF 2", MOTU_CTRL_STD_CHANNEL, 0x002c, }, - {"ADAT 1", MOTU_CTRL_STD_CHANNEL, 0x0030, }, - {"ADAT 2", MOTU_CTRL_STD_CHANNEL, 0x0034, }, - {"ADAT 3", MOTU_CTRL_STD_CHANNEL, 0x0038, }, - {"ADAT 4", MOTU_CTRL_STD_CHANNEL, 0x003c, }, - {"ADAT 5", MOTU_CTRL_STD_CHANNEL, 0x0040, }, - {"ADAT 6", MOTU_CTRL_STD_CHANNEL, 0x0044, }, - {"ADAT 7", MOTU_CTRL_STD_CHANNEL, 0x0048, }, - {"ADAT 8", MOTU_CTRL_STD_CHANNEL, 0x004c, }, -}; - -const MixerCtrl MixerCtrls_Traveler[] = { - {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, - {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, - {"Mix3/Mix_", "Mix 3 ", "", MOTU_CTRL_STD_MIX, 0x0c28, }, - {"Mix4/Mix_", "Mix 4 ", "", MOTU_CTRL_STD_MIX, 0x0c2c, }, - {"Mainout_", "MainOut ", "", MOTU_CTRL_MIX_FADER, 0x0c0c, }, - {"Phones_", "Phones ", "", MOTU_CTRL_MIX_FADER, 0x0c10, }, - - /* For mic/line input controls, the "register" is the zero-based channel number */ - {"Control/Ana1_", "Analog 1 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 0}, - {"Control/Ana2_", "Analog 2 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 1}, - {"Control/Ana3_", "Analog 3 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 2}, - {"Control/Ana4_", "Analog 4 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 3}, - {"Control/Ana5_", "Analog 5 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 4}, - {"Control/Ana6_", "Analog 6 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 5}, - {"Control/Ana7_", "Analog 7 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 6}, - {"Control/Ana8_", "Analog 8 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 7}, - - /* For phones source control, "register" is currently unused */ - {"Control/Phones_", "Phones source", "", MOTU_CTRL_PHONES_SRC, 0}, - - /* For optical mode controls, the "register" is used to indicate direction */ - {"Control/OpticalIn_mode", "Optical input mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_IN}, - {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_OUT}, -}; - -const MatrixMixBus MixerBuses_Ultralite[] = { - {"Mix 1", 0x4000, }, - {"Mix 2", 0x4100, }, - {"Mix 3", 0x4200, }, - {"Mix 4", 0x4300, }, -}; - -const MatrixMixChannel MixerChannels_Ultralite[] = { - {"Analog 1", MOTU_CTRL_STD_CHANNEL, 0x0000, }, - {"Analog 2", MOTU_CTRL_STD_CHANNEL, 0x0004, }, - {"Analog 3", MOTU_CTRL_STD_CHANNEL, 0x0008, }, - {"Analog 4", MOTU_CTRL_STD_CHANNEL, 0x000c, }, - {"Analog 5", MOTU_CTRL_STD_CHANNEL, 0x0010, }, - {"Analog 6", MOTU_CTRL_STD_CHANNEL, 0x0014, }, - {"Analog 7", MOTU_CTRL_STD_CHANNEL, 0x0018, }, - {"Analog 8", MOTU_CTRL_STD_CHANNEL, 0x001c, }, - {"AES/EBU 1", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, - {"AES/EBU 2", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, - {"SPDIF 1", MOTU_CTRL_STD_CHANNEL, 0x0020, }, - {"SPDIF 2", MOTU_CTRL_STD_CHANNEL, 0x0024, }, - {"ADAT 1", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, - {"ADAT 2", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, - {"ADAT 3", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, - {"ADAT 4", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, - {"ADAT 5", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, - {"ADAT 6", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, - {"ADAT 7", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, - {"ADAT 8", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, -}; - -const MixerCtrl MixerCtrls_Ultralite[] = { - {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, - {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, - {"Mix3/Mix_", "Mix 3 ", "", MOTU_CTRL_STD_MIX, 0x0c28, }, - {"Mix4/Mix_", "Mix 4 ", "", MOTU_CTRL_STD_MIX, 0x0c2c, }, - {"Mainout_", "MainOut ", "", MOTU_CTRL_MIX_FADER, 0x0c0c, }, - {"Phones_", "Phones ", "", MOTU_CTRL_MIX_FADER, 0x0c10, }, - - /* For mic/line input controls, the "register" is the zero-based channel number */ - {"Control/Ana1_", "Analog 1 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 0}, - {"Control/Ana2_", "Analog 2 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 1}, - {"Control/Ana3_", "Analog 3 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 2}, - {"Control/Ana4_", "Analog 4 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 3}, - {"Control/Ana5_", "Analog 5 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 4}, - {"Control/Ana6_", "Analog 6 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 5}, - {"Control/Ana7_", "Analog 7 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 6}, - {"Control/Ana8_", "Analog 8 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 7}, - {"Control/Spdif1_", "SPDIF 1 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 6}, - {"Control/Spdif2_", "SPDIF 2 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 7}, - - /* For phones source control, "register" is currently unused */ - {"Control/Phones_", "Phones source", "", MOTU_CTRL_PHONES_SRC, 0}, - - /* For optical mode controls, the "register" is used to indicate direction */ - {"Control/OpticalIn_mode", "Optical input mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_IN}, - {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_OUT}, -}; - -const MatrixMixBus MixerBuses_896HD[] = { - {"Mix 1", 0x4000, }, - {"Mix 2", 0x4100, }, - {"Mix 3", 0x4200, }, - {"Mix 4", 0x4300, }, -}; - -const MatrixMixChannel MixerChannels_896HD[] = { - {"Analog 1", MOTU_CTRL_STD_CHANNEL, 0x0000, }, - {"Analog 2", MOTU_CTRL_STD_CHANNEL, 0x0004, }, - {"Analog 3", MOTU_CTRL_STD_CHANNEL, 0x0008, }, - {"Analog 4", MOTU_CTRL_STD_CHANNEL, 0x000c, }, - {"Analog 5", MOTU_CTRL_STD_CHANNEL, 0x0010, }, - {"Analog 6", MOTU_CTRL_STD_CHANNEL, 0x0014, }, - {"Analog 7", MOTU_CTRL_STD_CHANNEL, 0x0018, }, - {"Analog 8", MOTU_CTRL_STD_CHANNEL, 0x001c, }, - {"AES/EBU 1", MOTU_CTRL_STD_CHANNEL, 0x0020, }, - {"AES/EBU 2", MOTU_CTRL_STD_CHANNEL, 0x0024, }, - {"SPDIF 1", MOTU_CTRL_STD_CHANNEL, 0x0048, }, - {"SPDIF 2", MOTU_CTRL_STD_CHANNEL, 0x004c, }, - {"ADAT 1", MOTU_CTRL_STD_CHANNEL, 0x0028, }, - {"ADAT 2", MOTU_CTRL_STD_CHANNEL, 0x002c, }, - {"ADAT 3", MOTU_CTRL_STD_CHANNEL, 0x0030, }, - {"ADAT 4", MOTU_CTRL_STD_CHANNEL, 0x0034, }, - {"ADAT 5", MOTU_CTRL_STD_CHANNEL, 0x0038, }, - {"ADAT 6", MOTU_CTRL_STD_CHANNEL, 0x003c, }, - {"ADAT 7", MOTU_CTRL_STD_CHANNEL, 0x0040, }, - {"ADAT 8", MOTU_CTRL_STD_CHANNEL, 0x0044, }, -}; - -const MixerCtrl MixerCtrls_896HD[] = { - {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, - {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, - {"Mix3/Mix_", "Mix 3 ", "", MOTU_CTRL_STD_MIX, 0x0c28, }, - {"Mix4/Mix_", "Mix 4 ", "", MOTU_CTRL_STD_MIX, 0x0c2c, }, - {"Mainout_", "MainOut ", "", MOTU_CTRL_MIX_FADER, 0x0c0c, }, - {"Phones_", "Phones ", "", MOTU_CTRL_MIX_FADER, 0x0c10, }, - - /* For phones source control, "register" is currently unused */ - {"Control/Phones_", "Phones source", "", MOTU_CTRL_PHONES_SRC, 0}, - - /* For optical mode controls, the "register" is used to indicate direction */ - {"Control/OpticalIn_mode", "Optical input mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_IN}, - {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_OUT}, - - /* For meter controls the "register" indicates which meter controls are available */ - {"Control/Meter_", "Meter ", "", MOTU_CTRL_METER, - MOTU_CTRL_METER_PEAKHOLD | MOTU_CTRL_METER_CLIPHOLD | MOTU_CTRL_METER_AESEBU_SRC | - MOTU_CTRL_METER_PROG_SRC}, -}; - -const MatrixMixBus MixerBuses_828Mk2[] = { - {"Mix 1", 0x4000, }, - {"Mix 2", 0x4100, }, - {"Mix 3", 0x4200, }, - {"Mix 4", 0x4300, }, -}; - -const MatrixMixChannel MixerChannels_828Mk2[] = { - {"Analog 1", MOTU_CTRL_STD_CHANNEL, 0x0000, }, - {"Analog 2", MOTU_CTRL_STD_CHANNEL, 0x0004, }, - {"Analog 3", MOTU_CTRL_STD_CHANNEL, 0x0008, }, - {"Analog 4", MOTU_CTRL_STD_CHANNEL, 0x000c, }, - {"Analog 5", MOTU_CTRL_STD_CHANNEL, 0x0010, }, - {"Analog 6", MOTU_CTRL_STD_CHANNEL, 0x0014, }, - {"Analog 7", MOTU_CTRL_STD_CHANNEL, 0x0018, }, - {"Analog 8", MOTU_CTRL_STD_CHANNEL, 0x001c, }, - {"Mic 1", MOTU_CTRL_STD_CHANNEL, 0x0020, }, - {"Mic 2", MOTU_CTRL_STD_CHANNEL, 0x0024, }, - {"SPDIF 1", MOTU_CTRL_STD_CHANNEL, 0x0028, }, - {"SPDIF 2", MOTU_CTRL_STD_CHANNEL, 0x002c, }, - {"ADAT 1", MOTU_CTRL_STD_CHANNEL, 0x0030, }, - {"ADAT 2", MOTU_CTRL_STD_CHANNEL, 0x0034, }, - {"ADAT 3", MOTU_CTRL_STD_CHANNEL, 0x0038, }, - {"ADAT 4", MOTU_CTRL_STD_CHANNEL, 0x003c, }, - {"ADAT 5", MOTU_CTRL_STD_CHANNEL, 0x0040, }, - {"ADAT 6", MOTU_CTRL_STD_CHANNEL, 0x0044, }, - {"ADAT 7", MOTU_CTRL_STD_CHANNEL, 0x0048, }, - {"ADAT 8", MOTU_CTRL_STD_CHANNEL, 0x004c, }, -}; - -const MixerCtrl MixerCtrls_828Mk2[] = { - {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, - {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, - {"Mix3/Mix_", "Mix 3 ", "", MOTU_CTRL_STD_MIX, 0x0c28, }, - {"Mix4/Mix_", "Mix 4 ", "", MOTU_CTRL_STD_MIX, 0x0c2c, }, - {"Mainout_", "MainOut ", "", MOTU_CTRL_MIX_FADER, 0x0c0c, }, - {"Phones_", "Phones ", "", MOTU_CTRL_MIX_FADER, 0x0c10, }, - - /* For mic/line input controls, the "register" is the zero-based channel number */ - {"Control/Ana1_", "Analog 1 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 0}, - {"Control/Ana2_", "Analog 2 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 1}, - {"Control/Ana3_", "Analog 3 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 2}, - {"Control/Ana4_", "Analog 4 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 3}, - {"Control/Ana5_", "Analog 5 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 4}, - {"Control/Ana6_", "Analog 6 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 5}, - {"Control/Ana7_", "Analog 7 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 6}, - {"Control/Ana8_", "Analog 8 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 7}, - - /* For phones source control, "register" is currently unused */ - {"Control/Phones_", "Phones source", "", MOTU_CTRL_PHONES_SRC, 0}, - - /* For optical mode controls, the "register" is used to indicate direction */ - {"Control/OpticalIn_mode", "Optical input mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_IN}, - {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_OUT}, -}; - -const MotuMixer Mixer_Traveler = MOTUMIXER( - MixerCtrls_Traveler, MixerBuses_Traveler, MixerChannels_Traveler); - -const MotuMixer Mixer_Ultralite = MOTUMIXER( - MixerCtrls_Ultralite, MixerBuses_Ultralite, MixerChannels_Ultralite); - -const MotuMixer Mixer_828Mk2 = MOTUMIXER( - MixerCtrls_828Mk2, MixerBuses_828Mk2, MixerChannels_828Mk2); - -const MotuMixer Mixer_896HD = MOTUMIXER( - MixerCtrls_896HD, MixerBuses_896HD, MixerChannels_896HD); /* The order of DevicesProperty entries must match the numeric order of the @@ -544,12 +341,13 @@ */ const DevicePropertyEntry DevicesProperty[] = { -// { Ports_map, N_ELEMENTS( Ports_map ), MaxSR, MixerDescrPtr }, - { Ports_828MKII, N_ELEMENTS( Ports_828MKII ), 96000, &Mixer_828Mk2, }, - { Ports_TRAVELER, N_ELEMENTS( Ports_TRAVELER ), 192000, &Mixer_Traveler, }, - { Ports_ULTRALITE, N_ELEMENTS( Ports_ULTRALITE ), 96000, &Mixer_Ultralite, }, - { Ports_8PRE, N_ELEMENTS( Ports_8PRE ), 96000 }, - { Ports_828MKI, N_ELEMENTS( Ports_828MKI ), 48000 }, - { Ports_896HD, N_ELEMENTS( Ports_896HD ), 192000, &Mixer_896HD, }, - { Ports_828mk3, N_ELEMENTS( Ports_828mk3 ), 192000 }, +// { Ports_map, N_ELEMENTS( Ports_map ), MaxSR, MixerDescrPtr, Mark3MixerDescrPtr }, + { Ports_828MKII, N_ELEMENTS( Ports_828MKII ), 96000, &Mixer_828Mk2, NULL, }, + { Ports_TRAVELER, N_ELEMENTS( Ports_TRAVELER ), 192000, &Mixer_Traveler, NULL, }, + { Ports_ULTRALITE, N_ELEMENTS( Ports_ULTRALITE ), 96000, &Mixer_Ultralite, NULL, }, + { Ports_8PRE, N_ELEMENTS( Ports_8PRE ), 96000, &Mixer_8pre, NULL, }, + { Ports_828MKI, N_ELEMENTS( Ports_828MKI ), 48000 }, + { Ports_896HD, N_ELEMENTS( Ports_896HD ), 192000, &Mixer_896HD, NULL, }, + { Ports_828mk3, N_ELEMENTS( Ports_828mk3 ), 192000 }, + { Ports_ULTRALITEmk3, N_ELEMENTS( Ports_ULTRALITEmk3 ), 192000 }, }; @@ -584,337 +382,4 @@ destroyMixer(); -} - -bool -MotuDevice::buildMixerAudioControls(void) { - - bool result = true; - MotuMatrixMixer *fader_mmixer = NULL; - MotuMatrixMixer *pan_mmixer = NULL; - MotuMatrixMixer *solo_mmixer = NULL; - MotuMatrixMixer *mute_mmixer = NULL; - const struct MatrixMixBus *buses = NULL; - const struct MatrixMixChannel *channels = NULL; - unsigned int bus, ch, i; - - if (DevicesProperty[m_motu_model-1].mixer == NULL) { - debugOutput(DEBUG_LEVEL_WARNING, "No mixer controls defined for model %d\n", m_motu_model); - result = false; - } else { - buses = DevicesProperty[m_motu_model-1].mixer->mixer_buses; - if (buses == NULL) { - debugOutput(DEBUG_LEVEL_WARNING, "No buses defined for model %d\n", m_motu_model); - result = false; - } - channels = DevicesProperty[m_motu_model-1].mixer->mixer_channels; - if (channels == NULL) { - debugOutput(DEBUG_LEVEL_WARNING, "No channels defined for model %d\n", m_motu_model); - result = false; - } - } - if (result == false) { - return true; - } - - /* Create the top-level matrix mixers */ - fader_mmixer = new ChannelFaderMatrixMixer(*this, "fader"); - result &= m_MixerContainer->addElement(fader_mmixer); - pan_mmixer = new ChannelPanMatrixMixer(*this, "pan"); - result &= m_MixerContainer->addElement(pan_mmixer); - solo_mmixer = new ChannelBinSwMatrixMixer(*this, "solo", - MOTU_CTRL_MASK_SOLO_VALUE, MOTU_CTRL_MASK_SOLO_SETENABLE); - result &= m_MixerContainer->addElement(solo_mmixer); - mute_mmixer = new ChannelBinSwMatrixMixer(*this, "mute", - MOTU_CTRL_MASK_MUTE_VALUE, MOTU_CTRL_MASK_MUTE_SETENABLE); - result &= m_MixerContainer->addElement(mute_mmixer); - - for (bus=0; busn_mixer_buses; bus++) { - fader_mmixer->addRowInfo(buses[bus].name, 0, buses[bus].address); - pan_mmixer->addRowInfo(buses[bus].name, 0, buses[bus].address); - solo_mmixer->addRowInfo(buses[bus].name, 0, buses[bus].address); - mute_mmixer->addRowInfo(buses[bus].name, 0, buses[bus].address); - } - - for (ch=0; chn_mixer_channels; ch++) { - uint32_t flags = channels[ch].flags; - if (flags & MOTU_CTRL_CHANNEL_FADER) - fader_mmixer->addColInfo(channels[ch].name, 0, channels[ch].addr_ofs); - if (flags & MOTU_CTRL_CHANNEL_PAN) - pan_mmixer->addColInfo(channels[ch].name, 0, channels[ch].addr_ofs); - if (flags & MOTU_CTRL_CHANNEL_SOLO) - solo_mmixer->addColInfo(channels[ch].name, 0, channels[ch].addr_ofs); - if (flags & MOTU_CTRL_CHANNEL_MUTE) - mute_mmixer->addColInfo(channels[ch].name, 0, channels[ch].addr_ofs); - flags &= ~(MOTU_CTRL_CHANNEL_FADER|MOTU_CTRL_CHANNEL_PAN|MOTU_CTRL_CHANNEL_SOLO|MOTU_CTRL_CHANNEL_MUTE); - if (flags) { - debugOutput(DEBUG_LEVEL_WARNING, "Control %s: unknown flag bits 0x%08x\n", channels[ch].name, flags); - } - } - - // Single non-matrixed mixer controls get added here. Channel controls are supported - // here, but usually these will be a part of a matrix mixer. - for (i=0; in_mixer_ctrls; i++) { - const struct MixerCtrl *ctrl = &DevicesProperty[m_motu_model-1].mixer->mixer_ctrl[i]; - unsigned int type; - char name[100]; - char label[100]; - - if (ctrl == NULL) { - debugOutput(DEBUG_LEVEL_WARNING, "NULL control at index %d for model %d\n", i, m_motu_model); - continue; - } - type = ctrl->type; - if (type & MOTU_CTRL_CHANNEL_FADER) { - snprintf(name, 100, "%s%s", ctrl->name, "fader"); - snprintf(label,100, "%s%s", ctrl->label,"fader"); - result &= m_MixerContainer->addElement( - new ChannelFader(*this, ctrl->dev_register, name, label, ctrl->desc)); - type &= ~MOTU_CTRL_CHANNEL_FADER; - } - if (type & MOTU_CTRL_CHANNEL_PAN) { - snprintf(name, 100, "%s%s", ctrl->name, "pan"); - snprintf(label,100, "%s%s", ctrl->label,"pan"); - result &= m_MixerContainer->addElement( - new ChannelPan(*this, - ctrl->dev_register, - name, label, - ctrl->desc)); - type &= ~MOTU_CTRL_CHANNEL_PAN; - } - if (type & MOTU_CTRL_CHANNEL_MUTE) { - snprintf(name, 100, "%s%s", ctrl->name, "mute"); - snprintf(label,100, "%s%s", ctrl->label,"mute"); - result &= m_MixerContainer->addElement( - new MotuBinarySwitch(*this, ctrl->dev_register, - MOTU_CTRL_MASK_MUTE_VALUE, MOTU_CTRL_MASK_MUTE_SETENABLE, - name, label, ctrl->desc)); - type &= ~MOTU_CTRL_CHANNEL_MUTE; - } - if (type & MOTU_CTRL_CHANNEL_SOLO) { - snprintf(name, 100, "%s%s", ctrl->name, "solo"); - snprintf(label,100, "%s%s", ctrl->label,"solo"); - result &= m_MixerContainer->addElement( - new MotuBinarySwitch(*this, ctrl->dev_register, - MOTU_CTRL_MASK_SOLO_VALUE, MOTU_CTRL_MASK_SOLO_SETENABLE, - name, label, ctrl->desc)); - type &= ~MOTU_CTRL_CHANNEL_SOLO; - } - - if (type & MOTU_CTRL_MIX_FADER) { - snprintf(name, 100, "%s%s", ctrl->name, "fader"); - snprintf(label,100, "%s%s", ctrl->label,"fader"); - result &= m_MixerContainer->addElement( - new MixFader(*this, ctrl->dev_register, name, label, ctrl->desc)); - type &= ~MOTU_CTRL_MIX_FADER; - } - if (type & MOTU_CTRL_MIX_MUTE) { - snprintf(name, 100, "%s%s", ctrl->name, "mute"); - snprintf(label,100, "%s%s", ctrl->label,"mute"); - result &= m_MixerContainer->addElement( - new MixMute(*this, ctrl->dev_register, name, label, ctrl->desc)); - type &= ~MOTU_CTRL_MIX_MUTE; - } - if (type & MOTU_CTRL_MIX_DEST) { - snprintf(name, 100, "%s%s", ctrl->name, "dest"); - snprintf(label,100, "%s%s", ctrl->label,"dest"); - result &= m_MixerContainer->addElement( - new MixDest(*this, ctrl->dev_register, name, label, ctrl->desc)); - type &= ~MOTU_CTRL_MIX_DEST; - } - - if (type & MOTU_CTRL_INPUT_UL_GAIN) { - snprintf(name, 100, "%s%s", ctrl->name, "trimgain"); - snprintf(label,100, "%s%s", ctrl->label,"trimgain"); - result &= m_MixerContainer->addElement( - new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_UL_GAIN, - name, label, ctrl->desc)); - type &= ~MOTU_CTRL_INPUT_UL_GAIN; - } - if (type & MOTU_CTRL_INPUT_PHASE_INV) { - snprintf(name, 100, "%s%s", ctrl->name, "invert"); - snprintf(label,100, "%s%s", ctrl->label,"invert"); - result &= m_MixerContainer->addElement( - new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_PHASE_INV, - name, label, ctrl->desc)); - type &= ~MOTU_CTRL_INPUT_PHASE_INV; - } - if (type & MOTU_CTRL_INPUT_TRIMGAIN) { - snprintf(name, 100, "%s%s", ctrl->name, "trimgain"); - snprintf(label,100, "%s%s", ctrl->label,"trimgain"); - result &= m_MixerContainer->addElement( - new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_TRIMGAIN, - name, label, ctrl->desc)); - type &= ~MOTU_CTRL_INPUT_TRIMGAIN; - } - if (type & MOTU_CTRL_INPUT_PAD) { - snprintf(name, 100, "%s%s", ctrl->name, "pad"); - snprintf(label,100, "%s%s", ctrl->label,"pad"); - result &= m_MixerContainer->addElement( - new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_PAD, - name, label, ctrl->desc)); - type &= ~MOTU_CTRL_INPUT_PAD; - } - - if (type & MOTU_CTRL_INPUT_LEVEL) { - snprintf(name, 100, "%s%s", ctrl->name, "level"); - snprintf(label,100, "%s%s", ctrl->label,"level"); - result &= m_MixerContainer->addElement( - new MotuBinarySwitch(*this, MOTU_REG_INPUT_LEVEL, - 1<dev_register, 0, name, label, ctrl->desc)); - type &= ~MOTU_CTRL_INPUT_LEVEL; - } - if (type & MOTU_CTRL_INPUT_BOOST) { - snprintf(name, 100, "%s%s", ctrl->name, "boost"); - snprintf(label,100, "%s%s", ctrl->label,"boost"); - result &= m_MixerContainer->addElement( - new MotuBinarySwitch(*this, MOTU_REG_INPUT_BOOST, - 1<dev_register, 0, name, label, ctrl->desc)); - type &= ~MOTU_CTRL_INPUT_BOOST; - } - if (type & MOTU_CTRL_PHONES_SRC) { - snprintf(name, 100, "%s%s", ctrl->name, "src"); - snprintf(label,100, "%s%s", ctrl->label,"src"); - result &= m_MixerContainer->addElement( - new PhonesSrc(*this, name, label, ctrl->desc)); - type &= ~MOTU_CTRL_PHONES_SRC; - } - if (type & MOTU_CTRL_OPTICAL_MODE) { - result &= m_MixerContainer->addElement( - new OpticalMode(*this, ctrl->dev_register, - ctrl->name, ctrl->label, ctrl->desc)); - type &= ~MOTU_CTRL_OPTICAL_MODE; - } - if (type & MOTU_CTRL_METER) { - if (ctrl->dev_register & MOTU_CTRL_METER_PEAKHOLD) { - snprintf(name, 100, "%s%s", ctrl->name, "peakhold_time"); - snprintf(label,100, "%s%s", ctrl->label,"peakhold time"); - result &= m_MixerContainer->addElement( - new MeterControl(*this, MOTU_METER_PEAKHOLD_MASK, - MOTU_METER_PEAKHOLD_SHIFT, name, label, ctrl->desc)); - } - if (ctrl->dev_register & MOTU_CTRL_METER_CLIPHOLD) { - snprintf(name, 100, "%s%s", ctrl->name, "cliphold_time"); - snprintf(label,100, "%s%s", ctrl->label,"cliphold time"); - result &= m_MixerContainer->addElement( - new MeterControl(*this, MOTU_METER_CLIPHOLD_MASK, - MOTU_METER_CLIPHOLD_SHIFT, name, label, ctrl->desc)); - } - if (ctrl->dev_register & MOTU_CTRL_METER_AESEBU_SRC) { - snprintf(name, 100, "%s%s", ctrl->name, "aesebu_src"); - snprintf(label,100, "%s%s", ctrl->label,"AESEBU source"); - result &= m_MixerContainer->addElement( - new MeterControl(*this, MOTU_METER_AESEBU_SRC_MASK, - MOTU_METER_AESEBU_SRC_SHIFT, name, label, ctrl->desc)); - } - if (ctrl->dev_register & MOTU_CTRL_METER_PROG_SRC) { - snprintf(name, 100, "%s%s", ctrl->name, "src"); - snprintf(label,100, "%s%s", ctrl->label,"source"); - result &= m_MixerContainer->addElement( - new MeterControl(*this, MOTU_METER_PROG_SRC_MASK, - MOTU_METER_PROG_SRC_SHIFT, name, label, ctrl->desc)); - } - type &= ~MOTU_CTRL_METER; - } - - if (type) { - debugOutput(DEBUG_LEVEL_WARNING, "Unknown mixer control type flag bits 0x%08x\n", ctrl->type); - } - } - return result; -} - -bool -MotuDevice::buildMixer() { - bool result = true; - - destroyMixer(); - debugOutput(DEBUG_LEVEL_VERBOSE, "Building a MOTU mixer...\n"); - - // create the mixer object container - m_MixerContainer = new Control::Container(this, "Mixer"); - if (!m_MixerContainer) { - debugError("Could not create mixer container...\n"); - return false; - } - - // Create and populate the top-level matrix mixers - result = buildMixerAudioControls(); - - /* Now add some general device information controls. These may yet - * become device-specific if it turns out to be easier that way. - */ - result &= m_MixerContainer->addElement( - new InfoElement(*this, MOTU_INFO_MODEL, "Info/Model", "Model identifier", "")); - result &= m_MixerContainer->addElement( - new InfoElement(*this, MOTU_INFO_IS_STREAMING, "Info/IsStreaming", "Is device streaming", "")); - result &= m_MixerContainer->addElement( - new InfoElement(*this, MOTU_INFO_SAMPLE_RATE, "Info/SampleRate", "Device sample rate", "")); - - if (!addElement(m_MixerContainer)) { - debugWarning("Could not register mixer to device\n"); - // clean up - destroyMixer(); - return false; - } - - // Special controls - m_ControlContainer = new Control::Container(this, "Control"); - if (!m_ControlContainer) { - debugError("Could not create control container...\n"); - destroyMixer(); - return false; - } - - // Special controls get added here - - if (!result) { - debugWarning("One or more device control elements could not be created\n"); - // clean up those that couldn't be created - destroyMixer(); - return false; - } - if (!addElement(m_ControlContainer)) { - debugWarning("Could not register controls to device\n"); - // clean up - destroyMixer(); - return false; - } - - return true; -} - - -bool -MotuDevice::destroyMixer() { - bool ret = true; - debugOutput(DEBUG_LEVEL_VERBOSE, "destroy mixer...\n"); - - if (m_MixerContainer == NULL) { - debugOutput(DEBUG_LEVEL_VERBOSE, "no mixer to destroy...\n"); - } else - if (!deleteElement(m_MixerContainer)) { - debugError("Mixer present but not registered to the avdevice\n"); - ret = false; - } else { - // remove and delete (as in free) child control elements - m_MixerContainer->clearElements(true); - delete m_MixerContainer; - m_MixerContainer = NULL; - } - - // remove control container - if (m_ControlContainer == NULL) { - debugOutput(DEBUG_LEVEL_VERBOSE, "no controls to destroy...\n"); - } else - if (!deleteElement(m_ControlContainer)) { - debugError("Controls present but not registered to the avdevice\n"); - ret = false; - } else { - // remove and delete (as in free) child control elements - m_ControlContainer->clearElements(true); - delete m_ControlContainer; - m_ControlContainer = NULL; - } - return ret; } @@ -1010,7 +475,18 @@ * Retrieve the current sample rate from the MOTU device. */ - quadlet_t q = ReadRegister(MOTU_REG_CLK_CTRL); + quadlet_t q = 0; int rate = 0; + if (m_motu_model == MOTU_MODEL_828MkI) { + /* The original MOTU interfaces did things rather differently */ + q = ReadRegister(MOTU_G1_REG_CONFIG); + if ((q & MOTU_G1_RATE_MASK) == MOTU_G1_RATE_44100) + rate = 44100; + else + rate = 48000; + return rate; + } + + q = ReadRegister(MOTU_REG_CLK_CTRL); switch (q & MOTU_RATE_BASE_MASK) { case MOTU_RATE_BASE_44100: @@ -1057,4 +533,44 @@ if ( samplingFrequency > DevicesProperty[m_motu_model-1].MaxSampleRate ) return false; + + /* The original MOTU devices do things differently; they are much + * simpler than the later interfaces. + */ + if (m_motu_model == MOTU_MODEL_828MkI) { + reg = ReadRegister(MOTU_G1_REG_CONFIG); + if (samplingFrequency > 0) { + reg &= ~MOTU_G1_RATE_MASK; + switch (samplingFrequency) { + case 44100: + reg |= MOTU_G1_RATE_44100; + break; + case 48000: + reg |= MOTU_G1_RATE_48000; + default: + // Unsupported rate + return false; + } + } + if (clock_source != MOTU_CLKSRC_UNCHANGED) { + switch (clock_source) { + case MOTU_CLKSRC_INTERNAL: + clock_source = MOTU_G1_CLKSRC_INTERNAL; break; + case MOTU_CLKSRC_SPDIF_TOSLINK: + clock_source = MOTU_G1_CLKSRC_SPDIF; break; + case MOTU_CLKSRC_ADAT_9PIN: + clock_source = MOTU_G1_CLKSRC_ADAT_9PIN; break; + default: + // Unsupported clock source + return false; + } + reg &= ~MOTU_G1_CLKSRC_MASK; + reg |= clock_source; + } + if (WriteRegister(MOTU_G1_REG_CONFIG, reg) != 0) + return false; + return true; + } + + /* The rest of this function deals with later generation devices */ reg = ReadRegister(MOTU_REG_CLK_CTRL); @@ -1220,4 +736,5 @@ MotuDevice::clockIdToClockSource(unsigned int id) { ClockSource s; + bool g1_model = (m_motu_model == MOTU_MODEL_828MkI); s.id = id; @@ -1235,4 +752,5 @@ s.type = eCT_ADAT; s.description = "ADAT optical"; + s.valid = s.active = s.locked = !g1_model; break; case MOTU_CLKSRC_SPDIF_TOSLINK: @@ -1252,4 +770,5 @@ s.type = eCT_WordClock; s.description = "Wordclock"; + s.valid = s.active = s.locked = !g1_model; break; case MOTU_CLKSRC_ADAT_9PIN: @@ -1260,4 +779,5 @@ s.type = eCT_AES; s.description = "AES/EBU"; + s.valid = s.active = s.locked = !g1_model; break; default: @@ -1563,4 +1083,10 @@ quadlet_t isoctrl = ReadRegister(MOTU_REG_ISOCTRL); + if (m_motu_model == MOTU_MODEL_828MkI) { + // The 828MkI device does this differently. + // To be implemented + return false; + } + // NOTE: this assumes that you have two streams switch (i) { @@ -1614,4 +1140,10 @@ // TODO: connection management: break connection // cfr the start function + + if (m_motu_model == MOTU_MODEL_828MkI) { + // The 828MkI device does this differently. + // To be implemented + return false; + } // NOTE: this assumes that you have two streams @@ -1650,8 +1182,24 @@ unsigned int MotuDevice::getOpticalMode(unsigned int dir) { - unsigned int reg = ReadRegister(MOTU_REG_ROUTE_PORT_CONF); - -debugOutput(DEBUG_LEVEL_VERBOSE, "optical mode: %x %x %x %x\n",dir, reg, reg & MOTU_OPTICAL_IN_MODE_MASK, -reg & MOTU_OPTICAL_OUT_MODE_MASK); + unsigned int reg; + + if (m_motu_model == MOTU_MODEL_828MkI) { + // The early devices used a different register layout. + unsigned int mask, shift; + reg = ReadRegister(MOTU_G1_REG_CONFIG); + mask = (dir==MOTU_DIR_IN)?MOTU_G1_OPT_IN_MODE_MASK:MOTU_G1_OPT_OUT_MODE_MASK; + shift = (dir==MOTU_DIR_IN)?MOTU_G1_OPT_IN_MODE_BIT0:MOTU_G1_OPT_OUT_MODE_BIT0; + switch (reg & mask) { + case MOTU_G1_OPTICAL_OFF: return MOTU_OPTICAL_MODE_OFF; + case MOTU_G1_OPTICAL_TOSLINK: return MOTU_OPTICAL_MODE_TOSLINK; + // MOTU_G1_OPTICAL_OFF and MOTU_G1_OPTICAL_ADAT seem to be + // identical, so currently we don't know how to differentiate + // these two modes. + // case MOTU_G1_OPTICAL_ADAT: return MOTU_OPTICAL_MODE_ADAT; + } + return 0; + } + + reg = ReadRegister(MOTU_REG_ROUTE_PORT_CONF); if (dir == MOTU_DIR_IN) @@ -1662,5 +1210,5 @@ signed int MotuDevice::setOpticalMode(unsigned int dir, unsigned int mode) { - unsigned int reg = ReadRegister(MOTU_REG_ROUTE_PORT_CONF); + unsigned int reg; unsigned int opt_ctrl = 0x0000002; @@ -1670,4 +1218,22 @@ if (m_motu_model==MOTU_MODEL_896HD && mode==MOTU_OPTICAL_MODE_TOSLINK) return -1; + + if (m_motu_model == MOTU_MODEL_828MkI) { + // The earlier MOTUs handle this differently. + unsigned int mask, shift, g1mode = 0; + reg = ReadRegister(MOTU_G1_REG_CONFIG); + mask = (dir==MOTU_DIR_IN)?MOTU_G1_OPT_IN_MODE_MASK:MOTU_G1_OPT_OUT_MODE_MASK; + shift = (dir==MOTU_DIR_IN)?MOTU_G1_OPT_IN_MODE_BIT0:MOTU_G1_OPT_OUT_MODE_BIT0; + switch (mode) { + case MOTU_OPTICAL_MODE_OFF: g1mode = MOTU_G1_OPTICAL_OFF; break; + case MOTU_OPTICAL_MODE_ADAT: g1mode = MOTU_G1_OPTICAL_ADAT; break; + // See comment in getOpticalMode() about mode ambiguity + // case MOTU_OPTICAL_MODE_TOSLINK: g1mode = MOTU_G1_OPTICAL_TOSLINK; break; + } + reg = (reg & ~mask) | (g1mode << shift); + return WriteRegister(MOTU_G1_REG_CONFIG, reg); + } + + reg = ReadRegister(MOTU_REG_ROUTE_PORT_CONF); // Set up the optical control register value according to the current Index: /trunk/libffado/src/motu/motu_mixerdefs.cpp =================================================================== --- /trunk/libffado/src/motu/motu_mixerdefs.cpp (revision 1763) +++ /trunk/libffado/src/motu/motu_mixerdefs.cpp (revision 1763) @@ -0,0 +1,311 @@ +/* + * Copyright (C) 2005-2008 by Pieter Palmers + * Copyright (C) 2005-2009 by Jonathan Woithe + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/* This module contains definitions of mixers on devices which utilise the + * original "pre-Mark3" mixer control protocol. + */ + +#include "motu/motu_avdevice.h" +#include "motu/motu_mixerdefs.h" + +namespace Motu { + +// Mixer registers +const MatrixMixBus MixerBuses_Traveler[] = { + {"Mix 1", 0x4000, }, + {"Mix 2", 0x4100, }, + {"Mix 3", 0x4200, }, + {"Mix 4", 0x4300, }, +}; + +const MatrixMixChannel MixerChannels_Traveler[] = { + {"Analog 1", MOTU_CTRL_STD_CHANNEL, 0x0000, }, + {"Analog 2", MOTU_CTRL_STD_CHANNEL, 0x0004, }, + {"Analog 3", MOTU_CTRL_STD_CHANNEL, 0x0008, }, + {"Analog 4", MOTU_CTRL_STD_CHANNEL, 0x000c, }, + {"Analog 5", MOTU_CTRL_STD_CHANNEL, 0x0010, }, + {"Analog 6", MOTU_CTRL_STD_CHANNEL, 0x0014, }, + {"Analog 7", MOTU_CTRL_STD_CHANNEL, 0x0018, }, + {"Analog 8", MOTU_CTRL_STD_CHANNEL, 0x001c, }, + {"AES/EBU 1", MOTU_CTRL_STD_CHANNEL, 0x0020, }, + {"AES/EBU 2", MOTU_CTRL_STD_CHANNEL, 0x0024, }, + {"SPDIF 1", MOTU_CTRL_STD_CHANNEL, 0x0028, }, + {"SPDIF 2", MOTU_CTRL_STD_CHANNEL, 0x002c, }, + {"ADAT 1", MOTU_CTRL_STD_CHANNEL, 0x0030, }, + {"ADAT 2", MOTU_CTRL_STD_CHANNEL, 0x0034, }, + {"ADAT 3", MOTU_CTRL_STD_CHANNEL, 0x0038, }, + {"ADAT 4", MOTU_CTRL_STD_CHANNEL, 0x003c, }, + {"ADAT 5", MOTU_CTRL_STD_CHANNEL, 0x0040, }, + {"ADAT 6", MOTU_CTRL_STD_CHANNEL, 0x0044, }, + {"ADAT 7", MOTU_CTRL_STD_CHANNEL, 0x0048, }, + {"ADAT 8", MOTU_CTRL_STD_CHANNEL, 0x004c, }, +}; + +const MixerCtrl MixerCtrls_Traveler[] = { + {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, + {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, + {"Mix3/Mix_", "Mix 3 ", "", MOTU_CTRL_STD_MIX, 0x0c28, }, + {"Mix4/Mix_", "Mix 4 ", "", MOTU_CTRL_STD_MIX, 0x0c2c, }, + {"Mainout_", "MainOut ", "", MOTU_CTRL_MIX_FADER, 0x0c0c, }, + {"Phones_", "Phones ", "", MOTU_CTRL_MIX_FADER, 0x0c10, }, + + /* For mic/line input controls, the "register" is the zero-based channel number */ + {"Control/Ana1_", "Analog 1 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 0}, + {"Control/Ana2_", "Analog 2 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 1}, + {"Control/Ana3_", "Analog 3 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 2}, + {"Control/Ana4_", "Analog 4 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 3}, + {"Control/Ana5_", "Analog 5 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 4}, + {"Control/Ana6_", "Analog 6 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 5}, + {"Control/Ana7_", "Analog 7 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 6}, + {"Control/Ana8_", "Analog 8 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 7}, + + /* For phones source control, "register" is currently unused */ + {"Control/Phones_", "Phones source", "", MOTU_CTRL_PHONES_SRC, 0}, + + /* For optical mode controls, the "register" is used to indicate direction */ + {"Control/OpticalIn_mode", "Optical input mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_IN}, + {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_OUT}, +}; + +const MatrixMixBus MixerBuses_Ultralite[] = { + {"Mix 1", 0x4000, }, + {"Mix 2", 0x4100, }, + {"Mix 3", 0x4200, }, + {"Mix 4", 0x4300, }, +}; + +const MatrixMixChannel MixerChannels_Ultralite[] = { + {"Analog 1", MOTU_CTRL_STD_CHANNEL, 0x0000, }, + {"Analog 2", MOTU_CTRL_STD_CHANNEL, 0x0004, }, + {"Analog 3", MOTU_CTRL_STD_CHANNEL, 0x0008, }, + {"Analog 4", MOTU_CTRL_STD_CHANNEL, 0x000c, }, + {"Analog 5", MOTU_CTRL_STD_CHANNEL, 0x0010, }, + {"Analog 6", MOTU_CTRL_STD_CHANNEL, 0x0014, }, + {"Analog 7", MOTU_CTRL_STD_CHANNEL, 0x0018, }, + {"Analog 8", MOTU_CTRL_STD_CHANNEL, 0x001c, }, + {"AES/EBU 1", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, + {"AES/EBU 2", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, + {"SPDIF 1", MOTU_CTRL_STD_CHANNEL, 0x0020, }, + {"SPDIF 2", MOTU_CTRL_STD_CHANNEL, 0x0024, }, + {"ADAT 1", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, + {"ADAT 2", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, + {"ADAT 3", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, + {"ADAT 4", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, + {"ADAT 5", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, + {"ADAT 6", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, + {"ADAT 7", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, + {"ADAT 8", MOTU_CTRL_STD_CHANNEL, MOTU_CTRL_NONE, }, +}; + +const MixerCtrl MixerCtrls_Ultralite[] = { + {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, + {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, + {"Mix3/Mix_", "Mix 3 ", "", MOTU_CTRL_STD_MIX, 0x0c28, }, + {"Mix4/Mix_", "Mix 4 ", "", MOTU_CTRL_STD_MIX, 0x0c2c, }, + {"Mainout_", "MainOut ", "", MOTU_CTRL_MIX_FADER, 0x0c0c, }, + {"Phones_", "Phones ", "", MOTU_CTRL_MIX_FADER, 0x0c10, }, + + /* For mic/line input controls, the "register" is the zero-based channel number */ + {"Control/Ana1_", "Analog 1 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 0}, + {"Control/Ana2_", "Analog 2 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 1}, + {"Control/Ana3_", "Analog 3 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 2}, + {"Control/Ana4_", "Analog 4 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 3}, + {"Control/Ana5_", "Analog 5 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 4}, + {"Control/Ana6_", "Analog 6 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 5}, + {"Control/Ana7_", "Analog 7 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 6}, + {"Control/Ana8_", "Analog 8 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 7}, + {"Control/Spdif1_", "SPDIF 1 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 6}, + {"Control/Spdif2_", "SPDIF 2 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 7}, + + /* For phones source control, "register" is currently unused */ + {"Control/Phones_", "Phones source", "", MOTU_CTRL_PHONES_SRC, 0}, + + /* For optical mode controls, the "register" is used to indicate direction */ + {"Control/OpticalIn_mode", "Optical input mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_IN}, + {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_OUT}, +}; + +const MatrixMixBus MixerBuses_896HD[] = { + {"Mix 1", 0x4000, }, + {"Mix 2", 0x4100, }, + {"Mix 3", 0x4200, }, + {"Mix 4", 0x4300, }, +}; + +const MatrixMixChannel MixerChannels_896HD[] = { + {"Analog 1", MOTU_CTRL_STD_CHANNEL, 0x0000, }, + {"Analog 2", MOTU_CTRL_STD_CHANNEL, 0x0004, }, + {"Analog 3", MOTU_CTRL_STD_CHANNEL, 0x0008, }, + {"Analog 4", MOTU_CTRL_STD_CHANNEL, 0x000c, }, + {"Analog 5", MOTU_CTRL_STD_CHANNEL, 0x0010, }, + {"Analog 6", MOTU_CTRL_STD_CHANNEL, 0x0014, }, + {"Analog 7", MOTU_CTRL_STD_CHANNEL, 0x0018, }, + {"Analog 8", MOTU_CTRL_STD_CHANNEL, 0x001c, }, + {"AES/EBU 1", MOTU_CTRL_STD_CHANNEL, 0x0020, }, + {"AES/EBU 2", MOTU_CTRL_STD_CHANNEL, 0x0024, }, + {"SPDIF 1", MOTU_CTRL_STD_CHANNEL, 0x0048, }, + {"SPDIF 2", MOTU_CTRL_STD_CHANNEL, 0x004c, }, + {"ADAT 1", MOTU_CTRL_STD_CHANNEL, 0x0028, }, + {"ADAT 2", MOTU_CTRL_STD_CHANNEL, 0x002c, }, + {"ADAT 3", MOTU_CTRL_STD_CHANNEL, 0x0030, }, + {"ADAT 4", MOTU_CTRL_STD_CHANNEL, 0x0034, }, + {"ADAT 5", MOTU_CTRL_STD_CHANNEL, 0x0038, }, + {"ADAT 6", MOTU_CTRL_STD_CHANNEL, 0x003c, }, + {"ADAT 7", MOTU_CTRL_STD_CHANNEL, 0x0040, }, + {"ADAT 8", MOTU_CTRL_STD_CHANNEL, 0x0044, }, +}; + +const MixerCtrl MixerCtrls_896HD[] = { + {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, + {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, + {"Mix3/Mix_", "Mix 3 ", "", MOTU_CTRL_STD_MIX, 0x0c28, }, + {"Mix4/Mix_", "Mix 4 ", "", MOTU_CTRL_STD_MIX, 0x0c2c, }, + {"Mainout_", "MainOut ", "", MOTU_CTRL_MIX_FADER, 0x0c0c, }, + {"Phones_", "Phones ", "", MOTU_CTRL_MIX_FADER, 0x0c10, }, + + /* For phones source control, "register" is currently unused */ + {"Control/Phones_", "Phones source", "", MOTU_CTRL_PHONES_SRC, 0}, + + /* For optical mode controls, the "register" is used to indicate direction */ + {"Control/OpticalIn_mode", "Optical input mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_IN}, + {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_OUT}, + + /* For meter controls the "register" indicates which meter controls are available */ + {"Control/Meter_", "Meter ", "", MOTU_CTRL_METER, + MOTU_CTRL_METER_PEAKHOLD | MOTU_CTRL_METER_CLIPHOLD | MOTU_CTRL_METER_AESEBU_SRC | + MOTU_CTRL_METER_PROG_SRC}, +}; + +const MatrixMixBus MixerBuses_828Mk2[] = { + {"Mix 1", 0x4000, }, + {"Mix 2", 0x4100, }, + {"Mix 3", 0x4200, }, + {"Mix 4", 0x4300, }, +}; + +const MatrixMixChannel MixerChannels_828Mk2[] = { + {"Analog 1", MOTU_CTRL_STD_CHANNEL, 0x0000, }, + {"Analog 2", MOTU_CTRL_STD_CHANNEL, 0x0004, }, + {"Analog 3", MOTU_CTRL_STD_CHANNEL, 0x0008, }, + {"Analog 4", MOTU_CTRL_STD_CHANNEL, 0x000c, }, + {"Analog 5", MOTU_CTRL_STD_CHANNEL, 0x0010, }, + {"Analog 6", MOTU_CTRL_STD_CHANNEL, 0x0014, }, + {"Analog 7", MOTU_CTRL_STD_CHANNEL, 0x0018, }, + {"Analog 8", MOTU_CTRL_STD_CHANNEL, 0x001c, }, + {"Mic 1", MOTU_CTRL_STD_CHANNEL, 0x0020, }, + {"Mic 2", MOTU_CTRL_STD_CHANNEL, 0x0024, }, + {"SPDIF 1", MOTU_CTRL_STD_CHANNEL, 0x0028, }, + {"SPDIF 2", MOTU_CTRL_STD_CHANNEL, 0x002c, }, + {"ADAT 1", MOTU_CTRL_STD_CHANNEL, 0x0030, }, + {"ADAT 2", MOTU_CTRL_STD_CHANNEL, 0x0034, }, + {"ADAT 3", MOTU_CTRL_STD_CHANNEL, 0x0038, }, + {"ADAT 4", MOTU_CTRL_STD_CHANNEL, 0x003c, }, + {"ADAT 5", MOTU_CTRL_STD_CHANNEL, 0x0040, }, + {"ADAT 6", MOTU_CTRL_STD_CHANNEL, 0x0044, }, + {"ADAT 7", MOTU_CTRL_STD_CHANNEL, 0x0048, }, + {"ADAT 8", MOTU_CTRL_STD_CHANNEL, 0x004c, }, +}; + +const MixerCtrl MixerCtrls_828Mk2[] = { + {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, + {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, + {"Mix3/Mix_", "Mix 3 ", "", MOTU_CTRL_STD_MIX, 0x0c28, }, + {"Mix4/Mix_", "Mix 4 ", "", MOTU_CTRL_STD_MIX, 0x0c2c, }, + {"Mainout_", "MainOut ", "", MOTU_CTRL_MIX_FADER, 0x0c0c, }, + {"Phones_", "Phones ", "", MOTU_CTRL_MIX_FADER, 0x0c10, }, + + /* For mic/line input controls, the "register" is the zero-based channel number */ + {"Control/Ana1_", "Analog 1 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 0}, + {"Control/Ana2_", "Analog 2 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 1}, + {"Control/Ana3_", "Analog 3 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 2}, + {"Control/Ana4_", "Analog 4 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 3}, + {"Control/Ana5_", "Analog 5 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 4}, + {"Control/Ana6_", "Analog 6 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 5}, + {"Control/Ana7_", "Analog 7 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 6}, + {"Control/Ana8_", "Analog 8 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 7}, + + /* For phones source control, "register" is currently unused */ + {"Control/Phones_", "Phones source", "", MOTU_CTRL_PHONES_SRC, 0}, + + /* For optical mode controls, the "register" is used to indicate direction */ + {"Control/OpticalIn_mode", "Optical input mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_IN}, + {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_OUT}, +}; + +const MatrixMixBus MixerBuses_8pre[] = { + {"Mix 1", 0x4000, }, + {"Mix 2", 0x4100, }, + {"Mix 3", 0x4200, }, + {"Mix 4", 0x4300, }, +}; + +const MatrixMixChannel MixerChannels_8pre[] = { + {"Analog 1", MOTU_CTRL_STD_CHANNEL, 0x0000, }, + {"Analog 2", MOTU_CTRL_STD_CHANNEL, 0x0004, }, + {"Analog 3", MOTU_CTRL_STD_CHANNEL, 0x0008, }, + {"Analog 4", MOTU_CTRL_STD_CHANNEL, 0x000c, }, + {"Analog 5", MOTU_CTRL_STD_CHANNEL, 0x0010, }, + {"Analog 6", MOTU_CTRL_STD_CHANNEL, 0x0014, }, + {"Analog 7", MOTU_CTRL_STD_CHANNEL, 0x0018, }, + {"Analog 8", MOTU_CTRL_STD_CHANNEL, 0x001c, }, + {"ADAT 1", MOTU_CTRL_STD_CHANNEL, 0x0020, }, + {"ADAT 2", MOTU_CTRL_STD_CHANNEL, 0x0024, }, + {"ADAT 3", MOTU_CTRL_STD_CHANNEL, 0x0028, }, + {"ADAT 4", MOTU_CTRL_STD_CHANNEL, 0x002c, }, + {"ADAT 5", MOTU_CTRL_STD_CHANNEL, 0x0030, }, + {"ADAT 6", MOTU_CTRL_STD_CHANNEL, 0x0034, }, + {"ADAT 7", MOTU_CTRL_STD_CHANNEL, 0x0038, }, + {"ADAT 8", MOTU_CTRL_STD_CHANNEL, 0x003c, }, +}; + +const MixerCtrl MixerCtrls_8pre[] = { + {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, + {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, + {"Mix3/Mix_", "Mix 3 ", "", MOTU_CTRL_STD_MIX, 0x0c28, }, + {"Mix4/Mix_", "Mix 4 ", "", MOTU_CTRL_STD_MIX, 0x0c2c, }, + + /* For phones source control, "register" is currently unused */ + {"Control/Phones_", "Phones source", "", MOTU_CTRL_PHONES_SRC, 0}, + + /* For optical mode controls, the "register" is used to indicate direction */ + {"Control/OpticalIn_mode", "Optical input mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_IN}, + {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_CTRL_DIR_OUT}, +}; + +const MotuMixer Mixer_Traveler = MOTUMIXER( + MixerCtrls_Traveler, MixerBuses_Traveler, MixerChannels_Traveler); + +const MotuMixer Mixer_Ultralite = MOTUMIXER( + MixerCtrls_Ultralite, MixerBuses_Ultralite, MixerChannels_Ultralite); + +const MotuMixer Mixer_828Mk2 = MOTUMIXER( + MixerCtrls_828Mk2, MixerBuses_828Mk2, MixerChannels_828Mk2); + +const MotuMixer Mixer_896HD = MOTUMIXER( + MixerCtrls_896HD, MixerBuses_896HD, MixerChannels_896HD); + +const MotuMixer Mixer_8pre = MOTUMIXER( + MixerCtrls_8pre, MixerBuses_8pre, MixerChannels_8pre); + +} Index: /trunk/libffado/src/motu/motu_controls.h =================================================================== --- /trunk/libffado/src/motu/motu_controls.h (revision 1742) +++ /trunk/libffado/src/motu/motu_controls.h (revision 1763) @@ -23,4 +23,6 @@ * */ + +/* DBus controls used with devices which utilise a pre-Mark3 mixer interface */ #include "debugmodule/debugmodule.h" Index: /trunk/libffado/src/motu/motu_mark3_mixerdefs.h =================================================================== --- /trunk/libffado/src/motu/motu_mark3_mixerdefs.h (revision 1763) +++ /trunk/libffado/src/motu/motu_mark3_mixerdefs.h (revision 1763) @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2005-2008 by Pieter Palmers + * Copyright (C) 2005-2009 by Jonathan Woithe + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/* Provide access to mixer details for devices which utilise the "Mark3" + * mixer control protocol. + */ + +#ifndef MOTU_MARK3_MIXERDEFS_H +#define MOTU_MARK3_MIXERDEFS_H + +#include "motu/motu_avdevice.h" + +namespace Motu { + +} + +#endif Index: /trunk/libffado/src/SConscript =================================================================== --- /trunk/libffado/src/SConscript (revision 1747) +++ /trunk/libffado/src/SConscript (revision 1763) @@ -150,4 +150,8 @@ motu/motu_avdevice.cpp \ motu/motu_controls.cpp \ + motu/motu_mark3_controls.cpp \ + motu/motu_mixerdefs.cpp \ + motu/motu_mark3_mixerdefs.cpp \ + motu/motu_mixer.cpp \ libstreaming/motu/MotuPort.cpp \ libstreaming/motu/MotuPortInfo.cpp \ Index: /trunk/libffado/src/DeviceStringParser.h =================================================================== --- /trunk/libffado/src/DeviceStringParser.h (revision 1568) +++ /trunk/libffado/src/DeviceStringParser.h (revision 1763) @@ -75,4 +75,5 @@ bool match(ConfigRom &); + int matchPosition(ConfigRom& c); bool parseString(std::string s); Index: /trunk/libffado/src/debugmodule/debugmodule.h =================================================================== --- /trunk/libffado/src/debugmodule/debugmodule.h (revision 1568) +++ /trunk/libffado/src/debugmodule/debugmodule.h (revision 1763) @@ -302,5 +302,9 @@ void printShort( debug_level_t level, const char* format, - ... ) const; + ... ) const +#ifdef __GNUC__ + __attribute__((format(printf, 3, 4))) +#endif + ; void print( debug_level_t level, @@ -309,5 +313,9 @@ unsigned int line, const char* format, - ... ) const; + ... ) const +#ifdef __GNUC__ + __attribute__((format(printf, 6, 7))) +#endif + ; bool setLevel( debug_level_t level ) Index: /trunk/libffado/src/debugmodule/debugmodule.cpp =================================================================== --- /trunk/libffado/src/debugmodule/debugmodule.cpp (revision 1713) +++ /trunk/libffado/src/debugmodule/debugmodule.cpp (revision 1763) @@ -185,5 +185,5 @@ int chars_written=0; int retval=0; - retval = snprintf(msg, MB_BUFFERSIZE, "%011llu: %s (%s)[%4d] %s: ", + retval = snprintf(msg, MB_BUFFERSIZE, "%011"PRIu64": %s (%s)[%4u] %s: ", ts_usec, getPreSequence( level ), fname, line, function ); Index: /trunk/libffado/src/libavc/descriptors/avc_descriptor.cpp =================================================================== --- /trunk/libffado/src/libavc/descriptors/avc_descriptor.cpp (revision 1254) +++ /trunk/libffado/src/libavc/descriptors/avc_descriptor.cpp (revision 1763) @@ -249,10 +249,12 @@ // copy the payload - if (bytes_read+readDescCmd.m_data_length>m_descriptor_length) { + if (bytes_read + readDescCmd.m_data_length > m_descriptor_length) { debugWarning("Device returned too much data, truncating\n"); readDescCmd.m_data_length=m_descriptor_length-bytes_read; } - debugOutput(DEBUG_LEVEL_VERBOSE, " copying %u bytes to internal buffer offset %u\n",readDescCmd.m_data_length, bytes_read); + debugOutput(DEBUG_LEVEL_VERBOSE, + " copying %u bytes to internal buffer offset %zd\n", + readDescCmd.m_data_length, bytes_read); memcpy(m_data+bytes_read,readDescCmd.m_data, readDescCmd.m_data_length); Index: /trunk/libffado/src/libavc/descriptors/avc_descriptor_cmd.cpp =================================================================== --- /trunk/libffado/src/libavc/descriptors/avc_descriptor_cmd.cpp (revision 1234) +++ /trunk/libffado/src/libavc/descriptors/avc_descriptor_cmd.cpp (revision 1763) @@ -120,5 +120,5 @@ break; default: - debugError("Can't handle command type %s\n", getCommandType()); + debugError("Can't handle command type %d\n", getCommandType()); return false; } Index: /trunk/libffado/src/libavc/audiosubunit/avc_descriptor_audio.h =================================================================== --- /trunk/libffado/src/libavc/audiosubunit/avc_descriptor_audio.h (revision 1538) +++ /trunk/libffado/src/libavc/audiosubunit/avc_descriptor_audio.h (revision 1763) @@ -43,9 +43,13 @@ class Ieee1394Service; +// forward declarations +namespace Util { + namespace Cmd { + class IOSSerialize; + class IISDeserialize; + } +} + namespace AVC { - - -class Util::Cmd::IOSSerialize; -class Util::Cmd::IISDeserialize; class AVCAudioClusterInformation Index: /trunk/libffado/src/libavc/general/avc_plug.cpp =================================================================== --- /trunk/libffado/src/libavc/general/avc_plug.cpp (revision 1568) +++ /trunk/libffado/src/libavc/general/avc_plug.cpp (revision 1763) @@ -1423,7 +1423,4 @@ case eAPD_Output: return string("Output"); - default: - case eAPT_Unknown: - return string("Unknown"); } } Index: /trunk/libffado/src/fbtypes.h =================================================================== --- /trunk/libffado/src/fbtypes.h (revision 1336) +++ /trunk/libffado/src/fbtypes.h (revision 1763) @@ -25,4 +25,9 @@ #define FBTYPES_H +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif +#include + #include @@ -35,4 +40,8 @@ typedef nodeaddr_t fb_nodeaddr_t; +#define FORMAT_FB_OCTLET_T "0x%016" PRIX64 +#define FORMAT_FB_NODEID_T "0x%016" PRIX64 +#define FORMAT_FB_NODEADDR_T "0x%016" PRIX64 + class DeviceManager; Index: /trunk/libffado/src/dice/dice_eap.cpp =================================================================== --- /trunk/libffado/src/dice/dice_eap.cpp (revision 1742) +++ /trunk/libffado/src/dice/dice_eap.cpp (revision 1763) @@ -676,5 +676,5 @@ // out-of-range check if(length > maxlen) { - debugError("requested length too large: %d > %d\n", length, maxlen); + debugError("requested length too large: %zd > %"PRIu64"\n", length, maxlen); return DICE_INVALID_OFFSET; } @@ -827,5 +827,5 @@ m_input_route_map[i] = rcfg->getRouteForDestination(dest, ch); - debugOutput(DEBUG_LEVEL_VERBOSE, "Mixer input channel %2d source: %s\n", i, + debugOutput(DEBUG_LEVEL_VERBOSE, "Mixer input channel %2d source: %s (%d)\n", i, srcBlockToString(m_input_route_map[i].src), m_input_route_map[i].srcChannel); @@ -1978,5 +1978,5 @@ return false; } - debugOutput(DEBUG_LEVEL_VERBOSE, " Entries: TX: %lu, RX: %lu\n", m_nb_tx, m_nb_rx); + debugOutput(DEBUG_LEVEL_VERBOSE, " Entries: TX: %u, RX: %u\n", m_nb_tx, m_nb_rx); if(m_tx_configs) { @@ -2070,5 +2070,5 @@ Device::EAP::StreamConfig::showConfigBlock(struct ConfigBlock &b) { - debugOutput(DEBUG_LEVEL_VERBOSE, " Channel count : %lu audio, %lu midi\n", b.nb_audio, b.nb_midi); + debugOutput(DEBUG_LEVEL_VERBOSE, " Channel count : %u audio, %u midi\n", b.nb_audio, b.nb_midi); debugOutput(DEBUG_LEVEL_VERBOSE, " AC3 Map : 0x%08X\n", b.ac3_map); diceNameVector channel_names = getNamesForBlock(b); Index: /trunk/libffado/src/dice/dice_avdevice.cpp =================================================================== --- /trunk/libffado/src/dice/dice_avdevice.cpp (revision 1727) +++ /trunk/libffado/src/dice/dice_avdevice.cpp (revision 1763) @@ -376,5 +376,5 @@ readGlobalReg(DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, &clock_caps); uint16_t clocks_supported = (clock_caps >> 16) & 0xFFFF; - debugOutput(DEBUG_LEVEL_VERBOSE," Clock caps: 0x%08X, supported=0x%04X\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Clock caps: 0x%08"PRIX32", supported=0x%04X\n", clock_caps, clocks_supported); @@ -382,5 +382,5 @@ readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &clock_select); byte_t clock_selected = (clock_select) & 0xFF; - debugOutput(DEBUG_LEVEL_VERBOSE," Clock select: 0x%08X, selected=0x%04X\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Clock select: 0x%08"PRIX32", selected=0x%04X\n", clock_select, clock_selected); quadlet_t extended_status; @@ -389,5 +389,5 @@ uint16_t clock_status = (extended_status) & 0xFFFF; uint16_t clock_slipping = (extended_status >> 16) & 0xFFFF; - debugOutput(DEBUG_LEVEL_VERBOSE," Clock status: 0x%08X, status=0x%04X, slip=0x%04X\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Clock status: 0x%08"PRIX32", status=0x%04X, slip=0x%04X\n", extended_status, clock_status, clock_slipping); #endif @@ -540,5 +540,5 @@ readGlobalReg(DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, &clock_caps); uint16_t clocks_supported = (clock_caps >> 16) & 0xFFFF; - debugOutput(DEBUG_LEVEL_VERBOSE," Clock caps: 0x%08X, supported=0x%04X\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Clock caps: 0x%08"PRIX32", supported=0x%04X\n", clock_caps, clocks_supported); @@ -546,5 +546,5 @@ readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &clock_select); byte_t id = (clock_select) & 0xFF; - debugOutput(DEBUG_LEVEL_VERBOSE," Clock select: 0x%08X, selected=0x%04X\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Clock select: 0x%08"PRIX32", selected=0x%04X\n", clock_select, id); quadlet_t extended_status; @@ -553,5 +553,5 @@ uint16_t clock_status = (extended_status) & 0xFFFF; uint16_t clock_slipping = (extended_status >> 16) & 0xFFFF; - debugOutput(DEBUG_LEVEL_VERBOSE," Clock status: 0x%08X, status=0x%04X, slip=0x%04X\n", + debugOutput(DEBUG_LEVEL_VERBOSE," Clock status: 0x%08"PRIX32", status=0x%04X, slip=0x%04X\n", extended_status, clock_status, clock_slipping); #endif @@ -610,8 +610,8 @@ readGlobalRegBlock(DICE_REGISTER_GLOBAL_OWNER, reinterpret_cast(&tmp_octlet), sizeof(fb_octlet_t)); - debugOutput(DEBUG_LEVEL_VERBOSE," Owner : 0x%016X\n",tmp_octlet); + debugOutput(DEBUG_LEVEL_VERBOSE," Owner : 0x%016"PRIX64"\n",tmp_octlet); readGlobalReg(DICE_REGISTER_GLOBAL_NOTIFICATION, &tmp_quadlet); - debugOutput(DEBUG_LEVEL_VERBOSE," Notification : 0x%08X\n",tmp_quadlet); + debugOutput(DEBUG_LEVEL_VERBOSE," Notification : 0x%08"PRIX32"\n",tmp_quadlet); readGlobalReg(DICE_REGISTER_GLOBAL_NOTIFICATION, &tmp_quadlet); @@ -631,14 +631,14 @@ readGlobalReg(DICE_REGISTER_GLOBAL_EXTENDED_STATUS, &tmp_quadlet); - debugOutput(DEBUG_LEVEL_VERBOSE," Extended Status : 0x%08X\n",tmp_quadlet); + debugOutput(DEBUG_LEVEL_VERBOSE, " Extended Status : 0x%08"PRIX32"\n", tmp_quadlet); readGlobalReg(DICE_REGISTER_GLOBAL_SAMPLE_RATE, &tmp_quadlet); - debugOutput(DEBUG_LEVEL_NORMAL," Samplerate : 0x%08X (%lu)\n",tmp_quadlet,tmp_quadlet); + debugOutput(DEBUG_LEVEL_NORMAL, " Samplerate : 0x%08"PRIX32" (%"PRIu32")\n", tmp_quadlet, tmp_quadlet); readGlobalRegBlock(DICE_REGISTER_GLOBAL_VERSION, reinterpret_cast(&tmp_quadlet), sizeof(fb_quadlet_t)); - debugOutput(DEBUG_LEVEL_NORMAL," Version : 0x%08X\n", tmp_quadlet); + debugOutput(DEBUG_LEVEL_NORMAL," Version : 0x%08"PRIX32"\n", tmp_quadlet); readGlobalReg(DICE_REGISTER_GLOBAL_VERSION, &tmp_quadlet); - debugOutput(DEBUG_LEVEL_NORMAL," Version : 0x%08X (%u.%u.%u.%u)\n", + debugOutput(DEBUG_LEVEL_NORMAL," Version : 0x%08"PRIX32" (%u.%u.%u.%u)\n", tmp_quadlet, DICE_DRIVER_SPEC_VERSION_NUMBER_GET_A(tmp_quadlet), @@ -649,5 +649,5 @@ readGlobalReg(DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, &tmp_quadlet); - debugOutput(DEBUG_LEVEL_VERBOSE," Clock caps : 0x%08X\n",tmp_quadlet); + debugOutput(DEBUG_LEVEL_VERBOSE," Clock caps : 0x%08"PRIX32"\n", tmp_quadlet); diceNameVector names=getClockSourceNameString(); @@ -677,7 +677,7 @@ readTxReg(i, DICE_REGISTER_TX_AC3_CAPABILITIES_BASE, &tmp_quadlet); - debugOutput(DEBUG_LEVEL_VERBOSE," AC3 caps : 0x%08X\n", tmp_quadlet); + debugOutput(DEBUG_LEVEL_VERBOSE," AC3 caps : 0x%08"PRIX32"\n", tmp_quadlet); readTxReg(i, DICE_REGISTER_TX_AC3_ENABLE_BASE, &tmp_quadlet); - debugOutput(DEBUG_LEVEL_VERBOSE," AC3 enable : 0x%08X\n", tmp_quadlet); + debugOutput(DEBUG_LEVEL_VERBOSE," AC3 enable : 0x%08"PRIX32"\n", tmp_quadlet); diceNameVector channel_names=getTxNameString(i); @@ -707,7 +707,7 @@ readTxReg(i, DICE_REGISTER_RX_AC3_CAPABILITIES_BASE, &tmp_quadlet); - debugOutput(DEBUG_LEVEL_VERBOSE," AC3 caps : 0x%08X\n", tmp_quadlet); + debugOutput(DEBUG_LEVEL_VERBOSE," AC3 caps : 0x%08"PRIX32"\n", tmp_quadlet); readTxReg(i, DICE_REGISTER_RX_AC3_ENABLE_BASE, &tmp_quadlet); - debugOutput(DEBUG_LEVEL_VERBOSE," AC3 enable : 0x%08X\n", tmp_quadlet); + debugOutput(DEBUG_LEVEL_VERBOSE," AC3 enable : 0x%08"PRIX32"\n", tmp_quadlet); diceNameVector channel_names=getRxNameString(i); @@ -1132,5 +1132,5 @@ if (result != DICE_OWNER_NO_OWNER) { - debugWarning("Could not register ourselves as device owner, unexpected register value: 0x%016llX\n", result); + debugWarning("Could not register ourselves as device owner, unexpected register value: 0x%016"PRIX64"\n", result); return false; } @@ -1260,5 +1260,7 @@ } int isochannel = reg_isoch; - debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Snooping RX from channel %d\n", isochannel); + debugOutput(DEBUG_LEVEL_VERBOSE, + "(%p) Snooping RX from channel %d\n", + this, isochannel); p->setChannel(isochannel); } else { @@ -1266,8 +1268,10 @@ int isochannel = allocateIsoChannel(p->getMaxPacketSize()); if(isochannel<0) { - debugError("Could not allocate iso channel for SP %d (ATX %d)\n",i,n); + debugError("Could not allocate iso channel for SP %d (ATX %d)\n", i, n); return false; } - debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Allocated channel %lu for RX\n", isochannel); + debugOutput(DEBUG_LEVEL_VERBOSE, + "(%p) Allocated channel %u for RX\n", + this, isochannel); p->setChannel(isochannel); @@ -1281,5 +1285,5 @@ } if(reg_isoch != 0xFFFFFFFFUL) { - debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08X) for ATX %d\n", reg_isoch, n); + debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08"PRIX32") for ATX %d\n", reg_isoch, n); p->setChannel(-1); deallocateIsoChannel(isochannel); @@ -1311,5 +1315,5 @@ } int isochannel = reg_isoch; - debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Snooping TX from channel %d\n", isochannel); + debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Snooping TX from channel %d\n", this, isochannel); p->setChannel(isochannel); } else { @@ -1320,5 +1324,5 @@ return false; } - debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Allocated channel %lu for TX\n", isochannel); + debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Allocated channel %u for TX\n", this, isochannel); p->setChannel(isochannel); @@ -1332,5 +1336,5 @@ } if(reg_isoch != 0xFFFFFFFFUL) { - debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08X) for ARX %d\n", reg_isoch, n); + debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08"PRIX32") for ARX %d\n", reg_isoch, n); p->setChannel(-1); deallocateIsoChannel(isochannel); @@ -1381,5 +1385,5 @@ } if(reg_isoch != isochannel) { - debugError("ISO_CHANNEL register != 0x%08X (=0x%08X) for ATX %d\n", isochannel, reg_isoch, n); + debugError("ISO_CHANNEL register != 0x%08"PRIX32" (=0x%08"PRIX32") for ATX %d\n", isochannel, reg_isoch, n); return false; } @@ -1417,5 +1421,5 @@ } if(reg_isoch != isochannel) { - debugError("ISO_CHANNEL register != 0x%08X (=0x%08X) for ARX %d\n", isochannel, reg_isoch, n); + debugError("ISO_CHANNEL register != 0x%08"PRIX32" (=0x%08"PRIX32") for ARX %d\n", isochannel, reg_isoch, n); return false; } @@ -1734,8 +1738,8 @@ bool Device::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX\n", offset); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08"PRIX64"\n", offset); if(offset >= DICE_INVALID_OFFSET) { - debugError("invalid offset: 0x%016llX\n", offset); + debugError("invalid offset: 0x%016"PRIX64"\n", offset); return false; } @@ -1745,5 +1749,5 @@ if(!get1394Service().read_quadlet( nodeId, addr, result ) ) { - debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); + debugError("Could not read from node 0x%04X addr 0x%12"PRIX64"\n", nodeId, addr); return false; } @@ -1751,5 +1755,5 @@ *result = CondSwapFromBus32(*result); - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", *result); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08"PRIX32"\n", *result); return true; @@ -1758,9 +1762,9 @@ bool Device::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08"PRIX64", data: 0x%08"PRIX32"\n", offset, data); if(offset >= DICE_INVALID_OFFSET) { - debugError("invalid offset: 0x%016llX\n", offset); + debugError("invalid offset: 0x%012"PRIX64"\n", offset); return false; } @@ -1770,5 +1774,5 @@ if(!get1394Service().write_quadlet( nodeId, addr, CondSwapToBus32(data) ) ) { - debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); + debugError("Could not write to node 0x%04X addr 0x%12"PRIX64"\n", nodeId, addr); return false; } @@ -1778,10 +1782,11 @@ bool Device::readRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { - debugOutput(DEBUG_LEVEL_VERBOSE,"Reading base register offset 0x%08llX, length %u, to %p\n", - offset, length, data); + debugOutput(DEBUG_LEVEL_VERBOSE, + "Reading base register offset 0x%08"PRIX64", length %zd, to %p\n", + offset, length, data); const int blocksize_quads = 512/4; if(offset >= DICE_INVALID_OFFSET) { - debugError("invalid offset: 0x%016llX\n", offset); + debugError("invalid offset: 0x%012"PRIX64"\n", offset); return false; } @@ -1796,5 +1801,5 @@ fb_quadlet_t *curr_data = data + quads_done; int quads_todo = length_quads - quads_done; - debugOutput(DEBUG_LEVEL_VERBOSE, "reading addr: 0x%016llX, %d quads to %p\n", curr_addr, quads_todo, curr_data); + debugOutput(DEBUG_LEVEL_VERBOSE, "reading addr: 0x%012"PRIX64", %d quads to %p\n", curr_addr, quads_todo, curr_data); if (quads_todo > blocksize_quads) { @@ -1809,5 +1814,5 @@ if(!get1394Service().read( nodeId, curr_addr, quads_todo, curr_data ) ) { - debugError("Could not read %d quadlets from node 0x%04X addr 0x%012llX\n", quads_todo, nodeId, curr_addr); + debugError("Could not read %d quadlets from node 0x%04X addr 0x%012"PRIX64"\n", quads_todo, nodeId, curr_addr); return false; } @@ -1821,10 +1826,10 @@ bool Device::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08"PRIX64", length: %zd\n", offset, length); const int blocksize_quads = 512/4; if(offset >= DICE_INVALID_OFFSET) { - debugError("invalid offset: 0x%016llX\n", offset); + debugError("invalid offset: 0x%012"PRIX64"\n", offset); return false; } @@ -1853,5 +1858,5 @@ if(!get1394Service().write( nodeId, addr, quads_todo, curr_data ) ) { - debugError("Could not write %d quadlets to node 0x%04X addr 0x%012llX\n", quads_todo, nodeId, curr_addr); + debugError("Could not write %d quadlets to node 0x%04X addr 0x%012"PRIX64"\n", quads_todo, nodeId, curr_addr); return false; } @@ -1864,5 +1869,5 @@ bool Device::readGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading global register offset 0x%04llX\n", offset); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading global register offset 0x%04"PRIX64"\n", offset); fb_nodeaddr_t offset_gl = globalOffsetGen(offset, sizeof(fb_quadlet_t)); @@ -1872,5 +1877,5 @@ bool Device::writeGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t data) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing global register offset 0x%08llX, data: 0x%08X\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing global register offset 0x%08"PRIX64", data: 0x%08"PRIX32"\n", offset, data); @@ -1881,5 +1886,5 @@ bool Device::readGlobalRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading global register block offset 0x%04llX, length %u bytes\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading global register block offset 0x%04"PRIX64", length %zd bytes\n", offset, length); @@ -1890,5 +1895,5 @@ bool Device::writeGlobalRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing global register block offset 0x%04llX, length %u bytes\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing global register block offset 0x%04"PRIX64", length: %zd bytes\n", offset, length); @@ -1908,5 +1913,5 @@ // out-of-range check if(offset+length > m_global_reg_offset+m_global_reg_size) { - debugError("register offset+length too large: 0x%0llX\n", offset + length); + debugError("register offset+length too large: 0x%04"PRIX64"\n", offset + length); return DICE_INVALID_OFFSET; } @@ -1917,5 +1922,5 @@ bool Device::readTxReg(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *result) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Reading tx %d register offset 0x%04llX\n", i, offset); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Reading tx %d register offset 0x%04"PRIX64"\n", i, offset); fb_nodeaddr_t offset_tx = txOffsetGen(i, offset, sizeof(fb_quadlet_t)); @@ -1925,5 +1930,5 @@ bool Device::writeTxReg(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t data) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing tx %d register offset 0x%08llX, data: 0x%08X\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing tx %d register offset 0x%08"PRIX64", data: 0x%08"PRIX32"\n", i, offset, data); @@ -1934,5 +1939,5 @@ bool Device::readTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx register block offset 0x%04llX, length %u bytes\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx register block offset 0x%04"PRIX64", length: %zd bytes\n", offset, length); @@ -1943,5 +1948,5 @@ bool Device::writeTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register block offset 0x%04llX, length %u bytes\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register block offset 0x%04"PRIX64", length: %zd bytes\n", offset, length); @@ -1975,5 +1980,5 @@ // out-of-range check if(offset_tx + length > m_tx_reg_offset+4+m_tx_reg_size*m_nb_tx) { - debugError("register offset+length too large: 0x%0llX\n", offset_tx + length); + debugError("register offset+length too large: 0x%04"PRIX64"\n", offset_tx + length); return DICE_INVALID_OFFSET; } @@ -1984,5 +1989,5 @@ bool Device::readRxReg(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *result) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx %d register offset 0x%04llX\n", i, offset); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx %d register offset 0x%04"PRIX64"\n", i, offset); fb_nodeaddr_t offset_rx=rxOffsetGen(i, offset, sizeof(fb_quadlet_t)); @@ -1992,5 +1997,5 @@ bool Device::writeRxReg(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t data) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register offset 0x%08llX, data: 0x%08X\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register offset 0x%08"PRIX64", data: 0x%08"PRIX32"\n", offset, data); @@ -2001,5 +2006,5 @@ bool Device::readRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx register block offset 0x%04llX, length %u bytes\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx register block offset 0x%04"PRIX64", length: %zd bytes\n", offset, length); @@ -2010,5 +2015,5 @@ bool Device::writeRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register block offset 0x%04llX, length %u bytes\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register block offset 0x%04"PRIX64", length: %zd bytes\n", offset, length); @@ -2042,5 +2047,5 @@ // out-of-range check if(offset_rx + length > m_rx_reg_offset+4+m_rx_reg_size*m_nb_rx) { - debugError("register offset+length too large: 0x%0llX\n", offset_rx + length); + debugError("register offset+length too large: 0x%04"PRIX64"\n", offset_rx + length); return DICE_INVALID_OFFSET; } Index: /trunk/libffado/src/libutil/serialize_libxml.cpp =================================================================== --- /trunk/libffado/src/libutil/serialize_libxml.cpp (revision 1568) +++ /trunk/libffado/src/libutil/serialize_libxml.cpp (revision 1763) @@ -89,5 +89,5 @@ { - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "write %s = %d\n", + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "write %s = %lld\n", strMemberName.c_str(), value ); @@ -266,5 +266,5 @@ value = strtoll( pElement->get_child_text()->get_content().c_str(), &tail, 0 ); - debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "found %s = %d\n", + debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "found %s = %lld\n", strMemberName.c_str(), value ); return true; Index: /trunk/libffado/src/libutil/Time.h =================================================================== --- /trunk/libffado/src/libutil/Time.h (revision 864) +++ /trunk/libffado/src/libutil/Time.h (revision 1763) @@ -25,4 +25,7 @@ #define __Time__ +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif #include @@ -34,4 +37,5 @@ */ typedef uint64_t ffado_microsecs_t; +#define PRI_FFADO_MICROSECS_T PRIu64 static inline void SleepRelativeUsec(ffado_microsecs_t usec) { Index: /trunk/libffado/src/libutil/StreamStatistics.cpp =================================================================== --- /trunk/libffado/src/libutil/StreamStatistics.cpp (revision 864) +++ /trunk/libffado/src/libutil/StreamStatistics.cpp (revision 1763) @@ -55,5 +55,5 @@ void StreamStatistics::dumpInfo() { debugOutputShort( DEBUG_LEVEL_VERBOSE, - "--- Stats for %s: min=%ld avg=%f max=%ld cnt=%ld sum=%ld\n", + "--- Stats for %s: min=%"PRId64" avg=%f max=%"PRId64" cnt=%"PRId64" sum=%"PRId64"\n", m_name.c_str(), m_min, m_average, m_max, m_count, m_sum); debugOutputShort( DEBUG_LEVEL_VERBOSE, " Signal stats\n"); Index: /trunk/libffado/src/libutil/TimestampedBuffer.h =================================================================== --- /trunk/libffado/src/libutil/TimestampedBuffer.h (revision 1531) +++ /trunk/libffado/src/libutil/TimestampedBuffer.h (revision 1763) @@ -152,4 +152,6 @@ void dumpInfo(); void setVerboseLevel ( int l ) {setDebugLevel ( l );}; + + bool resizeBuffer(unsigned int size); private: Index: /trunk/libffado/src/libutil/SystemTimeSource.cpp =================================================================== --- /trunk/libffado/src/libutil/SystemTimeSource.cpp (revision 1165) +++ /trunk/libffado/src/libutil/SystemTimeSource.cpp (revision 1763) @@ -55,6 +55,6 @@ ts.tv_nsec = (wake_at_usec % (1000000LL)) * 1000LL; debugOutputExtreme(DEBUG_LEVEL_VERBOSE, - "clock_nanosleep until %lld sec, %lld nanosec\n", - (int64_t)ts.tv_sec, (int64_t)ts.tv_nsec); + "clock_nanosleep until %"PRId64" sec, %"PRId64" nanosec\n", + (int64_t)ts.tv_sec, (int64_t)ts.tv_nsec); int err = clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &ts, NULL); if(err) { Index: /trunk/libffado/src/libutil/TimestampedBuffer.cpp =================================================================== --- /trunk/libffado/src/libutil/TimestampedBuffer.cpp (revision 1531) +++ /trunk/libffado/src/libutil/TimestampedBuffer.cpp (revision 1763) @@ -383,7 +383,6 @@ m_current_rate = m_nominal_rate; - if( !(m_event_buffer=ffado_ringbuffer_create( - (m_events_per_frame * m_buffer_size) * m_event_size))) { - debugFatal("Could not allocate memory event ringbuffer\n"); + if( !resizeBuffer(m_buffer_size) ) { + debugError("Failed to allocate the event buffer\n"); return false; } @@ -408,4 +407,36 @@ m_buffer_tail_timestamp = TIMESTAMP_MAX + 1.0; m_buffer_next_tail_timestamp = TIMESTAMP_MAX + 1.0; + + return true; +} + +/** + * Resizes the timestamped buffer + * @return true if successful, false if not + */ +bool +TimestampedBuffer::resizeBuffer(unsigned int new_size) +{ + assert(new_size); + assert(m_events_per_frame); + assert(m_event_size); + + // if present, free the previous buffer + if(m_event_buffer) { + ffado_ringbuffer_free(m_event_buffer); + } + // allocate a new one + if( !(m_event_buffer = ffado_ringbuffer_create( + (m_events_per_frame * new_size) * m_event_size))) { + debugFatal("Could not allocate memory event ringbuffer\n"); + + return false; + } + resetFrameCounter(); + + m_current_rate = m_nominal_rate; + m_dll_e2 = m_current_rate * (float)m_update_period; + + m_buffer_size = new_size; return true; @@ -474,5 +505,5 @@ if (written < write_size) { - debugWarning("ringbuffer full, %u, %u\n", write_size, written); + debugWarning("ringbuffer full, %u, %zd\n", write_size, written); return false; } @@ -503,5 +534,5 @@ if (written < write_size) { - debugWarning("ringbuffer full, request: %u, actual: %u\n", write_size, written); + debugWarning("ringbuffer full, request: %u, actual: %zd\n", write_size, written); return false; } @@ -614,5 +645,5 @@ if(vec[0].len + vec[1].len < m_process_block_size) { // this indicates a full event buffer - debugError("Event buffer overrun in buffer %p, fill: %u, bytes2write: %u \n", + debugError("Event buffer overrun in buffer %p, fill: %zd, bytes2write: %u \n", this, ffado_ringbuffer_read_space(m_event_buffer), bytes2write); debugShowBackLog(); Index: /trunk/libffado/src/libutil/Configuration.cpp =================================================================== --- /trunk/libffado/src/libutil/Configuration.cpp (revision 1568) +++ /trunk/libffado/src/libutil/Configuration.cpp (revision 1763) @@ -182,5 +182,5 @@ int32_t i = s; debugOutput(DEBUG_LEVEL_NORMAL, - " %s%s = %ld (0x%08lX)\n", + " %s%s = %d (0x%08X)\n", prefix.c_str(), s.getName(), i, i); } @@ -190,5 +190,5 @@ int64_t i = s; debugOutput(DEBUG_LEVEL_NORMAL, - " %s%s = %lld (0x%016llX)\n", + " %s%s = %"PRId64" (0x%016"PRIX64")\n", prefix.c_str(), s.getName(), i, i); } @@ -259,5 +259,5 @@ if(t == Setting::TypeInt64) { ref = *s; - debugOutput(DEBUG_LEVEL_VERBOSE, "path '%s' has value %d\n", path.c_str(), ref); + debugOutput(DEBUG_LEVEL_VERBOSE, "path '%s' has value %"PRId64"\n", path.c_str(), ref); return true; } else { Index: /trunk/libffado/src/libutil/serialize_expat.cpp =================================================================== --- /trunk/libffado/src/libutil/serialize_expat.cpp (revision 1254) +++ /trunk/libffado/src/libutil/serialize_expat.cpp (revision 1763) @@ -117,5 +117,5 @@ Xml::Node& n = pNode->add( Xml::Node(tokens[tokens.size() - 1].c_str(), NULL) ); char* valstr; - asprintf( &valstr, "%lld", value ); + asprintf( &valstr, "%"PRId64"", value ); n.set_child_text( valstr ); free( valstr ); Index: /trunk/libffado/src/libutil/PosixThread.cpp =================================================================== --- /trunk/libffado/src/libutil/PosixThread.cpp (revision 1550) +++ /trunk/libffado/src/libutil/PosixThread.cpp (revision 1763) @@ -149,5 +149,5 @@ if (res) { debugError("Cannot create realtime thread (%d: %s)\n", res, strerror(res)); - debugError(" priority: %d %s\n", fPriority); + debugError(" priority: %d\n", fPriority); return -1; } @@ -172,5 +172,5 @@ { if (fThread) { // If thread has been started - debugOutput( DEBUG_LEVEL_VERBOSE, "(%s) Kill %p (thread: %p)\n", m_id.c_str(), this, fThread); + debugOutput( DEBUG_LEVEL_VERBOSE, "(%s) Kill %p (thread: %p)\n", m_id.c_str(), this, (void *)fThread); void* status; pthread_cancel(fThread); @@ -178,5 +178,5 @@ pthread_join(fThread, &status); m_lock.Unlock(); - debugOutput( DEBUG_LEVEL_VERBOSE, "(%s) Killed %p (thread: %p)\n", m_id.c_str(), this, fThread); + debugOutput( DEBUG_LEVEL_VERBOSE, "(%s) Killed %p (thread: %p)\n", m_id.c_str(), this, (void *)fThread); return 0; } else { @@ -188,5 +188,5 @@ { if (fThread) { // If thread has been started - debugOutput( DEBUG_LEVEL_VERBOSE, "(%s) Stop %p (thread: %p)\n", m_id.c_str(), this, fThread); + debugOutput( DEBUG_LEVEL_VERBOSE, "(%s) Stop %p (thread: %p)\n", m_id.c_str(), this, (void *)fThread); void* status; fRunning = false; // Request for the thread to stop @@ -195,5 +195,5 @@ fThread = NULL; m_lock.Unlock(); - debugOutput( DEBUG_LEVEL_VERBOSE, "(%s) Stopped %p (thread: %p)\n", m_id.c_str(), this, fThread); + debugOutput( DEBUG_LEVEL_VERBOSE, "(%s) Stopped %p (thread: %p)\n", m_id.c_str(), this, (void *)fThread); return 0; } else { Index: /trunk/libffado/src/genericavc/stanton/scs.cpp =================================================================== --- /trunk/libffado/src/genericavc/stanton/scs.cpp (revision 1550) +++ /trunk/libffado/src/genericavc/stanton/scs.cpp (revision 1763) @@ -69,5 +69,5 @@ // read the current value present in the register, i.e. read-ping if(!readRegBlock(addr, (quadlet_t *)cmdBuffer, 1) ) { - debugError("Could not read from addr 0x%012llX\n", addr); + debugError("Could not read from addr 0x%012"PRIX64"\n", addr); } else { int version = cmdBuffer[0] & 0xFFFF; @@ -84,5 +84,5 @@ // execute the command if(!writeRegBlock(addr, (quadlet_t *)cmdBuffer, 1)) { - debugError("Could not write to addr 0x%012llX\n", addr); + debugError("Could not write to addr 0x%012"PRIX64"\n", addr); } else { debugOutput(DEBUG_LEVEL_VERBOSE, "Write Ping succeeded\n"); @@ -126,5 +126,5 @@ // execute the command if(!writeRegBlock(addr, (quadlet_t *)cmdBuffer, 2)) { - debugError("Could not write to addr 0x%012llX\n", addr); + debugError("Could not write to addr 0x%012"PRIX64"\n", addr); return false; } @@ -140,5 +140,5 @@ // execute the command if(!writeRegBlock(addr, (quadlet_t *)cmdBuffer, 2)) { - debugError("Could not write to addr 0x%012llX\n", addr); + debugError("Could not write to addr 0x%012"PRIX64"\n", addr); return false; } @@ -149,5 +149,5 @@ bool ScsDevice::writeHSS1394Message(enum eMessageType message_type, byte_t* buffer, size_t len) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing message type: %02X, length: %u bytes\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing message type: %02X, length: %zd bytes\n", message_type, len); size_t len_quadlets = len/4 + 1; @@ -169,5 +169,5 @@ // execute the command if(!writeRegBlock(addr, (quadlet_t *)cmdBuffer, len_quadlets)) { - debugError("Could not write to addr 0x%012llX\n", addr); + debugError("Could not write to addr 0x%012"PRIX64"\n", addr); return false; } @@ -177,5 +177,5 @@ bool ScsDevice::readRegBlock(fb_nodeaddr_t addr, fb_quadlet_t *data, size_t length_quads, size_t blocksize_quads) { - debugOutput(DEBUG_LEVEL_VERBOSE,"Reading register 0x%016llX, length %u quadlets, to %p\n", + debugOutput(DEBUG_LEVEL_VERBOSE,"Reading register 0x%016"PRIX64", length %zd quadlets, to %p\n", addr, length_quads, data); @@ -187,5 +187,5 @@ int quads_todo = length_quads - quads_done; if (quads_todo > (int)blocksize_quads) { - debugOutput(DEBUG_LEVEL_VERBOSE, "Truncating read from %d to %d quadlets\n", quads_todo, blocksize_quads); + debugOutput(DEBUG_LEVEL_VERBOSE, "Truncating read from %d to %zd quadlets\n", quads_todo, blocksize_quads); quads_todo = blocksize_quads; } @@ -196,7 +196,7 @@ #endif - debugOutput(DEBUG_LEVEL_VERBOSE, "reading addr: 0x%016llX, %d quads to %p\n", curr_addr, quads_todo, curr_data); + debugOutput(DEBUG_LEVEL_VERBOSE, "reading addr: 0x%016"PRIX64", %d quads to %p\n", curr_addr, quads_todo, curr_data); if(!get1394Service().read( nodeId, curr_addr, quads_todo, curr_data ) ) { - debugError("Could not read %d quadlets from node 0x%04X addr 0x%012llX\n", quads_todo, nodeId, curr_addr); + debugError("Could not read %d quadlets from node 0x%04X addr 0x%012"PRIX64"\n", quads_todo, nodeId, curr_addr); return false; } @@ -210,6 +210,7 @@ bool ScsDevice::writeRegBlock(fb_nodeaddr_t addr, fb_quadlet_t *data, size_t length_quads, size_t blocksize_quads) { - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing register 0x%016llX, length: %u quadlets, from %p\n", - addr, length_quads, addr); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, + "Writing register 0x%016"PRIX64", length: %zd quadlets, from %p\n", + addr, length_quads, data); fb_quadlet_t data_out[length_quads]; @@ -224,5 +225,5 @@ int quads_todo = length_quads - quads_done; if (quads_todo > (int)blocksize_quads) { - debugOutput(DEBUG_LEVEL_VERBOSE, "Truncating write from %d to %d quadlets\n", quads_todo, blocksize_quads); + debugOutput(DEBUG_LEVEL_VERBOSE, "Truncating write from %d to %zd quadlets\n", quads_todo, blocksize_quads); quads_todo = blocksize_quads; } @@ -233,7 +234,7 @@ #endif - debugOutput(DEBUG_LEVEL_VERBOSE, "writing addr: 0x%016llX, %d quads from %p\n", curr_addr, quads_todo, curr_data); + debugOutput(DEBUG_LEVEL_VERBOSE, "writing addr: 0x%016"PRIX64", %d quads from %p\n", curr_addr, quads_todo, curr_data); if(!get1394Service().write( nodeId, addr, quads_todo, curr_data ) ) { - debugError("Could not write %d quadlets to node 0x%04X addr 0x%012llX\n", quads_todo, nodeId, curr_addr); + debugError("Could not write %d quadlets to node 0x%04X addr 0x%012"PRIX64"\n", quads_todo, nodeId, curr_addr); return false; } Index: /trunk/libffado/src/libcontrol/Element.cpp =================================================================== --- /trunk/libffado/src/libcontrol/Element.cpp (revision 1630) +++ /trunk/libffado/src/libcontrol/Element.cpp (revision 1763) @@ -327,5 +327,5 @@ { Util::MutexLockHelper lock(getLock()); - debugOutput( DEBUG_LEVEL_NORMAL, "Container %s (%d Elements)\n", + debugOutput( DEBUG_LEVEL_NORMAL, "Container %s (%zd Elements)\n", getName().c_str(), m_Children.size()); Index: /trunk/libffado/src/bebob/bebob_dl_bcd.cpp =================================================================== --- /trunk/libffado/src/bebob/bebob_dl_bcd.cpp (revision 864) +++ /trunk/libffado/src/bebob/bebob_dl_bcd.cpp (revision 1763) @@ -154,5 +154,5 @@ bytes_read = fread( &m_bcd_version, 1, sizeof( fb_quadlet_t ), m_file ); if ( bytes_read != sizeof( fb_quadlet_t ) ) { - debugError( "parse: %d bytes read at position %d failed\n", + debugError( "parse: %zd bytes read at position %d failed\n", sizeof( fb_quadlet_t ), BCDFileVersionOffset ); @@ -245,5 +245,5 @@ size_t bytes_read = std::fread( q, 1, sizeof( *q ), m_file ); if ( bytes_read != sizeof( *q ) ) { - debugError( "read: %d byte read failed at position 0x%08x\n", + debugError( "read: %zd byte read failed at position 0x%08x\n", sizeof( *q ), addr ); return false; @@ -263,5 +263,5 @@ size_t bytes_read = std::fread( o, 1, sizeof( *o ), m_file ); if ( bytes_read != sizeof( *o ) ) { - debugError( "read: %d byte read failed at position 0x%08x\n", + debugError( "read: %zd byte read failed at position 0x%08x\n", sizeof( *o ), addr ); return false; @@ -281,5 +281,5 @@ size_t bytes_read = std::fread( b, 1, len, m_file ); if ( bytes_read != len ) { - debugError( "read: %d byte read failed at position 0x%08x\n", + debugError( "read: %zd byte read failed at position 0x%08x\n", len, addr ); return false; Index: /trunk/libffado/src/bebob/bebob_dl_mgr.h =================================================================== --- /trunk/libffado/src/bebob/bebob_dl_mgr.h (revision 932) +++ /trunk/libffado/src/bebob/bebob_dl_mgr.h (revision 1763) @@ -67,4 +67,9 @@ bool setStartBootloader( bool bStartBootloader ) { m_bStartBootloader = bStartBootloader; return true; } + + int getSoftwareVersion() {return m_cachedInfoRegs.m_softwareVersion;}; + std::string getSoftwareDate(); + std::string getSoftwareTime(); + protected: enum EObjectType { Index: /trunk/libffado/src/bebob/bebob_avdevice.cpp =================================================================== --- /trunk/libffado/src/bebob/bebob_avdevice.cpp (revision 1543) +++ /trunk/libffado/src/bebob/bebob_avdevice.cpp (revision 1763) @@ -724,5 +724,5 @@ char* configId; - asprintf(&configId, "%016llx", getConfigurationId() ); + asprintf(&configId, "%016"PRIx64"", getConfigurationId() ); if ( !configId ) { debugError( "could not create id string\n" ); @@ -800,5 +800,5 @@ // come up with an unique file name for the current settings char* configId; - asprintf(&configId, "%016llx", BeBoB::Device::getConfigurationId() ); + asprintf(&configId, "%016"PRIx64"", BeBoB::Device::getConfigurationId() ); if ( !configId ) { debugError( "Could not create id string\n" ); Index: /trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp =================================================================== --- /trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp (revision 1543) +++ /trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp (revision 1763) @@ -58,5 +58,5 @@ FocusriteDevice::setSpecificValue(uint32_t id, uint32_t v) { - debugOutput(DEBUG_LEVEL_VERBOSE, "Writing parameter address space id 0x%08lX (%u), data: 0x%08lX\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "Writing parameter address space id 0x%08X (%u), data: 0x%08X\n", id, id, v); bool use_avc = false; @@ -69,5 +69,5 @@ if(m_cmd_time_interval && (m_earliest_next_cmd_time > now)) { ffado_microsecs_t wait = m_earliest_next_cmd_time - now; - debugOutput( DEBUG_LEVEL_VERBOSE, "Rate control... %llu\n", wait ); + debugOutput( DEBUG_LEVEL_VERBOSE, "Rate control... %"PRIu64"\n", wait ); Util::SystemTimeSource::SleepUsecRelative(wait); } @@ -94,5 +94,5 @@ if(m_cmd_time_interval && (m_earliest_next_cmd_time > now)) { ffado_microsecs_t wait = m_earliest_next_cmd_time - now; - debugOutput( DEBUG_LEVEL_VERBOSE, "Rate control... %llu\n", wait ); + debugOutput( DEBUG_LEVEL_VERBOSE, "Rate control... %"PRIu64"\n", wait ); Util::SystemTimeSource::SleepUsecRelative(wait); } @@ -105,5 +105,5 @@ retval = getSpecificValueARM(id, v); } - debugOutput(DEBUG_LEVEL_VERBOSE,"Read parameter address space id 0x%08lX (%u): %08lX\n", id, id, *v); + debugOutput(DEBUG_LEVEL_VERBOSE,"Read parameter address space id 0x%08X (%u): %08X\n", id, id, *v); return retval; } @@ -161,6 +161,6 @@ FocusriteDevice::setSpecificValueARM(uint32_t id, uint32_t v) { - fb_quadlet_t data=v; - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing parameter address space id 0x%08lX (%u), data: 0x%08lX\n", + fb_quadlet_t data = v; + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing parameter address space id 0x%08X (%u), data: 0x%08X\n", id, id, data); @@ -169,5 +169,5 @@ if(!get1394Service().write_quadlet( nodeId, addr, CondSwapToBus32(data) ) ) { - debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); + debugError("Could not write to node 0x%04X addr 0x%012"PRIX64"\n", nodeId, addr); return false; } @@ -179,5 +179,5 @@ { fb_quadlet_t result; - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading parameter address space id 0x%08lX\n", id); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading parameter address space id 0x%08X\n", id); fb_nodeaddr_t addr = FR_PARAM_SPACE_START + (id * 4); @@ -185,10 +185,10 @@ if(!get1394Service().read_quadlet( nodeId, addr, &result ) ) { - debugError("Could not read from node 0x%04llX addr 0x%012llX\n", nodeId, addr); - return false; - } - - result=CondSwapFromBus32(result); - debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08llX\n", result); + debugError("Could not read from node 0x%04X addr 0x%012"PRIX64"\n", nodeId, addr); + return false; + } + + result = CondSwapFromBus32(result); + debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", result); *v = result; @@ -385,5 +385,5 @@ RegisterControl::setValue(uint64_t addr, uint64_t v) { - debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for addr %llu to %llu\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for addr %"PRIu64" to %"PRIu64"\n", addr, v); @@ -403,5 +403,5 @@ return 0; } else { - debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for %llu = %lu\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for %"PRIu64" = %u\n", addr, val); return val; @@ -576,5 +576,5 @@ struct sCellInfo c = m_CellInfo.at(row).at(col); - debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for id %d row %d col %d to %lf (%ld)\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for id %d row %d col %d to %lf (%d)\n", c.address, row, col, val, v); @@ -597,5 +597,5 @@ return 0; } else { - debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for id %d row %d col %d = %lu\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for id %d row %d col %d = %u\n", c.address, row, col, val); return val; Index: /trunk/libffado/src/bebob/focusrite/focusrite_saffire.cpp =================================================================== --- /trunk/libffado/src/bebob/focusrite/focusrite_saffire.cpp (revision 1617) +++ /trunk/libffado/src/bebob/focusrite/focusrite_saffire.cpp (revision 1763) @@ -48,9 +48,9 @@ if(config.getValueForDeviceSetting(getConfigRom().getNodeVendorId(), getConfigRom().getModelId(), "cmd_interval_time", delaytime)) { m_cmd_time_interval = delaytime; - debugOutput( DEBUG_LEVEL_VERBOSE, "Setting command interval time to %llu\n", + debugOutput( DEBUG_LEVEL_VERBOSE, "Setting command interval time to %"PRIu64"\n", m_cmd_time_interval ); } else { m_cmd_time_interval = 10000; - debugOutput( DEBUG_LEVEL_VERBOSE, "No command interval time setting found, defaulting to %llu\n", + debugOutput( DEBUG_LEVEL_VERBOSE, "No command interval time setting found, defaulting to %"PRIu64"\n", m_cmd_time_interval ); } Index: /trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp =================================================================== --- /trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp (revision 1617) +++ /trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp (revision 1763) @@ -423,9 +423,9 @@ return; } - debugOutput(DEBUG_LEVEL_VERBOSE, "SYNC_CONFIG field value: %08lX\n", sync ); + debugOutput(DEBUG_LEVEL_VERBOSE, "SYNC_CONFIG field value: %08X\n", sync ); switch(sync & FR_SAFFIREPRO_CMD_ID_SYNC_CONFIG_MASK) { default: - debugWarning( "Unexpected SYNC_CONFIG field value: %08lX\n", sync ); + debugWarning( "Unexpected SYNC_CONFIG field value: %08X\n", sync ); case FR_SAFFIREPRO_CMD_SYNC_CONFIG_INTERNAL: m_internal_clocksource.active=true; @@ -466,5 +466,5 @@ break; default: - debugWarning( "Unexpected SYNC_CONFIG_STATE field value: %08lX\n", sync ); + debugWarning( "Unexpected SYNC_CONFIG_STATE field value: %08X\n", sync ); } } @@ -772,5 +772,5 @@ break; } - debugOutput( DEBUG_LEVEL_VERBOSE, "setSampleRate (try %d) failed. Try again...\n" ); + debugOutput( DEBUG_LEVEL_VERBOSE, "setSampleRate (try %d) failed. Try again...\n", ntries); } @@ -872,6 +872,5 @@ } - debugOutput( DEBUG_LEVEL_VERBOSE, - "getCount32: %08lX\n", v ); + debugOutput( DEBUG_LEVEL_VERBOSE, "getCount32: %08X\n", v ); return v; } Index: /trunk/libffado/src/bebob/bebob_avplug.cpp =================================================================== --- /trunk/libffado/src/bebob/bebob_avplug.cpp (revision 1245) +++ /trunk/libffado/src/bebob/bebob_avplug.cpp (revision 1763) @@ -583,5 +583,5 @@ { debugError( "number of output plugs (%d) disagree with " - "number of elements in plug address vector (%d)\n", + "number of elements in plug address vector (%zd)\n", infoType->m_plugOutput->m_nrOfOutputPlugs, infoType->m_plugOutput->m_outputPlugAddresses.size()); Index: /trunk/libffado/src/bebob/terratec/terratec_device.cpp =================================================================== --- /trunk/libffado/src/bebob/terratec/terratec_device.cpp (revision 1543) +++ /trunk/libffado/src/bebob/terratec/terratec_device.cpp (revision 1763) @@ -23,4 +23,6 @@ #include "terratec_device.h" +#include "src/bebob/bebob_dl_mgr.h" +#include "src/bebob/bebob_dl_bcd.h" namespace BeBoB { @@ -45,6 +47,17 @@ BeBoB::Device::showDevice(); } -/* 'externalsync': ['/Mixer/Selector_8', self.comboExtSync], - 'syncsource': ['/Mixer/Selector_9', self.comboSyncSource], */ + +bool +Phase88Device::discover() +{ + BeBoB::BootloaderManager blMgr( get1394Service(), getNodeId() ); + blMgr.printInfoRegisters(); + if (blMgr.getSoftwareVersion() < 0x01120d1f) { + debugError("The firmware of this Phase88 device is too old. Please update the firmware.\n"); + return false; + } + return BeBoB::Device::discover(); +} + void Phase88Device::updateClockSources() { Index: /trunk/libffado/src/bebob/terratec/terratec_device.h =================================================================== --- /trunk/libffado/src/bebob/terratec/terratec_device.h (revision 1543) +++ /trunk/libffado/src/bebob/terratec/terratec_device.h (revision 1763) @@ -37,4 +37,6 @@ virtual ~Phase88Device(); + virtual bool discover(); + virtual void showDevice(); Index: /trunk/libffado/src/bebob/bebob_dl_mgr.cpp =================================================================== --- /trunk/libffado/src/bebob/bebob_dl_mgr.cpp (revision 1336) +++ /trunk/libffado/src/bebob/bebob_dl_mgr.cpp (revision 1763) @@ -165,4 +165,16 @@ return false; +} + +std::string +BeBoB::BootloaderManager::getSoftwareDate() +{ + return makeDate( m_cachedInfoRegs.m_softwareDate ); +} + +std::string +BeBoB::BootloaderManager::getSoftwareTime() +{ + return makeDate( m_cachedInfoRegs.m_softwareTime ); } Index: /trunk/libffado/src/fireworks/fireworks_firmware.cpp =================================================================== --- /trunk/libffado/src/fireworks/fireworks_firmware.cpp (revision 1336) +++ /trunk/libffado/src/fireworks/fireworks_firmware.cpp (revision 1763) @@ -172,12 +172,12 @@ unsigned int version_minor = (m_version & 0x00FF0000) >> 16; unsigned int version_build = (m_version & 0x0000FFFF); - debugOutput(DEBUG_LEVEL_NORMAL, " Address Offset : 0x%08lX\n", m_flash_offset_address); - debugOutput(DEBUG_LEVEL_NORMAL, " Length (Quadlets) : 0x%08lX\n", m_length_quads); - debugOutput(DEBUG_LEVEL_NORMAL, " CRC 32 : 0x%08lX\n", m_CRC32); - debugOutput(DEBUG_LEVEL_NORMAL, " Checksum : 0x%08lX\n", m_checksum); + debugOutput(DEBUG_LEVEL_NORMAL, " Address Offset : 0x%08X\n", m_flash_offset_address); + debugOutput(DEBUG_LEVEL_NORMAL, " Length (Quadlets) : 0x%08X\n", m_length_quads); + debugOutput(DEBUG_LEVEL_NORMAL, " CRC 32 : 0x%08X\n", m_CRC32); + debugOutput(DEBUG_LEVEL_NORMAL, " Checksum : 0x%08X\n", m_checksum); debugOutput(DEBUG_LEVEL_NORMAL, " Firmware version : %02u.%02u.%02u (0x%08X)\n", version_major, version_minor, version_build, m_version); debugOutput(DEBUG_LEVEL_NORMAL, " Append CRC : %s\n", (m_append_crc?"Yes":"No")); - debugOutput(DEBUG_LEVEL_NORMAL, " Footprint (Quadlets) : 0x%08lX\n", m_footprint_quads); + debugOutput(DEBUG_LEVEL_NORMAL, " Footprint (Quadlets) : 0x%08X\n", m_footprint_quads); #endif } @@ -298,5 +298,5 @@ } - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " Header %02d: %08lX\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " Header %02d: %08X\n", i, m_header[i]); } @@ -337,5 +337,5 @@ } - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " Data %02d: %08lX\n", + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " Data %02d: %08X\n", i, m_data[i]); } Index: /trunk/libffado/src/fireworks/fireworks_session_block.cpp =================================================================== --- /trunk/libffado/src/fireworks/fireworks_session_block.cpp (revision 1336) +++ /trunk/libffado/src/fireworks/fireworks_session_block.cpp (revision 1763) @@ -255,5 +255,5 @@ if (len != h.size_quads*4) { - debugWarning("size not correct: got %d, should be %d according to data\n", len, h.size_quads*4); + debugWarning("size not correct: got %zd, should be %d according to data\n", len, h.size_quads*4); } Index: /trunk/libffado/src/fireworks/fireworks_device.cpp =================================================================== --- /trunk/libffado/src/fireworks/fireworks_device.cpp (revision 1543) +++ /trunk/libffado/src/fireworks/fireworks_device.cpp (revision 1763) @@ -43,4 +43,5 @@ #define ECHO_FLASH_ERASE_TIMEOUT_MILLISECS 2000 +#define FIREWORKS_MIN_FIRMWARE_VERSION 0x04080000 #include @@ -136,5 +137,4 @@ // get the info from the EFC if ( !discoverUsingEFC() ) { - debugError( "Could not discover using EFC\n" ); return false; } @@ -161,4 +161,17 @@ if (!doEfcOverAVC(m_HwInfo)) { debugError("Could not read hardware capabilities\n"); + return false; + } + + // check the firmware version + if (m_HwInfo.m_arm_version < FIREWORKS_MIN_FIRMWARE_VERSION) { + debugError("Firmware version %u.%u (rev %u) not recent enough. FFADO requires at least version %u.%u (rev %u).\n", + (m_HwInfo.m_arm_version >> 24) & 0xFF, + (m_HwInfo.m_arm_version >> 16) & 0xFF, + (m_HwInfo.m_arm_version >> 0) & 0xFFFF, + (FIREWORKS_MIN_FIRMWARE_VERSION >> 24) & 0xFF, + (FIREWORKS_MIN_FIRMWARE_VERSION >> 16) & 0xFF, + (FIREWORKS_MIN_FIRMWARE_VERSION >> 0) & 0xFFFF + ); return false; } @@ -547,5 +560,5 @@ Device::clockIdToClockSource(uint32_t clockid) { ClockSource s; - debugOutput(DEBUG_LEVEL_VERBOSE, "clock id: %lu\n", clockid); + debugOutput(DEBUG_LEVEL_VERBOSE, "clock id: %u\n", clockid); // the polled values are used to detect @@ -611,5 +624,5 @@ return EFC_CMD_HW_CLOCK_UNSPECIFIED; } - debugOutput(DEBUG_LEVEL_VERBOSE, "Active clock: 0x%08lX\n",gccmd.m_clock); + debugOutput(DEBUG_LEVEL_VERBOSE, "Active clock: 0x%08X\n",gccmd.m_clock); gccmd.showEfcCmd(); @@ -624,5 +637,5 @@ return false; } - debugOutput(DEBUG_LEVEL_VERBOSE, "Set clock: 0x%08lX\n", id); + debugOutput(DEBUG_LEVEL_VERBOSE, "Set clock: 0x%08X\n", id); EfcSetClockCmd sccmd; Index: /trunk/libffado/src/fireworks/fireworks_control.cpp =================================================================== --- /trunk/libffado/src/fireworks/fireworks_control.cpp (revision 1336) +++ /trunk/libffado/src/fireworks/fireworks_control.cpp (revision 1763) @@ -321,5 +321,5 @@ break; } - debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for channel %d to %lf = %lf\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for channel %d to %lf = %u\n", m_Slave->m_channel, val, m_Slave->m_value); return true; @@ -339,5 +339,5 @@ return 0.0; } - debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for channel %d = %lf\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for channel %d = %u\n", m_Slave->m_channel, m_Slave->m_value); return m_Slave->m_value; @@ -451,5 +451,5 @@ } - debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for channel %d to %ld (reg: 0x%08X => 0x%08X)\n", + debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for channel %d to %d (reg: 0x%08X => 0x%08X)\n", m_Slave->m_channel, val, old_reg, reg); return true; @@ -583,5 +583,5 @@ return 0; } - debugOutput(DEBUG_LEVEL_VERBOSE, "setValue to %ld \n", val); + debugOutput(DEBUG_LEVEL_VERBOSE, "setValue to %d \n", val); return true; } else { Index: /trunk/libffado/src/fireworks/efc/efc_cmds_hardware_ctrl.cpp =================================================================== --- /trunk/libffado/src/fireworks/efc/efc_cmds_hardware_ctrl.cpp (revision 1336) +++ /trunk/libffado/src/fireworks/efc/efc_cmds_hardware_ctrl.cpp (revision 1763) @@ -73,7 +73,7 @@ EfcCmd::showEfcCmd(); debugOutput(DEBUG_LEVEL_NORMAL, "EFC Get Clock:\n"); - debugOutput(DEBUG_LEVEL_NORMAL, " Clock : %lu\n", m_clock); - debugOutput(DEBUG_LEVEL_NORMAL, " Samplerate : %lu\n", m_samplerate); - debugOutput(DEBUG_LEVEL_NORMAL, " Index : %lu\n", m_index); + debugOutput(DEBUG_LEVEL_NORMAL, " Clock : %u\n", m_clock); + debugOutput(DEBUG_LEVEL_NORMAL, " Samplerate : %u\n", m_samplerate); + debugOutput(DEBUG_LEVEL_NORMAL, " Index : %u\n", m_index); } @@ -124,7 +124,7 @@ EfcCmd::showEfcCmd(); debugOutput(DEBUG_LEVEL_NORMAL, "EFC Set Clock:\n"); - debugOutput(DEBUG_LEVEL_NORMAL, " Clock : %lu\n", m_clock); - debugOutput(DEBUG_LEVEL_NORMAL, " Samplerate : %lu\n", m_samplerate); - debugOutput(DEBUG_LEVEL_NORMAL, " Index : %lu\n", m_index); + debugOutput(DEBUG_LEVEL_NORMAL, " Clock : %u\n", m_clock); + debugOutput(DEBUG_LEVEL_NORMAL, " Samplerate : %u\n", m_samplerate); + debugOutput(DEBUG_LEVEL_NORMAL, " Index : %u\n", m_index); } Index: /trunk/libffado/src/fireworks/efc/efc_cmds_mixer.cpp =================================================================== --- /trunk/libffado/src/fireworks/efc/efc_cmds_mixer.cpp (revision 1136) +++ /trunk/libffado/src/fireworks/efc/efc_cmds_mixer.cpp (revision 1763) @@ -245,6 +245,6 @@ eMixerTargetToString(m_target), eMixerCommandToString(m_command)); - debugOutput(DEBUG_LEVEL_NORMAL, " Channel : %ld\n", m_channel); - debugOutput(DEBUG_LEVEL_NORMAL, " Value : %lu\n", m_value); + debugOutput(DEBUG_LEVEL_NORMAL, " Channel : %d\n", m_channel); + debugOutput(DEBUG_LEVEL_NORMAL, " Value : %u\n", m_value); } Index: /trunk/libffado/src/fireworks/efc/efc_cmds_monitor.cpp =================================================================== --- /trunk/libffado/src/fireworks/efc/efc_cmds_monitor.cpp (revision 1136) +++ /trunk/libffado/src/fireworks/efc/efc_cmds_monitor.cpp (revision 1763) @@ -150,7 +150,7 @@ (m_type==eCT_Get?"GET":"SET"), eMonitorCommandToString(m_command)); - debugOutput(DEBUG_LEVEL_NORMAL, " Input : %ld\n", m_input); - debugOutput(DEBUG_LEVEL_NORMAL, " Output : %ld\n", m_output); - debugOutput(DEBUG_LEVEL_NORMAL, " Value : %lu\n", m_value); + debugOutput(DEBUG_LEVEL_NORMAL, " Input : %d\n", m_input); + debugOutput(DEBUG_LEVEL_NORMAL, " Output : %d\n", m_output); + debugOutput(DEBUG_LEVEL_NORMAL, " Value : %u\n", m_value); } Index: /trunk/libffado/src/fireworks/efc/efc_cmds_ioconfig.cpp =================================================================== --- /trunk/libffado/src/fireworks/efc/efc_cmds_ioconfig.cpp (revision 1336) +++ /trunk/libffado/src/fireworks/efc/efc_cmds_ioconfig.cpp (revision 1763) @@ -162,5 +162,5 @@ (m_type==eCT_Get?"GET":"SET"), eIOConfigRegisterToString(m_reg)); - debugOutput(DEBUG_LEVEL_NORMAL, " Value : %lu\n", m_value); + debugOutput(DEBUG_LEVEL_NORMAL, " Value : %u\n", m_value); } Index: /trunk/libffado/src/fireworks/efc/efc_cmds_hardware.cpp =================================================================== --- /trunk/libffado/src/fireworks/efc/efc_cmds_hardware.cpp (revision 1135) +++ /trunk/libffado/src/fireworks/efc/efc_cmds_hardware.cpp (revision 1763) @@ -127,7 +127,7 @@ debugOutput(DEBUG_LEVEL_NORMAL, "EFC HW CAPS info:\n"); debugOutput(DEBUG_LEVEL_NORMAL, " Flags : 0x%08X\n", m_flags); - debugOutput(DEBUG_LEVEL_NORMAL, " GUID : %016llX\n", m_guid); + debugOutput(DEBUG_LEVEL_NORMAL, " GUID : %016"PRIX64"\n", m_guid); debugOutput(DEBUG_LEVEL_NORMAL, " HwType : 0x%08X\n", m_type); - debugOutput(DEBUG_LEVEL_NORMAL, " Version : %lu\n", m_version); + debugOutput(DEBUG_LEVEL_NORMAL, " Version : %u\n", m_version); debugOutput(DEBUG_LEVEL_NORMAL, " Vendor : %s\n", m_vendor_name); debugOutput(DEBUG_LEVEL_NORMAL, " Model : %s\n", m_model_name); @@ -232,10 +232,10 @@ debugOutput(DEBUG_LEVEL_NORMAL, " # Output Meters : %d\n", m_nb_output_meters); for (i=0;icountDeviceStrings()) { // only if there are devicestrings + // first map the devices to a position using the device spec strings + std::map positionMap; + for ( FFADODeviceVectorIterator it = m_avDevices.begin(); + it != m_avDevices.end(); + ++it ) + { + int pos = m_deviceStringParser->matchPosition((*it)->getConfigRom()); + fb_octlet_t guid = (*it)->getConfigRom().getGuid(); + positionMap[guid] = pos; + debugOutput( DEBUG_LEVEL_VERBOSE, "Mapping %s to position %d...\n", (*it)->getConfigRom().getGuidString().c_str(), pos ); + } + + // now run over all positions, and add the devices that belong to it + FFADODeviceVector sorted; + int nbPositions = m_deviceStringParser->countDeviceStrings(); + for (i=0; i < nbPositions; i++) { + for ( FFADODeviceVectorIterator it = m_avDevices.begin(); + it != m_avDevices.end(); + ++it ) + { + fb_octlet_t guid = (*it)->getConfigRom().getGuid(); + if(positionMap[guid] == i) { + sorted.push_back(*it); + } + } + } + // assign the new vector + flushDebugOutput(); + assert(sorted.size() == m_avDevices.size()); + m_avDevices = sorted; + } + + // set device id's + i = 0; for ( FFADODeviceVectorIterator it = m_avDevices.begin(); it != m_avDevices.end(); @@ -710,5 +746,5 @@ { if (!deleteElement(*it)) { - debugWarning("failed to remove AvDevice from Control::Container\n"); + debugWarning("failed to remove Device from Control::Container\n"); } delete *it; @@ -827,5 +863,125 @@ bool +DeviceManager::startStreamingOnDevice(FFADODevice *device) +{ + assert(device); + + int j=0; + bool all_streams_started = true; + bool device_start_failed = false; + for(j=0; j < device->getStreamCount(); j++) { + debugOutput(DEBUG_LEVEL_VERBOSE,"Starting stream %d of device %p\n", j, device); + // start the stream + if (!device->startStreamByIndex(j)) { + debugWarning("Could not start stream %d of device %p\n", j, device); + all_streams_started = false; + break; + } + } + + if(!all_streams_started) { + // disable all streams that did start up correctly + for(j = j-1; j >= 0; j--) { + debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %p\n", j, device); + // stop the stream + if (!device->stopStreamByIndex(j)) { + debugWarning("Could not stop stream %d of device %p\n", j, device); + } + } + device_start_failed = true; + } else { + if (!device->enableStreaming()) { + debugWarning("Could not enable streaming on device %p!\n", device); + device_start_failed = true; + } + } + return !device_start_failed; +} + +bool DeviceManager::startStreaming() { + bool device_start_failed = false; + FFADODeviceVectorIterator it; + + // create the connections for all devices + // iterate over the found devices + for ( it = m_avDevices.begin(); + it != m_avDevices.end(); + ++it ) + { + if (!startStreamingOnDevice(*it)) { + debugWarning("Could not start streaming on device %p!\n", *it); + device_start_failed = true; + break; + } + } + + // if one of the devices failed to start, + // the previous routine should have cleaned up the failing one. + // we still have to stop all devices that were started before this one. + if(device_start_failed) { + for (FFADODeviceVectorIterator it2 = m_avDevices.begin(); + it2 != it; + ++it2 ) + { + if (!stopStreamingOnDevice(*it2)) { + debugWarning("Could not stop streaming on device %p!\n", *it2); + } + } + return false; + } + + // start the stream processor manager to tune in to the channels + if(m_processorManager->start()) { + return true; + } else { + debugWarning("Failed to start SPM!\n"); + for( it = m_avDevices.begin(); + it != m_avDevices.end(); + ++it ) + { + if (!stopStreamingOnDevice(*it)) { + debugWarning("Could not stop streaming on device %p!\n", *it); + } + } + return false; + } +} + +bool +DeviceManager::resetStreaming() { + return true; +} + +bool +DeviceManager::stopStreamingOnDevice(FFADODevice *device) +{ + assert(device); + bool result = true; + + if (!device->disableStreaming()) { + debugWarning("Could not disable streaming on device %p!\n", device); + } + + int j=0; + for(j=0; j < device->getStreamCount(); j++) { + debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %p\n", j, device); + // stop the stream + // start the stream + if (!device->stopStreamByIndex(j)) { + debugWarning("Could not stop stream %d of device %p\n", j, device); + result = false; + continue; + } + } + return result; +} + +bool +DeviceManager::stopStreaming() +{ + bool result = true; + m_processorManager->stop(); + // create the connections for all devices // iterate over the found devices @@ -835,66 +991,5 @@ ++it ) { - FFADODevice *device = *it; - assert(device); - - int j=0; - for(j=0; j < device->getStreamCount(); j++) { - debugOutput(DEBUG_LEVEL_VERBOSE,"Starting stream %d of device %p\n", j, device); - // start the stream - if (!device->startStreamByIndex(j)) { - debugWarning("Could not start stream %d of device %p\n", j, device); - continue; - } - } - - if (!device->enableStreaming()) { - debugWarning("Could not enable streaming on device %p!\n", device); - } - } - - if(m_processorManager->start()) { - return true; - } else { - stopStreaming(); - return false; - } -} - -bool -DeviceManager::resetStreaming() { - return true; -} - -bool -DeviceManager::stopStreaming() -{ - bool result = true; - m_processorManager->stop(); - - // create the connections for all devices - // iterate over the found devices - // add the stream processors of the devices to the managers - for ( FFADODeviceVectorIterator it = m_avDevices.begin(); - it != m_avDevices.end(); - ++it ) - { - FFADODevice *device = *it; - assert(device); - - if (!device->disableStreaming()) { - debugWarning("Could not disable streaming on device %p!\n", device); - } - - int j=0; - for(j=0; j < device->getStreamCount(); j++) { - debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %p\n", j, device); - // stop the stream - // start the stream - if (!device->stopStreamByIndex(j)) { - debugWarning("Could not stop stream %d of device %p\n", j, device); - result = false; - continue; - } - } + stopStreamingOnDevice(*it); } return result; Index: /trunk/libffado/config.h.in =================================================================== --- /trunk/libffado/config.h.in (revision 1673) +++ /trunk/libffado/config.h.in (revision 1763) @@ -117,6 +117,11 @@ // more robust. It should be noted though that shifting the transfer // time to a later time instant also causes the xmit buffer fill to be -// lower on average. +// lower on average. This can be counteracted by increasing the +// STREAMPROCESSORMANAGER_XMIT_PREBUFFER_FRAMES option #define STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS (3072*0) + +// the number of frames that we prebuffer in the 1394 ISO layer +// this adds directly to the roundtrip latency +#define STREAMPROCESSORMANAGER_XMIT_PREBUFFER_FRAMES 100 // causes the waitForPeriod() call to wait until sufficient Index: /trunk/libffado/tests/test-scs.cpp =================================================================== --- /trunk/libffado/tests/test-scs.cpp (revision 1595) +++ /trunk/libffado/tests/test-scs.cpp (revision 1763) @@ -325,5 +325,5 @@ virtual void operator() (byte_t *buff, size_t len) { if (m_ready) { - debugOutput(DEBUG_LEVEL_NORMAL, "got message len %d\n", len); + debugOutput(DEBUG_LEVEL_NORMAL, "got message len %zd\n", len); for (size_t s=0; s < len; s++) { Index: /trunk/libffado/tests/test-bufferops.cpp =================================================================== --- /trunk/libffado/tests/test-bufferops.cpp (revision 1136) +++ /trunk/libffado/tests/test-bufferops.cpp (revision 1763) @@ -30,4 +30,6 @@ #include "libutil/SystemTimeSource.h" +#include "libutil/Time.h" + #include @@ -86,5 +88,5 @@ byteSwapToBus(buffer_1, nb_quadlets); elapsed = Util::SystemTimeSource::getCurrentTimeAsUsecs() - start; - printMessage( " took %lluusec...\n", elapsed); + printMessage( " took %"PRI_FFADO_MICROSECS_T"usec...\n", elapsed); } @@ -154,5 +156,5 @@ convertFromInt24AndLabelAsMBLA(buffer_1, nb_quadlets); elapsed = Util::SystemTimeSource::getCurrentTimeAsUsecs() - start; - printMessage( " took %lluusec...\n", elapsed); + printMessage( " took %"PRI_FFADO_MICROSECS_T"usec...\n", elapsed); } @@ -236,5 +238,5 @@ convertFromFloatAndLabelAsMBLA(buffer_1, nb_quadlets); elapsed = Util::SystemTimeSource::getCurrentTimeAsUsecs() - start; - printMessage( " took %lluusec...\n", elapsed); + printMessage( " took %"PRI_FFADO_MICROSECS_T"usec...\n", elapsed); } Index: /trunk/libffado/tests/streaming/teststreaming-ipc.cpp =================================================================== --- /trunk/libffado/tests/streaming/teststreaming-ipc.cpp (revision 1254) +++ /trunk/libffado/tests/streaming/teststreaming-ipc.cpp (revision 1763) @@ -287,5 +287,5 @@ } - debugOutput(DEBUG_LEVEL_NORMAL, "verbose level = %d\n", arguments.verbose); + debugOutput(DEBUG_LEVEL_NORMAL, "verbose level = %ld\n", arguments.verbose); setDebugLevel(arguments.verbose); @@ -308,5 +308,5 @@ debugOutput(DEBUG_LEVEL_NORMAL, "FFADO streaming test application (3)\n"); - printMessage(" period %d, nb_buffers %d, playback %d, capture %d\n", + printMessage(" period %ld, nb_buffers %ld, playback %ld, capture %ld\n", arguments.period, arguments.nb_buffers, arguments.playback, @@ -374,14 +374,14 @@ printMessage("Device channel count: %d capture, %d playback\n", nb_in_channels, nb_out_channels); - printMessage("Requested channel count: %d capture, %d playback\n", + printMessage("Requested channel count: %ld capture, %ld playback\n", arguments.capture, arguments.playback); if(arguments.playback > nb_out_channels) { - debugError("Too many playback channels requested (want: %d, have:%d)\n", + debugError("Too many playback channels requested (want: %ld, have:%d)\n", arguments.playback, nb_out_channels); return -1; } if(arguments.capture > nb_in_channels) { - debugError("Too many capture channels requested (want: %d, have:%d)\n", + debugError("Too many capture channels requested (want: %ld, have:%d)\n", arguments.capture, nb_in_channels); return -1; @@ -460,5 +460,5 @@ // enter the loop debugOutput(DEBUG_LEVEL_NORMAL, - "Entering receive loop (IN: %d, OUT: %d)\n", + "Entering receive loop (IN: %ld, OUT: %ld)\n", arguments.capture, arguments.playback); Index: /trunk/libffado/tests/streaming/test-ipcclient.cpp =================================================================== --- /trunk/libffado/tests/streaming/test-ipcclient.cpp (revision 1256) +++ /trunk/libffado/tests/streaming/test-ipcclient.cpp (revision 1763) @@ -195,5 +195,5 @@ printMessage("Testing shared memory streaming IPC\n"); - printMessage(" period %d, nb_buffers %d, playback %d, capture %d\n", + printMessage(" period %ld, nb_buffers %ld, playback %ld, capture %ld\n", arguments.period, arguments.nb_buffers, arguments.playback, Index: /trunk/libffado/tests/streaming/teststreaming3.cpp =================================================================== --- /trunk/libffado/tests/streaming/teststreaming3.cpp (revision 1568) +++ /trunk/libffado/tests/streaming/teststreaming3.cpp (revision 1763) @@ -262,5 +262,5 @@ } - debugOutput(DEBUG_LEVEL_NORMAL, "verbose level = %d\n", arguments.verbose); + debugOutput(DEBUG_LEVEL_NORMAL, "verbose level = %d\n", (int)arguments.verbose); setDebugLevel(arguments.verbose); Index: /trunk/libffado/tests/test-focusrite.cpp =================================================================== --- /trunk/libffado/tests/test-focusrite.cpp (revision 1535) +++ /trunk/libffado/tests/test-focusrite.cpp (revision 1763) @@ -183,5 +183,5 @@ } if (!retval) { - debugError( " read from %16llX failed (id: %d)\n", addr, id); + debugError( " read from %16"PRIX64" failed (id: %d)\n", addr, id); } else { value = CondSwapFromBus32(value); Index: /trunk/libffado/tests/test-timestampedbuffer.cpp =================================================================== --- /trunk/libffado/tests/test-timestampedbuffer.cpp (revision 1146) +++ /trunk/libffado/tests/test-timestampedbuffer.cpp (revision 1763) @@ -346,7 +346,7 @@ if (timestamp != ts_head) { - debugError(" cycle %4u error: %011llu != %011llu\n", - timestamp, ts_head); - pass=false; + debugError(" cycle %4u error: %011"PRIu64" != %011"PRIu64"\n", + cycle, timestamp, ts_head); + pass=false; } @@ -418,7 +418,9 @@ } - debugOutput(DEBUG_LEVEL_NORMAL, "Simulating cycle %d @ time=%011llu, diff=%lld\n",cycle,time,diff); - - if(diff>0) { + debugOutput(DEBUG_LEVEL_NORMAL, + "Simulating cycle %d @ time=%011"PRIu64", diff=%"PRId64"\n", + cycle, time, diff); + + if(diff > 0) { ffado_timestamp_t ts_head_tmp, ts_tail_tmp; uint64_t ts_head, ts_tail; @@ -434,8 +436,8 @@ ts_tail=(uint64_t)ts_tail_tmp; debugOutput(DEBUG_LEVEL_NORMAL, - " TS after write: HEAD: %011llu, FC=%04u\n", + " TS after write: HEAD: %011"PRIu64", FC=%04u\n", ts_head,fc_head); debugOutput(DEBUG_LEVEL_NORMAL, - " TAIL: %011llu, FC=%04u\n", + " TAIL: %011"PRIu64", FC=%04u\n", ts_tail,fc_tail); @@ -449,8 +451,8 @@ ts_tail=(uint64_t)ts_tail_tmp; debugOutput(DEBUG_LEVEL_NORMAL, - " TS after write: HEAD: %011llu, FC=%04u\n", + " TS after write: HEAD: %011"PRIu64", FC=%04u\n", ts_head,fc_head); debugOutput(DEBUG_LEVEL_NORMAL, - " TAIL: %011llu, FC=%04u\n", + " TAIL: %011"PRIu64", FC=%04u\n", ts_tail,fc_tail); @@ -523,5 +525,7 @@ } - debugOutput(DEBUG_LEVEL_NORMAL, "Simulating cycle %d @ time=%011llu, diff=%lld\n",cycle,time,diff); + debugOutput(DEBUG_LEVEL_NORMAL, + "Simulating cycle %d @ time=%011"PRIu64", diff=%"PRId64"\n", + cycle, time, diff); if(diff>0) { @@ -539,8 +543,8 @@ ts_tail=(uint64_t)ts_tail_tmp; debugOutput(DEBUG_LEVEL_NORMAL, - " TS after write: HEAD: %011llu, FC=%04u\n", + " TS after write: HEAD: %011"PRIu64", FC=%04u\n", ts_head,fc_head); debugOutput(DEBUG_LEVEL_NORMAL, - " TAIL: %011llu, FC=%04u\n", + " TAIL: %011"PRIu64", FC=%04u\n", ts_tail,fc_tail); @@ -557,8 +561,8 @@ ts_tail=(uint64_t)ts_tail_tmp; debugOutput(DEBUG_LEVEL_NORMAL, - " TS after read: HEAD: %011llu, FC=%04u\n", + " TS after read: HEAD: %011"PRIu64", FC=%04u\n", ts_head,fc_head); debugOutput(DEBUG_LEVEL_NORMAL, - " TAIL: %011llu, FC=%04u\n", + " TAIL: %011"PRIu64", FC=%04u\n", ts_tail,fc_tail); } Index: /trunk/libffado/tests/test-dice-eap.cpp =================================================================== --- /trunk/libffado/tests/test-dice-eap.cpp (revision 1717) +++ /trunk/libffado/tests/test-dice-eap.cpp (revision 1763) @@ -271,6 +271,4 @@ e = NULL; eap.unlockControl(); - - int cnt = 0; while(run && arguments.counts != 0) { Index: /trunk/libffado/tests/systemtests/gen-loadpulses.cpp =================================================================== --- /trunk/libffado/tests/systemtests/gen-loadpulses.cpp (revision 1234) +++ /trunk/libffado/tests/systemtests/gen-loadpulses.cpp (revision 1763) @@ -33,4 +33,7 @@ #include +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif #include @@ -157,10 +160,10 @@ debugOutput(DEBUG_LEVEL_INFO, "System Load pulse generator\n"); debugOutput(DEBUG_LEVEL_INFO, " Arguments:\n"); - debugOutput(DEBUG_LEVEL_INFO, " RT priority : %d\n", arguments.rtprio); - debugOutput(DEBUG_LEVEL_INFO, " Countdown : %d\n", arguments.countdown); - debugOutput(DEBUG_LEVEL_INFO, " Period : %d usec\n", arguments.period); - debugOutput(DEBUG_LEVEL_INFO, " Pulse duration : %d usec\n", arguments.duration); - - debugOutput(DEBUG_LEVEL_INFO, "Setting RT priority (%d)...\n", arguments.rtprio); + debugOutput(DEBUG_LEVEL_INFO, " RT priority : %ld\n", arguments.rtprio); + debugOutput(DEBUG_LEVEL_INFO, " Countdown : %ld\n", arguments.countdown); + debugOutput(DEBUG_LEVEL_INFO, " Period : %ld usec\n", arguments.period); + debugOutput(DEBUG_LEVEL_INFO, " Pulse duration : %ld usec\n", arguments.duration); + + debugOutput(DEBUG_LEVEL_INFO, "Setting RT priority (%ld)...\n", arguments.rtprio); set_realtime_priority(arguments.rtprio); @@ -185,10 +188,10 @@ int64_t usecs_late = toc - sleep_time; if(usecs_late > 1000) { - debugWarning("late wakeup: %lld usecs\n", usecs_late); + debugWarning("late wakeup: %"PRId64" usecs\n", usecs_late); } // try and detect lockup () if(usecs_late > 100000) { - debugWarning("very late wakeup: %lld usecs\n", usecs_late); + debugWarning("very late wakeup: %"PRId64" usecs\n", usecs_late); // force exit, since this is a loop out of control run=0; Index: /trunk/libffado/tests/systemtests/test-isorecv-1.cpp =================================================================== --- /trunk/libffado/tests/systemtests/test-isorecv-1.cpp (revision 1700) +++ /trunk/libffado/tests/systemtests/test-isorecv-1.cpp (revision 1763) @@ -188,5 +188,5 @@ } - debugOutput(DEBUG_LEVEL_INFO, "Select 1394 port %d...\n", arguments.port); + debugOutput(DEBUG_LEVEL_INFO, "Select 1394 port %d...\n", (int) arguments.port); int ret = -1; do @@ -226,5 +226,5 @@ } - debugOutput(DEBUG_LEVEL_INFO, "Setting RT priority (%d)...\n", arguments.rtprio); + debugOutput(DEBUG_LEVEL_INFO, "Setting RT priority (%d)...\n", (int)arguments.rtprio); set_realtime_priority(arguments.rtprio); Index: /trunk/libffado/tests/systemtests/test-isoxmit-1.cpp =================================================================== --- /trunk/libffado/tests/systemtests/test-isoxmit-1.cpp (revision 1700) +++ /trunk/libffado/tests/systemtests/test-isoxmit-1.cpp (revision 1763) @@ -233,5 +233,5 @@ } - debugOutput(DEBUG_LEVEL_NORMAL, "verbose level = %d\n", arguments.verbose); + debugOutput(DEBUG_LEVEL_NORMAL, "verbose level = %d\n", (int) arguments.verbose); setDebugLevel(arguments.verbose); @@ -244,5 +244,5 @@ } - debugOutput(DEBUG_LEVEL_INFO, "Select 1394 port %d...\n", arguments.port); + debugOutput(DEBUG_LEVEL_INFO, "Select 1394 port %d...\n", (int)arguments.port); int ret = -1; do @@ -269,5 +269,5 @@ raw1394_set_bus_reset_handler(handle, myResetHandler); - debugOutput(DEBUG_LEVEL_INFO, "Setting RT priority (%d)...\n", arguments.rtprio); + debugOutput(DEBUG_LEVEL_INFO, "Setting RT priority (%d)...\n", (int)arguments.rtprio); set_realtime_priority(arguments.rtprio); Index: /trunk/libffado/tests/systemtests/test-sysload.cpp =================================================================== --- /trunk/libffado/tests/systemtests/test-sysload.cpp (revision 1234) +++ /trunk/libffado/tests/systemtests/test-sysload.cpp (revision 1763) @@ -33,4 +33,7 @@ #include +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif #include @@ -157,10 +160,10 @@ debugOutput(DEBUG_LEVEL_INFO, "Simple RT system loader\n"); debugOutput(DEBUG_LEVEL_INFO, " Arguments:\n"); - debugOutput(DEBUG_LEVEL_INFO, " RT priority : %d\n", arguments.rtprio); - debugOutput(DEBUG_LEVEL_INFO, " Countdown : %d\n", arguments.countdown); - debugOutput(DEBUG_LEVEL_INFO, " Period : %d usec\n", arguments.period); - debugOutput(DEBUG_LEVEL_INFO, " CPU load : %d%%\n", arguments.cpu_pct); - - debugOutput(DEBUG_LEVEL_INFO, "Setting RT priority (%d)...\n", arguments.rtprio); + debugOutput(DEBUG_LEVEL_INFO, " RT priority : %ld\n", arguments.rtprio); + debugOutput(DEBUG_LEVEL_INFO, " Countdown : %ld\n", arguments.countdown); + debugOutput(DEBUG_LEVEL_INFO, " Period : %ld usec\n", arguments.period); + debugOutput(DEBUG_LEVEL_INFO, " CPU load : %ld%%\n", arguments.cpu_pct); + + debugOutput(DEBUG_LEVEL_INFO, "Setting RT priority (%ld)...\n", arguments.rtprio); set_realtime_priority(arguments.rtprio); @@ -187,10 +190,10 @@ int64_t usecs_late = toc - sleep_time; if(usecs_late > 1000) { - debugWarning("late wakeup: %lld usecs\n", usecs_late); + debugWarning("late wakeup: %"PRId64" usecs\n", usecs_late); } // try and detect lockup () if(usecs_late > 100000) { - debugWarning("very late wakeup: %lld usecs\n", usecs_late); + debugWarning("very late wakeup: %"PRId64" usecs\n", usecs_late); // force exit, since this is a loop out of control run=0; Index: /trunk/libffado/tests/systemtests/test-clock_nanosleep.cpp =================================================================== --- /trunk/libffado/tests/systemtests/test-clock_nanosleep.cpp (revision 1079) +++ /trunk/libffado/tests/systemtests/test-clock_nanosleep.cpp (revision 1763) @@ -23,4 +23,5 @@ #include "debugmodule/debugmodule.h" +#include "libutil/Time.h" // needed for clock_nanosleep @@ -69,5 +70,5 @@ ts.tv_nsec = (wake_at_usec % (1000000LL)) * 1000LL; debugOutput(DEBUG_LEVEL_VERBOSE, - "clock_nanosleep until %lld sec, %lld nanosec\n", + "clock_nanosleep until %"PRId64" sec, %"PRId64" nanosec\n", (int64_t)ts.tv_sec, (int64_t)ts.tv_nsec); int err = clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &ts, NULL); @@ -105,5 +106,7 @@ wake_at += SLEEP_PERIOD_USECS; - debugOutput( DEBUG_LEVEL_VERBOSE, "cuckoo from %p at %012llu\n", obj, getCurrentTimeAsUsecs()); + debugOutput(DEBUG_LEVEL_VERBOSE, + "cuckoo from %p at %012"PRI_FFADO_MICROSECS_T"\n", + obj, getCurrentTimeAsUsecs()); pthread_testcancel(); Index: /trunk/libffado/tests/test-ieee1394service.cpp =================================================================== --- /trunk/libffado/tests/test-ieee1394service.cpp (revision 1550) +++ /trunk/libffado/tests/test-ieee1394service.cpp (revision 1763) @@ -165,5 +165,5 @@ } debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, - "(%p) Cycle timer: %011llu (%03us %04ucy %04uticks)\n", + "(%p) Cycle timer: %011"PRIu64" (%03us %04ucy %04uticks)\n", this, ctr, (unsigned int)TICKS_TO_SECS( ctr ), @@ -171,5 +171,5 @@ (unsigned int)TICKS_TO_OFFSET( ctr ) ); debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, - "(%p) from DLL: %011llu (%03us %04ucy %04uticks)\n", + "(%p) from DLL: %011"PRIu64" (%03us %04ucy %04uticks)\n", this, ctr_dll, (unsigned int)TICKS_TO_SECS( ctr_dll ), @@ -200,11 +200,11 @@ } debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, - "(%p) diff: %s%011llu (%03us %04ucy %04uticks)\n", this, + "(%p) diff: %s%011"PRIu64" (%03us %04ucy %04uticks)\n", this, ((int64_t)abs_diff==diff?" ":"-"), abs_diff, (unsigned int)TICKS_TO_SECS( abs_diff ), (unsigned int)TICKS_TO_CYCLES( abs_diff ), (unsigned int)TICKS_TO_OFFSET( abs_diff ) ); if (abs_diff > DIFF_CONSIDERED_LARGE) { - debugWarning("(%p) Alert, large diff: %lld\n", this, diff); - debugOutput ( DEBUG_LEVEL_NORMAL, - "(%p) Cycle timer: %011llu (%03us %04ucy %04uticks)\n", + debugWarning("(%p) Alert, large diff: %"PRId64"\n", this, diff); + debugOutput ( DEBUG_LEVEL_NORMAL, + "(%p) Cycle timer: %011"PRIu64" (%03us %04ucy %04uticks)\n", this, ctr, (unsigned int)TICKS_TO_SECS( ctr ), @@ -212,5 +212,5 @@ (unsigned int)TICKS_TO_OFFSET( ctr ) ); debugOutput ( DEBUG_LEVEL_NORMAL, - "(%p) from DLL: %011llu (%03us %04ucy %04uticks)\n", + "(%p) from DLL: %011"PRIu64" (%03us %04ucy %04uticks)\n", this, ctr_dll, (unsigned int)TICKS_TO_SECS( ctr_dll ), @@ -221,8 +221,8 @@ diff = diffTicks(ctr, ctr_prev); if (diff < 0) { - debugWarning("(%p) Alert, non-monotonic ctr (direct): %llu - %llu = %lld\n", + debugWarning("(%p) Alert, non-monotonic ctr (direct): %"PRId64" - %"PRId64" = %"PRId64"\n", this, ctr, ctr_prev, diff); debugOutput ( DEBUG_LEVEL_NORMAL, - "(%p) Cycle timer now : %011llu (%03us %04ucy %04uticks)\n", + "(%p) Cycle timer now : %011"PRIu64" (%03us %04ucy %04uticks)\n", this, ctr, (unsigned int)TICKS_TO_SECS( ctr ), @@ -230,5 +230,5 @@ (unsigned int)TICKS_TO_OFFSET( ctr ) ); debugOutput ( DEBUG_LEVEL_NORMAL, - "(%p) Cycle timer prev: %011llu (%03us %04ucy %04uticks)\n", + "(%p) Cycle timer prev: %011"PRIu64" (%03us %04ucy %04uticks)\n", this, ctr_prev, (unsigned int)TICKS_TO_SECS( ctr_prev ), @@ -238,8 +238,8 @@ diff = diffTicks(ctr_dll, ctr_dll_prev); if (diff < 0) { - debugWarning("(%p) Alert, non-monotonic ctr (dll): %llu - %llu = %lld\n", + debugWarning("(%p) Alert, non-monotonic ctr (dll): %"PRId64" - %"PRId64" = %"PRId64"\n", this, ctr_dll, ctr_dll_prev, diff); debugOutput ( DEBUG_LEVEL_NORMAL, - "(%p) Cycle timer now : %011llu (%03us %04ucy %04uticks)\n", + "(%p) Cycle timer now : %011"PRIu64" (%03us %04ucy %04uticks)\n", this, ctr_dll, (unsigned int)TICKS_TO_SECS( ctr_dll ), @@ -247,5 +247,5 @@ (unsigned int)TICKS_TO_OFFSET( ctr_dll ) ); debugOutput ( DEBUG_LEVEL_NORMAL, - "(%p) Cycle timer prev: %011llu (%03us %04ucy %04uticks)\n", + "(%p) Cycle timer prev: %011"PRIu64" (%03us %04ucy %04uticks)\n", this, ctr_dll_prev, (unsigned int)TICKS_TO_SECS( ctr_dll_prev ), @@ -268,5 +268,5 @@ (unsigned int)CYCLE_TIMER_GET_OFFSET( tmp_orig ) ); debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, - "(%p) TICKS: %011llu (%03us %04ucy %04uticks)\n", + "(%p) TICKS: %011"PRIu32" (%03us %04ucy %04uticks)\n", this, tmp_ticks, (unsigned int)TICKS_TO_SECS( tmp_ticks ), Index: /trunk/libffado/tests/test-ffado.cpp =================================================================== --- /trunk/libffado/tests/test-ffado.cpp (revision 1498) +++ /trunk/libffado/tests/test-ffado.cpp (revision 1763) @@ -351,5 +351,5 @@ int devices_on_bus = m_deviceManager->getNbDevices(); - printf(" port = %ld, devices_on_bus = %d\n", arguments.port, devices_on_bus); + printf(" port = %d, devices_on_bus = %d\n", (int)arguments.port, devices_on_bus); for(i=0;i + + Copyright (C) 2005-2008 by Pieter Palmers @@ -18,6 +19,6 @@ Phase88ControlUI - - + + 0 @@ -27,47 +28,47 @@ - + Terratec Phase 88 Control - - - - + + + + Mixer bus output: - + false - - - - + + + + S/PDIF Out - + Line Out 1/2 - + Line Out 3/4 - + Line Out 5/6 - + Line Out 7/8 - + None @@ -75,274 +76,274 @@ - - - + + + Hardware Mixer - + - - - - + + + + 1/2 - + false - - - + + + 3/4 - + false - - - + + + 5/6 - + false - - - + + + 7/8 - + false - - - + + + S/PDIF - + false - - - + + + WavePlay - + false - - - + + + Master - + false - - - - + + + + 0 0 - + 0 - + 32767 - - 10000 - - + + 10000 + + 1000 - + Qt::Vertical - - 10000 - - - - - - - + + 10000 + + + + + + + 0 0 - + 0 - + 32767 - - 10000 - - + + 10000 + + 1000 - + Qt::Vertical - - 10000 - - - - - - - + + 10000 + + + + + + + 0 0 - + 0 - + 32767 - - 10000 - - + + 10000 + + 1000 - + Qt::Vertical - - 10000 - - - - - - - + + 10000 + + + + + + + 0 0 - + 0 - + 32767 - - 10000 - - + + 10000 + + 1000 - + Qt::Vertical - - 10000 - - - - - - - + + 10000 + + + + + + + 0 0 - + 0 - + 32767 - - 10000 - - + + 10000 + + 1000 - + Qt::Vertical - - 10000 - - - - - - - + + 10000 + + + + + + + 0 0 - + 0 - + 32767 - - 10000 - - + + 10000 + + 1000 - + Qt::Vertical - - 10000 - - - - - - - + + 10000 + + + + + + + 0 0 - + 0 - + 32767 - - 10000 - - + + 10000 + + 1000 - + Qt::Vertical - + 10000 @@ -354,38 +355,38 @@ - - - + + + Waveplay Channel Source - + false - - - - + + + + S/PDIF - + CH 1/2 - + CH 3/4 - + CH5/6 - + CH7/8 @@ -393,47 +394,47 @@ - - - + + + In 7/8 Input Select - + false - - - - + + + + + Back + + + + Front - - - Back - - - - - - - + + + + + Sync Source - + false - - - - + + + + Internal - + External @@ -441,23 +442,23 @@ - - - + + + External Sync Source - + false - - - - + + + + S/PDIF - + WordClock @@ -467,5 +468,5 @@ - + qPixmapFromMimeSource @@ -477,9 +478,9 @@ switchOutAssign(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -493,9 +494,9 @@ switchFrontState(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -509,9 +510,9 @@ switchWaveInAssign(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -525,9 +526,9 @@ switchSyncSource(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -541,9 +542,9 @@ switchExtSyncSource(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -557,9 +558,9 @@ setVolume12(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -573,9 +574,9 @@ setVolume34(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -589,9 +590,9 @@ setVolume56(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -605,9 +606,9 @@ setVolume78(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -621,9 +622,9 @@ setVolumeMaster(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -637,9 +638,9 @@ setVolumeSPDIF(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 @@ -653,9 +654,9 @@ setVolumeWavePlay(int) - - 20 - 20 - - + + 20 + 20 + + 20 20 Index: /trunk/libffado/support/mixer-qt4/ffado/regdialog.py =================================================================== --- /trunk/libffado/support/mixer-qt4/ffado/regdialog.py (revision 1664) +++ /trunk/libffado/support/mixer-qt4/ffado/regdialog.py (revision 1763) @@ -1,2 +1,3 @@ +# -*- coding: utf-8 -*- # # Copyright (C) 2005-2008 by Pieter Palmers @@ -34,4 +35,5 @@

You are running this version of FFADO for the first time with this device.

+

If FFADO is useful to you, please consider a donation through http://www.ffado.org/?q=donations.

In order to collect usage statistics we would like to send some information about your system to ffado.org. Index: /trunk/libffado/support/firmware/fireworks-downloader.cpp =================================================================== --- /trunk/libffado/support/firmware/fireworks-downloader.cpp (revision 1498) +++ /trunk/libffado/support/firmware/fireworks-downloader.cpp (revision 1763) @@ -23,4 +23,5 @@ */ +#include "fbtypes.h" #include "downloader.h" @@ -214,5 +215,5 @@ if (node_id < 0) { - printMessage("Could not find device with GUID 0x%016llX\n", guid); + printMessage("Could not find device with GUID 0x%016"PRIX64"\n", guid); return -1; } Index: /trunk/libffado/support/dbus/SConscript =================================================================== --- /trunk/libffado/support/dbus/SConscript (revision 1694) +++ /trunk/libffado/support/dbus/SConscript (revision 1763) @@ -39,4 +39,5 @@ if not env.GetOption( "clean" ): env.MergeFlags( env["DBUS1_FLAGS"] ) + env.MergeFlags( env['LIBRAW1394_FLAGS'] ) if not env['SERIALIZE_USE_EXPAT']: env.MergeFlags( env['LIBXML26_FLAGS'] )