/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * daedalus-v4l2 — kernel-internal device/state declarations. * * Shared between daedalus_v4l2_main.c (V4L2 m2m driver) and * daedalus_v4l2_chardev.c (kernel↔daemon bridge). The chardev * needs to look up in-flight V4L2 requests by cookie to complete * the m2m job when RESP_FRAME arrives — that path lives in * daedalus_complete_resp_frame(). */ #ifndef DAEDALUS_V4L2_MAIN_H #define DAEDALUS_V4L2_MAIN_H #include #include #include #include #include #include #include "daedalus_v4l2_proto.h" /** * struct daedalus_dev - top-level device state (singleton for now) * @pdev: owning platform device (synthesised in module_init) * @v4l2_dev: V4L2 device parent for any video_device we register * @vdev: video_device exposed as /dev/videoNN * @m2m_dev: mem2mem device shared by all per-open contexts * @m2m_lock: serialises vb2 queue + v4l2 ioctl ops * @inflight: list of struct daedalus_inflight (REQ_DECODE sent, * RESP_FRAME not yet returned) * @inflight_lock: protects @inflight * * Singleton per-module instance. Multi-instance support (one * decoder per /dev/videoNN) would require breaking g_daedalus_dev * out of daedalus_v4l2_main.c; not needed yet. */ struct daedalus_dev { struct platform_device *pdev; struct v4l2_device v4l2_dev; struct video_device vdev; struct v4l2_m2m_dev *m2m_dev; struct mutex m2m_lock; struct list_head inflight; struct mutex inflight_lock; }; /* Module-wide singleton accessor (chardev needs this for RESP_FRAME). */ struct daedalus_dev *daedalus_get_dev(void); /** * daedalus_complete_resp_frame() - chardev RESP_FRAME completion * @cookie: cookie carried by the matching REQ_DECODE * @fr: RESP_FRAME header from the daemon * @pixels: inline pixel bytes following the header in the * chardev payload (may be NULL if @pixels_len == 0) * @pixels_len: number of inline pixel bytes * * Called from the chardev write() path on RESP_FRAME. Looks up * the in-flight request, copies inline pixel data into the * CAPTURE vb2 buffer if available, then completes both src+dst * buffers and finishes the m2m job. Silently drops responses * for unknown cookies (pr_warn_ratelimited). */ void daedalus_complete_resp_frame(u32 cookie, const struct daedalus_resp_frame *fr, const u8 *pixels, size_t pixels_len); #endif /* DAEDALUS_V4L2_MAIN_H */