/* config.h.in. */
#ifndef CONFIG_H
#define CONFIG_H

/* Name of package */
#define PACKAGE $PACKAGE

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "<ffado-devel@lists.sf.net>"

/* Define to the full name of this package. */
#define PACKAGE_NAME "$PACKAGE"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "$PACKAGE $VERSION$REVISIONSTRING"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "$PACKAGE"

/* Define to the version of this package. */
#define PACKAGE_VERSION "$VERSION$REVISIONSTRING"

/* Define to the version of the cace. */
#define CACHE_VERSION "$VERSION$REVISIONSTRING"
#define CACHEDIR "$CACHEDIR"

/* Define to the api version */
#define FFADO_API_VERSION $FFADO_API_VERSION

#define BINDIR "$BINDIR"
#define LIBDIR "$LIBDIR"
#define SHAREDIR "$SHAREDIR"

/* configuration file locations */
#define USER_CONFIG_FILE    "$USER_CONFIG_FILE"
#define SYSTEM_CONFIG_FILE  "$SYSTEM_CONFIG_FILE"

/* Define indicating availability of lrint() */
#define HAVE_LRINT $HAVE_LRINT

/* Define indicatin availability of lrintf() */
#define HAVE_LRINTF $HAVE_LRINTF

// serialization
#define SERIALIZE_USE_EXPAT $SERIALIZE_USE_EXPAT

// use a RT-safe message buffer for debug output
// useful to disable this when the code aborts/segfaults to
// not lose debug output. should be enabled though.
#define DEBUG_USE_MESSAGE_BUFFER             1
// max message length in the debug messagebuffer
#define DEBUG_MAX_MESSAGE_LENGTH          2048
// number of messages in the debug messagebuffer (power of two)
#define DEBUG_MB_BUFFERS                  1024

// use an RT thread for reading out the messagebuffer.
// can reduce the number of buffer xruns, but not
// recommended
#define DEBUG_MESSAGE_BUFFER_REALTIME        0
#define DEBUG_MESSAGE_BUFFER_REALTIME_PRIO   1

// When a write can't get the buffer lock, how many times
// should it retry, and wait how long between retries?
#define DEBUG_MESSAGE_BUFFER_COLLISION_WAIT_NTRIES      2
#define DEBUG_MESSAGE_BUFFER_COLLISION_WAIT_NSEC    50000


// support a debug backlog
// note that this does not influence non-debug builds
#define DEBUG_BACKLOG_SUPPORT                0
// number of messages in the backlog buffer (power of two)
#define DEBUG_BACKLOG_MB_BUFFERS            64

// support backtrace debugging
// note that this does not influence non-debug builds
#define DEBUG_BACKTRACE_SUPPORT              0
// max length of backtrace
#define DEBUG_MAX_BACKTRACE_LENGTH           8
// max amount of function pointers to keep track of
#define DEBUG_MAX_BACKTRACE_FUNCTIONS_SEEN  64

// lock debugging
#define DEBUG_LOCK_COLLISION_TRACING         0

// make this zero to disable the most extreme
// debug logging in the critical sections
#define DEBUG_EXTREME_ENABLE                 0

// discovery
#define ENABLE_DISCOVERY_CACHE               1

// watchdog
#define WATCHDOG_DEFAULT_CHECK_INTERVAL_USECS   (1000*1000*4)
#define WATCHDOG_DEFAULT_RUN_REALTIME           1
#define WATCHDOG_DEFAULT_PRIORITY               98

// threading
#define THREAD_MAX_RTPRIO                   98
#define THREAD_MIN_RTPRIO                   1

// time

// we should be using absolute clock_nanosleep
// but on my system it causes a problem on shutdown.
#define USE_ABSOLUTE_NANOSLEEP              1

// 1394 service constants 
#define IEEE1394SERVICE_USE_CYCLETIMER_DLL                         1
#define IEEE1394SERVICE_CYCLETIMER_DLL_UPDATE_INTERVAL_USEC   200000
#define IEEE1394SERVICE_CYCLETIMER_DLL_BANDWIDTH_HZ              0.5
#define IEEE1394SERVICE_MAX_FIREWIRE_PORTS                         4
#define IEEE1394SERVICE_MIN_SPLIT_TIMEOUT_USECS              1000000

