STRUCT MEDIA_DEVICE_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ NAME πŸŽ€

okay so bestie, this is struct media_device_ops β€” the media device operations struct πŸ’… like, it's the lil bundle of function pointers that tells a media device how to behave. from the struct media_device_ops(9) page in the Kernel API Manual, and yes we're getting into it ✨


🌸 SYNOPSIS 🌸

struct media_device_ops {
    int (*link_notify)(struct media_link *link, u32 flags, unsigned int
notification);
    struct media_request *(*req_alloc)(struct media_device *mdev);
    void (*req_free)(struct media_request *req);
    int (*req_validate)(struct media_request *req);
    void (*req_queue)(struct media_request *req);
 };

lowkey iconic struct ngl 🫢


✨ Members ✨

  • link_notify β€” the link state change notification callback πŸ¦‹ bestie this one gets called with the graph_mutex held, so like… be aware ok?
  • req_alloc β€” allocates a request. set this if you need to allocate a struct larger then struct media_request πŸ‘‘ and heads up: req_alloc and req_free must either both be set or both be NULL β€” no mix-and-match, it's giving all or nothing πŸ’€
  • req_free β€” frees a request. set this if req_alloc was set as well, otherwise leave it to NULL πŸŽ€ they're a matching set fr fr
  • req_validate β€” validates a request, but does not queue it yet πŸ™ˆ the req_queue_mutex lock is held when this op is called, so yeah, mind that πŸ”₯
  • req_queue β€” queues up a validated request, and it cannot fail πŸ’… if something goes wrong while queueing this request, then it should be marked as such internally in the driver, and any related buffers must eventually return to vb2 with state VB2_BUF_STATE_ERROR 😭

the req_queue_mutex lock is held when this op is called too. and listen β€” it is important that vb2 buffer objects are queued last, after all other object types are queued πŸ‘‘ because queueing a buffer kickstarts the request processing, so like, all other objects related to the request (and thus the buffer) must be available to the driver. and once a buffer is queued, then the driver can complete or delete objects from the request before req_queue exits 🌟 main character timing honestly


πŸ¦‹ SEE ALSO πŸ¦‹

kernel file ./include/media/media-device.h β€” plus these besties πŸ’–


and that's the whole vibe check 🧚 this one lives in ./include/media, dated October 2026, straight from the Kernel API Manual β€” go read the source, slay, periodt πŸ’œπŸŒΈ
πŸ“¦ where this page comes from