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:
@@ -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
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -10,6 +10,8 @@ add_library(gvfg SHARED
|
||||
src/gigabyte/gigabyte_types.h
|
||||
src/gigabyte/gigabyte_capture_session.cpp
|
||||
src/gigabyte/gigabyte_capture_session.h
|
||||
src/gigabyte/gigabyte_driver_extensions.cpp
|
||||
src/gigabyte/gigabyte_driver_extensions.h
|
||||
src/gigabyte/gigabyte_device.cpp
|
||||
src/gigabyte/gigabyte_device.h
|
||||
src/gpu/d3d_conversion_pipeline.cpp
|
||||
|
||||
@@ -9,6 +9,7 @@ EXPORTS
|
||||
gvfg_get_channel_event_mask
|
||||
gvfg_set_channel_zero_copy_enabled
|
||||
gvfg_get_channel_zero_copy_enabled
|
||||
gvfg_set_channel_video_format
|
||||
gvfg_set_channel_audio_enabled
|
||||
gvfg_get_channel_audio_format
|
||||
gvfg_start_channel
|
||||
@@ -29,4 +30,6 @@ EXPORTS
|
||||
gvfg_pixel_format_name
|
||||
gvfg_strerror
|
||||
gvfg_get_channel_last_error_detail
|
||||
gvfg_debug_get_channel_stats
|
||||
gvfg_debug_get_channel_backend_stats
|
||||
gvfg_debug_read_register
|
||||
gvfg_debug_write_register
|
||||
|
||||
@@ -340,6 +340,16 @@ extern "C"
|
||||
_In_ int channel_index,
|
||||
_Out_ int *out_enabled);
|
||||
|
||||
/*
|
||||
* Select the hardware output format before capture starts. This capability
|
||||
* currently uses an isolated driver extension because GvfgSdk.lib 1.0.0
|
||||
* does not expose an equivalent API.
|
||||
*/
|
||||
GVFG_API gvfg_status_t gvfg_set_channel_video_format(
|
||||
_In_ gvfg_handle handle,
|
||||
_In_ int channel_index,
|
||||
_In_ gvfg_pixel_format_t format);
|
||||
|
||||
/*
|
||||
* Enable or disable audio for the next channel start. Video remains
|
||||
* enabled; applications do not need to construct stream flag masks.
|
||||
|
||||
@@ -34,17 +34,17 @@ typedef struct
|
||||
uint64_t frames_returned;
|
||||
gvfg_debug_last_frame_info_t last_frame;
|
||||
|
||||
int session_state;
|
||||
uint64_t session_frames_captured;
|
||||
uint64_t session_frames_delivered;
|
||||
uint64_t session_dma_errors;
|
||||
uint64_t session_interrupt_count;
|
||||
uint64_t session_wait_timeouts;
|
||||
int backend_state;
|
||||
uint64_t backend_frames_captured;
|
||||
uint64_t backend_frames_delivered;
|
||||
uint64_t backend_dma_errors;
|
||||
uint64_t backend_interrupt_count;
|
||||
uint64_t backend_wait_timeouts;
|
||||
|
||||
int session_running;
|
||||
int session_capture_active;
|
||||
uint64_t session_latest_sequence;
|
||||
uint64_t session_delivered_sequence;
|
||||
int backend_running;
|
||||
int backend_capture_active;
|
||||
uint64_t backend_latest_sequence;
|
||||
uint64_t backend_delivered_sequence;
|
||||
uint64_t audio_dma_event_wakes;
|
||||
uint64_t extra_audio_event_wakes;
|
||||
uint64_t audio_frames_from_driver;
|
||||
@@ -55,18 +55,29 @@ typedef struct
|
||||
double get_frame_timing_average_us;
|
||||
double get_frame_timing_max300_us;
|
||||
double get_frame_timing_max_us;
|
||||
} gvfg_debug_channel_stats_t;
|
||||
} gvfg_debug_backend_stats_t;
|
||||
|
||||
/*
|
||||
* Query driver-neutral internal session counters.
|
||||
* Query driver-neutral internal backend counters.
|
||||
*
|
||||
* This exposes implementation-level counters for internal tools only. Customer
|
||||
* applications should use gvfg_get_channel_runtime_info() instead.
|
||||
*/
|
||||
GVFG_API gvfg_status_t gvfg_debug_get_channel_stats(
|
||||
GVFG_API gvfg_status_t gvfg_debug_get_channel_backend_stats(
|
||||
_In_ gvfg_handle handle,
|
||||
_In_ int channel_index,
|
||||
_Out_ gvfg_debug_channel_stats_t *out_stats);
|
||||
_Out_ gvfg_debug_backend_stats_t *out_stats);
|
||||
|
||||
/* GIGABYTELIB GAP: GvfgSdk.lib 1.0.0 has no register-access API. */
|
||||
GVFG_API gvfg_status_t gvfg_debug_read_register(
|
||||
_In_ gvfg_handle handle,
|
||||
_In_ uint32_t offset,
|
||||
_Out_ uint32_t *out_value);
|
||||
|
||||
GVFG_API gvfg_status_t gvfg_debug_write_register(
|
||||
_In_ gvfg_handle handle,
|
||||
_In_ uint32_t offset,
|
||||
_In_ uint32_t value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "gigabyte_capture_session.h"
|
||||
#include "gigabyte_driver_extensions.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -184,6 +185,24 @@ gigabyte_status_t GigabyteCaptureSession::set_audio_enabled(bool enabled)
|
||||
return GIGABYTE_OK;
|
||||
}
|
||||
|
||||
gigabyte_status_t GigabyteCaptureSession::set_video_format(gigabyte_pixel_format_t format)
|
||||
{
|
||||
if (format != GIGABYTE_PIXFMT_YUY2 && format != GIGABYTE_PIXFMT_Y210)
|
||||
return reject(GIGABYTE_EINVAL, "video format is invalid");
|
||||
if (running_)
|
||||
return reject(GIGABYTE_ESTATE, "video format cannot change while capture is running");
|
||||
const gigabyte_status_t openStatus = ensure_vendor_channel_open();
|
||||
if (openStatus != GIGABYTE_OK)
|
||||
return openStatus;
|
||||
|
||||
constexpr uint32_t kVideoOutputFormatRegister = 0x080;
|
||||
if (!gigabyte_write_register(device_handle_, kVideoOutputFormatRegister,
|
||||
format == GIGABYTE_PIXFMT_Y210 ? 1u : 0u))
|
||||
return reject(GIGABYTE_EIO,
|
||||
"GigabyteLib gap: driver extension failed to set the output format register");
|
||||
return GIGABYTE_OK;
|
||||
}
|
||||
|
||||
gigabyte_status_t GigabyteCaptureSession::refresh_video_info() const
|
||||
{
|
||||
if (!context_)
|
||||
@@ -571,6 +590,28 @@ void GigabyteCaptureSession::get_debug_stats(
|
||||
outDebugState.get_frame_timing_max_us = get_frame_timing_lifetime_max_us_;
|
||||
}
|
||||
|
||||
gigabyte_status_t GigabyteCaptureSession::debug_read_register(uint32_t offset, uint32_t &outValue) const
|
||||
{
|
||||
const gigabyte_status_t openStatus = ensure_vendor_channel_open();
|
||||
if (openStatus != GIGABYTE_OK)
|
||||
return openStatus;
|
||||
if (!gigabyte_read_register(device_handle_, offset, outValue))
|
||||
return reject(GIGABYTE_EIO,
|
||||
"GigabyteLib gap: driver extension register read failed");
|
||||
return GIGABYTE_OK;
|
||||
}
|
||||
|
||||
gigabyte_status_t GigabyteCaptureSession::debug_write_register(uint32_t offset, uint32_t value) const
|
||||
{
|
||||
const gigabyte_status_t openStatus = ensure_vendor_channel_open();
|
||||
if (openStatus != GIGABYTE_OK)
|
||||
return openStatus;
|
||||
if (!gigabyte_write_register(device_handle_, offset, value))
|
||||
return reject(GIGABYTE_EIO,
|
||||
"GigabyteLib gap: driver extension register write failed");
|
||||
return GIGABYTE_OK;
|
||||
}
|
||||
|
||||
gigabyte_status_t GigabyteCaptureSession::from_vendor(GVFG_HRESULT result, const char *operation) const
|
||||
{
|
||||
if (result == GVFG_HRESULT_OK)
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace gvfg::internal
|
||||
gigabyte_status_t set_zero_copy_enabled(bool enabled);
|
||||
bool zero_copy_enabled() const { return zero_copy_enabled_; }
|
||||
gigabyte_status_t set_audio_enabled(bool enabled);
|
||||
gigabyte_status_t set_video_format(gigabyte_pixel_format_t format);
|
||||
gigabyte_status_t get_signal_status(gigabyte_signal_status_t &out) const;
|
||||
gigabyte_status_t get_audio_format(gigabyte_audio_format_t &out) const;
|
||||
gigabyte_status_t set_event_callback(gigabyte_event_callback_t callback, void *user, uint32_t eventMask);
|
||||
@@ -51,6 +52,8 @@ namespace gvfg::internal
|
||||
gigabyte_status_t release_frame(const gigabyte_frame_t &frame);
|
||||
void get_debug_stats(gigabyte_stream_stats_t &outStats, uint64_t &outWaitTimeouts,
|
||||
gigabyte_debug_state_t &outDebugState) const;
|
||||
gigabyte_status_t debug_read_register(uint32_t offset, uint32_t &outValue) const;
|
||||
gigabyte_status_t debug_write_register(uint32_t offset, uint32_t value) const;
|
||||
|
||||
private:
|
||||
gigabyte_status_t open_device(const GigabyteDevice &device);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "gigabyte_driver_extensions.h"
|
||||
|
||||
#include <winioctl.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr DWORD kWriteRegister = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS);
|
||||
constexpr DWORD kReadRegister = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS);
|
||||
|
||||
struct RegisterAccess
|
||||
{
|
||||
ULONG offset;
|
||||
ULONG value;
|
||||
};
|
||||
}
|
||||
|
||||
namespace gvfg::internal
|
||||
{
|
||||
bool gigabyte_read_register(HANDLE device, uint32_t offset, uint32_t &value)
|
||||
{
|
||||
RegisterAccess request{offset, 0};
|
||||
DWORD returned = 0;
|
||||
if (!DeviceIoControl(device, kReadRegister,
|
||||
&request, sizeof(request), &request, sizeof(request),
|
||||
&returned, nullptr))
|
||||
return false;
|
||||
value = request.value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool gigabyte_write_register(HANDLE device, uint32_t offset, uint32_t value)
|
||||
{
|
||||
RegisterAccess request{offset, value};
|
||||
DWORD returned = 0;
|
||||
return DeviceIoControl(device, kWriteRegister,
|
||||
&request, sizeof(request), nullptr, 0,
|
||||
&returned, nullptr) != FALSE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace gvfg::internal
|
||||
{
|
||||
// GIGABYTELIB GAP: GvfgSdk.lib 1.0.0 does not expose register access or
|
||||
// output-format selection. Keep these driver extensions isolated here so
|
||||
// they can be deleted when equivalent Gvfg* APIs are supplied.
|
||||
bool gigabyte_read_register(HANDLE device, uint32_t offset, uint32_t &value);
|
||||
bool gigabyte_write_register(HANDLE device, uint32_t offset, uint32_t value);
|
||||
}
|
||||
@@ -593,7 +593,7 @@ struct gvfg_channel_session_t
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t getDebugStats(gvfg_debug_channel_stats_t &out)
|
||||
gvfg_status_t getDebugStats(gvfg_debug_backend_stats_t &out)
|
||||
{
|
||||
std::memset(&out, 0, sizeof(out));
|
||||
out.sdk_running = running.load(std::memory_order_relaxed) ? 1 : 0;
|
||||
@@ -623,16 +623,16 @@ struct gvfg_channel_session_t
|
||||
gigabyte_debug_state_t debugState{};
|
||||
uint64_t waitTimeouts = 0;
|
||||
session->get_debug_stats(stats, waitTimeouts, debugState);
|
||||
out.session_state = static_cast<int>(stats.state);
|
||||
out.session_frames_captured = stats.frames_captured;
|
||||
out.session_frames_delivered = stats.frames_delivered;
|
||||
out.session_dma_errors = stats.dma_errors;
|
||||
out.session_interrupt_count = stats.interrupt_count;
|
||||
out.session_wait_timeouts = waitTimeouts;
|
||||
out.session_running = debugState.running;
|
||||
out.session_capture_active = debugState.capture_active;
|
||||
out.session_latest_sequence = debugState.latest_sequence;
|
||||
out.session_delivered_sequence = debugState.delivered_sequence;
|
||||
out.backend_state = static_cast<int>(stats.state);
|
||||
out.backend_frames_captured = stats.frames_captured;
|
||||
out.backend_frames_delivered = stats.frames_delivered;
|
||||
out.backend_dma_errors = stats.dma_errors;
|
||||
out.backend_interrupt_count = stats.interrupt_count;
|
||||
out.backend_wait_timeouts = waitTimeouts;
|
||||
out.backend_running = debugState.running;
|
||||
out.backend_capture_active = debugState.capture_active;
|
||||
out.backend_latest_sequence = debugState.latest_sequence;
|
||||
out.backend_delivered_sequence = debugState.delivered_sequence;
|
||||
out.audio_dma_event_wakes = debugState.audio_dma_event_wakes;
|
||||
out.extra_audio_event_wakes = debugState.extra_audio_event_wakes;
|
||||
out.audio_frames_from_driver = debugState.audio_frames_from_driver;
|
||||
@@ -647,6 +647,28 @@ struct gvfg_channel_session_t
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t debugReadRegister(uint32_t offset, uint32_t &outValue)
|
||||
{
|
||||
if (!session)
|
||||
return reject(GVFG_ESTATE, "debug register read rejected: channel is not open");
|
||||
return map_status(session->debug_read_register(offset, outValue));
|
||||
}
|
||||
|
||||
gvfg_status_t setVideoFormat(gvfg_pixel_format_t format)
|
||||
{
|
||||
if (!session)
|
||||
return reject(GVFG_ESTATE, "gvfg_set_channel_video_format rejected: channel is not open");
|
||||
|
||||
gigabyte_pixel_format_t nativeFormat = GIGABYTE_PIXFMT_UNKNOWN;
|
||||
if (format == GVFG_PIXFMT_YUY2)
|
||||
nativeFormat = GIGABYTE_PIXFMT_YUY2;
|
||||
else if (format == GVFG_PIXFMT_Y210)
|
||||
nativeFormat = GIGABYTE_PIXFMT_Y210;
|
||||
else
|
||||
return reject(GVFG_EINVAL, "gvfg_set_channel_video_format rejected: pixel format is invalid");
|
||||
return map_status(session->set_video_format(nativeFormat));
|
||||
}
|
||||
|
||||
gvfg_status_t setAudioEnabled(bool enabled)
|
||||
{
|
||||
if (!session)
|
||||
@@ -660,6 +682,13 @@ struct gvfg_channel_session_t
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t debugWriteRegister(uint32_t offset, uint32_t value)
|
||||
{
|
||||
if (!session)
|
||||
return reject(GVFG_ESTATE, "debug register write rejected: channel is not open");
|
||||
return map_status(session->debug_write_register(offset, value));
|
||||
}
|
||||
|
||||
gvfg_status_t getAudioFormat(gvfg_audio_format_t &out)
|
||||
{
|
||||
std::memset(&out, 0, sizeof(out));
|
||||
@@ -846,6 +875,13 @@ struct gvfg_handle_t
|
||||
return status;
|
||||
}
|
||||
|
||||
gvfg_status_t rejectAllChannels(gvfg_status_t status, const char *message)
|
||||
{
|
||||
for (ChannelErrorState &error : channelErrors)
|
||||
error.set(message ? message : "GVFG operation rejected");
|
||||
return status;
|
||||
}
|
||||
|
||||
gvfg_status_t copyChannelError(int channelIndex,
|
||||
char *outMessage,
|
||||
uint32_t outMessageSize) const
|
||||
@@ -866,6 +902,13 @@ struct gvfg_handle_t
|
||||
return channels[static_cast<size_t>(channelIndex)].get();
|
||||
}
|
||||
|
||||
gvfg_channel_session_t *findOpenChannel()
|
||||
{
|
||||
if (channels[GVFG_CHANNEL_0])
|
||||
return channels[GVFG_CHANNEL_0].get();
|
||||
return channels[GVFG_CHANNEL_1].get();
|
||||
}
|
||||
|
||||
gvfg_status_t openChannel(int index, int channelIndex)
|
||||
{
|
||||
if (channelIndex != GVFG_CHANNEL_0 && channelIndex != GVFG_CHANNEL_1)
|
||||
@@ -940,6 +983,28 @@ struct gvfg_handle_t
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t setChannelVideoFormat(int channelIndex, gvfg_pixel_format_t format)
|
||||
{
|
||||
gvfg_channel_session_t *channel = findChannel(channelIndex);
|
||||
if (!channel)
|
||||
return rejectChannel(channelIndex, GVFG_ESTATE,
|
||||
"gvfg_set_channel_video_format rejected: channel is not open");
|
||||
if (format != GVFG_PIXFMT_YUY2 && format != GVFG_PIXFMT_Y210)
|
||||
return rejectChannel(channelIndex, GVFG_EINVAL,
|
||||
"gvfg_set_channel_video_format rejected: pixel format is invalid");
|
||||
|
||||
const int other = channelIndex == GVFG_CHANNEL_0 ? GVFG_CHANNEL_1 : GVFG_CHANNEL_0;
|
||||
if (format == GVFG_PIXFMT_Y210 &&
|
||||
requestedFormats[static_cast<size_t>(other)] == GVFG_PIXFMT_Y210)
|
||||
return rejectChannel(channelIndex, GVFG_ENOTSUP,
|
||||
"both channels cannot use Y210 at the same time");
|
||||
|
||||
const gvfg_status_t status = channel->setVideoFormat(format);
|
||||
if (status == GVFG_OK)
|
||||
requestedFormats[static_cast<size_t>(channelIndex)] = format;
|
||||
return status;
|
||||
}
|
||||
|
||||
gvfg_status_t stopAll()
|
||||
{
|
||||
gvfg_status_t result = GVFG_OK;
|
||||
@@ -954,12 +1019,29 @@ struct gvfg_handle_t
|
||||
return result;
|
||||
}
|
||||
|
||||
gvfg_status_t debugReadRegister(uint32_t offset, uint32_t &outValue)
|
||||
{
|
||||
gvfg_channel_session_t *channel = findOpenChannel();
|
||||
return channel ? channel->debugReadRegister(offset, outValue)
|
||||
: rejectAllChannels(GVFG_ESTATE,
|
||||
"debug register read rejected: no channel is open");
|
||||
}
|
||||
|
||||
gvfg_status_t debugWriteRegister(uint32_t offset, uint32_t value)
|
||||
{
|
||||
gvfg_channel_session_t *channel = findOpenChannel();
|
||||
return channel ? channel->debugWriteRegister(offset, value)
|
||||
: rejectAllChannels(GVFG_ESTATE,
|
||||
"debug register write rejected: no channel is open");
|
||||
}
|
||||
|
||||
std::array<ChannelErrorState, 2> channelErrors;
|
||||
std::shared_ptr<gvfg::internal::GigabyteDeviceConnection> deviceConnection;
|
||||
std::array<std::unique_ptr<gvfg_channel_session_t>, 2> channels;
|
||||
std::array<uint32_t, 2> eventMasks{GVFG_EVENT_MASK_ALL, GVFG_EVENT_MASK_ALL};
|
||||
int currentIndex = -1;
|
||||
std::array<bool, 2> zeroCopyRequested{false, false};
|
||||
std::array<gvfg_pixel_format_t, 2> requestedFormats{GVFG_PIXFMT_YUY2, GVFG_PIXFMT_YUY2};
|
||||
};
|
||||
|
||||
extern "C"
|
||||
@@ -1080,6 +1162,15 @@ extern "C"
|
||||
"gvfg_start_channel rejected: channel is not open");
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_set_channel_video_format(gvfg_handle handle,
|
||||
int channel_index,
|
||||
gvfg_pixel_format_t format)
|
||||
{
|
||||
if (!handle)
|
||||
return GVFG_EINVAL;
|
||||
return handle->setChannelVideoFormat(channel_index, format);
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_set_channel_audio_enabled(gvfg_handle handle,
|
||||
int channel_index,
|
||||
int enabled)
|
||||
@@ -1297,9 +1388,9 @@ extern "C"
|
||||
return handle->copyChannelError(channel_index, out_message, out_message_size);
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_debug_get_channel_stats(gvfg_handle handle,
|
||||
gvfg_status_t gvfg_debug_get_channel_backend_stats(gvfg_handle handle,
|
||||
int channel_index,
|
||||
gvfg_debug_channel_stats_t *out_stats)
|
||||
gvfg_debug_backend_stats_t *out_stats)
|
||||
{
|
||||
if (!handle || !out_stats)
|
||||
return GVFG_EINVAL;
|
||||
@@ -1307,7 +1398,7 @@ extern "C"
|
||||
gvfg_channel_session_t *channel = handle->findChannel(channel_index);
|
||||
if (!channel)
|
||||
return GVFG_ESTATE;
|
||||
gvfg_debug_channel_stats_t stats{};
|
||||
gvfg_debug_backend_stats_t stats{};
|
||||
const gvfg_status_t status = channel->getDebugStats(stats);
|
||||
if (status != GVFG_OK)
|
||||
return status;
|
||||
@@ -1316,4 +1407,22 @@ extern "C"
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_debug_read_register(gvfg_handle handle,
|
||||
uint32_t offset,
|
||||
uint32_t *out_value)
|
||||
{
|
||||
if (!handle || !out_value || (offset & 0x3u) != 0)
|
||||
return GVFG_EINVAL;
|
||||
return handle->debugReadRegister(offset, *out_value);
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_debug_write_register(gvfg_handle handle,
|
||||
uint32_t offset,
|
||||
uint32_t value)
|
||||
{
|
||||
if (!handle || (offset & 0x3u) != 0)
|
||||
return GVFG_EINVAL;
|
||||
return handle->debugWriteRegister(offset, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ Qt Sample 的 source boundary:
|
||||
客戶使用指南在 `docs/GVFG_CUSTOMER_API.md`,完整函式與結構參考在
|
||||
`docs/GVFG_CUSTOMER_API_REFERENCE.md`。內部架構、package
|
||||
切分、threading、frame ownership 說明在 `docs/GVFG_INTERNAL_NOTES.md`。
|
||||
主管 library 尚缺少的 API 與目前暫時補法整理在 `docs/GIGABYTELIB_GAPS.md`。
|
||||
|
||||
## Build
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# GigabyteLib 1.0.0 integration gaps
|
||||
|
||||
Capture, audio, events, signal information, copy mode, and zero-copy mode use
|
||||
the supervisor-provided `GvfgSdk.lib` API directly.
|
||||
|
||||
## Action required from the GigabyteLib owner
|
||||
|
||||
The following existing GVFG capabilities are not exposed by `GvfgSdk.lib 1.0.0`:
|
||||
|
||||
| GVFG capability | Current temporary implementation | Requested GigabyteLib API |
|
||||
|---|---|---|
|
||||
| Select YUY2 or Y210 output | Write global register `0x080` through the isolated driver extension | Add a channel-aware `GvfgSetVideoFormat` or equivalent |
|
||||
| Read a diagnostic register | Driver read-register request in `gigabyte_driver_extensions.cpp` | Add a supported diagnostic register-read API |
|
||||
| Write a diagnostic register | Driver write-register request in `gigabyte_driver_extensions.cpp` | Add a supported diagnostic register-write API |
|
||||
|
||||
These are marked `GIGABYTELIB GAP` in source. They intentionally do not use
|
||||
the removed `giga_ioctl.dll`; the minimal fallback is compiled into `gvfg.dll`.
|
||||
Once official `Gvfg*` functions exist, replace the three extension calls and
|
||||
delete `gigabyte_driver_extensions.*`.
|
||||
|
||||
The library owner should also confirm whether output-format register `0x080`
|
||||
is global or channel-specific and whether CH0 and CH1 may both select Y210.
|
||||
@@ -231,8 +231,8 @@ Zero-copy mode 的 driver lifecycle 由 SDK 管理:open 時 enable,每次成
|
||||
|
||||
成功 read 後,不論 PCM 是送往播放、錄音或被丟棄,都必須正好 release 一次。
|
||||
|
||||
Video format 由 `GvfgGetVideoInfo()` 回報的原生輸入格式決定。GigabyteLib 沒有
|
||||
輸出格式切換 API,因此 GVFG 不提供格式 setter。
|
||||
`gvfg_set_channel_video_format()` 可在 stream 尚未開始或已 stop 時選擇 YUY2/Y210。
|
||||
目前 GigabyteLib 1.0.0 沒有對應 API,因此此功能由隔離的 driver extension 暫時補足。
|
||||
|
||||
### 查詢
|
||||
|
||||
|
||||
@@ -263,7 +263,21 @@ gvfg_status_t gvfg_get_channel_zero_copy_enabled(gvfg_handle handle, int channel
|
||||
呼叫 `gvfg_release_channel_frame()`,且每個 channel 同時最多持有一張 frame。
|
||||
- SDK 在 open 時 enable driver zero-copy,在 destroy/close 前 disable。
|
||||
|
||||
### 1.19 Audio capture selection and frame ownership
|
||||
### 1.19 `gvfg_set_channel_video_format`
|
||||
|
||||
```c
|
||||
gvfg_status_t gvfg_set_channel_video_format(gvfg_handle handle,
|
||||
int channel_index,
|
||||
gvfg_pixel_format_t format);
|
||||
```
|
||||
|
||||
- 支援 `GVFG_PIXFMT_YUY2` 與 `GVFG_PIXFMT_Y210`。
|
||||
- Channel 必須已 open,且 capture 必須尚未 start 或已 stop。
|
||||
- 目前透過隔離的 driver extension 寫入 output-format register;這是
|
||||
`GvfgSdk.lib 1.0.0` 尚未提供的功能。
|
||||
- 同一裝置 CH0、CH1 不可同時設定 Y210。
|
||||
|
||||
### 1.20 Audio capture selection and frame ownership
|
||||
|
||||
```c
|
||||
gvfg_status_t gvfg_set_channel_audio_enabled(gvfg_handle handle,
|
||||
|
||||
@@ -122,8 +122,10 @@ x64 `gvfg_frame_t` ABI 已在 `gvfg_capture.cpp` 以 static assertions 固定為
|
||||
|
||||
## GigabyteLib requirement
|
||||
|
||||
GVFG 不再保存或操作 private IOCTL、register offset 或 DMA request layout。
|
||||
Driver ABI 相容性由主管提供的 `GvfgSdk.lib` 負責。
|
||||
Capture、audio、event 與 frame ownership 的 driver ABI 由主管提供的
|
||||
`GvfgSdk.lib` 負責。例外只有 library 1.0.0 尚未提供的 output-format selection
|
||||
與 diagnostic register R/W;它們集中在 `gigabyte_driver_extensions.*`,不得擴大
|
||||
成第二套 capture backend。待主管補上正式 `Gvfg*` API 後應刪除此 extension。
|
||||
|
||||
目前原生格式:
|
||||
|
||||
@@ -159,7 +161,7 @@ non-blocking、有限 timeout 與 infinite wait;stop 透過 `eventCv` 喚醒 w
|
||||
|
||||
`gvfg_debug.h` 僅供內部工具,包含:
|
||||
|
||||
- `gvfg_debug_get_channel_stats()`:指定 channel 的 facade/backend state、
|
||||
- `gvfg_debug_get_channel_backend_stats()`:指定 channel 的 facade/backend state、
|
||||
captured/delivered frame、DMA error、IRQ、timeout、sequence 與 GetFrame timing。
|
||||
|
||||
客戶診斷使用 `gvfg_get_channel_signal_status()`、`gvfg_get_channel_runtime_info()`、event、
|
||||
|
||||
@@ -125,7 +125,7 @@ Debug 診斷會增加 log 與檢查成本,不應拿來判斷正式版本效能
|
||||
- signal status、runtime FPS 與 channel event。
|
||||
- GPU conversion:BGRA8、RGB10A2、NV12。
|
||||
- 公開詳細錯誤 API:`gvfg_get_channel_last_error_detail()`。
|
||||
- 內部 debug API:session stats、register read/write。
|
||||
- 內部 debug API:backend stats、register read/write。
|
||||
|
||||
目前 FPGA 的 8-bit format register 仍可能回報舊 `YVYU` 值;SDK 只把它當作 legacy register identifier,對外格式與實際 DMA layout一律是 YUY2(`Y0 U0 Y1 V0`)。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user