From: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
To: Ming Qian <ming.qian@nxp.com>
Cc: "mchehab@kernel.org" <mchehab@kernel.org>,
"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>,
"shawnguo@kernel.org" <shawnguo@kernel.org>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
"kernel@pengutronix.de" <kernel@pengutronix.de>,
"festevam@gmail.com" <festevam@gmail.com>,
dl-linux-imx <linux-imx@nxp.com>,
"X.H. Bao" <xiahong.bao@nxp.com>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [EXT] Re: [PATCH v4 2/4] media: amphion: tell and handle contiguous and non contiguous format
Date: Mon, 22 Aug 2022 14:03:22 +0200 [thread overview]
Message-ID: <20220822120322.GD17530@tom-ThinkPad-T14s-Gen-2i> (raw)
In-Reply-To: <AM6PR04MB6341A3B117F6FDB818DAB5E6E7719@AM6PR04MB6341.eurprd04.prod.outlook.com>
Hi Ming,
On Mon, Aug 22, 2022 at 11:56:11AM +0000, Ming Qian wrote:
> >Hi Ming,
> >Sorry for delay. I'm on vacation last week :)
> >
> >On Tue, Aug 09, 2022 at 02:50:39PM +0800, Ming Qian wrote:
> >> Driver should tell the number of memory planes and component planes.
> >> the amphion vpu support non contiguous planes, but for compatibility
> >> with other device that only support contiguous planes.
> >> driver can add support for contiguous planes in the same time.
> >> Then the mem_planes can be different from the comp_planes.
> >> driver need to handle buffer according mem_planes and comp_planes.
> >>
> >> So driver can support NV12 and NV12M.
> >>
> >> Signed-off-by: Ming Qian <ming.qian@nxp.com>
> >> ---
> >> drivers/media/platform/amphion/vdec.c | 187 ++++++++++---------
> >> drivers/media/platform/amphion/venc.c | 33 ++--
> >> drivers/media/platform/amphion/vpu.h | 4 +-
> >> drivers/media/platform/amphion/vpu_dbg.c | 8 +-
> >> drivers/media/platform/amphion/vpu_helpers.c | 48 ++++-
> >> drivers/media/platform/amphion/vpu_helpers.h | 2 +
> >> drivers/media/platform/amphion/vpu_malone.c | 3 +-
> >> drivers/media/platform/amphion/vpu_v4l2.c | 168 ++++++++++++-----
> >> drivers/media/platform/amphion/vpu_v4l2.h | 3 +-
> >> drivers/media/platform/amphion/vpu_windsor.c | 8 +-
> >> 10 files changed, 299 insertions(+), 165 deletions(-)
> >>
>
> [snip]
>
> >> +const struct vpu_format *vpu_helper_find_sibling(struct vpu_inst
> >> +*inst, u32 type, u32 pixelfmt) {
> >> + const struct vpu_format *fmt;
> >> + const struct vpu_format *sibling;
> >> +
> >> + fmt = vpu_helper_find_format(inst, type, pixelfmt);
> >> + if (!fmt)
> >> + return NULL;
> >> + if (!fmt->sibling)
> >> + return NULL;
> >> + sibling = vpu_helper_find_format(inst, type, fmt->sibling);
> >> + if (!sibling)
> >> + return NULL;
> >> + if (sibling->sibling != fmt->pixfmt)
> >> + return NULL;
> >> + if (sibling->comp_planes != fmt->comp_planes)
> >> + return NULL;
> >> + return sibling;
> >> +}
> >
> >I think we can limit the use of "if" statement here. What about this?
> >
> >const struct vpu_format *vpu_helper_find_sibling(struct vpu_inst *inst, u32
> >type, u32 pixelfmt) {
> > const struct vpu_format *fmt;
> > const struct vpu_format *sibling;
> >
> > fmt = vpu_helper_find_format(inst, type, pixelfmt);
> > if (!fmt || !fmt->sibling)
> > return NULL;
> >
> > sibling = vpu_helper_find_format(inst, type, fmt->sibling);
> > if (!sibling || (sibling->sibling != fmt->pixfmt) ||
> > (sibling->comp_planes != fmt->comp_planes))
> > return NULL;
> >
> > return sibling;
> >}
> >
>
> OK, I'll apply this change in v5
>
> >> +
> >> +bool vpu_helper_match_format(struct vpu_inst *inst, u32 type, u32
> >> +fmta, u32 fmtb) {
> >> + const struct vpu_format *sibling;
> >> +
> >> + if (fmta == fmtb)
> >> + return true;
> >> +
> >> + sibling = vpu_helper_find_sibling(inst, type, fmta);
> >> + if (sibling && sibling->pixfmt == fmtb)
> >> + return true;
> >> + return false;
> >> +}
> >> +
>
> [snip]
>
> >> --- a/drivers/media/platform/amphion/vpu_malone.c
> >> +++ b/drivers/media/platform/amphion/vpu_malone.c
> >> @@ -583,7 +583,8 @@ bool vpu_malone_check_fmt(enum vpu_core_type
> >type, u32 pixelfmt)
> >> if (!vpu_imx8q_check_fmt(type, pixelfmt))
> >> return false;
> >>
> >> - if (pixelfmt == V4L2_PIX_FMT_NV12M_8L128 || pixelfmt ==
> >V4L2_PIX_FMT_NV12M_10BE_8L128)
> >> + if (pixelfmt == V4L2_PIX_FMT_NV12_8L128 || pixelfmt ==
> >V4L2_PIX_FMT_NV12_10BE_8L128 ||
> >> + pixelfmt == V4L2_PIX_FMT_NV12M_8L128 || pixelfmt ==
> >> + V4L2_PIX_FMT_NV12M_10BE_8L128)
> >
> >^Here are we using spaces instead of tab or I'm wrong?
> >
>
> It's following the rule of checkpatch.pl
>
> >> return true;
> >> if (vpu_malone_format_remap(pixelfmt) == MALONE_FMT_NULL)
> >> return false;
>
> [snip]
>
> >> +static int vpu_calc_fmt_sizeimage(struct vpu_inst *inst, struct
> >> +vpu_format *fmt) {
> >> u32 stride = 1;
> >> - u32 bytesperline;
> >> - u32 sizeimage;
> >> - const struct vpu_format *fmt;
> >> - const struct vpu_core_resources *res;
> >> int i;
> >>
> >> - fmt = vpu_helper_find_format(inst, type, pixmp->pixelformat);
> >> - if (!fmt) {
> >> - fmt = vpu_helper_enum_format(inst, type, 0);
> >> - if (!fmt)
> >> - return NULL;
> >> - pixmp->pixelformat = fmt->pixfmt;
> >> + if (!(fmt->flags & V4L2_FMT_FLAG_COMPRESSED)) {
> >> + const struct vpu_core_resources *res =
> >> + vpu_get_resource(inst);
> >> +
> >> + if (res)
> >> + stride = res->stride;
> >
> >If res=NULL stride=1 it is ok? Or we need to return some error?
> >
>
> If res is NULL, it means there is no additional alignment constraints
> So it's ok to set stride to 1 in this case.
>
> >> }
> >>
> >> - res = vpu_get_resource(inst);
> >> - if (res)
> >> - stride = res->stride;
> >> - if (pixmp->width)
> >> - pixmp->width = vpu_helper_valid_frame_width(inst,
> >pixmp->width);
> >> - if (pixmp->height)
> >> - pixmp->height = vpu_helper_valid_frame_height(inst,
> >pixmp->height);
> >> + for (i = 0; i < fmt->comp_planes; i++) {
> >> + fmt->sizeimage[i] = vpu_helper_get_plane_size(fmt->pixfmt,
> >> +
> >fmt->width,
> >> +
> >fmt->height,
> >> + i,
> >> + stride,
> >> +
> >fmt->field != V4L2_FIELD_NONE ? 1 : 0,
> >> +
> >&fmt->bytesperline[i]);
> >> + fmt->sizeimage[i] = max_t(u32, fmt->sizeimage[i], PAGE_SIZE);
> >> + if (fmt->flags & V4L2_FMT_FLAG_COMPRESSED) {
> >> + fmt->sizeimage[i] = clamp_val(fmt->sizeimage[i],
> >SZ_128K, SZ_8M);
> >> + fmt->bytesperline[i] = 0;
> >> + }
> >> + }
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +u32 vpu_get_fmt_plane_size(struct vpu_format *fmt, u32 plane_no) {
> >> + u32 size;
> >> + int i;
> >> +
> >> + if (plane_no >= fmt->mem_planes)
> >> + return 0;
> >> +
> >> + if (fmt->comp_planes == fmt->mem_planes)
> >> + return fmt->sizeimage[plane_no];
> >> + if (plane_no < fmt->mem_planes - 1)
> >> + return fmt->sizeimage[plane_no];
> >
> >I like a space here but is my personal opinion :)
> >
>
> OK, I'll add a space line here in v5
>
> [snip]
Thanks for clarifications.
Regards,
Tommaso
--
Tommaso Merciai
Embedded Linux Engineer
tommaso.merciai@amarulasolutions.com
__________________________________
Amarula Solutions SRL
Via Le Canevare 30, 31100 Treviso, Veneto, IT
T. +39 042 243 5310
info@amarulasolutions.com
www.amarulasolutions.com
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-08-22 12:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-09 6:50 [PATCH v4 0/4] media: amphion: add support for contiguous format Ming Qian
2022-08-09 6:50 ` [PATCH v4 1/4] media: add nv12_8l128 and nv12_10be_8l128 video format Ming Qian
2022-08-11 15:18 ` Tommaso Merciai
2022-08-12 1:25 ` [EXT] " Ming Qian
2022-08-12 7:11 ` Tommaso Merciai
2022-08-16 14:42 ` Nicolas Dufresne
2022-08-09 6:50 ` [PATCH v4 2/4] media: amphion: tell and handle contiguous and non contiguous format Ming Qian
2022-08-12 7:14 ` Tommaso Merciai
2022-08-12 7:19 ` [EXT] " Ming Qian
2022-08-12 9:42 ` Tommaso Merciai
2022-08-12 9:49 ` Tommaso Merciai
2022-08-12 23:26 ` Ming Qian
2022-08-22 7:25 ` Tommaso Merciai
2022-08-22 11:16 ` Tommaso Merciai
2022-08-22 11:56 ` [EXT] " Ming Qian
2022-08-22 12:03 ` Tommaso Merciai [this message]
2022-08-09 6:50 ` [PATCH v4 3/4] media: amphion: decoder add support for contiguous planes Ming Qian
2022-08-22 11:30 ` Tommaso Merciai
2022-08-09 6:50 ` [PATCH v4 4/4] media: amphion: encoder " Ming Qian
2022-08-22 11:31 ` Tommaso Merciai
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=20220822120322.GD17530@tom-ThinkPad-T14s-Gen-2i \
--to=tommaso.merciai@amarulasolutions.com \
--cc=festevam@gmail.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ming.qian@nxp.com \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=xiahong.bao@nxp.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