Add HDMI input and chip queries to GVFG SDK 3.1

- Expose HDMI input and chip information through the capture API and rename the full-frame OSD rendering entry point.
- Update the bundled Gigabyte library and add opt-in internal diagnostics with a user LED control.
- Update the customer API reference, generated PDF, and build guidance.

Validation: git diff --cached --check passed. Build and runtime tests were not run for this commit.
This commit is contained in:
Mark.lin
2026-11-17 17:40:25 +08:00
parent 47a5f041ee
commit 7a7027391e
20 changed files with 568 additions and 47 deletions
@@ -3,6 +3,8 @@
#include <algorithm>
#include <array>
#include <cinttypes>
#include <cstdio>
namespace
{
@@ -12,9 +14,48 @@ namespace
constexpr uint32_t kFourccY210 = GVFG_MAKEFOURCC('Y', '2', '1', '0');
constexpr DWORD kVideoFormatChangeTimeoutMs = 1000;
constexpr DWORD kVideoFormatSettleMs = 500;
// Temporary bring-up workaround: HDMI VideoSignalLock is not implemented
// by the current driver/FPGA. Set false once HDMI lock reporting is ready.
constexpr bool kBypassHdmiSignalLock = true;
const char *hdmi_color_format_name(uint32_t code)
{
switch (code)
{
case GVFG_HDMI_CF_RGB: return "RGB";
case GVFG_HDMI_CF_YUV_422: return "YUV 4:2:2";
case GVFG_HDMI_CF_YUV_444: return "YUV 4:4:4";
case GVFG_HDMI_CF_YUV_420: return "YUV 4:2:0";
default: return "Unknown";
}
}
const char *hdmi_color_space_name(uint32_t code)
{
switch (code)
{
case GVFG_HDMI_CS_DEFAULT_RGB: return "Default RGB";
case GVFG_HDMI_CS_RGB: return "RGB";
case GVFG_HDMI_CS_YUV_601: return "YUV 601";
case GVFG_HDMI_CS_YUV_709: return "YUV 709";
case GVFG_HDMI_CS_YCC_601: return "YCC 601";
case GVFG_HDMI_CS_YCC_709: return "YCC 709";
case GVFG_HDMI_CS_SYCC_601: return "sYCC 601";
case GVFG_HDMI_CS_ADOBE_YCC_601: return "Adobe YCC 601";
case GVFG_HDMI_CS_ADOBE_RGB: return "Adobe RGB";
case GVFG_HDMI_CS_BT2020_YCC: return "BT.2020 YCC";
case GVFG_HDMI_CS_BT2020_RGB: return "BT.2020 RGB";
case GVFG_HDMI_CS_AUTO: return "Auto";
case GVFG_HDMI_CS_LIM_RGB: return "RGB (Limited)";
case GVFG_HDMI_CS_LIM_YUV_601: return "YUV 601 (Limited)";
case GVFG_HDMI_CS_LIM_YUV_709: return "YUV 709 (Limited)";
case GVFG_HDMI_CS_LIM_YCC_601: return "YCC 601 (Limited)";
case GVFG_HDMI_CS_LIM_YCC_709: return "YCC 709 (Limited)";
case GVFG_HDMI_CS_LIM_SYCC_601: return "sYCC 601 (Limited)";
case GVFG_HDMI_CS_LIM_ADOBE_YCC_601: return "Adobe YCC 601 (Limited)";
case GVFG_HDMI_CS_LIM_ADOBE_RGB: return "Adobe RGB (Limited)";
case GVFG_HDMI_CS_LIM_BT2020_YCC: return "BT.2020 YCC (Limited)";
case GVFG_HDMI_CS_LIM_BT2020_RGB: return "BT.2020 RGB (Limited)";
default: return "Unknown";
}
}
uint64_t monotonic_ns()
{
@@ -268,12 +309,7 @@ namespace gvfg::internal
if (status != GVFG_OK)
return status;
gvfg_signal_status_t signal{};
// Apply the HDMI workaround here so Start, frame reads and SDK clients
// use the same effective signal state. SDI still uses the reported lock.
// With bypass enabled, HDMI connected does not prove physical signal lock.
const bool bypassLock = kBypassHdmiSignalLock &&
info.VideoInterface == GVFG_VIDEO_INTERFACE_HDMI;
signal.connected = (bypassLock || info.VideoSignalLock != 0) ? 1 : 0;
signal.connected = info.VideoSignalLock != 0 ? 1 : 0;
signal.channel = channel_;
signal.width = info.Width;
signal.height = info.Height;
@@ -362,6 +398,72 @@ namespace gvfg::internal
return GVFG_OK;
}
gvfg_status_t GigabyteCaptureSession::get_hdmi_info(gvfg_hdmi_info_t &out)
{
const gvfg_status_t openStatus = ensure_vendor_channel_open();
if (openStatus != GVFG_OK)
return openStatus;
GVFG_HDMI_VIDEO_INPUT_INFO info{};
{
std::lock_guard<std::mutex> captureLock(capture_mutex_);
const gvfg_status_t status = from_vendor(
GvfgGetHdmiVideoInputInfo(context_, channel_, &info), "GvfgGetHdmiVideoInputInfo");
if (status != GVFG_OK)
return status;
}
char debugMessage[256];
std::snprintf(debugMessage, sizeof(debugMessage),
"[GVFG] GvfgGetHdmiVideoInputInfo CH%" PRIu32
" | VideoSignalLock=%" PRIu32 " | %" PRIu32 "x%" PRIu32
" @ %" PRIu32 " fps | ColorFormat=0x%08" PRIX32
" | ColorSpace=0x%08" PRIX32 " | BitsPerPixel=%" PRIu32 "\n",
static_cast<uint32_t>(channel_), static_cast<uint32_t>(info.VideoSignalLock),
static_cast<uint32_t>(info.Width), static_cast<uint32_t>(info.Height),
static_cast<uint32_t>(info.Fps), static_cast<uint32_t>(info.ColorFormat),
static_cast<uint32_t>(info.ColorSpace), static_cast<uint32_t>(info.BitsPerPixel));
OutputDebugStringA(debugMessage);
out.connected = info.VideoSignalLock != 0;
out.width = info.Width;
out.height = info.Height;
out.fps = info.Fps;
out.color_format = info.ColorFormat;
out.color_space = info.ColorSpace;
out.bit_depth = info.BitsPerPixel;
std::snprintf(out.fps_name, sizeof(out.fps_name), "%" PRIu32, out.fps);
strncpy_s(out.color_format_name, hdmi_color_format_name(out.color_format), _TRUNCATE);
strncpy_s(out.color_space_name, hdmi_color_space_name(out.color_space), _TRUNCATE);
return GVFG_OK;
}
gvfg_status_t GigabyteCaptureSession::get_chip_info(gvfg_chip_info_t &out)
{
const gvfg_status_t openStatus = ensure_vendor_channel_open();
if (openStatus != GVFG_OK)
return openStatus;
GVFG_CHIP_INFO info{};
std::lock_guard<std::mutex> captureLock(capture_mutex_);
const gvfg_status_t status = from_vendor(GvfgGetChipInfo(context_, &info), "GvfgGetChipInfo");
if (status == GVFG_OK)
{
out.version_date = info.VerDate;
out.version_time = info.VerTime;
}
return status;
}
gvfg_status_t GigabyteCaptureSession::set_user_led(bool on)
{
const gvfg_status_t openStatus = ensure_vendor_channel_open();
if (openStatus != GVFG_OK)
return openStatus;
std::lock_guard<std::mutex> captureLock(capture_mutex_);
return from_vendor(GvfgSetLed(context_, on ? 1u : 0u), "GvfgSetLed");
}
gvfg_status_t GigabyteCaptureSession::get_sdi_info(gvfg_sdi_info_t &out)
{
const gvfg_status_t openStatus = ensure_vendor_channel_open();
@@ -50,6 +50,9 @@ namespace gvfg::internal
void get_cached_signal_status(gvfg_signal_status_t &out) const;
gvfg_status_t get_device_capabilities(gvfg_debug_device_capabilities_t &out);
gvfg_status_t get_sdi_info(gvfg_sdi_info_t &out);
gvfg_status_t get_hdmi_info(gvfg_hdmi_info_t &out);
gvfg_status_t get_chip_info(gvfg_chip_info_t &out);
gvfg_status_t set_user_led(bool on);
gvfg_status_t get_audio_format(GigabyteAudioInfo &out);
gvfg_status_t set_event_callback(GigabyteEventCallback callback, void *user);
gvfg_status_t configure_stream();
+140 -9
View File
@@ -1,5 +1,9 @@
#include "gvfg_capture.h"
#ifdef GVFG_CAPTURE_TEST_RUNTIME
#include "gvfg_test_device.h"
#endif
#include "gvfg_debug.h"
#include "gigabyte_capture_session.h"
#include "gpu/gvfg_gpu_osd.h"
@@ -952,7 +956,7 @@ struct gvfg_handle_t
return channels[GVFG_CHANNEL_1].get();
}
gvfg_status_t openChannel(int index, int channelIndex)
gvfg_status_t openChannel(int index, int channelIndex, const std::wstring *requestedPath = nullptr)
{
if (channelIndex != GVFG_CHANNEL_0 && channelIndex != GVFG_CHANNEL_1)
return GVFG_EINVAL;
@@ -962,7 +966,8 @@ struct gvfg_handle_t
channelErrors[slot].set("gvfg_open_channel rejected: device index is invalid");
return GVFG_EINVAL;
}
if (currentIndex >= 0 && currentIndex != index)
if (currentIndex >= 0 && (currentIndex != index ||
(requestedPath && devicePath != *requestedPath)))
{
channelErrors[slot].set("gvfg_open_channel rejected: handle is already bound to another device");
return GVFG_ESTATE;
@@ -976,7 +981,7 @@ struct gvfg_handle_t
const gvfg_status_t status = channel->open(index,
channelIndex,
devicePath.empty() ? nullptr : &devicePath);
devicePath.empty() ? requestedPath : &devicePath);
if (status != GVFG_OK)
return status;
@@ -1073,6 +1078,35 @@ struct gvfg_handle_t
extern "C"
{
#ifdef GVFG_CAPTURE_TEST_RUNTIME
int gvfg_test_enumerate_devices(gvfg_test_device_t *devices, int capacity)
{
if (!devices || capacity <= 0)
return 0;
int written = 0;
for (const auto &device : enumerate_gigabyte_devices())
{
if (written == capacity)
break;
gvfg_test_device_t entry{};
if (device.interface_path.empty() ||
wcscpy_s(entry.interface_path, device.interface_path.c_str()) != 0)
continue;
wcsncpy_s(entry.name, device.friendly_name.c_str(), _TRUNCATE);
devices[written++] = entry;
}
return written;
}
gvfg_status_t gvfg_test_open_channel(gvfg_handle handle, const wchar_t *interface_path, int channel)
{
if (!handle || !interface_path || !*interface_path)
return GVFG_EINVAL;
const std::wstring path(interface_path);
return handle->openChannel(0, channel, &path);
}
#endif
int gvfg_enumerate_devices(gvfg_device_info_t *out_devices, int max_devices)
{
const std::vector<gvfg::internal::GigabyteDevice> devices =
@@ -1212,13 +1246,11 @@ extern "C"
catch (...) { return GVFG_EIO; }
}
gvfg_status_t gvfg_render_osd_bgra(const gvfg_channel_osd_config_t *config,
gvfg_osd_bitmap_t *out_bitmap)
static gvfg_status_t renderOsdBgraTile(const gvfg_channel_osd_config_t *config,
gvfg_osd_bitmap_t *out_bitmap,
std::vector<uint8_t> &pixels)
{
thread_local std::vector<uint8_t> pixels;
pixels.clear();
if (out_bitmap) *out_bitmap = {};
if (!config || !config->text || !out_bitmap)
if (!config || !config->text)
return GVFG_EINVAL;
const size_t length = strnlen_s(config->text, GVFG_OSD_MAX_TEXT_CHARACTERS + 1u);
if (length == 0 || length > GVFG_OSD_MAX_TEXT_CHARACTERS)
@@ -1265,6 +1297,61 @@ extern "C"
catch (...) { return GVFG_EIO; }
}
gvfg_status_t gvfg_render_osd_frame_bgra(uint32_t video_width, uint32_t video_height,
const gvfg_channel_osd_config_t *slot0,
const gvfg_channel_osd_config_t *slot1,
gvfg_osd_bitmap_t *out_bitmap)
{
thread_local std::vector<uint8_t> frame;
frame.clear();
if (!out_bitmap)
return GVFG_EINVAL;
*out_bitmap = {};
const uint64_t stride = static_cast<uint64_t>(video_width) * 4u;
if (!video_width || !video_height || stride > UINT32_MAX ||
stride * video_height > UINT32_MAX ||
stride * video_height > (std::numeric_limits<size_t>::max)())
return GVFG_EINVAL;
try
{
frame.assign(static_cast<size_t>(stride * video_height), 0);
std::vector<uint8_t> tilePixels;
for (const auto *slot : {slot0, slot1})
{
if (!slot)
continue;
gvfg_osd_bitmap_t tile{};
const auto status = renderOsdBgraTile(slot, &tile, tilePixels);
if (status != GVFG_OK)
return status;
if (tile.width > video_width || tile.height > video_height)
continue;
const size_t x = std::clamp<int64_t>(slot->x, 0, video_width - tile.width);
const size_t y = std::clamp<int64_t>(slot->y, 0, video_height - tile.height);
for (uint32_t row = 0; row < tile.height; ++row)
{
const auto *src = tile.data + static_cast<size_t>(row) * tile.stride;
auto *dst = frame.data() + (y + row) * static_cast<size_t>(stride) + x * 4u;
for (uint32_t col = 0; col < tile.width; ++col, src += 4, dst += 4)
{
if (!src[3])
continue;
// Both layers are premultiplied, including at glyph edges.
const unsigned remaining = 255u - src[3];
for (unsigned c = 0; c < 4; ++c)
dst[c] = static_cast<uint8_t>(src[c] + (dst[c] * remaining + 127u) / 255u);
}
}
}
*out_bitmap = {frame.data(), frame.size(), video_width, video_height,
static_cast<uint32_t>(stride)};
return GVFG_OK;
}
catch (...) { return GVFG_EIO; }
}
gvfg_status_t gvfg_set_channel_osd(gvfg_handle handle, int channel_index,
uint32_t osd_index, const gvfg_channel_osd_config_t *config)
{
@@ -1549,6 +1636,39 @@ extern "C"
return channel->session->get_sdi_info(*out_info);
}
gvfg_status_t gvfg_get_channel_hdmi_info(
gvfg_handle handle, int channel_index, gvfg_hdmi_info_t *out_info)
{
if (!handle || (channel_index != GVFG_CHANNEL_0 && channel_index != GVFG_CHANNEL_1))
return GVFG_EINVAL;
if (!out_info)
return handle->rejectChannel(
channel_index, GVFG_EINVAL,
"gvfg_get_channel_hdmi_info rejected: out_info is null");
*out_info = {};
auto *channel = handle->findChannel(channel_index);
if (!channel || !channel->session)
return handle->rejectChannel(
channel_index, GVFG_ESTATE,
"gvfg_get_channel_hdmi_info rejected: channel is not open");
return channel->session->get_hdmi_info(*out_info);
}
gvfg_status_t gvfg_get_chip_info(gvfg_handle handle, gvfg_chip_info_t *out_info)
{
if (!handle)
return GVFG_EINVAL;
if (!out_info)
return handle->rejectAllChannels(GVFG_EINVAL,
"gvfg_get_chip_info rejected: out_info is null");
*out_info = {};
auto *channel = handle->findOpenChannel();
if (!channel || !channel->session)
return handle->rejectAllChannels(GVFG_ESTATE,
"gvfg_get_chip_info rejected: device is not open");
return channel->session->get_chip_info(*out_info);
}
const char *gvfg_get_version(void)
{
return GVFG_VERSION_STRING;
@@ -1618,6 +1738,17 @@ extern "C"
return GVFG_OK;
}
gvfg_status_t gvfg_debug_set_user_led(gvfg_handle handle, int on)
{
if (!handle || (on != 0 && on != 1))
return GVFG_EINVAL;
auto *channel = handle->findOpenChannel();
if (!channel || !channel->session)
return handle->rejectAllChannels(GVFG_ESTATE,
"gvfg_debug_set_user_led rejected: device is not open");
return channel->session->set_user_led(on != 0);
}
gvfg_status_t gvfg_debug_get_device_capabilities(
gvfg_handle handle, gvfg_debug_device_capabilities_t *out_capabilities)
{
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include "gvfg_capture.h"
// Private interface compiled only into the capture-test runtime.
struct gvfg_test_device_t
{
wchar_t interface_path[1024];
wchar_t name[256];
};
extern "C"
{
GVFG_API int gvfg_test_enumerate_devices(gvfg_test_device_t *devices, int capacity);
GVFG_API gvfg_status_t gvfg_test_open_channel(gvfg_handle handle,
const wchar_t *interface_path, int channel);
}