STRUCT V4L2_SUBDEV_CORE_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct v4l2_subdev_core_ops(9) β€” from the Kernel API Manual, but make it fashion ✨

okay so picture this: you're writing a V4L2 subdev driver, and the kernel wants to know which core callbacks you're bringing to the function-pointer party. that's this struct, bestie. it's the ~core ops~ section of the whole subdev ops situation β€” let's get into it πŸŽ€


✨ NAME ✨

struct v4l2_subdev_core_ops β€” literally the place where you define core ops callbacks for subdevs. no cap.


🌸 SYNOPSIS 🌸

struct v4l2_subdev_core_ops {
    int (*log_status)(struct v4l2_subdev *sd);
    int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n, struct
v4l2_subdev_io_pin_config *pincfg);
    int (*init)(struct v4l2_subdev *sd, u32 val);
    int (*load_fw)(struct v4l2_subdev *sd);
    int (*reset)(struct v4l2_subdev *sd, u32 val);
    int (*s_gpio)(struct v4l2_subdev *sd, u32 val);
    long (*command)(struct v4l2_subdev *sd, unsigned int cmd, void
*arg);
    long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
  #ifdef CONFIG_COMPAT;
    long (*compat_ioctl32)(struct v4l2_subdev *sd, unsigned int cmd,
unsigned long arg);
  #endif;
  #ifdef CONFIG_VIDEO_ADV_DEBUG;
    int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register
*reg);
    int (*s_register)(struct v4l2_subdev *sd, const struct
v4l2_dbg_register *reg);
  #endif;
    int (*s_power)(struct v4l2_subdev *sd, int on);
    int (*interrupt_service_routine)(struct v4l2_subdev *sd, u32 status,
bool *handled);
    int (*subscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
struct v4l2_event_subscription *sub);
    int (*unsubscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
struct v4l2_event_subscription *sub);
 };

yes the #ifdefs have semicolons after them, i don't make the rules, i just report them πŸ’€


πŸ¦‹ Members πŸ¦‹

  • log_status β€” the callback that backs the VIDIOC_LOG_STATUS ioctl handler code. your ✨status dump✨ moment.
  • s_io_pin_config β€” configure one or more chip I/O pins, for chips that multiplex different internal signal pads out to IO pins. it takes a pointer to an array of n pin configuration entries, one for each pin being configured. and heads up: this function could be called at times other than just subdevice initialization, so don't assume it's an init-only thing 🫢
  • init β€” initialize the sensor registers to some sort of reasonable default values. 🚨 but do not use for new drivers, and it should be removed in existing drivers. it's giving legacy, respectfully.
  • load_fw β€” load firmware. short, sweet, iconic. πŸŽ€
  • reset β€” the generic reset command. the argument selects which subsystems to reset, and passing 0 will always reset the whole chip. 🚨 do not use for new drivers without discussing this first on the linux-media mailinglist. there should be no reason normally to reset a device. fr fr, like why are we resetting.
  • s_gpio β€” set GPIO pins. very simple right now; might need to be extended with a direction argument if needed. she's a work in progress and we love her πŸ’…
  • command β€” called by in-kernel drivers in order to call functions internal to subdev drivers that have a separate callback.
  • ioctl β€” called at the end of the ioctl syscall handler at the V4L2 core. used to provide support for private ioctls used on the driver. private ioctls only, iykyk.
  • compat_ioctl32 β€” only shows up #ifdef CONFIG_COMPAT. called when a 32 bits application uses a 64 bits Kernel, in order to fix data passed from/to userspace. she's the compatibility icon 🌈
  • g_register β€” only shows up #ifdef CONFIG_VIDEO_ADV_DEBUG. callback for VIDIOC_DBG_G_REGISTER ioctl handler code.
  • s_register β€” same #ifdef CONFIG_VIDEO_ADV_DEBUG energy. callback for VIDIOC_DBG_S_REGISTER ioctl handler code.
  • s_power β€” puts the subdevice in power saving mode (on == 0) or normal operation mode (on == 1). 🚨 DEPRECATED, bestie. see Documentation/driver-api/media/camera-sensor.rst. the pre_streamon and post_streamoff callbacks can be used for e.g. setting the bus to LP-11 mode before s_stream is called.
  • interrupt_service_routine β€” called by the bridge chip's interrupt service handler, when an interrupt status has been raised due to this subdev, so that this subdev can handle the details. it may schedule work to be performed later. it must not sleep. πŸ’€ Called from an IRQ context. like, seriously, do not sleep in there.
  • subscribe_event β€” used by the drivers to request the control framework that for it to be warned when the value of a control changes. bestie wants a notification and bestie shall receive one πŸ””
  • unsubscribe_event β€” remove event subscription from the control framework. leaving the group chat, no hard feelings πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

