From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
Tiffany Lin <tiffany.lin@mediatek.com>,
Andrew-CT Chen <andrew-ct.chen@mediatek.com>,
Yunfei Dong <yunfei.dong@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, kernel@collabora.com,
linux-media@vger.kernel.org,
Sebastian Fricke <sebastian.fricke@collabora.com>
Subject: Re: [PATCH v2 4/5] media: vcodec: Implement manual request completion
Date: Mon, 14 Apr 2025 15:19:47 -0400 [thread overview]
Message-ID: <4052616c2ee6dafe1c8889454df73da2c4452f04.camel@collabora.com> (raw)
In-Reply-To: <d3da96bf-d1c8-4bf8-a22a-21a43f78f27d@collabora.com>
Le lundi 14 avril 2025 à 11:11 +0200, AngeloGioacchino Del Regno a écrit :
> Il 10/04/25 17:39, Nicolas Dufresne ha scritto:
> > From: Sebastian Fricke <sebastian.fricke@collabora.com>
> >
> > Rework how requests are completed in the MediaTek VCodec driver, by
> > implementing the new manual request completion feature, which allows to
> > keep a request open while allowing to add new bitstream data.
> > This is useful in this case, because the hardware has a LAT and a core
> > decode work, after the LAT decode the bitstream isn't required anymore
> > so the source buffer can be set done and the request stays open until
> > the core decode work finishes.
> >
> > Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
> > Co-developed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
>
> This patch is great - but looks like it's worsening naming consistency across the
> driver.
>
> Please look below.
>
> > ---
> > .../mediatek/vcodec/common/mtk_vcodec_cmn_drv.h | 13 +++++
> > .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 4 +-
> > .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 50 +++++++++++++++++
> > .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h | 19 +++++++
> > .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 63 +++++++++++++---------
> > 5 files changed, 124 insertions(+), 25 deletions(-)
> >
> > diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_cmn_drv.h b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_cmn_drv.h
> > index 6087e27bd604d24e5d37b48de5bb37eab86fc1ab..c5fd37cb60ca0cc5fd09c9243b36fbc716c56454 100644
> > --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_cmn_drv.h
> > +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_cmn_drv.h
> > @@ -105,6 +105,19 @@ enum mtk_instance_state {
> > MTK_STATE_ABORT = 4,
> > };
> >
> > +/**
> > + * enum mtk_request_state - Stages of processing a request
> > + * @MTK_REQUEST_RECEIVED: Hardware prepared for the LAT decode
> > + * @MTK_REQUEST_LAT_DONE: LAT decode finished, the bitstream is not
> > + * needed anymore
> > + * @MTK_REQUEST_CORE_DONE: CORE decode finished
> > + */
> > +enum mtk_request_state {
> > + MTK_REQUEST_RECEIVED = 0,
> > + MTK_REQUEST_LAT_DONE = 1,
> > + MTK_REQUEST_CORE_DONE = 2,
> > +};
> > +
> > enum mtk_fmt_type {
> > MTK_FMT_DEC = 0,
> > MTK_FMT_ENC = 1,
> > diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
> > index 98838217b97d45ed2b5431fdf87c94e0ff79fc57..036ad191a9c3e644fe99b4ce25d6a089292f1e57 100644
> > --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
> > +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
> > @@ -889,8 +889,10 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
> > src_buf->vb2_buf.req_obj.req;
> > v4l2_m2m_buf_done(src_buf,
> > VB2_BUF_STATE_ERROR);
> > - if (req)
> > + if (req) {
> > v4l2_ctrl_request_complete(req, &ctx->ctrl_hdl);
> > + media_request_manual_complete(req);
> > + }
> > }
> > }
> > return;
> > diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
> > index 9247d92d431d8570609423156b989878f7901f1c..c80c1db509eaadd449bfd183c5eb9db0a1fc22bd 100644
> > --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
> > +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
> > @@ -26,6 +26,56 @@
> > #include "mtk_vcodec_dec_pm.h"
> > #include "../common/mtk_vcodec_intr.h"
> >
> > +static const char *state_to_str(enum mtk_request_state state)
>
> static const char *mtk_vcodec_req_state_to_str(enum mtk_request_state state)
I'd keep this one an exception, its local to this C file.
>
> > +{
> > + switch (state) {
> > + case MTK_REQUEST_RECEIVED:
> > + return "RECEIVED";
> > + case MTK_REQUEST_LAT_DONE:
> > + return "LAT_DONE";
> > + case MTK_REQUEST_CORE_DONE:
> > + return "CORE_DONE";
> > + default:
> > + return "UNKNOWN";
> > + }
> > +}
> > +
> > +void mtk_request_complete(struct mtk_vcodec_dec_ctx *ctx, enum mtk_request_state state,
>
> void mtk_vcodec_request_complete( ....)
Ack, though the namspace here seems to be "mtk_vcodec_dec", so I'll opt
for that.
>
>
> > + enum vb2_buffer_state buffer_state, struct media_request *src_buf_req)
> > +{
> > + struct mtk_request *req = req_to_mtk_req(src_buf_req);
> > + struct vb2_v4l2_buffer *src_buf, *dst_buf;
> > +
> > + mutex_lock(&ctx->lock);
> > +
> > + if (req->req_state >= state) {
> > + mutex_unlock(&ctx->lock);
> > + return;
> > + }
> > +
> > + switch (req->req_state) {
> > + case MTK_REQUEST_RECEIVED:
> > + v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl);
> > + src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> > + v4l2_m2m_buf_done(src_buf, buffer_state);
> > + if (state == MTK_REQUEST_LAT_DONE)
> > + break;
> > + fallthrough;
> > + case MTK_REQUEST_LAT_DONE:
> > + dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
> > + v4l2_m2m_buf_done(dst_buf, buffer_state);
> > + media_request_manual_complete(src_buf_req);
> > + break;
> > + default:
> > + break;
> > + }
> > +
> > + mtk_v4l2_vdec_dbg(3, ctx, "Switch state from %s to %s.\n",
> > + state_to_str(req->req_state), state_to_str(state));
> > + req->req_state = state;
> > + mutex_unlock(&ctx->lock);
> > +}
> > +
> > static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dec_ctx *ctx, struct mtk_vcodec_dec_dev *dev)
> > {
> > switch (dev->vdec_pdata->hw_arch) {
> > diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
> > index ac568ed14fa257d25b533b6fd6b3cd341227ecc2..cd61bf46de6918c27ed39ba64162e5f2637f93b2 100644
> > --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
> > +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
> > @@ -126,6 +126,17 @@ struct mtk_vcodec_dec_pdata {
> > bool uses_stateless_api;
> > };
> >
> > +/**
> > + * struct mtk_request - Media request private data.
> > + *
> > + * @req_state: Request completion state
> > + * @req: Media Request structure
> > + */
> > +struct mtk_request {
>
> Maybe mtk_vcodec_dec_request? :-)
Ack.
>
> > + enum mtk_request_state req_state;
> > + struct media_request req;
> > +};
> > +
> > /**
> > * struct mtk_vcodec_dec_ctx - Context (instance) private data.
> > *
> > @@ -317,6 +328,11 @@ static inline struct mtk_vcodec_dec_ctx *ctrl_to_dec_ctx(struct v4l2_ctrl *ctrl)
> > return container_of(ctrl->handler, struct mtk_vcodec_dec_ctx, ctrl_hdl);
> > }
> >
> > +static inline struct mtk_request *req_to_mtk_req(struct media_request *req)
>
> ...and this could become req_to_dec_req ... but no strong opinions on this one
> specifically, so feel free to keep this as it is.
Something like that, very subtle at this point.
>
> > +{
> > + return container_of(req, struct mtk_request, req);
> > +}
> > +
> > /* Wake up context wait_queue */
> > static inline void
> > wake_up_dec_ctx(struct mtk_vcodec_dec_ctx *ctx, unsigned int reason, unsigned int hw_id)
>
> After which....
>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
thanks,
--
Nicolas Dufresne
Principal Engineer at Collabora
next prev parent reply other threads:[~2025-04-14 19:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 15:39 [PATCH v2 0/5] Add manual request completion to the MediaTek VCodec driver Nicolas Dufresne
2025-04-10 15:39 ` [PATCH v2 1/5] media: mc: add manual request completion Nicolas Dufresne
2025-04-10 17:50 ` Laurent Pinchart
2025-04-10 18:26 ` Nicolas Dufresne
2025-04-10 18:42 ` Hans Verkuil
2025-04-10 18:41 ` Nicolas Dufresne
2025-04-10 19:05 ` Laurent Pinchart
2025-04-10 19:58 ` Nicolas Dufresne
2025-04-10 20:31 ` Nicolas Dufresne
2025-04-11 6:31 ` Hans Verkuil
2025-04-10 15:39 ` [PATCH v2 2/5] media: vicodec: add support for manual completion Nicolas Dufresne
2025-04-10 15:39 ` [PATCH v2 3/5] media: mc: add debugfs node to keep track of requests Nicolas Dufresne
2025-04-10 15:39 ` [PATCH v2 4/5] media: vcodec: Implement manual request completion Nicolas Dufresne
2025-04-14 9:11 ` AngeloGioacchino Del Regno
2025-04-14 19:19 ` Nicolas Dufresne [this message]
2025-04-10 15:40 ` [PATCH v2 5/5] media: mtk-vcodec: Don't try to decode 422/444 VP9 Nicolas Dufresne
2025-04-14 9:11 ` AngeloGioacchino Del Regno
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=4052616c2ee6dafe1c8889454df73da2c4452f04.camel@collabora.com \
--to=nicolas.dufresne@collabora.com \
--cc=andrew-ct.chen@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=kernel@collabora.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=sebastian.fricke@collabora.com \
--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