STRUCT MEDIA_DEVICE_OPS(9)
π 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 thegraph_mutexheld, so likeβ¦ be aware ok?req_allocβ allocates a request. set this if you need to allocate a struct larger thenstruct media_requestπ and heads up:req_allocandreq_freemust 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 ifreq_allocwas set as well, otherwise leave it toNULLπ they're a matching set fr frreq_validateβ validates a request, but does not queue it yet π thereq_queue_mutexlock 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 tovb2with stateVB2_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 π
struct media_entity_notify(9)struct media_device(9)media_device_init(9)media_device_cleanup(9)__media_device_register(9)media_device_register(9)media_device_unregister(9)media_device_register_entity(9)media_device_unregister_entity(9)media_device_register_entity_notify(9)media_device_unregister_entity_notify(9)media_device_pci_init(9)__media_device_usb_init(9)media_device_usb_init(9)media_set_bus_info(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms