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
92 * for actual decoding are met.
97 * @job_flags: Job queue flags, used internally by v4l2-mem2mem.c:
124 /* For device job queue */
133 * struct v4l2_m2m_buffer - Memory to memory buffer
144 * v4l2_m2m_get_curr_priv() - return driver private data for the currently
152 * v4l2_m2m_get_vq() - return vb2_queue for the given type
161 * v4l2_m2m_try_schedule() - check whether an instance is ready to be added to
171 * If a queue is buffered (for example a decoder hardware ringbuffer that has
184 * v4l2_m2m_job_finish() - inform the framework that a job has been finished
194 * This function has to be called only after &v4l2_m2m_ops->device_run
196 * not be called directly from the &v4l2_m2m_ops->device_run callback though.
202 * v4l2_m2m_buf_done_and_job_finish() - return source/destination buffers with
212 * optional for other drivers.
215 * it with the given state. The same is done for the destination buffer, unless
220 * This allows for multiple output buffers to be used to fill in a single
231 vb2_buffer_done(&buf->vb2_buf, state); in v4l2_m2m_buf_done()
235 * v4l2_m2m_clear_state() - clear encoding/decoding state
242 m2m_ctx->next_buf_last = false; in v4l2_m2m_clear_state()
243 m2m_ctx->is_draining = false; in v4l2_m2m_clear_state()
244 m2m_ctx->has_stopped = false; in v4l2_m2m_clear_state()
248 * v4l2_m2m_mark_stopped() - set current encoding/decoding state as stopped
255 m2m_ctx->next_buf_last = false; in v4l2_m2m_mark_stopped()
256 m2m_ctx->is_draining = false; in v4l2_m2m_mark_stopped()
257 m2m_ctx->has_stopped = true; in v4l2_m2m_mark_stopped()
261 * v4l2_m2m_dst_buf_is_last() - return the current encoding/decoding session
272 return m2m_ctx->is_draining && m2m_ctx->next_buf_last; in v4l2_m2m_dst_buf_is_last()
276 * v4l2_m2m_has_stopped() - return the current encoding/decoding session
284 return m2m_ctx->has_stopped; in v4l2_m2m_has_stopped()
288 * v4l2_m2m_is_last_draining_src_buf() - return the output buffer draining
292 * was required, leading to an actual encoding/decoding session stop state
302 return m2m_ctx->is_draining && vbuf == m2m_ctx->last_src_buf; in v4l2_m2m_is_last_draining_src_buf()
306 * v4l2_m2m_last_buffer_done() - marks the buffer with LAST flag and DONE
315 * v4l2_m2m_suspend() - stop new jobs from being run and wait for current job
320 * Called by a driver in the suspend hook. Stop new jobs from being run, and
321 * wait for current running job to finish.
326 * v4l2_m2m_resume() - resume job running and try to run a queued job
337 * v4l2_m2m_reqbufs() - multi-queue-aware REQBUFS multiplexer
347 * v4l2_m2m_querybuf() - multi-queue-aware QUERYBUF multiplexer
353 * See v4l2_m2m_mmap() documentation for details.
359 * v4l2_m2m_qbuf() - enqueue a source or destination buffer, depending on
370 * v4l2_m2m_dqbuf() - dequeue a source or destination buffer, depending on
381 * v4l2_m2m_prepare_buf() - prepare a source or destination buffer, depending on
392 * v4l2_m2m_create_bufs() - create a source or destination buffer, depending
403 * v4l2_m2m_expbuf() - export a source or destination buffer, depending on
414 * v4l2_m2m_streamon() - turn on streaming for a video queue
424 * v4l2_m2m_streamoff() - turn off streaming for a video queue
434 * v4l2_m2m_update_start_streaming_state() - update the encoding/decoding
444 * v4l2_m2m_update_stop_streaming_state() - update the encoding/decoding
454 * v4l2_m2m_encoder_cmd() - execute an encoder command
464 * v4l2_m2m_decoder_cmd() - execute a decoder command
474 * v4l2_m2m_poll() - poll replacement, for destination buffers only
482 * indicate that a non-blocking write can be performed, while read will be
489 * v4l2_m2m_mmap() - source and destination queues-aware mmap multiplexer
495 * Call from driver's mmap() function. Will handle mmap() for both queues
496 * seamlessly for the video buffer, which will receive normal per-queue offsets
511 * v4l2_m2m_init() - initialize per-driver m2m data
540 * v4l2_m2m_release() - cleans up and frees a m2m_dev structure
549 * v4l2_m2m_ctx_init() - allocate and initialize a m2m context
553 * @queue_init: a callback for queue type-specific initialization function
554 * to be used for initializing vb2_queues
565 m2m_ctx->out_q_ctx.buffered = buffered; in v4l2_m2m_set_src_buffered()
571 m2m_ctx->cap_q_ctx.buffered = buffered; in v4l2_m2m_set_dst_buffered()
575 * v4l2_m2m_ctx_release() - release m2m context
584 * v4l2_m2m_buf_queue() - add a buffer to the proper ready buffers list.
589 * Call from vb2_queue_ops->ops->buf_queue, vb2_queue_ops callback.
595 * v4l2_m2m_num_src_bufs_ready() - return the number of source buffers ready for
606 spin_lock_irqsave(&m2m_ctx->out_q_ctx.rdy_spinlock, flags); in v4l2_m2m_num_src_bufs_ready()
607 num_buf_rdy = m2m_ctx->out_q_ctx.num_rdy; in v4l2_m2m_num_src_bufs_ready()
608 spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock, flags); in v4l2_m2m_num_src_bufs_ready()
614 * v4l2_m2m_num_dst_bufs_ready() - return the number of destination buffers
615 * ready for use
625 spin_lock_irqsave(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags); in v4l2_m2m_num_dst_bufs_ready()
626 num_buf_rdy = m2m_ctx->cap_q_ctx.num_rdy; in v4l2_m2m_num_dst_bufs_ready()
627 spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags); in v4l2_m2m_num_dst_bufs_ready()
633 * v4l2_m2m_next_buf() - return next buffer from the list of ready buffers
640 * v4l2_m2m_next_src_buf() - return next source buffer from the list of ready
648 return v4l2_m2m_next_buf(&m2m_ctx->out_q_ctx); in v4l2_m2m_next_src_buf()
652 * v4l2_m2m_next_dst_buf() - return next destination buffer from the list of
660 return v4l2_m2m_next_buf(&m2m_ctx->cap_q_ctx); in v4l2_m2m_next_dst_buf()
664 * v4l2_m2m_last_buf() - return last buffer from the list of ready buffers
671 * v4l2_m2m_last_src_buf() - return last source buffer from the list of
679 return v4l2_m2m_last_buf(&m2m_ctx->out_q_ctx); in v4l2_m2m_last_src_buf()
683 * v4l2_m2m_last_dst_buf() - return last destination buffer from the list of
691 return v4l2_m2m_last_buf(&m2m_ctx->cap_q_ctx); in v4l2_m2m_last_dst_buf()
695 * v4l2_m2m_for_each_dst_buf() - iterate over a list of destination ready
702 list_for_each_entry(b, &m2m_ctx->cap_q_ctx.rdy_queue, list)
705 * v4l2_m2m_for_each_src_buf() - iterate over a list of source ready buffers
711 list_for_each_entry(b, &m2m_ctx->out_q_ctx.rdy_queue, list)
714 * v4l2_m2m_for_each_dst_buf_safe() - iterate over a list of destination ready
722 list_for_each_entry_safe(b, n, &m2m_ctx->cap_q_ctx.rdy_queue, list)
725 * v4l2_m2m_for_each_src_buf_safe() - iterate over a list of source ready
733 list_for_each_entry_safe(b, n, &m2m_ctx->out_q_ctx.rdy_queue, list)
736 * v4l2_m2m_get_src_vq() - return vb2_queue for source buffers
743 return &m2m_ctx->out_q_ctx.q; in v4l2_m2m_get_src_vq()
747 * v4l2_m2m_get_dst_vq() - return vb2_queue for destination buffers
754 return &m2m_ctx->cap_q_ctx.q; in v4l2_m2m_get_dst_vq()
758 * v4l2_m2m_buf_remove() - take off a buffer from the list of ready buffers and
766 * v4l2_m2m_src_buf_remove() - take off a source buffer from the list of ready
774 return v4l2_m2m_buf_remove(&m2m_ctx->out_q_ctx); in v4l2_m2m_src_buf_remove()
778 * v4l2_m2m_dst_buf_remove() - take off a destination buffer from the list of
786 return v4l2_m2m_buf_remove(&m2m_ctx->cap_q_ctx); in v4l2_m2m_dst_buf_remove()
790 * v4l2_m2m_buf_remove_by_buf() - take off exact buffer from the list of ready
800 * v4l2_m2m_src_buf_remove_by_buf() - take off exact source buffer from the list
809 v4l2_m2m_buf_remove_by_buf(&m2m_ctx->out_q_ctx, vbuf); in v4l2_m2m_src_buf_remove_by_buf()
813 * v4l2_m2m_dst_buf_remove_by_buf() - take off exact destination buffer from the
822 v4l2_m2m_buf_remove_by_buf(&m2m_ctx->cap_q_ctx, vbuf); in v4l2_m2m_dst_buf_remove_by_buf()
831 return v4l2_m2m_buf_remove_by_idx(&m2m_ctx->out_q_ctx, idx); in v4l2_m2m_src_buf_remove_by_idx()
837 return v4l2_m2m_buf_remove_by_idx(&m2m_ctx->cap_q_ctx, idx); in v4l2_m2m_dst_buf_remove_by_idx()
841 * v4l2_m2m_buf_copy_metadata() - copy buffer metadata from
853 * flags are not copied. This is typically needed for encoders that