STRUCT TYPEC_ALTMODE_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 a struct typec_altmode *altmode and a u32 *vdo pointer. Slay. πŸ’…
  • exit β€” The operations to be executed with the Exit Mode Command. Opposite vibes: time to shut it down. Takes just the struct typec_altmode *altmode. Bye bestie. πŸ‘‹
  • attention β€” Callback for an Attention Command. The kernel is like "hey, notice me," and this callback gets struct typec_altmode *altmode and a u32 vdo. It's the ping of the alt mode world. πŸ””
  • vdm β€” Callback for SVID specific commands. This one is the most extra: it takes struct typec_altmode *altmode, const u32 hdr, const u32 *vdo, and int cnt. Standard or Vendor Defined Message? Either way, it's handled here. Iconic. ✨
  • notify β€” The communication channel for platform and the alternate mode. Gets struct typec_altmode *altmode, unsigned long conf, and void *data. This is how the platform and the alt mode gossip with each other. πŸ—£οΈ
  • activate β€” The user callback for Enter/Exit Mode. Takes struct typec_altmode *altmode and int 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:

⚠️ 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