Compare commits

...
13 Commits
Author SHA1 Message Date
iverson3yaandClaude Opus 5.5 86601a661d Stop tracking the ignored CaptureDemo reference tree
CaptureDemo/ is listed in .gitignore, but 490 previously committed files under it
(old CaptureDemo sources, 0714 Y210 build, vfg100 driver package, and notes) were still
tracked and have been deleted from the working tree. Remove them from version control;
they remain available in history. Drop the CaptureDemo entry from both READMEs and note
in AGENTS.md that the directory is local-only.

Validation: git diff --cached --check passed. No build run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 16:04:13 +08:00
iverson3yaandClaude Opus 5.5 8e1bc903ec Export gvfg_playback_enable_audio_reconnect from the playback DLL export list
The function is declared in gvfg_playback.h and documented as a public API, but
gvfg_playback.def did not list it. Add it to the export list so the import library
generated from the .def (including the MinGW import library) contains the symbol.

Validation: none run for this commit (no build).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 16:04:08 +08:00
iverson3yaandClaude Opus 5.5 784aa5c579 Update SDK 3.2 documentation and add English and Traditional Chinese versions
- Check the README, customer guides, API reference, and internal notes against the
  SDK 3.2.0 headers, export lists, and CMake rules. Fix stale versions, the OSD move to
  gvfg_osd.dll, the OSD example header, and missing APIs (HDMI audio info, the HDMI and
  chip structs, gvfg_render_osd_frame_bgra, gvfg_playback_enable_audio_reconnect).
- Document present_image returning EOUTPUT when nothing was presented, opt-in audio
  reconnect for EAUDIO, and whole-macropixel YUY2 row sizes.
- Make English the primary *.md for the README and customer documents, keep Traditional
  Chinese as *.zh-TW.md, and install both language versions.
- Update the GigabyteLib README version and checksum to 1.0.5 and redraw the
  architecture diagram for the Capture, OSD, and Playback DLLs.

Validation: git diff --cached --check passed. All relative links and anchors in the
changed Markdown files resolve, and the drawio XML parses with valid edges and
non-overlapping boxes. No build, cmake --install, or PDF regeneration was run, and the
diagram was not opened in draw.io.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 16:03:38 +08:00
iverson3yaandClaude Opus 5.5 02c7004e8c Confirm single-image presents and require whole YUY2 macropixels in preview rows
- gvfg_playback_present_image compares the preview's presented count before and after rendering, and returns GVFG_PLAYBACK_EOUTPUT when the image was not actually presented.
- Compute the minimum YUY2 row size from whole 4-byte macropixels, so an odd-width row that is 2 bytes short is rejected instead of read past its end.

Validation: git diff --cached --check passed. The MSVC Release SDK build with these changes and 1d89392 passed. On a GIGABYTE SDI VFG100 with a 1080p60 SDI signal, the Viewer capture journey (live preview, snapshot, stop, restart, recording) passed with that SDK. gvfg_playback_present_image and odd-width YUY2 frames were not exercised.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 16:50:43 +08:00
iverson3yaandClaude Opus 5.5 208fb6c811 Add a frame-hold verification skill and TLA+ model shared by Claude Code and Codex
- Add GVFG_SDK/sdk/gvfg/formal: a TLA+ model of one channel's frame-hold protocol (read, release, stop, start and signal-change recovery) and six TLC configs: the shipped code with the reader joined before stop/start and with it running across them, and four mutations that must fail.
- Add .agents/skills/verify-gvfg-frame-hold: check.ps1 runs every config against its expected result, prints counterexamples with -Trace, and reports when the covered code moves past the sync commit; f1-hardware-repro.ps1 stages a stop and start during a read on a real card.
- Add a Claude Code entry in .claude/skills that points to the shared copy, and notes on which steps must run outside the Codex Windows sandbox.

Validation: git diff --cached --check passed. check.ps1 met all six expectations and reported the model in step with 1d89392. f1-hardware-repro.ps1 reproduced the stuck channel against b47f27b and passed against 1d89392 on a GIGABYTE SDI VFG100. TLC needs Java 17+ and tla2tools 1.7.4; check.ps1 -Install fetches the jar into the git-ignored formal/tools. Not yet run from Codex.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 16:46:15 +08:00
iverson3yaandClaude Opus 5.5 1d89392cef Reject frames read across a stop and restart of a GVFG channel
- Record the channel's run generation when a read begins and refuse delivery if stop and start ran during the read. The frame belonged to the stopped stream and its backend hold had been reset, so the caller's release failed with GVFG_ESTATE and every later read stayed rejected until the next stop.
- Return GVFG_ESTATE with a specific last-error message in that case, and document it in the customer API reference.

Validation: git diff --cached --check passed. The MSVC Release SDK build passed. On a GIGABYTE SDI VFG100 with a 1080p60 SDI signal, a hardware reproduction that parks a read between capture and delivery left the channel stuck with the previous 3.2.0 code and with 3.1.0, and passed with this change. The Viewer capture journey (start, snapshot, stop, restart) passed on this SDK. A TLA+ model of the frame-hold protocol, kept outside this commit, passes with the reader running across stop and start. SDK version not bumped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 16:24:35 +08:00
iverson3ya b47f27bd39 Record PCI location paths during GVFG device enumeration
- Read Windows PCI location paths for capture devices.
- Remove per-query HDMI video debug output and simplify frame descriptor transfer.
- Document repository workflow and validation in AGENTS.md.

Validation: git diff --cached --check passed. Build and runtime tests were not run for this commit.
2026-11-30 14:43:52 +08:00
iverson3ya a47ab190bc Add HDMI audio input queries and split OSD into a helper in GVFG SDK 3.2
- Expose HDMI audio input information through the capture API and refresh the bundled Gigabyte library.
- Move OSD rendering into gvfg_osd.dll, connect channel OSD through the capture frame processor, and remove the experimental in-place zero-copy OSD path.
- Update playback integration, the customer API documentation, and the internal build guide.

Validation: git diff --cached --check passed. The MSVC Release SDK build passed. Capture hardware and runtime behavior were not tested.
2026-11-25 09:35:49 +08:00
Mark.lin 7a7027391e 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.
2026-11-17 17:40:25 +08:00
Mark.lin 47a5f041ee Preserve video format notifications before capture starts
Confirm the requested format before clearing stale audio and video frame notifications.

Validation: SDK Release built with the current worktree; staged whitespace check passed.
2026-11-16 20:55:07 +08:00
Mark.lin 3f4d416076 Adjust video format stabilization before capture
Allow up to one second for the format event and wait 500 ms after receipt before the single hardware format readback.
2026-11-16 11:33:32 +08:00
Mark.lin 5ebe03a2bb Consolidate playback APIs and add standalone OSD bitmap rendering
- move public PCM, image and presentation types into gvfg_playback.h and remove the separate backend headers from source and installation

- keep WASAPI and D3D backends private while preserving the existing public type names, fields and static backend integration

- move detailed preview delivery counters into a private header and expose their playback query only through the Debug diagnostics API

- retain public preview information and basic presentation statistics, mark EQUEUE_FULL as reserved, and document capacity limits as advanced settings with recommended defaults

- refresh customer guides, API reference and error handling for the single-header interface, presentation counter limits and EAUDIO handle-recreation policy

- add SDK-owned standalone premultiplied BGRA text rendering with transparent backgrounds, measured dimensions, thread-local snapshot lifetime and validated output bounds

Validation: git diff --cached --check passed. Release gvfg_playback and Customer Sample builds, standalone C/C++ header checks, Debug playback syntax checks and Release export inspection passed earlier in this session. Final follow-up changes affect comments and documentation only. No runtime or hardware playback validation was performed. The existing Release gvfg target was also checked and was up to date. OSD rendering changes were source-reviewed; no new bitmap or hardware test was run in this commit pass. Capture debug exports are unchanged.
2026-11-04 16:53:41 +08:00
Mark.lin d6935df9ae Refine customer API guides and consolidate SDK usage examples
- organize customer documentation around public API usage, parameters, ownership, status codes and limits while reducing internal implementation details

- move complete dual-slot OSD examples into the Capture guide and consolidate font-list lifetime, visibility, placement and error contracts in the API reference

- add a GPU conversion example with dimension overflow checks, allocation failure handling and explicit destination cleanup

- simplify playback guidance for timestamps, synchronization, buffering, reset and stop while preserving caller responsibilities and output limitations

- update the learning index with customer/internal documentation boundaries and study links, and refresh the bundled API reference PDF

