Simplify the SDK around GigabyteLib

Compared with 0af70a5:

- Remove the generic backend directory and legacy PCIE S2MM naming so the SDK now has a direct gvfg facade to GigabyteCaptureSession to GvfgSdk.lib structure.

- Delete the unsupported video-format setter and direct register read/write APIs instead of retaining compatibility methods that cannot be implemented by the supplied GigabyteLib interface.

- Remove output-format controls and requested-format state from the Qt sample; capture now follows the native YUY2 or Y210 format reported by GvfgGetVideoInfo.

- Eliminate the placeholder stream descriptor and allocate copy buffers from current GigabyteLib video metadata when a frame becomes available.

- Rename the internal debug stats API and fields from backend terminology to channel/session terminology, while retaining capture, audio, event, timeout, timing, and zero-copy diagnostics.

- Update source paths and documentation to describe GigabyteLib as the only lower layer and remove stale format-setting, register, and direct IOCTL guidance.

Validation: git diff --cached --check passed. MSVC x64 Release and Debug gvfg.dll builds passed, the Release Qt sample rebuilt and linked successfully, dumpbin verified the intentional 29-export API, and the Release package script produced an archive containing the sample and gvfg.dll without private GigabyteLib files or giga_ioctl.dll. No runtime capture, audio, zero-copy, hot-plug, dual-channel, shutdown, MinGW, or hardware validation was run.
This commit is contained in:
Mark.lin
2026-09-14 10:05:54 +08:00
parent 0af70a59ca
commit a04bd611f9
26 changed files with 532 additions and 920 deletions
+16 -39
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_backend_stats_t &stats, bool signalConnected)
QString captureStatusText(const gvfg_debug_channel_stats_t &stats, bool signalConnected)
{
if (!stats.backend_running) return QStringLiteral("stopped");
if (!stats.session_running) return QStringLiteral("stopped");
if (!signalConnected) return QStringLiteral("waiting_signal");
if (!stats.backend_capture_active) return QStringLiteral("paused");
if (!stats.session_capture_active) return QStringLiteral("paused");
return QStringLiteral("streaming");
}
#endif
@@ -98,13 +98,11 @@ CaptureController::~CaptureController()
closeDevice();
}
void CaptureController::setChannelOptions(int channel, bool zeroCopy,
gvfg_pixel_format_t format, bool audioEnabled)
void CaptureController::setChannelOptions(int channel, bool zeroCopy, 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;
}
@@ -231,7 +229,7 @@ bool CaptureController::openChannel(int channel)
{
ChannelRuntime &runtime = channels_[channel];
if (runtime.opened)
return applyOutputFormat(channel);
return true;
if (handle_ == nullptr && !openDevice())
return false;
@@ -249,8 +247,6 @@ 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_)
@@ -295,25 +291,6 @@ void CaptureController::closeDevice()
emit stateChanged();
}
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("set output format register"), status, channel);
return false;
}
appendLog(QStringLiteral("CH%1 Output format | %2")
.arg(channel)
.arg(format == GVFG_PIXFMT_Y210 ? QStringLiteral("Y210") : QStringLiteral("YUY2")));
return true;
}
void CaptureController::startCapture(int channelIndex)
{
ChannelRuntime &channel = channels_[channelIndex];
@@ -656,8 +633,8 @@ void CaptureController::updateSignalStatus(bool queryHardware)
sdkBytes = channel.audioReceivedBytes;
appOutputBytes = channel.audioAcceptedBytes;
}
gvfg_debug_backend_stats_t audioStats{};
if (gvfg_debug_get_channel_backend_stats(handle_, channelIndex, &audioStats) == GVFG_OK)
gvfg_debug_channel_stats_t audioStats{};
if (gvfg_debug_get_channel_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)
@@ -702,23 +679,23 @@ void CaptureController::updateSignalStatus(bool queryHardware)
}
#if GVFG_INTERNAL_DIAGNOSTICS
gvfg_debug_backend_stats_t backendStats{};
if (gvfg_debug_get_channel_backend_stats(handle_, channelIndex, &backendStats) == GVFG_OK)
gvfg_debug_channel_stats_t channelStats{};
if (gvfg_debug_get_channel_stats(handle_, channelIndex, &channelStats) == GVFG_OK)
{
statusLines << QStringLiteral("CH%1 Capture | status=%2 dma_errors=%3 no_frame_waits=%4")
.arg(channelIndex)
.arg(captureStatusText(backendStats, signal.connected != 0))
.arg(static_cast<qulonglong>(backendStats.backend_dma_errors))
.arg(static_cast<qulonglong>(backendStats.backend_wait_timeouts));
if (channel.haveDebugBaseline && backendStats.backend_dma_errors > channel.lastDebugDmaErrors)
.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)
{
appendLog(QStringLiteral("CH%1 ERROR DMA failures +%2, total=%3")
.arg(channelIndex)
.arg(valueOrDash(backendStats.backend_dma_errors - channel.lastDebugDmaErrors),
valueOrDash(backendStats.backend_dma_errors)));
.arg(valueOrDash(channelStats.session_dma_errors - channel.lastDebugDmaErrors),
valueOrDash(channelStats.session_dma_errors)));
diagnosticProblemDetected = true;
}
channel.lastDebugDmaErrors = backendStats.backend_dma_errors;
channel.lastDebugDmaErrors = channelStats.session_dma_errors;
channel.haveDebugBaseline = true;
}
#endif
+1 -3
View File
@@ -29,7 +29,7 @@ public:
~CaptureController() override;
void setSelectedDeviceIndex(int index) { selectedDeviceIndex_ = index; }
void setChannelOptions(int channel, bool zeroCopy, gvfg_pixel_format_t format, bool audioEnabled);
void setChannelOptions(int channel, bool zeroCopy, bool audioEnabled);
void setChannelStatusVisible(int channel, bool visible);
void setPreviewTarget(int channel, void *nativeWindow);
void setPreviewVisible(int channel, bool visible);
@@ -47,7 +47,6 @@ public slots:
void refreshDevices();
bool openDevice();
void closeDevice();
bool applyOutputFormat(int channel);
void startCapture(int channel);
void stopCapture(int channel);
void stopAllCaptures();
@@ -71,7 +70,6 @@ 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};
+1 -35
View File
@@ -4,7 +4,6 @@
#include "ui_mainwindow.h"
#include <QCloseEvent>
#include <QStandardItemModel>
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
@@ -102,14 +101,6 @@ 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);
@@ -119,7 +110,6 @@ MainWindow::MainWindow(QWidget *parent)
if (controller_->deviceOpen()) controller_->updateSignalStatus(false);
});
updateOutputFormatOptions();
updateUiState();
controller_->logStartupInfo();
controller_->refreshDevices();
@@ -148,10 +138,8 @@ 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,
formatIndex == 1 ? GVFG_PIXFMT_Y210 : GVFG_PIXFMT_YUY2, audio);
controller_->setChannelOptions(channel, zeroCopy, audio);
}
void MainWindow::showPreviewWindow(int channel, bool fullscreen)
@@ -170,27 +158,6 @@ 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").arg(channel)
: QStringLiteral("Y210 is already selected by the other channel"));
}
}
void MainWindow::updateUiState()
{
const bool open = controller_->deviceOpen();
@@ -206,7 +173,6 @@ 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,7 +27,6 @@ protected:
private:
void syncControllerOptions(int channel);
void showPreviewWindow(int channel, bool fullscreen);
void updateOutputFormatOptions(int changedChannel = -1);
void updateUiState();
void appendLogLine(const QString &line);
+3 -54
View File
@@ -63,30 +63,6 @@
</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>Requested CH0 capture 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>
@@ -99,7 +75,7 @@
</property>
</widget>
</item>
<item row="0" column="3">
<item row="0" column="1">
<widget class="QCheckBox" name="ch0AudioCheckBox">
<property name="enabled">
<bool>true</bool>
@@ -115,7 +91,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="channel0ButtonLayout">
<item>
<widget class="QPushButton" name="ch0StartButton">
@@ -157,33 +133,6 @@
</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>Requested CH1 capture 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>
@@ -196,7 +145,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<item row="1" column="0">
<layout class="QHBoxLayout" name="channel1ButtonLayout">
<item>
<widget class="QPushButton" name="ch1StartButton">