STRUCT CCS_QUIRK(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct ccs_quirk(9) β€” like, the whole vibe

okay so bestie, welcome to the Kernel API Manual section 9, where we talk about struct ccs_quirk ✨ β€” literally the designated coping mechanism for sensors that refuse to follow the SMIA++ standard. no cap, these are quirks for sensors that deviate from that standard, and honestly? relatable. we all deviate sometimes πŸ’…


🌸 SYNOPSIS 🌸

here's the whole struct, character for character, because we do not paraphrase code in this house:

struct ccs_quirk {
    int (*limits)(struct ccs_sensor *sensor);
    int (*post_poweron)(struct ccs_sensor *sensor);
    int (*pre_streamon)(struct ccs_sensor *sensor);
    int (*post_streamoff)(struct ccs_sensor *sensor);
    unsigned long (*pll_flags)(struct ccs_sensor *sensor);
    int (*init)(struct ccs_sensor *sensor);
    int (*reg_access)(struct ccs_sensor *sensor, bool write, u32 *reg, u32 *val);
    unsigned long flags;
 };

yes ma'am, that's eight members and one very important flags field at the end. we love a struct that knows what it is 🫢


πŸŽ€ Members πŸŽ€

like a little roster of function pointers, each one doing its own iconic thing:

  • limits β€” swaps out sensor->limits with values that genuinely can't be read from the sensor registers. it gets called the first time the sensor is powered up. so like, once. only once. main character energy, one appearance only πŸ‘‘
  • post_poweron β€” called always after the sensor has been fully powered on. no conditions, no ifs, just vibes ✨
  • pre_streamon β€” called just before streaming is enabled. a little pre-game ritual πŸŽ€
  • post_streamoff β€” called right after stopping streaming. the cool-down stretch πŸ’œ
  • pll_flags β€” returns flags for the PLL calculator. that's it, that's the whole job 🧚
  • init β€” quirk initialisation, and it's called last in probe. also the appropriate spot for adding sensor specific controls, for instance. so like, if you're gonna do it, do it here bestie πŸ’…
  • reg_access β€” the register access quirk. plot twist: the quirk may divert the access to another register, or to no register at all 😭. giving "i'll take it from here" energy
  • flags β€” quirk flags. short, sweet, iconic 🌈

✨ Description ✨

okay this part is specifically about reg_access, and the original writes it as a lovely run-on, so let's break it down but keep every single bit of it:

  • -write: is this a read (false) or a write (true) access?
  • -reg: pointer to the register to access
  • -val: register value β€” set by the caller on write, or by the quirk on read
  • -return: 0 on success, -ENOIOCTLCMD if no register access may be done by the caller (default read value is zero), else negative error code on error
ngl, that -ENOIOCTLCMD return is the one to remember fr fr β€” if the caller isn't allowed to do the register access, that's the code you get back, and the default read value comes back as zero. not optional knowledge, bestie πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

  • Kernel file ./drivers/media/i2c/ccs/ccs-quirk.h β€” go read it, iykyk πŸ’–

and that's the whole page, bestie! 🌸 this little gem lives in ./drivers/media/i2c/ccs and it's dated October 2026 β€” so mark your calendar, mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from