Restore GVFG features missing from GigabyteLib

Compared with a04bd61:

- Restore the existing gvfg_set_channel_video_format API and the Qt sample YUY2/Y210 output-format controls with the original dual-channel Y210 restriction.

- Restore gvfg_debug_read_register, gvfg_debug_write_register, and the original gvfg_debug_get_channel_backend_stats names and fields so the established internal API remains compatible.

- Implement the three missing operations through a small in-process driver extension using the existing register read/write requests; capture, audio, events, signal queries, copy, and zero-copy paths continue to use GvfgSdk.lib.

- Mark every fallback as a GIGABYTELIB GAP and add a focused gap report requesting official format-selection and diagnostic register APIs from the GigabyteLib owner.

- Remove empty legacy backend and giga_ioctl directories without restoring giga_ioctl.dll or a second capture backend.

Validation: git diff --cached --check passed. MSVC x64 Release and Debug gvfg.dll builds passed, the Release Qt sample rebuilt and linked successfully, dumpbin confirmed all original 32 exports are present, and the Release package contains gvfg.dll without giga_ioctl.dll or private GigabyteLib files. The actual register operations, output-format switching, capture, audio, zero-copy, hot-plug, dual-channel behavior, shutdown, MinGW, and hardware behavior were not runtime-tested.
This commit is contained in:
Mark.lin
2026-09-14 10:22:09 +08:00
parent a04bd611f9
commit 9bc38c4862
20 changed files with 413 additions and 57 deletions
+38 -15
View File
@@ -39,11 +39,11 @@ namespace
QString boolText(int value) { return value ? QStringLiteral("yes") : QStringLiteral("no"); }
QString valueOrDash(uint64_t value) { return QString::number(static_cast<qulonglong>(value)); }
QString captureStatusText(const gvfg_debug_channel_stats_t &stats, bool signalConnected)
QString captureStatusText(const gvfg_debug_backend_stats_t &stats, bool signalConnected)
{
if (!stats.session_running) return QStringLiteral("stopped");
if (!stats.backend_running) return QStringLiteral("stopped");
if (!signalConnected) return QStringLiteral("waiting_signal");
if (!stats.session_capture_active) return QStringLiteral("paused");
if (!stats.backend_capture_active) return QStringLiteral("paused");
return QStringLiteral("streaming");
}
#endif
@@ -98,11 +98,13 @@ CaptureController::~CaptureController()
closeDevice();
}
void CaptureController::setChannelOptions(int channel, bool zeroCopy, bool audioEnabled)
void CaptureController::setChannelOptions(int channel, bool zeroCopy,
gvfg_pixel_format_t format, bool audioEnabled)
{
if (channel < GVFG_CHANNEL_0 || channel > GVFG_CHANNEL_1)
return;
channels_[channel].zeroCopy = zeroCopy;
channels_[channel].requestedFormat = format;
channels_[channel].requestedAudio = channel == GVFG_CHANNEL_0 && audioEnabled;
}
@@ -229,7 +231,7 @@ bool CaptureController::openChannel(int channel)
{
ChannelRuntime &runtime = channels_[channel];
if (runtime.opened)
return true;
return applyOutputFormat(channel);
if (handle_ == nullptr && !openDevice())
return false;
@@ -247,6 +249,8 @@ bool CaptureController::openChannel(int channel)
return false;
}
runtime.opened = true;
if (!applyOutputFormat(channel))
return false;
appendLog(QStringLiteral("Opened device index %1 CH%2 | mode=%3")
.arg(selectedDeviceIndex_)
@@ -256,6 +260,25 @@ bool CaptureController::openChannel(int channel)
return true;
}
bool CaptureController::applyOutputFormat(int channel)
{
if (handle_ == nullptr || !channels_[channel].opened ||
channels_[channel].running.load(std::memory_order_acquire))
return false;
const gvfg_pixel_format_t format = channels_[channel].requestedFormat;
const gvfg_status_t status = gvfg_set_channel_video_format(handle_, channel, format);
if (status != GVFG_OK)
{
reportError(QStringLiteral("gvfg_set_channel_video_format"), status, channel);
return false;
}
appendLog(QStringLiteral("CH%1 Output format | %2 (GigabyteLib extension)")
.arg(channel)
.arg(format == GVFG_PIXFMT_Y210 ? QStringLiteral("Y210") : QStringLiteral("YUY2")));
return true;
}
void CaptureController::closeDevice()
{
if (runtimeStatusTimer_)
@@ -633,8 +656,8 @@ void CaptureController::updateSignalStatus(bool queryHardware)
sdkBytes = channel.audioReceivedBytes;
appOutputBytes = channel.audioAcceptedBytes;
}
gvfg_debug_channel_stats_t audioStats{};
if (gvfg_debug_get_channel_stats(handle_, channelIndex, &audioStats) == GVFG_OK)
gvfg_debug_backend_stats_t audioStats{};
if (gvfg_debug_get_channel_backend_stats(handle_, channelIndex, &audioStats) == GVFG_OK)
{
statusLines << QStringLiteral("CH%1 Audio Debug | Events DMA=%2 Extra=%3 | Driver->SDK %4 frames/%5 bytes | SDK->APP %6 frames/%7 bytes | APP->Output %8 bytes")
.arg(channelIndex)
@@ -679,23 +702,23 @@ void CaptureController::updateSignalStatus(bool queryHardware)
}
#if GVFG_INTERNAL_DIAGNOSTICS
gvfg_debug_channel_stats_t channelStats{};
if (gvfg_debug_get_channel_stats(handle_, channelIndex, &channelStats) == GVFG_OK)
gvfg_debug_backend_stats_t channelStats{};
if (gvfg_debug_get_channel_backend_stats(handle_, channelIndex, &channelStats) == GVFG_OK)
{
statusLines << QStringLiteral("CH%1 Capture | status=%2 dma_errors=%3 no_frame_waits=%4")
.arg(channelIndex)
.arg(captureStatusText(channelStats, signal.connected != 0))
.arg(static_cast<qulonglong>(channelStats.session_dma_errors))
.arg(static_cast<qulonglong>(channelStats.session_wait_timeouts));
if (channel.haveDebugBaseline && channelStats.session_dma_errors > channel.lastDebugDmaErrors)
.arg(static_cast<qulonglong>(channelStats.backend_dma_errors))
.arg(static_cast<qulonglong>(channelStats.backend_wait_timeouts));
if (channel.haveDebugBaseline && channelStats.backend_dma_errors > channel.lastDebugDmaErrors)
{
appendLog(QStringLiteral("CH%1 ERROR DMA failures +%2, total=%3")
.arg(channelIndex)
.arg(valueOrDash(channelStats.session_dma_errors - channel.lastDebugDmaErrors),
valueOrDash(channelStats.session_dma_errors)));
.arg(valueOrDash(channelStats.backend_dma_errors - channel.lastDebugDmaErrors),
valueOrDash(channelStats.backend_dma_errors)));
diagnosticProblemDetected = true;
}
channel.lastDebugDmaErrors = channelStats.session_dma_errors;
channel.lastDebugDmaErrors = channelStats.backend_dma_errors;
channel.haveDebugBaseline = true;
}
#endif
+3 -1
View File
@@ -29,7 +29,7 @@ public:
~CaptureController() override;
void setSelectedDeviceIndex(int index) { selectedDeviceIndex_ = index; }
void setChannelOptions(int channel, bool zeroCopy, bool audioEnabled);
void setChannelOptions(int channel, bool zeroCopy, gvfg_pixel_format_t format, bool audioEnabled);
void setChannelStatusVisible(int channel, bool visible);
void setPreviewTarget(int channel, void *nativeWindow);
void setPreviewVisible(int channel, bool visible);
@@ -47,6 +47,7 @@ public slots:
void refreshDevices();
bool openDevice();
void closeDevice();
bool applyOutputFormat(int channel);
void startCapture(int channel);
void stopCapture(int channel);
void stopAllCaptures();
@@ -70,6 +71,7 @@ private:
bool opened = false;
bool zeroCopy = false;
bool requestedAudio = false;
gvfg_pixel_format_t requestedFormat = GVFG_PIXFMT_YUY2;
void *previewTarget = nullptr;
gvfg_preview_handle previewHandle = nullptr;
std::atomic<bool> running{false}, stopRequested{false}, signalConnected{false};
+36 -1
View File
@@ -4,6 +4,7 @@
#include "ui_mainwindow.h"
#include <QCloseEvent>
#include <QStandardItemModel>
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
@@ -101,6 +102,15 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui_->ch0FullscreenButton, &QPushButton::clicked, this, [this] { showPreviewWindow(0, true); });
connect(ui_->ch1FullscreenButton, &QPushButton::clicked, this, [this] { showPreviewWindow(1, true); });
auto formatChanged = [this](int channel) {
updateOutputFormatOptions(channel);
syncControllerOptions(channel);
if (controller_->channelOpened(channel) && !controller_->channelRunning(channel))
{ controller_->applyOutputFormat(channel); controller_->updateSignalStatus(); }
};
connect(ui_->ch0OutputFormatCombo, &QComboBox::currentIndexChanged, this, [formatChanged](int) { formatChanged(0); });
connect(ui_->ch1OutputFormatCombo, &QComboBox::currentIndexChanged, this, [formatChanged](int) { formatChanged(1); });
connect(ui_->ch0ZeroCopyCheckBox, &QCheckBox::toggled, this, [this](bool) {
syncControllerOptions(GVFG_CHANNEL_0);
if (controller_->deviceOpen()) controller_->updateSignalStatus(false);
@@ -110,6 +120,7 @@ MainWindow::MainWindow(QWidget *parent)
if (controller_->deviceOpen()) controller_->updateSignalStatus(false);
});
updateOutputFormatOptions();
updateUiState();
controller_->logStartupInfo();
controller_->refreshDevices();
@@ -138,8 +149,10 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::syncControllerOptions(int channel)
{
const bool zeroCopy = channel == 0 ? ui_->ch0ZeroCopyCheckBox->isChecked() : ui_->ch1ZeroCopyCheckBox->isChecked();
const int formatIndex = channel == 0 ? ui_->ch0OutputFormatCombo->currentIndex() : ui_->ch1OutputFormatCombo->currentIndex();
const bool audio = channel == 0 && ui_->ch0AudioCheckBox->isChecked();
controller_->setChannelOptions(channel, zeroCopy, audio);
controller_->setChannelOptions(channel, zeroCopy,
formatIndex == 1 ? GVFG_PIXFMT_Y210 : GVFG_PIXFMT_YUY2, audio);
}
void MainWindow::showPreviewWindow(int channel, bool fullscreen)
@@ -158,6 +171,27 @@ void MainWindow::showPreviewWindow(int channel, bool fullscreen)
: QStringLiteral("CH%1 Show Preview failed: unable to update preview window").arg(channel));
}
void MainWindow::updateOutputFormatOptions(int changedChannel)
{
QComboBox *combos[] = {ui_->ch0OutputFormatCombo, ui_->ch1OutputFormatCombo};
constexpr int y210 = 1;
if ((changedChannel == 0 || changedChannel == 1) && combos[changedChannel]->currentIndex() == y210)
{
const int other = changedChannel == 0 ? 1 : 0;
if (combos[other]->currentIndex() == y210) combos[other]->setCurrentIndex(0);
}
const bool enabled[] = {combos[1]->currentIndex() != y210, combos[0]->currentIndex() != y210};
for (int channel = 0; channel < 2; ++channel)
{
auto *model = qobject_cast<QStandardItemModel *>(combos[channel]->model());
if (model && model->item(y210)) model->item(y210)->setEnabled(enabled[channel]);
combos[channel]->setToolTip(
enabled[channel]
? QStringLiteral("Requested CH%1 capture output format (GigabyteLib extension)").arg(channel)
: QStringLiteral("Y210 is already selected by the other channel"));
}
}
void MainWindow::updateUiState()
{
const bool open = controller_->deviceOpen();
@@ -173,6 +207,7 @@ void MainWindow::updateUiState()
ui_->ch1PreviewButton->setEnabled(running[1] && controller_->frameAvailable(1));
ui_->ch0FullscreenButton->setEnabled(ui_->ch0PreviewButton->isEnabled());
ui_->ch1FullscreenButton->setEnabled(ui_->ch1PreviewButton->isEnabled());
ui_->ch0OutputFormatCombo->setEnabled(!running[0]); ui_->ch1OutputFormatCombo->setEnabled(!running[1]);
ui_->ch0ZeroCopyCheckBox->setEnabled(!controller_->channelOpened(0));
ui_->ch1ZeroCopyCheckBox->setEnabled(!controller_->channelOpened(1));
ui_->ch0AudioCheckBox->setEnabled(!running[0]);
+1
View File
@@ -27,6 +27,7 @@ protected:
private:
void syncControllerOptions(int channel);
void showPreviewWindow(int channel, bool fullscreen);
void updateOutputFormatOptions(int changedChannel = -1);
void updateUiState();
void appendLogLine(const QString &line);
+28 -3
View File
@@ -63,6 +63,18 @@
</property>
<layout class="QGridLayout" name="channel0GridLayout">
<item row="0" column="0">
<widget class="QLabel" name="channel0FormatLabel">
<property name="text"><string>Output format:</string></property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="ch0OutputFormatCombo">
<property name="toolTip"><string>GigabyteLib extension: requested CH0 output format</string></property>
<item><property name="text"><string>YUY2 (8-bit 4:2:2)</string></property></item>
<item><property name="text"><string>Y210 (10-bit 4:2:2)</string></property></item>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="ch0ZeroCopyCheckBox">
<property name="toolTip">
<string>Must be selected before opening CH0</string>
@@ -75,7 +87,7 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="3">
<widget class="QCheckBox" name="ch0AudioCheckBox">
<property name="enabled">
<bool>true</bool>
@@ -91,7 +103,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item row="1" column="0" colspan="4">
<layout class="QHBoxLayout" name="channel0ButtonLayout">
<item>
<widget class="QPushButton" name="ch0StartButton">
@@ -133,6 +145,19 @@
</property>
<layout class="QGridLayout" name="channel1GridLayout">
<item row="0" column="0">
<widget class="QLabel" name="channel1FormatLabel">
<property name="text"><string>Output format:</string></property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="ch1OutputFormatCombo">
<property name="enabled"><bool>false</bool></property>
<property name="toolTip"><string>GigabyteLib extension: requested CH1 output format</string></property>
<item><property name="text"><string>YUY2 (8-bit 4:2:2)</string></property></item>
<item><property name="text"><string>Y210 (10-bit 4:2:2)</string></property></item>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="ch1ZeroCopyCheckBox">
<property name="enabled">
<bool>false</bool>
@@ -145,7 +170,7 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="0" colspan="3">
<layout class="QHBoxLayout" name="channel1ButtonLayout">
<item>
<widget class="QPushButton" name="ch1StartButton">