#define IEEE1394SERVICE_CYCLETIMER_HELPER_RUN_REALTIME       1
#define IEEE1394SERVICE_CYCLETIMER_HELPER_PRIO               1

// config rom read wait interval
#define IEEE1394SERVICE_CONFIGROM_READ_WAIT_USECS         1000

// FCP defines
#define IEEE1394SERVICE_FCP_MAX_TRIES                       20
#define IEEE1394SERVICE_FCP_SLEEP_BETWEEN_FAILURES_USECS  1000
#define IEEE1394SERVICE_FCP_POLL_TIMEOUT_MSEC              200
#define IEEE1394SERVICE_FCP_RESPONSE_TIMEOUT_USEC      2000000

// The current version of libiec61883 doesn't seem to calculate
// the bandwidth correctly. Defining this to non-zero skips
// bandwidth allocation when doing CMP connections.
#define IEEE1394SERVICE_SKIP_IEC61883_BANDWIDTH_ALLOCATION   1

#define MINIMUM_INTERRUPTS_PER_PERIOD                       2U

// These are the result of a lot of trial and error
// due to weirdness in the kernel layer
#define MAX_XMIT_PACKET_SIZE                         (2048-16)
#define MIN_XMIT_PACKET_SIZE                                72
#define MAX_XMIT_NB_BUFFERS                                128
#define MAX_RECV_NB_BUFFERS                                 64
#define MIN_RECV_PACKET_SIZE                               130

// the default ISO receive mode. 
// 0 = auto, 1 = packet-per-buffer, 2 = bufferfill. 
// 'auto' will automatically choose the mode that is expected 
// to perform best for the given situation. For large periods 
// this is 'bufferfill' mode, for small periods this is 
// 'packet-per-buffer' mode. The 'BUFFERFILL_MODE_THRESHOLD' 
// defines what a 'large period' is.
#define DEFAULT_ISO_RECEIVE_MODE                             0

// the number of packets required to fill one period from which
// the bufferfill mode is to be used
#define BUFFERFILL_MODE_THRESHOLD                           64


#define ISOHANDLER_FLUSH_BEFORE_ITERATE                      0

#define ISOHANDLER_DEATH_DETECT_TIMEOUT_USECS        1000000LL

#define ISOHANDLER_CHECK_CTR_RECONSTRUCTION                  1

#define ISOHANDLERMANAGER_MAX_ISO_HANDLERS_PER_PORT         16
#define ISOHANDLERMANAGER_MAX_STREAMS_PER_ISOTHREAD         16

// The best setup is if the receive handlers have lower priority
// than the client thread since that ensures that as soon as we
// received sufficient frames, the client thread runs.
// The transmit thread should have higher priority to ensure that
// all available data is flushed to the ISO kernel buffers as
// soon as possible
// At this moment, the jack backend uses base+5 to init ffado
// prio
#define ISOHANDLERMANAGER_ISO_PRIO_INCREASE                  0
#define ISOHANDLERMANAGER_ISO_PRIO_INCREASE_RECV            -1
#define ISOHANDLERMANAGER_ISO_PRIO_INCREASE_XMIT             1

// the timeout for ISO activity on any thread
// NOTE: don't make this 0
#define ISOHANDLERMANAGER_ISO_TASK_WAIT_TIMEOUT_USECS        1000000LL

// allows to add some processing margin. This shifts the time
// at which the buffer is transfer()'ed, making things somewhat
// 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. 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
// data is present in the buffer such that a transfer() will
// succeed. Normally we wait for the period of time that theoretically
// would mean that his is true. However sometimes the kernel hasn't
// flushed everything to userspace (or the card hasn't IRQ'd).
// the side-effect of this is some jitter in the return timing
// whenever this occurs.
#define STREAMPROCESSORMANAGER_ALLOW_DELAYED_PERIOD_SIGNAL         1

