STRUCT TYPEC_ALTMODE_OPS(9)
π STRUCT TYPEC_ALTMODE_OPS(9) π
Okay bestie, so you know how USB-C does that whole alternate mode thing where your laptop can suddenly output HDMI or whatever through a tiny reversible port? Yeah, this struct is literally the plug for that. It's the Alternate mode specific operations vector β think of it as the group chat where your driver tells the Type-C subsystem what it can do and how to do it. Fr fr, it's giving "responsibilities" energy. π
This is a kernel API manual thing, so it's all struct typec_altmode_ops(9), and yes, you will need it if you're writing a Type-C alt mode driver. No cap.
β¨ SYNOPSIS β¨
struct typec_altmode_ops {
int (*enter)(struct typec_altmode *altmode, u32 *vdo);
int (*exit)(struct typec_altmode *altmode);
void (*attention)(struct typec_altmode *altmode, u32 vdo);
int (*vdm)(struct typec_altmode *altmode, const u32 hdr, const u32
*vdo, int cnt);
int (*notify)(struct typec_altmode *altmode, unsigned long conf,
void *data);
int (*activate)(struct typec_altmode *altmode, int activate);
};
Like, this is the whole menu. Every single function pointer is a little hook where the kernel can call into your driver when something goes down. π«Ά
πΈ MEMBERS πΈ
enterβ The operations to be executed with the Enter Mode Command. Basically, when the system asks your alternate mode to activate, this fires. It gets astruct typec_altmode *altmodeand au32 *vdopointer. Slay. πexitβ The operations to be executed with the Exit Mode Command. Opposite vibes: time to shut it down. Takes just thestruct typec_altmode *altmode. Bye bestie. πattentionβ Callback for an Attention Command. The kernel is like "hey, notice me," and this callback getsstruct typec_altmode *altmodeand au32 vdo. It's the ping of the alt mode world. πvdmβ Callback for SVID specific commands. This one is the most extra: it takesstruct typec_altmode *altmode,const u32 hdr,const u32 *vdo, andint cnt. Standard or Vendor Defined Message? Either way, it's handled here. Iconic. β¨notifyβ The communication channel for platform and the alternate mode. Getsstruct typec_altmode *altmode,unsigned long conf, andvoid *data. This is how the platform and the alt mode gossip with each other. π£οΈactivateβ The user callback for Enter/Exit Mode. Takesstruct typec_altmode *altmodeandint activate. So when the user (or system) wants to flip the switch, this is the hook that gets called. Main character energy, honestly. π
π¦ SEE ALSO π¦
Bestie, the full squad is here β all referenced from the Kernel file ./include/linux/usb/typec_altmode.h. Read them, love them, link against them:
struct typec_altmode(9)struct typec_cable_ops(9)typec_altmode_get_cable_svdm_version(9)typec_altmode_get_orientation(9)typec_altmode_get_svdm_version(9)typec_altmode_get_data_role(9)struct typec_altmode_driver(9)typec_altmode_register_driver(9)typec_altmode_unregister_driver(9)typec_mode_selection_start(9)typec_altmode_state_update(9)typec_mode_selection_delete(9)
β οΈ Real talk: if you're implementing these callbacks, make sure you know what you're doing β this is kernel-space, so a bad pointer here is not a vibe. No crashing the whole system, mmmkay? π
And that's the tea, bestie. This page is from the Kernel API Manual and it lives at ./include/linux/usb. Date on the original? October 2026. So like, future vibes. π Go forth and write your alt mode driver, and remember: every function pointer is a promise. 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