From a126fcc4ff38718e2e714fbb78db3ca1c4f8e564 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Fri, 15 Feb 2019 11:36:14 +0000 Subject: [PATCH] staging: bcm2835_codec: Add an option for ignoring Bayer formats. This is a workaround for GStreamer currently not identifying Bayer as a raw format, therefore any device that supports it does not match the criteria for v4l2convert. Signed-off-by: Dave Stevenson --- .../bcm2835-codec/bcm2835-v4l2-codec.c | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c @@ -58,6 +58,15 @@ static int isp_video_nr = 12; module_param(isp_video_nr, int, 0644); MODULE_PARM_DESC(isp_video_nr, "isp video device number"); +/* + * Workaround for GStreamer v4l2convert component not considering Bayer formats + * as raw, and therefore not considering a V4L2 device that supports them as + * as a suitable candidate. + */ +static bool disable_bayer; +module_param(disable_bayer, bool, 0644); +MODULE_PARM_DESC(disable_bayer, "Disable support for Bayer formats"); + static unsigned int debug; module_param(debug, uint, 0644); MODULE_PARM_DESC(debug, "activates debug info (0-3)"); @@ -105,6 +114,7 @@ struct bcm2835_codec_fmt { u32 flags; u32 mmal_fmt; int size_multiplier_x2; + bool is_bayer; }; static const struct bcm2835_codec_fmt supported_formats[] = { @@ -203,6 +213,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB8, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SBGGR8, .depth = 8, @@ -210,6 +221,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR8, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGRBG8, .depth = 8, @@ -217,6 +229,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG8, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGBRG8, .depth = 8, @@ -224,6 +237,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG8, .size_multiplier_x2 = 2, + .is_bayer = true, }, { /* 10 bit */ .fourcc = V4L2_PIX_FMT_SRGGB10P, @@ -232,6 +246,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB10P, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SBGGR10P, .depth = 10, @@ -239,6 +254,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR10P, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGRBG10P, .depth = 10, @@ -246,6 +262,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG10P, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGBRG10P, .depth = 10, @@ -253,6 +270,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG10P, .size_multiplier_x2 = 2, + .is_bayer = true, }, { /* 12 bit */ .fourcc = V4L2_PIX_FMT_SRGGB12P, @@ -261,6 +279,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB12P, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SBGGR12P, .depth = 12, @@ -268,6 +287,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR12P, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGRBG12P, .depth = 12, @@ -275,6 +295,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG12P, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGBRG12P, .depth = 12, @@ -282,6 +303,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG12P, .size_multiplier_x2 = 2, + .is_bayer = true, }, { /* 16 bit */ .fourcc = V4L2_PIX_FMT_SRGGB16, @@ -290,6 +312,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB16, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SBGGR16, .depth = 16, @@ -297,6 +320,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR16, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGRBG16, .depth = 16, @@ -304,6 +328,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG16, .size_multiplier_x2 = 2, + .is_bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGBRG16, .depth = 16, @@ -311,6 +336,7 @@ static const struct bcm2835_codec_fmt su .flags = 0, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG16, .size_multiplier_x2 = 2, + .is_bayer = true, }, { /* Compressed formats */ .fourcc = V4L2_PIX_FMT_H264, @@ -438,7 +464,8 @@ static const struct bcm2835_codec_fmt *g unsigned int i; for (i = 0; i < ARRAY_SIZE(supported_formats); i++) { - if (supported_formats[i].mmal_fmt == mmal_fmt) + if (supported_formats[i].mmal_fmt == mmal_fmt && + (!disable_bayer || !supported_formats[i].is_bayer)) return &supported_formats[i]; } return NULL;