History

Merge tag 'media/v6.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media

Pull media updates from Mauro Carvalho Chehab: - New drivers: - Mali-C55 ISP - Rockchip VICAP (RKCIF) - RKVDEC HEVC Decoder - Renesas RZV2H IVC - Sony IMX111 CMOS sensor driver - Removed STi C8SECTPFE Driver - Added a V4L2 ISP generic framework - Usual set of cleanup, fixes and driver improvements * tag 'media/v6.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (249 commits) media: rockchip: rkcif: add support for rk3568 vicap mipi capture media: rockchip: rkcif: add support for rk3568 vicap dvp capture media: rockchip: rkcif: add support for px30 vip dvp capture media: rockchip: rkcif: add abstraction for dma blocks media: rockchip: rkcif: add abstraction for interface and crop blocks media: rockchip: add driver for the rockchip camera interface media: dt-bindings: add rockchip rk3568 vicap media: dt-bindings: add rockchip px30 vip media: dt-bindings: video-interfaces: add defines for sampling modes Documentation: admin-guide: media: add rockchip camera interface media: mali-c55: Mark pm handlers as __maybe_unused media: mali-c55: Assert ISP blocks size correctness media: v4l2-isp: Rename block_info to block_type_info MAINTAINERS: Add entry for rzv2h-ivc driver media: platform: Add Renesas Input Video Control block driver dt-bindings: media: Add bindings for the RZ/V2H(P) IVC block Documentation: media: mali-c55: Document the mali-c55 parameter setting media: platform: Add mali-c55 parameters video node media: uapi: Add parameters structs to mali-c55-config.h media: mali-c55: Add image formats for Mali-C55 parameters buffer ...

Linus Torvalds committed 11 months ago

Commit d7aa60d2 parents 559e608 1f2353f310 files · +22133 −4826Browse files

Showing the changes to include/uapi (7 of 310 files). Show all

Unified · Split

7 files
  1. include/uapi/linux/media-bus-format.h +7 −2
  2. include/uapi/linux/media/amlogic/c3-isp-config.h +24 −68
  3. include/uapi/linux/media/arm/mali-c55-config.h +794 −0
  4. include/uapi/linux/media/v4l2-isp.h +102 −0
  5. include/uapi/linux/rkisp1-config.h +24 −83
  6. include/uapi/linux/v4l2-controls.h +6 −0
  7. include/uapi/linux/videodev2.h +4 −0