Validation: git diff --cached --check passed. Markdown changes were reviewed against the staged scope. No build, PDF rendering, runtime or hardware validation was performed during this documentation-only commit pass.
2026-10-30 16:42:52 +08:00
562 changed files with 6101 additions and 13976 deletions
@@ -0,0 +1,172 @@
---
name: verify-gvfg-frame-hold
description: "Model-check the GVFG capture frame-hold protocol (gvfg_read_channel_frame / gvfg_release_channel_frame against stop, start and signal-change recovery) with TLA+/TLC, and reproduce the stop->start race on real hardware. Use it before and after any change to gvfg_capture.cpp's channel read/release/stop/start, or to GigabyteCaptureSession's wait_frame, release_frame, start_stream, stop_stream, handle_signal_event or restart_stream_after_signal_change."
---
# Verify the GVFG frame-hold protocol
## What is verified
**Property.** While an application holds a frame whose data is the backend capture buffer:
(1) `HeldFrameIsCurrent`: the buffer still belongs to the driver stream that is running now, so no recovery
restart and no stop/start has replaced it; (2) `ReleaseWillSucceed`: the application's single mandated
`gvfg_release_channel_frame()` will succeed.
**Harm if broken.** In zero-copy mode, the application reads a buffer that the driver is refilling, which gives
torn or foreign video. In every mode, the release returns `GVFG_ESTATE` and the channel stays "frame held", so
every later read fails with "previous frame has not been released" until the app stops the channel.
**Model.** The model is `GVFG_SDK/sdk/gvfg/formal/CaptureFrameHold.tla`. It has three threads: the app's video
reader (read, OSD branch, deliver, release), the app's lifecycle thread (stop and start, serialized as the
customer docs require), and the session event thread (format change or plug-in, followed by the recovery
restart). Each action is one mutex-protected section, or one atomic access, in the code, and its comment names
the function. A ghost `epoch` counts `GvfgStartCapture` calls, so "same buffer" means "same epoch".
**Tool.** TLA+ with TLC 1.7.4 (pinned and SHA256-checked). The question is whether events can happen in a bad
order across threads, and an exhaustive model checker over the protocol answers that. The C++ cannot be model
checked directly, because it sits on Win32 events and the vendor GvfgSdk. A small hardware program
(`scripts/f1_hardware_repro.cpp`) stages the one interleaving that matters most on a real card.
## Scope and bounds
- One channel. The configs use at most 4 stop/start calls, 2 signal events and 4 read attempts. At those bounds
`MC_Contract` covers 45,655 distinct states and `MC_ConcurrentReader` 237,899. A one-off run at 6/3/6 also
passed, with 361,278 and 2,822,739 states.
- Out of scope: audio frames, unplug events (they bump the generation but never restart), the vendor driver
itself (`GvfgGetVideoFrame*`, `GvfgStart/StopCapture` are taken as atomic and correct), the OSD processor's
internals (only its keep-hold versus early-release branch is modelled), multi-channel handles,
open/close/destroy, and timeouts (a timed-out wait is the same as a failed wait here).
- A Pass covers this model under these bounds, not the whole SDK.
## Run it
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .agents\skills\verify-gvfg-frame-hold\scripts\check.ps1
```
It needs Java 17 or later (installed on the dev PC: Eclipse Temurin 21, from
`winget install --id EclipseAdoptium.Temurin.21.JDK -e`) and tla2tools.jar 1.7.4. The script looks for the jar in
`$env:TLA2TOOLS_JAR`, then `GVFG_SDK/sdk/gvfg/formal/tools/` (git-ignored, inside the workspace so a sandboxed
agent can read it), then `%USERPROFILE%\.tools\tla`. Pass `-Install` once to download it into `formal/tools/`.
All six configs take a few seconds together. TLC runs with one worker,
so the first violation it reports is the same on every run. Logs go to
`GVFG_SDK/sdk/gvfg/formal/out/<config>.log` (git-ignored). Use `-Only MC_Contract` to run a single config.
| Config | What it is | Expected |
| --- | --- | --- |
| `MC_Contract.cfg` | Shipped code. The app pauses or joins its reader before every stop/start (srcroot `GvfgSource::stop` does). | Pass |
| `MC_ConcurrentReader.cfg` | Shipped code. The reader keeps running across stop then start. | Pass (F1 fixed) |
| `MC_Mut_NoRestartWait.cfg` | Mutation: recovery restart no longer waits for `frame_held_`. | Violation: HeldFrameIsCurrent |
| `MC_Mut_NoRecoveryCheck.cfg` | Mutation: capture ignores `recovery_pending_` and the generation. | Violation: HeldFrameIsCurrent |
| `MC_Mut_NoRunGeneration.cfg` | Mutation: delivery checks only `running`. This is the code before the F1 fix. | Violation: HeldFrameIsCurrent |
| `MC_Mut_NoRunningRecheck.cfg` | Mutation: delivery checks only the run generation. | Violation: ReleaseWillSucceed |
The script exits 0 only when every config matches its expected result and the covered code is unchanged since
the sync commit. Exit 3 (`STALE`) means the model passed but nobody has confirmed it against the changed code.
That is not a pass, so follow "Keeping it in step".
Read a violation with `check.ps1 -Trace <config>`. It reruns that config and prints the shortest counterexample,
one row per step: the action, then the variables that step changed. Map each action to code with the table under
"Code-to-model map". In Claude Code, the pstack **statechart** skill (`/pstack:statechart`) can also draw the
trace, and on a pass it draws how the protocol moves between states. Use its current instructions, and do not
copy its commands into this skill.
## Running it from Codex
Codex reads this skill from `.agents/skills/` (repo scope). Its Windows sandbox (`[windows] sandbox = "elevated"`)
runs commands as a separate low-privilege user on a private desktop.
- `check.ps1` and `check.ps1 -Trace` only need Java (under `C:\Program Files`) and the jar in `formal/tools/`, so
they should run inside the sandbox. `-Install` needs network access.
- `f1-hardware-repro.ps1` needs the capture card and the MSVC toolchain. Run it outside the sandbox: approve
the escalation when Codex asks, or use full access for that command.
- The behaviour above follows the Codex docs. It has not been tried in Codex yet, so if a step fails in the
sandbox, rerun that one command outside it before you suspect the code.
## Hardware check for F1
On a PC with a GVFG card and a live signal on channel 0, with no viewer holding the card:
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .agents\skills\verify-gvfg-frame-hold\scripts\f1-hardware-repro.ps1 -GvfgBuildDir GVFG_SDK\build\<name>
```
It compiles `f1_hardware_repro.cpp` against that build's `gvfg.lib`. It attaches a frame processor through the
exported `gvfg_control_frame_processor` (the hook OSD uses), which parks one read between capture and delivery.
It then calls `gvfg_stop_channel` and `gvfg_start_channel`, and lets the read finish. Exit 0 means the read was
rejected and the next read works. Exit 1 means F1 reproduced. Exit 2 means it could not be verified here, and
exit 3 means the race could not be staged.
## Finding F1: fixed in `1d89392`
**Before the fix.** The trigger is `gvfg_stop_channel()` followed by `gvfg_start_channel()` while
`gvfg_read_channel_frame()` sits between getting the frame and delivering it. The delivery check looked only at
`running`, which start had set back to true. So the read handed out a frame from the stopped stream as valid.
Its release then failed with `GVFG_ESTATE` ("Capture frame release rejected: no frame is held"), because
stop/start had reset `frame_held_`. `releaseFrame` returns before clearing `frameHeld`, so every later read
failed with "previous frame has not been released". On the dev PC this reproduced on hardware with the code
before the fix (3.2.0 at `b47f27b`, built from `git archive`) and with the older 3.1.0 build.
**The fix**, in `gvfg_capture.cpp` (`gvfg_channel_session_t`):
- `start()` increments `runGeneration` and sets `running` in one `frameMutex` section.
- `readFrame()` records `runGeneration` when it marks the read in progress.
- Delivery rejects the frame when `running` is false or the generation moved. It releases the backend hold if
the session still has one, and returns `GVFG_ESTATE` with "capture stopped or restarted during the read".
**Verified.** `MC_ConcurrentReader` passes. `MC_Mut_NoRunGeneration` (the old check) still fails, which shows the
check can fail. The hardware program exits 0 against the fixed build (`GVFG_SDK/build/verify-f1`) and 1 against
`b47f27b`. srcroot's capture journey passes on the fixed SDK.
**Still open, related.** `readAudioFrame` has the same `running`-only check. A stop->start during an audio read
can deliver one PCM chunk from before the restart. There is no backend hold for audio, so the channel does not
get stuck. Audio is outside this model.
## Telling a real bug from a modeling error
Map each step of the trace to the code named in the action's comment. Then ask whether the code really allows
that step at that moment: are the mutexes the same, and is the check the same? If it does, the trace is a real
interleaving. Report it in the code's words, as F1 does. If it does not, the model is wrong. Fix the action so it
matches the code. Never weaken an invariant and never drop a thread to get a pass.
## Code-to-model map (keep in step)
| Code (gvfg_capture.cpp = C, gigabyte_capture_session.cpp = S) | Model action / guard |
| --- | --- |
| C `readFrame`: `if (!running)` before the lock | `RBegin` |
| C `readFrame`, first `frameMutex` section: held / in-progress checks, record `runGeneration` | `RBeginLock` |
| S `wait_frame`: `running_`, `frame_held_`, generation snapshot | `RWaitCheck` |
| S `wait_frame`: WaitForMultipleObjects (stop, recovery, frame) | `RWakeFail`, `RWakeFrame` |
| S `wait_frame` capture section under `capture_mutex_`: `recovery_pending_` / generation check | `RCapture`, guard `CaptureRejectsDuringRecovery` |
| C `readFrame` OSD: keep the backend hold, or `release_frame` early | `ROsdKeep`, `ROsdEarlyRelease` |
| C `readFrame` delivery under `frameMutex`: `running` recheck and `runGeneration` comparison | `RDeliver`, guards `DeliverRechecksRunning`, `DeliverChecksRunGeneration` |
| C `readFrame` `stoppedWhileWaiting` release | `RStopRelease` |
| C `releaseFrame` (calls S `release_frame` inside `frameMutex`) | `RRelease` |
| C `stop`: `running = false`, `releaseHeldFrameForStop`, then S `stop_stream` | `UStop`, `UStopFrames`, `UStopBackend`, `UStopStream`, `UStopJoin` |
| C `start`: S `start_stream`, then `++runGeneration; running = true` under `frameMutex` | `UStartSession`, `UStartChannel` |
| S `handle_signal_event` first block (generation++, `recovery_pending_`) | `ESignal` |
| S restart decision (format compare) | `EDecide` (nondeterministic) |
| S `restart_stream_after_signal_change`: wait for `!frame_held_ \|\| !running_` | `EWaitHold`, guard `RestartWaitsForRelease` |
| S restart Stop/StartCapture under `capture_mutex_` | `ERestart` (epoch + 1) |
| S `handle_signal_event` end (`recovery_pending_ = false`) | `EFinish` |
**Coverage record.** The covered files are `GVFG_SDK/sdk/gvfg/src/gvfg_capture.cpp` (`gvfg_channel_session_t`:
`start`, `stop`, `readFrame`, `releaseFrame`, `releaseHeldFrameForStop`), and
`GVFG_SDK/sdk/gvfg/src/gigabyte/gigabyte_capture_session.cpp` with its `.h` (`start_stream`, `stop_stream`,
`wait_frame`, `release_frame`, `handle_signal_event`, `restart_stream_after_signal_change`,
`wait_for_recovery`). **Sync commit: `1d89392`** (the F1 fix, on master). The model
was last confirmed against the code at this commit.
### Keeping it in step
1. `check.ps1` prints `STALE` when a covered file differs from the sync commit, working tree included. Read the
diff of the covered functions: `git diff <sync commit> -- <file>`.
2. For each changed check, lock, or ordering, update the matching action in the table, or its guard in the
`Guards` set of `MC_Contract.cfg` and `MC_ConcurrentReader.cfg` when the change removes a guarded check.
Add any new step as a new action, with its function named in a comment.
3. Run `check.ps1`. A violation in `MC_Contract` or `MC_ConcurrentReader` means the change breaks the property.
Read the trace with `check.ps1 -Trace <config>`, and report it with the steps in code words. Do not loosen
the model.
When the change touches the read, stop or start path, also run the hardware check.
4. Move the sync commit (here and in `check.ps1`) forward only after you have confirmed that the model describes
the code at the new commit.
@@ -0,0 +1,142 @@
<#
Model-checks GVFG_SDK/sdk/gvfg/formal/CaptureFrameHold.tla with TLC and compares every config with its expected result.
Also reports whether the covered code changed since the sync commit (then the model needs another look).
powershell -NoProfile -ExecutionPolicy Bypass -File .agents\skills\verify-gvfg-frame-hold\scripts\check.ps1 [-Only MC_Contract] [-Install]
powershell -NoProfile -ExecutionPolicy Bypass -File .agents\skills\verify-gvfg-frame-hold\scripts\check.ps1 -Trace MC_Mut_NoRunGeneration
-Trace <config> runs one config and prints its counterexample as a table: each step's action and the variables it changed.
Map each action to code with the table in SKILL.md.
Exit 0: every config matched its expectation and the covered code is unchanged since the sync commit.
1: a mismatch (read the log it names). 2: Java or TLA+ tools missing.
3: expectations met, but covered code changed since the sync commit, so update the model first (SKILL.md).
tla2tools.jar is looked up in $env:TLA2TOOLS_JAR, then GVFG_SDK\sdk\gvfg\formal\tools (git-ignored, inside the
workspace so sandboxed agents can read it), then %USERPROFILE%\.tools\tla. -Install downloads the pinned v1.7.4
(SHA256 checked) into formal\tools. Java must be installed separately, e.g.
winget install --id EclipseAdoptium.Temurin.21.JDK -e.
#>
param([string[]]$Only, [switch]$Install, [string]$Trace)
$ErrorActionPreference = 'Stop'
$repo = (Resolve-Path (Join-Path $PSScriptRoot '..\..\..\..')).Path
$formal = Join-Path $repo 'GVFG_SDK\sdk\gvfg\formal'
$outDir = Join-Path $formal 'out'
# ---- tools -----------------------------------------------------------------
$jarVersion = '1.7.4'
$jarName = "tla2tools-$jarVersion.jar"
$jarSha256 = '936A262061C914694DFD669A543BE24573C45D5AA0FF20A8B96B23D01E050E88'
$workspaceJar = Join-Path $formal "tools\$jarName"
$jar = @($env:TLA2TOOLS_JAR, $workspaceJar, (Join-Path $env:USERPROFILE ".tools\tla\$jarName")) |
Where-Object { $_ -and (Test-Path $_) } | Select-Object -First 1
if (-not $jar) {
if (-not $Install) { Write-Host "Missing $jarName. Rerun with -Install (downloads ~2 MB from github.com/tlaplus into $workspaceJar)."; exit 2 }
New-Item -ItemType Directory -Force (Split-Path $workspaceJar) | Out-Null
Invoke-WebRequest -UseBasicParsing -OutFile $workspaceJar `
-Uri "https://github.com/tlaplus/tlaplus/releases/download/v$jarVersion/tla2tools.jar"
$jar = $workspaceJar
}
if ((Get-FileHash $jar -Algorithm SHA256).Hash -ne $jarSha256) { Write-Host "SHA256 mismatch for $jar"; exit 2 }
$java = $null
if ($env:JAVA_HOME -and (Test-Path "$env:JAVA_HOME\bin\java.exe")) { $java = "$env:JAVA_HOME\bin\java.exe" }
if (-not $java) {
$java = Get-ChildItem 'C:\Program Files\Eclipse Adoptium' -Directory -ErrorAction SilentlyContinue |
Sort-Object Name -Descending | ForEach-Object { Join-Path $_.FullName 'bin\java.exe' } |
Where-Object { Test-Path $_ } | Select-Object -First 1
}
if (-not $java) { $java = (Get-Command java -ErrorAction SilentlyContinue).Source }
if (-not $java) { Write-Host 'Java not found. Install it: winget install --id EclipseAdoptium.Temurin.21.JDK -e'; exit 2 }
# ---- expectations ----------------------------------------------------------
# Pass : TLC must report "No error has been found".
# Violation:X : TLC must report invariant X violated (mutations prove the check can fail; findings are known bugs).
$expect = [ordered]@{
'MC_Contract' = 'Pass' # shipped code, app quiesces reader before stop/start
'MC_ConcurrentReader' = 'Pass' # shipped code, reader runs across stop->start (F1 fixed)
'MC_Mut_NoRestartWait' = 'Violation:HeldFrameIsCurrent' # mutation: restart does not wait for frame_held_
'MC_Mut_NoRecoveryCheck' = 'Violation:HeldFrameIsCurrent' # mutation: capture ignores recovery_pending_/generation
'MC_Mut_NoRunGeneration' = 'Violation:HeldFrameIsCurrent' # mutation: delivery checks only running (F1, code before the fix)
'MC_Mut_NoRunningRecheck' = 'Violation:ReleaseWillSucceed' # mutation: delivery checks only the run generation
}
function Invoke-Tlc([string]$Config) {
$log = Join-Path $outDir "$Config.log"
$meta = Join-Path $outDir "meta-$Config"
# One worker keeps the search order, and so the first violated invariant, the same on every run.
& $java -XX:+UseParallelGC -cp $jar tlc2.TLC -config "$Config.cfg" -metadir $meta -workers 1 -cleanup CaptureFrameHold.tla 2>&1 |
ForEach-Object { "$_" } | Set-Content -Encoding UTF8 $log
Remove-Item -Recurse -Force $meta -ErrorAction SilentlyContinue
return $log
}
function Show-Trace([string]$LogPath) {
# TLC prints each state as "State N: <Action ...>" followed by "/\ var = value" lines.
$text = Get-Content $LogPath
$violation = $text | Where-Object { $_ -match 'Invariant \w+ is violated|Deadlock reached' } | Select-Object -First 1
if (-not $violation) { 'No counterexample in ' + $LogPath + ' (the config passed or TLC failed; read the log).'; return }
$violation.Trim()
$prev = @{}; $cur = $null; $action = $null; $step = 0
$states = New-Object System.Collections.ArrayList
foreach ($line in $text) {
if ($line -match '^State (\d+): <(\w+)') {
if ($cur) { [void]$states.Add(@($step, $action, $cur)) }
$step = [int]$matches[1]; $action = $matches[2]; $cur = [ordered]@{}
}
elseif ($cur -and $line -match '^/\\ (\w+) = (.+)$') { $cur[$matches[1]] = $matches[2] }
}
if ($cur) { [void]$states.Add(@($step, $action, $cur)) }
foreach ($s in $states) {
$vars = $s[2]
$changed = foreach ($k in $vars.Keys) { if (-not $prev.Contains($k) -or $prev[$k] -ne $vars[$k]) { "$k=$($vars[$k])" } }
'{0,3} {1,-16} {2}' -f $s[0], $s[1], ($changed -join ' ')
$prev = $vars
}
}
New-Item -ItemType Directory -Force $outDir | Out-Null
Push-Location $formal
try {
if ($Trace) {
if (-not (Test-Path "$Trace.cfg")) { Write-Host "No config $Trace.cfg in $formal"; exit 2 }
Show-Trace (Invoke-Tlc $Trace)
exit 0
}
$failed = $false
foreach ($cfg in $expect.Keys) {
if ($Only -and $cfg -notin $Only) { continue }
$sw = [Diagnostics.Stopwatch]::StartNew()
$log = Invoke-Tlc $cfg
$sw.Stop()
$text = Get-Content $log -Raw
$got = if ($text -match 'Model checking completed\. No error has been found') { 'Pass' }
elseif ($text -match 'Invariant (\w+) is violated') { "Violation:$($matches[1])" }
elseif ($text -match 'Deadlock reached') { 'Deadlock' }
else { 'ToolError' }
# TLC also prints progress lines with partial counts; the final summary is the last one.
$final = [regex]::Matches($text, '(\d+) distinct states found')
$states = if ($final.Count) { $final[$final.Count - 1].Groups[1].Value } else { '?' }
$ok = $got -eq $expect[$cfg]
if (-not $ok) { $failed = $true }
'{0,-24} expected {1,-30} got {2,-30} {3,8} states {4,6:n1}s {5}' -f $cfg, $expect[$cfg], $got, $states, $sw.Elapsed.TotalSeconds, $(if ($ok) { 'OK' } else { "MISMATCH -> $log" })
}
}
finally { Pop-Location }
# ---- is the verification still in step with the code? ---------------------
$syncCommit = '1d89392'
$covered = @('GVFG_SDK/sdk/gvfg/src/gvfg_capture.cpp', 'GVFG_SDK/sdk/gvfg/src/gigabyte/gigabyte_capture_session.cpp',
'GVFG_SDK/sdk/gvfg/src/gigabyte/gigabyte_capture_session.h')
$changed = git -C $repo diff --name-only $syncCommit -- @covered
if ($changed) {
Write-Host "STALE: covered code changed since sync commit ${syncCommit}: $($changed -join ', ')"
Write-Host " Re-read the changed functions against the model before trusting a Pass (see SKILL.md, 'Keeping it in step')."
} else {
Write-Host "In step: covered code unchanged since sync commit $syncCommit."
}
if ($failed) { 'RESULT: MISMATCH'; exit 1 }
# A pass against a model nobody re-checked after the code moved proves nothing about the new code.
if ($changed) { 'RESULT: STALE - expectations met by the model, but the model is not confirmed against the changed code'; exit 3 }
'RESULT: ALL EXPECTATIONS MET'
@@ -0,0 +1,37 @@
<#
Builds and runs f1_hardware_repro.cpp against one GVFG SDK build, on a PC with a GVFG card and a live signal on
channel 0. No viewer may hold the card while it runs.
powershell -NoProfile -ExecutionPolicy Bypass -File .agents\skills\verify-gvfg-frame-hold\scripts\f1-hardware-repro.ps1 -GvfgBuildDir GVFG_SDK\build\<name>
The build dir must contain bin\gvfg.dll and lib\gvfg.lib. Exit codes are the program's: 0 fixed, 1 F1 reproduced,
2 not verifiable here, 3 unexpected.
#>
param([Parameter(Mandatory)][string]$GvfgBuildDir)
$ErrorActionPreference = 'Stop'
$repo = (Resolve-Path (Join-Path $PSScriptRoot '..\..\..\..')).Path
$sdk = Join-Path $repo 'GVFG_SDK\sdk\gvfg'
$build = (Resolve-Path $GvfgBuildDir).Path
foreach ($f in 'bin\gvfg.dll', 'lib\gvfg.lib') {
if (-not (Test-Path (Join-Path $build $f))) { Write-Host "Missing $f in $build"; exit 3 }
}
if (Get-Process qt6_viewer, GVFG_CardTest -ErrorAction SilentlyContinue) { Write-Host 'A viewer or card test holds the card; close it first.'; exit 2 }
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
$vs = & $vswhere -products * -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
$env:PATH = (Split-Path $vswhere) + ';' + $env:PATH
cmd /c "`"$(Join-Path $vs 'VC\Auxiliary\Build\vcvars64.bat')`" >nul 2>&1 && set" | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') { [Environment]::SetEnvironmentVariable($matches[1], $matches[2]) }
}
$out = Join-Path $env:TEMP ("gvfg-f1-repro-" + (Split-Path $build -Leaf))
New-Item -ItemType Directory -Force $out | Out-Null
$exe = Join-Path $out 'f1_hardware_repro.exe'
& cl.exe /nologo /std:c++17 /EHsc /O2 /utf-8 "/I$sdk\include" "/I$sdk\src" (Join-Path $PSScriptRoot 'f1_hardware_repro.cpp') `
"/Fe:$exe" "/Fo:$out\\" /link "/LIBPATH:$build\lib" gvfg.lib | Out-Null
if ($LASTEXITCODE -ne 0) { Write-Host 'Compile failed'; exit 3 }
$env:PATH = (Join-Path $build 'bin') + ';' + $env:PATH
Write-Host "SDK build: $build"
& $exe
exit $LASTEXITCODE
@@ -0,0 +1,193 @@
// F1 on real hardware, deterministically: stop + start while a read sits between
// capture and delivery. A frame processor (the hook OSD uses) parks the reader in
// exactly that window, so no timing luck is needed.
//
// Exit 0: fixed behaviour (the read is rejected, the next read works).
// Exit 1: F1 reproduced (stale frame delivered, release rejected or channel stuck).
// Exit 2: not verifiable here (no device / no signal). Exit 3: unexpected result.
#include <windows.h>
#include <chrono>
#include <condition_variable>
#include <cstdio>
#include <mutex>
#include <thread>
#include "gvfg_capture.h"
#include "gvfg_frame_processor.h"
namespace
{
std::mutex g_mutex;
std::condition_variable g_cv;
bool g_armed = false;
bool g_parked = false;
bool g_resume = false;
gvfg_status_t parkerCreate(void **context)
{
*context = nullptr;
return GVFG_OK;
}
void parkerDestroy(void *) {}
gvfg_status_t parkerProcess(void *, const gvfg_frame_t &in, gvfg_frame_t &out, bool &applied,
gvfg_debug_osd_frame_timing_t *, uint8_t *, bool *inPlace)
{
out = in;
applied = false; // keep the backend hold, like OSD off / in-place OSD
if (inPlace)
*inPlace = false;
std::unique_lock<std::mutex> lock(g_mutex);
if (g_armed)
{
g_armed = false;
g_parked = true;
g_cv.notify_all();
g_cv.wait(lock, [] { return g_resume; });
}
return GVFG_OK;
}
gvfg_status_t parkerControl(void *, const void *) { return GVFG_OK; }
const gvfg_frame_processor kParker{parkerCreate, parkerDestroy, parkerProcess};
const char *name(gvfg_status_t status) { return gvfg_strerror(status); }
void lastError(gvfg_handle handle, const char *label)
{
char message[512] = {};
gvfg_get_channel_last_sdk_error_detail(handle, GVFG_CHANNEL_0, message, sizeof(message));
std::printf(" %-16s last SDK error: %s\n", label, message[0] ? message : "(none)");
}
}
int main()
{
std::printf("GVFG SDK %s\n", gvfg_get_version());
if (gvfg_enumerate_devices(nullptr, 0) < 1)
{
std::puts("NOT VERIFIED: no GVFG device");
return 2;
}
gvfg_handle handle = nullptr;
if (gvfg_create(&handle) != GVFG_OK || gvfg_open_channel(handle, 0, GVFG_CHANNEL_0) != GVFG_OK)
{
std::puts("NOT VERIFIED: cannot open device 0 channel 0");
return 2;
}
gvfg_status_t st = gvfg_start_channel(handle, GVFG_CHANNEL_0);
if (st != GVFG_OK)
{
std::printf("NOT VERIFIED: start failed (%s); is a signal connected?\n", name(st));
gvfg_destroy(handle);
return 2;
}
st = gvfg_control_frame_processor(handle, GVFG_CHANNEL_0, &kParker, true, parkerControl, nullptr,
"attach parker failed");
if (st != GVFG_OK)
{
std::printf("UNEXPECTED: cannot attach frame processor (%s)\n", name(st));
gvfg_destroy(handle);
return 3;
}
// Warm up: capture really flows before the race.
int warm = 0;
for (int i = 0; i < 20 && warm < 5; ++i)
{
gvfg_frame_t frame{};
if (gvfg_read_channel_frame(handle, GVFG_CHANNEL_0, &frame, 1000) == GVFG_OK)
{
++warm;
gvfg_release_channel_frame(handle, GVFG_CHANNEL_0, &frame);
}
}
if (warm < 5)
{
std::puts("NOT VERIFIED: frames are not flowing");
gvfg_destroy(handle);
return 2;
}
{
std::lock_guard<std::mutex> lock(g_mutex);
g_armed = true;
}
gvfg_status_t readStatus = GVFG_ETIMEOUT;
gvfg_status_t releaseStatus = GVFG_ETIMEOUT;
bool released = false;
std::thread reader([&] {
gvfg_frame_t frame{};
readStatus = gvfg_read_channel_frame(handle, GVFG_CHANNEL_0, &frame, 2000);
if (readStatus == GVFG_OK)
{
released = true;
releaseStatus = gvfg_release_channel_frame(handle, GVFG_CHANNEL_0, &frame);
}
});
bool parked = false;
{
std::unique_lock<std::mutex> lock(g_mutex);
parked = g_cv.wait_for(lock, std::chrono::seconds(5), [] { return g_parked; });
}
gvfg_status_t stopStatus = GVFG_ETIMEOUT;
gvfg_status_t startStatus = GVFG_ETIMEOUT;
if (parked)
{
stopStatus = gvfg_stop_channel(handle, GVFG_CHANNEL_0);
startStatus = gvfg_start_channel(handle, GVFG_CHANNEL_0);
}
{
std::lock_guard<std::mutex> lock(g_mutex);
g_resume = true;
}
g_cv.notify_all();
reader.join();
lastError(handle, "after race:");
gvfg_status_t nextRead = GVFG_ETIMEOUT;
gvfg_status_t nextRelease = GVFG_ETIMEOUT;
for (int i = 0; i < 5 && nextRead != GVFG_OK; ++i)
{
gvfg_frame_t frame{};
nextRead = gvfg_read_channel_frame(handle, GVFG_CHANNEL_0, &frame, 1000);
if (nextRead == GVFG_OK)
nextRelease = gvfg_release_channel_frame(handle, GVFG_CHANNEL_0, &frame);
else if (nextRead == GVFG_ESTATE)
break; // ESTATE here means the channel is stuck; retrying will not help
}
lastError(handle, "after next read:");
std::printf("parked in window : %s\n", parked ? "yes" : "no");
std::printf("stop / start : %s / %s\n", name(stopStatus), name(startStatus));
std::printf("racing read : %s\n", name(readStatus));
std::printf("its release : %s\n", released ? name(releaseStatus) : "(not called: no frame)");
std::printf("next read : %s (release %s)\n", name(nextRead),
nextRead == GVFG_OK ? name(nextRelease) : "-");
gvfg_stop_channel(handle, GVFG_CHANNEL_0);
gvfg_destroy(handle);
if (!parked || stopStatus != GVFG_OK || startStatus != GVFG_OK)
{
std::puts("RESULT: UNEXPECTED (race not staged)");
return 3;
}
if (readStatus == GVFG_OK && (releaseStatus != GVFG_OK || nextRead != GVFG_OK))
{
std::puts("RESULT: F1 REPRODUCED (stale frame delivered after stop->start)");
return 1;
}
if (readStatus != GVFG_OK && nextRead == GVFG_OK && nextRelease == GVFG_OK)
{
std::puts("RESULT: FIXED (racing read rejected, channel keeps working)");
return 0;
}
std::puts("RESULT: UNEXPECTED");
return 3;
}
@@ -0,0 +1,10 @@
---
name: verify-gvfg-frame-hold
description: "Model-check the GVFG capture frame-hold protocol (gvfg_read_channel_frame / gvfg_release_channel_frame against stop, start and signal-change recovery) with TLA+/TLC, and reproduce the stop->start race on real hardware. Use it before and after any change to gvfg_capture.cpp's channel read/release/stop/start, or to GigabyteCaptureSession's wait_frame, release_frame, start_stream, stop_stream, handle_signal_event or restart_stream_after_signal_change."
---
# verify-gvfg-frame-hold (Claude Code entry)
The skill lives in `.agents/skills/verify-gvfg-frame-hold/` at the GVFG_Standalone repository root, so Claude Code
and Codex share one copy. Read `.agents/skills/verify-gvfg-frame-hold/SKILL.md` and follow it. Its scripts are in
that folder. Do not copy them here.
+41
View File
@@ -0,0 +1,41 @@
# AGENTS.md
本指引適用於 `GVFG_Standalone`。以下路徑及指令以此 Git repository 根目錄為準。
## 專案入口
| 改動範圍 | 先看哪裡 |
| --- | --- |
| 擷取 API、裝置、通道、格式事件與 GPU 轉換 | `GVFG_SDK/sdk/gvfg/`,GigabyteLib adapter 位於 `src/gigabyte/` |
| 播放 API、模式、緩衝與影音同步 | `GVFG_SDK/helpers/gvfg_playback/` 與該目錄的 [維護說明](GVFG_SDK/helpers/gvfg_playback/README.md) |
| D3D 預覽與 WASAPI 音訊輸出 | `GVFG_SDK/helpers/gvfg_preview/`、`GVFG_SDK/helpers/gvfg_audio_playback/`,兩者都是 Playback 的內部靜態元件 |
| OSD(`gvfg_osd.dll`,選用) | `GVFG_SDK/helpers/gvfg_osd/` 與該目錄的 README |
| 建置、Sample 串接與安裝 | [內部建置說明](docs/INTERNAL_BUILD_GUIDE.md) 與各 target 的 `CMakeLists.txt` |
`../Costomer_SDK_Release/GVFG_Customer_Sample/` 是獨立的 Qt Demo,`../srcroot/` 是完整 Viewer。跨專案驗證可使用這些呼叫端,變更範圍依任務決定。`CaptureDemo/` 已列入 `.gitignore`,不在版本控制內;本機若有,僅作舊範例及驅動參考。
## 實作與相容性
- 修改前先用 `git status --short` 確認既有變更,讀取相關實作、呼叫端及驗收條件。沿用適用的介面,優先在問題所屬模組修正根因。
- 公開 C API 變更應核對標頭、DLL 匯出清單(適用時檢查 `.def`)、呼叫端和安裝規則。保留現有呼叫端依賴的結構配置、狀態碼及資源所有權。版本以 `GVFG_SDK/CMakeLists.txt` 的 `GVFG_SDK_VERSION` 為準,依該檔案的版本政策評估變更。
- 擷取改動需追蹤裝置與通道的啟停、格式變更及 frame 的 read/release 配對。涉及 callback、等待或 teardown 時,檢查失敗路徑、重複啟停,以及停止或釋放後是否仍可存取緩衝區。
- Playback 管理提交資料的播放副本,模式、時鐘和同步邏輯留在 Playback。涵蓋受影響的 video-only、audio-only、audio-video 或單張影像路徑。預覽略過與錄影掉格分開量測。
- 維持 GigabyteLib vendor 介面和播放 backend 的既有邊界。客戶 Release 透過公開 API 使用 SDK,內部診斷依各 target 的組態控制。
- 公開契約或用法有變動時,更新對應的 [擷取手冊](docs/GVFG_CUSTOMER_API.md)、[播放手冊](docs/GVFG_PLAYBACK_API.md) 或 [API Reference](docs/GVFG_Customer_doc/GVFG_CUSTOMER_API_REFERENCE.md)。客戶文件與 README 都有英文(`*.md`)和繁體中文(`*.zh-TW.md`)兩版,兩版須同步更新。
- 修正缺陷時,若同類錯誤能穩定重現,依現有測試入口加入適當的回歸驗證。需要人工判斷時,記下重現步驟與預期結果。
## 建置與驗證
SDK 使用 Windows x64、C++17、CMake 3.16 以上及與 vendor `GvfgSdk.lib` 相容的 MSVC x64 工具鏈。SDK 建置無需 Qt。在 MSVC x64 Developer Command Prompt 確認 Ninja 可用後,從 repository 根目錄執行。
```bat
cmake -S GVFG_SDK -B GVFG_SDK/build_release -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build GVFG_SDK/build_release --target gvfg gvfg_osd gvfg_playback
```
- 單項建置可將 `--target` 指定為受影響的 target。涉及公開標頭或共用類別配置時,完整重建 SDK,並用同版標頭、匯入庫和 DLL 乾淨重建相關應用程式。切換 generator 或 toolchain 時,使用獨立的 build 目錄。
- 封裝或安裝規則變更時,以 `cmake --install GVFG_SDK/build_release --prefix packages/sdk_check` 安裝到新的目錄,再核對公開標頭、匯入庫、DLL 與文件。需要 MinGW 客戶端匯入庫時,依建置說明設定並驗證 `GVFG_MINGW_DLLTOOL`。
- 擷取行為變更依影響範圍在有擷取卡、相容驅動及訊號源的環境驗證。播放行為使用對應的視窗或音訊裝置。依改動檢查有訊號、無訊號、格式切換、停止後重啟、輸出或同步。
- 修正擷取缺陷時,記錄卡型、驅動版本、輸入格式、重現步驟與預期行為。用相同條件重測,並驗證受影響的格式切換或停止後重啟流程。
- 修正影音同步或效能問題時,先量測基準,再用相同輸入、設定與測試時長比較修改前後。依問題記錄同步偏差、掉格數或其他相關指標,並附上單位與量測方式。缺少硬體或量測工具時,列出尚未驗證的情境。
- 文件變更核對路徑、指令及來源定義。交付時列出實際執行的檢查、結果與未驗證項目,分別回報編譯、封裝和實機結果。
@@ -1,98 +0,0 @@
;
; pcie_s2mm_driver.inf
;
[Version]
Signature="$WINDOWS NT$"
Class=Sample ; TODO: edit Class
ClassGuid={78A1C341-4539-11d3-B88D-00C04FAD5171} ; TODO: edit ClassGuid
Provider=%ManufacturerName%
CatalogFile=pcie_s2mm_driver.cat
DriverVer = 07/20/2026,15.7.4.909
[DestinationDirs]
DefaultDestDir = 12
pcie_s2mm_driver_Device_CoInstaller_CopyFiles = 11
; ================= Class section =====================
[ClassInstall32]
Addreg=SampleClassReg
[SampleClassReg]
HKR,,,0,%ClassName%
HKR,,Icon,,-5
[SourceDisksNames]
1 = %DiskName%,,,""
[SourceDisksFiles]
pcie_s2mm_driver.sys = 1,,
;
;*****************************************
; Install Section
;*****************************************
[Manufacturer]
%ManufacturerName%=Standard,NTamd64
[Standard.NTamd64]
%pcie_s2mm_driver.DeviceDesc%=pcie_s2mm_driver_Device, PCI\VEN_10EE&DEV_7024 ; PCIe device match
[pcie_s2mm_driver_Device.NT]
CopyFiles=Drivers_Dir
[Drivers_Dir]
pcie_s2mm_driver.sys
[pcie_s2mm_driver_Device.NT.HW]
AddReg = AddInterruptReg
[AddInterruptReg]
HKR,"Interrupt Management",,0x00000010
HKR,"Interrupt Management\MessageSignaledInterruptProperties",,0x00000010
HKR,"Interrupt Management\MessageSignaledInterruptProperties",MSISupported,0x00010001,1
HKR,"Interrupt Management\MessageSignaledInterruptPropperties",MessageNumberLimit,0x00010001,24
;-------------- Service installation
[pcie_s2mm_driver_Device.NT.Services]
AddService = pcie_s2mm_driver,%SPSVCINST_ASSOCSERVICE%, pcie_s2mm_driver_Service_Inst
; -------------- pcie_s2mm_driver driver install sections
[pcie_s2mm_driver_Service_Inst]
DisplayName = %pcie_s2mm_driver.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\pcie_s2mm_driver.sys
;
;--- pcie_s2mm_driver_Device Coinstaller installation ------
;
[pcie_s2mm_driver_Device.NT.CoInstallers]
AddReg=pcie_s2mm_driver_Device_CoInstaller_AddReg
CopyFiles=pcie_s2mm_driver_Device_CoInstaller_CopyFiles
[pcie_s2mm_driver_Device_CoInstaller_AddReg]
;
[pcie_s2mm_driver_Device_CoInstaller_CopyFiles]
;
[pcie_s2mm_driver_Device.NT.Wdf]
KmdfService = pcie_s2mm_driver, pcie_s2mm_driver_wdfsect
[pcie_s2mm_driver_wdfsect]
KmdfLibraryVersion = 1.15
[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
ManufacturerName="<Your manufacturer name>" ;TODO: Replace with your manufacturer name
ClassName="Samples" ; TODO: edit ClassName
DiskName = "pcie_s2mm_driver Installation Disk"
pcie_s2mm_driver.DeviceDesc = "pcie_s2mm_driver Device"
pcie_s2mm_driver.SVCDESC = "pcie_s2mm_driver Service"
-257
View File
@@ -1,257 +0,0 @@
/*
* This file is part of the EasyLogger Library.
*
* Copyright (c) 2015-2018, Armink, <armink.ztl@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* 'Software'), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Function: It is an head file for this library. You can see all be called functions.
* Created on: 2015-04-28
*/
#ifndef __ELOG_H__
#define __ELOG_H__
#include <elog_cfg.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/* output log's level */
#define ELOG_LVL_ASSERT 0
#define ELOG_LVL_ERROR 1
#define ELOG_LVL_WARN 2
#define ELOG_LVL_INFO 3
#define ELOG_LVL_DEBUG 4
#define ELOG_LVL_VERBOSE 5
/* output log's level total number */
#define ELOG_LVL_TOTAL_NUM 6
/* EasyLogger software version number */
#define ELOG_SW_VERSION "1.0.0"
/* EasyLogger assert for developer. */
#ifdef ELOG_ASSERT_ENABLE
#define ELOG_ASSERT(EXPR) \
if (!(EXPR)) \
{ \
if (elog_assert_hook == NULL) { \
elog_a("elog", "(%s) has assert failed at %s:%ld.", #EXPR, __FUNCTION__, __LINE__); \
while (1); \
} else { \
elog_assert_hook(#EXPR, __FUNCTION__, __LINE__); \
} \
}
#else
#define ELOG_ASSERT(EXPR) ((void)0);
#endif
#ifndef ELOG_OUTPUT_ENABLE
#define elog_a(tag, ...)
#define elog_e(tag, ...)
#define elog_w(tag, ...)
#define elog_i(tag, ...)
#define elog_d(tag, ...)
#define elog_v(tag, ...)
#else /* ELOG_OUTPUT_ENABLE */
#if ELOG_OUTPUT_LVL >= ELOG_LVL_ASSERT
#define elog_assert(tag, ...) \
elog_output(ELOG_LVL_ASSERT, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_assert(tag, ...)
#endif /* ELOG_OUTPUT_LVL >= ELOG_LVL_ASSERT */
#if ELOG_OUTPUT_LVL >= ELOG_LVL_ERROR
#define elog_error(tag, ...) \
elog_output(ELOG_LVL_ERROR, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_error(tag, ...)
#endif /* ELOG_OUTPUT_LVL >= ELOG_LVL_ERROR */
#if ELOG_OUTPUT_LVL >= ELOG_LVL_WARN
#define elog_warn(tag, ...) \
elog_output(ELOG_LVL_WARN, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_warn(tag, ...)
#endif /* ELOG_OUTPUT_LVL >= ELOG_LVL_WARN */
#if ELOG_OUTPUT_LVL >= ELOG_LVL_INFO
#define elog_info(tag, ...) \
elog_output(ELOG_LVL_INFO, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_info(tag, ...)
#endif /* ELOG_OUTPUT_LVL >= ELOG_LVL_INFO */
#if ELOG_OUTPUT_LVL >= ELOG_LVL_DEBUG
#define elog_debug(tag, ...) \
elog_output(ELOG_LVL_DEBUG, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_debug(tag, ...)
#endif /* ELOG_OUTPUT_LVL >= ELOG_LVL_DEBUG */
#if ELOG_OUTPUT_LVL == ELOG_LVL_VERBOSE
#define elog_verbose(tag, ...) \
elog_output(ELOG_LVL_VERBOSE, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_verbose(tag, ...)
#endif /* ELOG_OUTPUT_LVL == ELOG_LVL_VERBOSE */
#endif /* ELOG_OUTPUT_ENABLE */
/* all formats index */
typedef enum {
ELOG_FMT_LVL = 1 << 0, /**< level */
ELOG_FMT_TAG = 1 << 1, /**< tag */
ELOG_FMT_TIME = 1 << 2, /**< current time */
ELOG_FMT_P_INFO = 1 << 3, /**< process info */
ELOG_FMT_T_INFO = 1 << 4, /**< thread info */
ELOG_FMT_DIR = 1 << 5, /**< file directory and name */
ELOG_FMT_FUNC = 1 << 6, /**< function name */
ELOG_FMT_LINE = 1 << 7, /**< line number */
} ElogFmtIndex;
/* macro definition for all formats */
#define ELOG_FMT_ALL (ELOG_FMT_LVL|ELOG_FMT_TAG|ELOG_FMT_TIME|ELOG_FMT_P_INFO|ELOG_FMT_T_INFO| \
ELOG_FMT_DIR|ELOG_FMT_FUNC|ELOG_FMT_LINE)
/* output log's filter */
typedef struct {
uint8_t level;
char tag[ELOG_FILTER_TAG_MAX_LEN + 1];
char keyword[ELOG_FILTER_KW_MAX_LEN + 1];
} ElogFilter, *ElogFilter_t;
/* easy logger */
typedef struct {
ElogFilter filter;
size_t enabled_fmt_set[ELOG_LVL_TOTAL_NUM];
bool output_enabled;
bool output_lock_enabled;
bool output_is_locked_before_enable;
bool output_is_locked_before_disable;
#ifdef ELOG_COLOR_ENABLE
bool text_color_enabled;
#endif
}EasyLogger, *EasyLogger_t;
/* EasyLogger error code */
typedef enum {
ELOG_NO_ERR,
} ElogErrCode;
/* elog.c */
ElogErrCode elog_init(const char *log_file);
void elog_start(void);
void elog_set_output_enabled(bool enabled);
bool elog_get_output_enabled(void);
void elog_set_text_color_enabled(bool enabled);
bool elog_get_text_color_enabled(void);
void elog_set_fmt(uint8_t level, size_t set);
void elog_set_filter(uint8_t level, const char *tag, const char *keyword);
void elog_set_filter_lvl(uint8_t level);
void elog_set_filter_tag(const char *tag);
void elog_set_filter_kw(const char *keyword);
void elog_raw(const char *format, ...);
void elog_output(uint8_t level, const char *tag, const char *file, const char *func,
const long line, const char *format, ...);
void elog_output_lock_enabled(bool enabled);
extern void (*elog_assert_hook)(const char* expr, const char* func, size_t line);
void elog_assert_set_hook(void (*hook)(const char* expr, const char* func, size_t line));
int8_t elog_find_lvl(const char *log);
const char *elog_find_tag(const char *log, uint8_t lvl, size_t *tag_len);
#define elog_a(tag, ...) elog_assert(tag, __VA_ARGS__)
#define elog_e(tag, ...) elog_error(tag, __VA_ARGS__)
#define elog_w(tag, ...) elog_warn(tag, __VA_ARGS__)
#define elog_i(tag, ...) elog_info(tag, __VA_ARGS__)
#define elog_d(tag, ...) elog_debug(tag, __VA_ARGS__)
#define elog_v(tag, ...) elog_verbose(tag, __VA_ARGS__)
/**
* log API short definition
* NOTE: The `LOG_TAG` and `LOG_LVL` must defined before including the <elog.h> when you want to use log_x API.
*/
#if !defined(LOG_TAG)
#define LOG_TAG "NO_TAG"
#endif
#if !defined(LOG_LVL)
#define LOG_LVL ELOG_LVL_VERBOSE
#endif
#if LOG_LVL >= ELOG_LVL_ASSERT
#define log_a(...) elog_a(LOG_TAG, __VA_ARGS__)
#else
#define log_a(...) ((void)0);
#endif
#if LOG_LVL >= ELOG_LVL_ERROR
#define log_e(...) elog_e(LOG_TAG, __VA_ARGS__)
#else
#define log_e(...) ((void)0);
#endif
#if LOG_LVL >= ELOG_LVL_WARN
#define log_w(...) elog_w(LOG_TAG, __VA_ARGS__)
#else
#define log_w(...) ((void)0);
#endif
#if LOG_LVL >= ELOG_LVL_INFO
#define log_i(...) elog_i(LOG_TAG, __VA_ARGS__)
#else
#define log_i(...) ((void)0);
#endif
#if LOG_LVL >= ELOG_LVL_DEBUG
#define log_d(...) elog_d(LOG_TAG, __VA_ARGS__)
#else
#define log_d(...) ((void)0);
#endif
#if LOG_LVL >= ELOG_LVL_VERBOSE
#define log_v(...) elog_v(LOG_TAG, __VA_ARGS__)
#else
#define log_v(...) ((void)0);
#endif
/* assert API short definition */
#if !defined(assert)
#define assert ELOG_ASSERT
#endif
/* elog_buf.c */
void elog_buf_enabled(bool enabled);
void elog_flush(void);
/* elog_async.c */
void elog_async_enabled(bool enabled);
size_t elog_async_get_log(char *log, size_t size);
size_t elog_async_get_line_log(char *log, size_t size);
/* elog_utils.c */
size_t elog_strcpy(size_t cur_len, char *dst, const char *src);
size_t elog_cpyln(char *line, const char *log, size_t len);
void *elog_memcpy(void *dst, const void *src, size_t count);
#ifdef __cplusplus
}
#endif
#endif /* __ELOG_H__ */
-75
View File
@@ -1,75 +0,0 @@
/*
* This file is part of the EasyLogger Library.
*
* Copyright (c) 2015-2016, Armink, <armink.ztl@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* 'Software'), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Function: It is the configure head file for this library.
* Created on: 2015-07-30
*/
#ifndef _ELOG_CFG_H_
#define _ELOG_CFG_H_
/*---------------------------------------------------------------------------*/
/* enable log output. */
#define ELOG_OUTPUT_ENABLE
/* setting static output log level. range: from ELOG_LVL_ASSERT to ELOG_LVL_VERBOSE */
#define ELOG_OUTPUT_LVL ELOG_LVL_VERBOSE
/* enable assert check */
#define ELOG_ASSERT_ENABLE
/* buffer size for every line's log */
#define ELOG_LINE_BUF_SIZE 1024
/* output line number max length */
#define ELOG_LINE_NUM_MAX_LEN 5
/* output filter's tag max length */
#define ELOG_FILTER_TAG_MAX_LEN 30
/* output filter's keyword max length */
#define ELOG_FILTER_KW_MAX_LEN 16
/* output newline sign */
#define ELOG_NEWLINE_SIGN "\n"
/*---------------------------------------------------------------------------*/
/* enable log color */
#define ELOG_COLOR_ENABLE
/* change the some level logs to not default color if you want */
#define ELOG_COLOR_ASSERT (F_MAGENTA B_NULL S_NORMAL)
#define ELOG_COLOR_ERROR (F_RED B_NULL S_NORMAL)
#define ELOG_COLOR_WARN (F_YELLOW B_NULL S_NORMAL)
#define ELOG_COLOR_INFO (F_CYAN B_NULL S_NORMAL)
#define ELOG_COLOR_DEBUG (F_GREEN B_NULL S_NORMAL)
#define ELOG_COLOR_VERBOSE (F_BLUE B_NULL S_NORMAL)
/*---------------------------------------------------------------------------*/
/* enable asynchronous output mode */
#define ELOG_ASYNC_OUTPUT_ENABLE
/* the highest output level for async mode, other level will sync output */
#define ELOG_ASYNC_OUTPUT_LVL ELOG_LVL_ASSERT
/* buffer size for asynchronous output mode */
#define ELOG_ASYNC_OUTPUT_BUF_SIZE (ELOG_LINE_BUF_SIZE * 10)
/* each asynchronous output's log which must end with newline sign */
#define ELOG_ASYNC_LINE_OUTPUT
/* asynchronous output mode using POSIX pthread implementation */
#define ELOG_ASYNC_OUTPUT_USING_PTHREAD
/*---------------------------------------------------------------------------*/
/* enable buffered output mode */
#define ELOG_BUF_OUTPUT_ENABLE
/* buffer size for buffered output mode */
#define ELOG_BUF_OUTPUT_BUF_SIZE (ELOG_LINE_BUF_SIZE * 10)
#endif /* _ELOG_CFG_H_ */
-95
View File
@@ -1,95 +0,0 @@
#-------------------------------------------------
#
# Project created by QtCreator 2018-12-06T23:31:36
#
#-------------------------------------------------
QT += core gui openglwidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = CaptureDemo
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS QT_DEBUG
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
CONFIG += console
SOURCES += \
main.cpp \
mainwindow.cpp \
my_widget/gl_widget.cpp \
video_card.cpp \
my_widget/nav_widget.cpp \
task.cpp \
common/utils.cpp \
yuv_widget.cpp
HEADERS += \
mainwindow.h \
mainwindow.h \
my_widget/gl_widget.h \
video_card.h \
my_widget/nav_widget.h \
3rdparty/include/elog.h \
3rdparty/include/elog_cfg.h \
task.h \
common/semaphore.h \
common/utils.h \
video_card.h \
xdma_public.h \
yuv_widget.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
res.qrc
INCLUDEPATH += $$PWD/3rdparty/include
DEPENDPATH += $$PWD/3rdparty/include
GVFG_ROOT = $$clean_path($$PWD/../..)
INCLUDEPATH += \
$$GVFG_ROOT/helpers/gvfg_preview/include
CONFIG(debug, debug|release) {
GVFG_CONFIG = Debug
GVFG_DEMO_OUTPUT = $$OUT_PWD/debug
} else {
GVFG_CONFIG = Release
GVFG_DEMO_OUTPUT = $$OUT_PWD/release
}
msvc {
GVFG_BUILD = $$GVFG_ROOT/build/Desktop_Qt_6_10_2_MSVC2022_64bit-$${GVFG_CONFIG}
GVFG_PREVIEW_DLL = $$GVFG_BUILD/bin/gvfg_preview.dll
}
mingw {
GVFG_BUILD = $$GVFG_ROOT/build/Desktop_Qt_6_10_2_MinGW_64_bit-$${GVFG_CONFIG}
GVFG_PREVIEW_DLL = $$GVFG_BUILD/bin/libgvfg_preview.dll
}
LIBS += -L$$GVFG_BUILD/lib -lgvfg_preview
QMAKE_POST_LINK += $$QMAKE_COPY $$shell_path($$GVFG_PREVIEW_DLL) $$shell_path($$GVFG_DEMO_OUTPUT)
msvc {
QMAKE_CFLAGS += /utf-8
QMAKE_CXXFLAGS += /utf-8
}
win32: LIBS += -lSetupAPI
Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

@@ -1,36 +0,0 @@
#ifndef _SEMAPHORE_H_
#define _SEMAPHORE_H_
#include <memory>
class Semaphore
{
public:
Semaphore(unsigned long count = 0) : count_(count) {}
Semaphore(const Semaphore &) = delete;
Semaphore &operator=(const Semaphore &) = delete;
void signal()
{
{
std::unique_lock<std::mutex> lock(mtx_);
++count_;
}
cv_.notify_one();
}
void wait()
{
std::unique_lock<std::mutex> lock(mtx_);
cv_.wait(lock, [=]() {
return count_ > 0;
});
--count_;
}
private:
std::mutex mtx_;
std::condition_variable cv_;
unsigned long count_;
};
#endif
-18
View File
@@ -1,18 +0,0 @@
#include "utils.h"
BYTE* Utils::allocate_buffer(size_t size, size_t alignment)
{
if (size == 0)
{
size = 4;
}
if (alignment == 0)
{
SYSTEM_INFO sys_info;
GetSystemInfo(&sys_info);
alignment = sys_info.dwPageSize;
}
return (BYTE *)_aligned_malloc(size, alignment);
}
-10
View File
@@ -1,10 +0,0 @@
#ifndef UTILS_H_
#define UTILS_H_
#include <Windows.h>
class Utils {
public:
Utils(){};
public:
static BYTE* allocate_buffer(size_t size, size_t alignment);
};
#endif
-39
View File
@@ -1,39 +0,0 @@
#include "mainwindow.h"
#include <QApplication>
#include <QFile>
// #include <QtCore/QTextCodec>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// #if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
// #if _MSC_VER
// QTextCodec *codec = QTextCodec::codecForName("GBK");
// #else
// QTextCodec *codec = QTextCodec::codecForName("UTF-8");
// #endif
// QTextCodec::setCodecForLocale(codec);
// QTextCodec::setCodecForCStrings(codec);
// QTextCodec::setCodecForTr(codec);
// #else
// QTextCodec *codec = QTextCodec::codecForName("UTF-8");
// QTextCodec::setCodecForLocale(codec);
// #endif
// QThread::Sleep(1);
qDebug() << "start";
QFile file(":/res/qss/default.qss");
if (file.open(QFile::ReadOnly))
{
QString qss = QString(file.readAll());
qApp->setStyleSheet(qss);
file.close();
MainWindow w;
w.init();
w.show();
return a.exec();
}
else
{
return -1;
}
}
-771
View File
@@ -1,771 +0,0 @@
#include "mainwindow.h"
#include <QVariant>
#include <QVBoxLayout>
#include <QCoreApplication>
#include <QPushButton>
#include <QApplication>
#include <QString>
#include <QDebug>
#include <QButtonGroup>
#include <QPainter>
#include <QPainterPath>
#include <QGraphicsDropShadowEffect>
#include <QLabel>
#include <QScreen>
#include <conio.h>
#include <QDateTime>
#include <QFile>
#include <QMessageBox>
#include "my_widget/nav_widget.h"
#define FRAMESHAPE 10
constexpr ULONG FOURCC_V210 = 0x76323130;
namespace
{
void destroyPreview(gvfg_preview_handle &handle)
{
if (!handle)
return;
gvfg_preview_shutdown(handle);
gvfg_preview_destroy(handle);
handle = nullptr;
}
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setProperty("type", QVariant("mainwindow"));
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
setAttribute(Qt::WA_TranslucentBackground);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
setMinimumSize(1200, 600);
is_dragging_ = false;
is_scaling = false;
}
MainWindow::~MainWindow()
{
// if(write_worker_) {
// write_worker_->stop();
// write_worker_.reset();
// }
}
void MainWindow::init()
{
QWidget *main_widget = new QWidget(this);
QVBoxLayout *main_layout = new QVBoxLayout(this);
main_layout->setContentsMargins(8, 8, 8, 8);
main_layout->setSpacing(0);
// main_layout->setContentsMargins(0);
main_layout->setSizeConstraint(QLayout::SetMaximumSize);
NavWidget *nav_widget = new NavWidget();
nav_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
nav_widget->setFixedHeight(40);
nav_widget->setMouseTracking(true);
QLabel *title = new QLabel("CaptureDemo");
title->setProperty("type", QVariant("nav_title"));
QPushButton *btn_about = new QPushButton("深圳市拓新高电子科技有限公司");
btn_about->setProperty("type", QVariant("nav_btn"));
btn_about->setCursor(Qt::PointingHandCursor);
btn_about->setCheckable(true);
QPushButton *btn_minimize = new QPushButton;
btn_minimize->setProperty("type", QVariant("nav_min_btn"));
btn_minimize->setCursor(Qt::PointingHandCursor);
btn_minimize->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
btn_minimize->setFixedSize(20, 20);
connect(btn_minimize, &QPushButton::clicked, this, &MainWindow::clickedMinimizeBtn);
btn_max_or_normal_ = new QPushButton;
btn_max_or_normal_->setProperty("type", QVariant("nav_max_btn"));
btn_max_or_normal_->setCursor(Qt::PointingHandCursor);
btn_max_or_normal_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
btn_max_or_normal_->setFixedSize(20, 20);
btn_max_or_normal_->setCheckable(true);
connect(btn_max_or_normal_, &QPushButton::clicked, this, &MainWindow::clickedMaxOrNormalBtn);
QPushButton *btn_close = new QPushButton;
btn_close->setProperty("type", QVariant("nav_close_btn"));
btn_close->setCursor(Qt::PointingHandCursor);
btn_close->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
btn_close->setFixedSize(20, 20);
connect(btn_close, &QPushButton::clicked, this, &MainWindow::clickedCloseBtn);
QHBoxLayout *nav_layout = new QHBoxLayout;
// nav_layout->setContentsMargins(0);
nav_layout->setSpacing(0);
nav_layout->setContentsMargins(8, 0, 8, 0);
nav_layout->addWidget(title, 0, Qt::AlignLeft | Qt::AlignVCenter);
nav_layout->addStretch(9);
nav_layout->addWidget(btn_about, 0, Qt::AlignRight | Qt::AlignBottom);
nav_layout->addStretch(1);
nav_layout->addWidget(btn_minimize, 0, Qt::AlignRight | Qt::AlignVCenter);
nav_layout->addSpacing(10);
nav_layout->addWidget(btn_max_or_normal_, 0, Qt::AlignRight | Qt::AlignVCenter);
nav_layout->addSpacing(10);
nav_layout->addWidget(btn_close, 0, Qt::AlignRight | Qt::AlignVCenter);
nav_widget->setLayout(nav_layout);
main_layout->addWidget(nav_widget);
connect(nav_widget, &NavWidget::doubleClicked, this, &MainWindow::clickedMaxOrNormalBtn);
QHBoxLayout *gl_layout = new QHBoxLayout;
gl_layout->setSpacing(4);
gl_layout->setContentsMargins(0, 0, 0, 0);
for (int i = 0; i < PCIE_S2MM_MAX_CHANNELS; i++)
{
gl_widget_[i] = new YUVWidget(this);
gl_widget_[i]->setAttribute(Qt::WA_NativeWindow);
gl_widget_[i]->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
gl_widget_[i]->setMouseTracking(true);
gl_layout->addWidget(gl_widget_[i]);
}
main_layout->addLayout(gl_layout);
// QHBoxLayout *wh_layout = new QHBoxLayout;
// // wh_layout->setContentsMargins(0);
// wh_layout->setSpacing(4);
// wh_layout->setContentsMargins(25, 4, 25, 4);
// wh_layout->setAlignment(Qt::AlignLeft);
// QLabel *tmp = new QLabel("长:");
// tmp->setProperty("type", QVariant("nav_title"));
// wh_layout->addWidget(tmp);
// edt_width_ = new QLineEdit;
// edt_width_->setFixedWidth(100);
// edt_width_->setText("1920");
// wh_layout->addWidget(edt_width_, 0, Qt::AlignLeft);
// QLabel *tmp1 = new QLabel("宽:");
// tmp1->setProperty("type", QVariant("nav_title"));
// wh_layout->addWidget(tmp1);
// edt_height_ = new QLineEdit;
// edt_height_->setFixedWidth(100);
// edt_height_->setText("1080");
// wh_layout->addWidget(edt_height_, 0, Qt::AlignLeft);
// main_layout->addLayout(wh_layout);
QHBoxLayout *bar0_layout = new QHBoxLayout;
bar0_layout->setSpacing(4);
bar0_layout->setContentsMargins(25, 4, 25, 4);
bar0_layout->setAlignment(Qt::AlignLeft);
QLabel *bar0_addr_label = new QLabel("BAR0地址:");
bar0_addr_label->setProperty("type", QVariant("nav_title"));
bar0_layout->addWidget(bar0_addr_label);
edt_bar0_addr_ = new QLineEdit;
edt_bar0_addr_->setFixedWidth(100);
edt_bar0_addr_->setPlaceholderText("0x");
bar0_layout->addWidget(edt_bar0_addr_, 0, Qt::AlignLeft);
QLabel *bar0_val_label = new QLabel("值:");
bar0_val_label->setProperty("type", QVariant("nav_title"));
bar0_layout->addWidget(bar0_val_label);
edt_bar0_val_ = new QLineEdit;
edt_bar0_val_->setFixedWidth(100);
edt_bar0_val_->setPlaceholderText("0x");
bar0_layout->addWidget(edt_bar0_val_, 0, Qt::AlignLeft);
btn_read_bar0_ = new QPushButton("读BAR0");
btn_read_bar0_->setProperty("type", QVariant("gl_btn"));
btn_read_bar0_->setProperty("color", QVariant("white"));
btn_read_bar0_->setCursor(Qt::PointingHandCursor);
btn_read_bar0_->setFixedWidth(80);
bar0_layout->addWidget(btn_read_bar0_);
connect(btn_read_bar0_, &QPushButton::clicked, [=]()
{
if (!video_card_) return;
bool ok;
ULONG addr = edt_bar0_addr_->text().toULong(&ok, 0);
if (!ok) {
qWarning() << "BAR0 read: invalid address";
return;
}
ULONG val = 0;
if (video_card_->readReg(addr, val)) {
edt_bar0_val_->setText(QString("0x%1").arg(val, 8, 16, QChar('0')));
qDebug() << "BAR0 read: addr=0x" << Qt::hex << addr << " val=0x" << val;
} });
btn_write_bar0_ = new QPushButton("写BAR0");
btn_write_bar0_->setProperty("type", QVariant("gl_btn"));
btn_write_bar0_->setProperty("color", QVariant("white"));
btn_write_bar0_->setCursor(Qt::PointingHandCursor);
btn_write_bar0_->setFixedWidth(80);
bar0_layout->addWidget(btn_write_bar0_);
connect(btn_write_bar0_, &QPushButton::clicked, [=]()
{
if (!video_card_) return;
bool ok1, ok2;
ULONG addr = edt_bar0_addr_->text().toULong(&ok1, 0);
ULONG val = edt_bar0_val_->text().toULong(&ok2, 0);
if (!ok1 || !ok2) {
qWarning() << "BAR0 write: invalid address or value";
return;
}
if (video_card_->writeReg(addr, val)) {
qDebug() << "BAR0 write: addr=0x" << Qt::hex << addr << " val=0x" << val;
} });
main_layout->addLayout(bar0_layout);
QHBoxLayout *bar1_layout = new QHBoxLayout;
bar1_layout->setSpacing(4);
bar1_layout->setContentsMargins(25, 4, 25, 4);
bar1_layout->setAlignment(Qt::AlignLeft);
QLabel *bar1_addr_label = new QLabel("BAR1地址:");
bar1_addr_label->setProperty("type", QVariant("nav_title"));
bar1_layout->addWidget(bar1_addr_label);
edt_bar1_addr_ = new QLineEdit;
edt_bar1_addr_->setFixedWidth(100);
edt_bar1_addr_->setPlaceholderText("0x");
bar1_layout->addWidget(edt_bar1_addr_, 0, Qt::AlignLeft);
QLabel *bar1_val_label = new QLabel("值:");
bar1_val_label->setProperty("type", QVariant("nav_title"));
bar1_layout->addWidget(bar1_val_label);
edt_bar1_val_ = new QLineEdit;
edt_bar1_val_->setFixedWidth(100);
edt_bar1_val_->setPlaceholderText("0x");
bar1_layout->addWidget(edt_bar1_val_, 0, Qt::AlignLeft);
btn_read_bar1_ = new QPushButton("读BAR1");
btn_read_bar1_->setProperty("type", QVariant("gl_btn"));
btn_read_bar1_->setProperty("color", QVariant("white"));
btn_read_bar1_->setCursor(Qt::PointingHandCursor);
btn_read_bar1_->setFixedWidth(80);
bar1_layout->addWidget(btn_read_bar1_);
connect(btn_read_bar1_, &QPushButton::clicked, [=]()
{
if (!video_card_) return;
bool ok;
ULONG addr = edt_bar1_addr_->text().toULong(&ok, 0);
if (!ok) {
qWarning() << "BAR1 read: invalid address";
return;
}
ULONG val = 0;
if (video_card_->readRegBar1(addr, val)) {
edt_bar1_val_->setText(QString("0x%1").arg(val, 8, 16, QChar('0')));
qDebug() << "BAR1 read: addr=0x" << Qt::hex << addr << " val=0x" << val;
} });
btn_write_bar1_ = new QPushButton("写BAR1");
btn_write_bar1_->setProperty("type", QVariant("gl_btn"));
btn_write_bar1_->setProperty("color", QVariant("white"));
btn_write_bar1_->setCursor(Qt::PointingHandCursor);
btn_write_bar1_->setFixedWidth(80);
bar1_layout->addWidget(btn_write_bar1_);
connect(btn_write_bar1_, &QPushButton::clicked, [=]()
{
if (!video_card_) return;
bool ok1, ok2;
ULONG addr = edt_bar1_addr_->text().toULong(&ok1, 0);
ULONG val = edt_bar1_val_->text().toULong(&ok2, 0);
if (!ok1 || !ok2) {
qWarning() << "BAR1 write: invalid address or value";
return;
}
if (video_card_->writeRegBar1(addr, val)) {
qDebug() << "BAR1 write: addr=0x" << Qt::hex << addr << " val=0x" << val;
} });
main_layout->addLayout(bar1_layout);
QHBoxLayout *frame_read_layout = new QHBoxLayout;
frame_read_layout->setSpacing(4);
frame_read_layout->setContentsMargins(25, 4, 25, 4);
frame_read_layout->setAlignment(Qt::AlignLeft);
QLabel *frame_index_label = new QLabel("FrameIndex:");
frame_index_label->setProperty("type", QVariant("nav_title"));
frame_read_layout->addWidget(frame_index_label);
spn_frame_index_ = new QSpinBox;
spn_frame_index_->setRange(0, PCIE_S2MM_DMA_BUFFER_COUNT - 1);
spn_frame_index_->setFixedWidth(100);
frame_read_layout->addWidget(spn_frame_index_, 0, Qt::AlignLeft);
// btn_read_frame_ = new QPushButton("读取");
// btn_read_frame_->setProperty("type", QVariant("gl_btn"));
// btn_read_frame_->setProperty("color", QVariant("white"));
// btn_read_frame_->setCursor(Qt::PointingHandCursor);
// btn_read_frame_->setFixedWidth(80);
// frame_read_layout->addWidget(btn_read_frame_);
// connect(btn_read_frame_, &QPushButton::clicked, [=]()
// {
// if (!video_card_ || !video_card_->is_initialized_) {
// qWarning() << "请先打开板卡";
// QMessageBox::warning(this, "提示", "请先打开板卡!");
// return;
// }
// bool ok1, ok2;
// int w = edt_width_->text().toInt(&ok1, 10);
// int h = edt_height_->text().toInt(&ok2, 10);
// if (!ok1 || !ok2 || w <= 0 || h <= 0) {
// qWarning() << "无效的宽高参数";
// QMessageBox::warning(this, "提示", "无效的宽高参数!");
// return;
// }
// DWORD frame_size = w * h * 2; // YUV422
// std::unique_ptr<BYTE[]> frame_data(new BYTE[frame_size]);
// ULONG frame_index = (ULONG)spn_frame_index_->value();
// int ret = video_card_->getFrame(frame_data.get(), frame_size, frame_index);
// if (ret < 0) {
// qWarning() << "读取帧失败, frameIndex:" << frame_index << " ret:" << ret;
// QMessageBox::warning(this, "提示", QString("读取帧失败!frameIndex=%1, ret=%2").arg(frame_index).arg(ret));
// return;
// }
// QString filename = QString("frame_%1_%2x%3.bin")
// .arg(frame_index)
// .arg(w)
// .arg(h);
// QFile file(filename);
// if (!file.open(QIODevice::WriteOnly)) {
// qWarning() << "无法创建文件:" << filename;
// QMessageBox::warning(this, "提示", QString("无法创建文件:%1").arg(filename));
// return;
// }
// file.write((const char *)frame_data.get(), frame_size);
// file.close();
// qDebug() << "帧已保存:" << filename << "大小:" << frame_size << "字节";
// QMessageBox::information(this, "提示", QString("帧已保存到:%1\n大小:%2 字节").arg(filename).arg(frame_size)); });
main_layout->addLayout(frame_read_layout);
QWidget *btns_widget = new QWidget;
QHBoxLayout *btns_layout = new QHBoxLayout;
// btns_layout->setContentsMargins(0);
btns_layout->setSpacing(4);
btns_layout->setContentsMargins(0, 0, 0, 0);
video_card_ = std::make_shared<VideoCard>();
QButtonGroup *btn_group = new QButtonGroup;
btn_init_ = new QPushButton("打开板卡");
btn_init_->setProperty("type", QVariant("gl_btn"));
btn_init_->setProperty("color", QVariant("white"));
btn_init_->setCheckable(true);
btn_init_->setCursor(Qt::PointingHandCursor);
btn_init_->setFixedWidth(100);
btn_init_->setEnabled(true);
btns_layout->addWidget(btn_init_);
connect(btn_init_, &QPushButton::clicked, [=]()
{
if(video_card_) {
bool ok1;
bool ok2;
// int w = edt_width_->text().toInt(&ok1, 10);
// int h = edt_height_->text().toInt(&ok2, 10);
// if (!ok1 || !ok2) {
// qDebug() << "error width or height";
// return;
// }
if(0 != video_card_->init()) {
qDebug() << "video card init failed.";
return;
}
// edt_width_->setEnabled(false);
// edt_height_->setEnabled(false);
for (int i = 0; i < PCIE_S2MM_MAX_CHANNELS; i++)
btn_start_capture_[i]->setEnabled(true);
btn_init_->setEnabled(false);
btn_uninit_->setEnabled(true);
} });
for (int i = 0; i < PCIE_S2MM_MAX_CHANNELS; i++)
{
QString start_text = QString("开始采集 CH%1").arg(i);
btn_start_capture_[i] = new QPushButton(start_text);
btn_start_capture_[i]->setProperty("type", QVariant("gl_btn"));
btn_start_capture_[i]->setProperty("color", QVariant("white"));
btn_start_capture_[i]->setCheckable(true);
btn_start_capture_[i]->setCursor(Qt::PointingHandCursor);
btn_start_capture_[i]->setFixedWidth(120);
btn_start_capture_[i]->setEnabled(false);
btns_layout->addWidget(btn_start_capture_[i]);
connect(btn_start_capture_[i], &QPushButton::clicked, [=]()
{
if(video_card_) {
bool ok1, ok2;
// int w = edt_width_->text().toInt(&ok1, 10);
// int h = edt_height_->text().toInt(&ok2, 10);
// if (!ok1 || !ok2) {
// qDebug() << "error width or height";
// return;
// }
int ch = i; // capture channel index
ULONG width;
ULONG height;
ULONG fourcc;
video_card_->readReg(CH_VIDEO_BASE(i) + VIDEO_HSIZE_OFFSET, width);
video_card_->readReg(CH_VIDEO_BASE(i) + VIDEO_VSIZE_OFFSET, height);
video_card_->readReg(CH_VIDEO_BASE(i) + VIDEO_FORMAT_OFFSET, fourcc);
if (width == 0 || height == 0) {
qDebug() << "ch:" << ch << ", width:" << width << ", height:" << height;
return;
}
qDebug() << "ch:" << ch << ", width:" << width << ", height:" << height
<< ", fourcc: 0x" << Qt::hex << fourcc;
HWND previewHwnd = nullptr;
if (fourcc == FOURCC_V210) {
if (!preview_handle_[ch]) {
const gvfg_preview_status_t createStatus =
gvfg_preview_create(&preview_handle_[ch]);
if (createStatus != GVFG_PREVIEW_OK) {
qWarning() << "gvfg_preview_create failed:"
<< gvfg_preview_strerror(createStatus);
}
}
gl_widget_[ch]->setUpdatesEnabled(false);
previewHwnd = reinterpret_cast<HWND>(gl_widget_[ch]->winId());
if (preview_handle_[ch]) {
const gvfg_preview_status_t attachStatus =
gvfg_preview_attach_window(preview_handle_[ch], previewHwnd);
if (attachStatus != GVFG_PREVIEW_OK) {
qWarning() << "gvfg_preview_attach_window failed:"
<< gvfg_preview_strerror(attachStatus);
}
}
}
auto cb = [=](uchar *data, int video_width, int video_height) {
if (fourcc == FOURCC_V210 && preview_handle_[ch]) {
// The FPGA format register currently reports v210,
// but its DMA payload is Y210 (4 bytes per pixel).
const uint64_t frameSize =
(uint64_t)video_width * 4u * (uint64_t)video_height;
gvfg_preview_frame_t frame{};
frame.data = data;
frame.data_size = frameSize;
frame.width = video_width;
frame.height = video_height;
frame.pixel_format = GVFG_PREVIEW_PIXFMT_Y210;
frame.bit_depth = 10;
frame.row_bytes = video_width * 4;
const gvfg_preview_status_t renderStatus =
gvfg_preview_render_frame(preview_handle_[ch], &frame);
if (renderStatus != GVFG_PREVIEW_OK) {
qWarning() << "gvfg_preview_render_frame failed:"
<< gvfg_preview_strerror(renderStatus);
}
} else {
gl_widget_[ch]->renderYUV422((const uchar *)data, video_width, video_height);
}
};
if(0 != video_card_->startCapture(ch, width, height, fourcc, cb)) {
qDebug() << "video card startCapture failed for ch" << ch;
return;
}
btn_stop_capture_[ch]->setEnabled(true);
btn_start_capture_[ch]->setEnabled(false);
} });
QString stop_text = QString("停止采集 CH%1").arg(i);
btn_stop_capture_[i] = new QPushButton(stop_text);
btn_stop_capture_[i]->setProperty("type", QVariant("gl_btn"));
btn_stop_capture_[i]->setProperty("color", QVariant("white"));
btn_stop_capture_[i]->setCheckable(true);
btn_stop_capture_[i]->setCursor(Qt::PointingHandCursor);
btn_stop_capture_[i]->setFixedWidth(120);
btn_stop_capture_[i]->setEnabled(false);
btns_layout->addWidget(btn_stop_capture_[i]);
connect(btn_stop_capture_[i], &QPushButton::clicked, [=]()
{
if(video_card_) {
int ch = i; // capture channel index
video_card_->stopCapture(ch);
destroyPreview(preview_handle_[ch]);
gl_widget_[ch]->setUpdatesEnabled(true);
btn_start_capture_[ch]->setEnabled(true);
btn_stop_capture_[ch]->setEnabled(false);
} });
}
btn_uninit_ = new QPushButton("关闭板卡");
btn_uninit_->setProperty("type", QVariant("gl_btn"));
btn_uninit_->setProperty("color", QVariant("white"));
btn_uninit_->setCheckable(true);
btn_uninit_->setCursor(Qt::PointingHandCursor);
btn_uninit_->setFixedWidth(100);
btn_uninit_->setEnabled(false);
btns_layout->addWidget(btn_uninit_);
connect(btn_uninit_, &QPushButton::clicked, [=]()
{
if(video_card_) {
video_card_->uninit();
for (int i = 0; i < PCIE_S2MM_MAX_CHANNELS; i++) {
destroyPreview(preview_handle_[i]);
gl_widget_[i]->setUpdatesEnabled(true);
}
btn_init_->setEnabled(true);
btn_uninit_->setEnabled(false);
for (int i = 0; i < PCIE_S2MM_MAX_CHANNELS; i++) {
btn_start_capture_[i]->setEnabled(false);
btn_stop_capture_[i]->setEnabled(false);
}
// edt_width_->setEnabled(true);
// edt_height_->setEnabled(true);
} });
btns_widget->setLayout(btns_layout);
btns_widget->setMouseTracking(true);
main_layout->addSpacing(5);
main_layout->addWidget(btns_widget);
QWidget *bottom_widget = new QWidget;
bottom_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
bottom_widget->setFixedHeight(5);
bottom_widget->setProperty("type", QVariant("bottom"));
main_layout->addWidget(bottom_widget);
main_widget->setLayout(main_layout);
main_widget->setProperty("type", QVariant("mainwindow"));
setCentralWidget(main_widget);
centralWidget()->setMouseTracking(true);
setMouseTracking(true);
}
void MainWindow::mousePressEvent(QMouseEvent *event)
{
cal_cursor_pos_ = CalCursorPos(event->pos(), CalCursorCol(event->pos()));
if (event->button() == Qt::LeftButton /*&& Qt::WindowMaximized != windowState()*/)
{
if (cal_cursor_pos_ != CENTER)
{
is_dragging_ = false;
is_scaling = true;
}
else
{
is_dragging_ = true;
is_scaling = false;
}
}
move_start_pos_ = event->globalPos();
if (is_dragging_)
{
window_pos_ = this->frameGeometry().topLeft(); // 记录当前窗口位置
}
else if (is_scaling)
{
pre_geometry_rect_ = geometry();
}
}
void MainWindow::clickedCloseBtn()
{
if (screen_capture_thread_)
{
capture_ = false;
screen_capture_thread_->join();
screen_capture_thread_.reset();
screen_capture_thread_ = nullptr;
}
if (video_card_)
{
video_card_->uninit();
video_card_.reset();
video_card_ = nullptr;
}
for (int i = 0; i < PCIE_S2MM_MAX_CHANNELS; i++)
{
destroyPreview(preview_handle_[i]);
}
for (int i = 0; i < PCIE_S2MM_MAX_CHANNELS; i++)
{
if (gl_widget_[i])
{
delete gl_widget_[i];
gl_widget_[i] = nullptr;
}
}
QCoreApplication::instance()->quit();
}
void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
// 窗体不是最大的话就改变鼠标的形状
if (Qt::WindowMaximized != windowState())
{
setCursorShape(CalCursorPos(event->pos(), CalCursorCol(event->pos())));
}
// 获取当前的点,这个点是全局的
QPoint current_pos = QCursor::pos();
// 计算出移动的位置,当前点 - 鼠标左键按下的点
QPoint move_size = current_pos - move_start_pos_;
QRect temp_geometry = pre_geometry_rect_;
if (is_scaling)
{
switch (cal_cursor_pos_)
{
case TOPLEFT:
temp_geometry.setTopLeft(pre_geometry_rect_.topLeft() + move_size);
break;
case TOP:
temp_geometry.setTop(pre_geometry_rect_.top() + move_size.y());
break;
case TOPRIGHT:
temp_geometry.setTopRight(pre_geometry_rect_.topRight() + move_size);
break;
case LEFT:
temp_geometry.setLeft(pre_geometry_rect_.left() + move_size.x());
break;
case RIGHT:
temp_geometry.setRight(pre_geometry_rect_.right() + move_size.x());
break;
case BUTTOMLEFT:
temp_geometry.setBottomLeft(pre_geometry_rect_.bottomLeft() + move_size);
break;
case BUTTOM:
temp_geometry.setBottom(pre_geometry_rect_.bottom() + move_size.y());
break;
case BUTTOMRIGHT:
temp_geometry.setBottomRight(pre_geometry_rect_.bottomRight() + move_size);
break;
default:
break;
}
setGeometry(temp_geometry);
}
else if (is_dragging_)
{
QPoint relative_pos = event->globalPos() - move_start_pos_;
move(window_pos_ + relative_pos);
}
}
void MainWindow::mouseReleaseEvent(QMouseEvent *event)
{
is_scaling = false;
is_dragging_ = false;
QApplication::restoreOverrideCursor();
}
int MainWindow::CalCursorCol(QPoint pt)
{
return (pt.x() < FRAMESHAPE ? 1 : ((pt.x() > this->width() - FRAMESHAPE) ? 3 : 2));
}
int MainWindow::CalCursorPos(QPoint pt, int col_pos)
{
return ((pt.y() < FRAMESHAPE ? 10 : ((pt.y() > this->height() - FRAMESHAPE) ? 30 : 20)) + col_pos);
}
void MainWindow::setCursorShape(int cal_pos)
{
Qt::CursorShape cursor;
switch (cal_pos)
{
case TOPLEFT:
case BUTTOMRIGHT:
cursor = Qt::SizeFDiagCursor;
break;
case TOPRIGHT:
case BUTTOMLEFT:
cursor = Qt::SizeBDiagCursor;
break;
case TOP:
case BUTTOM:
cursor = Qt::SizeVerCursor;
break;
case LEFT:
case RIGHT:
cursor = Qt::SizeHorCursor;
break;
default:
cursor = Qt::ArrowCursor;
break;
}
setCursor(cursor);
}
void MainWindow::clickedMaxOrNormalBtn()
{
if (Qt::WindowMaximized != windowState())
{
btn_max_or_normal_->setChecked(true);
setWindowState(Qt::WindowMaximized);
update();
}
else
{
btn_max_or_normal_->setChecked(false);
setWindowState(Qt::WindowNoState);
update();
}
}
void MainWindow::clickedMinimizeBtn()
{
showMinimized();
}
void MainWindow::paintEvent(QPaintEvent *event)
{
// if(Qt::WindowMaximized == windowState())
// {
// qDebug() << "in here";
// setContentsMargins(0,0,0,0);
// QWidget::paintEvent(event);
// return;
// }
// setContentsMargins(20,20,20,20);
// QPainterPath path;
// QRect rect = this->rect();
// rect.adjust(22,22,-22,-22);
// path.addRoundedRect(rect, 10, 10);
// QPainter painter(this);
// painter.setRenderHint(QPainter::Antialiasing, true);
// QColor color(40, 40, 40, 50);
// for(int i = 0; i < 20; i++)
// {
// int alpha = 130 - sqrt(i)*1.1*38;
// if(alpha <= 0) {
// break;
// }
// color.setAlpha(alpha);
// QPainterPath path;
// rect.adjust(-1, -1, 1, 1);
// path.addRoundedRect(rect, 10, 10);
// painter.fillPath(path, color);
// }
QWidget::paintEvent(event);
}
-99
View File
@@ -1,99 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QSemaphore>
#include <QMainWindow>
#include <memory>
#include <QLineEdit>
#include <QSpinBox>
#include "video_card.h"
#include "my_widget/gl_widget.h"
#include "yuv_widget.h"
#include "task.h"
#include "gvfg_preview.h"
enum
{
TOPLEFT = 11,
TOP = 12,
TOPRIGHT = 13,
LEFT = 21,
CENTER = 22,
RIGHT = 23,
BUTTOMLEFT = 31,
BUTTOM = 32,
BUTTOMRIGHT = 33
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
void init();
public:
void mousePressEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void paintEvent(QPaintEvent *event);
private:
void clickedStartBtn();
void clickedStopBtn();
void clickedCloseBtn();
void clickedMaxOrNormalBtn();
void clickedMinimizeBtn();
private:
YUVWidget *gl_widget_[PCIE_S2MM_MAX_CHANNELS];
QPushButton *btn_start_capture_[PCIE_S2MM_MAX_CHANNELS];
QPushButton *btn_stop_capture_[PCIE_S2MM_MAX_CHANNELS];
QPushButton *btn_init_;
QPushButton *btn_uninit_;
// QLineEdit *edt_width_;
// QLineEdit *edt_height_;
QLineEdit *edt_bar0_addr_;
QLineEdit *edt_bar0_val_;
QPushButton *btn_read_bar0_;
QPushButton *btn_write_bar0_;
QLineEdit *edt_bar1_addr_;
QLineEdit *edt_bar1_val_;
QPushButton *btn_read_bar1_;
QPushButton *btn_write_bar1_;
QSpinBox *spn_frame_index_;
QPushButton *btn_read_frame_;
QPushButton *btn_max_or_normal_;
QPoint move_start_pos_;
QPoint window_pos_;
int CalCursorCol(QPoint pt); // 计算鼠标X的位置
int CalCursorPos(QPoint pt, int col_pos); // 计算鼠标的位置
void setCursorShape(int cal_pos); // 设置鼠标对应位置的形状
int cal_cursor_pos_;
bool is_dragging_; // 是否在拖动窗口,不是缩放
bool is_scaling; // 是否在缩放状态
bool prepare_scale_; // 是否准备缩放(鼠标在缩放区域)
QRect pre_geometry_rect_;
QPoint mouse_pos_;
std::shared_ptr<VideoCard> video_card_;
gvfg_preview_handle preview_handle_[PCIE_S2MM_MAX_CHANNELS] = {};
std::unique_ptr<char[]> screen_data_buffer_;
std::mutex screen_data_buffer_mtx_;
std::unique_ptr<std::thread> screen_capture_thread_ = nullptr;
bool capture_ = false;
};
#endif // MAINWINDOW_H
@@ -1,255 +0,0 @@
#include "gl_widget.h"
#include <QtOpenGL/QOpenGLShaderProgram>
#include <QtOpenGL/QOpenGLTexture>
#include <QMouseEvent>
#include <QMenu>
#include <math.h>
#include <QDebug>
#define VERTEXIN 0
#define TEXTUREIN 1
#define POSITION 2
#define SHOW_DRAW 0
#define SHOW_RGB 1
GLfloat GL_DETEDT_COLOR[4] = {0, 1, 0, 1};
GLfloat GL_DRAWING_COLOR[4] = {1, 0, 0, 1};
GLfloat GL_SELECTED_COLOR[4] = {1, 1, 1, 1};
GLfloat GL_MAX_COLOR[4] = {1, 1, 0, 1};
GLfloat GL_MIN_COLOR[4] = {1, 0, 1, 1};
GLfloat GL_MASK_COLOR[4] = {0.5, 0.5, 0.5, 1};
GLWidget::GLWidget(QWidget *parent) : QOpenGLWidget(parent)
{
init_ = false;
img_width_ = 0;
img_height_ = 0;
widget_width_ = 0;
widget_height_ = 0;
curr_video_frame_ = nullptr;
video_frame_free_queue_ = std::make_shared<std::queue<std::shared_ptr<T_VideoFrame>>>();
video_frame_busy_queue_ = std::make_shared<std::queue<std::shared_ptr<T_VideoFrame>>>();
default_video_frame_ = std::make_shared<T_VideoFrame>();
default_video_frame_->width = 1920;
default_video_frame_->height = 1080;
memset(default_video_frame_->yuv422, 0, default_video_frame_->width*default_video_frame_->height*2);
for(int i = 0; i < 40; i++) {
std::shared_ptr<T_VideoFrame> video_frame = std::make_shared<T_VideoFrame>();
video_frame_free_queue_->push(video_frame);
}
}
GLWidget::~GLWidget()
{
exit_display_thread_ = true;
video_busy_queue_sem_->release();
if(display_thread_ && display_thread_->joinable()) {
display_thread_->join();
}
}
void GLWidget::showImg(const uchar *yuv422, uint width, uint height)
{
std::shared_ptr<T_VideoFrame> video_frame;
std::lock_guard<std::mutex> lck(video_queue_mutex_);
if(video_frame_free_queue_->empty()) {
video_frame = std::make_shared<T_VideoFrame>();
} else {
video_frame = video_frame_free_queue_->front();
}
memcpy(video_frame->yuv422, yuv422, width * height * 2);
video_frame->width = width;
video_frame->height = height;
video_frame_busy_queue_->push(video_frame);
video_busy_queue_sem_->release(1);
memcpy(yuv422_data_, yuv422, width * height * 2);
img_width_ = width;
img_height_ = height;
update();
// qDebug() << "show img";
// static int count = 0;
// if (count == 0) {
// FILE *fp = fopen("img.yuv", "wb");
// fwrite((char*)rgb, 1, width*height*2, fp);
// fclose(fp);
// }
// count++;
}
void GLWidget::internalShowImg(std::shared_ptr<T_VideoFrame> video_frame)
{
curr_video_frame_ = video_frame;
// memcpy(rgb_data_, video_frame->rgb, video_frame->width * video_frame->height * 3);
// img_width_ = video_frame->width;
// img_height_ = video_frame->height;
update();
}
void GLWidget::initializeGL()
{
widget_width_ = this->geometry().width();
widget_height_ = this->geometry().height();
initializeOpenGLFunctions();
glEnable(GL_DEPTH_TEST);
static const GLfloat vertices[]{
-1.0f,
-1.0f,
-1.0f,
+1.0f,
+1.0f,
+1.0f,
+1.0f,
-1.0f,
0.0f,
1.0f,
0.0f,
0.0f,
1.0f,
0.0f,
1.0f,
1.0f,
0.0f,
0.5f,
-0.8f,
-0.5f,
0.5f,
-0.5f,
1.0f,
1.0f,
};
QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this);
const char *vsrc =
"attribute vec4 vertexIn; \
attribute vec2 textureIn; \
attribute vec4 vPosition; \
varying vec2 textureOut; \
void main(void) \
{ \ \
gl_Position = vPosition; \ \
textureOut = textureIn; \
}";
if(!vshader->compileSourceCode(vsrc)) {
return;
}
QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this);
const char *fsrc =
"\
varying vec2 textureOut;\
uniform sampler2D texYUYV;\
void main()\
{\
vec2 yuyv = texture2D(texYUYV, textureOut).rg;\
float y = yuyv.r;\
float u = yuyv.g - 0.5;\
float v = yuyv.g - 0.5;\
float r = y + 1.402 * v;\
float g = y - 0.344 * u - 0.714 * v;\
float b = y + 1.772 * u;\
gl_FragColor = vec4(r, g, b, 1.0);\
}";
if(!fshader->compileSourceCode(fsrc)) {
qDebug() << "Fragment shader compilation error:" << fshader->log();
return;
}
program_ = new QOpenGLShaderProgram(this);
if(!program_->addShader(vshader)) {
return;
}
if(!program_->addShader(fshader)) {
return;
}
if(!program_->link()) {
return;
}
if(!program_->bind()) {
return;
}
program_->enableAttributeArray(VERTEXIN);
program_->enableAttributeArray(TEXTUREIN);
program_->enableAttributeArray(POSITION);
program_->setAttributeArray("vertexIn", GL_FLOAT, vertices, 2, 2 * sizeof(GLfloat));
program_->enableAttributeArray("textureIn");
program_->setAttributeArray("textureIn", GL_FLOAT, vertices + 8, 2, 2 * sizeof(GLfloat));
program_->setAttributeArray("vPosition", GL_FLOAT, vertices + 16, 2, 2 * sizeof(GLfloat));
texture_uniform_yuv_ = program_->uniformLocation("texYUYV");
texture_yuv_ = new QOpenGLTexture(QOpenGLTexture::Target2D);
if(!texture_yuv_->create()) {
return;
}
id_yuv_ = texture_yuv_->textureId();
glClearColor(0.0, 0.0, 1.0, 0.0);
video_busy_queue_sem_ = std::make_shared<QSemaphore>(0);
exit_display_thread_ = false;
display_thread_ = std::make_shared<std::thread>([&](){
while(1) {
if(!video_busy_queue_sem_->tryAcquire(1, 10)) {
continue;
}
if(exit_display_thread_) {
break;
}
std::lock_guard<std::mutex> lck(video_queue_mutex_);
curr_video_frame_ = video_frame_busy_queue_->front();
video_frame_busy_queue_->pop();
update();
//internalShowImg(video_frame);
}
});
}
void GLWidget::drawYUV422()
{
if(!curr_video_frame_) {
// glClearColor(0.0f,0.0f,0.0f,0.0f);
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glActiveTexture(GL_TEXTURE0);
// glBindTexture(GL_TEXTURE_2D, id_yuv_);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RG, default_video_frame_->width, default_video_frame_->height, 0, GL_RG, GL_UNSIGNED_BYTE, default_video_frame_->yuv422);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// glUniform1i(texture_uniform_yuv_, 0);
// glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
return;
}
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, id_yuv_);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RG, curr_video_frame_->width, curr_video_frame_->height, 0, GL_RG, GL_UNSIGNED_BYTE, curr_video_frame_->yuv422);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glUniform1i(texture_uniform_yuv_, 0);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
qDebug() << "draw triangle";
//显示完后,归还到free队列
std::lock_guard<std::mutex> lck(video_queue_mutex_);
video_frame_free_queue_->push(curr_video_frame_);
}
void GLWidget::paintGL()
{
drawYUV422();
}
@@ -1,78 +0,0 @@
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QtOpenGLWidgets/QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QtOpenGL/QOpenGLBuffer>
#include <QTimer>
#include <QFile>
#include <QRect>
#include <QVector>
#include <QPushButton>
#include <QContextMenuEvent>
#include <iostream>
#include <thread>
#include <memory>
#include <fstream>
#include <queue>
#include <mutex>
#include <QSemaphore>
QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
QT_FORWARD_DECLARE_CLASS(QOpenGLTexture)
#define MAX_IMG_WIDTH 1920
#define MAX_IMG_HEIGHT 1280
typedef struct T_VideoFrame {
size_t width;
size_t height;
char *yuv422;
size_t buffer_len;
public:
T_VideoFrame() {
yuv422 = new char[MAX_IMG_WIDTH*MAX_IMG_HEIGHT*2];
width = MAX_IMG_WIDTH;
height = MAX_IMG_HEIGHT;
}
};
class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
GLWidget(QWidget *parent = nullptr);
virtual ~GLWidget();
public:
void showImg(const uchar *rgb, uint width, uint height);
protected:
void initializeGL() Q_DECL_OVERRIDE;
void paintGL() Q_DECL_OVERRIDE;
void drawYUV422();
void internalShowImg(std::shared_ptr<T_VideoFrame> video_frame);
private:
std::shared_ptr<std::thread> display_thread_;
bool exit_display_thread_;
std::mutex video_queue_mutex_;
std::shared_ptr<T_VideoFrame> curr_video_frame_;
std::shared_ptr<T_VideoFrame> default_video_frame_;
std::shared_ptr<std::queue<std::shared_ptr<T_VideoFrame>>> video_frame_free_queue_;
std::shared_ptr<std::queue<std::shared_ptr<T_VideoFrame>>> video_frame_busy_queue_;
std::shared_ptr<QSemaphore> video_busy_queue_sem_;
uchar yuv422_data_[MAX_IMG_WIDTH * MAX_IMG_HEIGHT * 3];
bool init_;
int img_width_;
int img_height_;
int widget_width_;
int widget_height_;
QOpenGLShaderProgram *program_;
QOpenGLTexture *texture_yuv_;
GLuint texture_uniform_yuv_;
GLuint id_yuv_;
std::ofstream log_file_;
};
#endif
@@ -1,20 +0,0 @@
#include "nav_widget.h"
#include <QStyleOption>
#include <QPainter>
NavWidget::NavWidget(QWidget *parent) : QWidget(parent)
{
setProperty("type", QVariant("nav_bar"));
}
void NavWidget::mouseDoubleClickEvent(QMouseEvent *event) {
emit doubleClicked();
}
void NavWidget::paintEvent(QPaintEvent *m)
{
QStyleOption opt;
opt.initFrom(this);
QPainter painter(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
}
@@ -1,18 +0,0 @@
#ifndef NAV_WIDGET_H
#define NAV_WIDGET_H
#include <QWidget>
class NavWidget : public QWidget
{
Q_OBJECT
public:
explicit NavWidget(QWidget *parent = nullptr);
void mouseDoubleClickEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *m) override;
signals:
void doubleClicked();
public slots:
};
#endif // NAV_WIDGET_H
@@ -1,25 +0,0 @@
#include "scalectrl_widget.h"
ScaleCtrlWidget::ScaleCtrlWidget(E_SCALE_POS scale_pos, int width, int height, QWidget *parent):QWidget(parent)
{
width_ = width;
height_ = height;
scale_pos_ = scale_pos;
scale_cb_ = nullptr;
setMouseTracking(true);
}
void ScaleCtrlWidget::mousePressEvent(QMouseEvent *event)
{
}
void ScaleCtrlWidget::mouseMoveEvent(QMouseEvent *event)
{
}
void ScaleCtrlWidget::mouseReleaseEvent(QMouseEvent *event)
{
}
-435
View File
@@ -1,435 +0,0 @@
#ifndef _REG_H_
#define _REG_H_
#ifdef _KERNEL_MODE
#include <ntddk.h>
#endif
/* ========================================================================
* Config BRAM Register Map (bramctrl_to_config)
*
* Address decoding (byte address):
* byte_addr = module_base + type_base + offset * 4
*
* Module base addresses:
* Module 0 (Interrupt) = 0x000 (type bit ignored)
* Module 1 (CH0) Video = 0x200 (type=0)
* Module 1 (CH0) Audio = 0x280 (type=1)
* Module 2 (CH1) Video = 0x400 (type=0)
* Module 2 (CH1) Audio = 0x480 (type=1)
*
* Descriptor 100-bit format: [99:96]=ctrl, [95:64]=bytes,
* [63:32]=addr_hi, [31:0]=addr_lo
* ======================================================================== */
/* ---- Interrupt bit helper ---- */
#define BIT_N(i) (1 << (i))
/*
* Interrupt pending status bit layout (irq_pending_status [7:0]):
* Each channel occupies 4 bits:
* bit[0] = video DMA controller interrupt (read dma_irq_status for details)
* bit[1] = video event interrupt
* bit[2] = audio DMA controller interrupt (read dma_irq_status for details)
* bit[3] = audio event interrupt
* CH0 = bits [3:0], CH1 = bits [7:4]
*
* dma_irq_status register [1:0] sub-bit definitions:
* bit[0] = DMA transfer done interrupt
* bit[1] = DMA soft reset complete interrupt
*/
/* Sub-interrupt type offsets within a channel's 4-bit field */
#define IRQ_SUB_VIDEO_DMA_CTRL 0
#define IRQ_SUB_VIDEO_EVENT 1
#define IRQ_SUB_AUDIO_DMA_CTRL 2
#define IRQ_SUB_AUDIO_EVENT 3
#define IRQ_SUBS_PER_CH 4
/* Bit position / mask for a specific sub-interrupt of a given channel */
#define IRQ_BIT(ch, sub) ((ch) * IRQ_SUBS_PER_CH + (sub))
#define IRQ_BIT_MASK(ch, sub) BIT_N(IRQ_BIT(ch, sub))
#define IRQ_CH_MASK(ch) (0xFUL << ((ch) * IRQ_SUBS_PER_CH))
/* Decompose a global bit position into channel number and sub-interrupt type */
#define IRQ_BIT_TO_CH(bit) ((bit) / IRQ_SUBS_PER_CH)
#define IRQ_BIT_TO_SUB(bit) ((bit) % IRQ_SUBS_PER_CH)
/* Concrete CH0 masks: bit[0]=0x01, bit[1]=0x02, bit[2]=0x04, bit[3]=0x08 */
#define IRQ_CH0_VIDEO_DMA_CTRL_MASK IRQ_BIT_MASK(0, IRQ_SUB_VIDEO_DMA_CTRL)
#define IRQ_CH0_VIDEO_EVENT_MASK IRQ_BIT_MASK(0, IRQ_SUB_VIDEO_EVENT)
#define IRQ_CH0_AUDIO_DMA_CTRL_MASK IRQ_BIT_MASK(0, IRQ_SUB_AUDIO_DMA_CTRL)
#define IRQ_CH0_AUDIO_EVENT_MASK IRQ_BIT_MASK(0, IRQ_SUB_AUDIO_EVENT)
#define IRQ_CH0_ALL_MASK IRQ_CH_MASK(0)
/* Concrete CH1 masks: bit[4]=0x10, bit[5]=0x20, bit[6]=0x40, bit[7]=0x80 */
#define IRQ_CH1_VIDEO_DMA_CTRL_MASK IRQ_BIT_MASK(1, IRQ_SUB_VIDEO_DMA_CTRL)
#define IRQ_CH1_VIDEO_EVENT_MASK IRQ_BIT_MASK(1, IRQ_SUB_VIDEO_EVENT)
#define IRQ_CH1_AUDIO_DMA_CTRL_MASK IRQ_BIT_MASK(1, IRQ_SUB_AUDIO_DMA_CTRL)
#define IRQ_CH1_AUDIO_EVENT_MASK IRQ_BIT_MASK(1, IRQ_SUB_AUDIO_EVENT)
#define IRQ_CH1_ALL_MASK IRQ_CH_MASK(1)
#define IRQ_ALL_MASK (IRQ_CH0_ALL_MASK | IRQ_CH1_ALL_MASK)
/* ---- Config BRAM Base Addresses (byte offsets) ---- */
#define INTERRUPT_BASE 0x00000000
#define CH0_VIDEO_BASE 0x00000200
#define CH0_AUDIO_BASE 0x00000280
#define CH1_VIDEO_BASE 0x00000400
#define CH1_AUDIO_BASE 0x00000480
/* Channel-indexed base: CH(n) video = 0x200 + n*0x200, audio = 0x280 + n*0x200 */
#define CH_VIDEO_BASE(ch) (CH0_VIDEO_BASE + (ch) * 0x200)
#define CH_AUDIO_BASE(ch) (CH0_AUDIO_BASE + (ch) * 0x200)
/* ========================================================================
* Interrupt Registers (module 0, base 0x000)
*
* Note: 0x000/0x004/0x008 have different R/W semantics:
* Read = RO status
* Write = WO control
* ======================================================================== */
#define IRQ_PENDING_STATUS_OFFSET 0x000 /* RO: Interrupt pending status (read) */
#define IRQ_CLEAR_OFFSET 0x000 /* WO: Write-1-to-clear pending (write) */
#define IRQ_MASKED_STATUS_OFFSET 0x004 /* RO: Interrupt masked status (read) */
#define IRQ_MASK_W1S_OFFSET 0x004 /* WO: Write-1-to-set mask (write) */
#define IRQ_MASK_STATUS_OFFSET 0x008 /* RO: Interrupt mask register status (read) */
#define IRQ_MASK_W1C_OFFSET 0x008 /* WO: Write-1-to-clear mask (write) */
#define MAX_CHANNEL_COUNT_OFFSET 0x00C /* RO: Max channel count [2:0], fixed=2 */
/* ========================================================================
* Video Register Offsets (relative to CHx_VIDEO_BASE)
* ======================================================================== */
#define VIDEO_EN_OFFSET 0x000 /* R/W: Video enable, bit[0] */
#define VIDEO_DMA_ADDR_LO_OFFSET 0x004 /* R/W: DMA address [31:0] */
#define VIDEO_DMA_ADDR_HI_OFFSET 0x008 /* R/W: DMA address [63:32] */
#define VIDEO_DMA_BYTES_OFFSET 0x00C /* R/W: DMA transfer byte count */
#define VIDEO_DMA_CTRL_OFFSET 0x010 /* R/W: DMA control [3:0] */
#define VIDEO_DMA_WR_PTR_OFFSET 0x014 /* R/W: Descriptor write pointer [5:0] */
#define VIDEO_DMA_DESC_WR_OFFSET 0x018 /* WO: Descriptor write pulse (self-clearing) */
#define VIDEO_DESC_MAX_CNT_OFFSET 0x01C /* R/W: Max descriptor count [5:0] */
#define VIDEO_DMA_EN_OFFSET 0x020 /* R/W: DMA engine enable, bit[0] */
#define VIDEO_DMA_DONE_PTR_OFFSET 0x024 /* RO: DMA done pointer [5:0] */
#define VIDEO_LOST_FRAME_CNT_OFFSET 0x028 /* R/W: Lost frame count (write=clear, read=current) [31:0] */
#define VIDEO_HSIZE_OFFSET 0x02C /* RO: Horizontal resolution [31:0] */
#define VIDEO_VSIZE_OFFSET 0x030 /* RO: Vertical resolution [31:0] */
#define VIDEO_FORMAT_OFFSET 0x034 /* RO: Video format (FOURCC) [31:0] */
#define VIDEO_IRQ_STATUS_OFFSET 0x038 /* WO/RO: Video IRQ status [7:0] (write=clear, read=external) */
#define VIDEO_DMA_IRQ_STATUS_OFFSET 0x03C /* WO/RO: Video DMA IRQ status [1:0] (read=external, write=clear); bit[0]=DMA done, bit[1]=reset done */
#define VIDEO_DMA_SOFT_RESET_OFFSET 0x040 /* WO: DMA soft reset [31:0] (write value determines whether to send IRQ after reset) */
/* ========================================================================
* Audio Register Offsets (relative to CHx_AUDIO_BASE)
* ======================================================================== */
#define AUDIO_EN_OFFSET 0x000 /* R/W: Audio enable, bit[0] */
#define AUDIO_DMA_ADDR_LO_OFFSET 0x004 /* R/W: DMA address [31:0] */
#define AUDIO_DMA_ADDR_HI_OFFSET 0x008 /* R/W: DMA address [63:32] */
#define AUDIO_DMA_BYTES_OFFSET 0x00C /* R/W: DMA transfer byte count */
#define AUDIO_DMA_CTRL_OFFSET 0x010 /* R/W: DMA control [3:0] */
#define AUDIO_DMA_WR_PTR_OFFSET 0x014 /* R/W: Descriptor write pointer [5:0] */
#define AUDIO_DMA_DESC_WR_OFFSET 0x018 /* WO: Descriptor write pulse (self-clearing) */
#define AUDIO_DESC_MAX_CNT_OFFSET 0x01C /* R/W: Max descriptor count [5:0] */
#define AUDIO_DMA_EN_OFFSET 0x020 /* R/W: DMA engine enable, bit[0] */
#define AUDIO_DMA_DONE_PTR_OFFSET 0x024 /* RO: DMA done pointer [5:0] */
#define AUDIO_LOST_FRAME_CNT_OFFSET 0x028 /* R/W: Lost frame count (write=clear, read=current) [31:0] */
#define AUDIO_HAS_AUDIO_OFFSET 0x02C /* RO: Has audio flag, bit[0] */
#define AUDIO_THRES_OFFSET 0x030 /* R/W: Audio interrupt threshold [31:0] */
#define AUDIO_SAMPLE_OFFSET 0x034 /* RO: Audio sample rate [31:0] */
#define AUDIO_DEPTH_OFFSET 0x038 /* RO: Audio bit depth [7:0] */
#define AUDIO_NUM_OFFSET 0x03C /* RO: Audio channel count [3:0] */
#define AUDIO_IRQ_STATUS_OFFSET 0x040 /* WO/RO: Audio IRQ status [7:0] (write=clear, read=external) */
#define AUDIO_DMA_IRQ_STATUS_OFFSET 0x044 /* WO/RO: Audio DMA IRQ status [1:0] (read=external, write=clear); bit[0]=DMA done, bit[1]=reset done */
#define AUDIO_DMA_SOFT_RESET_OFFSET 0x048 /* WO: DMA soft reset [31:0] (write value determines whether to send IRQ after reset) */
/* ========================================================================
* Bit-field Definitions
* ======================================================================== */
#define EN_BIT 0
#define DMA_CTRL_WIDTH 4
#define DMA_CTRL_MASK 0x0FUL
#define DESC_PTR_WIDTH 6
#define DESC_PTR_MASK 0x3FUL
#define MAX_CHANNEL_COUNT_MASK 0x07UL
#define AUDIO_NUM_MASK 0x0FUL
#define AUDIO_DEPTH_MASK 0xFFUL
#define IRQ_STATUS_MASK 0xFFUL
#define DMA_IRQ_STATUS_MASK 0x03UL
/* DMA IRQ status sub-bit definitions (within dma_irq_status [1:0]) */
#define DMA_IRQ_SUB_DONE 0 /* bit[0]: DMA transfer done */
#define DMA_IRQ_SUB_RESET_DONE 1 /* bit[1]: DMA soft reset complete */
#define DMA_IRQ_DONE_MASK BIT_N(DMA_IRQ_SUB_DONE) /* 0x01 */
#define DMA_IRQ_RESET_DONE_MASK BIT_N(DMA_IRQ_SUB_RESET_DONE) /* 0x02 */
#define DMA_IRQ_ALL_MASK (DMA_IRQ_DONE_MASK | DMA_IRQ_RESET_DONE_MASK) /* 0x03 */
/* ========================================================================
* Helper Macros - Config BRAM Register Access
* ======================================================================== */
#ifdef _KERNEL_MODE
#define REG_READ32(Base, Offset) \
READ_REGISTER_ULONG((PULONG)((PUCHAR)(Base) + (Offset)))
#define REG_WRITE32(Base, Offset, Value) \
WRITE_REGISTER_ULONG((PULONG)((PUCHAR)(Base) + (Offset)), (Value))
/* ---- Interrupt Helpers ---- */
#define READ_INT_STATUS(Base) \
REG_READ32(Base, IRQ_PENDING_STATUS_OFFSET)
#define WRITE_INT_CLEAR(Base, Val) \
REG_WRITE32(Base, IRQ_CLEAR_OFFSET, (Val))
#define WRITE_INT_MASK_W1S(Base, Val) \
REG_WRITE32(Base, IRQ_MASK_W1S_OFFSET, (Val))
#define WRITE_INT_MASK_W1C(Base, Val) \
REG_WRITE32(Base, IRQ_MASK_W1C_OFFSET, (Val))
#define READ_INT_MASK(Base) \
REG_READ32(Base, IRQ_MASK_STATUS_OFFSET)
#define READ_MAX_CHANNEL_COUNT(Base) \
(REG_READ32(Base, MAX_CHANNEL_COUNT_OFFSET) & MAX_CHANNEL_COUNT_MASK)
/* ---- CH0 Video Helpers ---- */
#define CH0_VIDEO_READ_EN(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_EN_OFFSET)
#define CH0_VIDEO_WRITE_EN(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_EN_OFFSET, (Val))
#define CH0_VIDEO_READ_DMA_ADDR_LO(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_DMA_ADDR_LO_OFFSET)
#define CH0_VIDEO_WRITE_DMA_ADDR_LO(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_DMA_ADDR_LO_OFFSET, (Val))
#define CH0_VIDEO_READ_DMA_ADDR_HI(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_DMA_ADDR_HI_OFFSET)
#define CH0_VIDEO_WRITE_DMA_ADDR_HI(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_DMA_ADDR_HI_OFFSET, (Val))
#define CH0_VIDEO_READ_DMA_BYTES(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_DMA_BYTES_OFFSET)
#define CH0_VIDEO_WRITE_DMA_BYTES(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_DMA_BYTES_OFFSET, (Val))
#define CH0_VIDEO_READ_DMA_CTRL(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_DMA_CTRL_OFFSET)
#define CH0_VIDEO_WRITE_DMA_CTRL(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_DMA_CTRL_OFFSET, (Val))
#define CH0_VIDEO_READ_DMA_WR_PTR(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_DMA_WR_PTR_OFFSET)
#define CH0_VIDEO_WRITE_DMA_WR_PTR(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_DMA_WR_PTR_OFFSET, (Val))
#define CH0_VIDEO_WRITE_DESC_WR(Base) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_DMA_DESC_WR_OFFSET, 1)
#define CH0_VIDEO_READ_DESC_MAX_CNT(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_DESC_MAX_CNT_OFFSET)
#define CH0_VIDEO_WRITE_DESC_MAX_CNT(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_DESC_MAX_CNT_OFFSET, (Val))
#define CH0_VIDEO_READ_DMA_EN(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_DMA_EN_OFFSET)
#define CH0_VIDEO_WRITE_DMA_EN(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_DMA_EN_OFFSET, (Val))
#define CH0_VIDEO_READ_DMA_DONE_PTR(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_DMA_DONE_PTR_OFFSET)
#define CH0_VIDEO_READ_LOST_FRAME_CNT(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_LOST_FRAME_CNT_OFFSET)
#define CH0_VIDEO_WRITE_LOST_FRAME_CLR(Base) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_LOST_FRAME_CNT_OFFSET, 0)
#define CH0_VIDEO_READ_HSIZE(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_HSIZE_OFFSET)
#define CH0_VIDEO_READ_VSIZE(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_VSIZE_OFFSET)
#define CH0_VIDEO_READ_FORMAT(Base) \
REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_FORMAT_OFFSET)
#define CH0_VIDEO_READ_IRQ_STATUS(Base) \
(REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_IRQ_STATUS_OFFSET) & IRQ_STATUS_MASK)
#define CH0_VIDEO_WRITE_IRQ_STATUS_CLEAR(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_IRQ_STATUS_OFFSET, (Val) & IRQ_STATUS_MASK)
#define CH0_VIDEO_READ_DMA_IRQ_STATUS(Base) \
(REG_READ32(Base, CH0_VIDEO_BASE + VIDEO_DMA_IRQ_STATUS_OFFSET) & DMA_IRQ_STATUS_MASK)
#define CH0_VIDEO_WRITE_DMA_IRQ_STATUS_CLEAR(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_DMA_IRQ_STATUS_OFFSET, (Val) & DMA_IRQ_STATUS_MASK)
#define CH0_VIDEO_WRITE_DMA_SOFT_RESET(Base, Val) \
REG_WRITE32(Base, CH0_VIDEO_BASE + VIDEO_DMA_SOFT_RESET_OFFSET, (Val))
/* ---- CH0 Audio Helpers ---- */
#define CH0_AUDIO_READ_EN(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_EN_OFFSET)
#define CH0_AUDIO_WRITE_EN(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_EN_OFFSET, (Val))
#define CH0_AUDIO_READ_DMA_ADDR_LO(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_DMA_ADDR_LO_OFFSET)
#define CH0_AUDIO_WRITE_DMA_ADDR_LO(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_DMA_ADDR_LO_OFFSET, (Val))
#define CH0_AUDIO_READ_DMA_ADDR_HI(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_DMA_ADDR_HI_OFFSET)
#define CH0_AUDIO_WRITE_DMA_ADDR_HI(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_DMA_ADDR_HI_OFFSET, (Val))
#define CH0_AUDIO_READ_DMA_BYTES(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_DMA_BYTES_OFFSET)
#define CH0_AUDIO_WRITE_DMA_BYTES(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_DMA_BYTES_OFFSET, (Val))
#define CH0_AUDIO_READ_DMA_CTRL(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_DMA_CTRL_OFFSET)
#define CH0_AUDIO_WRITE_DMA_CTRL(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_DMA_CTRL_OFFSET, (Val))
#define CH0_AUDIO_READ_DMA_WR_PTR(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_DMA_WR_PTR_OFFSET)
#define CH0_AUDIO_WRITE_DMA_WR_PTR(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_DMA_WR_PTR_OFFSET, (Val))
#define CH0_AUDIO_WRITE_DESC_WR(Base) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_DMA_DESC_WR_OFFSET, 1)
#define CH0_AUDIO_READ_DESC_MAX_CNT(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_DESC_MAX_CNT_OFFSET)
#define CH0_AUDIO_WRITE_DESC_MAX_CNT(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_DESC_MAX_CNT_OFFSET, (Val))
#define CH0_AUDIO_READ_DMA_EN(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_DMA_EN_OFFSET)
#define CH0_AUDIO_WRITE_DMA_EN(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_DMA_EN_OFFSET, (Val))
#define CH0_AUDIO_READ_DMA_DONE_PTR(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_DMA_DONE_PTR_OFFSET)
#define CH0_AUDIO_READ_LOST_FRAME_CNT(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_LOST_FRAME_CNT_OFFSET)
#define CH0_AUDIO_WRITE_LOST_FRAME_CLR(Base) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_LOST_FRAME_CNT_OFFSET, 0)
#define CH0_AUDIO_READ_HAS_AUDIO(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_HAS_AUDIO_OFFSET)
#define CH0_AUDIO_READ_THRES(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_THRES_OFFSET)
#define CH0_AUDIO_WRITE_THRES(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_THRES_OFFSET, (Val))
#define CH0_AUDIO_READ_SAMPLE(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_SAMPLE_OFFSET)
#define CH0_AUDIO_READ_DEPTH(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_DEPTH_OFFSET)
#define CH0_AUDIO_READ_NUM(Base) \
REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_NUM_OFFSET)
#define CH0_AUDIO_READ_IRQ_STATUS(Base) \
(REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_IRQ_STATUS_OFFSET) & IRQ_STATUS_MASK)
#define CH0_AUDIO_WRITE_IRQ_STATUS_CLEAR(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_IRQ_STATUS_OFFSET, (Val) & IRQ_STATUS_MASK)
#define CH0_AUDIO_READ_DMA_IRQ_STATUS(Base) \
(REG_READ32(Base, CH0_AUDIO_BASE + AUDIO_DMA_IRQ_STATUS_OFFSET) & DMA_IRQ_STATUS_MASK)
#define CH0_AUDIO_WRITE_DMA_IRQ_STATUS_CLEAR(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_DMA_IRQ_STATUS_OFFSET, (Val) & DMA_IRQ_STATUS_MASK)
#define CH0_AUDIO_WRITE_DMA_SOFT_RESET(Base, Val) \
REG_WRITE32(Base, CH0_AUDIO_BASE + AUDIO_DMA_SOFT_RESET_OFFSET, (Val))
/* ---- CH1 Video Helpers ---- */
#define CH1_VIDEO_READ_EN(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_EN_OFFSET)
#define CH1_VIDEO_WRITE_EN(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_EN_OFFSET, (Val))
#define CH1_VIDEO_READ_DMA_ADDR_LO(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_DMA_ADDR_LO_OFFSET)
#define CH1_VIDEO_WRITE_DMA_ADDR_LO(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_DMA_ADDR_LO_OFFSET, (Val))
#define CH1_VIDEO_READ_DMA_ADDR_HI(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_DMA_ADDR_HI_OFFSET)
#define CH1_VIDEO_WRITE_DMA_ADDR_HI(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_DMA_ADDR_HI_OFFSET, (Val))
#define CH1_VIDEO_READ_DMA_BYTES(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_DMA_BYTES_OFFSET)
#define CH1_VIDEO_WRITE_DMA_BYTES(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_DMA_BYTES_OFFSET, (Val))
#define CH1_VIDEO_READ_DMA_CTRL(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_DMA_CTRL_OFFSET)
#define CH1_VIDEO_WRITE_DMA_CTRL(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_DMA_CTRL_OFFSET, (Val))
#define CH1_VIDEO_READ_DMA_WR_PTR(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_DMA_WR_PTR_OFFSET)
#define CH1_VIDEO_WRITE_DMA_WR_PTR(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_DMA_WR_PTR_OFFSET, (Val))
#define CH1_VIDEO_WRITE_DESC_WR(Base) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_DMA_DESC_WR_OFFSET, 1)
#define CH1_VIDEO_READ_DESC_MAX_CNT(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_DESC_MAX_CNT_OFFSET)
#define CH1_VIDEO_WRITE_DESC_MAX_CNT(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_DESC_MAX_CNT_OFFSET, (Val))
#define CH1_VIDEO_READ_DMA_EN(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_DMA_EN_OFFSET)
#define CH1_VIDEO_WRITE_DMA_EN(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_DMA_EN_OFFSET, (Val))
#define CH1_VIDEO_READ_DMA_DONE_PTR(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_DMA_DONE_PTR_OFFSET)
#define CH1_VIDEO_READ_LOST_FRAME_CNT(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_LOST_FRAME_CNT_OFFSET)
#define CH1_VIDEO_WRITE_LOST_FRAME_CLR(Base) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_LOST_FRAME_CNT_OFFSET, 0)
#define CH1_VIDEO_READ_HSIZE(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_HSIZE_OFFSET)
#define CH1_VIDEO_READ_VSIZE(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_VSIZE_OFFSET)
#define CH1_VIDEO_READ_FORMAT(Base) \
REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_FORMAT_OFFSET)
#define CH1_VIDEO_READ_IRQ_STATUS(Base) \
(REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_IRQ_STATUS_OFFSET) & IRQ_STATUS_MASK)
#define CH1_VIDEO_WRITE_IRQ_STATUS_CLEAR(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_IRQ_STATUS_OFFSET, (Val) & IRQ_STATUS_MASK)
#define CH1_VIDEO_READ_DMA_IRQ_STATUS(Base) \
(REG_READ32(Base, CH1_VIDEO_BASE + VIDEO_DMA_IRQ_STATUS_OFFSET) & DMA_IRQ_STATUS_MASK)
#define CH1_VIDEO_WRITE_DMA_IRQ_STATUS_CLEAR(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_DMA_IRQ_STATUS_OFFSET, (Val) & DMA_IRQ_STATUS_MASK)
#define CH1_VIDEO_WRITE_DMA_SOFT_RESET(Base, Val) \
REG_WRITE32(Base, CH1_VIDEO_BASE + VIDEO_DMA_SOFT_RESET_OFFSET, (Val))
/* ---- CH1 Audio Helpers ---- */
#define CH1_AUDIO_READ_EN(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_EN_OFFSET)
#define CH1_AUDIO_WRITE_EN(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_EN_OFFSET, (Val))
#define CH1_AUDIO_READ_DMA_ADDR_LO(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_DMA_ADDR_LO_OFFSET)
#define CH1_AUDIO_WRITE_DMA_ADDR_LO(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_DMA_ADDR_LO_OFFSET, (Val))
#define CH1_AUDIO_READ_DMA_ADDR_HI(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_DMA_ADDR_HI_OFFSET)
#define CH1_AUDIO_WRITE_DMA_ADDR_HI(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_DMA_ADDR_HI_OFFSET, (Val))
#define CH1_AUDIO_READ_DMA_BYTES(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_DMA_BYTES_OFFSET)
#define CH1_AUDIO_WRITE_DMA_BYTES(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_DMA_BYTES_OFFSET, (Val))
#define CH1_AUDIO_READ_DMA_CTRL(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_DMA_CTRL_OFFSET)
#define CH1_AUDIO_WRITE_DMA_CTRL(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_DMA_CTRL_OFFSET, (Val))
#define CH1_AUDIO_READ_DMA_WR_PTR(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_DMA_WR_PTR_OFFSET)
#define CH1_AUDIO_WRITE_DMA_WR_PTR(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_DMA_WR_PTR_OFFSET, (Val))
#define CH1_AUDIO_WRITE_DESC_WR(Base) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_DMA_DESC_WR_OFFSET, 1)
#define CH1_AUDIO_READ_DESC_MAX_CNT(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_DESC_MAX_CNT_OFFSET)
#define CH1_AUDIO_WRITE_DESC_MAX_CNT(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_DESC_MAX_CNT_OFFSET, (Val))
#define CH1_AUDIO_READ_DMA_EN(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_DMA_EN_OFFSET)
#define CH1_AUDIO_WRITE_DMA_EN(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_DMA_EN_OFFSET, (Val))
#define CH1_AUDIO_READ_DMA_DONE_PTR(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_DMA_DONE_PTR_OFFSET)
#define CH1_AUDIO_READ_LOST_FRAME_CNT(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_LOST_FRAME_CNT_OFFSET)
#define CH1_AUDIO_WRITE_LOST_FRAME_CLR(Base) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_LOST_FRAME_CNT_OFFSET, 0)
#define CH1_AUDIO_READ_HAS_AUDIO(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_HAS_AUDIO_OFFSET)
#define CH1_AUDIO_READ_THRES(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_THRES_OFFSET)
#define CH1_AUDIO_WRITE_THRES(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_THRES_OFFSET, (Val))
#define CH1_AUDIO_READ_SAMPLE(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_SAMPLE_OFFSET)
#define CH1_AUDIO_READ_DEPTH(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_DEPTH_OFFSET)
#define CH1_AUDIO_READ_NUM(Base) \
REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_NUM_OFFSET)
#define CH1_AUDIO_READ_IRQ_STATUS(Base) \
(REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_IRQ_STATUS_OFFSET) & IRQ_STATUS_MASK)
#define CH1_AUDIO_WRITE_IRQ_STATUS_CLEAR(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_IRQ_STATUS_OFFSET, (Val) & IRQ_STATUS_MASK)
#define CH1_AUDIO_READ_DMA_IRQ_STATUS(Base) \
(REG_READ32(Base, CH1_AUDIO_BASE + AUDIO_DMA_IRQ_STATUS_OFFSET) & DMA_IRQ_STATUS_MASK)
#define CH1_AUDIO_WRITE_DMA_IRQ_STATUS_CLEAR(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_DMA_IRQ_STATUS_OFFSET, (Val) & DMA_IRQ_STATUS_MASK)
#define CH1_AUDIO_WRITE_DMA_SOFT_RESET(Base, Val) \
REG_WRITE32(Base, CH1_AUDIO_BASE + AUDIO_DMA_SOFT_RESET_OFFSET, (Val))
#endif /* _KERNEL_MODE */
#endif /* _REG_H_ */
-28
View File
@@ -1,28 +0,0 @@
<RCC>
<qresource prefix="/">
<file>res/qss/default.qss</file>
<file>res/img/icon_alert_failure.png</file>
<file>res/img/icon_alert_succeed.png</file>
<file>res/img/icon_-volume_circle.png</file>
<file>res/img/logo.png</file>
<file>res/img/nav_close_btn.png</file>
<file>res/img/nav_close_btn_hover.png</file>
<file>res/img/nav_min_btn.png</file>
<file>res/img/nav_min_btn_hover.png</file>
<file>res/img/top_close.png</file>
<file>res/img/top_close_hover.png</file>
<file>res/img/top_narrow.png</file>
<file>res/img/top_narrow_hover.png</file>
<file>res/icon/check.png</file>
<file>res/icon/dialog_allow.png</file>
<file>res/icon/dialog_deny.png</file>
<file>res/icon/dialog_notify.png</file>
<file>res/icon/dialog_query.png</file>
<file>res/icon/down.png</file>
<file>res/icon/uncheck.png</file>
<file>res/img/nav_max_btn.png</file>
<file>res/img/nav_max_hover_btn.png</file>
<file>res/img/nav_restore_hover_btn.png</file>
<file>res/img/nav_restore_btn.png</file>
</qresource>
</RCC>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 978 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 959 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 996 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 991 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Some files were not shown because too many files have changed in this diff Show More