// startup control
#define STREAMPROCESSORMANAGER_CYCLES_FOR_DRYRUN            40000
#define STREAMPROCESSORMANAGER_CYCLES_FOR_STARTUP           200
#define STREAMPROCESSORMANAGER_PRESTART_CYCLES_FOR_XMIT     20
#define STREAMPROCESSORMANAGER_PRESTART_CYCLES_FOR_RECV     0
#define STREAMPROCESSORMANAGER_SYNCSTART_TRIES              10
#define STREAMPROCESSORMANAGER_SYNC_WAIT_TIME_MSEC          200
#define STREAMPROCESSORMANAGER_NB_ALIGN_TRIES               40
#define STREAMPROCESSORMANAGER_ALIGN_AVERAGE_TIME_MSEC      400

#define STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY           0

// the default bandwidth of the stream processor timestamp DLL when synchronizing (should be fast)
#define STREAMPROCESSOR_DLL_FAST_BW_HZ                      5.0
// the default bandwidth of the stream processor timestamp DLL when streaming
#define STREAMPROCESSOR_DLL_BW_HZ                           0.1

// -- AMDTP options -- //

// in ticks
// as per AMDTP2.1:
// 354.17us + 125us @ 24.576ticks/usec = 11776.08192 ticks
#define AMDTP_TRANSMIT_TRANSFER_DELAY   (11776U)

// the absolute minimum number of cycles we want to transmit
// a packet ahead of the presentation time. The nominal time
// the packet is transmitted ahead of the presentation time is
// given by AMDTP_TRANSMIT_TRANSFER_DELAY (in ticks), but in case we
// are too late for that, this constant defines how late we can
// be.
#define AMDTP_MIN_CYCLES_BEFORE_PRESENTATION                1

// the absolute maximum number of cycles we want to transmit
// a packet ahead of the ideal transmit time. The nominal time
// the packet is transmitted ahead of the presentation time is
// given by AMDTP_TRANSMIT_TRANSFER_DELAY (in ticks), but we can send
// packets early if we want to. (not completely according to spec)
// (for spec compliance you need to specify a value of 0)
#define AMDTP_MAX_CYCLES_TO_TRANSMIT_EARLY                  1

// ensure that the AMDTP SP clips all float values to [-1.0..1.0]
#define AMDTP_CLIP_FLOATS                                   1

// Allow that devices request that the AMDTP transmit SP adds
// payload to the NO-DATA packets.
#define AMDTP_ALLOW_PAYLOAD_IN_NODATA_XMIT                  1

// Default setting for the payload setting if
// AMDTP_ALLOW_PAYLOAD_IN_NODATA_XMIT is enabled. Devices can
// explicity override this
#define AMDTP_SEND_PAYLOAD_IN_NODATA_XMIT_BY_DEFAULT     true

// -- MOTU options -- //

// the transfer delay is substracted from the ideal presentation
// time to obtain a corrected presentation time. This values is
// then used to stamp the packet and determine the transmission
// time instant.
#define MOTU_TRANSMIT_TRANSFER_DELAY    (0U)

// the absolute minimum number of cycles we want to transmit
// a packet ahead of the presentation time. The nominal time
// the packet is transmitted ahead of the presentation time is
// given by MOTU_TRANSMIT_TRANSFER_DELAY (in ticks), but in case we
// are too late for that, this constant defines how late we can
// be.
#define MOTU_MIN_CYCLES_BEFORE_PRESENTATION                0

// the absolute maximum number of cycles we want to transmit
// a packet ahead of the ideal transmit time. The nominal time
// the packet is transmitted ahead of the presentation time is
// given by MOTU_TRANSMIT_TRANSFER_DELAY (in ticks), but we can send
// packets early if we want to.
#define MOTU_MAX_CYCLES_TO_TRANSMIT_EARLY                  2

// ensure that the MOTU tx SP clips all float values to [-1.0..1.0]
#define MOTU_CLIP_FLOATS                                   1

/// The unavoidable device specific hacks

// Use the information in the music plug instead of that in the
// cluster info block for the stream configuration. Should not
// be necessary
#define AVC_STREAMCONFIG_USE_MUSICPLUG                     0

#endif // CONFIG_H
