firmware-utils: bump to git HEAD
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0844-media-v4l-Add-14-bit-raw-bayer-pixel-formats.patch
1 From 59a535539277240c4bdbb9c21bc07c8b586b2c3a Mon Sep 17 00:00:00 2001
2 From: Sakari Ailus <sakari.ailus@linux.intel.com>
3 Date: Mon, 24 Feb 2020 18:52:20 +0100
4 Subject: [PATCH] media: v4l: Add 14-bit raw bayer pixel formats
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Commit d12127ed0e18192491c2508caae45bb19c2f8fdd upstream.
10
11 The formats added by this patch are:
12
13 V4L2_PIX_FMT_SBGGR14
14 V4L2_PIX_FMT_SGBRG14
15 V4L2_PIX_FMT_SGRBG14
16 V4L2_PIX_FMT_SRGGB14
17
18 Signed-off-by: Jouni Ukkonen <jouni.ukkonen@intel.com>
19 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
20 [dg@emlix.com: rebased onto current media_tree]
21 Signed-off-by: Daniel Glöckner <dg@emlix.com>
22 Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
23 Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
24 ---
25 Documentation/media/uapi/v4l/pixfmt-bayer.rst | 1 +
26 .../media/uapi/v4l/pixfmt-srggb14.rst | 82 +++++++++++++++++++
27 drivers/media/v4l2-core/v4l2-ioctl.c | 4 +
28 include/uapi/linux/videodev2.h | 4 +
29 4 files changed, 91 insertions(+)
30 create mode 100644 Documentation/media/uapi/v4l/pixfmt-srggb14.rst
31
32 --- a/Documentation/media/uapi/v4l/pixfmt-bayer.rst
33 +++ b/Documentation/media/uapi/v4l/pixfmt-bayer.rst
34 @@ -34,5 +34,6 @@ orders. See also `the Wikipedia article
35 pixfmt-srggb10-ipu3
36 pixfmt-srggb12
37 pixfmt-srggb12p
38 + pixfmt-srggb14
39 pixfmt-srggb14p
40 pixfmt-srggb16
41 --- /dev/null
42 +++ b/Documentation/media/uapi/v4l/pixfmt-srggb14.rst
43 @@ -0,0 +1,82 @@
44 +.. Permission is granted to copy, distribute and/or modify this
45 +.. document under the terms of the GNU Free Documentation License,
46 +.. Version 1.1 or any later version published by the Free Software
47 +.. Foundation, with no Invariant Sections, no Front-Cover Texts
48 +.. and no Back-Cover Texts. A copy of the license is included at
49 +.. Documentation/media/uapi/fdl-appendix.rst.
50 +..
51 +.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
52 +
53 +.. _V4L2-PIX-FMT-SRGGB14:
54 +.. _v4l2-pix-fmt-sbggr14:
55 +.. _v4l2-pix-fmt-sgbrg14:
56 +.. _v4l2-pix-fmt-sgrbg14:
57 +
58 +
59 +***************************************************************************************************************************
60 +V4L2_PIX_FMT_SRGGB14 ('RG14'), V4L2_PIX_FMT_SGRBG14 ('GR14'), V4L2_PIX_FMT_SGBRG14 ('GB14'), V4L2_PIX_FMT_SBGGR14 ('BG14'),
61 +***************************************************************************************************************************
62 +
63 +
64 +14-bit Bayer formats expanded to 16 bits
65 +
66 +
67 +Description
68 +===========
69 +
70 +These four pixel formats are raw sRGB / Bayer formats with 14 bits per
71 +colour. Each sample is stored in a 16-bit word, with two unused high
72 +bits filled with zeros. Each n-pixel row contains n/2 green samples
73 +and n/2 blue or red samples, with alternating red and blue rows. Bytes
74 +are stored in memory in little endian order. They are conventionally
75 +described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an
76 +example of a small V4L2_PIX_FMT_SBGGR14 image:
77 +
78 +**Byte Order.**
79 +Each cell is one byte, the two most significant bits in the high bytes are
80 +zero.
81 +
82 +
83 +
84 +.. flat-table::
85 + :header-rows: 0
86 + :stub-columns: 0
87 + :widths: 2 1 1 1 1 1 1 1 1
88 +
89 +
90 + * - start + 0:
91 + - B\ :sub:`00low`
92 + - B\ :sub:`00high`
93 + - G\ :sub:`01low`
94 + - G\ :sub:`01high`
95 + - B\ :sub:`02low`
96 + - B\ :sub:`02high`
97 + - G\ :sub:`03low`
98 + - G\ :sub:`03high`
99 + * - start + 8:
100 + - G\ :sub:`10low`
101 + - G\ :sub:`10high`
102 + - R\ :sub:`11low`
103 + - R\ :sub:`11high`
104 + - G\ :sub:`12low`
105 + - G\ :sub:`12high`
106 + - R\ :sub:`13low`
107 + - R\ :sub:`13high`
108 + * - start + 16:
109 + - B\ :sub:`20low`
110 + - B\ :sub:`20high`
111 + - G\ :sub:`21low`
112 + - G\ :sub:`21high`
113 + - B\ :sub:`22low`
114 + - B\ :sub:`22high`
115 + - G\ :sub:`23low`
116 + - G\ :sub:`23high`
117 + * - start + 24:
118 + - G\ :sub:`30low`
119 + - G\ :sub:`30high`
120 + - R\ :sub:`31low`
121 + - R\ :sub:`31high`
122 + - G\ :sub:`32low`
123 + - G\ :sub:`32high`
124 + - R\ :sub:`33low`
125 + - R\ :sub:`33high`
126 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
127 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
128 @@ -1298,6 +1298,10 @@ static void v4l_fill_fmtdesc(struct v4l2
129 case V4L2_PIX_FMT_SGBRG12P: descr = "12-bit Bayer GBGB/RGRG Packed"; break;
130 case V4L2_PIX_FMT_SGRBG12P: descr = "12-bit Bayer GRGR/BGBG Packed"; break;
131 case V4L2_PIX_FMT_SRGGB12P: descr = "12-bit Bayer RGRG/GBGB Packed"; break;
132 + case V4L2_PIX_FMT_SBGGR14: descr = "14-bit Bayer BGBG/GRGR"; break;
133 + case V4L2_PIX_FMT_SGBRG14: descr = "14-bit Bayer GBGB/RGRG"; break;
134 + case V4L2_PIX_FMT_SGRBG14: descr = "14-bit Bayer GRGR/BGBG"; break;
135 + case V4L2_PIX_FMT_SRGGB14: descr = "14-bit Bayer RGRG/GBGB"; break;
136 case V4L2_PIX_FMT_SBGGR14P: descr = "14-bit Bayer BGBG/GRGR Packed"; break;
137 case V4L2_PIX_FMT_SGBRG14P: descr = "14-bit Bayer GBGB/RGRG Packed"; break;
138 case V4L2_PIX_FMT_SGRBG14P: descr = "14-bit Bayer GRGR/BGBG Packed"; break;
139 --- a/include/uapi/linux/videodev2.h
140 +++ b/include/uapi/linux/videodev2.h
141 @@ -666,6 +666,10 @@ struct v4l2_pix_format {
142 #define V4L2_PIX_FMT_SGBRG12P v4l2_fourcc('p', 'G', 'C', 'C')
143 #define V4L2_PIX_FMT_SGRBG12P v4l2_fourcc('p', 'g', 'C', 'C')
144 #define V4L2_PIX_FMT_SRGGB12P v4l2_fourcc('p', 'R', 'C', 'C')
145 +#define V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4') /* 14 BGBG.. GRGR.. */
146 +#define V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4') /* 14 GBGB.. RGRG.. */
147 +#define V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('G', 'R', '1', '4') /* 14 GRGR.. BGBG.. */
148 +#define V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4') /* 14 RGRG.. GBGB.. */
149 /* 14bit raw bayer packed, 7 bytes for every 4 pixels */
150 #define V4L2_PIX_FMT_SBGGR14P v4l2_fourcc('p', 'B', 'E', 'E')
151 #define V4L2_PIX_FMT_SGBRG14P v4l2_fourcc('p', 'G', 'E', 'E')