Content-Security-Policy: default-src 'none'
Content-Type: text/plain; charset=UTF-8
Content-Length: 3588
Content-Disposition: inline; filename="950-0278-media-Add-a-pixel-format-for-MIPI-packed-12bit-luma-.patch"
Last-Modified: Sun, 04 Aug 2024 11:29:26 GMT
Expires: Wed, 02 Aug 2034 11:29:26 GMT
ETag: "576e20a58fb0e7b13c4b306d75ba31a3d2c2d3ce"

From 85e4a24a7f8fd96cc765c038bbae601ca69daa39 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Thu, 7 May 2020 16:59:03 +0100
Subject: [PATCH] media: Add a pixel format for MIPI packed 12bit luma
 only.

This is the format used by monochrome 12bit image sensors.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 .../userspace-api/media/v4l/pixfmt-y12p.rst   | 45 +++++++++++++++++++
 .../userspace-api/media/v4l/yuv-formats.rst   |  1 +
 drivers/media/v4l2-core/v4l2-ioctl.c          |  1 +
 include/uapi/linux/videodev2.h                |  1 +
 4 files changed, 48 insertions(+)
 create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-y12p.rst

--- /dev/null
+++ b/Documentation/userspace-api/media/v4l/pixfmt-y12p.rst
@@ -0,0 +1,45 @@
+.. Permission is granted to copy, distribute and/or modify this
+.. document under the terms of the GNU Free Documentation License,
+.. Version 1.1 or any later version published by the Free Software
+.. Foundation, with no Invariant Sections, no Front-Cover Texts
+.. and no Back-Cover Texts. A copy of the license is included at
+.. Documentation/media/uapi/fdl-appendix.rst.
+..
+.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
+
+.. _V4L2-PIX-FMT-Y12P:
+
+******************************
+V4L2_PIX_FMT_Y12P ('Y12P')
+******************************
+
+Grey-scale image as a MIPI RAW12 packed array
+
+
+Description
+===========
+
+This is a packed grey-scale image format with a depth of 12 bits per
+pixel. Two consecutive pixels are packed into 3 bytes. The first 2 bytes
+contain the 8 high order bits of the pixels, and the 3rd byte contains the 4
+least significants bits of each pixel, in the same order.
+
+**Byte Order.**
+Each cell is one byte.
+
+.. tabularcolumns:: |p{2.2cm}|p{1.2cm}|p{1.2cm}|p{3.1cm}|
+
+
+.. flat-table::
+    :header-rows:  0
+    :stub-columns: 0
+    :widths:       2 1 1 1
+
+
+    -  -  start + 0:
+       -  Y'\ :sub:`00high`
+       -  Y'\ :sub:`01high`
+       -  Y'\ :sub:`01low`\ (bits 7--4)
+
+          Y'\ :sub:`00low`\ (bits 3--0)
+
--- a/Documentation/userspace-api/media/v4l/yuv-formats.rst
+++ b/Documentation/userspace-api/media/v4l/yuv-formats.rst
@@ -28,6 +28,7 @@ to brightness information.
     pixfmt-grey
     pixfmt-y10
     pixfmt-y12
