v4l2_m2m_mmap(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… v4l2_m2m_mmap β€” the Linux Kernel API manual, bestie edition πŸŽ€

okay so this is v4l2_m2m_mmap(9) from the Kernel API Manual, and honestly? it's giving "underrated little helper that does so much for you" energy. let's get into it ✨


🌸 NAME 🌸

v4l2_m2m_mmap β€” the source-and-destination-queues-aware mmap multiplexer πŸ¦‹

like, it's the mmap bouncer that knows both queues and keeps them from getting their vibes mixed up.


✨ SYNOPSIS ✨

int v4l2_m2m_mmap (struct file *file , struct v4l2_m2m_ctx *m2m_ctx ,
struct vm_area_struct *vma );

three args, one int back. no cap, that's the whole signature πŸ‘‘


πŸ’– ARGUMENTS πŸ’–

  • file β€” pointer to struct file. yeah. that file. the one you already have. 🫢
  • m2m_ctx β€” the m2m context that's assigned to the instance, given by struct v4l2_m2m_ctx. this is the main character of the whole operation, lowkey.
  • vma β€” pointer to struct vm_area_struct. your mapping bestie. 🌈

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” you call this from the driver's mmap function. and it will handle mmap for both queues seamlessly for the video buffer, which receives normal per-queue offsets and proper vb2 queue pointers. iconic behaviour, honestly.

the differentiation is made outside vb2 by adding a predefined offset to buffers from one of the queues, and then subtracting it before passing it back to vb2. yes, it's a little add-then-subtract situation. it works. don't question it. πŸ™ˆ

important detail bestie: only drivers (and thus applications) receive modified offsets. everyone else?? sees the normal thing. periodt. πŸ’…

πŸ”₯ SEE ALSO πŸ”₯

okay this is the long part and I'm not skipping a single one of them, because each and every one of these is a baddie in their own right:

Kernel file ./include/media/v4l2-mem2mem.h, plus: struct v4l2_m2m_ops(9), 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_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).

that's the whole friend group. literally all of them. go read about them, iykyk 🧚


and that's the page!! mwah πŸ’‹

this lil masterpiece lives in ./include/media, dated October 2026. stay hydrated, read your kernel headers, and remember: the offsets are modified for drivers and applications only, bestie. periodt. πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from