Simplify the SDK around GigabyteLib
Compared with 0af70a5:
- Remove the generic backend directory and legacy PCIE S2MM naming so the SDK now has a direct gvfg facade to GigabyteCaptureSession to GvfgSdk.lib structure.
- Delete the unsupported video-format setter and direct register read/write APIs instead of retaining compatibility methods that cannot be implemented by the supplied GigabyteLib interface.
- Remove output-format controls and requested-format state from the Qt sample; capture now follows the native YUY2 or Y210 format reported by GvfgGetVideoInfo.
- Eliminate the placeholder stream descriptor and allocate copy buffers from current GigabyteLib video metadata when a frame becomes available.
- Rename the internal debug stats API and fields from backend terminology to channel/session terminology, while retaining capture, audio, event, timeout, timing, and zero-copy diagnostics.
- Update source paths and documentation to describe GigabyteLib as the only lower layer and remove stale format-setting, register, and direct IOCTL guidance.
Validation: git diff --cached --check passed. MSVC x64 Release and Debug gvfg.dll builds passed, the Release Qt sample rebuilt and linked successfully, dumpbin verified the intentional 29-export API, and the Release package script produced an archive containing the sample and gvfg.dll without private GigabyteLib files or giga_ioctl.dll. No runtime capture, audio, zero-copy, hot-plug, dual-channel, shutdown, MinGW, or hardware validation was run.
This commit is contained in:
@@ -36,13 +36,13 @@
|
||||
<mxCell id="workers" parent="backendLayer" style="rounded=1;whiteSpace=wrap;html=1;arcSize=8;fillColor=#ffffff;strokeColor=#d6b656;fontSize=14;" value="per-channel workers<br>caller read thread waits DMA<br>event thread waits format / plug events" vertex="1">
|
||||
<mxGeometry height="52" width="280" x="510" y="173" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="pcies2mmSession" parent="backendLayer" style="rounded=1;whiteSpace=wrap;html=1;arcSize=8;fillColor=#ffffff;strokeColor=#d6b656;fontSize=14;" value="CH0 + CH1 PcieS2mmCaptureSession<br>independent events / state / direct frame read" vertex="1">
|
||||
<mxCell id="gigabyteSession" parent="backendLayer" style="rounded=1;whiteSpace=wrap;html=1;arcSize=8;fillColor=#ffffff;strokeColor=#d6b656;fontSize=14;" value="CH0 + CH1 GigabyteCaptureSession<br>independent events / state / direct frame read" vertex="1">
|
||||
<mxGeometry height="58" width="340" x="420" y="65" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="e6" edge="1" parent="backendLayer" source="pcies2mmSession" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;" target="backendTypes" value="uses">
|
||||
<mxCell id="e6" edge="1" parent="backendLayer" source="gigabyteSession" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;" target="backendTypes" value="uses">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="e7" edge="1" parent="backendLayer" source="pcies2mmSession" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;" target="workers" value="owns">
|
||||
<mxCell id="e7" edge="1" parent="backendLayer" source="gigabyteSession" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;" target="workers" value="owns">
|
||||
<mxGeometry relative="1" x="-0.004" as="geometry">
|
||||
<mxPoint as="offset" />
|
||||
</mxGeometry>
|
||||
@@ -80,7 +80,7 @@
|
||||
<mxCell id="e4" edge="1" parent="1" source="qtSample" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;" target="render" value="private preview">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="e5" edge="1" parent="1" source="facade" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;" target="pcies2mmSession" value="backend API calls">
|
||||
<mxCell id="e5" edge="1" parent="1" source="facade" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;" target="gigabyteSession" value="backend API calls">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="e8" edge="1" parent="1" source="workers" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;" target="ring" value="">
|
||||
@@ -89,7 +89,7 @@
|
||||
<mxCell id="e11" edge="1" parent="1" source="workers" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;" target="eventFlow" value="callback / queue">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="e9" edge="1" parent="1" source="pcies2mmSession" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;dashed=1;" target="facade" value="frames / events / status">
|
||||
<mxCell id="e9" edge="1" parent="1" source="gigabyteSession" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;dashed=1;" target="facade" value="frames / events / status">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="420" y="589" />
|
||||
@@ -97,7 +97,7 @@
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="e10" edge="1" parent="1" source="externalBoundary" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;dashed=1;" target="pcies2mmSession" value="input boundary">
|
||||
<mxCell id="e10" edge="1" parent="1" source="externalBoundary" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;dashed=1;" target="gigabyteSession" value="input boundary">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="550" y="780" />
|
||||
|
||||
@@ -231,8 +231,8 @@ Zero-copy mode 的 driver lifecycle 由 SDK 管理:open 時 enable,每次成
|
||||
|
||||
成功 read 後,不論 PCM 是送往播放、錄音或被丟棄,都必須正好 release 一次。
|
||||
|
||||
`gvfg_set_channel_video_format()` 只能在指定 stream 尚未開始或已 stop 時呼叫;streaming 中
|
||||
切換會回傳 `GVFG_ESTATE`。應用程式應在 UI 上同步鎖定格式選項。
|
||||
Video format 由 `GvfgGetVideoInfo()` 回報的原生輸入格式決定。GigabyteLib 沒有
|
||||
輸出格式切換 API,因此 GVFG 不提供格式 setter。
|
||||
|
||||
### 查詢
|
||||
|
||||
|
||||
@@ -263,22 +263,7 @@ 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 `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`。
|
||||
- Device 必須已 open,且 stream 必須尚未 start 或已 stop。
|
||||
- Streaming 中呼叫回傳 `GVFG_ESTATE`;不支援的 format 回傳 `GVFG_ENOTSUP` 或
|
||||
`GVFG_EINVAL`。
|
||||
- 同一裝置的 CH0、CH1 不可同時設定 Y210;第二個 Y210 request 回傳
|
||||
`GVFG_ENOTSUP`。
|
||||
|
||||
### 1.19a Audio capture selection and frame ownership
|
||||
### 1.19 Audio capture selection and frame ownership
|
||||
|
||||
```c
|
||||
gvfg_status_t gvfg_set_channel_audio_enabled(gvfg_handle handle,
|
||||
|
||||
+12
-12
@@ -65,7 +65,7 @@ explicit gvfg_channel_session_t(ChannelErrorState &errorState)
|
||||
backend 也取得同一份 reference:
|
||||
|
||||
```cpp
|
||||
backend = std::make_unique<PcieS2mmCaptureSession>(errorState);
|
||||
backend = std::make_unique<GigabyteCaptureSession>(errorState);
|
||||
```
|
||||
|
||||
因此同一條 channel 的三層共用同一份詳細訊息:
|
||||
@@ -75,7 +75,7 @@ backend = std::make_unique<PcieS2mmCaptureSession>(errorState);
|
||||
↓
|
||||
gvfg_channel_session_t
|
||||
↓
|
||||
PcieS2mmCaptureSession
|
||||
GigabyteCaptureSession
|
||||
↓
|
||||
同一個 ChannelErrorState
|
||||
```
|
||||
@@ -104,7 +104,7 @@ backend event thread、capture/read thread 與 application thread 都可能產
|
||||
|
||||
`gvfg_poll_channel_event()` 的 timeout/non-blocking 無資料不會寫入
|
||||
`ChannelErrorState`。目前 `gvfg_read_channel_frame()` 的 backend timeout 會經過
|
||||
`PcieS2mmCaptureSession::reject()`,因此會保存 timeout 詳細訊息。新的
|
||||
`GigabyteCaptureSession::reject()`,因此會保存 timeout 詳細訊息。新的
|
||||
`gvfg_start_channel()` request 會先清除舊內容;若 start 失敗,失敗路徑會立即寫入新的
|
||||
詳細資訊。
|
||||
|
||||
@@ -146,7 +146,7 @@ backend 的 `fail()` 會組合:
|
||||
例如:
|
||||
|
||||
```cpp
|
||||
return fail(PCIES2MM_EIO, "wait DMA event", err);
|
||||
return fail(GIGABYTE_EIO, "wait DMA event", err);
|
||||
```
|
||||
|
||||
同時會:
|
||||
@@ -157,16 +157,16 @@ return fail(PCIES2MM_EIO, "wait DMA event", err);
|
||||
|
||||
## 6. Backend status 如何轉成公開 status
|
||||
|
||||
backend 使用 `pcies2mm_status_t`,facade 透過 `map_status()` 轉成 `gvfg_status_t`:
|
||||
backend 使用 `gigabyte_status_t`,facade 透過 `map_status()` 轉成 `gvfg_status_t`:
|
||||
|
||||
```text
|
||||
PCIES2MM_OK -> GVFG_OK
|
||||
PCIES2MM_EINVAL -> GVFG_EINVAL
|
||||
PCIES2MM_ENODEV -> GVFG_ENODEV
|
||||
PCIES2MM_ESTATE -> GVFG_ESTATE
|
||||
PCIES2MM_ENOTSUP -> GVFG_ENOTSUP
|
||||
PCIES2MM_ETIMEOUT -> GVFG_ETIMEOUT
|
||||
PCIES2MM_EIO -> GVFG_EIO
|
||||
GIGABYTE_OK -> GVFG_OK
|
||||
GIGABYTE_EINVAL -> GVFG_EINVAL
|
||||
GIGABYTE_ENODEV -> GVFG_ENODEV
|
||||
GIGABYTE_ESTATE -> GVFG_ESTATE
|
||||
GIGABYTE_ENOTSUP -> GVFG_ENOTSUP
|
||||
GIGABYTE_ETIMEOUT -> GVFG_ETIMEOUT
|
||||
GIGABYTE_EIO -> GVFG_EIO
|
||||
```
|
||||
|
||||
轉換只改錯誤分類,不應覆蓋 backend 已寫入的詳細訊息。
|
||||
|
||||
@@ -58,7 +58,7 @@ frame ownership 與 timeout 契約,不再直接操作 driver IOCTL 或 FPGA re
|
||||
| signal 欄位 | `stateMutex` | width/height/format/connected cache |
|
||||
| delivered/FPS 欄位 | atomic | UI/debug runtime 統計 |
|
||||
|
||||
### `PcieS2mmCaptureSession`:driver backend
|
||||
### `GigabyteCaptureSession`:driver backend
|
||||
|
||||
| 變數 | 保護方式 | 意義 |
|
||||
|---|---|---|
|
||||
@@ -119,9 +119,9 @@ currentIndex = -1
|
||||
|
||||
```text
|
||||
建立 gvfg_channel_session_t
|
||||
-> 建立 PcieS2mmCaptureSession
|
||||
-> 建立 GigabyteCaptureSession
|
||||
-> CreateFileW() 得到 Windows HANDLE
|
||||
-> 建立 PcieS2mmDeviceConnection
|
||||
-> 建立 GigabyteDeviceConnection
|
||||
-> gvfg_handle_t 保存 shared_ptr
|
||||
-> backend set_channel(CH0 或 CH1)
|
||||
-> 建立並註冊該 channel events
|
||||
|
||||
+10
-28
@@ -42,9 +42,9 @@ customer/sample (optional)
|
||||
|
||||
- `gvfg_capture.cpp`:公開 handle 狀態、狀態碼轉換、frame token 驗證、event
|
||||
queue、runtime counter 與 debug API facade。
|
||||
- `backend/gigabyte/gigabyte_capture_session.*`:把既有 GVFG lifecycle、event、
|
||||
- `gigabyte/gigabyte_capture_session.*`:把既有 GVFG lifecycle、event、
|
||||
copy/zero-copy ownership 契約轉接到 `GvfgSdk.lib`。
|
||||
- `backend/gigabyte/gigabyte_device.*`:SetupAPI 裝置列舉與 interface path。
|
||||
- `gigabyte/gigabyte_device.*`:SetupAPI 裝置列舉與 interface path。
|
||||
- `third_party/GigabyteLib`:主管提供的靜態 library 與其 private headers,只供 SDK build。
|
||||
- `src/gpu/*`:D3D11 同步轉換及 readback 到 caller buffer。
|
||||
|
||||
@@ -120,19 +120,10 @@ x64 `gvfg_frame_t` ABI 已在 `gvfg_capture.cpp` 以 static assertions 固定為
|
||||
及明確欄位 offsets。修改公開 struct 時必須視為 ABI 變更,不能只重新編譯 DLL。
|
||||
新增 metadata 優先考慮新 query API 或帶 size/version 的新 struct。
|
||||
|
||||
## Driver ABI requirement
|
||||
## GigabyteLib requirement
|
||||
|
||||
目前 SDK 只支援新版 PCIE S2MM driver,必要 private ABI 包含:
|
||||
|
||||
- `IOCTL_GIGA_VIDEO_START` (`0x830`) / `IOCTL_GIGA_VIDEO_STOP` (`0x831`)。
|
||||
- `IOCTL_GIGA_RELEASE_VIDEO_FRAME` (`0x832`)。
|
||||
- `IOCTL_GIGA_ACQUIRE_VIDEO_FRAME_ZEROCOPY` (`0x833`)。
|
||||
- `IOCTL_GIGA_ENABLE_FRAME_ZEROCOPY` (`0x834`) /
|
||||
`IOCTL_GIGA_DISABLE_FRAME_ZEROCOPY` (`0x835`)。
|
||||
- Copy mode 的 `IOCTL_PCIES2MM_GET_FRAME` 接受 `frameIndex=0xFFFFFFFF`。
|
||||
|
||||
不再呼叫 `GET_VIDEO_DONE_INDEX`,也不再 fallback 直接寫入 video enable、DMA enable
|
||||
或 IRQ mask registers。舊 driver 不屬於此 revision 的支援範圍。
|
||||
GVFG 不再保存或操作 private IOCTL、register offset 或 DMA request layout。
|
||||
Driver ABI 相容性由主管提供的 `GvfgSdk.lib` 負責。
|
||||
|
||||
目前原生格式:
|
||||
|
||||
@@ -148,19 +139,15 @@ Backend event 映射:
|
||||
|
||||
| Backend | Public |
|
||||
|---|---|
|
||||
| `PCIES2MM_EVENT_PLUG_IN` | `GVFG_EVENT_SIGNAL_CONNECTED` |
|
||||
| `PCIES2MM_EVENT_PLUG_OUT` | `GVFG_EVENT_SIGNAL_DISCONNECTED` |
|
||||
| `PCIES2MM_EVENT_STREAM_READY` | `GVFG_EVENT_STREAM_READY` |
|
||||
| `PCIES2MM_EVENT_FORMAT_CHANGE_BEGIN` | `GVFG_EVENT_FORMAT_CHANGE_BEGIN` |
|
||||
| `GIGABYTE_EVENT_PLUG_IN` | `GVFG_EVENT_SIGNAL_CONNECTED` |
|
||||
| `GIGABYTE_EVENT_PLUG_OUT` | `GVFG_EVENT_SIGNAL_DISCONNECTED` |
|
||||
| `GIGABYTE_EVENT_STREAM_READY` | `GVFG_EVENT_STREAM_READY` |
|
||||
| `GIGABYTE_EVENT_FORMAT_CHANGE_BEGIN` | `GVFG_EVENT_FORMAT_CHANGE_BEGIN` |
|
||||
|
||||
每個 channel 的 public event mask 在 open 前設定。Video DMA event 永遠註冊;
|
||||
format-change、plug-in、unplug driver event 依 mask 選擇性註冊。關閉 driver event
|
||||
同時代表 backend 不執行該事件所驅動的自動 recovery。
|
||||
|
||||
Register read 必須排除純 write-only 位址:global `0x080`,以及每個 video/audio
|
||||
channel 的 descriptor-write pulse 與 DMA soft-reset register。Interrupt
|
||||
`0x000/0x004/0x008` 是 read-status/write-control 雙語意位址,讀取其 RO status 合法。
|
||||
|
||||
Facade queue 上限為 64;滿時丟棄最舊事件。`pollEvent()` 只允許 running 狀態,支援
|
||||
non-blocking、有限 timeout 與 infinite wait;stop 透過 `eventCv` 喚醒 waiter。
|
||||
|
||||
@@ -172,13 +159,8 @@ non-blocking、有限 timeout 與 infinite wait;stop 透過 `eventCv` 喚醒 w
|
||||
|
||||
`gvfg_debug.h` 僅供內部工具,包含:
|
||||
|
||||
- `gvfg_debug_get_channel_backend_stats()`:指定 channel 的 facade/backend state、
|
||||
- `gvfg_debug_get_channel_stats()`:指定 channel 的 facade/backend state、
|
||||
captured/delivered frame、DMA error、IRQ、timeout、sequence 與 GetFrame timing。
|
||||
- `gvfg_debug_read_register()`:讀取 4-byte aligned BAR-relative register。
|
||||
- `gvfg_debug_write_register()`:寫入 register。
|
||||
|
||||
Register write 可能中斷 DMA、interrupt 或 capture。工具必須確認裝置、offset 與當前
|
||||
stream 狀態,且不得將 register API 包裝成客戶功能。
|
||||
|
||||
客戶診斷使用 `gvfg_get_channel_signal_status()`、`gvfg_get_channel_runtime_info()`、event、
|
||||
`gvfg_strerror()` 與 `gvfg_get_channel_last_error_detail()`。每個 channel 的 `ChannelErrorState`
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
## 建議閱讀順序
|
||||
|
||||
1. [`GVFG_Overview.md`](GVFG_Overview.md)
|
||||
- 先認識 `gvfg_handle_t`、`gvfg_channel_session_t`、`PcieS2mmCaptureSession`。
|
||||
- 先認識 `gvfg_handle_t`、`gvfg_channel_session_t`、`GigabyteCaptureSession`。
|
||||
- 理解 `unique_ptr`、`shared_ptr`、宣告與實際配置的差異。
|
||||
- 理解 CH0、CH1 如何共用同一個 Windows device handle。
|
||||
2. [`GVFG_ERROR_HANDLING.md`](GVFG_ERROR_HANDLING.md)
|
||||
@@ -31,7 +31,7 @@
|
||||
目前已實作:
|
||||
|
||||
- 一個 `gvfg_handle_t` 可管理 CH0、CH1。
|
||||
- CH0、CH1 共用一個 `PcieS2mmDeviceConnection`,底層只有一個 Windows device `HANDLE`。
|
||||
- CH0、CH1 共用一個 `GigabyteDeviceConnection`,底層只有一個 Windows device `HANDLE`。
|
||||
- 每條 channel 各自擁有 backend、event、capture thread、copy buffer 與 frame lifetime state。
|
||||
- 公開 API 已改為 channel-aware:open/start/read/release/poll/stop 都帶 `channel_index`。
|
||||
- copy mode 直接把 driver frame 寫入該 channel 的 `copy_buffer_`。
|
||||
|
||||
+23
-23
@@ -17,7 +17,7 @@ sdk/gvfg/include
|
||||
sdk/gvfg/src/gvfg_capture.cpp
|
||||
C ABI facade、opaque handle、channel 管理、參數驗證、frame token、event queue
|
||||
|
||||
sdk/gvfg/src/backend/gigabyte
|
||||
sdk/gvfg/src/gigabyte
|
||||
將公開 API 的 lifecycle、event、copy/zero-copy ownership 轉接至 GvfgSdk.lib
|
||||
|
||||
third_party/GigabyteLib
|
||||
@@ -112,7 +112,7 @@ struct gvfg_handle_t
|
||||
std::array<ChannelErrorState, 2> channelErrors;
|
||||
|
||||
std::shared_ptr<
|
||||
gvfg::internal::PcieS2mmDeviceConnection
|
||||
gvfg::internal::GigabyteDeviceConnection
|
||||
> deviceConnection;
|
||||
|
||||
std::array<
|
||||
@@ -135,7 +135,7 @@ struct gvfg_handle_t
|
||||
### `deviceConnection`
|
||||
|
||||
```cpp
|
||||
std::shared_ptr<PcieS2mmDeviceConnection> deviceConnection;
|
||||
std::shared_ptr<GigabyteDeviceConnection> deviceConnection;
|
||||
```
|
||||
|
||||
負責保存底層 Windows driver connection。
|
||||
@@ -207,7 +207,7 @@ channels[1] 獨自擁有 CH1 session
|
||||
struct gvfg_channel_session_t
|
||||
{
|
||||
ChannelErrorState &errorState;
|
||||
std::unique_ptr<PcieS2mmCaptureSession> backend;
|
||||
std::unique_ptr<GigabyteCaptureSession> backend;
|
||||
|
||||
int currentIndex;
|
||||
uint32_t selectedChannel;
|
||||
@@ -218,13 +218,13 @@ struct gvfg_channel_session_t
|
||||
bool readInProgress;
|
||||
bool frameHeld;
|
||||
|
||||
pcies2mm_frame_t heldBackendFrame;
|
||||
gigabyte_frame_t heldBackendFrame;
|
||||
|
||||
// FPS、signal、event queue 等其他狀態
|
||||
};
|
||||
```
|
||||
|
||||
它是「公開 GVFG API」與「底層 PCIES2MM backend」中間的包裝層。
|
||||
它是「公開 GVFG API」與「底層 GIGABYTE backend」中間的包裝層。
|
||||
|
||||
例如應用程式呼叫:
|
||||
|
||||
@@ -241,7 +241,7 @@ gvfg_read_channel_frame()
|
||||
↓
|
||||
gvfg_channel_session_t::readFrame()
|
||||
↓
|
||||
PcieS2mmCaptureSession::wait_frame()
|
||||
GigabyteCaptureSession::wait_frame()
|
||||
↓
|
||||
driver IOCTL
|
||||
```
|
||||
@@ -257,14 +257,14 @@ driver IOCTL
|
||||
|
||||
---
|
||||
|
||||
## 第四層:`PcieS2mmCaptureSession`
|
||||
## 第四層:`GigabyteCaptureSession`
|
||||
|
||||
這是實際操作 PCIES2MM driver 的單一 channel backend:
|
||||
這是實際操作 GIGABYTE driver 的單一 channel backend:
|
||||
|
||||
```cpp
|
||||
class PcieS2mmCaptureSession
|
||||
class GigabyteCaptureSession
|
||||
{
|
||||
std::shared_ptr<PcieS2mmDeviceConnection>
|
||||
std::shared_ptr<GigabyteDeviceConnection>
|
||||
device_connection_;
|
||||
|
||||
HANDLE dma_event_;
|
||||
@@ -277,7 +277,7 @@ class PcieS2mmCaptureSession
|
||||
bool zero_copy_enabled_;
|
||||
|
||||
std::vector<uint8_t> copy_buffer_;
|
||||
pcies2mm_frame_t held_frame_;
|
||||
gigabyte_frame_t held_frame_;
|
||||
|
||||
bool frame_held_;
|
||||
bool read_in_progress_;
|
||||
@@ -288,7 +288,7 @@ class PcieS2mmCaptureSession
|
||||
};
|
||||
```
|
||||
|
||||
CH0、CH1 各有自己的 `PcieS2mmCaptureSession`,因此它們各自擁有:
|
||||
CH0、CH1 各有自己的 `GigabyteCaptureSession`,因此它們各自擁有:
|
||||
|
||||
- 自己的 DMA event
|
||||
- 自己的 signal event
|
||||
@@ -308,16 +308,16 @@ device_connection_
|
||||
|
||||
---
|
||||
|
||||
## 第五層:`PcieS2mmDeviceConnection`
|
||||
## 第五層:`GigabyteDeviceConnection`
|
||||
|
||||
目前非常單純:
|
||||
|
||||
```cpp
|
||||
struct PcieS2mmDeviceConnection
|
||||
struct GigabyteDeviceConnection
|
||||
{
|
||||
HANDLE handle = INVALID_HANDLE_VALUE;
|
||||
|
||||
~PcieS2mmDeviceConnection();
|
||||
~GigabyteDeviceConnection();
|
||||
};
|
||||
```
|
||||
|
||||
@@ -332,7 +332,7 @@ connection->handle = CreateFileW(...);
|
||||
最後一個 `shared_ptr` 被釋放時,destructor 執行:
|
||||
|
||||
```cpp
|
||||
PcieS2mmDeviceConnection::~PcieS2mmDeviceConnection()
|
||||
GigabyteDeviceConnection::~GigabyteDeviceConnection()
|
||||
{
|
||||
if (handle != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(handle);
|
||||
@@ -345,8 +345,8 @@ PcieS2mmDeviceConnection::~PcieS2mmDeviceConnection()
|
||||
|
||||
```text
|
||||
gvfg_handle_t
|
||||
CH0 PcieS2mmCaptureSession
|
||||
CH1 PcieS2mmCaptureSession
|
||||
CH0 GigabyteCaptureSession
|
||||
CH1 GigabyteCaptureSession
|
||||
```
|
||||
|
||||
它們共同使用同一個 Windows `HANDLE`。
|
||||
@@ -462,14 +462,14 @@ gvfg_create()
|
||||
gvfg_open_channel(CH0)
|
||||
│
|
||||
├─ 建立 CH0 gvfg_channel_session_t
|
||||
├─ 建立 CH0 PcieS2mmCaptureSession
|
||||
├─ 建立 CH0 GigabyteCaptureSession
|
||||
├─ CreateFileW() 開啟 driver
|
||||
└─ deviceConnection 保存 Windows HANDLE
|
||||
|
||||
gvfg_open_channel(CH1)
|
||||
│
|
||||
├─ 建立 CH1 gvfg_channel_session_t
|
||||
├─ 建立 CH1 PcieS2mmCaptureSession
|
||||
├─ 建立 CH1 GigabyteCaptureSession
|
||||
└─ 共用既有 deviceConnection
|
||||
|
||||
gvfg_start_channel(CH0)
|
||||
@@ -496,10 +496,10 @@ gvfg_handle_t
|
||||
gvfg_channel_session_t
|
||||
= 公開 API 所看到的一條 channel
|
||||
|
||||
PcieS2mmCaptureSession
|
||||
GigabyteCaptureSession
|
||||
= 實際操作 driver 的一條 channel
|
||||
|
||||
PcieS2mmDeviceConnection
|
||||
GigabyteDeviceConnection
|
||||
= CH0、CH1 共用的 Windows driver 連線
|
||||
|
||||
copy_buffer_
|
||||
|
||||
@@ -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:backend stats、register read/write。
|
||||
- 內部 debug API:session 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