STRUCT MEDIA_DEVICE(9)
β¨ NAME β¨
okay bestie, this is struct media_device(9) from the Kernel API Manual β section 9, bestie, keep up β and it's literally the page for a media device struct. It's giving "abstract high-level media device" main character energy, and we're gonna go through every single member, no cap. π
π SYNOPSIS π
struct media_device {
struct device *dev;
struct media_devnode *devnode;
char model[32];
char driver_name[32];
char serial[40];
char bus_info[32];
u32 hw_revision;
u64 topology_version;
u32 id;
struct ida entity_internal_idx;
int entity_internal_idx_max;
struct list_head entities;
struct list_head interfaces;
struct list_head pads;
struct list_head links;
struct list_head entity_notify;
struct mutex graph_mutex;
struct media_graph pm_count_walk;
void *source_priv;
int (*enable_source)(struct media_entity *entity, struct
media_pipeline *pipe);
void (*disable_source)(struct media_entity *entity);
const struct media_device_ops *ops;
struct mutex req_queue_mutex;
atomic_t num_requests;
atomic_t num_request_objects;
struct dentry *media_dir;
atomic_t request_id;
};
π Members π
devβ Parent device. The whole "who's your parent" situation. π«Άdevnodeβ Media device node. The node for the media device.modelβ Device model name. This is the model-name moment.driver_nameβ Optional device driver name. If you don't set it, calls toMEDIA_IOC_DEVICE_INFOreturndev->driver->name. This is needed for USB drivers for example, because otherwise they'll all appear as if the driver name was"usb". πserialβ Device serial number (optional).bus_infoβ Unique and stable device location identifier. Stable and unique, periodt.hw_revisionβ Hardware device revision.topology_versionβ Monotonic counter for storing the version of the graph topology. Should be incremented each time the topology changes. Lowkey important: if topology changes, bump it. βidβ Unique ID used on the last registered graph object.entity_internal_idxβ Unique internal entity ID used by the graph traversal algorithms.entity_internal_idx_maxβ Allocated internal entity indices.entitiesβ List of registered entities.interfacesβ List of registered interfaces.padsβ List of registered pads.linksβ List of registered links.entity_notifyβ List of registeredentity_notifycallbacks.graph_mutexβ Protects access tostruct media_devicedata. Literally the bodyguard. πͺpm_count_walkβ Graph walk for power state walk. Access serialised usinggraph_mutex.source_privβ Driver Private data forenable_source/disable_sourcehandlers.enable_sourceβ Enable Source Handler function pointer.disable_sourceβ Disable Source Handler function pointer.opsβ Operation handler callbacks.req_queue_mutexβ Serialise theMEDIA_REQUEST_IOC_QUEUEioctl w.r.t. other operations that stop or start streaming.num_requestsβ number of associated requests.num_request_objectsβ number of associated request objects.media_dirβ DebugFS media directory.request_idβ Used to generate unique request IDs.
πΈ Description πΈ
This structure represents an abstract high-level media device. It allows easy access to entities and provides basic media device-level support. The structure can be allocated directly or embedded in a larger structure. So yes, bestie, you can have it standalone or tucked inside a bigger struct β both are valid. π¦
The parent dev is a physical device. It must be set before registering the media device. Do not skip this. It's a must, fr fr.
model is a descriptive model name exported through sysfs. It doesn't have to be unique. So no pressure to be one-of-a-kind, it's just a descriptive name. π
enable_source is a handler to find source entity for the sink entity and activate the link between them if source entity is free. Drivers should call this handler before accessing the source.
disable_source is a handler to find source entity for the sink entity and deactivate the link between them. Drivers should call this handler to release the source.
Use-case: find tuner entity connected to the decoder entity and check if it is available, and activate the link between them from enable_source and deactivate from disable_source. That's the whole little tuner-decoder situation, iykyk. π
π¨ NOTE π¨
Bridge driver is expected to implement and set the handler whenmedia_deviceis registered or when bridge driver finds themedia_deviceduring probe. Bridge driver setssource_privwith information necessary to runenable_sourceanddisable_sourcehandlers. Callers should holdgraph_mutexto access and callenable_sourceanddisable_sourcehandlers.
π¦ SEE ALSO π¦
- Kernel file
./include/media/media-device.hstructmedia_entity_notify(9) struct media_device_ops(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)
that's the whole page, bestie β source/version: ./include/media, date: October 2026. go off, you've got this ππΈ
π¦ 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