Message ID | 20221103163113.245462-19-paul.kocialkowski@bootlin.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Allwinner A31/A83T MIPI CSI-2 and A31 ISP / CSI Rework | expand |
Hi Paul, On Thu, Nov 03, 2022 at 05:31:03PM +0100, Paul Kocialkowski wrote: > Introduce a list of mbus/pixel format combinations that need an exact > match between the two sides. This is the case when using raw input > configuration. The list will be used to replace the > sun6i_csi_is_format_supported combinatory helper. This patch introduces an unused function which generates a compiler warning that is now treated as an error. I'll squash this to the following patch that uses the function. I think the commit message will do as-is. > > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> > Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> > --- > .../sunxi/sun6i-csi/sun6i_csi_capture.c | 117 ++++++++++++++++++ > .../sunxi/sun6i-csi/sun6i_csi_capture.h | 5 + > 2 files changed, 122 insertions(+) > > diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c > index 99b821d79357..7958419d3c6e 100644 > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c > @@ -227,6 +227,123 @@ struct sun6i_csi_capture_format *sun6i_csi_capture_format_find(u32 pixelformat) > return NULL; > } > > +/* RAW formats need an exact match between pixel and mbus formats. */ > +static const > +struct sun6i_csi_capture_format_match sun6i_csi_capture_format_matches[] = { > + /* YUV420 */ > + { > + .pixelformat = V4L2_PIX_FMT_YUYV, > + .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_YUYV, > + .mbus_code = MEDIA_BUS_FMT_YUYV8_1X16, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_YVYU, > + .mbus_code = MEDIA_BUS_FMT_YVYU8_2X8, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_YVYU, > + .mbus_code = MEDIA_BUS_FMT_YVYU8_1X16, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_UYVY, > + .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_UYVY, > + .mbus_code = MEDIA_BUS_FMT_UYVY8_1X16, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_VYUY, > + .mbus_code = MEDIA_BUS_FMT_VYUY8_2X8, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_VYUY, > + .mbus_code = MEDIA_BUS_FMT_VYUY8_1X16, > + }, > + /* RGB */ > + { > + .pixelformat = V4L2_PIX_FMT_RGB565, > + .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_RGB565X, > + .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_BE, > + }, > + /* Bayer */ > + { > + .pixelformat = V4L2_PIX_FMT_SBGGR8, > + .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SGBRG8, > + .mbus_code = MEDIA_BUS_FMT_SGBRG8_1X8, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SGRBG8, > + .mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SRGGB8, > + .mbus_code = MEDIA_BUS_FMT_SRGGB8_1X8, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SBGGR10, > + .mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SGBRG10, > + .mbus_code = MEDIA_BUS_FMT_SGBRG10_1X10, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SGRBG10, > + .mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SRGGB10, > + .mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SBGGR12, > + .mbus_code = MEDIA_BUS_FMT_SBGGR12_1X12, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SGBRG12, > + .mbus_code = MEDIA_BUS_FMT_SGBRG12_1X12, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SGRBG12, > + .mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12, > + }, > + { > + .pixelformat = V4L2_PIX_FMT_SRGGB12, > + .mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12, > + }, > + /* Compressed */ > + { > + .pixelformat = V4L2_PIX_FMT_JPEG, > + .mbus_code = MEDIA_BUS_FMT_JPEG_1X8, > + }, > +}; > + > +static bool sun6i_csi_capture_format_match(u32 pixelformat, u32 mbus_code) > +{ > + unsigned int i; > + > + for (i = 0; i < ARRAY_SIZE(sun6i_csi_capture_format_matches); i++) { > + const struct sun6i_csi_capture_format_match *match = > + &sun6i_csi_capture_format_matches[i]; > + > + if (match->pixelformat == pixelformat && > + match->mbus_code == mbus_code) > + return true; > + } > + > + return false; > +} > + > /* Capture */ > > static void sun6i_csi_capture_irq_enable(struct sun6i_csi_device *csi_dev) > diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h > index 4b1ff19edc2f..2605b16f091c 100644 > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h > @@ -27,6 +27,11 @@ struct sun6i_csi_capture_format { > u32 hsize_len_factor; > }; > > +struct sun6i_csi_capture_format_match { > + u32 pixelformat; > + u32 mbus_code; > +}; > + > #undef current > struct sun6i_csi_capture_state { > struct list_head queue;
On Fri, Nov 11, 2022 at 12:18:14PM +0200, Sakari Ailus wrote: > Hi Paul, > > On Thu, Nov 03, 2022 at 05:31:03PM +0100, Paul Kocialkowski wrote: > > Introduce a list of mbus/pixel format combinations that need an exact > > match between the two sides. This is the case when using raw input > > configuration. The list will be used to replace the > > sun6i_csi_is_format_supported combinatory helper. > > This patch introduces an unused function which generates a compiler warning > that is now treated as an error. > > I'll squash this to the following patch that uses the function. I think the > commit message will do as-is. Ok, maybe the helper actually should be mentioned. I used this: Rework the capture link validate implementation with actual logic that reflects the possibilities of the device instead of the combinatory helper functions, using the added match list helper sun6i_csi_is_format_supported() when needed. Remove the previous dedicated helper.
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index 99b821d79357..7958419d3c6e 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -227,6 +227,123 @@ struct sun6i_csi_capture_format *sun6i_csi_capture_format_find(u32 pixelformat) return NULL; } +/* RAW formats need an exact match between pixel and mbus formats. */ +static const +struct sun6i_csi_capture_format_match sun6i_csi_capture_format_matches[] = { + /* YUV420 */ + { + .pixelformat = V4L2_PIX_FMT_YUYV, + .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, + }, + { + .pixelformat = V4L2_PIX_FMT_YUYV, + .mbus_code = MEDIA_BUS_FMT_YUYV8_1X16, + }, + { + .pixelformat = V4L2_PIX_FMT_YVYU, + .mbus_code = MEDIA_BUS_FMT_YVYU8_2X8, + }, + { + .pixelformat = V4L2_PIX_FMT_YVYU, + .mbus_code = MEDIA_BUS_FMT_YVYU8_1X16, + }, + { + .pixelformat = V4L2_PIX_FMT_UYVY, + .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8, + }, + { + .pixelformat = V4L2_PIX_FMT_UYVY, + .mbus_code = MEDIA_BUS_FMT_UYVY8_1X16, + }, + { + .pixelformat = V4L2_PIX_FMT_VYUY, + .mbus_code = MEDIA_BUS_FMT_VYUY8_2X8, + }, + { + .pixelformat = V4L2_PIX_FMT_VYUY, + .mbus_code = MEDIA_BUS_FMT_VYUY8_1X16, + }, + /* RGB */ + { + .pixelformat = V4L2_PIX_FMT_RGB565, + .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE, + }, + { + .pixelformat = V4L2_PIX_FMT_RGB565X, + .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_BE, + }, + /* Bayer */ + { + .pixelformat = V4L2_PIX_FMT_SBGGR8, + .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8, + }, + { + .pixelformat = V4L2_PIX_FMT_SGBRG8, + .mbus_code = MEDIA_BUS_FMT_SGBRG8_1X8, + }, + { + .pixelformat = V4L2_PIX_FMT_SGRBG8, + .mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8, + }, + { + .pixelformat = V4L2_PIX_FMT_SRGGB8, + .mbus_code = MEDIA_BUS_FMT_SRGGB8_1X8, + }, + { + .pixelformat = V4L2_PIX_FMT_SBGGR10, + .mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, + }, + { + .pixelformat = V4L2_PIX_FMT_SGBRG10, + .mbus_code = MEDIA_BUS_FMT_SGBRG10_1X10, + }, + { + .pixelformat = V4L2_PIX_FMT_SGRBG10, + .mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10, + }, + { + .pixelformat = V4L2_PIX_FMT_SRGGB10, + .mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10, + }, + { + .pixelformat = V4L2_PIX_FMT_SBGGR12, + .mbus_code = MEDIA_BUS_FMT_SBGGR12_1X12, + }, + { + .pixelformat = V4L2_PIX_FMT_SGBRG12, + .mbus_code = MEDIA_BUS_FMT_SGBRG12_1X12, + }, + { + .pixelformat = V4L2_PIX_FMT_SGRBG12, + .mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12, + }, + { + .pixelformat = V4L2_PIX_FMT_SRGGB12, + .mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12, + }, + /* Compressed */ + { + .pixelformat = V4L2_PIX_FMT_JPEG, + .mbus_code = MEDIA_BUS_FMT_JPEG_1X8, + }, +}; + +static bool sun6i_csi_capture_format_match(u32 pixelformat, u32 mbus_code) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(sun6i_csi_capture_format_matches); i++) { + const struct sun6i_csi_capture_format_match *match = + &sun6i_csi_capture_format_matches[i]; + + if (match->pixelformat == pixelformat && + match->mbus_code == mbus_code) + return true; + } + + return false; +} + /* Capture */ static void sun6i_csi_capture_irq_enable(struct sun6i_csi_device *csi_dev) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h index 4b1ff19edc2f..2605b16f091c 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h @@ -27,6 +27,11 @@ struct sun6i_csi_capture_format { u32 hsize_len_factor; }; +struct sun6i_csi_capture_format_match { + u32 pixelformat; + u32 mbus_code; +}; + #undef current struct sun6i_csi_capture_state { struct list_head queue;