bcm27xx: switch to kernel v6.1
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0219-media-uapi-v4l2-core-Add-ISP-statistics-output-V4L2-.patch
1 From 6b4ccbece097b456c2fb910d7e74ac5e848dc699 Mon Sep 17 00:00:00 2001
2 From: Naushir Patuck <naush@raspberrypi.com>
3 Date: Thu, 23 Apr 2020 10:20:26 +0100
4 Subject: [PATCH] media: uapi: v4l2-core: Add ISP statistics output
5 V4L2 fourcc type
6
7 Add V4L2_META_FMT_BCM2835_ISP_STATS V4L2 format type.
8
9 This new format will be used by the BCM2835 ISP device to return
10 out ISP statistics for 3A.
11
12 Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
13 ---
14 .../userspace-api/media/v4l/meta-formats.rst | 1 +
15 .../v4l/pixfmt-meta-bcm2835-isp-stats.rst | 41 +++++++++++++++++++
16 drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
17 include/uapi/linux/videodev2.h | 1 +
18 4 files changed, 44 insertions(+)
19 create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-meta-bcm2835-isp-stats.rst
20
21 --- a/Documentation/userspace-api/media/v4l/meta-formats.rst
22 +++ b/Documentation/userspace-api/media/v4l/meta-formats.rst
23 @@ -12,6 +12,7 @@ These formats are used for the :ref:`met
24 .. toctree::
25 :maxdepth: 1
26
27 + pixfmt-meta-bcm2835-isp-stats
28 pixfmt-meta-d4xx
29 pixfmt-meta-intel-ipu3
30 pixfmt-meta-rkisp1
31 --- /dev/null
32 +++ b/Documentation/userspace-api/media/v4l/pixfmt-meta-bcm2835-isp-stats.rst
33 @@ -0,0 +1,41 @@
34 +.. Permission is granted to copy, distribute and/or modify this
35 +.. document under the terms of the GNU Free Documentation License,
36 +.. Version 1.1 or any later version published by the Free Software
37 +.. Foundation, with no Invariant Sections, no Front-Cover Texts
38 +.. and no Back-Cover Texts. A copy of the license is included at
39 +.. Documentation/media/uapi/fdl-appendix.rst.
40 +..
41 +.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
42 +
43 +.. _v4l2-meta-fmt-bcm2835-isp-stats:
44 +
45 +*****************************************
46 +V4L2_META_FMT_BCM2835_ISP_STATS ('BSTA')
47 +*****************************************
48 +
49 +BCM2835 ISP Statistics
50 +
51 +Description
52 +===========
53 +
54 +The BCM2835 ISP hardware calculate image statistics for an input Bayer frame.
55 +These statistics are obtained from the "bcm2835-isp0-capture3" device node
56 +using the :c:type:`v4l2_meta_format` interface. They are formatted as described
57 +by the :c:type:`bcm2835_isp_stats` structure below.
58 +
59 +.. code-block:: c
60 +
61 + #define DEFAULT_AWB_REGIONS_X 16
62 + #define DEFAULT_AWB_REGIONS_Y 12
63 +
64 + #define NUM_HISTOGRAMS 2
65 + #define NUM_HISTOGRAM_BINS 128
66 + #define AWB_REGIONS (DEFAULT_AWB_REGIONS_X * DEFAULT_AWB_REGIONS_Y)
67 + #define FLOATING_REGIONS 16
68 + #define AGC_REGIONS 16
69 + #define FOCUS_REGIONS 12
70 +
71 +.. kernel-doc:: include/uapi/linux/bcm2835-isp.h
72 + :functions: bcm2835_isp_stats_hist bcm2835_isp_stats_region
73 + bcm2835_isp_stats_focus bcm2835_isp_stats
74 +
75 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
76 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
77 @@ -1390,6 +1390,7 @@ static void v4l_fill_fmtdesc(struct v4l2
78 case V4L2_META_FMT_RK_ISP1_PARAMS: descr = "Rockchip ISP1 3A Parameters"; break;
79 case V4L2_META_FMT_RK_ISP1_STAT_3A: descr = "Rockchip ISP1 3A Statistics"; break;
80 case V4L2_META_FMT_SENSOR_DATA: descr = "Sensor Ancillary Metadata"; break;
81 + case V4L2_META_FMT_BCM2835_ISP_STATS: descr = "BCM2835 ISP Image Statistics"; break;
82
83 default:
84 /* Compressed formats */
85 --- a/include/uapi/linux/videodev2.h
86 +++ b/include/uapi/linux/videodev2.h
87 @@ -776,6 +776,7 @@ struct v4l2_pix_format {
88 #define V4L2_META_FMT_D4XX v4l2_fourcc('D', '4', 'X', 'X') /* D4XX Payload Header metadata */
89 #define V4L2_META_FMT_VIVID v4l2_fourcc('V', 'I', 'V', 'D') /* Vivid Metadata */
90 #define V4L2_META_FMT_SENSOR_DATA v4l2_fourcc('S', 'E', 'N', 'S') /* Sensor Ancillary metadata */
91 +#define V4L2_META_FMT_BCM2835_ISP_STATS v4l2_fourcc('B', 'S', 'T', 'A') /* BCM2835 ISP image statistics output */
92
93 /* Vendor specific - used for RK_ISP1 camera sub-system */
94 #define V4L2_META_FMT_RK_ISP1_PARAMS v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */