Refine GVFG customer API surface

This commit is contained in:
Mark.lin
2026-06-11 10:25:50 +08:00
parent 8a13e8b0e8
commit 6120a6b74f
6 changed files with 648 additions and 1025 deletions
+468 -864
View File
File diff suppressed because it is too large Load Diff
+107
View File
@@ -0,0 +1,107 @@
<mxfile host="app.diagrams.net" modified="2026-06-10T00:00:00.000Z" agent="Codex" version="24.7.17" type="device">
<diagram id="gvfg-dma-ring-flow" name="GVFG DMA Ring Data Flow">
<mxGraphModel dx="1600" dy="1000" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="title" value="GVFG user-space DMA ring data flow" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=28;fontStyle=1" vertex="1" parent="1">
<mxGeometry x="360" y="30" width="880" height="40" as="geometry"/>
</mxCell>
<mxCell id="hw" value="FPGA / XDMA hardware&#xa;VIDEO IRQ" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=14;fontStyle=1" vertex="1" parent="1">
<mxGeometry x="80" y="130" width="210" height="80" as="geometry"/>
</mxCell>
<mxCell id="event" value="event_thread_proc()&#xa;ReadFile(event_N) returns" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=14;fontStyle=1" vertex="1" parent="1">
<mxGeometry x="360" y="130" width="230" height="80" as="geometry"/>
</mxCell>
<mxCell id="pending" value="pending_events_++&#xa;data_cv_.notify_one()" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=14" vertex="1" parent="1">
<mxGeometry x="660" y="130" width="230" height="80" as="geometry"/>
</mxCell>
<mxCell id="datawait" value="data_thread_proc()&#xa;waits for pending_events_ &gt; 0" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=14;fontStyle=1" vertex="1" parent="1">
<mxGeometry x="960" y="130" width="260" height="80" as="geometry"/>
</mxCell>
<mxCell id="clear" value="Clear VIDEO IRQ&#xa;write INT_CLR high/low&#xa;enable_user_event()" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=14" vertex="1" parent="1">
<mxGeometry x="1280" y="130" width="240" height="90" as="geometry"/>
</mxCell>
<mxCell id="findslot" value="Find free FrameSlot&#xa;slot.in_use == false" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=14;fontStyle=1" vertex="1" parent="1">
<mxGeometry x="80" y="310" width="240" height="80" as="geometry"/>
</mxCell>
<mxCell id="droptest" value="Slot already ready?&#xa;ready == true and newer than delivered" style="rhombus;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13" vertex="1" parent="1">
<mxGeometry x="390" y="300" width="190" height="100" as="geometry"/>
</mxCell>
<mxCell id="drop" value="Drop old ready frame&#xa;stats_.frames_dropped++" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=14" vertex="1" parent="1">
<mxGeometry x="650" y="290" width="230" height="70" as="geometry"/>
</mxCell>
<mxCell id="markwriting" value="Mark slot writing&#xa;ready = false&#xa;in_use = true" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=14" vertex="1" parent="1">
<mxGeometry x="650" y="390" width="230" height="90" as="geometry"/>
</mxCell>
<mxCell id="readc2h" value="ReadFile(c2h_N)&#xa;directly into slot.data" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=14;fontStyle=1" vertex="1" parent="1">
<mxGeometry x="960" y="330" width="260" height="80" as="geometry"/>
</mxCell>
<mxCell id="publish" value="publish_frame(slotIndex, bytes)&#xa;slot.ready = true&#xa;slot.in_use = false&#xa;frame_cv_.notify_one()" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=14" vertex="1" parent="1">
<mxGeometry x="1280" y="310" width="260" height="120" as="geometry"/>
</mxCell>
<mxCell id="wait" value="captureLoop()&#xa;backend-&gt;wait_frame(1000, frame)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=14;fontStyle=1" vertex="1" parent="1">
<mxGeometry x="80" y="560" width="270" height="80" as="geometry"/>
</mxCell>
<mxCell id="select" value="wait_frame() selects newest ready slot&#xa;slot.ready = false&#xa;slot.in_use = true&#xa;out.data = slot.data.data()" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=14" vertex="1" parent="1">
<mxGeometry x="430" y="540" width="310" height="120" as="geometry"/>
</mxCell>
<mxCell id="render" value="renderGpuFrame(frame)&#xa;SDK preview uses same slot pointer" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=14" vertex="1" parent="1">
<mxGeometry x="820" y="540" width="270" height="90" as="geometry"/>
</mxCell>
<mxCell id="callback" value="emitNativeFrame(frame)&#xa;customer callback gets out.data = frame.data" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=14" vertex="1" parent="1">
<mxGeometry x="1160" y="540" width="300" height="90" as="geometry"/>
</mxCell>
<mxCell id="release" value="release_frame(frame)&#xa;slot.in_use = false&#xa;data_cv_.notify_all()" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=14;fontStyle=1" vertex="1" parent="1">
<mxGeometry x="630" y="740" width="300" height="90" as="geometry"/>
</mxCell>
<mxCell id="stateTitle" value="FrameSlot state lifecycle" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontStyle=1" vertex="1" parent="1">
<mxGeometry x="80" y="900" width="280" height="30" as="geometry"/>
</mxCell>
<mxCell id="sfree" value="Free&#xa;ready=false&#xa;in_use=false" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13" vertex="1" parent="1">
<mxGeometry x="380" y="875" width="150" height="80" as="geometry"/>
</mxCell>
<mxCell id="swriting" value="Writing&#xa;ready=false&#xa;in_use=true" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13" vertex="1" parent="1">
<mxGeometry x="600" y="875" width="150" height="80" as="geometry"/>
</mxCell>
<mxCell id="sready" value="Ready&#xa;ready=true&#xa;in_use=false" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13" vertex="1" parent="1">
<mxGeometry x="820" y="875" width="150" height="80" as="geometry"/>
</mxCell>
<mxCell id="sdelivered" value="Delivered&#xa;ready=false&#xa;in_use=true" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13" vertex="1" parent="1">
<mxGeometry x="1040" y="875" width="160" height="80" as="geometry"/>
</mxCell>
<mxCell id="srelease" value="Released&#xa;ready=false&#xa;in_use=false" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13" vertex="1" parent="1">
<mxGeometry x="1270" y="875" width="160" height="80" as="geometry"/>
</mxCell>
<mxCell id="e1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="hw" target="event"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="event" target="pending"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="pending" target="datawait"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="datawait" target="clear"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="clear" target="findslot"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="1400" y="260"/><mxPoint x="200" y="260"/></Array></mxGeometry></mxCell>
<mxCell id="e6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="findslot" target="droptest"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e7" value="yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="droptest" target="drop"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e8" value="no / after drop" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="droptest" target="markwriting"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e9" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="drop" target="markwriting"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="markwriting" target="readc2h"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="readc2h" target="publish"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e12" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="publish" target="wait"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="1410" y="500"/><mxPoint x="220" y="500"/></Array></mxGeometry></mxCell>
<mxCell id="e13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="wait" target="select"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="select" target="render"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e15" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="render" target="callback"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="e16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="callback" target="release"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="1310" y="700"/><mxPoint x="780" y="700"/></Array></mxGeometry></mxCell>
<mxCell id="e17" value="slot reusable" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;strokeWidth=2;dashed=1" edge="1" parent="1" source="release" target="findslot"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="780" y="850"/><mxPoint x="40" y="850"/><mxPoint x="40" y="350"/></Array></mxGeometry></mxCell>
<mxCell id="se1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block" edge="1" parent="1" source="sfree" target="swriting"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="se2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block" edge="1" parent="1" source="swriting" target="sready"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="se3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block" edge="1" parent="1" source="sready" target="sdelivered"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="se4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block" edge="1" parent="1" source="sdelivered" target="srelease"><mxGeometry relative="1" as="geometry"/></mxCell>
<mxCell id="se5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;dashed=1" edge="1" parent="1" source="srelease" target="sfree"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="1350" y="1000"/><mxPoint x="455" y="1000"/></Array></mxGeometry></mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
+31 -114
View File
@@ -9,11 +9,6 @@
namespace
{
QString fpgaFieldText(bool valid, const QString &text)
{
return valid ? text : QStringLiteral("--");
}
QString hex32(uint32_t value)
{
return QStringLiteral("0x") + QString::number(value, 16).rightJustified(8, QLatin1Char('0')).toUpper();
@@ -37,85 +32,6 @@ namespace
return QStringLiteral("UNKNOWN");
}
}
bool fpgaMaskValid(uint32_t mask, uint32_t flag)
{
return (mask & flag) != 0;
}
QString fpgaRawLogLine(const gvfg_runtime_info_t &info)
{
const auto &signal = info.input_signal;
const auto &fpga = info.input_signal.fpga;
const bool videoFormatValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_VIDEO_FORMAT);
const bool frameRateValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_FRAME_RATE);
const bool bitDepthValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_BIT_DEPTH);
const bool statusValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_STATUS);
return QStringLiteral("fpga_raw\n"
" valid_mask=%1\n"
" resolution: width_valid=%2 width_raw=%3 height_valid=%4 height_raw=%5\n"
" video_format: valid=%6 raw=%7 code=%8 name=%9\n"
" frame_rate: valid=%10 raw=%11 code=%12 bits=%13 name=%14\n"
" bit_depth: valid=%15 raw=%16 value=%17\n"
" status: valid=%18 raw=%19 sdi_lock=%20 sdi_ddr=%21 hdmi_lock=%22 hdmi_ddr=%23")
.arg(hex32(fpga.valid_mask))
.arg(fpga.width_valid)
.arg(fpga.width_raw)
.arg(fpga.height_valid)
.arg(fpga.height_raw)
.arg(videoFormatValid ? 1 : 0)
.arg(hex32(fpga.video_format_raw))
.arg(signal.video_format_code)
.arg(QString::fromLatin1(signal.video_format))
.arg(frameRateValid ? 1 : 0)
.arg(hex32(fpga.frame_rate_raw))
.arg(signal.frame_rate_code)
.arg(QString::fromLatin1(signal.frame_rate_bits))
.arg(QString::fromLatin1(signal.frame_rate_name))
.arg(bitDepthValid ? 1 : 0)
.arg(hex32(fpga.bit_depth_raw))
.arg(signal.bit_depth)
.arg(statusValid ? 1 : 0)
.arg(hex32(fpga.status_raw))
.arg(signal.sdi_locked)
.arg(signal.sdi_ddr_ok)
.arg(signal.hdmi_locked)
.arg(signal.hdmi_ddr_ok);
}
QString fpgaRawStateKey(const gvfg_runtime_info_t &info)
{
const auto &signal = info.input_signal;
const auto &fpga = info.input_signal.fpga;
const bool videoFormatValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_VIDEO_FORMAT);
const bool frameRateValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_FRAME_RATE);
const bool bitDepthValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_BIT_DEPTH);
const bool statusValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_STATUS);
return QStringLiteral("%1|%2|%3|%4|%5|%6|%7|%8|%9|%10|%11|%12|%13|%14|%15|%16|%17|%18|%19|%20|%21|%22|%23")
.arg(fpga.valid_mask)
.arg(fpga.width_valid)
.arg(fpga.width_raw)
.arg(fpga.height_valid)
.arg(fpga.height_raw)
.arg(videoFormatValid ? 1 : 0)
.arg(fpga.video_format_raw)
.arg(signal.video_format_code)
.arg(QString::fromLatin1(signal.video_format))
.arg(frameRateValid ? 1 : 0)
.arg(fpga.frame_rate_raw)
.arg(signal.frame_rate_code)
.arg(QString::fromLatin1(signal.frame_rate_bits))
.arg(QString::fromLatin1(signal.frame_rate_name))
.arg(bitDepthValid ? 1 : 0)
.arg(fpga.bit_depth_raw)
.arg(signal.bit_depth)
.arg(statusValid ? 1 : 0)
.arg(fpga.status_raw)
.arg(signal.sdi_locked)
.arg(signal.sdi_ddr_ok)
.arg(signal.hdmi_locked)
.arg(signal.hdmi_ddr_ok);
}
}
MainWindow::MainWindow(QWidget *parent)
@@ -242,7 +158,6 @@ bool MainWindow::openDevice()
}
lastSignalStatusText_.clear();
lastFpgaRawStateKey_.clear();
appendLog(QStringLiteral("Opened device index %1").arg(deviceIndex));
appendLog(QStringLiteral("FPGA signal monitor active"));
updateSignalStatus(true);
@@ -267,7 +182,6 @@ void MainWindow::closeDevice()
ui_->statusLabel->setText(QStringLiteral("Idle"));
lastSignalStatusText_.clear();
lastFpgaRawStateKey_.clear();
updateUiState();
}
@@ -370,36 +284,42 @@ void MainWindow::updateSignalStatus(bool writeLog)
return;
const auto &signal = info.input_signal;
const auto &fpga = signal.fpga;
const auto &preview = info.preview_output;
const auto &callback = info.callback_frame;
const bool frameRateValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_FRAME_RATE);
const bool videoFormatValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_VIDEO_FORMAT);
const bool bitDepthValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_BIT_DEPTH);
const bool statusValid = fpgaMaskValid(fpga.valid_mask, GVFG_FPGA_SIGNAL_VALID_STATUS);
if (previewWindow_->isVisible())
updatePreviewSourceSize(info);
const QString fpgaResolution = (fpga.width_valid && fpga.height_valid)
const QString fpgaResolution = (signal.width > 0 && signal.height > 0)
? QStringLiteral("%1x%2").arg(signal.width).arg(signal.height)
: QStringLiteral("--");
const QString frameRateText = signal.frame_rate_code >= 0
? QStringLiteral("%1 (%2)")
.arg(QString::fromLatin1(signal.frame_rate_bits))
.arg(QString::fromLatin1(signal.frame_rate_name))
: QStringLiteral("--");
const QString formatText = signal.video_format_code >= 0
? QStringLiteral("%1 (%2)")
.arg(signal.video_format_code)
.arg(QString::fromLatin1(signal.video_format))
: QStringLiteral("--");
const QString bitDepthText = signal.bit_depth > 0 ? QString::number(signal.bit_depth) : QStringLiteral("--");
const QString line0 = QStringLiteral("FPGA reported | signal=%1 fps=%2 format=%3 bitdepth=%4")
.arg(fpgaResolution)
.arg(fpgaFieldText(frameRateValid,
QStringLiteral("%1 (%2)")
.arg(QString::fromLatin1(signal.frame_rate_bits))
.arg(QString::fromLatin1(signal.frame_rate_name))))
.arg(fpgaFieldText(videoFormatValid,
QStringLiteral("%1 (%2)")
.arg(signal.video_format_code)
.arg(QString::fromLatin1(signal.video_format))))
.arg(fpgaFieldText(bitDepthValid,
QStringLiteral("%1").arg(signal.bit_depth)));
.arg(frameRateText)
.arg(formatText)
.arg(bitDepthText);
const QString line2 = QStringLiteral("FPGA status | SDI lock=%1 SDI DDR=%2 HDMI lock=%3 HDMI DDR=%4")
.arg(fpgaFieldText(statusValid, QString::number(signal.sdi_locked)))
.arg(fpgaFieldText(statusValid, QString::number(signal.sdi_ddr_ok)))
.arg(fpgaFieldText(statusValid, QString::number(signal.hdmi_locked)))
.arg(fpgaFieldText(statusValid, QString::number(signal.hdmi_ddr_ok)));
.arg(signal.sdi_locked)
.arg(signal.sdi_ddr_ok)
.arg(signal.hdmi_locked)
.arg(signal.hdmi_ddr_ok);
const QString lineRaw = QStringLiteral("FPGA raw | size=%1x%2 fmt=%3 fps=%4 bit=%5 status=%6")
.arg(signal.raw.width)
.arg(signal.raw.height)
.arg(hex32(signal.raw.video_format))
.arg(hex32(signal.raw.frame_rate))
.arg(signal.raw.bit_depth)
.arg(hex32(signal.raw.status));
const QString line3 = preview.active
? QStringLiteral("Preview output | frame=%1x%2 format=%3 bitdepth=%4")
.arg(preview.width)
@@ -420,19 +340,16 @@ void MainWindow::updateSignalStatus(bool writeLog)
: QStringLiteral("--"))
.arg(static_cast<qulonglong>(info.delivered_frames));
const QString statusText = line0 + QLatin1Char('\n') + line2 + QLatin1Char('\n') + line3 + QLatin1Char('\n') + line4 + QLatin1Char('\n') + line5;
if (lastSignalStatusText_ != statusText)
const QString statusText = line0 + QLatin1Char('\n') + line2 + QLatin1Char('\n') + lineRaw + QLatin1Char('\n') + line3 + QLatin1Char('\n') + line4 + QLatin1Char('\n') + line5;
const bool changed = lastSignalStatusText_ != statusText;
if (changed)
{
ui_->statusLabel->setText(statusText);
lastSignalStatusText_ = statusText;
}
const QString stateKey = fpgaRawStateKey(info);
if (writeLog && lastFpgaRawStateKey_ != stateKey)
{
appendLog(fpgaRawLogLine(info));
lastFpgaRawStateKey_ = stateKey;
}
if (writeLog && changed)
appendLog(statusText);
}
void MainWindow::updateUiState()
-1
View File
@@ -60,5 +60,4 @@ private:
std::atomic<uint64_t> frameCount_{0};
QTimer *signalStatusTimer_ = nullptr;
QString lastSignalStatusText_;
QString lastFpgaRawStateKey_;
};
+15 -27
View File
@@ -3,9 +3,8 @@
/*
* Customer-facing GVFG capture API.
*
* Include only this header in customer applications. Do not include internal
* backend/gdriver headers; those layers are implementation details behind
* gvfg.dll.
* Include only this header in customer applications. Internal XDMA backend
* headers are implementation details behind gvfg.dll.
*
* Minimal capture flow:
*
@@ -108,26 +107,15 @@ typedef struct
int swapchain_bitdepth; /* gvfg_preview_bitdepth_t value. */
} gvfg_preview_desc_t;
typedef enum
{
GVFG_FPGA_SIGNAL_VALID_VIDEO_FORMAT = 1u << 0, /* FPGA 0x0c read succeeded. */
GVFG_FPGA_SIGNAL_VALID_FRAME_RATE = 1u << 1, /* FPGA 0x18 read succeeded. */
GVFG_FPGA_SIGNAL_VALID_BIT_DEPTH = 1u << 2, /* FPGA 0x1c read succeeded. */
GVFG_FPGA_SIGNAL_VALID_STATUS = 1u << 3 /* FPGA 0x180 read succeeded. */
} gvfg_fpga_signal_valid_mask_t;
typedef struct
{
uint32_t valid_mask; /* Combination of gvfg_fpga_signal_valid_mask_t flags. */
int width_valid; /* Non-zero when FPGA 0x10 read succeeded. */
int height_valid; /* Non-zero when FPGA 0x14 read succeeded. */
uint32_t width_raw; /* Raw FPGA 0x10 width register. */
uint32_t height_raw; /* Raw FPGA 0x14 height register. */
uint32_t video_format_raw; /* Raw FPGA 0x0c value. */
uint32_t frame_rate_raw; /* Raw FPGA 0x18 value. */
uint32_t bit_depth_raw; /* Raw FPGA 0x1c value. */
uint32_t status_raw; /* Raw FPGA 0x180 value. */
} gvfg_fpga_signal_status_t;
uint32_t width; /* Raw FPGA width value. */
uint32_t height; /* Raw FPGA height value. */
uint32_t video_format; /* Raw FPGA video-format value. */
uint32_t frame_rate; /* Raw FPGA frame-rate value. */
uint32_t bit_depth; /* Raw FPGA bit-depth value. */
uint32_t status; /* Raw FPGA lock/status value. */
} gvfg_fpga_signal_raw_t;
typedef struct
{
@@ -135,15 +123,15 @@ typedef struct
int height; /* Signal height in pixels, from FPGA when available. */
int video_format_code; /* 0=yuv422, 1=rgb, 2=yuv444, 3=yuv420. */
char video_format[16]; /* Decoded FPGA signal format name. */
int frame_rate_code; /* FPGA frame-rate code from 0x18 low nibble. */
int frame_rate_code; /* FPGA frame-rate code. */
char frame_rate_bits[5]; /* 4-bit binary text, for example "0110". */
char frame_rate_name[16]; /* None, 23.98, 24, 47.95, ..., or "--" for unsupported codes. */
int bit_depth; /* FPGA signal bit depth: 8 or 10 when valid. */
int sdi_locked; /* FPGA 0x180 bit0. */
int sdi_ddr_ok; /* FPGA 0x180 bit1. */
int hdmi_locked; /* FPGA 0x180 bit2. */
int hdmi_ddr_ok; /* FPGA 0x180 bit3. */
gvfg_fpga_signal_status_t fpga; /* Raw FPGA register values and read-valid mask. */
int sdi_locked; /* Non-zero when SDI reports locked. */
int sdi_ddr_ok; /* Non-zero when SDI DDR status is OK. */
int hdmi_locked; /* Non-zero when HDMI reports locked. */
int hdmi_ddr_ok; /* Non-zero when HDMI DDR status is OK. */
gvfg_fpga_signal_raw_t raw; /* Raw FPGA values for diagnostics; validity is handled by the SDK. */
} gvfg_signal_status_t;
typedef struct
+27 -19
View File
@@ -393,27 +393,35 @@ struct gvfg_handle_t
{
std::lock_guard<std::mutex> lock(stateMutex);
haveSignalSize = fpgaWidthValid && fpgaHeightValid && fpgaWidthRaw != 0 && fpgaHeightRaw != 0;
const bool videoFormatValid = fpga_field_valid(fpgaValidMask, 0);
const bool frameRateValid = fpga_field_valid(fpgaValidMask, 1);
const bool bitDepthValid = fpga_field_valid(fpgaValidMask, 2);
const bool statusValid = fpga_field_valid(fpgaValidMask, 3);
out.width = haveSignalSize ? static_cast<int>(fpgaWidthRaw) : 0;
out.height = haveSignalSize ? static_cast<int>(fpgaHeightRaw) : 0;
out.video_format_code = static_cast<int>(fpgaVideoFormatRaw & 0x3u);
copy_cstr(out.video_format, sizeof(out.video_format), fpga_video_format_name(fpgaVideoFormatRaw));
out.frame_rate_code = static_cast<int>(fpgaFrameRateRaw & 0x0fu);
copy_binary4(out.frame_rate_bits, sizeof(out.frame_rate_bits), fpgaFrameRateRaw);
copy_cstr(out.frame_rate_name, sizeof(out.frame_rate_name), fpga_frame_rate_name(fpgaFrameRateRaw));
out.bit_depth = static_cast<int>(fpgaBitDepthRaw);
out.sdi_locked = (fpgaStatusRaw & (1u << 0)) ? 1 : 0;
out.sdi_ddr_ok = (fpgaStatusRaw & (1u << 1)) ? 1 : 0;
out.hdmi_locked = (fpgaStatusRaw & (1u << 2)) ? 1 : 0;
out.hdmi_ddr_ok = (fpgaStatusRaw & (1u << 3)) ? 1 : 0;
out.fpga.valid_mask = fpgaValidMask;
out.fpga.width_valid = fpgaWidthValid ? 1 : 0;
out.fpga.height_valid = fpgaHeightValid ? 1 : 0;
out.fpga.width_raw = fpgaWidthRaw;
out.fpga.height_raw = fpgaHeightRaw;
out.fpga.video_format_raw = fpgaVideoFormatRaw;
out.fpga.frame_rate_raw = fpgaFrameRateRaw;
out.fpga.bit_depth_raw = fpgaBitDepthRaw;
out.fpga.status_raw = fpgaStatusRaw;
out.video_format_code = videoFormatValid ? static_cast<int>(fpgaVideoFormatRaw & 0x3u) : -1;
copy_cstr(out.video_format,
sizeof(out.video_format),
videoFormatValid ? fpga_video_format_name(fpgaVideoFormatRaw) : "--");
out.frame_rate_code = frameRateValid ? static_cast<int>(fpgaFrameRateRaw & 0x0fu) : -1;
if (frameRateValid)
copy_binary4(out.frame_rate_bits, sizeof(out.frame_rate_bits), fpgaFrameRateRaw);
else
copy_cstr(out.frame_rate_bits, sizeof(out.frame_rate_bits), "--");
copy_cstr(out.frame_rate_name,
sizeof(out.frame_rate_name),
frameRateValid ? fpga_frame_rate_name(fpgaFrameRateRaw) : "--");
out.bit_depth = bitDepthValid ? static_cast<int>(fpgaBitDepthRaw) : 0;
out.sdi_locked = statusValid && (fpgaStatusRaw & (1u << 0)) ? 1 : 0;
out.sdi_ddr_ok = statusValid && (fpgaStatusRaw & (1u << 1)) ? 1 : 0;
out.hdmi_locked = statusValid && (fpgaStatusRaw & (1u << 2)) ? 1 : 0;
out.hdmi_ddr_ok = statusValid && (fpgaStatusRaw & (1u << 3)) ? 1 : 0;
out.raw.width = fpgaWidthRaw;
out.raw.height = fpgaHeightRaw;
out.raw.video_format = fpgaVideoFormatRaw;
out.raw.frame_rate = fpgaFrameRateRaw;
out.raw.bit_depth = fpgaBitDepthRaw;
out.raw.status = fpgaStatusRaw;
}
return haveSignalSize ? GVFG_OK : GVFG_ENODEV;
}