Lines Matching refs:ctx

187 static struct vim2m_q_data *get_q_data(struct vim2m_ctx *ctx,  in get_q_data()  argument
192 return &ctx->q_data[V4L2_M2M_SRC]; in get_q_data()
194 return &ctx->q_data[V4L2_M2M_DST]; in get_q_data()
202 static int device_process(struct vim2m_ctx *ctx, in device_process() argument
206 struct vim2m_dev *dev = ctx->dev; in device_process()
213 q_data = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); in device_process()
237 out_vb->v4l2_buf.sequence = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE)->sequence++; in device_process()
253 switch (ctx->mode) { in device_process()
351 struct vim2m_ctx *ctx = priv; in job_ready() local
353 if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen in job_ready()
354 || v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen) { in job_ready()
355 dprintk(ctx->dev, "Not enough buffers available\n"); in job_ready()
364 struct vim2m_ctx *ctx = priv; in job_abort() local
367 ctx->aborting = 1; in job_abort()
378 struct vim2m_ctx *ctx = priv; in device_run() local
379 struct vim2m_dev *dev = ctx->dev; in device_run()
382 src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); in device_run()
383 dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); in device_run()
385 device_process(ctx, src_buf, dst_buf); in device_run()
388 schedule_irq(dev, ctx->transtime); in device_run()
482 static int vidioc_g_fmt(struct vim2m_ctx *ctx, struct v4l2_format *f) in vidioc_g_fmt() argument
487 vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); in vidioc_g_fmt()
491 q_data = get_q_data(ctx, f->type); in vidioc_g_fmt()
499 f->fmt.pix.colorspace = ctx->colorspace; in vidioc_g_fmt()
542 struct vim2m_ctx *ctx = file2ctx(file); in vidioc_try_fmt_vid_cap() local
550 v4l2_err(&ctx->dev->v4l2_dev, in vidioc_try_fmt_vid_cap()
555 f->fmt.pix.colorspace = ctx->colorspace; in vidioc_try_fmt_vid_cap()
564 struct vim2m_ctx *ctx = file2ctx(file); in vidioc_try_fmt_vid_out() local
572 v4l2_err(&ctx->dev->v4l2_dev, in vidioc_try_fmt_vid_out()
583 static int vidioc_s_fmt(struct vim2m_ctx *ctx, struct v4l2_format *f) in vidioc_s_fmt() argument
588 vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); in vidioc_s_fmt()
592 q_data = get_q_data(ctx, f->type); in vidioc_s_fmt()
597 v4l2_err(&ctx->dev->v4l2_dev, "%s queue busy\n", __func__); in vidioc_s_fmt()
607 dprintk(ctx->dev, in vidioc_s_fmt()
629 struct vim2m_ctx *ctx = file2ctx(file); in vidioc_s_fmt_vid_out() local
638 ctx->colorspace = f->fmt.pix.colorspace; in vidioc_s_fmt_vid_out()
644 struct vim2m_ctx *ctx = in vim2m_s_ctrl() local
650 ctx->mode |= MEM2MEM_HFLIP; in vim2m_s_ctrl()
652 ctx->mode &= ~MEM2MEM_HFLIP; in vim2m_s_ctrl()
657 ctx->mode |= MEM2MEM_VFLIP; in vim2m_s_ctrl()
659 ctx->mode &= ~MEM2MEM_VFLIP; in vim2m_s_ctrl()
663 ctx->transtime = ctrl->val; in vim2m_s_ctrl()
667 ctx->translen = ctrl->val; in vim2m_s_ctrl()
671 v4l2_err(&ctx->dev->v4l2_dev, "Invalid control\n"); in vim2m_s_ctrl()
719 struct vim2m_ctx *ctx = vb2_get_drv_priv(vq); in vim2m_queue_setup() local
723 q_data = get_q_data(ctx, vq->type); in vim2m_queue_setup()
739 dprintk(ctx->dev, "get %d buffer(s) of size %d each.\n", count, size); in vim2m_queue_setup()
746 struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in vim2m_buf_prepare() local
749 dprintk(ctx->dev, "type: %d\n", vb->vb2_queue->type); in vim2m_buf_prepare()
751 q_data = get_q_data(ctx, vb->vb2_queue->type); in vim2m_buf_prepare()
756 dprintk(ctx->dev, "%s field isn't supported\n", in vim2m_buf_prepare()
763 dprintk(ctx->dev, "%s data will not fit into plane (%lu < %lu)\n", in vim2m_buf_prepare()
775 struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in vim2m_buf_queue() local
777 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb); in vim2m_buf_queue()
782 struct vim2m_ctx *ctx = vb2_get_drv_priv(q); in vim2m_start_streaming() local
783 struct vim2m_q_data *q_data = get_q_data(ctx, q->type); in vim2m_start_streaming()
791 struct vim2m_ctx *ctx = vb2_get_drv_priv(q); in vim2m_stop_streaming() local
797 vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); in vim2m_stop_streaming()
799 vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); in vim2m_stop_streaming()
802 spin_lock_irqsave(&ctx->dev->irqlock, flags); in vim2m_stop_streaming()
804 spin_unlock_irqrestore(&ctx->dev->irqlock, flags); in vim2m_stop_streaming()
820 struct vim2m_ctx *ctx = priv; in queue_init() local
825 src_vq->drv_priv = ctx; in queue_init()
830 src_vq->lock = &ctx->dev->dev_mutex; in queue_init()
838 dst_vq->drv_priv = ctx; in queue_init()
843 dst_vq->lock = &ctx->dev->dev_mutex; in queue_init()
876 struct vim2m_ctx *ctx = NULL; in vim2m_open() local
882 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); in vim2m_open()
883 if (!ctx) { in vim2m_open()
888 v4l2_fh_init(&ctx->fh, video_devdata(file)); in vim2m_open()
889 file->private_data = &ctx->fh; in vim2m_open()
890 ctx->dev = dev; in vim2m_open()
891 hdl = &ctx->hdl; in vim2m_open()
902 ctx->fh.ctrl_handler = hdl; in vim2m_open()
905 ctx->q_data[V4L2_M2M_SRC].fmt = &formats[0]; in vim2m_open()
906 ctx->q_data[V4L2_M2M_SRC].width = 640; in vim2m_open()
907 ctx->q_data[V4L2_M2M_SRC].height = 480; in vim2m_open()
908 ctx->q_data[V4L2_M2M_SRC].sizeimage = in vim2m_open()
909 ctx->q_data[V4L2_M2M_SRC].width * in vim2m_open()
910 ctx->q_data[V4L2_M2M_SRC].height * in vim2m_open()
911 (ctx->q_data[V4L2_M2M_SRC].fmt->depth >> 3); in vim2m_open()
912 ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC]; in vim2m_open()
913 ctx->colorspace = V4L2_COLORSPACE_REC709; in vim2m_open()
915 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init); in vim2m_open()
917 if (IS_ERR(ctx->fh.m2m_ctx)) { in vim2m_open()
918 rc = PTR_ERR(ctx->fh.m2m_ctx); in vim2m_open()
921 kfree(ctx); in vim2m_open()
925 v4l2_fh_add(&ctx->fh); in vim2m_open()
929 ctx, ctx->fh.m2m_ctx); in vim2m_open()
939 struct vim2m_ctx *ctx = file2ctx(file); in vim2m_release() local
941 dprintk(dev, "Releasing instance %p\n", ctx); in vim2m_release()
943 v4l2_fh_del(&ctx->fh); in vim2m_release()
944 v4l2_fh_exit(&ctx->fh); in vim2m_release()
945 v4l2_ctrl_handler_free(&ctx->hdl); in vim2m_release()
947 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); in vim2m_release()
949 kfree(ctx); in vim2m_release()