Separate the SDK and Qt sample build projects

Compared with f612cfd:

- Move the capture SDK, private IOCTL wrapper, and optional preview helper under GVFG_SDK with an independent top-level CMake project and version source.

- Move the Qt preview application into GVFG_Qt_Sample and consume prebuilt SDK DLLs and compiler-specific import libraries through imported CMake targets instead of compiling SDK sources as subdirectories.

- Resolve Qt Creator configuration-specific SDK build directories automatically, copy the three runtime DLLs beside the sample executable, and keep missing MSVC or MinGW artifacts as explicit configure errors.

- Update Release and Debug packaging scripts to read SDK and sample outputs separately, and update the repository build instructions for the two-project workflow.

- Preserve the pre-existing uncommitted device display-name suffix change outside this commit.

Validation: independent MSVC SDK configure/build and independent Qt MSVC sample configure/build passed; the sample build graph contains no SDK implementation sources; git diff --check passed. No MinGW link, runtime launch, capture, audio playback, or hardware validation was run.
This commit is contained in:
Mark.lin
2026-09-11 13:28:56 +08:00
parent f612cfd11b
commit cae4a04612
39 changed files with 205 additions and 113 deletions
+19
View File
@@ -0,0 +1,19 @@
add_library(giga_ioctl SHARED
README.md
include/giga_ioctl.h
src/giga_ioctl.cpp
src/giga_ioctl_private.h
)
target_include_directories(giga_ioctl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_compile_definitions(giga_ioctl PRIVATE GIGA_IOCTL_BUILD)
set_target_properties(giga_ioctl PROPERTIES AUTOMOC OFF AUTOUIC OFF AUTORCC OFF)
if (MSVC)
target_compile_options(giga_ioctl PRIVATE /utf-8 /EHsc)
endif()
install(TARGETS giga_ioctl
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
+42
View File
@@ -0,0 +1,42 @@
# giga_ioctl
`giga_ioctl` is the private DLL boundary between GVFG and the Windows driver.
It owns only the driver IOCTL codes, request layouts, and thin
`DeviceIoControl` wrappers. Device discovery, capture state, threads, buffers,
and frame lifetime remain in `gvfg`.
When adding a driver operation:
1. Add its private IOCTL code and request layout to `src/giga_ioctl_private.h`.
2. Add a small C function to `include/giga_ioctl.h`.
3. Implement that function in `src/giga_ioctl.cpp` with no capture state.
4. Preserve `GetLastError()` on driver failures; use `ERROR_INVALID_PARAMETER`
for invalid caller output pointers.
The header is an internal dependency of `gvfg`; it is not a customer SDK API.
## Current audio ABI
At this private driver boundary the implemented audio path is copy-out, not
zero-copy:
- Register `GIGA_IOCTL_EVENT_AUDIO_DMA` and
`GIGA_IOCTL_EVENT_EXTRA_AUDIO_FRAME` as wake-up notifications.
- Start and stop capture with `giga_ioctl_start_video_audio()` and
`giga_ioctl_stop_video_audio()`.
- Query the PCM layout and driver frame size with
`giga_ioctl_get_audio_info()`.
- Read the next available driver frame with `giga_ioctl_get_audio_frame()` and
`frame_index == UINT32_MAX`. The returned byte count is the valid copy size.
The extra-frame events mean that more frames are ready and the consumer should
drain promptly. They do not transfer ownership of a frame. Audio zero-copy is a
future driver capability and is intentionally not exposed here until its
acquire/release ABI is complete.
This does not define the customer-facing ownership contract. `gvfg` copies the
driver result into its SDK-owned delivery buffer and exposes it as
`gvfg_audio_frame_t`; applications acquire it with
`gvfg_read_channel_audio_frame()` and return the unchanged token with
`gvfg_release_channel_audio_frame()`. Driver frame size, destination capacity,
and valid-byte output parameters remain private below that public API.
@@ -0,0 +1,60 @@
#pragma once
#include <windows.h>
#include <stdint.h>
#ifdef GIGA_IOCTL_BUILD
#define GIGA_IOCTL_API __declspec(dllexport)
#else
#define GIGA_IOCTL_API __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Driver event values. Keep these synchronized with the driver ABI. */
enum giga_ioctl_event_type
{
GIGA_IOCTL_EVENT_VIDEO_DMA = 0,
GIGA_IOCTL_EVENT_VIDEO_FORMAT_CHANGE = 1,
GIGA_IOCTL_EVENT_VIDEO_PLUGIN = 2,
GIGA_IOCTL_EVENT_VIDEO_UNPLUG = 3,
GIGA_IOCTL_EVENT_AUDIO_DMA = 4,
GIGA_IOCTL_EVENT_EXTRA_VIDEO_FRAME = 5,
GIGA_IOCTL_EVENT_EXTRA_AUDIO_FRAME = 6
};
typedef struct giga_ioctl_audio_info
{
uint16_t channels;
uint16_t samples_per_second;
uint16_t bits_per_sample;
uint16_t frames_per_second;
uint32_t frame_buffer_size;
} giga_ioctl_audio_info;
GIGA_IOCTL_API BOOL giga_ioctl_read_register(HANDLE device, uint32_t offset, uint32_t *value);
GIGA_IOCTL_API BOOL giga_ioctl_write_register(HANDLE device, uint32_t offset, uint32_t value);
GIGA_IOCTL_API BOOL giga_ioctl_register_event(HANDLE device, uint32_t channel,
uint32_t type, HANDLE event_handle);
GIGA_IOCTL_API BOOL giga_ioctl_unregister_event(HANDLE device, uint32_t channel, uint32_t type);
GIGA_IOCTL_API BOOL giga_ioctl_get_frame(HANDLE device, uint32_t channel, uint32_t frame_index,
void *buffer, uint32_t buffer_size, uint32_t *bytes_returned);
GIGA_IOCTL_API BOOL giga_ioctl_get_audio_frame(HANDLE device, uint32_t channel,
uint32_t frame_index, void *buffer,
uint32_t buffer_size, uint32_t *bytes_returned);
GIGA_IOCTL_API BOOL giga_ioctl_video_start(HANDLE device, uint32_t channel);
GIGA_IOCTL_API BOOL giga_ioctl_video_stop(HANDLE device, uint32_t channel);
GIGA_IOCTL_API BOOL giga_ioctl_start_video_audio(HANDLE device, uint32_t channel);
GIGA_IOCTL_API BOOL giga_ioctl_stop_video_audio(HANDLE device, uint32_t channel);
GIGA_IOCTL_API BOOL giga_ioctl_get_audio_info(HANDLE device, uint32_t channel,
giga_ioctl_audio_info *info);
GIGA_IOCTL_API BOOL giga_ioctl_release_video_frame(HANDLE device, uint32_t channel);
GIGA_IOCTL_API BOOL giga_ioctl_acquire_video_frame_zerocopy(HANDLE device, uint32_t channel,
const void **frame_address);
GIGA_IOCTL_API BOOL giga_ioctl_set_frame_zerocopy(HANDLE device, uint32_t channel, BOOL enabled);
#ifdef __cplusplus
}
#endif
+188
View File
@@ -0,0 +1,188 @@
#include "giga_ioctl.h"
#include "giga_ioctl_private.h"
#include <limits>
static_assert(sizeof(GIGA_AUDIO_INFO) == 12, "GIGA_AUDIO_INFO driver ABI size must remain 12 bytes");
namespace
{
BOOL send_ioctl(HANDLE device,
DWORD code,
void *input,
DWORD input_size,
void *output = nullptr,
DWORD output_size = 0,
DWORD *bytes_returned = nullptr)
{
DWORD ignored = 0;
return DeviceIoControl(device, code,
input, input_size,
output, output_size,
bytes_returned ? bytes_returned : &ignored,
nullptr);
}
BOOL send_channel_ioctl(HANDLE device, DWORD code, uint32_t channel)
{
ULONG channel_index = channel;
return send_ioctl(device, code, &channel_index, sizeof(channel_index));
}
BOOL invalid_output_pointer()
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
}
extern "C"
{
BOOL giga_ioctl_read_register(HANDLE device, uint32_t offset, uint32_t *value)
{
if (!value)
return invalid_output_pointer();
GIGA_REG_ACCESS request{offset, 0};
const BOOL ok = send_ioctl(device, IOCTL_PCIES2MM_READ_REG,
&request, sizeof(request),
&request, sizeof(request));
if (ok)
*value = request.Value;
return ok;
}
BOOL giga_ioctl_write_register(HANDLE device, uint32_t offset, uint32_t value)
{
GIGA_REG_ACCESS request{offset, value};
return send_ioctl(device, IOCTL_PCIES2MM_WRITE_REG, &request, sizeof(request));
}
BOOL giga_ioctl_register_event(HANDLE device, uint32_t channel,
uint32_t type, HANDLE event_handle)
{
GIGA_EVENT_REG request{type, channel, event_handle};
return send_ioctl(device, IOCTL_PCIES2MM_REGISTER_EVENT, &request, sizeof(request));
}
BOOL giga_ioctl_unregister_event(HANDLE device, uint32_t channel, uint32_t type)
{
GIGA_EVENT_REG request{type, channel, nullptr};
return send_ioctl(device, IOCTL_PCIES2MM_UNREGISTER_EVENT, &request, sizeof(request));
}
BOOL giga_ioctl_get_frame(HANDLE device, uint32_t channel, uint32_t frame_index,
void *buffer, uint32_t buffer_size, uint32_t *bytes_returned)
{
if (!bytes_returned)
return invalid_output_pointer();
GIGA_FRAME_REQUEST request{channel, frame_index};
DWORD returned = 0;
const BOOL ok = send_ioctl(device, IOCTL_PCIES2MM_GET_FRAME,
&request, sizeof(request),
buffer, buffer_size, &returned);
*bytes_returned = returned;
return ok;
}
BOOL giga_ioctl_get_audio_frame(HANDLE device, uint32_t channel,
uint32_t frame_index, void *buffer,
uint32_t buffer_size, uint32_t *bytes_returned)
{
if (!buffer || !bytes_returned)
return invalid_output_pointer();
GIGA_FRAME_REQUEST request{channel, frame_index};
DWORD returned = 0;
const BOOL ok = send_ioctl(device, IOCTL_PCIES2MM_GET_AUDIO_FRAME,
&request, sizeof(request),
buffer, buffer_size, &returned);
*bytes_returned = returned;
return ok;
}
BOOL giga_ioctl_video_start(HANDLE device, uint32_t channel)
{
return send_channel_ioctl(device, IOCTL_GIGA_VIDEO_START, channel);
}
BOOL giga_ioctl_video_stop(HANDLE device, uint32_t channel)
{
return send_channel_ioctl(device, IOCTL_GIGA_VIDEO_STOP, channel);
}
BOOL giga_ioctl_start_video_audio(HANDLE device, uint32_t channel)
{
return send_channel_ioctl(device, IOCTL_GIGA_START_VIDEO_AUDIO, channel);
}
BOOL giga_ioctl_stop_video_audio(HANDLE device, uint32_t channel)
{
return send_channel_ioctl(device, IOCTL_GIGA_STOP_VIDEO_AUDIO, channel);
}
BOOL giga_ioctl_get_audio_info(HANDLE device, uint32_t channel,
giga_ioctl_audio_info *info)
{
if (!info)
return invalid_output_pointer();
ULONG channel_index = channel;
GIGA_AUDIO_INFO driver_info{};
DWORD returned = 0;
const BOOL ok = send_ioctl(device, IOCTL_GIGA_GET_AUDIO_INFO,
&channel_index, sizeof(channel_index),
&driver_info, sizeof(driver_info), &returned);
if (!ok)
return FALSE;
if (returned != sizeof(driver_info))
{
SetLastError(ERROR_INVALID_DATA);
return FALSE;
}
info->channels = driver_info.Channels;
info->samples_per_second = driver_info.SamplesPerSec;
info->bits_per_sample = driver_info.BitsPerSample;
info->frames_per_second = driver_info.FramesPerSec;
info->frame_buffer_size = driver_info.FrameBufSize;
return TRUE;
}
BOOL giga_ioctl_release_video_frame(HANDLE device, uint32_t channel)
{
return send_channel_ioctl(device, IOCTL_GIGA_RELEASE_VIDEO_FRAME, channel);
}
BOOL giga_ioctl_acquire_video_frame_zerocopy(HANDLE device, uint32_t channel,
const void **frame_address)
{
if (!frame_address)
return invalid_output_pointer();
GIGA_FRAME_REQUEST request{channel, (std::numeric_limits<ULONG>::max)()};
void *address = nullptr;
const BOOL ok = send_ioctl(device, IOCTL_GIGA_ACQUIRE_VIDEO_FRAME_ZEROCOPY,
&request, sizeof(request),
&address, sizeof(address));
if (!ok)
return FALSE;
if (!address)
{
SetLastError(ERROR_INVALID_DATA);
return FALSE;
}
*frame_address = address;
return TRUE;
}
BOOL giga_ioctl_set_frame_zerocopy(HANDLE device, uint32_t channel, BOOL enabled)
{
const DWORD code = enabled
? IOCTL_GIGA_ENABLE_FRAME_ZEROCOPY
: IOCTL_GIGA_DISABLE_FRAME_ZEROCOPY;
return send_channel_ioctl(device, code, channel);
}
}
@@ -0,0 +1,37 @@
#pragma once
#include <windows.h>
#define GIGA_IOCTL_CODE(function, method, access) \
CTL_CODE(FILE_DEVICE_UNKNOWN, function, method, access)
#define IOCTL_PCIES2MM_WRITE_REG GIGA_IOCTL_CODE(0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PCIES2MM_READ_REG GIGA_IOCTL_CODE(0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PCIES2MM_REGISTER_EVENT GIGA_IOCTL_CODE(0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PCIES2MM_GET_FRAME \
GIGA_IOCTL_CODE(0x803, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_PCIES2MM_UNREGISTER_EVENT GIGA_IOCTL_CODE(0x804, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PCIES2MM_GET_AUDIO_FRAME \
GIGA_IOCTL_CODE(0x809, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_GIGA_VIDEO_START GIGA_IOCTL_CODE(0x830, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_GIGA_VIDEO_STOP GIGA_IOCTL_CODE(0x831, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_GIGA_RELEASE_VIDEO_FRAME GIGA_IOCTL_CODE(0x832, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_GIGA_ACQUIRE_VIDEO_FRAME_ZEROCOPY \
GIGA_IOCTL_CODE(0x833, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_GIGA_ENABLE_FRAME_ZEROCOPY GIGA_IOCTL_CODE(0x834, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_GIGA_DISABLE_FRAME_ZEROCOPY GIGA_IOCTL_CODE(0x835, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_GIGA_START_VIDEO_AUDIO GIGA_IOCTL_CODE(0x839, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_GIGA_STOP_VIDEO_AUDIO GIGA_IOCTL_CODE(0x83A, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_GIGA_GET_AUDIO_INFO GIGA_IOCTL_CODE(0x83B, METHOD_BUFFERED, FILE_ANY_ACCESS)
struct GIGA_REG_ACCESS { ULONG Offset; ULONG Value; };
struct GIGA_EVENT_REG { ULONG Type; ULONG ChannelIndex; HANDLE EventHandle; };
struct GIGA_FRAME_REQUEST { ULONG ChannelIndex; ULONG FrameIndex; };
struct GIGA_AUDIO_INFO
{
UINT16 Channels;
UINT16 SamplesPerSec;
UINT16 BitsPerSample;
UINT16 FramesPerSec;
UINT32 FrameBufSize;
};