[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251028082051.GY13023@pendragon.ideasonboard.com>
Date: Tue, 28 Oct 2025 10:20:51 +0200
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Frank Li <Frank.li@....com>
Cc: Rui Miguel Silva <rmfrfs@...il.com>,
Martin Kepplinger <martink@...teo.de>,
Purism Kernel Team <kernel@...i.sm>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Eugen Hristev <eugen.hristev@...aro.org>,
Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, Peng Fan <peng.fan@....com>,
Alice Yuan <alice.yuan@....com>, Vinod Koul <vkoul@...nel.org>,
Kishon Vijay Abraham I <kishon@...nel.org>,
Philipp Zabel <p.zabel@...gutronix.de>,
Steve Longerbeam <slongerbeam@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-media@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, imx@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org, linux-phy@...ts.infradead.org,
linux-staging@...ts.linux.dev
Subject: Re: [PATCH v3 03/31] media: v4l2-common: Add helper function
media_bus_fmt_to_csi2_(bpp|dt)()
On Mon, Oct 27, 2025 at 12:59:46PM -0400, Frank Li wrote:
> On Mon, Oct 27, 2025 at 03:32:04AM +0200, Laurent Pinchart wrote:
> > On Thu, Aug 21, 2025 at 04:15:38PM -0400, Frank Li wrote:
> > > Add helper function media_bus_fmt_to_csi2_bpp() to get media bus fmt's bpp
> > > to reduce codes such as
> > >
> > > static const struct imx7_csi_pixfmt pixel_formats[] = {
> > > {
> > > .fourcc = V4L2_PIX_FMT_UYVY,
> > > .codes = IMX_BUS_FMTS(
> > > MEDIA_BUS_FMT_UYVY8_2X8,
> > > MEDIA_BUS_FMT_UYVY8_1X16
> > > ),
> > > .yuv = true,
> > > .bpp = 16,
> > > },
> > > ....
> > >
> > > .bpp can be removed from pixel_formats with this helper function.
> > >
> > > CSI2 data type is defined by MIPI Camera Serial Interface 2 Spec Ver4.1.
> > > See section 9.4.
> > >
> > > Add helper function media_bus_fmt_to_csi2_dt() to convert media bus fmt to
> > > MIPI defined data type and avoid below duplicated static array in each CSI2
> > > drivers.
> > >
> > > {
> > > .code = MEDIA_BUS_FMT_UYVY8_1X16,
> > > .data_type = MIPI_CSI2_DT_YUV422_8B,
> > > }
> > >
> > > Only add known map for dt type. Need update media_bus_fmt_info when new
> > > mapping used.
> > >
> > > Signed-off-by: Frank Li <Frank.Li@....com>
> > > ---
> > > Change in v3:
> > > - squash two help function patch to one.
> > > - use media_bus_fmt_info to do map.
> > > ---
> > > drivers/media/v4l2-core/v4l2-common.c | 149 ++++++++++++++++++++++++++++++++++
> > > include/media/mipi-csi2.h | 30 +++++++
> > > 2 files changed, 179 insertions(+)
> > >
> > > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> > > index a5334aa35992e5f57fb228c33d40c51fdafdc135..a75987aa5fc69d6368709b7d521bede666da9513 100644
> > > --- a/drivers/media/v4l2-core/v4l2-common.c
> > > +++ b/drivers/media/v4l2-core/v4l2-common.c
> > > @@ -46,6 +46,7 @@
> > > #include <linux/uaccess.h>
> > > #include <asm/io.h>
> > > #include <asm/div64.h>
> > > +#include <media/mipi-csi2.h>
> > > #include <media/v4l2-common.h>
> > > #include <media/v4l2-device.h>
> > > #include <media/v4l2-ctrls.h>
> > > @@ -757,3 +758,151 @@ struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id)
> > > return clk_hw->clk;
> > > }
> > > EXPORT_SYMBOL_GPL(devm_v4l2_sensor_clk_get);
> > > +
> > > +static const struct media_bus_fmt_info media_bus_fmt_info[] = {
> > > + { .fmt = MEDIA_BUS_FMT_RGB444_1X12, .bpp = 12},
> >
> > Missing space before }.
> >
> > > + { .fmt = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_RGB565_1X16, .dt = MIPI_CSI2_DT_RGB565, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_BGR565_2X8_BE, .dt = MIPI_CSI2_DT_RGB565, .bpp = 16},
> >
> > Let's not specify .dt for formats that must not be used with CSI-2
> > buses.
>
> Do you know which not used CSI-2 bus, or where I can get such information?
The discussion is ongoing, see
https://lore.kernel.org/linux-media/20251013-csi-bgr-rgb-v4-0-55eab2caa69f@kernel.org/.
I think we can safely assume that we won't change the policy of using a
media bus code that transmits a pixel in a single sample. That means
we'll use _1X16 codes but never _2X8. For the colour components order,
we need to wait for a conclusion in the above mail thread.
> > > + { .fmt = MEDIA_BUS_FMT_BGR565_2X8_LE, .dt = MIPI_CSI2_DT_RGB565, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_RGB565_2X8_BE, .dt = MIPI_CSI2_DT_RGB565, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_RGB565_2X8_LE, .dt = MIPI_CSI2_DT_RGB565, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_RGB666_1X18, .bpp = 18},
> > > + { .fmt = MEDIA_BUS_FMT_RGB666_2X9_BE, .bpp = 18},
> > > + { .fmt = MEDIA_BUS_FMT_BGR666_1X18, .bpp = 18},
> > > + { .fmt = MEDIA_BUS_FMT_RBG888_1X24, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_RGB666_1X24_CPADHI, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_BGR666_1X24_CPADHI, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_RGB565_1X24_CPADHI, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG, .bpp = 21},
> > > + { .fmt = MEDIA_BUS_FMT_BGR888_1X24, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_BGR888_3X8, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_GBR888_1X24, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_RGB888_1X24, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_RGB888_2X12_BE, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_RGB888_2X12_LE, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_RGB888_3X8, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_RGB888_3X8_DELTA, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, .bpp = 28},
> > > + { .fmt = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA, .bpp = 28},
> > > + { .fmt = MEDIA_BUS_FMT_RGB666_1X30_CPADLO, .bpp = 30},
> > > + { .fmt = MEDIA_BUS_FMT_RGB888_1X30_CPADLO, .bpp = 30},
> > > + { .fmt = MEDIA_BUS_FMT_ARGB8888_1X32, .bpp = 32},
> > > + { .fmt = MEDIA_BUS_FMT_RGB888_1X32_PADHI, .bpp = 32},
> > > + { .fmt = MEDIA_BUS_FMT_RGB101010_1X30, .bpp = 30},
> > > + { .fmt = MEDIA_BUS_FMT_RGB101010_1X7X5_SPWG, .bpp = 35},
> > > + { .fmt = MEDIA_BUS_FMT_RGB101010_1X7X5_JEIDA, .bpp = 35},
> > > + { .fmt = MEDIA_BUS_FMT_RGB666_1X36_CPADLO, .bpp = 36},
> > > + { .fmt = MEDIA_BUS_FMT_RGB888_1X36_CPADLO, .bpp = 36},
> > > + { .fmt = MEDIA_BUS_FMT_RGB121212_1X36, .bpp = 36},
> > > + { .fmt = MEDIA_BUS_FMT_RGB161616_1X48, .bpp = 48},
> > > +
> > > + { .fmt = MEDIA_BUS_FMT_Y8_1X8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_UV8_1X8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_UYVY8_1_5X8, .bpp = 40},
> >
> > This doesn't seem correct.
>
> I add by surfix <m>X<n>, Is my understand about <m>X<n> wrong? or
> MEDIA_BUS_FMT_UYVY8_1_5X8 itself is wrong?
1_5X8 means 1.5 * 8.
> > > + { .fmt = MEDIA_BUS_FMT_VYUY8_1_5X8, .bpp = 40},
> > > + { .fmt = MEDIA_BUS_FMT_YUYV8_1_5X8, .bpp = 40},
> > > + { .fmt = MEDIA_BUS_FMT_YVYU8_1_5X8, .bpp = 40},
> > > + { .fmt = MEDIA_BUS_FMT_UYVY8_2X8, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_VYUY8_2X8, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_YUYV8_2X8, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_YVYU8_2X8, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_Y10_1X10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10},
> > > + { .fmt = MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_UYVY10_2X10, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20},
> > > + { .fmt = MEDIA_BUS_FMT_VYUY10_2X10, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20},
> > > + { .fmt = MEDIA_BUS_FMT_YUYV10_2X10, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20},
> > > + { .fmt = MEDIA_BUS_FMT_YVYU10_2X10, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20},
> > > + { .fmt = MEDIA_BUS_FMT_Y12_1X12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12},
> > > + { .fmt = MEDIA_BUS_FMT_UYVY12_2X12, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_VYUY12_2X12, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_YUYV12_2X12, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_YVYU12_2X12, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_Y14_1X14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14},
> > > + { .fmt = MEDIA_BUS_FMT_Y16_1X16, .dt = MIPI_CSI2_DT_RAW16, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_UYVY8_1X16, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_VYUY8_1X16, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_YUYV8_1X16, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_YVYU8_1X16, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_YDYUYDYV8_1X16, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_UYVY10_1X20, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20},
> > > + { .fmt = MEDIA_BUS_FMT_VYUY10_1X20, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20},
> > > + { .fmt = MEDIA_BUS_FMT_YUYV10_1X20, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20},
> > > + { .fmt = MEDIA_BUS_FMT_YVYU10_1X20, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20},
> > > + { .fmt = MEDIA_BUS_FMT_VUY8_1X24, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_YUV8_1X24, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_UYYVYY8_0_5X24, .dt = MIPI_CSI2_DT_YUV420_8B, .bpp = 120},
> > > + { .fmt = MEDIA_BUS_FMT_UYVY12_1X24, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_VYUY12_1X24, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_YUYV12_1X24, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_YVYU12_1X24, .bpp = 24},
> > > + { .fmt = MEDIA_BUS_FMT_YUV10_1X30, .bpp = 30},
> > > + { .fmt = MEDIA_BUS_FMT_UYYVYY10_0_5X30, .bpp = 150},
> > > + { .fmt = MEDIA_BUS_FMT_AYUV8_1X32, .bpp = 32},
> > > + { .fmt = MEDIA_BUS_FMT_UYYVYY12_0_5X36, .bpp = 180},
> > > + { .fmt = MEDIA_BUS_FMT_YUV12_1X36, .bpp = 36},
> > > + { .fmt = MEDIA_BUS_FMT_YUV16_1X48, .bpp = 48},
> > > + { .fmt = MEDIA_BUS_FMT_UYYVYY16_0_5X48, .bpp = 240},
> > > +
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR8_1X8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SGBRG8_1X8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SGRBG8_1X8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SRGGB8_1X8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR10_1X10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10},
> > > + { .fmt = MEDIA_BUS_FMT_SGBRG10_1X10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10},
> > > + { .fmt = MEDIA_BUS_FMT_SGRBG10_1X10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10},
> > > + { .fmt = MEDIA_BUS_FMT_SRGGB10_1X10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10},
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR12_1X12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12},
> > > + { .fmt = MEDIA_BUS_FMT_SGBRG12_1X12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12},
> > > + { .fmt = MEDIA_BUS_FMT_SGRBG12_1X12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12},
> > > + { .fmt = MEDIA_BUS_FMT_SRGGB12_1X12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12},
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR14_1X14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14},
> > > + { .fmt = MEDIA_BUS_FMT_SGBRG14_1X14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14},
> > > + { .fmt = MEDIA_BUS_FMT_SGRBG14_1X14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14},
> > > + { .fmt = MEDIA_BUS_FMT_SRGGB14_1X14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14},
> > > + { .fmt = MEDIA_BUS_FMT_SBGGR16_1X16, .dt = MIPI_CSI2_DT_RAW16, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_SGBRG16_1X16, .dt = MIPI_CSI2_DT_RAW16, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_SGRBG16_1X16, .dt = MIPI_CSI2_DT_RAW16, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_SRGGB16_1X16, .dt = MIPI_CSI2_DT_RAW16, .bpp = 16},
> > > +
> > > + { .fmt = MEDIA_BUS_FMT_JPEG_1X8, .bpp = 8},
> > > +
> > > + { .fmt = MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8, .bpp = 8},
> > > +
> > > + { .fmt = MEDIA_BUS_FMT_AHSV8888_1X32, .bpp = 8},
> > > +
> > > + { .fmt = MEDIA_BUS_FMT_META_8, .bpp = 8},
> > > + { .fmt = MEDIA_BUS_FMT_META_10, .bpp = 10},
> > > + { .fmt = MEDIA_BUS_FMT_META_12, .bpp = 12},
> > > + { .fmt = MEDIA_BUS_FMT_META_14, .bpp = 14},
> > > + { .fmt = MEDIA_BUS_FMT_META_16, .bpp = 16},
> > > + { .fmt = MEDIA_BUS_FMT_META_20, .bpp = 20},
> > > + { .fmt = MEDIA_BUS_FMT_META_24, .bpp = 24},
> > > +};
> > > +
> > > +const struct media_bus_fmt_info *media_bus_fmt_info_get(u32 bus_fmt)
> > > +{
> > > + int i;
> >
> > unsigned
> >
> > > +
> > > + for (i = 0; i < ARRAY_SIZE(media_bus_fmt_info); i++)
> > > + if (media_bus_fmt_info[i].fmt == bus_fmt)
> > > + return &media_bus_fmt_info[i];
> >
> > Add curly braces for the "for" statement.
> >
> > > +
> > > + return NULL;
> > > +}
> > > +EXPORT_SYMBOL_GPL(media_bus_fmt_info_get);
> > > diff --git a/include/media/mipi-csi2.h b/include/media/mipi-csi2.h
> > > index 40fc0264250d779ab5dfa7d2fe16e6f1382c07d4..3227d28224b7c32ef2745548391da9e792cfa559 100644
> > > --- a/include/media/mipi-csi2.h
> > > +++ b/include/media/mipi-csi2.h
> > > @@ -8,6 +8,8 @@
> > > #ifndef _MEDIA_MIPI_CSI2_H
> > > #define _MEDIA_MIPI_CSI2_H
> > >
> > > +/* DT value ref to MIPI Camera Serial Interface 2 Spec Ver4.1 section 9.4 */
> > > +
> > > /* Short packet data types */
> > > #define MIPI_CSI2_DT_FS 0x00
> > > #define MIPI_CSI2_DT_FE 0x01
> > > @@ -44,4 +46,32 @@
> > > #define MIPI_CSI2_DT_RAW20 0x2f
> > > #define MIPI_CSI2_DT_USER_DEFINED(n) (0x30 + (n)) /* 0..7 */
> > >
> > > +/**
> > > + * struct media_bus_fmt_info - information about a media bus format
> > > + * @fmt: media bus format identifier (MEDIA_BUS_FMT_*)
> >
> > We usually name this "code".
> >
> > > + * @dt: data type define in MIPI spec (MIPI_CSI2_DT *)
> > > + * @bpp: bit width per pixel
> >
> > You will need to define this much more precisely. In particular, how is
> > padding handled ? How about compressed formats such as JPEG ? How about
> > the LVDS formats, how are the control bits accounted for ?
> >
> > I understand you're trying to share code between two drivers, but I'm
> > not sure we will be able to come up with a standard definition of bpp
> > that will match the needs of all drivers. It feels that this information
> > would be better stored in driver-specific tables.
>
> 80% is duplicated codes if stored in driver-specific tables. If driver use
> difference defination, they can create customerized table. This one at
> least cover more than 80% case.
In that case we need a clear and precise definition of the 'bpp' field.
> > > + */
> > > +struct media_bus_fmt_info {
> > > + u32 fmt;
> > > + u32 dt;
> > > + u8 bpp;
> > > +};
> > > +
> > > +const struct media_bus_fmt_info *media_bus_fmt_info_get(u32 bus_fmt);
> > > +
> > > +static inline int media_bus_fmt_to_csi2_dt(int bus_fmt)
> > > +{
> > > + const struct media_bus_fmt_info *info = media_bus_fmt_info_get(bus_fmt);
> > > +
> > > + return info ? info->dt : 0;
> > > +}
> > > +
> > > +static inline int media_bus_fmt_to_csi2_bpp(int bus_fmt)
> > > +{
> > > + const struct media_bus_fmt_info *info = media_bus_fmt_info_get(bus_fmt);
> > > +
> > > + return info ? info->bpp : 0;
> > > +}
> > > +
> >
> > These are not specific to CSI-2, they belong to a different header.
> > v4l2-common.h is an option, given that the implementation goes to
> > v4l2-common.c.
> >
> > > #endif /* _MEDIA_MIPI_CSI2_H */
> > >
> > >
--
Regards,
Laurent Pinchart
Powered by blists - more mailing lists