////////////////////////////////////////////////////////////////////////////////
// NVIDIA Sync Firmware Update Tool
////////////////////////////////////////////////////////////////////////////////

This tool is used to update the firmware on the Nvidia Sync product.

Use of this tool implies agreement with the "NVIDIA Driver License Agreement".
See the enclosed eula.txt document for the license text.
 
On Windows, open a CMD shell with Administrator privilege to run the
nvsyncupdate command.
 
On Linux, run the nvsyncupdate command with root/sudo privilege from a 
terminal.
 
Framelock must be disabled before updating the firmware.
If the tool detects that framelock is enabled, it will attempt to disable
framelock.
 
To check the current installed firmware version:
> nvsyncupdate status
 
To update the firmware:
> nvsyncupdate install
 
For a full list of all commands:
> nvsyncupdate --help
 
After updating the firmware, a reboot is required for the new firmware to take 
effect.


////////////////////////////////////////////////////////////////////////////////
// Firmware Changelog
////////////////////////////////////////////////////////////////////////////////

v2.18
- Core clock change 4x  (131.072MHz from 32.768MHz)
- Add sync multiply register
- Add sync skew register
- Remove P2061 stereo sync control register (now done in GPU on Kepler+)
- Fix bug to prevent driving swap ready high and low at same time
- Bug fix: Update internal sync pulse width sent on RJ45 to match v2.02 and
    earlier due to clock frequency change, which was preventing frame counter
    synchronization.
- Fix bug to enable interrupt pins on connectors 2,3
- Add more functionality for sync multiply/divide
- Improvement to servo circuit to improve locking speed:
    Lock will be indicated when the recovered vsync is within 30ppm of the
    external sync.
    Lock time should always be within two seconds.
    The intial vsync period must be within 100ppm of the external sync period.
- Add control register to disable rastersync busfighting when using nvlink
    bridges
- Change sync skew functionality:
    Now propogates skew to client Sync cards.  
    Limited only to incoming house sync signal on BNC connector.
- Bug fix: prevent swapready I/O contention
- Fix bug in house sync detect circuit for interlaced formats.
    Jitter threshold is now +/- 62.5 uS
- Fix bug LED behavior for Sync and Stereo LEDs
- Bug fix for sync skew functionality
- Bug fix when using sync skew without multiply/divide
- Bug fix for LED behavior for Sync LED
    New LED behavior: the Sync LED is now amber instead of green when
    Mosaic is enabled
- Bug fix for sync skew feature
- Bug fix for LEDs mapping to port numbers
- Add features for internal debugging capability
- Bug fix for VCO circuit
- Optimization of VCO control loop -- speeding up locking
- Bug fix when syncing multiple Sync boards
- Bug fix to sync to falling edge when detecting "composite" house sync signals
- Improved servo circuit

v2.19
- Updated VCO servo lock detection
    lock when gpu vsync phase matches reference sync phase and frequency is 
    within 31.5ppm.
- Updated sync synthesizer circuit
    Added external sync detector circuit to prevent the synthesizer from 
    continuing to generate a signal after the external sync has been removed.
- Updated vsync decoder circuit detection criteria
    new detection criteria: last_cycle_low_count + (last_cycle_low_count/2)
    nvbug reference: 4185821

v2.20
- Update VCO servo circuit
    added missing conditions for negative gain and positive error signal
    nvbug reference: 4265187

- Framelock pulse width fixed at 55uS
    The framelock pulses sent from P2061 to the GPU via internal header was 
    proportional to the vsync period in prev. firmware versions. This was 
    unreliable due to the period being calculated during rastersync startup.

v2.21
- Fix bug in raster sync detection circuit
    VCO servo and LED control circuits where activated when raster sync was
    inactive (regression; introduced in v2.19)
    nvbug reference: 4364980

v2.22
- The VCO servo phase detector circuit was redesigned.
    The old phase detector circuit was dependent on startup conditions. In some
    conditions the phase detector would reference a vsync edge farthest from the
    reference sync edge instead of the closest vsync edge. This would cause the
    servo to push the vsync edge away from the reference sync edge and the circuit
    would never achieve lock.
    The new circuit will always reference the vsync edge that is closest to the
    reference sync edge.
    nvbug reference: 4689298

v3.02
- Add Blackwell support - initial version
    backwards compatible to pre-Blackwell 2.x firmware

v3.03
- Removed timing source GPU exclusivity for writing CONTROL 2 register bits 4:2.

v3.04
- Change number of generated crash lock pulses from 7 to 1 for Raster Sync Decode Mode = 0x1 (CONTROL5[1:0]=0x1).

v3.05
- add VRR support
    Added new registers VRR SYNC WINDOW HIGH, VRR SYNC WINDOW LOW.
    Added new register bit STATUS 1 0x00 bit 3 VRR In Sync Window.
    Changed the VCO servo enable logic to remain disabled in VRR mode.
- Register block I2C write path optimizations.
- Removed deprecated debug circuits.

v3.06
- Fix logical port 0 I2C issue.
    Logical port 0 could be mapped to physical port 0 or 1.

////////////////////////////////////////////////////////////////////////////////
// Third Party Open Source Software Notice:
////////////////////////////////////////////////////////////////////////////////

// Copyright 2018-2022 René Ferdinand Rivera Morell
// Copyright 2017 Two Blue Cubes Ltd. All rights reserved.
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

# /* Copyright (C) 2001
#  * Housemarque Oy
#  * http://www.housemarque.com
#  *
#  * Distributed under the Boost Software License, Version 1.0. (See
#  * accompanying file LICENSE_1_0.txt or copy at
#  * http://www.boost.org/LICENSE_1_0.txt)
#  */
#
# /* Revised by Paul Mensonides (2002) */
# /* Revised by Edward Diener (2020) */
#
# /* See http://www.boost.org for most recent version. */

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

//  Boost string_algo library string_algo.hpp header file  -------------------//

//  Copyright Pavol Droba 2002-2004.
//
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/ for updates, documentation, and revision history.

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.


