Lines Matching +full:required +full:- +full:for +full:- +full:hardware +full:- +full:jobs
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Memory-to-memory device framework for Video for Linux 2.
5 * Helper functions for devices that use memory buffers for both source
16 #include <media/videobuf2-v4l2.h>
19 * struct v4l2_m2m_ops - mem-to-mem device driver callbacks
20 * @device_run: required. Begin the actual job (transaction) inside this
30 * that is required for the driver to perform one full transaction.
52 * struct v4l2_m2m_queue_ctx - represents a queue for buffers ready to be
56 * @rdy_queue: List of V4L2 mem-to-mem queues
61 * Queue for buffers ready to be processed as soon as this
75 * struct v4l2_m2m_ctx - Memory to memory context structure
80 * for an existing frame. This is always true unless
84 * @last_src_buf: indicate the last source buffer for draining
91 * @job_flags: Job queue flags, used internally by v4l2-mem2mem.c:
117 /* For device job queue */
126 * struct v4l2_m2m_buffer - Memory to memory buffer
137 * v4l2_m2m_get_curr_priv() - return driver private data for the currently
145 * v4l2_m2m_get_vq() - return vb2_queue for the given type
154 * v4l2_m2m_try_schedule() - check whether an instance is ready to be added to
164 * If a queue is buffered (for example a decoder hardware ringbuffer that has
177 * v4l2_m2m_job_finish() - inform the framework that a job has been finished
187 * This function has to be called only after &v4l2_m2m_ops->device_run
189 * not be called directly from the &v4l2_m2m_ops->device_run callback though.
195 * v4l2_m2m_buf_done_and_job_finish() - return source/destination buffers with
205 * optional for other drivers.
208 * it with the given state. The same is done for the destination buffer, unless
213 * This allows for multiple output buffers to be used to fill in a single
224 vb2_buffer_done(&buf->vb2_buf, state); in v4l2_m2m_buf_done()
228 * v4l2_m2m_clear_state() - clear encoding/decoding state
235 m2m_ctx->next_buf_last = false; in v4l2_m2m_clear_state()
236 m2m_ctx->is_draining = false; in v4l2_m2m_clear_state()
237 m2m_ctx->has_stopped = false; in v4l2_m2m_clear_state()
241 * v4l2_m2m_mark_stopped() - set current encoding/decoding state as stopped
248 m2m_ctx->next_buf_last = false; in v4l2_m2m_mark_stopped()
249 m2m_ctx->is_draining = false; in v4l2_m2m_mark_stopped()
250 m2m_ctx->has_stopped = true; in v4l2_m2m_mark_stopped()
254 * v4l2_m2m_dst_buf_is_last() - return the current encoding/decoding session
265 return m2m_ctx->is_draining && m2m_ctx->next_buf_last; in v4l2_m2m_dst_buf_is_last()
269 * v4l2_m2m_has_stopped() - return the current encoding/decoding session
277 return m2m_ctx->has_stopped; in v4l2_m2m_has_stopped()
281 * v4l2_m2m_is_last_draining_src_buf() - return the output buffer draining
285 * was required, leading to an actual encoding/decoding session stop state
295 return m2m_ctx->is_draining && vbuf == m2m_ctx->last_src_buf; in v4l2_m2m_is_last_draining_src_buf()
299 * v4l2_m2m_last_buffer_done() - marks the buffer with LAST flag and DONE
308 * v4l2_m2m_suspend() - stop new jobs from being run and wait for current job
313 * Called by a driver in the suspend hook. Stop new jobs from being run, and
314 * wait for current running job to finish.
319 * v4l2_m2m_resume() - resume job running and try to run a queued job
330 * v4l2_m2m_reqbufs() - multi-queue-aware REQBUFS multiplexer
340 * v4l2_m2m_querybuf() - multi-queue-aware QUERYBUF multiplexer
346 * See v4l2_m2m_mmap() documentation for details.
352 * v4l2_m2m_qbuf() - enqueue a source or destination buffer, depending on
363 * v4l2_m2m_dqbuf() - dequeue a source or destination buffer, depending on
374 * v4l2_m2m_prepare_buf() - prepare a source or destination buffer, depending on
385 * v4l2_m2m_create_bufs() - create a source or destination buffer, depending
396 * v4l2_m2m_expbuf() - export a source or destination buffer, depending on
407 * v4l2_m2m_streamon() - turn on streaming for a video queue
417 * v4l2_m2m_streamoff() - turn off streaming for a video queue
427 * v4l2_m2m_update_start_streaming_state() - update the encoding/decoding
437 * v4l2_m2m_update_stop_streaming_state() - update the encoding/decoding
447 * v4l2_m2m_encoder_cmd() - execute an encoder command
457 * v4l2_m2m_decoder_cmd() - execute a decoder command
467 * v4l2_m2m_poll() - poll replacement, for destination buffers only
475 * indicate that a non-blocking write can be performed, while read will be
482 * v4l2_m2m_mmap() - source and destination queues-aware mmap multiplexer
488 * Call from driver's mmap() function. Will handle mmap() for both queues
489 * seamlessly for the video buffer, which will receive normal per-queue offsets
504 * v4l2_m2m_init() - initialize per-driver m2m data
533 * v4l2_m2m_release() - cleans up and frees a m2m_dev structure
542 * v4l2_m2m_ctx_init() - allocate and initialize a m2m context
546 * @queue_init: a callback for queue type-specific initialization function
547 * to be used for initializing vb2_queues
558 m2m_ctx->out_q_ctx.buffered = buffered; in v4l2_m2m_set_src_buffered()
564 m2m_ctx->cap_q_ctx.buffered = buffered; in v4l2_m2m_set_dst_buffered()
568 * v4l2_m2m_ctx_release() - release m2m context
577 * v4l2_m2m_buf_queue() - add a buffer to the proper ready buffers list.
582 * Call from vb2_queue_ops->ops->buf_queue, vb2_queue_ops callback.
588 * v4l2_m2m_num_src_bufs_ready() - return the number of source buffers ready for
599 spin_lock_irqsave(&m2m_ctx->out_q_ctx.rdy_spinlock, flags); in v4l2_m2m_num_src_bufs_ready()
600 num_buf_rdy = m2m_ctx->out_q_ctx.num_rdy; in v4l2_m2m_num_src_bufs_ready()
601 spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock, flags); in v4l2_m2m_num_src_bufs_ready()
607 * v4l2_m2m_num_dst_bufs_ready() - return the number of destination buffers
608 * ready for use
618 spin_lock_irqsave(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags); in v4l2_m2m_num_dst_bufs_ready()
619 num_buf_rdy = m2m_ctx->cap_q_ctx.num_rdy; in v4l2_m2m_num_dst_bufs_ready()
620 spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags); in v4l2_m2m_num_dst_bufs_ready()
626 * v4l2_m2m_next_buf() - return next buffer from the list of ready buffers
633 * v4l2_m2m_next_src_buf() - return next source buffer from the list of ready
641 return v4l2_m2m_next_buf(&m2m_ctx->out_q_ctx); in v4l2_m2m_next_src_buf()
645 * v4l2_m2m_next_dst_buf() - return next destination buffer from the list of
653 return v4l2_m2m_next_buf(&m2m_ctx->cap_q_ctx); in v4l2_m2m_next_dst_buf()
657 * v4l2_m2m_last_buf() - return last buffer from the list of ready buffers
664 * v4l2_m2m_last_src_buf() - return last destination buffer from the list of
672 return v4l2_m2m_last_buf(&m2m_ctx->out_q_ctx); in v4l2_m2m_last_src_buf()
676 * v4l2_m2m_last_dst_buf() - return last destination buffer from the list of
684 return v4l2_m2m_last_buf(&m2m_ctx->cap_q_ctx); in v4l2_m2m_last_dst_buf()
688 * v4l2_m2m_for_each_dst_buf() - iterate over a list of destination ready
695 list_for_each_entry(b, &m2m_ctx->cap_q_ctx.rdy_queue, list)
698 * v4l2_m2m_for_each_src_buf() - iterate over a list of source ready buffers
704 list_for_each_entry(b, &m2m_ctx->out_q_ctx.rdy_queue, list)
707 * v4l2_m2m_for_each_dst_buf_safe() - iterate over a list of destination ready
715 list_for_each_entry_safe(b, n, &m2m_ctx->cap_q_ctx.rdy_queue, list)
718 * v4l2_m2m_for_each_src_buf_safe() - iterate over a list of source ready
726 list_for_each_entry_safe(b, n, &m2m_ctx->out_q_ctx.rdy_queue, list)
729 * v4l2_m2m_get_src_vq() - return vb2_queue for source buffers
736 return &m2m_ctx->out_q_ctx.q; in v4l2_m2m_get_src_vq()
740 * v4l2_m2m_get_dst_vq() - return vb2_queue for destination buffers
747 return &m2m_ctx->cap_q_ctx.q; in v4l2_m2m_get_dst_vq()
751 * v4l2_m2m_buf_remove() - take off a buffer from the list of ready buffers and
759 * v4l2_m2m_src_buf_remove() - take off a source buffer from the list of ready
767 return v4l2_m2m_buf_remove(&m2m_ctx->out_q_ctx); in v4l2_m2m_src_buf_remove()
771 * v4l2_m2m_dst_buf_remove() - take off a destination buffer from the list of
779 return v4l2_m2m_buf_remove(&m2m_ctx->cap_q_ctx); in v4l2_m2m_dst_buf_remove()
783 * v4l2_m2m_buf_remove_by_buf() - take off exact buffer from the list of ready
793 * v4l2_m2m_src_buf_remove_by_buf() - take off exact source buffer from the list
802 v4l2_m2m_buf_remove_by_buf(&m2m_ctx->out_q_ctx, vbuf); in v4l2_m2m_src_buf_remove_by_buf()
806 * v4l2_m2m_dst_buf_remove_by_buf() - take off exact destination buffer from the
815 v4l2_m2m_buf_remove_by_buf(&m2m_ctx->cap_q_ctx, vbuf); in v4l2_m2m_dst_buf_remove_by_buf()
824 return v4l2_m2m_buf_remove_by_idx(&m2m_ctx->out_q_ctx, idx); in v4l2_m2m_src_buf_remove_by_idx()
830 return v4l2_m2m_buf_remove_by_idx(&m2m_ctx->cap_q_ctx, idx); in v4l2_m2m_dst_buf_remove_by_idx()
834 * v4l2_m2m_buf_copy_metadata() - copy buffer metadata from
846 * flags are not copied. This is typically needed for encoders that