Add stateless encoder instance field to the dev struct and register another node for the stateless encoder. The stateless API for the node will be implemented in further patches. Signed-off-by: Dafna Hirschfeld <dafna3@xxxxxxxxx> --- drivers/media/platform/vicodec/vicodec-core.c | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index a701afd7cecb..6bfcd266ffc4 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -105,6 +105,7 @@ struct vicodec_dev { struct vicodec_dev_instance stateful_enc; struct vicodec_dev_instance stateful_dec; struct vicodec_dev_instance stateless_dec; + struct vicodec_dev_instance stateless_enc; #ifdef CONFIG_MEDIA_CONTROLLER struct media_device mdev; #endif @@ -1887,16 +1888,20 @@ static int vicodec_open(struct file *file) rc = -ENOMEM; goto open_unlock; } + ctx->is_enc = (vfd == &dev->stateful_enc.vfd || + vfd == &dev->stateless_enc.vfd); - if (vfd == &dev->stateful_enc.vfd) { - ctx->is_enc = true; + ctx->is_stateless = (vfd == &dev->stateless_dec.vfd || + vfd == &dev->stateless_enc.vfd); + + if (vfd == &dev->stateful_enc.vfd) ctx->dev_inst = &dev->stateful_enc; - } else if (vfd == &dev->stateless_dec.vfd) { - ctx->is_stateless = true; - ctx->dev_inst = &dev->stateless_dec; - } else { + else if (vfd == &dev->stateful_dec.vfd) ctx->dev_inst = &dev->stateful_dec; - } + else if (vfd == &dev->stateless_enc.vfd) + ctx->dev_inst = &dev->stateless_enc; + else + ctx->dev_inst = &dev->stateless_dec; v4l2_fh_init(&ctx->fh, video_devdata(file)); file->private_data = &ctx->fh; @@ -2150,6 +2155,9 @@ static int vicodec_probe(struct platform_device *pdev) "stateless-decoder", false)) goto unreg_sf_dec; + if (register_instance(dev, &dev->stateless_enc, + "stateless-encoder", false)) + goto unreg_sl_dec; #ifdef CONFIG_MEDIA_CONTROLLER ret = v4l2_m2m_register_media_controller(dev->stateful_enc.m2m_dev, &dev->stateful_enc.vfd, @@ -2175,15 +2183,26 @@ static int vicodec_probe(struct platform_device *pdev) goto unreg_m2m_sf_dec_mc; } + ret = v4l2_m2m_register_media_controller(dev->stateless_enc.m2m_dev, + &dev->stateless_enc.vfd, + MEDIA_ENT_F_PROC_VIDEO_ENCODER); + if (ret) { + v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller for stateless enc\n"); + goto unreg_m2m_sl_dec_mc; + } + + ret = media_device_register(&dev->mdev); if (ret) { v4l2_err(&dev->v4l2_dev, "Failed to register mem2mem media device\n"); - goto unreg_m2m_sl_dec_mc; + goto unreg_m2m_sl_enc_mc; } #endif return 0; #ifdef CONFIG_MEDIA_CONTROLLER +unreg_m2m_sl_enc_mc: + v4l2_m2m_unregister_media_controller(dev->stateless_enc.m2m_dev); unreg_m2m_sl_dec_mc: v4l2_m2m_unregister_media_controller(dev->stateless_dec.m2m_dev); unreg_m2m_sf_dec_mc: @@ -2191,9 +2210,12 @@ static int vicodec_probe(struct platform_device *pdev) unreg_m2m_sf_enc_mc: v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev); unreg_m2m: + video_unregister_device(&dev->stateless_enc.vfd); + v4l2_m2m_release(dev->stateless_enc.m2m_dev); +#endif +unreg_sl_dec: 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); v4l2_m2m_release(dev->stateful_dec.m2m_dev); @@ -2217,6 +2239,7 @@ static int vicodec_remove(struct platform_device *pdev) 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->stateless_dec.m2m_dev); + v4l2_m2m_unregister_media_controller(dev->stateless_enc.m2m_dev); media_device_cleanup(&dev->mdev); #endif @@ -2225,6 +2248,7 @@ static int vicodec_remove(struct platform_device *pdev) video_unregister_device(&dev->stateful_enc.vfd); video_unregister_device(&dev->stateful_dec.vfd); video_unregister_device(&dev->stateless_dec.vfd); + video_unregister_device(&dev->stateless_enc.vfd); v4l2_device_unregister(&dev->v4l2_dev); return 0; -- 2.17.1