576e20a58fb0e7b13c4b306d75ba31a3d2c2d3ce
[openwrt/staging/robimarko.git] /
1 From 85e4a24a7f8fd96cc765c038bbae601ca69daa39 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 7 May 2020 16:59:03 +0100
4 Subject: [PATCH] media: Add a pixel format for MIPI packed 12bit luma
5 only.
6
7 This is the format used by monochrome 12bit image sensors.
8
9 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
10 ---
11 .../userspace-api/media/v4l/pixfmt-y12p.rst | 45 +++++++++++++++++++
12 .../userspace-api/media/v4l/yuv-formats.rst | 1 +
13 drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
14 include/uapi/linux/videodev2.h | 1 +
15 4 files changed, 48 insertions(+)
16 create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-y12p.rst
17
18 --- /dev/null
19 +++ b/Documentation/userspace-api/media/v4l/pixfmt-y12p.rst
20 @@ -0,0 +1,45 @@
21 +.. Permission is granted to copy, distribute and/or modify this
22 +.. document under the terms of the GNU Free Documentation License,
23 +.. Version 1.1 or any later version published by the Free Software
24 +.. Foundation, with no Invariant Sections, no Front-Cover Texts
25 +.. and no Back-Cover Texts. A copy of the license is included at
26 +.. Documentation/media/uapi/fdl-appendix.rst.
27 +..
28 +.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
29 +
30 +.. _V4L2-PIX-FMT-Y12P:
31 +
32 +******************************
33 +V4L2_PIX_FMT_Y12P ('Y12P')
34 +******************************
35 +
36 +Grey-scale image as a MIPI RAW12 packed array
37 +
38 +
39 +Description
40 +===========
41 +
42 +This is a packed grey-scale image format with a depth of 12 bits per
43 +pixel. Two consecutive pixels are packed into 3 bytes. The first 2 bytes
44 +contain the 8 high order bits of the pixels, and the 3rd byte contains the 4
45 +least significants bits of each pixel, in the same order.
46 +
47 +**Byte Order.**
48 +Each cell is one byte.
49 +
50 +.. tabularcolumns:: |p{2.2cm}|p{1.2cm}|p{1.2cm}|p{3.1cm}|
51 +
52 +
53 +.. flat-table::
54 + :header-rows: 0
55 + :stub-columns: 0
56 + :widths: 2 1 1 1
57 +
58 +
59 + - - start + 0:
60 + - Y'\ :sub:`00high`
61 + - Y'\ :sub:`01high`
62 + - Y'\ :sub:`01low`\ (bits 7--4)
63 +
64 + Y'\ :sub:`00low`\ (bits 3--0)
65 +
66 --- a/Documentation/userspace-api/media/v4l/yuv-formats.rst
67 +++ b/Documentation/userspace-api/media/v4l/yuv-formats.rst
68 @@ -28,6 +28,7 @@ to brightness information.
69 pixfmt-grey
70 pixfmt-y10
71 pixfmt-y12
72 + pixfmt-y12p
73 pixfmt-y14
74 pixfmt-y10b
75 pixfmt-y10p
76 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
77 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
78 @@ -1301,6 +1301,7 @@ static void v4l_fill_fmtdesc(struct v4l2
79 case V4L2_PIX_FMT_Y16_BE: descr = "16-bit Greyscale BE"; break;
80 case V4L2_PIX_FMT_Y10BPACK: descr = "10-bit Greyscale (Packed)"; break;
81 case V4L2_PIX_FMT_Y10P: descr = "10-bit Greyscale (MIPI Packed)"; break;
82 + case V4L2_PIX_FMT_Y12P: descr = "12-bit Greyscale (MIPI Packed)"; break;
83 case V4L2_PIX_FMT_Y8I: descr = "Interleaved 8-bit Greyscale"; break;
84 case V4L2_PIX_FMT_Y12I: descr = "Interleaved 12-bit Greyscale"; break;
85 case V4L2_PIX_FMT_Z16: descr = "16-bit Depth"; break;
86 --- a/include/uapi/linux/videodev2.h
87 +++ b/include/uapi/linux/videodev2.h
88 @@ -580,6 +580,7 @@ struct v4l2_pix_format {
89 /* Grey bit-packed formats */
90 #define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B') /* 10 Greyscale bit-packed */
91 #define V4L2_PIX_FMT_Y10P v4l2_fourcc('Y', '1', '0', 'P') /* 10 Greyscale, MIPI RAW10 packed */
92 +#define V4L2_PIX_FMT_Y12P v4l2_fourcc('Y', '1', '2', 'P') /* 12 Greyscale, MIPI RAW12 packed */
93
94 /* Palette formats */
95 #define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */