Lines Matching refs:ctx
184 static struct vim2m_q_data *get_q_data(struct vim2m_ctx *ctx, in get_q_data() argument
189 return &ctx->q_data[V4L2_M2M_SRC]; in get_q_data()
191 return &ctx->q_data[V4L2_M2M_DST]; in get_q_data()
199 static int device_process(struct vim2m_ctx *ctx, in device_process() argument
203 struct vim2m_dev *dev = ctx->dev; in device_process()
210 q_data = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); in device_process()
236 get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE)->sequence++; in device_process()
250 switch (ctx->mode) { in device_process()
348 struct vim2m_ctx *ctx = priv; in job_ready() local
350 if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen in job_ready()
351 || v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen) { in job_ready()
352 dprintk(ctx->dev, "Not enough buffers available\n"); in job_ready()
361 struct vim2m_ctx *ctx = priv; in job_abort() local
364 ctx->aborting = 1; in job_abort()
375 struct vim2m_ctx *ctx = priv; in device_run() local
376 struct vim2m_dev *dev = ctx->dev; in device_run()
379 src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); in device_run()
380 dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); in device_run()
382 device_process(ctx, src_buf, dst_buf); in device_run()
385 schedule_irq(dev, ctx->transtime); in device_run()
478 static int vidioc_g_fmt(struct vim2m_ctx *ctx, struct v4l2_format *f) in vidioc_g_fmt() argument
483 vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); in vidioc_g_fmt()
487 q_data = get_q_data(ctx, f->type); in vidioc_g_fmt()
495 f->fmt.pix.colorspace = ctx->colorspace; in vidioc_g_fmt()
538 struct vim2m_ctx *ctx = file2ctx(file); in vidioc_try_fmt_vid_cap() local
546 v4l2_err(&ctx->dev->v4l2_dev, in vidioc_try_fmt_vid_cap()
551 f->fmt.pix.colorspace = ctx->colorspace; in vidioc_try_fmt_vid_cap()
560 struct vim2m_ctx *ctx = file2ctx(file); in vidioc_try_fmt_vid_out() local
568 v4l2_err(&ctx->dev->v4l2_dev, in vidioc_try_fmt_vid_out()
579 static int vidioc_s_fmt(struct vim2m_ctx *ctx, struct v4l2_format *f) in vidioc_s_fmt() argument
584 vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); in vidioc_s_fmt()
588 q_data = get_q_data(ctx, f->type); in vidioc_s_fmt()
593 v4l2_err(&ctx->dev->v4l2_dev, "%s queue busy\n", __func__); in vidioc_s_fmt()
603 dprintk(ctx->dev, in vidioc_s_fmt()
625 struct vim2m_ctx *ctx = file2ctx(file); in vidioc_s_fmt_vid_out() local
634 ctx->colorspace = f->fmt.pix.colorspace; in vidioc_s_fmt_vid_out()
640 struct vim2m_ctx *ctx = in vim2m_s_ctrl() local
646 ctx->mode |= MEM2MEM_HFLIP; in vim2m_s_ctrl()
648 ctx->mode &= ~MEM2MEM_HFLIP; in vim2m_s_ctrl()
653 ctx->mode |= MEM2MEM_VFLIP; in vim2m_s_ctrl()
655 ctx->mode &= ~MEM2MEM_VFLIP; in vim2m_s_ctrl()
659 ctx->transtime = ctrl->val; in vim2m_s_ctrl()
663 ctx->translen = ctrl->val; in vim2m_s_ctrl()
667 v4l2_err(&ctx->dev->v4l2_dev, "Invalid control\n"); in vim2m_s_ctrl()
718 struct vim2m_ctx *ctx = vb2_get_drv_priv(vq); in vim2m_queue_setup() local
722 q_data = get_q_data(ctx, vq->type); in vim2m_queue_setup()
744 dprintk(ctx->dev, "get %d buffer(s) of size %d each.\n", count, size); in vim2m_queue_setup()
752 struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in vim2m_buf_prepare() local
755 dprintk(ctx->dev, "type: %d\n", vb->vb2_queue->type); in vim2m_buf_prepare()
757 q_data = get_q_data(ctx, vb->vb2_queue->type); in vim2m_buf_prepare()
762 dprintk(ctx->dev, "%s field isn't supported\n", in vim2m_buf_prepare()
769 dprintk(ctx->dev, "%s data will not fit into plane (%lu < %lu)\n", in vim2m_buf_prepare()
782 struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in vim2m_buf_queue() local
784 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); in vim2m_buf_queue()
789 struct vim2m_ctx *ctx = vb2_get_drv_priv(q); in vim2m_start_streaming() local
790 struct vim2m_q_data *q_data = get_q_data(ctx, q->type); in vim2m_start_streaming()
798 struct vim2m_ctx *ctx = vb2_get_drv_priv(q); in vim2m_stop_streaming() local
804 vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); in vim2m_stop_streaming()
806 vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); in vim2m_stop_streaming()
809 spin_lock_irqsave(&ctx->dev->irqlock, flags); in vim2m_stop_streaming()
811 spin_unlock_irqrestore(&ctx->dev->irqlock, flags); in vim2m_stop_streaming()
827 struct vim2m_ctx *ctx = priv; in queue_init() local
832 src_vq->drv_priv = ctx; in queue_init()
837 src_vq->lock = &ctx->dev->dev_mutex; in queue_init()
845 dst_vq->drv_priv = ctx; in queue_init()
850 dst_vq->lock = &ctx->dev->dev_mutex; in queue_init()
883 struct vim2m_ctx *ctx = NULL; in vim2m_open() local
889 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); in vim2m_open()
890 if (!ctx) { in vim2m_open()
895 v4l2_fh_init(&ctx->fh, video_devdata(file)); in vim2m_open()
896 file->private_data = &ctx->fh; in vim2m_open()
897 ctx->dev = dev; in vim2m_open()
898 hdl = &ctx->hdl; in vim2m_open()
909 ctx->fh.ctrl_handler = hdl; in vim2m_open()
912 ctx->q_data[V4L2_M2M_SRC].fmt = &formats[0]; in vim2m_open()
913 ctx->q_data[V4L2_M2M_SRC].width = 640; in vim2m_open()
914 ctx->q_data[V4L2_M2M_SRC].height = 480; in vim2m_open()
915 ctx->q_data[V4L2_M2M_SRC].sizeimage = in vim2m_open()
916 ctx->q_data[V4L2_M2M_SRC].width * in vim2m_open()
917 ctx->q_data[V4L2_M2M_SRC].height * in vim2m_open()
918 (ctx->q_data[V4L2_M2M_SRC].fmt->depth >> 3); in vim2m_open()
919 ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC]; in vim2m_open()
920 ctx->colorspace = V4L2_COLORSPACE_REC709; in vim2m_open()
922 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init); in vim2m_open()
924 if (IS_ERR(ctx->fh.m2m_ctx)) { in vim2m_open()
925 rc = PTR_ERR(ctx->fh.m2m_ctx); in vim2m_open()
928 kfree(ctx); in vim2m_open()
932 v4l2_fh_add(&ctx->fh); in vim2m_open()
936 ctx, ctx->fh.m2m_ctx); in vim2m_open()
946 struct vim2m_ctx *ctx = file2ctx(file); in vim2m_release() local
948 dprintk(dev, "Releasing instance %p\n", ctx); in vim2m_release()
950 v4l2_fh_del(&ctx->fh); in vim2m_release()
951 v4l2_fh_exit(&ctx->fh); in vim2m_release()
952 v4l2_ctrl_handler_free(&ctx->hdl); in vim2m_release()
954 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); in vim2m_release()
956 kfree(ctx); in vim2m_release()