提交 a53c12da 编写于 作者: D David Plowman 提交者: Zheng Zengkai

bcm2835-isp: Allow formats with different colour spaces.

raspberrypi inclusion
category: feature
bugzilla: 50432

--------------------------------

Each supported format now includes a mask showing the allowed colour
spaces, as well as a default colour space for when one was not
specified.

Additionally we translate the colour space to mmal format and pass it
over to the VideoCore.
Signed-off-by: NDavid Plowman <david.plowman@raspberrypi.com>
Signed-off-by: NFang Yafen <yafen@iscas.ac.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 5b929a69
...@@ -20,10 +20,29 @@ struct bcm2835_isp_fmt { ...@@ -20,10 +20,29 @@ struct bcm2835_isp_fmt {
int bytesperline_align; int bytesperline_align;
u32 mmal_fmt; u32 mmal_fmt;
int size_multiplier_x2; int size_multiplier_x2;
enum v4l2_colorspace colorspace; u32 colorspace_mask;
enum v4l2_colorspace colorspace_default;
unsigned int step_size; unsigned int step_size;
}; };
#define V4L2_COLORSPACE_MASK(colorspace) BIT(colorspace)
#define V4L2_COLORSPACE_MASK_JPEG V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_JPEG)
#define V4L2_COLORSPACE_MASK_SMPTE170M V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_SMPTE170M)
#define V4L2_COLORSPACE_MASK_REC709 V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_REC709)
#define V4L2_COLORSPACE_MASK_SRGB V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_SRGB)
#define V4L2_COLORSPACE_MASK_RAW V4L2_COLORSPACE_MASK(V4L2_COLORSPACE_RAW)
/*
* The colour spaces we support for YUV outputs. SRGB features here because,
* once you assign the default transfer func and so on, it and JPEG effectively
* mean the same.
*/
#define V4L2_COLORSPACE_MASK_YUV (V4L2_COLORSPACE_MASK_JPEG | \
V4L2_COLORSPACE_MASK_SRGB | \
V4L2_COLORSPACE_MASK_SMPTE170M | \
V4L2_COLORSPACE_MASK_REC709)
static const struct bcm2835_isp_fmt supported_formats[] = { static const struct bcm2835_isp_fmt supported_formats[] = {
{ {
/* YUV formats */ /* YUV formats */
...@@ -32,7 +51,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -32,7 +51,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_I420, .mmal_fmt = MMAL_ENCODING_I420,
.size_multiplier_x2 = 3, .size_multiplier_x2 = 3,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
.colorspace_default = V4L2_COLORSPACE_JPEG,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_YVU420, .fourcc = V4L2_PIX_FMT_YVU420,
...@@ -40,7 +60,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -40,7 +60,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_YV12, .mmal_fmt = MMAL_ENCODING_YV12,
.size_multiplier_x2 = 3, .size_multiplier_x2 = 3,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_NV12, .fourcc = V4L2_PIX_FMT_NV12,
...@@ -48,7 +69,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -48,7 +69,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_NV12, .mmal_fmt = MMAL_ENCODING_NV12,
.size_multiplier_x2 = 3, .size_multiplier_x2 = 3,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_NV21, .fourcc = V4L2_PIX_FMT_NV21,
...@@ -56,7 +78,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -56,7 +78,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_NV21, .mmal_fmt = MMAL_ENCODING_NV21,
.size_multiplier_x2 = 3, .size_multiplier_x2 = 3,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_YUYV, .fourcc = V4L2_PIX_FMT_YUYV,
...@@ -64,7 +87,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -64,7 +87,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 64, .bytesperline_align = 64,
.mmal_fmt = MMAL_ENCODING_YUYV, .mmal_fmt = MMAL_ENCODING_YUYV,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_UYVY, .fourcc = V4L2_PIX_FMT_UYVY,
...@@ -72,7 +96,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -72,7 +96,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 64, .bytesperline_align = 64,
.mmal_fmt = MMAL_ENCODING_UYVY, .mmal_fmt = MMAL_ENCODING_UYVY,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_YVYU, .fourcc = V4L2_PIX_FMT_YVYU,
...@@ -80,7 +105,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -80,7 +105,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 64, .bytesperline_align = 64,
.mmal_fmt = MMAL_ENCODING_YVYU, .mmal_fmt = MMAL_ENCODING_YVYU,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_VYUY, .fourcc = V4L2_PIX_FMT_VYUY,
...@@ -88,7 +114,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -88,7 +114,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 64, .bytesperline_align = 64,
.mmal_fmt = MMAL_ENCODING_VYUY, .mmal_fmt = MMAL_ENCODING_VYUY,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .colorspace_mask = V4L2_COLORSPACE_MASK_YUV,
.colorspace_default = V4L2_COLORSPACE_SMPTE170M,
.step_size = 2, .step_size = 2,
}, { }, {
/* RGB formats */ /* RGB formats */
...@@ -97,7 +124,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -97,7 +124,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_RGB24, .mmal_fmt = MMAL_ENCODING_RGB24,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_SRGB, .colorspace_mask = V4L2_COLORSPACE_MASK_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
.step_size = 1, .step_size = 1,
}, { }, {
.fourcc = V4L2_PIX_FMT_RGB565, .fourcc = V4L2_PIX_FMT_RGB565,
...@@ -105,7 +133,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -105,7 +133,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_RGB16, .mmal_fmt = MMAL_ENCODING_RGB16,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_SRGB, .colorspace_mask = V4L2_COLORSPACE_MASK_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
.step_size = 1, .step_size = 1,
}, { }, {
.fourcc = V4L2_PIX_FMT_BGR24, .fourcc = V4L2_PIX_FMT_BGR24,
...@@ -113,7 +142,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -113,7 +142,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BGR24, .mmal_fmt = MMAL_ENCODING_BGR24,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_SRGB, .colorspace_mask = V4L2_COLORSPACE_MASK_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
.step_size = 1, .step_size = 1,
}, { }, {
.fourcc = V4L2_PIX_FMT_XBGR32, .fourcc = V4L2_PIX_FMT_XBGR32,
...@@ -121,7 +151,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -121,7 +151,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 64, .bytesperline_align = 64,
.mmal_fmt = MMAL_ENCODING_BGRA, .mmal_fmt = MMAL_ENCODING_BGRA,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_SRGB, .colorspace_mask = V4L2_COLORSPACE_MASK_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
.step_size = 1, .step_size = 1,
}, { }, {
.fourcc = V4L2_PIX_FMT_RGBX32, .fourcc = V4L2_PIX_FMT_RGBX32,
...@@ -129,7 +160,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -129,7 +160,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 64, .bytesperline_align = 64,
.mmal_fmt = MMAL_ENCODING_RGBA, .mmal_fmt = MMAL_ENCODING_RGBA,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_SRGB, .colorspace_mask = V4L2_COLORSPACE_MASK_SRGB,
.colorspace_default = V4L2_COLORSPACE_SRGB,
.step_size = 1, .step_size = 1,
}, { }, {
/* Bayer formats */ /* Bayer formats */
...@@ -139,7 +171,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -139,7 +171,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SRGGB8, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB8,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SBGGR8, .fourcc = V4L2_PIX_FMT_SBGGR8,
...@@ -147,7 +180,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -147,7 +180,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SBGGR8, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR8,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGRBG8, .fourcc = V4L2_PIX_FMT_SGRBG8,
...@@ -155,7 +189,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -155,7 +189,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGRBG8, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG8,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGBRG8, .fourcc = V4L2_PIX_FMT_SGBRG8,
...@@ -163,7 +198,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -163,7 +198,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGBRG8, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG8,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 10 bit */ /* 10 bit */
...@@ -172,7 +208,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -172,7 +208,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SRGGB10P, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB10P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SBGGR10P, .fourcc = V4L2_PIX_FMT_SBGGR10P,
...@@ -180,7 +217,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -180,7 +217,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SBGGR10P, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR10P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGRBG10P, .fourcc = V4L2_PIX_FMT_SGRBG10P,
...@@ -188,7 +226,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -188,7 +226,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGRBG10P, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG10P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGBRG10P, .fourcc = V4L2_PIX_FMT_SGBRG10P,
...@@ -196,7 +235,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -196,7 +235,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGBRG10P, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG10P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 12 bit */ /* 12 bit */
...@@ -205,7 +245,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -205,7 +245,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SRGGB12P, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB12P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SBGGR12P, .fourcc = V4L2_PIX_FMT_SBGGR12P,
...@@ -213,7 +254,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -213,7 +254,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SBGGR12P, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR12P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGRBG12P, .fourcc = V4L2_PIX_FMT_SGRBG12P,
...@@ -221,7 +263,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -221,7 +263,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGRBG12P, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG12P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGBRG12P, .fourcc = V4L2_PIX_FMT_SGBRG12P,
...@@ -229,7 +272,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -229,7 +272,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGBRG12P, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG12P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 14 bit */ /* 14 bit */
...@@ -238,7 +282,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -238,7 +282,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SRGGB14P, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB14P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SBGGR14P, .fourcc = V4L2_PIX_FMT_SBGGR14P,
...@@ -246,7 +291,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -246,7 +291,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SBGGR14P, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR14P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGRBG14P, .fourcc = V4L2_PIX_FMT_SGRBG14P,
...@@ -254,7 +300,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -254,7 +300,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGRBG14P, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG14P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGBRG14P, .fourcc = V4L2_PIX_FMT_SGBRG14P,
...@@ -262,7 +309,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -262,7 +309,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGBRG14P, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG14P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 16 bit */ /* 16 bit */
...@@ -271,7 +319,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -271,7 +319,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SRGGB16, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB16,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SBGGR16, .fourcc = V4L2_PIX_FMT_SBGGR16,
...@@ -279,7 +328,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -279,7 +328,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SBGGR16, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR16,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGRBG16, .fourcc = V4L2_PIX_FMT_SGRBG16,
...@@ -287,7 +337,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -287,7 +337,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGRBG16, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG16,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGBRG16, .fourcc = V4L2_PIX_FMT_SGBRG16,
...@@ -295,7 +346,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -295,7 +346,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGBRG16, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG16,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* Bayer formats unpacked to 16bpp */ /* Bayer formats unpacked to 16bpp */
...@@ -305,7 +357,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -305,7 +357,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SRGGB10, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB10,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SBGGR10, .fourcc = V4L2_PIX_FMT_SBGGR10,
...@@ -313,7 +366,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -313,7 +366,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SBGGR10, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR10,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGRBG10, .fourcc = V4L2_PIX_FMT_SGRBG10,
...@@ -321,7 +375,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -321,7 +375,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGRBG10, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG10,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGBRG10, .fourcc = V4L2_PIX_FMT_SGBRG10,
...@@ -329,7 +384,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -329,7 +384,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGBRG10, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG10,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 12 bit */ /* 12 bit */
...@@ -338,7 +394,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -338,7 +394,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SRGGB12, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB12,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SBGGR12, .fourcc = V4L2_PIX_FMT_SBGGR12,
...@@ -346,7 +403,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -346,7 +403,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SBGGR12, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR12,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGRBG12, .fourcc = V4L2_PIX_FMT_SGRBG12,
...@@ -354,7 +412,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -354,7 +412,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGRBG12, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG12,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGBRG12, .fourcc = V4L2_PIX_FMT_SGBRG12,
...@@ -362,7 +421,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -362,7 +421,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGBRG12, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG12,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 14 bit */ /* 14 bit */
...@@ -371,7 +431,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -371,7 +431,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SRGGB14, .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB14,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SBGGR14, .fourcc = V4L2_PIX_FMT_SBGGR14,
...@@ -379,7 +440,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -379,7 +440,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SBGGR14, .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR14,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGRBG14, .fourcc = V4L2_PIX_FMT_SGRBG14,
...@@ -387,7 +449,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -387,7 +449,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGRBG14, .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG14,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_PIX_FMT_SGBRG14, .fourcc = V4L2_PIX_FMT_SGBRG14,
...@@ -395,7 +458,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -395,7 +458,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_BAYER_SGBRG14, .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG14,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* Monochrome MIPI formats */ /* Monochrome MIPI formats */
...@@ -405,7 +469,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -405,7 +469,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_GREY, .mmal_fmt = MMAL_ENCODING_GREY,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 10 bit */ /* 10 bit */
...@@ -414,7 +479,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -414,7 +479,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_Y10P, .mmal_fmt = MMAL_ENCODING_Y10P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 12 bit */ /* 12 bit */
...@@ -423,7 +489,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -423,7 +489,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_Y12P, .mmal_fmt = MMAL_ENCODING_Y12P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 14 bit */ /* 14 bit */
...@@ -432,7 +499,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -432,7 +499,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_Y14P, .mmal_fmt = MMAL_ENCODING_Y14P,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 16 bit */ /* 16 bit */
...@@ -441,7 +509,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -441,7 +509,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_Y16, .mmal_fmt = MMAL_ENCODING_Y16,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 10 bit as 16bpp */ /* 10 bit as 16bpp */
...@@ -450,7 +519,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -450,7 +519,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_Y10, .mmal_fmt = MMAL_ENCODING_Y10,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 12 bit as 16bpp */ /* 12 bit as 16bpp */
...@@ -459,7 +529,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -459,7 +529,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_Y12, .mmal_fmt = MMAL_ENCODING_Y12,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
/* 14 bit as 16bpp */ /* 14 bit as 16bpp */
...@@ -468,7 +539,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = { ...@@ -468,7 +539,8 @@ static const struct bcm2835_isp_fmt supported_formats[] = {
.bytesperline_align = 32, .bytesperline_align = 32,
.mmal_fmt = MMAL_ENCODING_Y14, .mmal_fmt = MMAL_ENCODING_Y14,
.size_multiplier_x2 = 2, .size_multiplier_x2 = 2,
.colorspace = V4L2_COLORSPACE_RAW, .colorspace_mask = V4L2_COLORSPACE_MASK_RAW,
.colorspace_default = V4L2_COLORSPACE_RAW,
.step_size = 2, .step_size = 2,
}, { }, {
.fourcc = V4L2_META_FMT_BCM2835_ISP_STATS, .fourcc = V4L2_META_FMT_BCM2835_ISP_STATS,
......
...@@ -72,6 +72,7 @@ struct bcm2835_isp_q_data { ...@@ -72,6 +72,7 @@ struct bcm2835_isp_q_data {
unsigned int width; unsigned int width;
unsigned int height; unsigned int height;
unsigned int sizeimage; unsigned int sizeimage;
enum v4l2_colorspace colorspace;
const struct bcm2835_isp_fmt *fmt; const struct bcm2835_isp_fmt *fmt;
}; };
...@@ -311,6 +312,43 @@ static void mmal_buffer_cb(struct vchiq_mmal_instance *instance, ...@@ -311,6 +312,43 @@ static void mmal_buffer_cb(struct vchiq_mmal_instance *instance,
complete(&dev->frame_cmplt); complete(&dev->frame_cmplt);
} }
struct colorspace_translation {
enum v4l2_colorspace v4l2_value;
u32 mmal_value;
};
static u32 translate_color_space(enum v4l2_colorspace color_space)
{
static const struct colorspace_translation translations[] = {
{ V4L2_COLORSPACE_DEFAULT, MMAL_COLOR_SPACE_UNKNOWN },
{ V4L2_COLORSPACE_SMPTE170M, MMAL_COLOR_SPACE_ITUR_BT601 },
{ V4L2_COLORSPACE_SMPTE240M, MMAL_COLOR_SPACE_SMPTE240M },
{ V4L2_COLORSPACE_REC709, MMAL_COLOR_SPACE_ITUR_BT709 },
/* V4L2_COLORSPACE_BT878 unavailable */
{ V4L2_COLORSPACE_470_SYSTEM_M, MMAL_COLOR_SPACE_BT470_2_M },
{ V4L2_COLORSPACE_470_SYSTEM_BG, MMAL_COLOR_SPACE_BT470_2_BG },
{ V4L2_COLORSPACE_JPEG, MMAL_COLOR_SPACE_JPEG_JFIF },
/*
* We don't have an encoding for SRGB as such, but VideoCore
* will do the right thing if it gets "unknown".
*/
{ V4L2_COLORSPACE_SRGB, MMAL_COLOR_SPACE_UNKNOWN },
/* V4L2_COLORSPACE_OPRGB unavailable */
/* V4L2_COLORSPACE_BT2020 unavailable */
/* V4L2_COLORSPACE_RAW unavailable */
/* V4L2_COLORSPACE_DCI_P3 unavailable */
};
unsigned int i;
for (i = 0; i < ARRAY_SIZE(translations); i++) {
if (color_space == translations[i].v4l2_value)
return translations[i].mmal_value;
}
return MMAL_COLOR_SPACE_UNKNOWN;
}
static void setup_mmal_port_format(struct bcm2835_isp_node *node, static void setup_mmal_port_format(struct bcm2835_isp_node *node,
struct vchiq_mmal_port *port) struct vchiq_mmal_port *port)
{ {
...@@ -324,6 +362,7 @@ static void setup_mmal_port_format(struct bcm2835_isp_node *node, ...@@ -324,6 +362,7 @@ static void setup_mmal_port_format(struct bcm2835_isp_node *node,
port->es.video.crop.height = q_data->height; port->es.video.crop.height = q_data->height;
port->es.video.crop.x = 0; port->es.video.crop.x = 0;
port->es.video.crop.y = 0; port->es.video.crop.y = 0;
port->es.video.color_space = translate_color_space(q_data->colorspace);
}; };
static int setup_mmal_port(struct bcm2835_isp_node *node) static int setup_mmal_port(struct bcm2835_isp_node *node)
...@@ -827,6 +866,9 @@ static int populate_qdata_fmt(struct v4l2_format *f, ...@@ -827,6 +866,9 @@ static int populate_qdata_fmt(struct v4l2_format *f,
/* All parameters should have been set correctly by try_fmt */ /* All parameters should have been set correctly by try_fmt */
q_data->bytesperline = f->fmt.pix.bytesperline; q_data->bytesperline = f->fmt.pix.bytesperline;
q_data->sizeimage = f->fmt.pix.sizeimage; q_data->sizeimage = f->fmt.pix.sizeimage;
/* We must indicate which of the allowed colour spaces we have. */
q_data->colorspace = f->fmt.pix.colorspace;
} else { } else {
v4l2_dbg(1, debug, &dev->v4l2_dev, v4l2_dbg(1, debug, &dev->v4l2_dev,
"%s: Setting meta format for fmt: %08x, size %u\n", "%s: Setting meta format for fmt: %08x, size %u\n",
...@@ -838,6 +880,9 @@ static int populate_qdata_fmt(struct v4l2_format *f, ...@@ -838,6 +880,9 @@ static int populate_qdata_fmt(struct v4l2_format *f,
q_data->height = 0; q_data->height = 0;
q_data->bytesperline = 0; q_data->bytesperline = 0;
q_data->sizeimage = f->fmt.meta.buffersize; q_data->sizeimage = f->fmt.meta.buffersize;
/* This won't mean anything for metadata, but may as well fill it in. */
q_data->colorspace = V4L2_COLORSPACE_DEFAULT;
} }
v4l2_dbg(1, debug, &dev->v4l2_dev, v4l2_dbg(1, debug, &dev->v4l2_dev,
...@@ -901,7 +946,7 @@ static int bcm2835_isp_node_g_fmt(struct file *file, void *priv, ...@@ -901,7 +946,7 @@ static int bcm2835_isp_node_g_fmt(struct file *file, void *priv,
f->fmt.pix.pixelformat = q_data->fmt->fourcc; f->fmt.pix.pixelformat = q_data->fmt->fourcc;
f->fmt.pix.bytesperline = q_data->bytesperline; f->fmt.pix.bytesperline = q_data->bytesperline;
f->fmt.pix.sizeimage = q_data->sizeimage; f->fmt.pix.sizeimage = q_data->sizeimage;
f->fmt.pix.colorspace = q_data->fmt->colorspace; f->fmt.pix.colorspace = q_data->colorspace;
} }
return 0; return 0;
...@@ -968,13 +1013,29 @@ static int bcm2835_isp_node_try_fmt(struct file *file, void *priv, ...@@ -968,13 +1013,29 @@ static int bcm2835_isp_node_try_fmt(struct file *file, void *priv,
fmt = get_default_format(node); fmt = get_default_format(node);
if (!node_is_stats(node)) { if (!node_is_stats(node)) {
int is_rgb;
f->fmt.pix.width = max(min(f->fmt.pix.width, MAX_DIM), f->fmt.pix.width = max(min(f->fmt.pix.width, MAX_DIM),
MIN_DIM); MIN_DIM);
f->fmt.pix.height = max(min(f->fmt.pix.height, MAX_DIM), f->fmt.pix.height = max(min(f->fmt.pix.height, MAX_DIM),
MIN_DIM); MIN_DIM);
f->fmt.pix.pixelformat = fmt->fourcc; f->fmt.pix.pixelformat = fmt->fourcc;
f->fmt.pix.colorspace = fmt->colorspace;
/*
* Fill in the actual colour space when the requested one was
* not supported. This also catches the case when the "default"
* colour space was requested (as that's never in the mask).
*/
if (!(V4L2_COLORSPACE_MASK(f->fmt.pix.colorspace) & fmt->colorspace_mask))
f->fmt.pix.colorspace = fmt->colorspace_default;
/* In all cases, we only support the defaults for these: */
f->fmt.pix.ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(f->fmt.pix.colorspace);
f->fmt.pix.xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(f->fmt.pix.colorspace);
is_rgb = f->fmt.pix.colorspace == V4L2_COLORSPACE_SRGB;
f->fmt.pix.quantization = V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb, f->fmt.pix.colorspace,
f->fmt.pix.ycbcr_enc);
f->fmt.pix.bytesperline = get_bytesperline(f->fmt.pix.width, f->fmt.pix.bytesperline = get_bytesperline(f->fmt.pix.width,
fmt); fmt);
f->fmt.pix.field = V4L2_FIELD_NONE; f->fmt.pix.field = V4L2_FIELD_NONE;
...@@ -1299,6 +1360,7 @@ static int register_node(struct bcm2835_isp_dev *dev, ...@@ -1299,6 +1360,7 @@ static int register_node(struct bcm2835_isp_dev *dev,
node->q_data.width, node->q_data.width,
node->q_data.height, node->q_data.height,
node->q_data.fmt); node->q_data.fmt);
node->q_data.colorspace = node->q_data.fmt->colorspace_default;
queue->io_modes = VB2_MMAP | VB2_DMABUF; queue->io_modes = VB2_MMAP | VB2_DMABUF;
queue->drv_priv = node; queue->drv_priv = node;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册