media: ov5640: Associate bpp with formats
authorJacopo Mondi <jacopo@jmondi.org>
Fri, 13 May 2022 14:13:52 +0000 (15:13 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 8 Jul 2022 14:17:11 +0000 (15:17 +0100)
Associate the bit depth to each format supported by the sensor.

The bpp will be used to calculate the line length.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/i2c/ov5640.c

index 0697c9bf03ed9f5f02170363f9c9e6c5157d8f5b..297ed135c4768cdae2b74f515ef536beece28dc9 100644 (file)
@@ -150,23 +150,56 @@ enum ov5640_format_mux {
        OV5640_FMT_MUX_RAW_CIP,
 };
 
-struct ov5640_pixfmt {
+static const struct ov5640_pixfmt {
        u32 code;
        u32 colorspace;
-};
-
-static const struct ov5640_pixfmt ov5640_formats[] = {
-       { MEDIA_BUS_FMT_JPEG_1X8, V4L2_COLORSPACE_JPEG, },
-       { MEDIA_BUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_SRGB, },
-       { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_COLORSPACE_SRGB, },
-       { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_SRGB, },
-       { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_COLORSPACE_SRGB, },
-       { MEDIA_BUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB, },
-       { MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB, },
-       { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB, },
-       { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_COLORSPACE_SRGB, },
-       { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_COLORSPACE_SRGB, },
-       { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_COLORSPACE_SRGB, },
+       u8 bpp;
+} ov5640_formats[] = {
+       {
+               .code = MEDIA_BUS_FMT_JPEG_1X8,
+               .colorspace = V4L2_COLORSPACE_JPEG,
+               .bpp = 16,
+       }, {
+               .code = MEDIA_BUS_FMT_UYVY8_2X8,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .bpp = 16,
+       }, {
+               .code = MEDIA_BUS_FMT_UYVY8_1X16,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .bpp = 16,
+       }, {
+               .code = MEDIA_BUS_FMT_YUYV8_2X8,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .bpp = 16,
+       }, {
+               .code = MEDIA_BUS_FMT_YUYV8_1X16,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .bpp = 16,
+       }, {
+               .code = MEDIA_BUS_FMT_RGB565_2X8_LE,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .bpp = 16,
+       }, {
+               .code = MEDIA_BUS_FMT_RGB565_2X8_BE,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .bpp = 16,
+       }, {
+               .code = MEDIA_BUS_FMT_SBGGR8_1X8,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .bpp = 8,
+       }, {
+               .code = MEDIA_BUS_FMT_SGBRG8_1X8,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .bpp = 8
+       }, {
+               .code = MEDIA_BUS_FMT_SGRBG8_1X8,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .bpp = 8,
+       }, {
+               .code = MEDIA_BUS_FMT_SRGGB8_1X8,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .bpp = 8,
+       },
 };
 
 /*