STRUCT DMX_DEMUX(9)
β¨ NAME β¨
okay so this is struct dmx_demux from the Kernel API Manual, aka the structure that contains the demux capabilities and callbacks π
that's the whole assignment bestie: capabilities + callbacks, all bundled in one iconic little struct.
think of it as the main character of the demux world β every demux out there has one of these, and it's where the kernel goes "hey, what can you do, and who do I call when I need something done?" π
πΈ SYNOPSIS πΈ
here's the whole thing, laid out exactly how it lives in the headers β no cap, this is verbatim:
struct dmx_demux {
enum dmx_demux_caps capabilities;
struct dmx_frontend *frontend;
void *priv;
int (*open)(struct dmx_demux *demux);
int (*close)(struct dmx_demux *demux);
int (*write)(struct dmx_demux *demux, const char __user *buf, size_t count);
int (*allocate_ts_feed)(struct dmx_demux *demux, struct dmx_ts_feed **feed, dmx_ts_cb callback);
int (*release_ts_feed)(struct dmx_demux *demux, struct dmx_ts_feed *feed);
int (*allocate_section_feed)(struct dmx_demux *demux, struct dmx_section_feed **feed, dmx_section_cb callback);
int (*release_section_feed)(struct dmx_demux *demux, struct dmx_section_feed *feed);
int (*add_frontend)(struct dmx_demux *demux, struct dmx_frontend *frontend);
int (*remove_frontend)(struct dmx_demux *demux, struct dmx_frontend *frontend);
struct list_head *(*get_frontends)(struct dmx_demux *demux);
int (*connect_frontend)(struct dmx_demux *demux, struct dmx_frontend *frontend);
int (*disconnect_frontend)(struct dmx_demux *demux);
int (*get_pes_pids)(struct dmx_demux *demux, u16 *pids);
};
π¦ meet the members (16 of them, all slaying)
let's do a little roll call so nothing gets lost, k? every single field, right here, no skipping π
enum dmx_demux_caps capabilities;β the capabilities field, typedenum dmx_demux_caps. it's literally the struct's whole personality.struct dmx_frontend *frontend;β a pointer to astruct dmx_frontend. yes girl, frontend, in a demux struct, we love a crossover episode.void *priv;β the classicvoid *privprivate-data slot. every good struct has one π«Άint (*open)(struct dmx_demux *demux);β theopencallback. takes the demux, returns anint.int (*close)(struct dmx_demux *demux);β theclosecallback. also demux in,intout. the matching set, periodt.int (*write)(struct dmx_demux *demux, const char __user *buf, size_t count);β thewritecallback, and it's givingconst char __user *bufplus asize_t count. note the__userβ that buffer is coming from userspace, iykyk πint (*allocate_ts_feed)(struct dmx_demux *demux, struct dmx_ts_feed **feed, dmx_ts_cb callback);β allocates a TS feed. double pointer onstruct dmx_ts_feed **feedso the caller gets the handle back, plus admx_ts_cb callback. iconic.int (*release_ts_feed)(struct dmx_demux *demux, struct dmx_ts_feed *feed);β the cleanup counterpart. single pointer this time,struct dmx_ts_feed *feed. balance β¨int (*allocate_section_feed)(struct dmx_demux *demux, struct dmx_section_feed **feed, dmx_section_cb callback);β same energy as the TS one but for sections:struct dmx_section_feed **feedand admx_section_cb callback.int (*release_section_feed)(struct dmx_demux *demux, struct dmx_section_feed *feed);β releases it.struct dmx_section_feed *feed, oneintreturn. we stan a matching pair πint (*add_frontend)(struct dmx_demux *demux, struct dmx_frontend *frontend);β adds a frontend. takes the demux and astruct dmx_frontend *frontend.int (*remove_frontend)(struct dmx_demux *demux, struct dmx_frontend *frontend);β removes one. same args, sameint. add/remove, the duo of all time.struct list_head *(*get_frontends)(struct dmx_demux *demux);β ok this one is chef's kiss: it's a function pointer that returns astruct list_head *. note the signature β it takes onlydemux, and it hands you back a list head. π₯int (*connect_frontend)(struct dmx_demux *demux, struct dmx_frontend *frontend);β connect a frontend. demux +struct dmx_frontend *frontend, returnsint.int (*disconnect_frontend)(struct dmx_demux *demux);β and here's the little plot twist:disconnect_frontendtakes only the demux. no frontend argument. she doesn't need one. main character energy fr fr πint (*get_pes_pids)(struct dmx_demux *demux, u16 *pids);β the last one, and it's givingu16 *pids. hands you pids via pointer, returnsint. a closer. π
heads up bestie: that's the whole struct as written β capabilities field, frontend pointer, priv, and all those callbacks. the deep lore on what each one actually does is coming in the next part, so don't go anywhere π
β¨ MEMBERS β¨
Okay bestie, this is the actual meat of struct dmx_demux β every single field and function pointer, no skips, let's go π
capabilitiesβ a bitfield of capability flags. that's it, that's the whole vibe β¨frontendβ the front-end that's connected to the demux π«Άprivβ a pointer to the private data of the API client. it's giving "my stuff, don't touch" πopenβ this function reserves the demux for use by the caller and, if necessary, initializes the demux. when the demux isn't needed anymore, you callclose. it should be possible for multiple clients to access the demux at the same time β so the implementation should increment the demux usage count whenopenis called and decrement it whencloseis called. thedemuxfunction parameter holds a pointer to the demux API and instance data. It returns:0on success;-EUSERS, if maximum usage count was reached;-EINVAL, on bad parameter.closeβ okay so the original text here is literally a copy of theopendescription (iconic of it, honestly π), but the actual deets: when the demux is no longer needed, this function should be called. multiple clients can access the demux at the same time, so the implementation should increment the demux usage count whenopenis called and decrement it whencloseis called. thedemuxfunction parameter holds a pointer to the demux API and instance data. It returns:0on success;-ENODEV, if demux was not in use (e. g. no users);-EINVAL, on bad parameter.writeβ this function hands the demux driver a memory buffer containing TS packets. instead of receiving TS packets from the DVB front-end, the demux driver software will read packets from memory π₯ any clients of this demux with active TS, PES or Section filters will receive filtered data via the Demux callback API (see0). the function returns when all the data in the buffer has been consumed by the demux. demux hardware typically cannot read TS from memory β if that's the case, memory-based filtering has to be implemented entirely in software, no cap π Thedemuxfunction parameter holds a pointer to the demux API and instance data. Thebuffunction parameter holds a pointer to the TS data in kernel-space memory. Thecountfunction parameter holds the length of the TS data. It returns:0on success;-ERESTARTSYS, if mutex lock was interrupted;-EINTR, if a signal handling is pending;-ENODEV, if demux was removed;-EINVAL, on bad parameter.allocate_ts_feedβ allocates a new TS feed, which is used to filter the TS packets carrying a certain PID. the TS feed normally corresponds to a hardware PID filter on the demux chip π― Thedemuxfunction parameter holds a pointer to the demux API and instance data. Thefeedfunction parameter holds a pointer to the TS feed API and instance data. Thecallbackfunction parameter holds a pointer to the callback function for passing received TS packet. It returns:0on success;-ERESTARTSYS, if mutex lock was interrupted;-EBUSY, if no more TS feeds is available;-EINVAL, on bad parameter.release_ts_feedβ releases the resources allocated withallocate_ts_feed. any filtering in progress on the TS feed should be stopped before calling this function, bestie, don't skip that step π Thedemuxfunction parameter holds a pointer to the demux API and instance data. Thefeedfunction parameter holds a pointer to the TS feed API and instance data. It returns:0on success;-EINVALon bad parameter.allocate_section_feedβ allocates a new section feed, i.e. a demux resource for filtering and receiving sections. on platforms with hardware support for section filtering, a section feed is directly mapped to the demux HW. on other platforms, TS packets are first PID filtered in hardware and a hardware section filter then emulated in software π§ the caller obtains an API pointer of typedmx_section_feed_tas an out parameter β using this API the caller can set filtering parameters and start receiving sections. Thedemuxfunction parameter holds a pointer to the demux API and instance data. Thefeedfunction parameter holds a pointer to the TS feed API and instance data. Thecallbackfunction parameter holds a pointer to the callback function for passing received TS packet. It returns:0on success;-EBUSY, if no more TS feeds is available;-EINVAL, on bad parameter.release_section_feedβ releases the resources allocated withallocate_section_feed, including allocated filters. any filtering in progress on the section feed should be stopped before calling this function π Thedemuxfunction parameter holds a pointer to the demux API and instance data. Thefeedfunction parameter holds a pointer to the TS feed API and instance data. It returns:0on success;-EINVAL, on bad parameter.add_frontendβ registers a connectivity between a demux and a front-end, i.e., it indicates that the demux can be connected via a call toconnect_frontendto use the given front-end as a TS source. the client of this function has to allocate dynamic or static memory for thefrontendstructure and initialize its fields before calling this function. this function is normally called during the driver initialization. the caller must not free the memory of thefrontendstruct before successfully callingremove_frontendβ like, do not do that, fr fr πΈ Thedemuxfunction parameter holds a pointer to the demux API and instance data. Thefrontendfunction parameter holds a pointer to the front-end instance data. It returns:0on success;-EINVAL, on bad parameter.remove_frontendβ indicates that the given front-end, registered by a call toadd_frontend, can no longer be connected as a TS source by this demux. the function should be called when a front-end driver or a demux driver is removed from the system. if the front-end is in use, the function fails with the return value of-EBUSY. after successfully calling this function, the caller can free the memory of thefrontendstruct if it was dynamically allocated before theadd_frontendoperation β¨ Thedemuxfunction parameter holds a pointer to the demux API and instance data. Thefrontendfunction parameter holds a pointer to the front-end instance data. It returns:0on success;-ENODEV, if the front-end was not found,-EINVAL, on bad parameter.get_frontendsβ provides the APIs of the front-ends that have been registered for this demux. any of the front-ends obtained with this call can be used as a parameter forconnect_frontend. the include filedemux.hcontains the macroDMX_FE_ENTRYfor converting an element of the generic typestruct list_head *to the typestruct dmx_frontend *π¦ the caller must not free the memory of any of the elements obtained via this function call β hands off, those aren't yours π Thedemuxfunction parameter holds a pointer to the demux API and instance data. It returns astruct list_headpointer to the list of front-end interfaces, orNULLin the case of an empty list.connect_frontendβ connects the TS output of the front-end to the input of the demux π a demux can only be connected to a front-end registered to the demux with the functionadd_frontend. it may or may not be possible to connect multiple demuxes to the same front-end, depending on the capabilities of the HW platform. when not used, the front-end should be released by callingdisconnect_frontend. Thedemuxfunction parameter holds a pointer to the demux API and instance data. Thefrontendfunction parameter holds a pointer to the front-end instance data. It returns:0on success;-EINVAL, on bad parameter.disconnect_frontendβ disconnects the demux and a front-end previously connected by aconnect_frontendcall βοΈ Thedemuxfunction parameter holds a pointer to the demux API and instance data. It returns:0on success;-EINVALon bad parameter.get_pes_pidsβ get the PIDs forDMX_PES_AUDIO0,DMX_PES_VIDEO0,DMX_PES_TELETEXT0,DMX_PES_SUBTITLE0andDMX_PES_PCR0π Thedemuxfunction parameter holds a pointer to the demux API and instance data. Thepidsfunction parameter holds an array with fiveu16elements where the PIDs will be stored. It returns:0on success;-EINVALon bad parameter.
π SEE ALSO π
Kernel file ./include/media/demux.h enum ts_filter_type(9), struct dmx_ts_feed(9), struct dmx_section_filter(9), struct dmx_section_feed(9), dmx_ts_cb(9), dmx_section_cb(9), enum dmx_frontend_source(9), struct dmx_frontend(9), enum dmx_demux_caps(9), DMX_FE_ENTRY(9)
okay that's the whole page, you ate that π this lil beauty lives in ./include/media and the version is from October 2026, page struct dmx_demux(9) β go forth and demux, bestie, 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