Lines Matching refs:ctx
31 static int gsc_m2m_ctx_stop_req(struct gsc_ctx *ctx) in gsc_m2m_ctx_stop_req() argument
34 struct gsc_dev *gsc = ctx->gsc_dev; in gsc_m2m_ctx_stop_req()
38 if (!gsc_m2m_pending(gsc) || (curr_ctx != ctx)) in gsc_m2m_ctx_stop_req()
41 gsc_ctx_state_lock_set(GSC_CTX_STOP_REQ, ctx); in gsc_m2m_ctx_stop_req()
43 !gsc_ctx_state_is_set(GSC_CTX_STOP_REQ, ctx), in gsc_m2m_ctx_stop_req()
49 static void __gsc_m2m_job_abort(struct gsc_ctx *ctx) in __gsc_m2m_job_abort() argument
53 ret = gsc_m2m_ctx_stop_req(ctx); in __gsc_m2m_job_abort()
54 if ((ret == -ETIMEDOUT) || (ctx->state & GSC_CTX_ABORT)) { in __gsc_m2m_job_abort()
55 gsc_ctx_state_lock_clear(GSC_CTX_STOP_REQ | GSC_CTX_ABORT, ctx); in __gsc_m2m_job_abort()
56 gsc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR); in __gsc_m2m_job_abort()
62 struct gsc_ctx *ctx = q->drv_priv; in gsc_m2m_start_streaming() local
65 ret = pm_runtime_get_sync(&ctx->gsc_dev->pdev->dev); in gsc_m2m_start_streaming()
71 struct gsc_ctx *ctx = q->drv_priv; in gsc_m2m_stop_streaming() local
73 __gsc_m2m_job_abort(ctx); in gsc_m2m_stop_streaming()
75 pm_runtime_put(&ctx->gsc_dev->pdev->dev); in gsc_m2m_stop_streaming()
78 void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state) in gsc_m2m_job_finish() argument
82 if (!ctx || !ctx->m2m_ctx) in gsc_m2m_job_finish()
85 src_vb = v4l2_m2m_src_buf_remove(ctx->m2m_ctx); in gsc_m2m_job_finish()
86 dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); in gsc_m2m_job_finish()
99 v4l2_m2m_job_finish(ctx->gsc_dev->m2m.m2m_dev, in gsc_m2m_job_finish()
100 ctx->m2m_ctx); in gsc_m2m_job_finish()
109 static int gsc_get_bufs(struct gsc_ctx *ctx) in gsc_get_bufs() argument
115 s_frame = &ctx->s_frame; in gsc_get_bufs()
116 d_frame = &ctx->d_frame; in gsc_get_bufs()
118 src_vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx); in gsc_get_bufs()
119 ret = gsc_prepare_addr(ctx, src_vb, s_frame, &s_frame->addr); in gsc_get_bufs()
123 dst_vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); in gsc_get_bufs()
124 ret = gsc_prepare_addr(ctx, dst_vb, d_frame, &d_frame->addr); in gsc_get_bufs()
135 struct gsc_ctx *ctx = priv; in gsc_m2m_device_run() local
141 if (WARN(!ctx, "null hardware context\n")) in gsc_m2m_device_run()
144 gsc = ctx->gsc_dev; in gsc_m2m_device_run()
150 if (gsc->m2m.ctx != ctx) { in gsc_m2m_device_run()
152 gsc->m2m.ctx, ctx); in gsc_m2m_device_run()
153 ctx->state |= GSC_PARAMS; in gsc_m2m_device_run()
154 gsc->m2m.ctx = ctx; in gsc_m2m_device_run()
157 is_set = ctx->state & GSC_CTX_STOP_REQ; in gsc_m2m_device_run()
159 ctx->state &= ~GSC_CTX_STOP_REQ; in gsc_m2m_device_run()
160 ctx->state |= GSC_CTX_ABORT; in gsc_m2m_device_run()
165 ret = gsc_get_bufs(ctx); in gsc_m2m_device_run()
171 gsc_set_prefbuf(gsc, &ctx->s_frame); in gsc_m2m_device_run()
172 gsc_hw_set_input_addr(gsc, &ctx->s_frame.addr, GSC_M2M_BUF_NUM); in gsc_m2m_device_run()
173 gsc_hw_set_output_addr(gsc, &ctx->d_frame.addr, GSC_M2M_BUF_NUM); in gsc_m2m_device_run()
175 if (ctx->state & GSC_PARAMS) { in gsc_m2m_device_run()
181 if (gsc_set_scaler_info(ctx)) { in gsc_m2m_device_run()
186 gsc_hw_set_input_path(ctx); in gsc_m2m_device_run()
187 gsc_hw_set_in_size(ctx); in gsc_m2m_device_run()
188 gsc_hw_set_in_image_format(ctx); in gsc_m2m_device_run()
190 gsc_hw_set_output_path(ctx); in gsc_m2m_device_run()
191 gsc_hw_set_out_size(ctx); in gsc_m2m_device_run()
192 gsc_hw_set_out_image_format(ctx); in gsc_m2m_device_run()
194 gsc_hw_set_prescaler(ctx); in gsc_m2m_device_run()
195 gsc_hw_set_mainscaler(ctx); in gsc_m2m_device_run()
196 gsc_hw_set_rotation(ctx); in gsc_m2m_device_run()
197 gsc_hw_set_global_alpha(ctx); in gsc_m2m_device_run()
201 gsc_hw_set_sfr_update(ctx); in gsc_m2m_device_run()
203 ctx->state &= ~GSC_PARAMS; in gsc_m2m_device_run()
210 ctx->state &= ~GSC_PARAMS; in gsc_m2m_device_run()
219 struct gsc_ctx *ctx = vb2_get_drv_priv(vq); in gsc_m2m_queue_setup() local
223 frame = ctx_get_frame(ctx, vq->type); in gsc_m2m_queue_setup()
233 allocators[i] = ctx->gsc_dev->alloc_ctx; in gsc_m2m_queue_setup()
240 struct gsc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in gsc_m2m_buf_prepare() local
244 frame = ctx_get_frame(ctx, vb->vb2_queue->type); in gsc_m2m_buf_prepare()
258 struct gsc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in gsc_m2m_buf_queue() local
260 pr_debug("ctx: %p, ctx->state: 0x%x", ctx, ctx->state); in gsc_m2m_buf_queue()
262 if (ctx->m2m_ctx) in gsc_m2m_buf_queue()
263 v4l2_m2m_buf_queue(ctx->m2m_ctx, vb); in gsc_m2m_buf_queue()
279 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_querycap() local
280 struct gsc_dev *gsc = ctx->gsc_dev; in gsc_m2m_querycap()
301 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_g_fmt_mplane() local
303 return gsc_g_fmt_mplane(ctx, f); in gsc_m2m_g_fmt_mplane()
309 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_try_fmt_mplane() local
311 return gsc_try_fmt_mplane(ctx, f); in gsc_m2m_try_fmt_mplane()
317 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_s_fmt_mplane() local
327 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); in gsc_m2m_s_fmt_mplane()
335 frame = &ctx->s_frame; in gsc_m2m_s_fmt_mplane()
337 frame = &ctx->d_frame; in gsc_m2m_s_fmt_mplane()
351 gsc_ctx_state_lock_set(GSC_PARAMS | GSC_DST_FMT, ctx); in gsc_m2m_s_fmt_mplane()
353 gsc_ctx_state_lock_set(GSC_PARAMS | GSC_SRC_FMT, ctx); in gsc_m2m_s_fmt_mplane()
363 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_reqbufs() local
364 struct gsc_dev *gsc = ctx->gsc_dev; in gsc_m2m_reqbufs()
373 gsc_ctx_state_lock_clear(GSC_SRC_FMT, ctx); in gsc_m2m_reqbufs()
375 gsc_ctx_state_lock_clear(GSC_DST_FMT, ctx); in gsc_m2m_reqbufs()
378 return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs); in gsc_m2m_reqbufs()
384 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_expbuf() local
385 return v4l2_m2m_expbuf(file, ctx->m2m_ctx, eb); in gsc_m2m_expbuf()
391 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_querybuf() local
392 return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf); in gsc_m2m_querybuf()
398 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_qbuf() local
399 return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf); in gsc_m2m_qbuf()
405 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_dqbuf() local
406 return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf); in gsc_m2m_dqbuf()
412 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_streamon() local
416 if (!gsc_ctx_state_is_set(GSC_SRC_FMT, ctx)) in gsc_m2m_streamon()
418 } else if (!gsc_ctx_state_is_set(GSC_DST_FMT, ctx)) { in gsc_m2m_streamon()
422 return v4l2_m2m_streamon(file, ctx->m2m_ctx, type); in gsc_m2m_streamon()
428 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_streamoff() local
429 return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type); in gsc_m2m_streamoff()
451 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_g_selection() local
457 frame = ctx_get_frame(ctx, s->type); in gsc_m2m_g_selection()
488 struct gsc_ctx *ctx = fh_to_ctx(fh); in gsc_m2m_s_selection() local
490 struct gsc_variant *variant = ctx->gsc_dev->variant; in gsc_m2m_s_selection()
500 ret = gsc_try_crop(ctx, &cr); in gsc_m2m_s_selection()
518 frame = &ctx->s_frame; in gsc_m2m_s_selection()
524 frame = &ctx->d_frame; in gsc_m2m_s_selection()
532 if (gsc_ctx_state_is_set(GSC_DST_FMT | GSC_SRC_FMT, ctx)) { in gsc_m2m_s_selection()
535 cr.c.height, ctx->d_frame.crop.width, in gsc_m2m_s_selection()
536 ctx->d_frame.crop.height, in gsc_m2m_s_selection()
537 ctx->gsc_ctrls.rotate->val, ctx->out_path); in gsc_m2m_s_selection()
540 ctx->s_frame.crop.width, in gsc_m2m_s_selection()
541 ctx->s_frame.crop.height, cr.c.width, in gsc_m2m_s_selection()
542 cr.c.height, ctx->gsc_ctrls.rotate->val, in gsc_m2m_s_selection()
543 ctx->out_path); in gsc_m2m_s_selection()
554 gsc_ctx_state_lock_set(GSC_PARAMS, ctx); in gsc_m2m_s_selection()
582 struct gsc_ctx *ctx = priv; in queue_init() local
588 src_vq->drv_priv = ctx; in queue_init()
593 src_vq->lock = &ctx->gsc_dev->lock; in queue_init()
602 dst_vq->drv_priv = ctx; in queue_init()
607 dst_vq->lock = &ctx->gsc_dev->lock; in queue_init()
615 struct gsc_ctx *ctx = NULL; in gsc_m2m_open() local
623 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); in gsc_m2m_open()
624 if (!ctx) { in gsc_m2m_open()
629 v4l2_fh_init(&ctx->fh, gsc->m2m.vfd); in gsc_m2m_open()
630 ret = gsc_ctrls_create(ctx); in gsc_m2m_open()
635 ctx->fh.ctrl_handler = &ctx->ctrl_handler; in gsc_m2m_open()
636 file->private_data = &ctx->fh; in gsc_m2m_open()
637 v4l2_fh_add(&ctx->fh); in gsc_m2m_open()
639 ctx->gsc_dev = gsc; in gsc_m2m_open()
641 ctx->s_frame.fmt = get_format(0); in gsc_m2m_open()
642 ctx->d_frame.fmt = get_format(0); in gsc_m2m_open()
644 ctx->state = GSC_CTX_M2M; in gsc_m2m_open()
645 ctx->flags = 0; in gsc_m2m_open()
646 ctx->in_path = GSC_DMA; in gsc_m2m_open()
647 ctx->out_path = GSC_DMA; in gsc_m2m_open()
649 ctx->m2m_ctx = v4l2_m2m_ctx_init(gsc->m2m.m2m_dev, ctx, queue_init); in gsc_m2m_open()
650 if (IS_ERR(ctx->m2m_ctx)) { in gsc_m2m_open()
652 ret = PTR_ERR(ctx->m2m_ctx); in gsc_m2m_open()
659 pr_debug("gsc m2m driver is opened, ctx(0x%p)", ctx); in gsc_m2m_open()
665 gsc_ctrls_delete(ctx); in gsc_m2m_open()
667 v4l2_fh_del(&ctx->fh); in gsc_m2m_open()
668 v4l2_fh_exit(&ctx->fh); in gsc_m2m_open()
669 kfree(ctx); in gsc_m2m_open()
677 struct gsc_ctx *ctx = fh_to_ctx(file->private_data); in gsc_m2m_release() local
678 struct gsc_dev *gsc = ctx->gsc_dev; in gsc_m2m_release()
685 v4l2_m2m_ctx_release(ctx->m2m_ctx); in gsc_m2m_release()
686 gsc_ctrls_delete(ctx); in gsc_m2m_release()
687 v4l2_fh_del(&ctx->fh); in gsc_m2m_release()
688 v4l2_fh_exit(&ctx->fh); in gsc_m2m_release()
692 kfree(ctx); in gsc_m2m_release()
701 struct gsc_ctx *ctx = fh_to_ctx(file->private_data); in gsc_m2m_poll() local
702 struct gsc_dev *gsc = ctx->gsc_dev; in gsc_m2m_poll()
708 ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait); in gsc_m2m_poll()
716 struct gsc_ctx *ctx = fh_to_ctx(file->private_data); in gsc_m2m_mmap() local
717 struct gsc_dev *gsc = ctx->gsc_dev; in gsc_m2m_mmap()
723 ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma); in gsc_m2m_mmap()