From: Hsin-Yi Wang <hsinyi@chromium.org>
To: Alexandre Courbot <acourbot@chromium.org>
Cc: Tiffany Lin <tiffany.lin@mediatek.com>,
Andrew-CT Chen <andrew-ct.chen@mediatek.com>,
Rob Herring <robh+dt@kernel.org>,
Yunfei Dong <yunfei.dong@mediatek.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
linux-media@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v4 07/15] media: mtk-vcodec: vdec: add media device if using stateless api
Date: Mon, 17 May 2021 12:35:07 +0800 [thread overview]
Message-ID: <CAJMQK-g=bnr9bAkvN61sFapX_XOKmUF8LPivtCEzUhP-LjoHUw@mail.gmail.com> (raw)
In-Reply-To: <20210427111526.1772293-8-acourbot@chromium.org>
On Tue, Apr 27, 2021 at 7:16 PM Alexandre Courbot <acourbot@chromium.org> wrote:
>
> From: Yunfei Dong <yunfei.dong@mediatek.com>
>
> The stateless API requires a media device for issuing requests. Add one
> if we are being instantiated as a stateless decoder.
>
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> [acourbot: refactor, cleanup and split]
> Co-developed-by: Alexandre Courbot <acourbot@chromium.org>
> Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
> ---
> drivers/media/platform/Kconfig | 1 +
> .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 39 +++++++++++++++++++
> .../platform/mtk-vcodec/mtk_vcodec_drv.h | 2 +
> 3 files changed, 42 insertions(+)
>
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index ae1468aa1b4e..4154fdec2efb 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -315,6 +315,7 @@ config VIDEO_MEDIATEK_VCODEC
> select VIDEO_MEDIATEK_VCODEC_VPU if VIDEO_MEDIATEK_VPU
> select VIDEO_MEDIATEK_VCODEC_SCP if MTK_SCP
> select V4L2_H264
> + select MEDIA_CONTROLLER
Should this also select MEDIA_CONTROLLER_REQUEST_API config?
Thanks
> help
> Mediatek video codec driver provides HW capability to
> encode and decode in a range of video formats on MT8173
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> index 533781d4680a..e942e28f96fe 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> @@ -14,6 +14,7 @@
> #include <media/v4l2-event.h>
> #include <media/v4l2-mem2mem.h>
> #include <media/videobuf2-dma-contig.h>
> +#include <media/v4l2-device.h>
>
> #include "mtk_vcodec_drv.h"
> #include "mtk_vcodec_dec.h"
> @@ -324,6 +325,31 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
> goto err_event_workq;
> }
>
> + if (dev->vdec_pdata->uses_stateless_api) {
> + dev->mdev_dec.dev = &pdev->dev;
> + strscpy(dev->mdev_dec.model, MTK_VCODEC_DEC_NAME,
> + sizeof(dev->mdev_dec.model));
> +
> + media_device_init(&dev->mdev_dec);
> + dev->mdev_dec.ops = &mtk_vcodec_media_ops;
> + dev->v4l2_dev.mdev = &dev->mdev_dec;
> +
> + ret = v4l2_m2m_register_media_controller(dev->m2m_dev_dec,
> + dev->vfd_dec, MEDIA_ENT_F_PROC_VIDEO_DECODER);
> + if (ret) {
> + mtk_v4l2_err("Failed to register media controller");
> + goto err_reg_cont;
> + }
> +
> + ret = media_device_register(&dev->mdev_dec);
> + if (ret) {
> + mtk_v4l2_err("Failed to register media device");
> + goto err_media_reg;
> + }
> +
> + mtk_v4l2_debug(0, "media registered as /dev/media%d",
> + vfd_dec->num);
> + }
> ret = video_register_device(vfd_dec, VFL_TYPE_VIDEO, 0);
> if (ret) {
> mtk_v4l2_err("Failed to register video device");
> @@ -336,6 +362,12 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
> return 0;
>
> err_dec_reg:
> + if (dev->vdec_pdata->uses_stateless_api)
> + media_device_unregister(&dev->mdev_dec);
> +err_media_reg:
> + if (dev->vdec_pdata->uses_stateless_api)
> + v4l2_m2m_unregister_media_controller(dev->m2m_dev_dec);
> +err_reg_cont:
> destroy_workqueue(dev->decode_workqueue);
> err_event_workq:
> v4l2_m2m_release(dev->m2m_dev_dec);
> @@ -368,6 +400,13 @@ static int mtk_vcodec_dec_remove(struct platform_device *pdev)
>
> flush_workqueue(dev->decode_workqueue);
> destroy_workqueue(dev->decode_workqueue);
> +
> + if (media_devnode_is_registered(dev->mdev_dec.devnode)) {
> + media_device_unregister(&dev->mdev_dec);
> + v4l2_m2m_unregister_media_controller(dev->m2m_dev_dec);
> + media_device_cleanup(&dev->mdev_dec);
> + }
> +
> if (dev->m2m_dev_dec)
> v4l2_m2m_release(dev->m2m_dev_dec);
>
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> index 78d4a7728ddf..10edd238c939 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
> @@ -383,6 +383,7 @@ struct mtk_vcodec_enc_pdata {
> * struct mtk_vcodec_dev - driver data
> * @v4l2_dev: V4L2 device to register video devices for.
> * @vfd_dec: Video device for decoder
> + * @mdev_dec: Media device for decoder
> * @vfd_enc: Video device for encoder.
> *
> * @m2m_dev_dec: m2m device for decoder
> @@ -418,6 +419,7 @@ struct mtk_vcodec_enc_pdata {
> struct mtk_vcodec_dev {
> struct v4l2_device v4l2_dev;
> struct video_device *vfd_dec;
> + struct media_device mdev_dec;
> struct video_device *vfd_enc;
>
> struct v4l2_m2m_dev *m2m_dev_dec;
> --
> 2.31.1.498.g6c1eba8ee3d-goog
>
>
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2021-05-17 4:35 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-27 11:15 [PATCH v4 00/15] media: mtk-vcodec: support for MT8183 decoder Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 01/15] media: mtk-vcodec: vdec: move stateful ops into their own file Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 02/15] media: mtk-vcodec: vdec: handle firmware version field Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 03/15] media: mtk-vcodec: support version 2 of decoder firmware ABI Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 04/15] media: add Mediatek's MM21 format Alexandre Courbot
2021-04-29 7:16 ` Hans Verkuil
2021-04-27 11:15 ` [PATCH v4 05/15] media: mtk-vcodec: vdec: support stateless API Alexandre Courbot
2021-04-29 7:27 ` Hans Verkuil
2021-05-13 9:20 ` Alexandre Courbot
2021-04-29 12:10 ` Dafna Hirschfeld
2021-05-13 9:21 ` Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 06/15] media: mtk-vcodec: vdec: support stateless H.264 decoding Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 07/15] media: mtk-vcodec: vdec: add media device if using stateless api Alexandre Courbot
2021-04-29 7:28 ` Hans Verkuil
2021-05-13 8:05 ` Alexandre Courbot
2021-05-13 15:07 ` Nicolas Dufresne
2021-05-17 4:35 ` Hsin-Yi Wang [this message]
2021-05-19 5:23 ` Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 08/15] dt-bindings: media: document mediatek,mt8183-vcodec-dec Alexandre Courbot
2021-05-04 12:55 ` Alexandre Courbot
2021-05-04 14:48 ` Rob Herring
2021-04-27 11:15 ` [PATCH v4 09/15] media: mtk-vcodec: enable MT8183 decoder Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 10/15] media: mtk-vcodec: vdec: use helpers in VIDIOC_(TRY_)DECODER_CMD Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 11/15] media: mtk-vcodec: vdec: Support H264 profile control Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 12/15] media: mtk-vcodec: vdec: clamp OUTPUT resolution to hardware limits Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 13/15] media: mtk-vcodec: make flush buffer reusable by encoder Alexandre Courbot
2021-04-27 11:15 ` [PATCH v4 14/15] media: mtk-vcodec: venc: support START and STOP commands Alexandre Courbot
2021-08-04 12:53 ` Dafna Hirschfeld
2021-08-05 9:56 ` Dafna Hirschfeld
2021-04-27 11:15 ` [PATCH v4 15/15] media: mtk-vcodec: venc: make sure buffer exists in list before removing Alexandre Courbot
2021-04-29 7:35 ` [PATCH v4 00/15] media: mtk-vcodec: support for MT8183 decoder Hans Verkuil
2021-05-13 8:06 ` Alexandre Courbot
2021-04-29 12:07 ` Dafna Hirschfeld
2021-05-13 8:21 ` Alexandre Courbot
2021-07-19 11:43 ` Dafna Hirschfeld
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJMQK-g=bnr9bAkvN61sFapX_XOKmUF8LPivtCEzUhP-LjoHUw@mail.gmail.com' \
--to=hsinyi@chromium.org \
--cc=acourbot@chromium.org \
--cc=andrew-ct.chen@mediatek.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=robh+dt@kernel.org \
--cc=tiffany.lin@mediatek.com \
--cc=yunfei.dong@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).