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
@@ -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);
}