From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jacopo Mondi <jacopo@jmondi.org>
Cc: slongerbeam@gmail.com, p.zabel@pengutronix.de,
shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com,
mchehab@kernel.org, hverkuil-cisco@xs4all.nl,
martin.kepplinger@puri.sm, rmfrfs@gmail.com,
xavier.roumegue@oss.nxp.com, alexander.stein@ew.tq-group.com,
dorota.czaplejewicz@puri.sm, kernel@pengutronix.de,
linux-imx@nxp.com, linux-media@vger.kernel.org,
linux-staging@lists.linux.dev,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 5/8] staging: media: imx: Use DUAL pixel mode if available
Date: Sun, 20 Feb 2022 15:34:55 +0200 [thread overview]
Message-ID: <YhJDf1WVQTIteE30@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220215085918.dxilh2sx2yx2l6c5@uno.localdomain>
Hi Jacopo,
On Tue, Feb 15, 2022 at 09:59:18AM +0100, Jacopo Mondi wrote:
> On Tue, Feb 15, 2022 at 09:12:44AM +0200, Laurent Pinchart wrote:
> > On Mon, Feb 14, 2022 at 07:43:15PM +0100, Jacopo Mondi wrote:
> > > The pixel sampling mode controls the size of data sampled from the CSI
> > > Rx queue. The supported sample size depends on the configuration of the
> > > preceding block in the capture pipeline and is then dependent on the SoC
> > > version the CSI peripheral is integrated on.
> > >
> > > When capturing YUV422 data if dual sample mode is available use it.
> > >
> > > This change is particularly relevant for the IMX8MM SoC which uses the
> > > CSIS CSI-2 receiver which operates in dual pixel mode.
> > >
> > > Other SoCs should be unaffected by this change and should continue to
> > > operate as before.
> > >
> > > Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
> > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> > > ---
> > > drivers/staging/media/imx/imx7-media-csi.c | 10 +++++++++-
> > > 1 file changed, 9 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c
> > > index 112096774961..a8bdfb0bb0ee 100644
> > > --- a/drivers/staging/media/imx/imx7-media-csi.c
> > > +++ b/drivers/staging/media/imx/imx7-media-csi.c
> > > @@ -426,6 +426,7 @@ static void imx7_csi_configure(struct imx7_csi *csi)
> > > {
> > > struct imx_media_video_dev *vdev = csi->vdev;
> > > struct v4l2_pix_format *out_pix = &vdev->fmt;
> > > + struct imx_media_dev *imxmd = csi->imxmd;
> > > int width = out_pix->width;
> > > u32 stride = 0;
> > > u32 cr3 = BIT_FRMCNT_RST;
> > > @@ -436,7 +437,7 @@ static void imx7_csi_configure(struct imx7_csi *csi)
> > > cr18 &= ~(BIT_CSI_HW_ENABLE | BIT_MIPI_DATA_FORMAT_MASK |
> > > BIT_DATA_FROM_MIPI | BIT_BASEADDR_CHG_ERR_EN |
> > > BIT_BASEADDR_SWITCH_EN | BIT_BASEADDR_SWITCH_SEL |
> > > - BIT_DEINTERLACE_EN);
> > > + BIT_DEINTERLACE_EN | BIT_MIPI_DOUBLE_CMPNT);
> > >
> > > if (out_pix->field == V4L2_FIELD_INTERLACED) {
> > > cr18 |= BIT_DEINTERLACE_EN;
> > > @@ -500,6 +501,13 @@ static void imx7_csi_configure(struct imx7_csi *csi)
> > > case MEDIA_BUS_FMT_YUYV8_2X8:
> > > case MEDIA_BUS_FMT_YUYV8_1X16:
> > > cr18 |= BIT_MIPI_DATA_FORMAT_YUV422_8B;
> > > +
> > > + /* If dual mode is supported use it. */
> > > + if (imxmd->info->sample_modes & MODE_DUAL) {
> > > + cr18 |= BIT_MIPI_DOUBLE_CMPNT;
> > > + cr3 |= BIT_TWO_8BIT_SENSOR;
> > > + }
> >
> > I would implement this differently:
> >
> > case MEDIA_BUS_FMT_UYVY8_2X8:
> > case MEDIA_BUS_FMT_YUYV8_2X8:
> > cr18 |= BIT_MIPI_DATA_FORMAT_YUV422_8B;
> > break;
> >
> > case MEDIA_BUS_FMT_UYVY8_1X16:
> > case MEDIA_BUS_FMT_YUYV8_1X16:
> > cr3 |= BIT_TWO_8BIT_SENSOR;
> > cr18 |= BIT_MIPI_DATA_FORMAT_YUV422_8B
> > | BIT_MIPI_DOUBLE_CMPNT;
> > break;
> >
> > This would support either option here. What you will then need to change
> > is imx7_csi_enum_mbus_code() and imx7_csi_try_fmt(), to allow/disallow
> > the 2X8 and 1X16 variants based on the SoC. This is important for the
>
> Exactly. And being the format list in the shared helper I decided it
> was really not worth adding any SoC specific code to those helpers
> which should ideally be nuked.
>
> Should we decouple the helpers to get to a point where we can have
> SoC-specific formats list ? Then I would be more than happy to use the
> above construct.
Yes, we should. I have started working on this, but haven't had time to
complete the work yet.
> There is one quirk I'm not sure about: How does the CSI connect to the
> transmitter ? It is my undertanding that in i.MX8 connects to the the
> CSI-2 receiver (either CSIS or the Northwest tech one). Does in older
> SoC revisions connects directly to a parallel sensor ?
On i.MX7 there's a mux that allows selecting the CSI-2 receiver or the
parallel input. It's implemented using the video-mux driver, see
imx7s.dtsi for details.
> I'm asking also because there is a comment that reports
>
> /*
> * CSI-2 sources are supposed to use the 1X16 formats, but not
> * all of them comply. Support both variants.
> */
>
> But if the preceding block is the CSI-2 receiver, we control what
> formats it exposes and we can use both 2X8 or 1X16 depending on the
> SoC specificities and we don't care about the CSI-2 Tx supported
> formats. Does that comment make sense in your opinion ?
I think the comment should be dropped. There are CSI-2 sensor drivers
that incorrectly use the 2X8 formats instead of 1X16, but I don't think
we should work around that here, the sensor drivers should be fixed
instead.
> Also be aware that, in example, if we expose from the CSIS source pad
> both 2X8 and 1X16 we create a condition where userspace could
> configure the pipeline uncorrectly.
>
> Let's draw a table (for i.MX8 only as I don't know about the 7)
>
>
> 8MM/CSI 8MQ/CSI 8MP/ISI
> CSIS Dual Dual
> NW Single
>
>
> Each block would then support
>
> CSIS Dual
> NW Single
> CSI Dual/Single
> ISI Dual
>
> So we create a potential for a misconfiguration in 8MM with
>
> CSIS = Dual
> CSI = Single
>
> or for the 8MQ
>
> NW = Single
> CSI = Double
>
> If we don't create a list of SoC specific formats. Nothing bad, -EPIPE
> will be returned, but maybe we should avoid that ?
Format propagation is typically done from source to sink in userspace,
so the risk of picking an incorrect format is very low (and it would be
a userspace bug in any case). Nonetheless, it would be nice to avoid
exposing formats that can't be used, but that can be done later.
> > i.MX7, which has both a CSI-2 input and a parallel input. When using the
> > CSIS it can (and should) use double component mode, while when using the
> > parallel input it can work in 8-bit or 16-bit mode depending on how the
> > sensor is wired.
>
> I didn't know i.MX7 used the CSIS :/
> Ah wait, the driver was called imx7-mipi-csi2 :/
:-)
> > > +
> > > break;
> > > }
> > > }
--
Regards,
Laurent Pinchart
_______________________________________________
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-02-20 13:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 18:43 [PATCH 0/8] media: imx: Destage imx7-mipi-csis with fixes on top Jacopo Mondi
2022-02-14 18:43 ` [PATCH 1/8] media: imx: De-stage imx7-mipi-csis Jacopo Mondi
2022-02-14 18:43 ` [PATCH 2/8] media: imx: Rename imx7-mipi-csis.c to imx-mipi-csis.c Jacopo Mondi
2022-02-15 6:58 ` Laurent Pinchart
2022-02-14 18:43 ` [PATCH 3/8] staging: media: imx: Add more compatible strings Jacopo Mondi
2022-02-14 19:15 ` Laurent Pinchart
2022-02-15 8:36 ` Jacopo Mondi
2022-02-15 8:45 ` Laurent Pinchart
2022-02-15 9:17 ` Jacopo Mondi
2022-02-14 18:43 ` [PATCH 4/8] staging: media: imx: Define per-SoC info Jacopo Mondi
2022-02-14 19:20 ` Laurent Pinchart
2022-02-15 8:40 ` Jacopo Mondi
2022-02-14 18:43 ` [PATCH 5/8] staging: media: imx: Use DUAL pixel mode if available Jacopo Mondi
2022-02-15 7:12 ` Laurent Pinchart
2022-02-15 8:59 ` Jacopo Mondi
2022-02-20 13:34 ` Laurent Pinchart [this message]
2022-02-14 18:43 ` [PATCH 6/8] media: imx: imx-mipi-csis: Set PIXEL_MODE for YUV422 Jacopo Mondi
2022-02-15 7:25 ` Laurent Pinchart
2022-02-14 18:43 ` [PATCH 7/8] media: imx: imx-mipi-csis: Add RGB565_1X16 Jacopo Mondi
2022-02-15 7:26 ` Laurent Pinchart
2022-02-14 18:43 ` [PATCH 8/8] media: imx: imx-mipi-csis: Add RGB/BGR888 Jacopo Mondi
2022-02-15 7:46 ` Laurent Pinchart
2022-02-15 21:07 ` Sakari Ailus
2022-02-15 21:52 ` Laurent Pinchart
2022-02-15 23:10 ` Sakari Ailus
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=YhJDf1WVQTIteE30@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=alexander.stein@ew.tq-group.com \
--cc=dorota.czaplejewicz@puri.sm \
--cc=festevam@gmail.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jacopo@jmondi.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=martin.kepplinger@puri.sm \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=rmfrfs@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=slongerbeam@gmail.com \
--cc=xavier.roumegue@oss.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;
as well as URLs for NNTP newsgroup(s).