+    pixfmt-y12p
     pixfmt-y14
     pixfmt-y10b
     pixfmt-y10p
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1301,6 +1301,7 @@ static void v4l_fill_fmtdesc(struct v4l2
 	case V4L2_PIX_FMT_Y16_BE:	descr = "16-bit Greyscale BE"; break;
 	case V4L2_PIX_FMT_Y10BPACK:	descr = "10-bit Greyscale (Packed)"; break;
 	case V4L2_PIX_FMT_Y10P:		descr = "10-bit Greyscale (MIPI Packed)"; break;
+	case V4L2_PIX_FMT_Y12P:		descr = "12-bit Greyscale (MIPI Packed)"; break;
 	case V4L2_PIX_FMT_Y8I:		descr = "Interleaved 8-bit Greyscale"; break;
 	case V4L2_PIX_FMT_Y12I:		descr = "Interleaved 12-bit Greyscale"; break;
 	case V4L2_PIX_FMT_Z16:		descr = "16-bit Depth"; break;
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -580,6 +580,7 @@ struct v4l2_pix_format {
 /* Grey bit-packed formats */
 #define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */
 #define V4L2_PIX_FMT_Y10P    v4l2_fourcc('Y', '1', '0', 'P') /* 10  Greyscale, MIPI RAW10 packed */
+#define V4L2_PIX_FMT_Y12P    v4l2_fourcc('Y', '1', '2', 'P') /* 12  Greyscale, MIPI RAW12 packed */
 
 /* Palette formats */
 #define V4L2_PIX_FMT_PAL8    v4l2_fourcc('P', 'A', 'L', '8') /*  8  8-bit palette */
7e065d17c7cbd406'>root</a>/<a href='/cgit.cgi/openwrt/upstream/tree/target?id=e5cec69484274ab6161d90397e065d17c7cbd406'>target</a>/<a href='/cgit.cgi/openwrt/upstream/tree/target/linux?id=e5cec69484274ab6161d90397e065d17c7cbd406'>linux</a>/<a href='/cgit.cgi/openwrt/upstream/tree/target/linux/bcm27xx?id=e5cec69484274ab6161d90397e065d17c7cbd406'>bcm27xx</a>/<a href='/cgit.cgi/openwrt/upstream/tree/target/linux/bcm27xx/patches-5.10?id=e5cec69484274ab6161d90397e065d17c7cbd406'>patches-5.10</a>/<a href='/cgit.cgi/openwrt/upstream/tree/target/linux/bcm27xx/patches-5.10/950-0235-media-i2c-ov5647-Neither-analogue-gain-nor-exposure-.patch?id=e5cec69484274ab6161d90397e065d17c7cbd406'>950-0235-media-i2c-ov5647-Neither-analogue-gain-nor-exposure-.patch</a></div><div class='content'>blob: b1505e7d06bd33a9c88ed3745c956334420066e8 (<a href='/cgit.cgi/openwrt/upstream/plain/target/linux/bcm27xx/patches-5.10/950-0235-media-i2c-ov5647-Neither-analogue-gain-nor-exposure-.patch?id=e5cec69484274ab6161d90397e065d17c7cbd406'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
<a id='n2' href='#n2'>2</a>
<a id='n3' href='#n3'>3</a>
<a id='n4' href='#n4'>4</a>
<a id='n5' href='#n5'>5</a>
<a id='n6' href='#n6'>6</a>
<a id='n7' href='#n7'>7</a>
<a id='n8' href='#n8'>8</a>
<a id='n9' href='#n9'>9</a>
<a id='n10' href='#n10'>10</a>
<a id='n11' href='#n11'>11</a>
<a id='n12' href='#n12'>12</a>
<a id='n13' href='#n13'>13</a>
<a id='n14' href='#n14'>14</a>
<a id='n15' href='#n15'>15</a>
<a id='n16' href='#n16'>16</a>
<a id='n17' href='#n17'>17</a>
<a id='n18' href='#n18'>18</a>
<a id='n19' href='#n19'>19</a>
<a id='n20' href='#n20'>20</a>
<a id='n21' href='#n21'>21</a>
<a id='n22' href='#n22'>22</a>
<a id='n23' href='#n23'>23</a>
<a id='n24' href='#n24'>24</a>
<a id='n25' href='#n25'>25</a>
<a id='n26' href='#n26'>26</a>
<a id='n27' href='#n27'>27</a>
<a id='n28' href='#n28'>28</a>
<a id='n29' href='#n29'>29</a>
<a id='n30' href='#n30'>30</a>
<a id='n31' href='#n31'>31</a>
<a id='n32' href='#n32'>32</a>
<a id='n33' href='#n33'>33</a>
<a id='n34' href='#n34'>34</a>
<a id='n35' href='#n35'>35</a>
<a id='n36' href='#n36'>36</a>
<a id='n37' href='#n37'>37</a>
<a id='n38' href='#n38'>38</a>
<a id='n39' href='#n39'>39</a>
<a id='n40' href='#n40'>40</a>
<a id='n41' href='#n41'>41</a>
<a id='n42' href='#n42'>42</a>
<a id='n43' href='#n43'>43</a>
<a id='n44' href='#n44'>44</a>
<a id='n45' href='#n45'>45</a>
<a id='n46' href='#n46'>46</a>
<a id='n47' href='#n47'>47</a>
<a id='n48' href='#n48'>48</a>
<a id='n49' href='#n49'>49</a>
<a id='n50' href='#n50'>50</a>
<a id='n51' href='#n51'>51</a>
<a id='n52' href='#n52'>52</a>
<a id='n53' href='#n53'>53</a>
<a id='n54' href='#n54'>54</a>
<a id='n55' href='#n55'>55</a>
<a id='n56' href='#n56'>56</a>
<a id='n57' href='#n57'>57</a>
<a id='n58' href='#n58'>58</a>
</pre></td>
<td class='lines'><pre><code><style>pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span>From 05a1c88d9b8dd344edfce3eaa00a3cac866cf3ad Mon Sep 17 00:00:00 2001
From: Dave Stevenson &lt;dave.stevenson@raspberrypi.com&gt;
Date: Wed, 29 Apr 2020 21:47:25 +0100
Subject: [PATCH] media: i2c: ov5647: Neither analogue gain nor
 exposure need EXECUTE_ON_WRITE

The controls for analogue gain and exposure were defined with
V4L2_CTRL_FLAG_EXECUTE_ON_WRITE. This is not required as we only need
to send changes to the sensor.

Signed-off-by: Dave Stevenson &lt;dave.stevenson@raspberrypi.com&gt;
<span class="gd">---</span>
 drivers/media/i2c/ov5647.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

<span class="gd">--- a/drivers/media/i2c/ov5647.c</span>
<span class="gi">+++ b/drivers/media/i2c/ov5647.c</span>
<span class="gu">@@ -1472,7 +1472,6 @@ static int ov5647_probe(struct i2c_clien</span>
 	struct v4l2_subdev *sd;
 	struct device_node *np = client-&gt;dev.of_node;
 	u32 xclk_freq;
<span class="gd">-	struct v4l2_ctrl *ctrl;</span>
 	int hblank;
 
 	sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL);
<span class="gu">@@ -1525,20 +1524,18 @@ static int ov5647_probe(struct i2c_clien</span>
 			       V4L2_EXPOSURE_MANUAL,  /* max */
 			       0,                     /* skip_mask */
 			       V4L2_EXPOSURE_MANUAL); /* default */
<span class="gd">-	ctrl = v4l2_ctrl_new_std(&amp;sensor-&gt;ctrls, &amp;ov5647_ctrl_ops,</span>
<span class="gd">-				 V4L2_CID_EXPOSURE,</span>
<span class="gd">-				 4,     /* min lines */</span>
<span class="gd">-				 65535, /* max lines (4+8+4 bits)*/</span>
<span class="gd">-				 1,     /* step */</span>
<span class="gd">-				 1000); /* default number of lines */</span>
<span class="gd">-	ctrl-&gt;flags |= V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;</span>
<span class="gd">-	ctrl = v4l2_ctrl_new_std(&amp;sensor-&gt;ctrls, &amp;ov5647_ctrl_ops,</span>
<span class="gd">-				 V4L2_CID_ANALOGUE_GAIN,</span>
<span class="gd">-				 16,   /* min, 16 = 1.0x */</span>
<span class="gd">-				 1023, /* max (10 bits) */</span>
<span class="gd">-				 1,    /* step */</span>
<span class="gd">-				 32);  /* default, 32 = 2.0x */</span>
<span class="gd">-	ctrl-&gt;flags |= V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;</span>
<span class="gi">+	v4l2_ctrl_new_std(&amp;sensor-&gt;ctrls, &amp;ov5647_ctrl_ops,</span>
<span class="gi">+			  V4L2_CID_EXPOSURE,</span>
<span class="gi">+			  4,     /* min lines */</span>
<span class="gi">+			  65535, /* max lines (4+8+4 bits)*/</span>
<span class="gi">+			  1,     /* step */</span>
<span class="gi">+			  1000); /* default number of lines */</span>
<span class="gi">+	v4l2_ctrl_new_std(&amp;sensor-&gt;ctrls, &amp;ov5647_ctrl_ops,</span>
<span class="gi">+			  V4L2_CID_ANALOGUE_GAIN,</span>
<span class="gi">+			  16,   /* min, 16 = 1.0x */</span>
<span class="gi">+			  1023, /* max (10 bits) */</span>
<span class="gi">+			  1,    /* step */</span>
<span class="gi">+			  32);  /* default, 32 = 2.0x */</span>
 
 	/* Set the default mode before we init the subdev */
 	sensor-&gt;mode = OV5647_DEFAULT_MODE;
</pre></div>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.25.1</a>) at 2024-08-04 11:29:26 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
