STRUCT V4L2_M2M_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… NAME

struct v4l2_m2m_ops(9) β€” the mem-to-mem device driver callbacks, bestie. It's the struct v4l2_m2m_ops from the Kernel API Manual, section 9, and it's literally the whole personality of a mem2mem driver. πŸŽ€


✨ SYNOPSIS

struct v4l2_m2m_ops {
    void (*device_run)(void *priv);
    int (*job_ready)(void *priv);
    void (*job_abort)(void *priv);
 };

okay so it's just three little function pointers and a void *priv that gets passed to every single one of them. that's the whole vibe. πŸ¦‹


🌸 MEMBERS

  • device_run β€” required, no skips βœ‹. This is where the actual job (the transaction) begins β€” inside this callback. And here's the iconic part: the job does NOT have to end before this callback returns, and ngl that's gonna be the usual case. When the job does finish, you gotta call v4l2_m2m_job_finish or v4l2_m2m_buf_done_and_job_finish. That's the rule, periodt. πŸ”₯
  • job_ready β€” optional 🫢. Should return 0 if the driver doesn't have a job fully prepared to run yet β€” like, it won't be able to finish a transaction without sleeping. If you don't provide it, it's assumed that one source buffer and one destination buffer are all the driver needs to perform one full transaction. ⚠️ Real talk: this method may not sleep. Not even a little. 😭
  • job_abort β€” optional 🧚. Tells the driver it has to abort the currently running transaction as SOON as possible β€” like, as soon as it can stop the device safely, e.g. in the next interrupt handler β€” even if the transaction wouldn't have finished by then. After the driver does the necessary steps, it has to call v4l2_m2m_job_finish or v4l2_m2m_buf_done_and_job_finish as if the transaction ended normally. And this function does not have to wait until the device enters a state where it can be stopped β€” and usually it won't. it's giving "don't wait up" πŸ’€

πŸ¦‹ SEE ALSO

Kernel file ./include/media/v4l2-mem2mem.h β€” the mothership 🏠 and all her children:

struct v4l2_m2m_queue_ctx(9), struct v4l2_m2m_ctx(9), struct v4l2_m2m_buffer(9), v4l2_m2m_get_curr_priv(9), v4l2_m2m_get_vq(9), v4l2_m2m_try_schedule(9), v4l2_m2m_job_finish(9), v4l2_m2m_buf_done_and_job_finish(9), v4l2_m2m_clear_state(9), v4l2_m2m_mark_stopped(9), v4l2_m2m_dst_buf_is_last(9), v4l2_m2m_has_stopped(9), v4l2_m2m_is_last_draining_src_buf(9), v4l2_m2m_last_buffer_done(9), v4l2_m2m_suspend(9), v4l2_m2m_resume(9), v4l2_m2m_reqbufs(9), v4l2_m2m_querybuf(9), v4l2_m2m_qbuf(9), v4l2_m2m_dqbuf(9), v4l2_m2m_prepare_buf(9), v4l2_m2m_create_bufs(9), v4l2_m2m_expbuf(9), v4l2_m2m_streamon(9), v4l2_m2m_streamoff(9), v4l2_m2m_update_start_streaming_state(9), v4l2_m2m_update_stop_streaming_state(9), v4l2_m2m_encoder_cmd(9), v4l2_m2m_decoder_cmd(9), v4l2_m2m_poll(9), v4l2_m2m_mmap(9), v4l2_m2m_init(9), v4l2_m2m_release(9), v4l2_m2m_get(9), v4l2_m2m_put(9), v4l2_m2m_ctx_init(9), v4l2_m2m_ctx_release(9), v4l2_m2m_buf_queue(9), v4l2_m2m_num_src_bufs_ready(9), v4l2_m2m_num_dst_bufs_ready(9), v4l2_m2m_next_buf(9), v4l2_m2m_next_src_buf(9), v4l2_m2m_next_dst_buf(9), v4l2_m2m_last_buf(9), v4l2_m2m_last_src_buf(9), v4l2_m2m_last_dst_buf(9), v4l2_m2m_for_each_dst_buf(9), v4l2_m2m_for_each_src_buf(9), v4l2_m2m_for_each_dst_buf_safe(9), v4l2_m2m_for_each_src_buf_safe(9), v4l2_m2m_get_src_vq(9), v4l2_m2m_get_dst_vq(9), v4l2_m2m_buf_remove(9), v4l2_m2m_src_buf_remove(9), v4l2_m2m_dst_buf_remove(9), v4l2_m2m_buf_remove_by_buf(9), v4l2_m2m_src_buf_remove_by_buf(9), v4l2_m2m_dst_buf_remove_by_buf(9), v4l2_m2m_buf_copy_metadata(9)

like genuinely that's a whole friend group πŸ’œ


okay that's the page!! 🌈 this one came from ./include/media, and it's dated October 2026 β€” shoutout to the kernel docs girlies who keep it cute and accurate, ily πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from