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
+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)
{