the entire extended fam, no gatekeeping πŸ’– β€” Kernel file ./include/media/v4l2-subdev.h, struct v4l2_decode_vbi_line(9), enum v4l2_subdev_io_pin_bits(9), struct v4l2_subdev_io_pin_config(9), struct v4l2_subdev_tuner_ops(9), struct v4l2_subdev_audio_ops(9), struct v4l2_mbus_frame_desc_entry_csi2(9), enum v4l2_mbus_frame_desc_flags(9), struct v4l2_mbus_frame_desc_entry(9), enum v4l2_mbus_frame_desc_type(9), struct v4l2_mbus_frame_desc(9), enum v4l2_subdev_pre_streamon_flags(9), struct v4l2_subdev_video_ops(9), struct v4l2_subdev_vbi_ops(9), struct v4l2_subdev_sensor_ops(9), enum v4l2_subdev_ir_mode(9), struct v4l2_subdev_ir_parameters(9), struct v4l2_subdev_ir_ops(9), struct v4l2_subdev_pad_config(9), struct v4l2_subdev_stream_configs(9), struct v4l2_subdev_krouting(9), struct v4l2_subdev_state(9), struct v4l2_subdev_pad_ops(9), struct v4l2_subdev_ops(9), struct v4l2_subdev_internal_ops(9), struct v4l2_subdev_platform_data(9), struct v4l2_subdev(9), media_entity_to_v4l2_subdev(9), vdev_to_v4l2_subdev(9), struct v4l2_subdev_fh(9), to_v4l2_subdev_fh(9), v4l2_set_subdevdata(9), v4l2_get_subdevdata(9), v4l2_set_subdev_hostdata(9), v4l2_get_subdev_hostdata(9), v4l2_subdev_get_fwnode_pad_1_to_1(9), v4l2_subdev_link_validate_default(9), v4l2_subdev_link_validate(9), v4l2_subdev_has_pad_interdep(9), __v4l2_subdev_state_alloc(9), __v4l2_subdev_state_free(9), v4l2_subdev_init_finalize(9), v4l2_subdev_cleanup(9), v4l2_subdev_state_get_format(9), v4l2_subdev_state_get_crop(9), v4l2_subdev_state_get_compose(9), v4l2_subdev_state_get_interval(9), v4l2_subdev_get_fmt(9), v4l2_subdev_get_frame_interval(9), v4l2_subdev_set_routing(9), for_each_active_route(9), v4l2_subdev_set_routing_with_fmt(9), v4l2_subdev_routing_find_opposite_end(9), v4l2_subdev_state_get_opposite_stream_format(9), v4l2_subdev_state_xlate_streams(9), enum v4l2_subdev_routing_restriction(9), v4l2_subdev_routing_validate(9), v4l2_subdev_enable_streams(9), v4l2_subdev_disable_streams(9), v4l2_subdev_s_stream_helper(9), __v4l2_subdev_get_frame_desc_passthrough(9), v4l2_subdev_get_frame_desc_passthrough(9), v4l2_subdev_lock_state(9), v4l2_subdev_unlock_state(9), v4l2_subdev_lock_states(9), v4l2_subdev_unlock_states(9), v4l2_subdev_get_unlocked_active_state(9), v4l2_subdev_get_locked_active_state(9), v4l2_subdev_lock_and_get_active_state(9), v4l2_subdev_init(9), v4l2_subdev_call(9), v4l2_subdev_call_state_active(9), v4l2_subdev_call_state_try(9), v4l2_subdev_has_op(9), v4l2_subdev_notify_event(9), v4l2_subdev_is_streaming(9) πŸ’œ


okay that's the whole page, bestie, you ate that 🫢 β€” this came from the source ./include/media, version October 2026, and yeah, the header up there really is struct v4l2_subdev_core_ops(9) from the Kernel API Manual. go forth and be iconic, and please don't sleep in your IRQ handler πŸ’…βœ¨

πŸ“¦ where this page comes from