Lines Matching refs:m2m_ctx
114 static struct v4l2_m2m_queue_ctx *get_queue_ctx(struct v4l2_m2m_ctx *m2m_ctx, in get_queue_ctx() argument
118 return &m2m_ctx->out_q_ctx; in get_queue_ctx()
120 return &m2m_ctx->cap_q_ctx; in get_queue_ctx()
123 struct vb2_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_get_vq() argument
128 q_ctx = get_queue_ctx(m2m_ctx, type); in v4l2_m2m_get_vq()
297 struct v4l2_m2m_ctx *m2m_ctx) in __v4l2_m2m_try_queue() argument
302 dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); in __v4l2_m2m_try_queue()
304 if (!m2m_ctx->out_q_ctx.q.streaming || in __v4l2_m2m_try_queue()
305 (!m2m_ctx->cap_q_ctx.q.streaming && !m2m_ctx->ignore_cap_streaming)) { in __v4l2_m2m_try_queue()
306 if (!m2m_ctx->ignore_cap_streaming) in __v4l2_m2m_try_queue()
316 if (m2m_ctx->job_flags & TRANS_ABORT) { in __v4l2_m2m_try_queue()
321 if (m2m_ctx->job_flags & TRANS_QUEUED) { in __v4l2_m2m_try_queue()
326 src = v4l2_m2m_next_src_buf(m2m_ctx); in __v4l2_m2m_try_queue()
327 dst = v4l2_m2m_next_dst_buf(m2m_ctx); in __v4l2_m2m_try_queue()
328 if (!src && !m2m_ctx->out_q_ctx.buffered) { in __v4l2_m2m_try_queue()
332 if (!dst && !m2m_ctx->cap_q_ctx.buffered) { in __v4l2_m2m_try_queue()
337 m2m_ctx->new_frame = true; in __v4l2_m2m_try_queue()
344 v4l2_m2m_dst_buf_remove(m2m_ctx); in __v4l2_m2m_try_queue()
346 dst = v4l2_m2m_next_dst_buf(m2m_ctx); in __v4l2_m2m_try_queue()
348 if (!dst && !m2m_ctx->cap_q_ctx.buffered) { in __v4l2_m2m_try_queue()
354 if (src && dst && (m2m_ctx->out_q_ctx.q.subsystem_flags & in __v4l2_m2m_try_queue()
356 m2m_ctx->new_frame = !dst->vb2_buf.copied_timestamp || in __v4l2_m2m_try_queue()
359 if (m2m_ctx->has_stopped) { in __v4l2_m2m_try_queue()
365 && (!m2m_dev->m2m_ops->job_ready(m2m_ctx->priv))) { in __v4l2_m2m_try_queue()
370 list_add_tail(&m2m_ctx->queue, &m2m_dev->job_queue); in __v4l2_m2m_try_queue()
371 m2m_ctx->job_flags |= TRANS_QUEUED; in __v4l2_m2m_try_queue()
389 void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx) in v4l2_m2m_try_schedule() argument
391 struct v4l2_m2m_dev *m2m_dev = m2m_ctx->m2m_dev; in v4l2_m2m_try_schedule()
393 __v4l2_m2m_try_queue(m2m_dev, m2m_ctx); in v4l2_m2m_try_schedule()
419 static void v4l2_m2m_cancel_job(struct v4l2_m2m_ctx *m2m_ctx) in v4l2_m2m_cancel_job() argument
424 m2m_dev = m2m_ctx->m2m_dev; in v4l2_m2m_cancel_job()
427 m2m_ctx->job_flags |= TRANS_ABORT; in v4l2_m2m_cancel_job()
428 if (m2m_ctx->job_flags & TRANS_RUNNING) { in v4l2_m2m_cancel_job()
431 m2m_dev->m2m_ops->job_abort(m2m_ctx->priv); in v4l2_m2m_cancel_job()
432 dprintk("m2m_ctx %p running, will wait to complete\n", m2m_ctx); in v4l2_m2m_cancel_job()
433 wait_event(m2m_ctx->finished, in v4l2_m2m_cancel_job()
434 !(m2m_ctx->job_flags & TRANS_RUNNING)); in v4l2_m2m_cancel_job()
435 } else if (m2m_ctx->job_flags & TRANS_QUEUED) { in v4l2_m2m_cancel_job()
436 list_del(&m2m_ctx->queue); in v4l2_m2m_cancel_job()
437 m2m_ctx->job_flags &= ~(TRANS_QUEUED | TRANS_RUNNING); in v4l2_m2m_cancel_job()
440 m2m_ctx); in v4l2_m2m_cancel_job()
452 struct v4l2_m2m_ctx *m2m_ctx) in v4l2_m2m_schedule_next_job() argument
459 __v4l2_m2m_try_queue(m2m_dev, m2m_ctx); in v4l2_m2m_schedule_next_job()
473 struct v4l2_m2m_ctx *m2m_ctx) in _v4l2_m2m_job_finish() argument
475 if (!m2m_dev->curr_ctx || m2m_dev->curr_ctx != m2m_ctx) { in _v4l2_m2m_job_finish()
488 struct v4l2_m2m_ctx *m2m_ctx) in v4l2_m2m_job_finish() argument
498 WARN_ON(m2m_ctx->out_q_ctx.q.subsystem_flags & in v4l2_m2m_job_finish()
501 schedule_next = _v4l2_m2m_job_finish(m2m_dev, m2m_ctx); in v4l2_m2m_job_finish()
505 v4l2_m2m_schedule_next_job(m2m_dev, m2m_ctx); in v4l2_m2m_job_finish()
510 struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_buf_done_and_job_finish() argument
518 src_buf = v4l2_m2m_src_buf_remove(m2m_ctx); in v4l2_m2m_buf_done_and_job_finish()
519 dst_buf = v4l2_m2m_next_dst_buf(m2m_ctx); in v4l2_m2m_buf_done_and_job_finish()
525 v4l2_m2m_dst_buf_remove(m2m_ctx); in v4l2_m2m_buf_done_and_job_finish()
538 schedule_next = _v4l2_m2m_job_finish(m2m_dev, m2m_ctx); in v4l2_m2m_buf_done_and_job_finish()
543 v4l2_m2m_schedule_next_job(m2m_dev, m2m_ctx); in v4l2_m2m_buf_done_and_job_finish()
575 int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_reqbufs() argument
581 vq = v4l2_m2m_get_vq(m2m_ctx, reqbufs->type); in v4l2_m2m_reqbufs()
609 int v4l2_m2m_querybuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_querybuf() argument
615 vq = v4l2_m2m_get_vq(m2m_ctx, buf->type); in v4l2_m2m_querybuf()
634 void v4l2_m2m_last_buffer_done(struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_last_buffer_done() argument
640 v4l2_m2m_mark_stopped(m2m_ctx); in v4l2_m2m_last_buffer_done()
645 static int v4l2_update_last_buf_state(struct v4l2_m2m_ctx *m2m_ctx) in v4l2_update_last_buf_state() argument
649 if (m2m_ctx->is_draining) in v4l2_update_last_buf_state()
652 if (m2m_ctx->has_stopped) in v4l2_update_last_buf_state()
655 m2m_ctx->last_src_buf = v4l2_m2m_last_src_buf(m2m_ctx); in v4l2_update_last_buf_state()
656 m2m_ctx->is_draining = true; in v4l2_update_last_buf_state()
663 if (m2m_ctx->last_src_buf) in v4l2_update_last_buf_state()
670 next_dst_buf = v4l2_m2m_dst_buf_remove(m2m_ctx); in v4l2_update_last_buf_state()
678 m2m_ctx->next_buf_last = true; in v4l2_update_last_buf_state()
682 v4l2_m2m_last_buffer_done(m2m_ctx, next_dst_buf); in v4l2_update_last_buf_state()
691 void v4l2_m2m_update_start_streaming_state(struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_update_start_streaming_state() argument
696 m2m_ctx->last_src_buf = NULL; in v4l2_m2m_update_start_streaming_state()
704 void v4l2_m2m_update_stop_streaming_state(struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_update_stop_streaming_state() argument
715 if (m2m_ctx->is_draining) { in v4l2_m2m_update_stop_streaming_state()
718 m2m_ctx->last_src_buf = NULL; in v4l2_m2m_update_stop_streaming_state()
719 next_dst_buf = v4l2_m2m_dst_buf_remove(m2m_ctx); in v4l2_m2m_update_stop_streaming_state()
721 m2m_ctx->next_buf_last = true; in v4l2_m2m_update_stop_streaming_state()
723 v4l2_m2m_last_buffer_done(m2m_ctx, in v4l2_m2m_update_stop_streaming_state()
727 v4l2_m2m_clear_state(m2m_ctx); in v4l2_m2m_update_stop_streaming_state()
732 static void v4l2_m2m_force_last_buf_done(struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_force_last_buf_done() argument
758 v4l2_m2m_last_buffer_done(m2m_ctx, vbuf); in v4l2_m2m_force_last_buf_done()
761 int v4l2_m2m_qbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_qbuf() argument
768 vq = v4l2_m2m_get_vq(m2m_ctx, buf->type); in v4l2_m2m_qbuf()
791 (v4l2_m2m_has_stopped(m2m_ctx) || v4l2_m2m_dst_buf_is_last(m2m_ctx))) in v4l2_m2m_qbuf()
792 v4l2_m2m_force_last_buf_done(m2m_ctx, vq); in v4l2_m2m_qbuf()
794 v4l2_m2m_try_schedule(m2m_ctx); in v4l2_m2m_qbuf()
800 int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_dqbuf() argument
806 vq = v4l2_m2m_get_vq(m2m_ctx, buf->type); in v4l2_m2m_dqbuf()
818 int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_prepare_buf() argument
825 vq = v4l2_m2m_get_vq(m2m_ctx, buf->type); in v4l2_m2m_prepare_buf()
837 int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_create_bufs() argument
842 vq = v4l2_m2m_get_vq(m2m_ctx, create->format.type); in v4l2_m2m_create_bufs()
847 int v4l2_m2m_expbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_expbuf() argument
852 vq = v4l2_m2m_get_vq(m2m_ctx, eb->type); in v4l2_m2m_expbuf()
857 int v4l2_m2m_streamon(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_streamon() argument
863 vq = v4l2_m2m_get_vq(m2m_ctx, type); in v4l2_m2m_streamon()
866 v4l2_m2m_try_schedule(m2m_ctx); in v4l2_m2m_streamon()
872 int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_streamoff() argument
881 v4l2_m2m_cancel_job(m2m_ctx); in v4l2_m2m_streamoff()
883 q_ctx = get_queue_ctx(m2m_ctx, type); in v4l2_m2m_streamoff()
888 m2m_dev = m2m_ctx->m2m_dev; in v4l2_m2m_streamoff()
891 if (m2m_ctx->job_flags & TRANS_QUEUED) in v4l2_m2m_streamoff()
892 list_del(&m2m_ctx->queue); in v4l2_m2m_streamoff()
893 m2m_ctx->job_flags = 0; in v4l2_m2m_streamoff()
902 if (m2m_dev->curr_ctx == m2m_ctx) { in v4l2_m2m_streamoff()
904 wake_up(&m2m_ctx->finished); in v4l2_m2m_streamoff()
913 struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_poll_for_data() argument
920 src_q = v4l2_m2m_get_src_vq(m2m_ctx); in v4l2_m2m_poll_for_data()
921 dst_q = v4l2_m2m_get_dst_vq(m2m_ctx); in v4l2_m2m_poll_for_data()
951 __poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_poll() argument
955 struct vb2_queue *src_q = v4l2_m2m_get_src_vq(m2m_ctx); in v4l2_m2m_poll()
956 struct vb2_queue *dst_q = v4l2_m2m_get_dst_vq(m2m_ctx); in v4l2_m2m_poll()
971 rc = v4l2_m2m_poll_for_data(file, m2m_ctx, wait); in v4l2_m2m_poll()
985 int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_mmap() argument
992 vq = v4l2_m2m_get_src_vq(m2m_ctx); in v4l2_m2m_mmap()
994 vq = v4l2_m2m_get_dst_vq(m2m_ctx); in v4l2_m2m_mmap()
1012 vq = v4l2_m2m_get_src_vq(fh->m2m_ctx); in v4l2_m2m_get_unmapped_area()
1014 vq = v4l2_m2m_get_dst_vq(fh->m2m_ctx); in v4l2_m2m_get_unmapped_area()
1228 struct v4l2_m2m_ctx *m2m_ctx; in v4l2_m2m_ctx_init() local
1232 m2m_ctx = kzalloc(sizeof *m2m_ctx, GFP_KERNEL); in v4l2_m2m_ctx_init()
1233 if (!m2m_ctx) in v4l2_m2m_ctx_init()
1236 m2m_ctx->priv = drv_priv; in v4l2_m2m_ctx_init()
1237 m2m_ctx->m2m_dev = m2m_dev; in v4l2_m2m_ctx_init()
1238 init_waitqueue_head(&m2m_ctx->finished); in v4l2_m2m_ctx_init()
1240 out_q_ctx = &m2m_ctx->out_q_ctx; in v4l2_m2m_ctx_init()
1241 cap_q_ctx = &m2m_ctx->cap_q_ctx; in v4l2_m2m_ctx_init()
1248 INIT_LIST_HEAD(&m2m_ctx->queue); in v4l2_m2m_ctx_init()
1262 m2m_ctx->q_lock = out_q_ctx->q.lock; in v4l2_m2m_ctx_init()
1264 return m2m_ctx; in v4l2_m2m_ctx_init()
1266 kfree(m2m_ctx); in v4l2_m2m_ctx_init()
1271 void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx) in v4l2_m2m_ctx_release() argument
1274 v4l2_m2m_cancel_job(m2m_ctx); in v4l2_m2m_ctx_release()
1276 vb2_queue_release(&m2m_ctx->cap_q_ctx.q); in v4l2_m2m_ctx_release()
1277 vb2_queue_release(&m2m_ctx->out_q_ctx.q); in v4l2_m2m_ctx_release()
1279 kfree(m2m_ctx); in v4l2_m2m_ctx_release()
1283 void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_buf_queue() argument
1291 q_ctx = get_queue_ctx(m2m_ctx, vbuf->vb2_buf.vb2_queue->type); in v4l2_m2m_buf_queue()
1326 struct v4l2_m2m_ctx *m2m_ctx = NULL; in v4l2_m2m_request_queue() local
1350 WARN_ON(m2m_ctx && m2m_ctx_obj != m2m_ctx); in v4l2_m2m_request_queue()
1351 m2m_ctx = m2m_ctx_obj; in v4l2_m2m_request_queue()
1362 WARN_ON(!m2m_ctx); in v4l2_m2m_request_queue()
1364 if (m2m_ctx) in v4l2_m2m_request_queue()
1365 v4l2_m2m_try_schedule(m2m_ctx); in v4l2_m2m_request_queue()
1376 return v4l2_m2m_reqbufs(file, fh->m2m_ctx, rb); in v4l2_m2m_ioctl_reqbufs()
1385 return v4l2_m2m_create_bufs(file, fh->m2m_ctx, create); in v4l2_m2m_ioctl_create_bufs()
1393 struct vb2_queue *q = v4l2_m2m_get_vq(fh->m2m_ctx, remove->type); in v4l2_m2m_ioctl_remove_bufs()
1409 return v4l2_m2m_querybuf(file, fh->m2m_ctx, buf); in v4l2_m2m_ioctl_querybuf()
1418 return v4l2_m2m_qbuf(file, fh->m2m_ctx, buf); in v4l2_m2m_ioctl_qbuf()
1427 return v4l2_m2m_dqbuf(file, fh->m2m_ctx, buf); in v4l2_m2m_ioctl_dqbuf()
1436 return v4l2_m2m_prepare_buf(file, fh->m2m_ctx, buf); in v4l2_m2m_ioctl_prepare_buf()
1445 return v4l2_m2m_expbuf(file, fh->m2m_ctx, eb); in v4l2_m2m_ioctl_expbuf()
1454 return v4l2_m2m_streamon(file, fh->m2m_ctx, type); in v4l2_m2m_ioctl_streamon()
1463 return v4l2_m2m_streamoff(file, fh->m2m_ctx, type); in v4l2_m2m_ioctl_streamoff()
1500 int v4l2_m2m_encoder_cmd(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_encoder_cmd() argument
1507 return v4l2_update_last_buf_state(m2m_ctx); in v4l2_m2m_encoder_cmd()
1509 if (m2m_ctx->is_draining) in v4l2_m2m_encoder_cmd()
1512 if (m2m_ctx->has_stopped) in v4l2_m2m_encoder_cmd()
1513 m2m_ctx->has_stopped = false; in v4l2_m2m_encoder_cmd()
1523 int v4l2_m2m_decoder_cmd(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, in v4l2_m2m_decoder_cmd() argument
1530 return v4l2_update_last_buf_state(m2m_ctx); in v4l2_m2m_decoder_cmd()
1532 if (m2m_ctx->is_draining) in v4l2_m2m_decoder_cmd()
1535 if (m2m_ctx->has_stopped) in v4l2_m2m_decoder_cmd()
1536 m2m_ctx->has_stopped = false; in v4l2_m2m_decoder_cmd()
1547 return v4l2_m2m_encoder_cmd(file, fh->m2m_ctx, ec); in v4l2_m2m_ioctl_encoder_cmd()
1556 return v4l2_m2m_decoder_cmd(file, fh->m2m_ctx, dc); in v4l2_m2m_ioctl_decoder_cmd()
1577 struct v4l2_m2m_dev *m2m_dev = fh->m2m_ctx->m2m_dev; in v4l2_m2m_ioctl_stateless_decoder_cmd()
1586 out_vb = v4l2_m2m_last_src_buf(fh->m2m_ctx); in v4l2_m2m_ioctl_stateless_decoder_cmd()
1587 cap_vb = v4l2_m2m_last_dst_buf(fh->m2m_ctx); in v4l2_m2m_ioctl_stateless_decoder_cmd()
1604 v4l2_m2m_dst_buf_remove(fh->m2m_ctx); in v4l2_m2m_ioctl_stateless_decoder_cmd()
1622 return v4l2_m2m_mmap(file, fh->m2m_ctx, vma); in v4l2_m2m_fop_mmap()
1629 struct v4l2_m2m_ctx *m2m_ctx = fh->m2m_ctx; in v4l2_m2m_fop_poll() local
1632 if (m2m_ctx->q_lock) in v4l2_m2m_fop_poll()
1633 mutex_lock(m2m_ctx->q_lock); in v4l2_m2m_fop_poll()
1635 ret = v4l2_m2m_poll(file, m2m_ctx, wait); in v4l2_m2m_fop_poll()
1637 if (m2m_ctx->q_lock) in v4l2_m2m_fop_poll()
1638 mutex_unlock(m2m_ctx->q_lock); in v4l2_m2m_fop_poll()