Phase 8.7: media controller + multi-frame streaming verification
Two pieces — both shipped:
1. Media controller binding closes the last v4l2-compliance
failure from 8.6 (DECODER_CMD, which requires has_media on
stateless decoders) and unlocks the V4L2 request API for
libva-v4l2-request.
2. Multi-frame streaming test exercises the daemon's
AVCodecContext state preservation across many REQ_DECODE
calls — Phase 8.6's tests pushed exactly one keyframe per
invocation; real content has P-frame references.
Compliance now reaches **49/49 passing.**
Kernel (kernel/daedalus_v4l2_main.{c,h}):
- Added `struct media_device mdev` to daedalus_dev.
- media_device_init(&mdev) BEFORE v4l2_device_register so
v4l2-core sees v4l2_dev.mdev = &mdev and binds the m2m
entities into the graph during register.
- After video_register_device:
v4l2_m2m_register_media_controller(..., MEDIA_ENT_F_PROC_VIDEO_DECODER)
then media_device_register so userspace sees the complete
graph in /dev/mediaN with the decoder entity tagged.
- daedalus_remove unwinds in reverse: unregister media,
unregister mc, unregister video, release m2m, unregister
v4l2, cleanup mdev.
- Error paths added for both new failure points.
Test harness (tools/test_m2m_stream.c, new):
- Multi-frame V4L2 m2m client: parses IVF → 4-deep buffer
rings on both queues → per-frame QBUF/DQBUF loop →
concatenates decoded NV12 to output file. Returns 0 only
if every input frame decoded without error.
- Same codec vocabulary as test_m2m_decode (vp9 | av1 |
h264 via 5th arg).
Verification on hertz (Pi 5, 6.12.75+rpt-rpi-2712):
v4l2-compliance: 49 tests, 49 passed, 0 failed, 0 warnings.
$ v4l2-ctl --list-devices
daedalus-fourier V3D7+NEON (platform:daedalus_v4l2):
/dev/video0
/dev/media3
VP9 320×240 30 frames (1 keyframe + 29 P-frames, 3.46 MB
NV12): byte-for-byte match vs `ffmpeg -i in.ivf -pix_fmt
nv12 -f rawvideo`.
VP9 1920×1080 10 frames (31 MB NV12 through the dmabuf
path): byte-for-byte match vs same reference command.
Daemon log shows cookies 1..30 all completing cleanly in
order; lazily-opened AVCodecContext maintains reference
frames across the chardev round-trips.
Clean SIGTERM + rmmod, no oops/WARN.
Roadmap update (docs/roadmap.md):
- 8.7 marked closed with closure-doc reference.
- 8.8 reshaped: perf profiling, QPU dispatch substitution
via daedalus-fourier, multi-frame AV1/H.264, HDR (P010M).
Per correctness-before-speed:
- Order-correct media controller lifecycle (init → bind
v4l2_dev → register video → register mc → register
media; reverse for teardown).
- 4-deep buffer rings on both queues — the scheduler
actually pipelines multiple in-flight cookies through
the chardev (not just one-at-a-time as in 8.5/8.6 tests).
- Bit-exact comparison against ffmpeg, not "looks right."
- All resource paths cleaned on every error branch.
Phase 8.8 next: profile daemon hot loops, dlopen
daedalus-fourier from the daemon, swap FFmpeg per-block
calls for daedalus_dispatch_* where the kernel matches,
target 30fps@1080p from 30fps-floor-is-fine memory.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,8 @@
|
||||
#include <media/v4l2-mem2mem.h>
|
||||
#include <media/v4l2-ctrls.h>
|
||||
#include <media/v4l2-event.h>
|
||||
#include <media/media-device.h>
|
||||
#include <media/media-entity.h>
|
||||
#include <media/videobuf2-v4l2.h>
|
||||
#include <media/videobuf2-dma-contig.h>
|
||||
|
||||
@@ -908,9 +910,23 @@ static int daedalus_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the media controller BEFORE v4l2_device_register
|
||||
* binds the mdev so v4l2-core publishes the link between
|
||||
* the v4l2_device and the media_device. Stateless decoders
|
||||
* are required by spec to expose a media controller (the
|
||||
* request API rides on it) — v4l2-compliance's DECODER_CMD
|
||||
* test rejects drivers without it.
|
||||
*/
|
||||
dev->mdev.dev = &pdev->dev;
|
||||
strscpy(dev->mdev.model, "daedalus-v4l2", sizeof(dev->mdev.model));
|
||||
media_device_init(&dev->mdev);
|
||||
dev->v4l2_dev.mdev = &dev->mdev;
|
||||
|
||||
ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "v4l2_device_register: %d\n", ret);
|
||||
media_device_cleanup(&dev->mdev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -938,16 +954,41 @@ static int daedalus_probe(struct platform_device *pdev)
|
||||
goto err_m2m;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register the m2m entities with the media controller
|
||||
* AFTER video_register_device so vdev->num is set.
|
||||
* MEDIA_ENT_F_PROC_VIDEO_DECODER tags us as a decoder
|
||||
* entity in the graph — what libva-v4l2-request scans for.
|
||||
*/
|
||||
ret = v4l2_m2m_register_media_controller(dev->m2m_dev, &dev->vdev,
|
||||
MEDIA_ENT_F_PROC_VIDEO_DECODER);
|
||||
if (ret) {
|
||||
v4l2_err(&dev->v4l2_dev,
|
||||
"v4l2_m2m_register_media_controller: %d\n", ret);
|
||||
goto err_vdev;
|
||||
}
|
||||
|
||||
ret = media_device_register(&dev->mdev);
|
||||
if (ret) {
|
||||
v4l2_err(&dev->v4l2_dev, "media_device_register: %d\n", ret);
|
||||
goto err_m2m_mc;
|
||||
}
|
||||
|
||||
g_daedalus_dev = dev;
|
||||
v4l2_info(&dev->v4l2_dev,
|
||||
"daedalus-v4l2 m2m registered as /dev/video%d (Phase 8.5)\n",
|
||||
"daedalus-v4l2 m2m registered as /dev/video%d (Phase 8.7)\n",
|
||||
dev->vdev.num);
|
||||
return 0;
|
||||
|
||||
err_m2m_mc:
|
||||
v4l2_m2m_unregister_media_controller(dev->m2m_dev);
|
||||
err_vdev:
|
||||
video_unregister_device(&dev->vdev);
|
||||
err_m2m:
|
||||
v4l2_m2m_release(dev->m2m_dev);
|
||||
err_v4l2_dev:
|
||||
v4l2_device_unregister(&dev->v4l2_dev);
|
||||
media_device_cleanup(&dev->mdev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -956,9 +997,12 @@ static void daedalus_remove(struct platform_device *pdev)
|
||||
struct daedalus_dev *dev = platform_get_drvdata(pdev);
|
||||
|
||||
g_daedalus_dev = NULL;
|
||||
media_device_unregister(&dev->mdev);
|
||||
v4l2_m2m_unregister_media_controller(dev->m2m_dev);
|
||||
video_unregister_device(&dev->vdev);
|
||||
v4l2_m2m_release(dev->m2m_dev);
|
||||
v4l2_device_unregister(&dev->v4l2_dev);
|
||||
media_device_cleanup(&dev->mdev);
|
||||
}
|
||||
|
||||
static struct platform_driver daedalus_platform_driver = {
|
||||
|
||||
Reference in New Issue
Block a user