Lines Matching refs:ctx

671 	struct jpu_ctx *ctx = fh_to_ctx(priv);  in jpu_querycap()  local
673 if (ctx->encoder) in jpu_querycap()
680 dev_name(ctx->jpu->dev)); in jpu_querycap()
733 struct jpu_ctx *ctx = fh_to_ctx(priv); in jpu_enum_fmt_cap() local
735 return jpu_enum_fmt(f, ctx->encoder ? JPU_ENC_CAPTURE : in jpu_enum_fmt_cap()
742 struct jpu_ctx *ctx = fh_to_ctx(priv); in jpu_enum_fmt_out() local
744 return jpu_enum_fmt(f, ctx->encoder ? JPU_ENC_OUTPUT : JPU_DEC_OUTPUT); in jpu_enum_fmt_out()
747 static struct jpu_q_data *jpu_get_q_data(struct jpu_ctx *ctx, in jpu_get_q_data() argument
751 return &ctx->out_q; in jpu_get_q_data()
753 return &ctx->cap_q; in jpu_get_q_data()
777 static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo, in __jpu_try_fmt() argument
787 fmt = jpu_find_format(ctx->encoder, pix->pixelformat, f_type); in __jpu_try_fmt()
791 dev_dbg(ctx->jpu->dev, "unknown format; set default format\n"); in __jpu_try_fmt()
792 if (ctx->encoder) in __jpu_try_fmt()
798 fmt = jpu_find_format(ctx->encoder, pixelformat, f_type); in __jpu_try_fmt()
816 if (pix->plane_fmt[0].sizeimage <= 0 || ctx->encoder) in __jpu_try_fmt()
847 struct jpu_ctx *ctx = fh_to_ctx(priv); in jpu_try_fmt() local
849 if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type)) in jpu_try_fmt()
852 return __jpu_try_fmt(ctx, NULL, &f->fmt.pix_mp, f->type); in jpu_try_fmt()
858 struct jpu_ctx *ctx = fh_to_ctx(priv); in jpu_s_fmt() local
859 struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; in jpu_s_fmt()
869 v4l2_err(&ctx->jpu->v4l2_dev, "%s queue busy\n", __func__); in jpu_s_fmt()
873 ret = __jpu_try_fmt(ctx, &fmtinfo, &f->fmt.pix_mp, f->type); in jpu_s_fmt()
877 q_data = jpu_get_q_data(ctx, f->type); in jpu_s_fmt()
888 struct jpu_ctx *ctx = fh_to_ctx(priv); in jpu_g_fmt() local
890 if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type)) in jpu_g_fmt()
893 q_data = jpu_get_q_data(ctx, f->type); in jpu_g_fmt()
904 struct jpu_ctx *ctx = ctrl_to_ctx(ctrl); in jpu_s_ctrl() local
907 spin_lock_irqsave(&ctx->jpu->lock, flags); in jpu_s_ctrl()
909 ctx->compr_quality = ctrl->val; in jpu_s_ctrl()
910 spin_unlock_irqrestore(&ctx->jpu->lock, flags); in jpu_s_ctrl()
921 struct jpu_ctx *ctx = fh_to_ctx(priv); in jpu_streamon() local
925 src_q_data = jpu_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); in jpu_streamon()
926 dst_q_data = jpu_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); in jpu_streamon()
928 if (ctx->encoder) { in jpu_streamon()
943 __jpu_try_fmt(ctx, NULL, &adj.format, adj_type); in jpu_streamon()
947 dev_err(ctx->jpu->dev, "src and dst formats do not match.\n"); in jpu_streamon()
952 return v4l2_m2m_streamon(file, ctx->fh.m2m_ctx, type); in jpu_streamon()
981 static int jpu_controls_create(struct jpu_ctx *ctx) in jpu_controls_create() argument
986 v4l2_ctrl_handler_init(&ctx->ctrl_handler, 1); in jpu_controls_create()
988 ctrl = v4l2_ctrl_new_std(&ctx->ctrl_handler, &jpu_ctrl_ops, in jpu_controls_create()
992 if (ctx->ctrl_handler.error) { in jpu_controls_create()
993 ret = ctx->ctrl_handler.error; in jpu_controls_create()
997 if (!ctx->encoder) in jpu_controls_create()
1001 ret = v4l2_ctrl_handler_setup(&ctx->ctrl_handler); in jpu_controls_create()
1008 v4l2_ctrl_handler_free(&ctx->ctrl_handler); in jpu_controls_create()
1023 struct jpu_ctx *ctx = vb2_get_drv_priv(vq); in jpu_queue_setup() local
1027 q_data = jpu_get_q_data(ctx, vq->type); in jpu_queue_setup()
1040 alloc_ctxs[i] = ctx->jpu->alloc_ctx; in jpu_queue_setup()
1049 struct jpu_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in jpu_buf_prepare() local
1053 q_data = jpu_get_q_data(ctx, vb->vb2_queue->type); in jpu_buf_prepare()
1059 dev_err(ctx->jpu->dev, "%s field isn't supported\n", in jpu_buf_prepare()
1069 dev_err(ctx->jpu->dev, in jpu_buf_prepare()
1076 if (!ctx->encoder && !V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) in jpu_buf_prepare()
1086 struct jpu_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in jpu_buf_queue() local
1088 if (!ctx->encoder && V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) { in jpu_buf_queue()
1102 q_data = &ctx->out_q; in jpu_buf_queue()
1108 __jpu_try_fmt(ctx, &adjust.fmtinfo, &adjust.format, in jpu_buf_queue()
1122 if (ctx->fh.m2m_ctx) in jpu_buf_queue()
1123 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); in jpu_buf_queue()
1128 dev_err(ctx->jpu->dev, "incompatible or corrupted JPEG data\n"); in jpu_buf_queue()
1136 struct jpu_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in jpu_buf_finish() local
1137 struct jpu_q_data *q_data = &ctx->out_q; in jpu_buf_finish()
1142 vbuf->sequence = jpu_get_q_data(ctx, type)->sequence++; in jpu_buf_finish()
1144 if (!ctx->encoder || vb->state != VB2_BUF_STATE_DONE || in jpu_buf_finish()
1160 struct jpu_ctx *ctx = vb2_get_drv_priv(vq); in jpu_start_streaming() local
1161 struct jpu_q_data *q_data = jpu_get_q_data(ctx, vq->type); in jpu_start_streaming()
1169 struct jpu_ctx *ctx = vb2_get_drv_priv(vq); in jpu_stop_streaming() local
1175 vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); in jpu_stop_streaming()
1177 vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); in jpu_stop_streaming()
1180 spin_lock_irqsave(&ctx->jpu->lock, flags); in jpu_stop_streaming()
1182 spin_unlock_irqrestore(&ctx->jpu->lock, flags); in jpu_stop_streaming()
1200 struct jpu_ctx *ctx = priv; in jpu_queue_init() local
1206 src_vq->drv_priv = ctx; in jpu_queue_init()
1211 src_vq->lock = &ctx->jpu->mutex; in jpu_queue_init()
1220 dst_vq->drv_priv = ctx; in jpu_queue_init()
1225 dst_vq->lock = &ctx->jpu->mutex; in jpu_queue_init()
1239 struct jpu_ctx *ctx; in jpu_open() local
1242 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); in jpu_open()
1243 if (!ctx) in jpu_open()
1246 v4l2_fh_init(&ctx->fh, vfd); in jpu_open()
1247 ctx->fh.ctrl_handler = &ctx->ctrl_handler; in jpu_open()
1248 file->private_data = &ctx->fh; in jpu_open()
1249 v4l2_fh_add(&ctx->fh); in jpu_open()
1251 ctx->jpu = jpu; in jpu_open()
1252 ctx->encoder = vfd == &jpu->vfd_encoder; in jpu_open()
1254 __jpu_try_fmt(ctx, &ctx->out_q.fmtinfo, &ctx->out_q.format, in jpu_open()
1256 __jpu_try_fmt(ctx, &ctx->cap_q.fmtinfo, &ctx->cap_q.format, in jpu_open()
1259 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(jpu->m2m_dev, ctx, jpu_queue_init); in jpu_open()
1260 if (IS_ERR(ctx->fh.m2m_ctx)) { in jpu_open()
1261 ret = PTR_ERR(ctx->fh.m2m_ctx); in jpu_open()
1265 ret = jpu_controls_create(ctx); in jpu_open()
1292 v4l2_fh_del(&ctx->fh); in jpu_open()
1293 v4l2_fh_exit(&ctx->fh); in jpu_open()
1294 kfree(ctx); in jpu_open()
1301 struct jpu_ctx *ctx = fh_to_ctx(file->private_data); in jpu_release() local
1308 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); in jpu_release()
1309 v4l2_ctrl_handler_free(&ctx->ctrl_handler); in jpu_release()
1310 v4l2_fh_del(&ctx->fh); in jpu_release()
1311 v4l2_fh_exit(&ctx->fh); in jpu_release()
1312 kfree(ctx); in jpu_release()
1331 static void jpu_cleanup(struct jpu_ctx *ctx, bool reset) in jpu_cleanup() argument
1337 spin_lock_irqsave(&ctx->jpu->lock, flags); in jpu_cleanup()
1339 src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); in jpu_cleanup()
1340 dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); in jpu_cleanup()
1347 jpu_write(ctx->jpu, JCCMD_SRST, JCCMD); in jpu_cleanup()
1349 spin_unlock_irqrestore(&ctx->jpu->lock, flags); in jpu_cleanup()
1351 v4l2_m2m_job_finish(ctx->jpu->m2m_dev, ctx->fh.m2m_ctx); in jpu_cleanup()
1356 struct jpu_ctx *ctx = priv; in jpu_device_run() local
1357 struct jpu *jpu = ctx->jpu; in jpu_device_run()
1367 jpu_cleanup(ctx, true); in jpu_device_run()
1371 spin_lock_irqsave(&ctx->jpu->lock, flags); in jpu_device_run()
1373 jpu->curr = ctx; in jpu_device_run()
1375 src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); in jpu_device_run()
1376 dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); in jpu_device_run()
1378 if (ctx->encoder) { in jpu_device_run()
1380 q_data = &ctx->out_q; in jpu_device_run()
1383 q_data = &ctx->cap_q; in jpu_device_run()
1392 if (ctx->encoder) { in jpu_device_run()
1405 jpu_buf->compr_quality = ctx->compr_quality; in jpu_device_run()
1449 jpu_set_qtbl(jpu, ctx->compr_quality); in jpu_device_run()
1455 dev_err(ctx->jpu->dev, in jpu_device_run()
1457 spin_unlock_irqrestore(&ctx->jpu->lock, flags); in jpu_device_run()
1458 jpu_cleanup(ctx, false); in jpu_device_run()
1490 spin_unlock_irqrestore(&ctx->jpu->lock, flags); in jpu_device_run()
1500 struct jpu_ctx *ctx = priv; in jpu_job_abort() local
1502 if (!wait_event_timeout(ctx->jpu->irq_queue, !ctx->jpu->curr, in jpu_job_abort()
1504 jpu_cleanup(ctx, true); in jpu_job_abort()