Enable zero-copy through the public API before opening the device and configure a driver-owned zero-copy ring slot. Return every delivered frame through IOCTL_GIGA_RELEASE_VIDEO_FRAME and validate the complete frame token before release. Preserve ownership when the release IOCTL fails so stop, close, or the next start can retry instead of discarding the driver pointer. Stop DMA and join the backend acquire/event thread before draining frames, preventing acquire from racing stop or disable. Drain caller-held, ready, unread, and pending zero-copy frames before stop, restart, disable, device close, or process destruction. Block restart and zero-copy disable when outstanding frames cannot be released successfully. Release unread frames on signal unplug and before format or resolution changes rebuild the frame ring. Propagate stop and release errors through the public API and report release failures in the standalone preview. Document zero-copy ownership, lifecycle requirements, diagnostics, and data flow. Verified with Standalone Debug and Release builds.
53 lines
11 KiB
Plaintext
53 lines
11 KiB
Plaintext
<mxfile host="app.diagrams.net" modified="2026-08-19T00:00:00.000Z" agent="Codex" version="24.7.17" type="device">
|
|
<diagram id="gvfg-dma-flow" name="GVFG Copy and Zero-Copy Flow">
|
|
<mxGraphModel dx="1600" dy="1000" grid="1" gridSize="10" page="1" pageScale="1" pageWidth="1600" pageHeight="1100">
|
|
<root>
|
|
<mxCell id="0"/>
|
|
<mxCell id="1" parent="0"/>
|
|
<mxCell id="title" value="GVFG DMA delivery — copy and zero-copy modes" style="text;html=1;strokeColor=none;align=center;fontSize=26;fontStyle=1" vertex="1" parent="1"><mxGeometry x="300" y="25" width="1000" height="45" as="geometry"/></mxCell>
|
|
<mxCell id="abi" value="Requires new driver ABI: VIDEO_START/STOP, GET_FRAME(MAXULONG), ZERO-COPY ENABLE/ACQUIRE/RELEASE/DISABLE" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13" vertex="1" parent="1"><mxGeometry x="300" y="80" width="1000" height="45" as="geometry"/></mxCell>
|
|
<mxCell id="hw" value="FPGA / driver DMA buffer
DMA complete interrupt" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=14;fontStyle=1" vertex="1" parent="1"><mxGeometry x="100" y="160" width="240" height="80" as="geometry"/></mxCell>
|
|
<mxCell id="event" value="dma_event_ wakes
capture_thread_proc()
handle_dma_event(channel)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=14" vertex="1" parent="1"><mxGeometry x="450" y="150" width="260" height="100" as="geometry"/></mxCell>
|
|
<mxCell id="mode" value="zero-copy enabled?" style="rhombus;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=14;fontStyle=1" vertex="1" parent="1"><mxGeometry x="850" y="145" width="220" height="110" as="geometry"/></mxCell>
|
|
|
|
<mxCell id="copyLane" value="COPY MODE — SDK 3-slot ring" style="swimlane;html=1;startSize=34;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=17;fontStyle=1" vertex="1" parent="1"><mxGeometry x="60" y="310" width="700" height="500" as="geometry"/></mxCell>
|
|
<mxCell id="copySlot" value="Select writable FrameSlot
ready=false, in_use=false
ring pressure may drop oldest unread frame" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=13" vertex="1" parent="1"><mxGeometry x="90" y="370" width="280" height="100" as="geometry"/></mxCell>
|
|
<mxCell id="copyGet" value="IOCTL_PCIES2MM_GET_FRAME
input {channel, 0xFFFFFFFF}
one copy: driver DMA → slot.data
GET_VIDEO_DONE_INDEX removed" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=13;fontStyle=1" vertex="1" parent="1"><mxGeometry x="440" y="360" width="280" height="120" as="geometry"/></mxCell>
|
|
<mxCell id="copyPublish" value="publish_frame()
slot.ready=true, in_use=false
frame_cv_.notify_one()" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=13" vertex="1" parent="1"><mxGeometry x="250" y="520" width="300" height="90" as="geometry"/></mxCell>
|
|
<mxCell id="copyRead" value="gvfg_read_frame()
frame.data = slot.data.data()
SDK-owned until release" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13" vertex="1" parent="1"><mxGeometry x="90" y="665" width="270" height="95" as="geometry"/></mxCell>
|
|
<mxCell id="copyRelease" value="gvfg_release_frame()
validate token
slot.in_use=false
slot reusable" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;fontStyle=1" vertex="1" parent="1"><mxGeometry x="450" y="655" width="270" height="105" as="geometry"/></mxCell>
|
|
|
|
<mxCell id="zcLane" value="ZERO-COPY MODE — one outstanding driver frame" style="swimlane;html=1;startSize=34;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=17;fontStyle=1" vertex="1" parent="1"><mxGeometry x="830" y="310" width="700" height="500" as="geometry"/></mxCell>
|
|
<mxCell id="zcEnable" value="Open device
ENABLE_FRAME_ZEROCOPY(channel)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=13" vertex="1" parent="1"><mxGeometry x="860" y="365" width="260" height="85" as="geometry"/></mxCell>
|
|
<mxCell id="zcHeld" value="frame ready or held?" style="rhombus;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13" vertex="1" parent="1"><mxGeometry x="1220" y="355" width="230" height="105" as="geometry"/></mxCell>
|
|
<mxCell id="zcAcquire" value="No: ACQUIRE_VIDEO_FRAME_ZEROCOPY
input {channel, 0xFFFFFFFF}
output driver-owned pointer
no SDK payload copy" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=13;fontStyle=1" vertex="1" parent="1"><mxGeometry x="860" y="520" width="300" height="115" as="geometry"/></mxCell>
|
|
<mxCell id="zcSkip" value="Yes: skip this acquire event
keep held driver pointer valid
no loss statistic or event" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13" vertex="1" parent="1"><mxGeometry x="1210" y="525" width="270" height="95" as="geometry"/></mxCell>
|
|
<mxCell id="zcRead" value="gvfg_read_frame()
returns driver pointer
valid until release" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13" vertex="1" parent="1"><mxGeometry x="860" y="675" width="270" height="85" as="geometry"/></mxCell>
|
|
<mxCell id="zcRelease" value="gvfg_release_frame()
validate token
RELEASE_VIDEO_FRAME(channel)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;fontStyle=1" vertex="1" parent="1"><mxGeometry x="1210" y="665" width="290" height="95" as="geometry"/></mxCell>
|
|
|
|
<mxCell id="consumer" value="Before release: application may preview, convert, record, or copy. Return the frame descriptor unchanged." style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=14" vertex="1" parent="1"><mxGeometry x="300" y="855" width="1000" height="60" as="geometry"/></mxCell>
|
|
<mxCell id="close" value="Stop / close / exit: release held frame first; zero-copy sends DISABLE_FRAME_ZEROCOPY(channel), then closes device" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1" vertex="1" parent="1"><mxGeometry x="450" y="960" width="700" height="70" as="geometry"/></mxCell>
|
|
|
|
<mxCell id="e1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;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;html=1;endArrow=block;strokeWidth=2" edge="1" parent="1" source="event" target="mode"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="e3" value="no / copy" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;strokeWidth=2;strokeColor=#82b366" edge="1" parent="1" source="mode" target="copySlot"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="960" y="280"/><mxPoint x="230" y="280"/></Array></mxGeometry></mxCell>
|
|
<mxCell id="e4" value="yes / zero-copy" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;strokeWidth=2;strokeColor=#6c8ebf" edge="1" parent="1" source="mode" target="zcHeld"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="c1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;strokeColor=#82b366" edge="1" parent="1" source="copySlot" target="copyGet"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="c2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;strokeColor=#82b366" edge="1" parent="1" source="copyGet" target="copyPublish"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="c3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;strokeColor=#82b366" edge="1" parent="1" source="copyPublish" target="copyRead"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="c4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;strokeColor=#9673a6" edge="1" parent="1" source="copyRead" target="copyRelease"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="c5" value="slot reusable" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;dashed=1;strokeColor=#82b366" edge="1" parent="1" source="copyRelease" target="copySlot"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="585" y="790"/><mxPoint x="40" y="790"/><mxPoint x="40" y="420"/></Array></mxGeometry></mxCell>
|
|
<mxCell id="z0" value="enabled at open" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;dashed=1;strokeColor=#6c8ebf" edge="1" parent="1" source="zcEnable" target="zcHeld"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="z1" value="no" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;strokeColor=#6c8ebf" edge="1" parent="1" source="zcHeld" target="zcAcquire"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="z2" value="yes" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;strokeColor=#d6b656" edge="1" parent="1" source="zcHeld" target="zcSkip"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="z3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;strokeColor=#6c8ebf" edge="1" parent="1" source="zcAcquire" target="zcRead"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="z4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;strokeColor=#9673a6" edge="1" parent="1" source="zcRead" target="zcRelease"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="z5" value="driver frame reusable" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;dashed=1;strokeColor=#6c8ebf" edge="1" parent="1" source="zcRelease" target="zcHeld"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="1355" y="790"/><mxPoint x="1510" y="790"/><mxPoint x="1510" y="407"/></Array></mxGeometry></mxCell>
|
|
<mxCell id="a1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;dashed=1;strokeColor=#9673a6" edge="1" parent="1" source="copyRead" target="consumer"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="a2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;dashed=1;strokeColor=#9673a6" edge="1" parent="1" source="zcRead" target="consumer"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
<mxCell id="a3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block" edge="1" parent="1" source="consumer" target="close"><mxGeometry relative="1" as="geometry"/></mxCell>
|
|
</root>
|
|
</mxGraphModel>
|
|
</diagram>
|
|
</mxfile>
|