Commit fde649b4 authored by Dafna Hirschfeld's avatar Dafna Hirschfeld Committed by Mauro Carvalho Chehab

media: vicodec: Register another node for stateless decoder

Add stateless decoder instance field to the dev struct and
register another node for the statelsess decoder.
The stateless API for the node will be implemented in further patches.
Signed-off-by: default avatarDafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: fix typo: videdev-stateless-dec -> stateless-decoder]
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent f05a51b9
...@@ -104,6 +104,7 @@ struct vicodec_dev { ...@@ -104,6 +104,7 @@ struct vicodec_dev {
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
struct vicodec_dev_instance stateful_enc; struct vicodec_dev_instance stateful_enc;
struct vicodec_dev_instance stateful_dec; struct vicodec_dev_instance stateful_dec;
struct vicodec_dev_instance stateless_dec;
#ifdef CONFIG_MEDIA_CONTROLLER #ifdef CONFIG_MEDIA_CONTROLLER
struct media_device mdev; struct media_device mdev;
#endif #endif
...@@ -114,6 +115,7 @@ struct vicodec_ctx { ...@@ -114,6 +115,7 @@ struct vicodec_ctx {
struct v4l2_fh fh; struct v4l2_fh fh;
struct vicodec_dev *dev; struct vicodec_dev *dev;
bool is_enc; bool is_enc;
bool is_stateless;
spinlock_t *lock; spinlock_t *lock;
struct v4l2_ctrl_handler hdl; struct v4l2_ctrl_handler hdl;
...@@ -372,6 +374,9 @@ static void device_run(void *priv) ...@@ -372,6 +374,9 @@ static void device_run(void *priv)
if (ctx->is_enc) if (ctx->is_enc)
v4l2_m2m_job_finish(dev->stateful_enc.m2m_dev, ctx->fh.m2m_ctx); v4l2_m2m_job_finish(dev->stateful_enc.m2m_dev, ctx->fh.m2m_ctx);
else if (ctx->is_stateless)
v4l2_m2m_job_finish(dev->stateless_dec.m2m_dev,
ctx->fh.m2m_ctx);
else else
v4l2_m2m_job_finish(dev->stateful_dec.m2m_dev, ctx->fh.m2m_ctx); v4l2_m2m_job_finish(dev->stateful_dec.m2m_dev, ctx->fh.m2m_ctx);
} }
...@@ -1508,8 +1513,14 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, ...@@ -1508,8 +1513,14 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->ops = &vicodec_qops; src_vq->ops = &vicodec_qops;
src_vq->mem_ops = &vb2_vmalloc_memops; src_vq->mem_ops = &vb2_vmalloc_memops;
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
src_vq->lock = ctx->is_enc ? &ctx->dev->stateful_enc.mutex : if (ctx->is_enc)
&ctx->dev->stateful_dec.mutex; src_vq->lock = &ctx->dev->stateful_enc.mutex;
else if (ctx->is_stateless)
src_vq->lock = &ctx->dev->stateless_dec.mutex;
else
src_vq->lock = &ctx->dev->stateful_dec.mutex;
src_vq->supports_requests = ctx->is_stateless;
src_vq->requires_requests = ctx->is_stateless;
ret = vb2_queue_init(src_vq); ret = vb2_queue_init(src_vq);
if (ret) if (ret)
return ret; return ret;
...@@ -1578,6 +1589,8 @@ static int vicodec_open(struct file *file) ...@@ -1578,6 +1589,8 @@ static int vicodec_open(struct file *file)
if (vfd == &dev->stateful_enc.vfd) if (vfd == &dev->stateful_enc.vfd)
ctx->is_enc = true; ctx->is_enc = true;
else if (vfd == &dev->stateless_dec.vfd)
ctx->is_stateless = true;
v4l2_fh_init(&ctx->fh, video_devdata(file)); v4l2_fh_init(&ctx->fh, video_devdata(file));
file->private_data = &ctx->fh; file->private_data = &ctx->fh;
...@@ -1590,6 +1603,8 @@ static int vicodec_open(struct file *file) ...@@ -1590,6 +1603,8 @@ static int vicodec_open(struct file *file)
1, 31, 1, 20); 1, 31, 1, 20);
v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, V4L2_CID_FWHT_P_FRAME_QP, v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, V4L2_CID_FWHT_P_FRAME_QP,
1, 31, 1, 20); 1, 31, 1, 20);
if (ctx->is_stateless)
v4l2_ctrl_new_custom(hdl, &vicodec_ctrl_stateless_state, NULL);
if (hdl->error) { if (hdl->error) {
rc = hdl->error; rc = hdl->error;
v4l2_ctrl_handler_free(hdl); v4l2_ctrl_handler_free(hdl);
...@@ -1629,6 +1644,10 @@ static int vicodec_open(struct file *file) ...@@ -1629,6 +1644,10 @@ static int vicodec_open(struct file *file)
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_enc.m2m_dev, ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_enc.m2m_dev,
ctx, &queue_init); ctx, &queue_init);
ctx->lock = &dev->stateful_enc.lock; ctx->lock = &dev->stateful_enc.lock;
} else if (ctx->is_stateless) {
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateless_dec.m2m_dev,
ctx, &queue_init);
ctx->lock = &dev->stateless_dec.lock;
} else { } else {
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_dec.m2m_dev, ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_dec.m2m_dev,
ctx, &queue_init); ctx, &queue_init);
...@@ -1765,6 +1784,10 @@ static int vicodec_probe(struct platform_device *pdev) ...@@ -1765,6 +1784,10 @@ static int vicodec_probe(struct platform_device *pdev)
"stateful-decoder", false)) "stateful-decoder", false))
goto unreg_sf_enc; goto unreg_sf_enc;
if (register_instance(dev, &dev->stateless_dec,
"stateless-decoder", false))
goto unreg_sf_dec;
#ifdef CONFIG_MEDIA_CONTROLLER #ifdef CONFIG_MEDIA_CONTROLLER
ret = v4l2_m2m_register_media_controller(dev->stateful_enc.m2m_dev, ret = v4l2_m2m_register_media_controller(dev->stateful_enc.m2m_dev,
&dev->stateful_enc.vfd, &dev->stateful_enc.vfd,
...@@ -1782,23 +1805,36 @@ static int vicodec_probe(struct platform_device *pdev) ...@@ -1782,23 +1805,36 @@ static int vicodec_probe(struct platform_device *pdev)
goto unreg_m2m_sf_enc_mc; goto unreg_m2m_sf_enc_mc;
} }
ret = v4l2_m2m_register_media_controller(dev->stateless_dec.m2m_dev,
&dev->stateless_dec.vfd,
MEDIA_ENT_F_PROC_VIDEO_DECODER);
if (ret) {
v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller for stateless dec\n");
goto unreg_m2m_sf_dec_mc;
}
ret = media_device_register(&dev->mdev); ret = media_device_register(&dev->mdev);
if (ret) { if (ret) {
v4l2_err(&dev->v4l2_dev, "Failed to register mem2mem media device\n"); v4l2_err(&dev->v4l2_dev, "Failed to register mem2mem media device\n");
goto unreg_m2m_sf_dec_mc; goto unreg_m2m_sl_dec_mc;
} }
#endif #endif
return 0; return 0;
#ifdef CONFIG_MEDIA_CONTROLLER #ifdef CONFIG_MEDIA_CONTROLLER
unreg_m2m_sl_dec_mc:
v4l2_m2m_unregister_media_controller(dev->stateless_dec.m2m_dev);
unreg_m2m_sf_dec_mc: unreg_m2m_sf_dec_mc:
v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev); v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev);
unreg_m2m_sf_enc_mc: unreg_m2m_sf_enc_mc:
v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev); v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev);
unreg_m2m: unreg_m2m:
video_unregister_device(&dev->stateless_dec.vfd);
v4l2_m2m_release(dev->stateless_dec.m2m_dev);
#endif
unreg_sf_dec:
video_unregister_device(&dev->stateful_dec.vfd); video_unregister_device(&dev->stateful_dec.vfd);
v4l2_m2m_release(dev->stateful_dec.m2m_dev); v4l2_m2m_release(dev->stateful_dec.m2m_dev);
#endif
unreg_sf_enc: unreg_sf_enc:
video_unregister_device(&dev->stateful_enc.vfd); video_unregister_device(&dev->stateful_enc.vfd);
v4l2_m2m_release(dev->stateful_enc.m2m_dev); v4l2_m2m_release(dev->stateful_enc.m2m_dev);
...@@ -1818,6 +1854,7 @@ static int vicodec_remove(struct platform_device *pdev) ...@@ -1818,6 +1854,7 @@ static int vicodec_remove(struct platform_device *pdev)
media_device_unregister(&dev->mdev); media_device_unregister(&dev->mdev);
v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev); v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev);
v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev); v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev);
v4l2_m2m_unregister_media_controller(dev->stateless_dec.m2m_dev);
media_device_cleanup(&dev->mdev); media_device_cleanup(&dev->mdev);
#endif #endif
...@@ -1825,6 +1862,7 @@ static int vicodec_remove(struct platform_device *pdev) ...@@ -1825,6 +1862,7 @@ static int vicodec_remove(struct platform_device *pdev)
v4l2_m2m_release(dev->stateful_dec.m2m_dev); v4l2_m2m_release(dev->stateful_dec.m2m_dev);
video_unregister_device(&dev->stateful_enc.vfd); video_unregister_device(&dev->stateful_enc.vfd);
video_unregister_device(&dev->stateful_dec.vfd); video_unregister_device(&dev->stateful_dec.vfd);
video_unregister_device(&dev->stateless_dec.vfd);
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment