1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
From 0e94883c2f4f6164d40d4ea355449ba0864dc4f9 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 19 Dec 2023 11:16:26 +0100
Subject: [PATCH 1/3] libcamera: Add support for IGIG_GBGR_IGIG_GRGB bayer
order DNU
The ov01a1s sensor has the following bayer pattern (4x4 tile repeating):
IGIG
GBGR
IGIG
GRGB
Add support for this PixelFormat to libcamera.
Do Not Upstream, first the include/linux/media-bus-format.h and
include/linux/videodev2.h changes need to land in the upstream kernel.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
include/libcamera/internal/bayer_format.h | 3 ++-
include/linux/drm_fourcc.h | 2 ++
include/linux/media-bus-format.h | 4 +++-
include/linux/videodev2.h | 3 +++
src/libcamera/bayer_format.cpp | 5 +++++
src/libcamera/formats.cpp | 20 ++++++++++++++++++++
src/libcamera/formats.yaml | 5 +++++
src/libcamera/sensor/camera_sensor.cpp | 3 +++
src/libcamera/v4l2_pixelformat.cpp | 4 ++++
src/libcamera/v4l2_subdevice.cpp | 7 +++++++
10 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h
index 5c14bb5f..49b7f417 100644
--- a/include/libcamera/internal/bayer_format.h
+++ b/include/libcamera/internal/bayer_format.h
@@ -27,7 +27,8 @@ public:
GBRG = 1,
GRBG = 2,
RGGB = 3,
- MONO = 4
+ MONO = 4,
+ IGIG_GBGR_IGIG_GRGB = 5,
};
enum class Packing : uint16_t {
diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h
index b4e1a092..070696bc 100644
--- a/include/linux/drm_fourcc.h
+++ b/include/linux/drm_fourcc.h
@@ -447,6 +447,8 @@ extern "C" {
#define DRM_FORMAT_SGRBG10 fourcc_code('B', 'A', '1', '0')
#define DRM_FORMAT_SGBRG10 fourcc_code('G', 'B', '1', '0')
#define DRM_FORMAT_SBGGR10 fourcc_code('B', 'G', '1', '0')
+/* Mixed 10 bit bayer + ir pixel pattern found on Omnivision ov01a1s */
+#define DRM_FORMAT_SIGIG_GBGR_IGIG_GRGB10 fourcc_code('O', 'V', '1', 'S')
/* 12-bit Bayer formats */
#define DRM_FORMAT_SRGGB12 fourcc_code('R', 'G', '1', '2')
diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h
index f05f747e..1b4a65db 100644
--- a/include/linux/media-bus-format.h
+++ b/include/linux/media-bus-format.h
@@ -121,7 +121,7 @@
#define MEDIA_BUS_FMT_YUV16_1X48 0x202a
#define MEDIA_BUS_FMT_UYYVYY16_0_5X48 0x202b
-/* Bayer - next is 0x3021 */
+/* Bayer - next is 0x3022 */
#define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001
#define MEDIA_BUS_FMT_SGBRG8_1X8 0x3013
#define MEDIA_BUS_FMT_SGRBG8_1X8 0x3002
@@ -154,6 +154,8 @@
#define MEDIA_BUS_FMT_SGBRG16_1X16 0x301e
#define MEDIA_BUS_FMT_SGRBG16_1X16 0x301f
#define MEDIA_BUS_FMT_SRGGB16_1X16 0x3020
+/* Mixed bayer + ir pixel pattern found on ov01a1s */
+#define MEDIA_BUS_FMT_SIGIG_GBGR_IGIG_GRGB10_1X10 0x3021
/* JPEG compressed formats - next is 0x4002 */
#define MEDIA_BUS_FMT_JPEG_1X8 0x4001
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 0b5482a0..a51d6755 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -704,6 +704,9 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_SGBRG16 v4l2_fourcc('G', 'B', '1', '6') /* 16 GBGB.. RGRG.. */
#define V4L2_PIX_FMT_SGRBG16 v4l2_fourcc('G', 'R', '1', '6') /* 16 GRGR.. BGBG.. */
#define V4L2_PIX_FMT_SRGGB16 v4l2_fourcc('R', 'G', '1', '6') /* 16 RGRG.. GBGB.. */
+ /* 10bit mixed bayer + ir pixel pattern found on ov01a1s */
+#define V4L2_PIX_FMT_SIGIG_GBGR_IGIG_GRGB10 v4l2_fourcc('O', 'V', '1', 'S') /* unpacked */
+#define V4L2_PIX_FMT_SIGIG_GBGR_IGIG_GRGB10P v4l2_fourcc('O', 'V', '1', 'P') /* packed */
/* HSV formats */
#define V4L2_PIX_FMT_HSV24 v4l2_fourcc('H', 'S', 'V', '3')
diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
index 014f716d..325887a2 100644
--- a/src/libcamera/bayer_format.cpp
+++ b/src/libcamera/bayer_format.cpp
@@ -112,6 +112,8 @@ const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
{ formats::SGRBG10, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) } },
{ { BayerFormat::RGGB, 10, BayerFormat::Packing::None },
{ formats::SRGGB10, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) } },
+ { { BayerFormat::IGIG_GBGR_IGIG_GRGB, 10, BayerFormat::Packing::None },
+ { formats::SIGIG_GBGR_IGIG_GRGB10, V4L2PixelFormat(V4L2_PIX_FMT_SIGIG_GBGR_IGIG_GRGB10) } },
{ { BayerFormat::BGGR, 10, BayerFormat::Packing::CSI2 },
{ formats::SBGGR10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) } },
{ { BayerFormat::GBRG, 10, BayerFormat::Packing::CSI2 },
@@ -120,6 +122,8 @@ const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{
{ formats::SGRBG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) } },
{ { BayerFormat::RGGB, 10, BayerFormat::Packing::CSI2 },
{ formats::SRGGB10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) } },
+ { { BayerFormat::IGIG_GBGR_IGIG_GRGB, 10, BayerFormat::Packing::CSI2 },
+ { formats::SIGIG_GBGR_IGIG_GRGB10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SIGIG_GBGR_IGIG_GRGB10P) } },
{ { BayerFormat::BGGR, 10, BayerFormat::Packing::IPU3 },
{ formats::SBGGR10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) } },
{ { BayerFormat::GBRG, 10, BayerFormat::Packing::IPU3 },
@@ -211,6 +215,7 @@ const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{
{ MEDIA_BUS_FMT_SGBRG10_1X10, { BayerFormat::GBRG, 10, BayerFormat::Packing::None } },
{ MEDIA_BUS_FMT_SGRBG10_1X10, { BayerFormat::GRBG, 10, BayerFormat::Packing::None } },
{ MEDIA_BUS_FMT_SRGGB10_1X10, { BayerFormat::RGGB, 10, BayerFormat::Packing::None } },
+ { MEDIA_BUS_FMT_SIGIG_GBGR_IGIG_GRGB10_1X10, { BayerFormat::IGIG_GBGR_IGIG_GRGB, 10, BayerFormat::Packing::None } },
{ MEDIA_BUS_FMT_SBGGR12_1X12, { BayerFormat::BGGR, 12, BayerFormat::Packing::None } },
{ MEDIA_BUS_FMT_SGBRG12_1X12, { BayerFormat::GBRG, 12, BayerFormat::Packing::None } },
{ MEDIA_BUS_FMT_SGRBG12_1X12, { BayerFormat::GRBG, 12, BayerFormat::Packing::None } },
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index cf41f2c2..13ac3253 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -639,6 +639,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
.pixelsPerGroup = 2,
.planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
} },
+ { formats::SIGIG_GBGR_IGIG_GRGB10, {
+ .name = "SIGIG_GBGR_IGIG_GRGB10",
+ .format = formats::SIGIG_GBGR_IGIG_GRGB10,
+ .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SIGIG_GBGR_IGIG_GRGB10), },
+ .bitsPerPixel = 10,
+ .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+ .packed = false,
+ .pixelsPerGroup = 4,
+ .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
+ } },
{ formats::SBGGR10_CSI2P, {
.name = "SBGGR10_CSI2P",
.format = formats::SBGGR10_CSI2P,
@@ -679,6 +689,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
.pixelsPerGroup = 4,
.planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }},
} },
+ { formats::SIGIG_GBGR_IGIG_GRGB10_CSI2P, {
+ .name = "SIGIG_GBGR_IGIG_GRGB10_CSI2P",
+ .format = formats::SIGIG_GBGR_IGIG_GRGB10_CSI2P,
+ .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SIGIG_GBGR_IGIG_GRGB10P), },
+ .bitsPerPixel = 10,
+ .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+ .packed = true,
+ .pixelsPerGroup = 4,
+ .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }},
+ } },
{ formats::SBGGR12, {
.name = "SBGGR12",
.format = formats::SBGGR12,
diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
index fe027a7c..394f980c 100644
--- a/src/libcamera/formats.yaml
+++ b/src/libcamera/formats.yaml
@@ -107,6 +107,8 @@ formats:
fourcc: DRM_FORMAT_SGBRG10
- SBGGR10:
fourcc: DRM_FORMAT_SBGGR10
+ - SIGIG_GBGR_IGIG_GRGB10:
+ fourcc: DRM_FORMAT_SIGIG_GBGR_IGIG_GRGB10
- SRGGB12:
fourcc: DRM_FORMAT_SRGGB12
@@ -151,6 +153,9 @@ formats:
- SBGGR10_CSI2P:
fourcc: DRM_FORMAT_SBGGR10
mod: MIPI_FORMAT_MOD_CSI2_PACKED
+ - SIGIG_GBGR_IGIG_GRGB10_CSI2P:
+ fourcc: DRM_FORMAT_SIGIG_GBGR_IGIG_GRGB10
+ mod: MIPI_FORMAT_MOD_CSI2_PACKED
- SRGGB12_CSI2P:
fourcc: DRM_FORMAT_SRGGB12
diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp
index c6d7f801..77c396b9 100644
--- a/src/libcamera/sensor/camera_sensor.cpp
+++ b/src/libcamera/sensor/camera_sensor.cpp
@@ -526,6 +526,9 @@ int CameraSensor::initProperties()
case BayerFormat::MONO:
cfa = properties::draft::MONO;
break;
+ case BayerFormat::IGIG_GBGR_IGIG_GRGB:
+ cfa = properties::draft::RGB;
+ break;
}
properties_.set(properties::draft::ColorFilterArrangement, cfa);
diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
index 70568335..a2fbd644 100644
--- a/src/libcamera/v4l2_pixelformat.cpp
+++ b/src/libcamera/v4l2_pixelformat.cpp
@@ -159,6 +159,8 @@ const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
{ formats::SGRBG10, "10-bit Bayer GRGR/BGBG" } },
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10),
{ formats::SRGGB10, "10-bit Bayer RGRG/GBGB" } },
+ { V4L2PixelFormat(V4L2_PIX_FMT_SIGIG_GBGR_IGIG_GRGB10),
+ { formats::SIGIG_GBGR_IGIG_GRGB10, "10-bit Bayer GRGB/IGIG/GBGR/IGIG" } },
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P),
{ formats::SBGGR10_CSI2P, "10-bit Bayer BGBG/GRGR Packed" } },
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P),
@@ -167,6 +169,8 @@ const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
{ formats::SGRBG10_CSI2P, "10-bit Bayer GRGR/BGBG Packed" } },
{ V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P),
{ formats::SRGGB10_CSI2P, "10-bit Bayer RGRG/GBGB Packed" } },
+ { V4L2PixelFormat(V4L2_PIX_FMT_SIGIG_GBGR_IGIG_GRGB10P),
+ { formats::SIGIG_GBGR_IGIG_GRGB10_CSI2P, "10-bit Bayer GRGB/IGIG/GBGR/IGIG Packed" } },
{ V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12),
{ formats::SBGGR12, "12-bit Bayer BGBG/GRGR" } },
{ V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12),
diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index 6da77775..0ba8c0de 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -595,6 +595,13 @@ const std::map<uint32_t, MediaBusFormatInfo> mediaBusFormatInfo{
.bitsPerPixel = 10,
.colourEncoding = PixelFormatInfo::ColourEncodingRAW,
} },
+ { MEDIA_BUS_FMT_SIGIG_GBGR_IGIG_GRGB10_1X10, {
+ .name = "SIGIG_GBGR_IGIG_GRGB10_1X10",
+ .code = MEDIA_BUS_FMT_SIGIG_GBGR_IGIG_GRGB10_1X10,
+ .type = MediaBusFormatInfo::Type::Image,
+ .bitsPerPixel = 10,
+ .colourEncoding = PixelFormatInfo::ColourEncodingRAW,
+ } },
{ MEDIA_BUS_FMT_SBGGR12_1X12, {
.name = "SBGGR12_1X12",
.code = MEDIA_BUS_FMT_SBGGR12_1X12,
--
2.45.2
|