include/uapi/linux/media-bus-format.h+7−2
@@ -34,7 +34,7 @@ · 33 unmodified lines
34 34
35#define MEDIA_BUS_FMT_FIXED 0x000135#define MEDIA_BUS_FMT_FIXED 0x0001
36 36
37/* RGB - next is 0x1028 */37/* RGB - next is 0x1029 */
38#define MEDIA_BUS_FMT_RGB444_1X12 0x101638#define MEDIA_BUS_FMT_RGB444_1X12 0x1016
39#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE 0x100139#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE 0x1001
40#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE 0x100240#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE 0x1002
@@ -74,6 +74,7 @@ · 33 unmodified lines
74#define MEDIA_BUS_FMT_RGB888_1X36_CPADLO 0x102174#define MEDIA_BUS_FMT_RGB888_1X36_CPADLO 0x1021
75#define MEDIA_BUS_FMT_RGB121212_1X36 0x101975#define MEDIA_BUS_FMT_RGB121212_1X36 0x1019
76#define MEDIA_BUS_FMT_RGB161616_1X48 0x101a76#define MEDIA_BUS_FMT_RGB161616_1X48 0x101a
77#define MEDIA_BUS_FMT_RGB202020_1X60 0x1028
77 78
78/* YUV (including grey) - next is 0x202f */79/* YUV (including grey) - next is 0x202f */
79#define MEDIA_BUS_FMT_Y8_1X8 0x200180#define MEDIA_BUS_FMT_Y8_1X8 0x2001
@@ -123,7 +124,7 @@ · 43 unmodified lines
123#define MEDIA_BUS_FMT_YUV16_1X48 0x202a124#define MEDIA_BUS_FMT_YUV16_1X48 0x202a
124#define MEDIA_BUS_FMT_UYYVYY16_0_5X48 0x202b125#define MEDIA_BUS_FMT_UYYVYY16_0_5X48 0x202b
125 126
126/* Bayer - next is 0x3021 */127/* Bayer - next is 0x3025 */
127#define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001128#define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001
128#define MEDIA_BUS_FMT_SGBRG8_1X8 0x3013129#define MEDIA_BUS_FMT_SGBRG8_1X8 0x3013
129#define MEDIA_BUS_FMT_SGRBG8_1X8 0x3002130#define MEDIA_BUS_FMT_SGRBG8_1X8 0x3002
@@ -156,6 +157,10 @@ · 26 unmodified lines
156#define MEDIA_BUS_FMT_SGBRG16_1X16 0x301e157#define MEDIA_BUS_FMT_SGBRG16_1X16 0x301e
157#define MEDIA_BUS_FMT_SGRBG16_1X16 0x301f158#define MEDIA_BUS_FMT_SGRBG16_1X16 0x301f
158#define MEDIA_BUS_FMT_SRGGB16_1X16 0x3020159#define MEDIA_BUS_FMT_SRGGB16_1X16 0x3020
160#define MEDIA_BUS_FMT_SBGGR20_1X20 0x3021
161#define MEDIA_BUS_FMT_SGBRG20_1X20 0x3022
162#define MEDIA_BUS_FMT_SGRBG20_1X20 0x3023
163#define MEDIA_BUS_FMT_SRGGB20_1X20 0x3024
159 164
160/* JPEG compressed formats - next is 0x4002 */165/* JPEG compressed formats - next is 0x4002 */
161#define MEDIA_BUS_FMT_JPEG_1X8 0x4001166#define MEDIA_BUS_FMT_JPEG_1X8 0x4001
include/uapi/linux/media/amlogic/c3-isp-config.h+24−68
@@ -6,8 +6,13 @@ · 5 unmodified lines
6#ifndef _UAPI_C3_ISP_CONFIG_H_6#ifndef _UAPI_C3_ISP_CONFIG_H_
7#define _UAPI_C3_ISP_CONFIG_H_7#define _UAPI_C3_ISP_CONFIG_H_
8 8
9#ifdef __KERNEL__
10#include <linux/build_bug.h>
11#endif /* __KERNEL__ */
9#include <linux/types.h>12#include <linux/types.h>
10 13
14#include <linux/media/v4l2-isp.h>
15
11/*16/*
12 * Frames are split into zones of almost equal width and height - a zone is a17 * Frames are split into zones of almost equal width and height - a zone is a
13 * rectangular tile of a frame. The metering blocks within the ISP collect18 * rectangular tile of a frame. The metering blocks within the ISP collect
@@ -141,7 +146,7 @@ struct c3_isp_stats_info { · 127 unmodified lines
141 * @C3_ISP_PARAMS_BUFFER_V0: First version of C3 ISP parameters block146 * @C3_ISP_PARAMS_BUFFER_V0: First version of C3 ISP parameters block
142 */147 */
143enum c3_isp_params_buffer_version {148enum c3_isp_params_buffer_version {
144 C3_ISP_PARAMS_BUFFER_V0,149 C3_ISP_PARAMS_BUFFER_V0 = V4L2_ISP_PARAMS_VERSION_V0,
145};150};
146 151
147/**152/**
@@ -176,62 +181,23 @@ enum c3_isp_params_block_type { · 28 unmodified lines
176 C3_ISP_PARAMS_BLOCK_SENTINEL181 C3_ISP_PARAMS_BLOCK_SENTINEL
177};182};
178 183
179#define C3_ISP_PARAMS_BLOCK_FL_DISABLE (1U << 0)184/* For backward compatibility */
180#define C3_ISP_PARAMS_BLOCK_FL_ENABLE (1U << 1)185#define C3_ISP_PARAMS_BLOCK_FL_DISABLE V4L2_ISP_PARAMS_FL_BLOCK_DISABLE
186#define C3_ISP_PARAMS_BLOCK_FL_ENABLE V4L2_ISP_PARAMS_FL_BLOCK_ENABLE
181 187
182/**188/**
183 * struct c3_isp_params_block_header - C3 ISP parameter block header189 * struct c3_isp_params_block_header - C3 ISP parameter block header
184 *190 *
185 * This structure represents the common part of all the ISP configuration191 * This structure represents the common part of all the ISP configuration
186 * blocks. Each parameters block shall embed an instance of this structure type192 * blocks and is identical to :c:type:`v4l2_isp_params_block_header`.
187 * as its first member, followed by the block-specific configuration data. The
188 * driver inspects this common header to discern the block type and its size and
189 * properly handle the block content by casting it to the correct block-specific
190 * type.
191 *193 *
192 * The @type field is one of the values enumerated by194 * The type field is one of the values enumerated by
193 * :c:type:`c3_isp_params_block_type` and specifies how the data should be195 * :c:type:`c3_isp_params_block_type` and specifies how the data should be
194 * interpreted by the driver. The @size field specifies the size of the196 * interpreted by the driver.
195 * parameters block and is used by the driver for validation purposes. The
196 * @flags field is a bitmask of per-block flags C3_ISP_PARAMS_FL*.
197 *
198 * When userspace wants to disable an ISP block the
199 * C3_ISP_PARAMS_BLOCK_FL_DISABLED bit should be set in the @flags field. In
200 * this case userspace may optionally omit the remainder of the configuration
201 * block, which will be ignored by the driver.
202 *
203 * When a new configuration of an ISP block needs to be applied userspace
204 * shall fully populate the ISP block and omit setting the
205 * C3_ISP_PARAMS_BLOCK_FL_DISABLED bit in the @flags field.
206 *
207 * Userspace is responsible for correctly populating the parameters block header
208 * fields (@type, @flags and @size) and the block-specific parameters.
209 *
210 * For example:
211 *
212 * .. code-block:: c
213 *197 *
214 * void populate_pst_gamma(struct c3_isp_params_block_header *block) {198 * The flags field is a bitmask of per-block flags C3_ISP_PARAMS_FL_*.
215 * struct c3_isp_params_pst_gamma *gamma =
216 * (struct c3_isp_params_pst_gamma *)block;
217 *
218 * gamma->header.type = C3_ISP_PARAMS_BLOCK_PST_GAMMA;
219 * gamma->header.flags = C3_ISP_PARAMS_BLOCK_FL_ENABLE;
220 * gamma->header.size = sizeof(*gamma);
221 *
222 * for (unsigned int i = 0; i < 129; i++)
223 * gamma->pst_gamma_lut[i] = i;
224 * }
225 *
226 * @type: The parameters block type from :c:type:`c3_isp_params_block_type`
227 * @flags: A bitmask of block flags
228 * @size: Size (in bytes) of the parameters block, including this header
229 */199 */
230struct c3_isp_params_block_header {200#define c3_isp_params_block_header v4l2_isp_params_block_header
231 __u16 type;
232 __u16 flags;
233 __u32 size;
234};
235 201
236/**202/**
237 * struct c3_isp_params_awb_gains - Gains for auto-white balance203 * struct c3_isp_params_awb_gains - Gains for auto-white balance
@@ -498,26 +464,10 @@ struct c3_isp_params_blc { · 260 unmodified lines
498/**464/**
499 * struct c3_isp_params_cfg - C3 ISP configuration parameters465 * struct c3_isp_params_cfg - C3 ISP configuration parameters
500 *466 *
501 * This struct contains the configuration parameters of the C3 ISP467 * This is the driver-specific implementation of
502 * algorithms, serialized by userspace into an opaque data buffer. Each468 * :c:type:`v4l2_isp_params_buffer`.
503 * configuration parameter block is represented by a block-specific structure469 *
504 * which contains a :c:type:`c3_isp_param_block_header` entry as first470 * Currently only C3_ISP_PARAM_BUFFER_V0 is supported.
505 * member. Userspace populates the @data buffer with configuration parameters
506 * for the blocks that it intends to configure. As a consequence, the data
507 * buffer effective size changes according to the number of ISP blocks that
508 * userspace intends to configure.
509 *
510 * The parameters buffer is versioned by the @version field to allow modifying
511 * and extending its definition. Userspace should populate the @version field to
512 * inform the driver about the version it intends to use. The driver will parse
513 * and handle the @data buffer according to the data layout specific to the
514 * indicated revision and return an error if the desired revision is not
515 * supported.
516 *
517 * For each ISP block that userspace wants to configure, a block-specific
518 * structure is appended to the @data buffer, one after the other without gaps
519 * in between nor overlaps. Userspace shall populate the @total_size field with
520 * the effective size, in bytes, of the @data buffer.
521 *471 *
522 * The expected memory layout of the parameters buffer is::472 * The expected memory layout of the parameters buffer is::
523 *473 *
@@ -561,4 +511,10 @@ struct c3_isp_params_cfg { · 37 unmodified lines
561 __u8 data[C3_ISP_PARAMS_MAX_SIZE];511 __u8 data[C3_ISP_PARAMS_MAX_SIZE];
562};512};
563 513
514#ifdef __KERNEL__
515/* Make sure the header is type-convertible to the generic v4l2 params one */
516static_assert((sizeof(struct c3_isp_params_cfg) - C3_ISP_PARAMS_MAX_SIZE) ==
517 sizeof(struct v4l2_isp_params_buffer));
518#endif /* __KERNEL__ */
519
564#endif520#endif
include/uapi/linux/media/arm/mali-c55-config.h+794−0
@@ -0,0 +1,794 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * ARM Mali-C55 ISP Driver - Userspace API
4 *
5 * Copyright (C) 2023 Ideas on Board Oy
6 */
7
8#ifndef __UAPI_MALI_C55_CONFIG_H
9#define __UAPI_MALI_C55_CONFIG_H
10
11#include <linux/types.h>
12#include <linux/v4l2-controls.h>
13#include <linux/media/v4l2-isp.h>
14
15#define V4L2_CID_MALI_C55_CAPABILITIES (V4L2_CID_USER_MALI_C55_BASE + 0x0)
16#define MALI_C55_GPS_PONG (1U << 0)
17#define MALI_C55_GPS_WDR (1U << 1)
18#define MALI_C55_GPS_COMPRESSION (1U << 2)
19#define MALI_C55_GPS_TEMPER (1U << 3)
20#define MALI_C55_GPS_SINTER_LITE (1U << 4)
21#define MALI_C55_GPS_SINTER (1U << 5)
22#define MALI_C55_GPS_IRIDIX_LTM (1U << 6)
23#define MALI_C55_GPS_IRIDIX_GTM (1U << 7)
24#define MALI_C55_GPS_CNR (1U << 8)
25#define MALI_C55_GPS_FRSCALER (1U << 9)
26#define MALI_C55_GPS_DS_PIPE (1U << 10)
27
28/*
29 * Frames are split into zones of almost equal width and height - a zone is a
30 * rectangular tile of a frame. The metering blocks within the ISP collect
31 * aggregated statistics per zone. A maximum of 15x15 zones can be configured,
32 * and so the statistics buffer within the hardware is sized to accommodate
33 * that.
34 *
35 * The utilised number of zones is runtime configurable.
36 */
37#define MALI_C55_MAX_ZONES (15 * 15)
38
39/**
40 * struct mali_c55_ae_1024bin_hist - Auto Exposure 1024-bin histogram statistics
41 *
42 * @bins: 1024 element array of 16-bit pixel counts.
43 *
44 * The 1024-bin histogram module collects image-global but zone-weighted
45 * intensity distributions of pixels in fixed-width bins. The modules can be
46 * configured into different "plane modes" which affect the contents of the
47 * collected statistics. In plane mode 0, pixel intensities are taken regardless
48 * of colour plane into a single 1024-bin histogram with a bin width of 4. In
49 * plane mode 1, four 256-bin histograms with a bin width of 16 are collected -
50 * one for each CFA colour plane. In plane modes 4, 5, 6 and 7 two 512-bin
51 * histograms with a bin width of 8 are collected - in each mode one of the
52 * colour planes is collected into the first histogram and all the others are
53 * combined into the second. The histograms are stored consecutively in the bins
54 * array.
55 *
56 * The 16-bit pixel counts are stored as a 4-bit exponent in the most
57 * significant bits followed by a 12-bit mantissa. Conversion to a usable
58 * format can be done according to the following pseudo-code::
59 *
60 * if (e == 0) {
61 * bin = m * 2;
62 * } else {
63 * bin = (m + 4096) * 2^e
64 * }
65 *
66 * where
67 * e is the exponent value in range 0..15
68 * m is the mantissa value in range 0..4095
69 *
70 * The pixels used in calculating the statistics can be masked using three
71 * methods:
72 *
73 * 1. Pixels can be skipped in X and Y directions independently.
74 * 2. Minimum/Maximum intensities can be configured
75 * 3. Zones can be differentially weighted, including 0 weighted to mask them
76 *
77 * The data for this histogram can be collected from different tap points in the
78 * ISP depending on configuration - after the white balance or digital gain
79 * blocks, or immediately after the input crossbar.
80 */
81struct mali_c55_ae_1024bin_hist {
82 __u16 bins[1024];
83} __attribute__((packed));
84
85/**
86 * struct mali_c55_ae_5bin_hist - Auto Exposure 5-bin histogram statistics
87 *
88 * @hist0: 16-bit normalised pixel count for the 0th intensity bin
89 * @hist1: 16-bit normalised pixel count for the 1st intensity bin
90 * @hist3: 16-bit normalised pixel count for the 3rd intensity bin
91 * @hist4: 16-bit normalised pixel count for the 4th intensity bin
92 *
93 * The ISP generates a 5-bin histogram of normalised pixel counts within bins of
94 * pixel intensity for each of 225 possible zones within a frame. The centre bin
95 * of the histogram for each zone is not available from the hardware and must be
96 * calculated by subtracting the values of hist0, hist1, hist3 and hist4 from
97 * 0xffff as in the following equation:
98 *
99 * hist2 = 0xffff - (hist0 + hist1 + hist3 + hist4)
100 */
101struct mali_c55_ae_5bin_hist {
102 __u16 hist0;
103 __u16 hist1;
104 __u16 hist3;
105 __u16 hist4;
106} __attribute__((packed));
107
108/**
109 * struct mali_c55_awb_average_ratios - Auto White Balance colour ratios
110 *
111 * @avg_rg_gr: Average R/G or G/R ratio in Q4.8 format.
112 * @avg_bg_br: Average B/G or B/R ratio in Q4.8 format.
113 * @num_pixels: The number of pixels used in the AWB calculation
114 *
115 * The ISP calculates and collects average colour ratios for each zone in an
116 * image and stores them in Q4.8 format (the lowest 8 bits are fractional, with
117 * bits [11:8] representing the integer). The exact ratios collected (either
118 * R/G, B/G or G/R, B/R) are configurable through the parameters buffer. The
119 * value of the 4 high bits is undefined.
120 */
121struct mali_c55_awb_average_ratios {
122 __u16 avg_rg_gr;
123 __u16 avg_bg_br;
124 __u32 num_pixels;
125} __attribute__((packed));
126
127/**
128 * struct mali_c55_af_statistics - Auto Focus edge and intensity statistics
129 *
130 * @intensity_stats: Packed mantissa and exponent value for pixel intensity
131 * @edge_stats: Packed mantissa and exponent values for edge intensity
132 *
133 * The ISP collects the squared sum of pixel intensities for each zone within a
134 * configurable Region of Interest on the frame. Additionally, the same data are
135 * collected after being passed through a bandpass filter which removes high and
136 * low frequency components - these are referred to as the edge statistics.
137 *
138 * The intensity and edge statistics for a zone can be used to calculate the
139 * contrast information for a zone
140 *
141 * C = E2 / I2
142 *
143 * Where I2 is the intensity statistic for a zone and E2 is the edge statistic
144 * for that zone. Optimum focus is reached when C is at its maximum.
145 *
146 * The intensity and edge statistics are stored packed into a non-standard 16
147 * bit floating point format, where the 7 most significant bits represent the
148 * exponent and the 9 least significant bits the mantissa. This format can be
149 * unpacked with the following pseudocode::
150 *
151 * if (e == 0) {
152 * x = m;
153 * } else {
154 * x = 2^e-1 * (m + 2^9)
155 * }
156 *
157 * where
158 * e is the exponent value in range 0..127
159 * m is the mantissa value in range 0..511
160 */
161struct mali_c55_af_statistics {
162 __u16 intensity_stats;
163 __u16 edge_stats;
164} __attribute__((packed));
165
166/**
167 * struct mali_c55_stats_buffer - 3A statistics for the mali-c55 ISP
168 *
169 * @ae_1024bin_hist: 1024-bin frame-global pixel intensity histogram
170 * @iridix_1024bin_hist: Post-Iridix block 1024-bin histogram
171 * @ae_5bin_hists: 5-bin pixel intensity histograms for AEC
172 * @reserved1: Undefined buffer space
173 * @awb_ratios: Color balance ratios for Auto White Balance
174 * @reserved2: Undefined buffer space
175 * @af_statistics: Pixel intensity statistics for Auto Focus
176 * @reserved3: Undefined buffer space
177 *
178 * This struct describes the metering statistics space in the Mali-C55 ISP's
179 * hardware in its entirety. The space between each defined area is marked as
180 * "unknown" and may not be 0, but should not be used. The @ae_5bin_hists,
181 * @awb_ratios and @af_statistics members are arrays of statistics per-zone.
182 * The zones are arranged in the array in raster order starting from the top
183 * left corner of the image.
184 */
185
186struct mali_c55_stats_buffer {
187 struct mali_c55_ae_1024bin_hist ae_1024bin_hist;
188 struct mali_c55_ae_1024bin_hist iridix_1024bin_hist;
189 struct mali_c55_ae_5bin_hist ae_5bin_hists[MALI_C55_MAX_ZONES];
190 __u32 reserved1[14];
191 struct mali_c55_awb_average_ratios awb_ratios[MALI_C55_MAX_ZONES];
192 __u32 reserved2[14];
193 struct mali_c55_af_statistics af_statistics[MALI_C55_MAX_ZONES];
194 __u32 reserved3[15];
195} __attribute__((packed));
196
197/**
198 * enum mali_c55_param_buffer_version - Mali-C55 parameters block versioning
199 *
200 * @MALI_C55_PARAM_BUFFER_V1: First version of Mali-C55 parameters block
201 */
202enum mali_c55_param_buffer_version {
203 MALI_C55_PARAM_BUFFER_V1,
204};
205
206/**
207 * enum mali_c55_param_block_type - Enumeration of Mali-C55 parameter blocks
208 *
209 * This enumeration defines the types of Mali-C55 parameters block. Each block
210 * configures a specific processing block of the Mali-C55 ISP. The block
211 * type allows the driver to correctly interpret the parameters block data.
212 *
213 * It is the responsibility of userspace to correctly set the type of each
214 * parameters block.
215 *
216 * @MALI_C55_PARAM_BLOCK_SENSOR_OFFS: Sensor pre-shading black level offset
217 * @MALI_C55_PARAM_BLOCK_AEXP_HIST: Auto-exposure 1024-bin histogram
218 * configuration
219 * @MALI_C55_PARAM_BLOCK_AEXP_IHIST: Post-Iridix auto-exposure 1024-bin
220 * histogram configuration
221 * @MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS: Auto-exposure 1024-bin histogram
222 * weighting
223 * @MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS: Post-Iridix auto-exposure 1024-bin
224 * histogram weighting
225 * @MALI_C55_PARAM_BLOCK_DIGITAL_GAIN: Digital gain
226 * @MALI_C55_PARAM_BLOCK_AWB_GAINS: Auto-white balance gains
227 * @MALI_C55_PARAM_BLOCK_AWB_CONFIG: Auto-white balance statistics config
228 * @MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP: Auto-white balance gains for AEXP-0 tap
229 * @MALI_C55_PARAM_MESH_SHADING_CONFIG : Mesh shading tables configuration
230 * @MALI_C55_PARAM_MESH_SHADING_SELECTION: Mesh shading table selection
231 */
232enum mali_c55_param_block_type {
233 MALI_C55_PARAM_BLOCK_SENSOR_OFFS,
234 MALI_C55_PARAM_BLOCK_AEXP_HIST,
235 MALI_C55_PARAM_BLOCK_AEXP_IHIST,
236 MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS,
237 MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS,
238 MALI_C55_PARAM_BLOCK_DIGITAL_GAIN,
239 MALI_C55_PARAM_BLOCK_AWB_GAINS,
240 MALI_C55_PARAM_BLOCK_AWB_CONFIG,
241 MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP,
242 MALI_C55_PARAM_MESH_SHADING_CONFIG,
243 MALI_C55_PARAM_MESH_SHADING_SELECTION,
244};
245
246/**
247 * struct mali_c55_params_sensor_off_preshading - offset subtraction for each
248 * color channel
249 *
250 * Provides removal of the sensor black level from the sensor data. Separate
251 * offsets are provided for each of the four Bayer component color channels
252 * which are defaulted to R, Gr, Gb, B.
253 *
254 * header.type should be set to MALI_C55_PARAM_BLOCK_SENSOR_OFFS from
255 * :c:type:`mali_c55_param_block_type` for this block.
256 *
257 * @header: The Mali-C55 parameters block header
258 * @chan00: Offset for color channel 00 (default: R)
259 * @chan01: Offset for color channel 01 (default: Gr)
260 * @chan10: Offset for color channel 10 (default: Gb)
261 * @chan11: Offset for color channel 11 (default: B)
262 */
263struct mali_c55_params_sensor_off_preshading {
264 struct v4l2_isp_params_block_header header;
265 __u32 chan00;
266 __u32 chan01;
267 __u32 chan10;
268 __u32 chan11;
269};
270
271/**
272 * enum mali_c55_aexp_hist_tap_points - Tap points for the AEXP histogram
273 * @MALI_C55_AEXP_HIST_TAP_WB: After static white balance
274 * @MALI_C55_AEXP_HIST_TAP_FS: After WDR Frame Stitch
275 * @MALI_C55_AEXP_HIST_TAP_TPG: After the test pattern generator
276 */
277enum mali_c55_aexp_hist_tap_points {
278 MALI_C55_AEXP_HIST_TAP_WB = 0,
279 MALI_C55_AEXP_HIST_TAP_FS,
280 MALI_C55_AEXP_HIST_TAP_TPG,
281};
282
283/**
284 * enum mali_c55_aexp_skip_x - Horizontal pixel skipping
285 * @MALI_C55_AEXP_SKIP_X_EVERY_2ND: Collect every 2nd pixel horizontally
286 * @MALI_C55_AEXP_SKIP_X_EVERY_3RD: Collect every 3rd pixel horizontally
287 * @MALI_C55_AEXP_SKIP_X_EVERY_4TH: Collect every 4th pixel horizontally
288 * @MALI_C55_AEXP_SKIP_X_EVERY_5TH: Collect every 5th pixel horizontally
289 * @MALI_C55_AEXP_SKIP_X_EVERY_8TH: Collect every 8th pixel horizontally
290 * @MALI_C55_AEXP_SKIP_X_EVERY_9TH: Collect every 9th pixel horizontally
291 */
292enum mali_c55_aexp_skip_x {
293 MALI_C55_AEXP_SKIP_X_EVERY_2ND,
294 MALI_C55_AEXP_SKIP_X_EVERY_3RD,
295 MALI_C55_AEXP_SKIP_X_EVERY_4TH,
296 MALI_C55_AEXP_SKIP_X_EVERY_5TH,
297 MALI_C55_AEXP_SKIP_X_EVERY_8TH,
298 MALI_C55_AEXP_SKIP_X_EVERY_9TH
299};
300
301/**
302 * enum mali_c55_aexp_skip_y - Vertical pixel skipping
303 * @MALI_C55_AEXP_SKIP_Y_ALL: Collect every single pixel vertically
304 * @MALI_C55_AEXP_SKIP_Y_EVERY_2ND: Collect every 2nd pixel vertically
305 * @MALI_C55_AEXP_SKIP_Y_EVERY_3RD: Collect every 3rd pixel vertically
306 * @MALI_C55_AEXP_SKIP_Y_EVERY_4TH: Collect every 4th pixel vertically
307 * @MALI_C55_AEXP_SKIP_Y_EVERY_5TH: Collect every 5th pixel vertically
308 * @MALI_C55_AEXP_SKIP_Y_EVERY_8TH: Collect every 8th pixel vertically
309 * @MALI_C55_AEXP_SKIP_Y_EVERY_9TH: Collect every 9th pixel vertically
310 */
311enum mali_c55_aexp_skip_y {
312 MALI_C55_AEXP_SKIP_Y_ALL,
313 MALI_C55_AEXP_SKIP_Y_EVERY_2ND,
314 MALI_C55_AEXP_SKIP_Y_EVERY_3RD,
315 MALI_C55_AEXP_SKIP_Y_EVERY_4TH,
316 MALI_C55_AEXP_SKIP_Y_EVERY_5TH,
317 MALI_C55_AEXP_SKIP_Y_EVERY_8TH,
318 MALI_C55_AEXP_SKIP_Y_EVERY_9TH
319};
320
321/**
322 * enum mali_c55_aexp_row_column_offset - Start from the first or second row or
323 * column
324 * @MALI_C55_AEXP_FIRST_ROW_OR_COL: Start from the first row / column
325 * @MALI_C55_AEXP_SECOND_ROW_OR_COL: Start from the second row / column
326 */
327enum mali_c55_aexp_row_column_offset {
328 MALI_C55_AEXP_FIRST_ROW_OR_COL = 1,
329 MALI_C55_AEXP_SECOND_ROW_OR_COL = 2,
330};
331
332/**
333 * enum mali_c55_aexp_hist_plane_mode - Mode for the AEXP Histograms
334 * @MALI_C55_AEXP_HIST_COMBINED: All color planes in one 1024-bin histogram
335 * @MALI_C55_AEXP_HIST_SEPARATE: Each color plane in one 256-bin histogram with a bin width of 16
336 * @MALI_C55_AEXP_HIST_FOCUS_00: Top left plane in the first bank, rest in second bank
337 * @MALI_C55_AEXP_HIST_FOCUS_01: Top right plane in the first bank, rest in second bank
338 * @MALI_C55_AEXP_HIST_FOCUS_10: Bottom left plane in the first bank, rest in second bank
339 * @MALI_C55_AEXP_HIST_FOCUS_11: Bottom right plane in the first bank, rest in second bank
340 *
341 * In the "focus" modes statistics are collected into two 512-bin histograms
342 * with a bin width of 8. One colour plane is in the first histogram with the
343 * remainder combined into the second. The four options represent which of the
344 * four positions in a bayer pattern are the focused plane.
345 */
346enum mali_c55_aexp_hist_plane_mode {
347 MALI_C55_AEXP_HIST_COMBINED = 0,
348 MALI_C55_AEXP_HIST_SEPARATE = 1,
349 MALI_C55_AEXP_HIST_FOCUS_00 = 4,
350 MALI_C55_AEXP_HIST_FOCUS_01 = 5,
351 MALI_C55_AEXP_HIST_FOCUS_10 = 6,
352 MALI_C55_AEXP_HIST_FOCUS_11 = 7,
353};
354
355/**
356 * struct mali_c55_params_aexp_hist - configuration for AEXP metering hists
357 *
358 * This struct allows users to configure the 1024-bin AEXP histograms. Broadly
359 * speaking the parameters allow you to mask particular regions of the image and
360 * to select different kinds of histogram.
361 *
362 * The skip_x, offset_x, skip_y and offset_y fields allow users to ignore or
363 * mask pixels in the frame by their position relative to the top left pixel.
364 * First, the skip_y, offset_x and offset_y fields define which of the pixels
365 * within each 2x2 region will be counted in the statistics.
366 *
367 * If skip_y == 0 then two pixels from each covered region will be counted. If
368 * both offset_x and offset_y are zero, then the two left-most pixels in each
369 * 2x2 pixel region will be counted. Setting offset_x = 1 will discount the top
370 * left pixel and count the top right pixel. Setting offset_y = 1 will discount
371 * the bottom left pixel and count the bottom right pixel.
372 *
373 * If skip_y != 0 then only a single pixel from each region covered by the
374 * pattern will be counted. In this case offset_x controls whether the pixel
375 * that's counted is in the left (if offset_x == 0) or right (if offset_x == 1)
376 * column and offset_y controls whether the pixel that's counted is in the top
377 * (if offset_y == 0) or bottom (if offset_y == 1) row.
378 *
379 * The skip_x and skip_y fields control how the 2x2 pixel region is repeated
380 * across the image data. The first instance of the region is always in the top
381 * left of the image data. The skip_x field controls how many pixels are ignored
382 * in the x direction before the pixel masking region is repeated. The skip_y
383 * field controls how many pixels are ignored in the y direction before the
384 * pixel masking region is repeated.
385 *
386 * These fields can be used to reduce the number of pixels counted for the
387 * statistics, but it's important to be careful to configure them correctly.
388 * Some combinations of values will result in colour components from the input
389 * data being ignored entirely, for example in the following configuration:
390 *
391 * skip_x = 0
392 * offset_x = 0
393 * skip_y = 0
394 * offset_y = 0
395 *
396 * Only the R and Gb components of RGGB data that was input would be collected.
397 * Similarly in the following configuration:
398 *
399 * skip_x = 0
400 * offset_x = 0
401 * skip_y = 1
402 * offset_y = 1
403 *
404 * Only the Gb component of RGGB data that was input would be collected. To
405 * correct things such that all 4 colour components were included it would be
406 * necessary to set the skip_x and skip_y fields in a way that resulted in all
407 * four colour components being collected:
408 *
409 * skip_x = 1
410 * offset_x = 0
411 * skip_y = 1
412 * offset_y = 1
413 *
414 * header.type should be set to one of either MALI_C55_PARAM_BLOCK_AEXP_HIST or
415 * MALI_C55_PARAM_BLOCK_AEXP_IHIST from :c:type:`mali_c55_param_block_type`.
416 *
417 * @header: The Mali-C55 parameters block header
418 * @skip_x: Horizontal decimation. See enum mali_c55_aexp_skip_x
419 * @offset_x: Skip the first column, or not. See enum mali_c55_aexp_row_column_offset
420 * @skip_y: Vertical decimation. See enum mali_c55_aexp_skip_y
421 * @offset_y: Skip the first row, or not. See enum mali_c55_aexp_row_column_offset
422 * @scale_bottom: Scale pixels in bottom half of intensity range: 0=1x ,1=2x, 2=4x, 4=8x, 4=16x
423 * @scale_top: scale pixels in top half of intensity range: 0=1x ,1=2x, 2=4x, 4=8x, 4=16x
424 * @plane_mode: Plane separation mode. See enum mali_c55_aexp_hist_plane_mode
425 * @tap_point: Tap point for histogram from enum mali_c55_aexp_hist_tap_points.
426 * This parameter is unused for the post-Iridix Histogram
427 */
428struct mali_c55_params_aexp_hist {
429 struct v4l2_isp_params_block_header header;
430 __u8 skip_x;
431 __u8 offset_x;
432 __u8 skip_y;
433 __u8 offset_y;
434 __u8 scale_bottom;
435 __u8 scale_top;
436 __u8 plane_mode;
437 __u8 tap_point;
438};
439
440/**
441 * struct mali_c55_params_aexp_weights - Array of weights for AEXP metering
442 *
443 * This struct allows users to configure the weighting for both of the 1024-bin
444 * AEXP histograms. The pixel data collected for each zone is multiplied by the
445 * corresponding weight from this array, which may be zero if the intention is
446 * to mask off the zone entirely.
447 *
448 * header.type should be set to one of either MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS
449 * or MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS from :c:type:`mali_c55_param_block_type`.
450 *
451 * @header: The Mali-C55 parameters block header
452 * @nodes_used_horiz: Number of active zones horizontally [0..15]
453 * @nodes_used_vert: Number of active zones vertically [0..15]
454 * @zone_weights: Zone weighting. Index is row*col where 0,0 is the top
455 * left zone continuing in raster order. Each zone can be
456 * weighted in the range [0..15]. The number of rows and
457 * columns is defined by @nodes_used_vert and
458 * @nodes_used_horiz
459 */
460struct mali_c55_params_aexp_weights {
461 struct v4l2_isp_params_block_header header;
462 __u8 nodes_used_horiz;
463 __u8 nodes_used_vert;
464 __u8 zone_weights[MALI_C55_MAX_ZONES];
465};
466
467/**
468 * struct mali_c55_params_digital_gain - Digital gain value
469 *
470 * This struct carries a digital gain value to set in the ISP.
471 *
472 * header.type should be set to MALI_C55_PARAM_BLOCK_DIGITAL_GAIN from
473 * :c:type:`mali_c55_param_block_type` for this block.
474 *
475 * @header: The Mali-C55 parameters block header
476 * @gain: The digital gain value to apply, in Q5.8 format.
477 */
478struct mali_c55_params_digital_gain {
479 struct v4l2_isp_params_block_header header;
480 __u16 gain;
481};
482
483/**
484 * enum mali_c55_awb_stats_mode - Statistics mode for AWB
485 * @MALI_C55_AWB_MODE_GRBR: Statistics collected as Green/Red and Blue/Red ratios
486 * @MALI_C55_AWB_MODE_RGBG: Statistics collected as Red/Green and Blue/Green ratios
487 */
488enum mali_c55_awb_stats_mode {
489 MALI_C55_AWB_MODE_GRBR = 0,
490 MALI_C55_AWB_MODE_RGBG,
491};
492
493/**
494 * struct mali_c55_params_awb_gains - Gain settings for auto white balance
495 *
496 * This struct allows users to configure the gains for auto-white balance. There
497 * are four gain settings corresponding to each colour channel in the bayer
498 * domain. Although named generically, the association between the gain applied
499 * and the colour channel is done automatically within the ISP depending on the
500 * input format, and so the following mapping always holds true::
501 *
502 * gain00 = R
503 * gain01 = Gr
504 * gain10 = Gb
505 * gain11 = B
506 *
507 * All of the gains are stored in Q4.8 format.
508 *
509 * header.type should be set to one of either MALI_C55_PARAM_BLOCK_AWB_GAINS or
510 * MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP from :c:type:`mali_c55_param_block_type`.
511 *
512 * @header: The Mali-C55 parameters block header
513 * @gain00: Multiplier for colour channel 00
514 * @gain01: Multiplier for colour channel 01
515 * @gain10: Multiplier for colour channel 10
516 * @gain11: Multiplier for colour channel 11
517 */
518struct mali_c55_params_awb_gains {
519 struct v4l2_isp_params_block_header header;
520 __u16 gain00;
521 __u16 gain01;
522 __u16 gain10;
523 __u16 gain11;
524};
525
526/**
527 * enum mali_c55_params_awb_tap_points - Tap points for the AWB statistics
528 * @MALI_C55_AWB_STATS_TAP_PF: Immediately after the Purple Fringe block
529 * @MALI_C55_AWB_STATS_TAP_CNR: Immediately after the CNR block
530 */
531enum mali_c55_params_awb_tap_points {
532 MALI_C55_AWB_STATS_TAP_PF = 0,
533 MALI_C55_AWB_STATS_TAP_CNR,
534};
535
536/**
537 * struct mali_c55_params_awb_config - Stats settings for auto-white balance
538 *
539 * This struct allows the configuration of the statistics generated for auto
540 * white balance. Pixel intensity limits can be set to exclude overly bright or
541 * dark regions of an image from the statistics entirely. Colour ratio minima
542 * and maxima can be set to discount pixels who's ratios fall outside the
543 * defined boundaries; there are two sets of registers to do this - the
544 * "min/max" ratios which bound a region and the "high/low" ratios which further
545 * trim the upper and lower ratios. For example with the boundaries configured
546 * as follows, only pixels whos colour ratios falls into the region marked "A"
547 * would be counted::
548 *
549 * cr_high
550 * 2.0 | |
551 * | cb_max --> _________________________v_____
552 * 1.8 | | \ |
553 * | | \ |
554 * 1.6 | | \ |
555 * | | \ |
556 * c 1.4 | cb_low -->|\ A \|<-- cb_high
557 * b | | \ |
558 * 1.2 | | \ |
559 * r | | \ |
560 * a 1.0 | cb_min --> |____\_________________________|
561 * t | ^ ^ ^
562 * i 0.8 | | | |
563 * o | cr_min | cr_max
564 * s 0.6 | |
565 * | cr_low
566 * 0.4 |
567 * |
568 * 0.2 |
569 * |
570 * 0.0 |_______________________________________________________________
571 * 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0
572 * cr ratios
573 *
574 * header.type should be set to MALI_C55_PARAM_BLOCK_AWB_CONFIG from
575 * :c:type:`mali_c55_param_block_type` for this block.
576 *
577 * @header: The Mali-C55 parameters block header
578 * @tap_point: The tap point from enum mali_c55_params_awb_tap_points
579 * @stats_mode: AWB statistics collection mode, see :c:type:`mali_c55_awb_stats_mode`
580 * @white_level: Upper pixel intensity (I.E. raw pixel values) limit
581 * @black_level: Lower pixel intensity (I.E. raw pixel values) limit
582 * @cr_max: Maximum R/G ratio (Q4.8 format)
583 * @cr_min: Minimum R/G ratio (Q4.8 format)
584 * @cb_max: Maximum B/G ratio (Q4.8 format)
585 * @cb_min: Minimum B/G ratio (Q4.8 format)
586 * @nodes_used_horiz: Number of active zones horizontally [0..15]
587 * @nodes_used_vert: Number of active zones vertically [0..15]
588 * @cr_high: R/G ratio trim high (Q4.8 format)
589 * @cr_low: R/G ratio trim low (Q4.8 format)
590 * @cb_high: B/G ratio trim high (Q4.8 format)
591 * @cb_low: B/G ratio trim low (Q4.8 format)
592 */
593struct mali_c55_params_awb_config {
594 struct v4l2_isp_params_block_header header;
595 __u8 tap_point;
596 __u8 stats_mode;
597 __u16 white_level;
598 __u16 black_level;
599 __u16 cr_max;
600 __u16 cr_min;
601 __u16 cb_max;
602 __u16 cb_min;
603 __u8 nodes_used_horiz;
604 __u8 nodes_used_vert;
605 __u16 cr_high;
606 __u16 cr_low;
607 __u16 cb_high;
608 __u16 cb_low;
609};
610
611#define MALI_C55_NUM_MESH_SHADING_ELEMENTS 3072
612
613/**
614 * struct mali_c55_params_mesh_shading_config - Mesh shading configuration
615 *
616 * The mesh shading correction module allows programming a separate table of
617 * either 16x16 or 32x32 node coefficients for 3 different light sources. The
618 * final correction coefficients applied are computed by blending the
619 * coefficients from two tables together.
620 *
621 * A page of 1024 32-bit integers is associated to each colour channel, with
622 * pages stored consecutively in memory. Each 32-bit integer packs 3 8-bit
623 * correction coefficients for a single node, one for each of the three light
624 * sources. The 8 most significant bits are unused. The following table
625 * describes the layout::
626 *
627 * +----------- Page (Colour Plane) 0 -------------+
628 * | @mesh[i] | Mesh Point | Bits | Light Source |
629 * +-----------+------------+-------+--------------+
630 * | 0 | 0,0 | 16,23 | LS2 |
631 * | | | 08-15 | LS1 |
632 * | | | 00-07 | LS0 |
633 * +-----------+------------+-------+--------------+
634 * | 1 | 0,1 | 16,23 | LS2 |
635 * | | | 08-15 | LS1 |
636 * | | | 00-07 | LS0 |
637 * +-----------+------------+-------+--------------+
638 * | ... | ... | ... | ... |
639 * +-----------+------------+-------+--------------+
640 * | 1023 | 31,31 | 16,23 | LS2 |
641 * | | | 08-15 | LS1 |
642 * | | | 00-07 | LS0 |
643 * +----------- Page (Colour Plane) 1 -------------+
644 * | @mesh[i] | Mesh Point | Bits | Light Source |
645 * +-----------+------------+-------+--------------+
646 * | 1024 | 0,0 | 16,23 | LS2 |
647 * | | | 08-15 | LS1 |
648 * | | | 00-07 | LS0 |
649 * +-----------+------------+-------+--------------+
650 * | 1025 | 0,1 | 16,23 | LS2 |
651 * | | | 08-15 | LS1 |
652 * | | | 00-07 | LS0 |
653 * +-----------+------------+-------+--------------+
654 * | ... | ... | ... | ... |
655 * +-----------+------------+-------+--------------+
656 * | 2047 | 31,31 | 16,23 | LS2 |
657 * | | | 08-15 | LS1 |
658 * | | | 00-07 | LS0 |
659 * +----------- Page (Colour Plane) 2 -------------+
660 * | @mesh[i] | Mesh Point | Bits | Light Source |
661 * +-----------+------------+-------+--------------+
662 * | 2048 | 0,0 | 16,23 | LS2 |
663 * | | | 08-15 | LS1 |
664 * | | | 00-07 | LS0 |
665 * +-----------+------------+-------+--------------+
666 * | 2049 | 0,1 | 16,23 | LS2 |
667 * | | | 08-15 | LS1 |
668 * | | | 00-07 | LS0 |
669 * +-----------+------------+-------+--------------+
670 * | ... | ... | ... | ... |
671 * +-----------+------------+-------+--------------+
672 * | 3071 | 31,31 | 16,23 | LS2 |
673 * | | | 08-15 | LS1 |
674 * | | | 00-07 | LS0 |
675 * +-----------+------------+-------+--------------+
676 *
677 * The @mesh_scale member determines the precision and minimum and maximum gain.
678 * For example if @mesh_scale is 0 and therefore selects 0 - 2x gain, a value of
679 * 0 in a coefficient means 0.0 gain, a value of 128 means 1.0 gain and 255
680 * means 2.0 gain.
681 *
682 * header.type should be set to MALI_C55_PARAM_MESH_SHADING_CONFIG from
683 * :c:type:`mali_c55_param_block_type` for this block.
684 *
685 * @header: The Mali-C55 parameters block header
686 * @mesh_show: Output the mesh data rather than image data
687 * @mesh_scale: Set the precision and maximum gain range of mesh shading
688 * - 0 = 0-2x gain
689 * - 1 = 0-4x gain
690 * - 2 = 0-8x gain
691 * - 3 = 0-16x gain
692 * - 4 = 1-2x gain
693 * - 5 = 1-3x gain
694 * - 6 = 1-5x gain
695 * - 7 = 1-9x gain
696 * @mesh_page_r: Mesh page select for red colour plane [0..2]
697 * @mesh_page_g: Mesh page select for green colour plane [0..2]
698 * @mesh_page_b: Mesh page select for blue colour plane [0..2]
699 * @mesh_width: Number of horizontal nodes minus 1 [15,31]
700 * @mesh_height: Number of vertical nodes minus 1 [15,31]
701 * @mesh: Mesh shading correction tables
702 */
703struct mali_c55_params_mesh_shading_config {
704 struct v4l2_isp_params_block_header header;
705 __u8 mesh_show;
706 __u8 mesh_scale;
707 __u8 mesh_page_r;
708 __u8 mesh_page_g;
709 __u8 mesh_page_b;
710 __u8 mesh_width;
711 __u8 mesh_height;
712 __u32 mesh[MALI_C55_NUM_MESH_SHADING_ELEMENTS];
713};
714
715/** enum mali_c55_params_mesh_alpha_bank - Mesh shading table bank selection
716 * @MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS1 - Select Light Sources 0 and 1
717 * @MALI_C55_MESH_ALPHA_BANK_LS1_AND_LS2 - Select Light Sources 1 and 2
718 * @MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS2 - Select Light Sources 0 and 2
719 */
720enum mali_c55_params_mesh_alpha_bank {
721 MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS1 = 0,
722 MALI_C55_MESH_ALPHA_BANK_LS1_AND_LS2 = 1,
723 MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS2 = 4
724};
725
726/**
727 * struct mali_c55_params_mesh_shading_selection - Mesh table selection
728 *
729 * The module computes the final correction coefficients by blending the ones
730 * from two light source tables, which are selected (independently for each
731 * colour channel) by the @mesh_alpha_bank_r/g/b fields.
732 *
733 * The final blended coefficients for each node are calculated using the
734 * following equation:
735 *
736 * Final coefficient = (a * LS\ :sub:`b`\ + (256 - a) * LS\ :sub:`a`\) / 256
737 *
738 * Where a is the @mesh_alpha_r/g/b value, and LS\ :sub:`a`\ and LS\ :sub:`b`\
739 * are the node cofficients for the two tables selected by the
740 * @mesh_alpha_bank_r/g/b value.
741 *
742 * The scale of the applied correction may also be controlled by tuning the
743 * @mesh_strength member. This is a modifier to the final coefficients which can
744 * be used to globally reduce the gains applied.
745 *
746 * header.type should be set to MALI_C55_PARAM_MESH_SHADING_SELECTION from
747 * :c:type:`mali_c55_param_block_type` for this block.
748 *
749 * @header: The Mali-C55 parameters block header
750 * @mesh_alpha_bank_r: Red mesh table select (c:type:`enum mali_c55_params_mesh_alpha_bank`)
751 * @mesh_alpha_bank_g: Green mesh table select (c:type:`enum mali_c55_params_mesh_alpha_bank`)
752 * @mesh_alpha_bank_b: Blue mesh table select (c:type:`enum mali_c55_params_mesh_alpha_bank`)
753 * @mesh_alpha_r: Blend coefficient for R [0..255]
754 * @mesh_alpha_g: Blend coefficient for G [0..255]
755 * @mesh_alpha_b: Blend coefficient for B [0..255]
756 * @mesh_strength: Mesh strength in Q4.12 format [0..4096]
757 */
758struct mali_c55_params_mesh_shading_selection {
759 struct v4l2_isp_params_block_header header;
760 __u8 mesh_alpha_bank_r;
761 __u8 mesh_alpha_bank_g;
762 __u8 mesh_alpha_bank_b;
763 __u8 mesh_alpha_r;
764 __u8 mesh_alpha_g;
765 __u8 mesh_alpha_b;
766 __u16 mesh_strength;
767};
768
769/**
770 * define MALI_C55_PARAMS_MAX_SIZE - Maximum size of all Mali C55 Parameters
771 *
772 * Though the parameters for the Mali-C55 are passed as optional blocks, the
773 * driver still needs to know the absolute maximum size so that it can allocate
774 * a buffer sized appropriately to accommodate userspace attempting to set all
775 * possible parameters in a single frame.
776 *
777 * Some structs are in this list multiple times. Where that's the case, it just
778 * reflects the fact that the same struct can be used with multiple different
779 * header types from :c:type:`mali_c55_param_block_type`.
780 */
781#define MALI_C55_PARAMS_MAX_SIZE \
782 (sizeof(struct mali_c55_params_sensor_off_preshading) + \
783 sizeof(struct mali_c55_params_aexp_hist) + \
784 sizeof(struct mali_c55_params_aexp_weights) + \
785 sizeof(struct mali_c55_params_aexp_hist) + \
786 sizeof(struct mali_c55_params_aexp_weights) + \
787 sizeof(struct mali_c55_params_digital_gain) + \
788 sizeof(struct mali_c55_params_awb_gains) + \
789 sizeof(struct mali_c55_params_awb_config) + \
790 sizeof(struct mali_c55_params_awb_gains) + \
791 sizeof(struct mali_c55_params_mesh_shading_config) + \
792 sizeof(struct mali_c55_params_mesh_shading_selection))
793
794#endif /* __UAPI_MALI_C55_CONFIG_H */
include/uapi/linux/media/v4l2-isp.h+102−0
@@ -0,0 +1,102 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/*
3 * Video4Linux2 generic ISP parameters and statistics support
4 *
5 * Copyright (C) 2025 Ideas On Board Oy
6 * Author: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
7 */
8
9#ifndef _UAPI_V4L2_ISP_H_
10#define _UAPI_V4L2_ISP_H_
11
12#include <linux/stddef.h>
13#include <linux/types.h>
14
15/**
16 * enum v4l2_isp_params_version - V4L2 ISP parameters versioning
17 *
18 * @V4L2_ISP_PARAMS_VERSION_V0: First version of the V4L2 ISP parameters format
19 * (for compatibility)
20 * @V4L2_ISP_PARAMS_VERSION_V1: First version of the V4L2 ISP parameters format
21 *
22 * V0 and V1 are identical in order to support drivers compatible with the V4L2
23 * ISP parameters format already upstreamed which use either 0 or 1 as their
24 * versioning identifier. Both V0 and V1 refers to the first version of the
25 * V4L2 ISP parameters format.
26 *
27 * Future revisions of the V4L2 ISP parameters format should start from the
28 * value of 2.
29 */
30enum v4l2_isp_params_version {
31 V4L2_ISP_PARAMS_VERSION_V0 = 0,
32 V4L2_ISP_PARAMS_VERSION_V1
33};
34
35#define V4L2_ISP_PARAMS_FL_BLOCK_DISABLE (1U << 0)
36#define V4L2_ISP_PARAMS_FL_BLOCK_ENABLE (1U << 1)
37
38/*
39 * Reserve the first 8 bits for V4L2_ISP_PARAMS_FL_* flag.
40 *
41 * Driver-specific flags should be defined as:
42 * #define DRIVER_SPECIFIC_FLAG0 ((1U << V4L2_ISP_PARAMS_FL_DRIVER_FLAGS(0))
43 * #define DRIVER_SPECIFIC_FLAG1 ((1U << V4L2_ISP_PARAMS_FL_DRIVER_FLAGS(1))
44 */
45#define V4L2_ISP_PARAMS_FL_DRIVER_FLAGS(n) ((n) + 8)
46
47/**
48 * struct v4l2_isp_params_block_header - V4L2 extensible parameters block header
49 * @type: The parameters block type (driver-specific)
50 * @flags: A bitmask of block flags (driver-specific)
51 * @size: Size (in bytes) of the parameters block, including this header
52 *
53 * This structure represents the common part of all the ISP configuration
54 * blocks. Each parameters block shall embed an instance of this structure type
55 * as its first member, followed by the block-specific configuration data.
56 *
57 * The @type field is an ISP driver-specific value that identifies the block
58 * type. The @size field specifies the size of the parameters block.
59 *
60 * The @flags field is a bitmask of per-block flags V4L2_PARAMS_ISP_FL_* and
61 * driver-specific flags specified by the driver header.
62 */
63struct v4l2_isp_params_block_header {
64 __u16 type;
65 __u16 flags;
66 __u32 size;
67} __attribute__((aligned(8)));
68
69/**
70 * struct v4l2_isp_params_buffer - V4L2 extensible parameters configuration
71 * @version: The parameters buffer version (driver-specific)
72 * @data_size: The configuration data effective size, excluding this header
73 * @data: The configuration data
74 *
75 * This structure contains the configuration parameters of the ISP algorithms,
76 * serialized by userspace into a data buffer. Each configuration parameter
77 * block is represented by a block-specific structure which contains a
78 * :c:type:`v4l2_isp_params_block_header` entry as first member. Userspace
79 * populates the @data buffer with configuration parameters for the blocks that
80 * it intends to configure. As a consequence, the data buffer effective size
81 * changes according to the number of ISP blocks that userspace intends to
82 * configure and is set by userspace in the @data_size field.
83 *
84 * The parameters buffer is versioned by the @version field to allow modifying
85 * and extending its definition. Userspace shall populate the @version field to
86 * inform the driver about the version it intends to use. The driver will parse
87 * and handle the @data buffer according to the data layout specific to the
88 * indicated version and return an error if the desired version is not
89 * supported.
90 *
91 * For each ISP block that userspace wants to configure, a block-specific
92 * structure is appended to the @data buffer, one after the other without gaps
93 * in between. Userspace shall populate the @data_size field with the effective
94 * size, in bytes, of the @data buffer.
95 */
96struct v4l2_isp_params_buffer {
97 __u32 version;
98 __u32 data_size;
99 __u8 data[] __counted_by(data_size);
100};
101
102#endif /* _UAPI_V4L2_ISP_H_ */
include/uapi/linux/rkisp1-config.h+24−83
@@ -7,8 +7,13 @@ · 6 unmodified lines
7#ifndef _UAPI_RKISP1_CONFIG_H7#ifndef _UAPI_RKISP1_CONFIG_H
8#define _UAPI_RKISP1_CONFIG_H8#define _UAPI_RKISP1_CONFIG_H
9 9
10#ifdef __KERNEL__
11#include <linux/build_bug.h>
12#endif /* __KERNEL__ */
10#include <linux/types.h>13#include <linux/types.h>
11 14
15#include <linux/media/v4l2-isp.h>
16
12/* Defect Pixel Cluster Detection */17/* Defect Pixel Cluster Detection */
13#define RKISP1_CIF_ISP_MODULE_DPCC (1U << 0)18#define RKISP1_CIF_ISP_MODULE_DPCC (1U << 0)
14/* Black Level Subtraction */19/* Black Level Subtraction */
@@ -1158,79 +1163,26 @@ enum rkisp1_ext_params_block_type { · 1143 unmodified lines
1158 RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR,1163 RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR,
1159};1164};
1160 1165
1161#define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE (1U << 0)1166/* For backward compatibility */
1162#define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE (1U << 1)1167#define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE V4L2_ISP_PARAMS_FL_BLOCK_DISABLE
1168#define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE V4L2_ISP_PARAMS_FL_BLOCK_ENABLE
1163 1169
1164/* A bitmask of parameters blocks supported on the current hardware. */1170/* A bitmask of parameters blocks supported on the current hardware. */
1165#define RKISP1_CID_SUPPORTED_PARAMS_BLOCKS (V4L2_CID_USER_RKISP1_BASE + 0x01)1171#define RKISP1_CID_SUPPORTED_PARAMS_BLOCKS (V4L2_CID_USER_RKISP1_BASE + 0x01)
1166 1172
1167/**1173/**
1168 * struct rkisp1_ext_params_block_header - RkISP1 extensible parameters block1174 * rkisp1_ext_params_block_header - RkISP1 extensible parameters block header
1169 * header
1170 *1175 *
1171 * This structure represents the common part of all the ISP configuration1176 * This structure represents the common part of all the ISP configuration
1172 * blocks. Each parameters block shall embed an instance of this structure type1177 * blocks and is identical to :c:type:`v4l2_isp_params_block_header`.
1173 * as its first member, followed by the block-specific configuration data. The
1174 * driver inspects this common header to discern the block type and its size and
1175 * properly handle the block content by casting it to the correct block-specific
1176 * type.
1177 *1178 *
1178 * The @type field is one of the values enumerated by1179 * The type field is one of the values enumerated by
1179 * :c:type:`rkisp1_ext_params_block_type` and specifies how the data should be1180 * :c:type:`rkisp1_ext_params_block_type` and specifies how the data should be
1180 * interpreted by the driver. The @size field specifies the size of the1181 * interpreted by the driver.
1181 * parameters block and is used by the driver for validation purposes.
1182 *
1183 * The @flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*.
1184 *
1185 * When userspace wants to configure and enable an ISP block it shall fully
1186 * populate the block configuration and set the
1187 * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE bit in the @flags field.
1188 *
1189 * When userspace simply wants to disable an ISP block the
1190 * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bit should be set in @flags field. The
1191 * driver ignores the rest of the block configuration structure in this case.
1192 *
1193 * If a new configuration of an ISP block has to be applied userspace shall
1194 * fully populate the ISP block configuration and omit setting the
1195 * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits
1196 * in the @flags field.
1197 *
1198 * Setting both the RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and
1199 * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits in the @flags field is not allowed
1200 * and not accepted by the driver.
1201 *
1202 * Userspace is responsible for correctly populating the parameters block header
1203 * fields (@type, @flags and @size) and the block-specific parameters.
1204 *
1205 * For example:
1206 *1182 *
1207 * .. code-block:: c1183 * The flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*.
1208 *
1209 * void populate_bls(struct rkisp1_ext_params_block_header *block) {
1210 * struct rkisp1_ext_params_bls_config *bls =
1211 * (struct rkisp1_ext_params_bls_config *)block;
1212 *
1213 * bls->header.type = RKISP1_EXT_PARAMS_BLOCK_ID_BLS;
1214 * bls->header.flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE;
1215 * bls->header.size = sizeof(*bls);
1216 *
1217 * bls->config.enable_auto = 0;
1218 * bls->config.fixed_val.r = blackLevelRed_;
1219 * bls->config.fixed_val.gr = blackLevelGreenR_;
1220 * bls->config.fixed_val.gb = blackLevelGreenB_;
1221 * bls->config.fixed_val.b = blackLevelBlue_;
1222 * }
1223 *
1224 * @type: The parameters block type, see
1225 * :c:type:`rkisp1_ext_params_block_type`
1226 * @flags: A bitmask of block flags
1227 * @size: Size (in bytes) of the parameters block, including this header
1228 */1184 */
1229struct rkisp1_ext_params_block_header {1185#define rkisp1_ext_params_block_header v4l2_isp_params_block_header
1230 __u16 type;
1231 __u16 flags;
1232 __u32 size;
1233};
1234 1186
1235/**1187/**
1236 * struct rkisp1_ext_params_bls_config - RkISP1 extensible params BLS config1188 * struct rkisp1_ext_params_bls_config - RkISP1 extensible params BLS config
@@ -1588,27 +1540,14 @@ struct rkisp1_ext_params_wdr_config { · 351 unmodified lines
1588 * @RKISP1_EXT_PARAM_BUFFER_V1: First version of RkISP1 extensible parameters1540 * @RKISP1_EXT_PARAM_BUFFER_V1: First version of RkISP1 extensible parameters
1589 */1541 */
1590enum rksip1_ext_param_buffer_version {1542enum rksip1_ext_param_buffer_version {
1591 RKISP1_EXT_PARAM_BUFFER_V1 = 1,1543 RKISP1_EXT_PARAM_BUFFER_V1 = V4L2_ISP_PARAMS_VERSION_V1,
1592};1544};
1593 1545
1594/**1546/**
1595 * struct rkisp1_ext_params_cfg - RkISP1 extensible parameters configuration1547 * struct rkisp1_ext_params_cfg - RkISP1 extensible parameters configuration
1596 *1548 *
1597 * This struct contains the configuration parameters of the RkISP1 ISP1549 * This is the driver-specific implementation of
1598 * algorithms, serialized by userspace into a data buffer. Each configuration1550 * :c:type:`v4l2_isp_params_buffer`.
1599 * parameter block is represented by a block-specific structure which contains a
1600 * :c:type:`rkisp1_ext_params_block_header` entry as first member. Userspace
1601 * populates the @data buffer with configuration parameters for the blocks that
1602 * it intends to configure. As a consequence, the data buffer effective size
1603 * changes according to the number of ISP blocks that userspace intends to
1604 * configure and is set by userspace in the @data_size field.
1605 *
1606 * The parameters buffer is versioned by the @version field to allow modifying
1607 * and extending its definition. Userspace shall populate the @version field to
1608 * inform the driver about the version it intends to use. The driver will parse
1609 * and handle the @data buffer according to the data layout specific to the
1610 * indicated version and return an error if the desired version is not
1611 * supported.
1612 *1551 *
1613 * Currently the single RKISP1_EXT_PARAM_BUFFER_V1 version is supported.1552 * Currently the single RKISP1_EXT_PARAM_BUFFER_V1 version is supported.
1614 * When a new format version will be added, a mechanism for userspace to query1553 * When a new format version will be added, a mechanism for userspace to query
@@ -1624,11 +1563,6 @@ enum rksip1_ext_param_buffer_version { · 9 unmodified lines
1624 * the maximum value represents the blocks supported by the kernel driver,1563 * the maximum value represents the blocks supported by the kernel driver,
1625 * independently of the device instance.1564 * independently of the device instance.
1626 *1565 *
1627 * For each ISP block that userspace wants to configure, a block-specific
1628 * structure is appended to the @data buffer, one after the other without gaps
1629 * in between nor overlaps. Userspace shall populate the @data_size field with
1630 * the effective size, in bytes, of the @data buffer.
1631 *
1632 * The expected memory layout of the parameters buffer is::1566 * The expected memory layout of the parameters buffer is::
1633 *1567 *
1634 * +-------------------- struct rkisp1_ext_params_cfg -------------------+1568 * +-------------------- struct rkisp1_ext_params_cfg -------------------+
@@ -1678,4 +1612,11 @@ struct rkisp1_ext_params_cfg { · 43 unmodified lines
1678 __u8 data[RKISP1_EXT_PARAMS_MAX_SIZE];1612 __u8 data[RKISP1_EXT_PARAMS_MAX_SIZE];
1679};1613};
1680 1614
1615#ifdef __KERNEL__
1616/* Make sure the header is type-convertible to the generic v4l2 params one */
1617static_assert((sizeof(struct rkisp1_ext_params_cfg) -
1618 RKISP1_EXT_PARAMS_MAX_SIZE) ==
1619 sizeof(struct v4l2_isp_params_buffer));
1620#endif /* __KERNEL__ */
1621
1681#endif /* _UAPI_RKISP1_CONFIG_H */1622#endif /* _UAPI_RKISP1_CONFIG_H */
include/uapi/linux/v4l2-controls.h+6−0
@@ -228,6 +228,12 @@ enum v4l2_colorfx { · 227 unmodified lines
228 */228 */
229#define V4L2_CID_USER_RKISP1_BASE (V4L2_CID_USER_BASE + 0x1220)229#define V4L2_CID_USER_RKISP1_BASE (V4L2_CID_USER_BASE + 0x1220)
230 230
231/*
232 * The base for the Arm Mali-C55 ISP driver controls.
233 * We reserve 16 controls for this driver
234 */
235#define V4L2_CID_USER_MALI_C55_BASE (V4L2_CID_USER_BASE + 0x1230)
236
231/* MPEG-class control IDs */237/* MPEG-class control IDs */
232/* The MPEG controls are applicable to all codec controls238/* The MPEG controls are applicable to all codec controls
233 * and the 'MPEG' part of the define is historical */239 * and the 'MPEG' part of the define is historical */
include/uapi/linux/videodev2.h+4−0
@@ -884,6 +884,10 @@ struct v4l2_pix_format { · 883 unmodified lines
884#define V4L2_META_FMT_RPI_FE_CFG v4l2_fourcc('R', 'P', 'F', 'C') /* PiSP FE configuration */884#define V4L2_META_FMT_RPI_FE_CFG v4l2_fourcc('R', 'P', 'F', 'C') /* PiSP FE configuration */
885#define V4L2_META_FMT_RPI_FE_STATS v4l2_fourcc('R', 'P', 'F', 'S') /* PiSP FE stats */885#define V4L2_META_FMT_RPI_FE_STATS v4l2_fourcc('R', 'P', 'F', 'S') /* PiSP FE stats */
886 886
887/* Vendor specific - used for Arm Mali-C55 ISP */
888#define V4L2_META_FMT_MALI_C55_PARAMS v4l2_fourcc('C', '5', '5', 'P') /* ARM Mali-C55 Parameters */
889#define V4L2_META_FMT_MALI_C55_STATS v4l2_fourcc('C', '5', '5', 'S') /* ARM Mali-C55 3A Statistics */
890
887#ifdef __KERNEL__891#ifdef __KERNEL__
888/*892/*
889 * Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when893 * Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when