From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jacopo Mondi <jacopo@jmondi.org>, Sakari Ailus <sakari.ailus@iki.fi>
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 8/8] media: imx: imx-mipi-csis: Add RGB/BGR888
Date: Tue, 15 Feb 2022 09:46:26 +0200 [thread overview]
Message-ID: <YgtaUsxBF69bZa92@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220214184318.409208-9-jacopo@jmondi.org>
Hi Jacopo,
(Adding Sakari to the recipients)
Thank you for the patch.
On Mon, Feb 14, 2022 at 07:43:18PM +0100, Jacopo Mondi wrote:
> Add support for the RGB888_1X24 and BGR888_1X24 image formats.
>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
> drivers/media/platform/imx/imx-mipi-csis.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/media/platform/imx/imx-mipi-csis.c b/drivers/media/platform/imx/imx-mipi-csis.c
> index 9e0a478dba75..0d5870b3010a 100644
> --- a/drivers/media/platform/imx/imx-mipi-csis.c
> +++ b/drivers/media/platform/imx/imx-mipi-csis.c
> @@ -366,6 +366,16 @@ static const struct csis_pix_format mipi_csis_formats[] = {
> .data_type = MIPI_CSI2_DATA_TYPE_RGB565,
> .width = 16,
> },
> + {
}, {
to match the rest of the array. Same below.
> + .code = MEDIA_BUS_FMT_RGB888_1X24,
> + .data_type = MIPI_CSI2_DATA_TYPE_RGB888,
> + .width = 24,
> + },
> + {
> + .code = MEDIA_BUS_FMT_BGR888_1X24,
> + .data_type = MIPI_CSI2_DATA_TYPE_RGB888,
> + .width = 24,
> + },
CSI-2 specifies the order of bits on the bus for RGB888, with data being
transmitted in the B, G, R order. The recommended format when stored in
memory is V4L2_PIX_FMT_BGR24 (B in byte 0, G in byte 1, R in byte 2).
There is no recommended deserialized bus format though.
On the output side of the CSIS, we have information. Given figure 13-23
("Pixel alignment") in the i.MX8MP reference manual, and the definition
of RGB_SWAP in MIPI_CSI2_ISP_CONFIG_CH0 that reads
Swapping RGB sequence
0 MSB is R and LSB is B.
1 MSB is B and LSB is R (swapped).
I think MEDIA_BUS_FMT_RGB888_1X24 is appropriate.
On the input side of the CSIS, however, it's a different story, similar
to YUV formats. For YUV 4:2:2 we have picked MEDIA_BUS_FMT_UYVY8_1X16
arbitrarily to represent the CSI-2 bus format. It doesn't correspond to
the physical reality, but it doesn't matter much. We thus need to do the
same for RGB888. If we follow the same convention as for YUV 4:2:2,
which transmits data in the U, Y, V, Y order, we should then pick
BGR888_1X24. However, the CSIS driver would then need to translate from
the input format BGR888_1X24 to the output format RGB888_1X24, which
adds a bit of complexity.
Picking RGB888_1X24 for the CSI-2 bus is thus tempting, but it's a
choice that will affect all drivers, so I wouldn't make this based
solely on ease of implementation in a particular driver. I'm thus
tempted to go for BGR888_1X24 to be consistent with YUV 4:2:2. Another
option would be to add a new RGB888_CSI2 media bus format. In retrospect
we should have done the same for YUV 4:2:2. Mistakes happen.
Sakari, what do you think ?
If we go for BGR888_1X24, the translation between BGR888_1X24 and
RGB888_1X24 may not be that hard to implement. You could add an output
field to the csis_pix_format structure to store the output media bus
code for a given input code, and I think the implementation would then
remain relatively simple.
Finally, we can also support the swapped RGB format (which is
non-standard in CSI-2 but is supported by some sensors, the same way as
YUV permutations are often supported too), but it will require setting
RGB_SWAP. You can add a rgb_swap field to csis_pix_format for this.
I'd split this patch in two, adding MEDIA_BUS_FMT_RGB888_1X24 first, and
then adding MEDIA_BUS_FMT_BGR888_1X24 with the new rgb_swap field. The
first patch should capture the above explanation.
> /* RAW (Bayer and greyscale) formats. */
> {
> .code = MEDIA_BUS_FMT_SBGGR8_1X8,
--
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-15 7:47 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
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 [this message]
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=YgtaUsxBF69bZa92@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=sakari.ailus@iki.fi \
--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).