1 From b5d50012157f909eff0e8775c1e040b7dfde0705 Mon Sep 17 00:00:00 2001
2 From: Naushir Patuck <naush@raspberrypi.com>
3 Date: Thu, 23 Apr 2020 10:18:15 +0100
4 Subject: [PATCH] uapi: bcm2835-isp: Add bcm2835-isp uapi header file
6 This file defines the userland interface to the bcm2835-isp driver
7 that will follow in a separate commit.
9 Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
11 include/uapi/linux/bcm2835-isp.h | 320 +++++++++++++++++++++++++++++++
12 1 file changed, 320 insertions(+)
13 create mode 100644 include/uapi/linux/bcm2835-isp.h
16 +++ b/include/uapi/linux/bcm2835-isp.h
18 +/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) */
22 + * BCM2835 ISP driver - user space header file.
24 + * Copyright © 2019-2020 Raspberry Pi (Trading) Ltd.
26 + * Author: Naushir Patuck (naush@raspberrypi.com)
30 +#ifndef __BCM2835_ISP_H_
31 +#define __BCM2835_ISP_H_
33 +#include <linux/v4l2-controls.h>
35 +#define V4L2_CID_USER_BCM2835_ISP_CC_MATRIX \
36 + (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0001)
37 +#define V4L2_CID_USER_BCM2835_ISP_LENS_SHADING \
38 + (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0002)
39 +#define V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL \
40 + (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0003)
41 +#define V4L2_CID_USER_BCM2835_ISP_GEQ \
42 + (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0004)
43 +#define V4L2_CID_USER_BCM2835_ISP_GAMMA \
44 + (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0005)
45 +#define V4L2_CID_USER_BCM2835_ISP_DENOISE \
46 + (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0006)
47 +#define V4L2_CID_USER_BCM2835_ISP_SHARPEN \
48 + (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0007)
49 +#define V4L2_CID_USER_BCM2835_ISP_DPC \
50 + (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0008)
53 + * All structs below are directly mapped onto the equivalent structs in
54 + * drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h
59 + * struct bcm2835_isp_rational - Rational value type.
62 + * @den: Denominator.
64 +struct bcm2835_isp_rational {
70 + * struct bcm2835_isp_ccm - Colour correction matrix.
72 + * @ccm: 3x3 correction matrix coefficients.
73 + * @offsets: 1x3 correction offsets.
75 +struct bcm2835_isp_ccm {
76 + struct bcm2835_isp_rational ccm[3][3];
81 + * struct bcm2835_isp_custom_ccm - Custom CCM applied with the
82 + * V4L2_CID_USER_BCM2835_ISP_CC_MATRIX ctrl.
84 + * @enabled: Enable custom CCM.
85 + * @ccm: Custom CCM coefficients and offsets.
87 +struct bcm2835_isp_custom_ccm {
89 + struct bcm2835_isp_ccm ccm;
93 + * enum bcm2835_isp_gain_format - format of the gains in the lens shading
94 + * tables used with the
95 + * V4L2_CID_USER_BCM2835_ISP_LENS_SHADING ctrl.
97 + * @GAIN_FORMAT_U0P8_1: Gains are u0.8 format, starting at 1.0
98 + * @GAIN_FORMAT_U1P7_0: Gains are u1.7 format, starting at 0.0
99 + * @GAIN_FORMAT_U1P7_1: Gains are u1.7 format, starting at 1.0
100 + * @GAIN_FORMAT_U2P6_0: Gains are u2.6 format, starting at 0.0
101 + * @GAIN_FORMAT_U2P6_1: Gains are u2.6 format, starting at 1.0
102 + * @GAIN_FORMAT_U3P5_0: Gains are u3.5 format, starting at 0.0
103 + * @GAIN_FORMAT_U3P5_1: Gains are u3.5 format, starting at 1.0
104 + * @GAIN_FORMAT_U4P10: Gains are u4.10 format, starting at 0.0
106 +enum bcm2835_isp_gain_format {
107 + GAIN_FORMAT_U0P8_1 = 0,
108 + GAIN_FORMAT_U1P7_0 = 1,
109 + GAIN_FORMAT_U1P7_1 = 2,
110 + GAIN_FORMAT_U2P6_0 = 3,
111 + GAIN_FORMAT_U2P6_1 = 4,
112 + GAIN_FORMAT_U3P5_0 = 5,
113 + GAIN_FORMAT_U3P5_1 = 6,
114 + GAIN_FORMAT_U4P10 = 7,
118 + * struct bcm2835_isp_lens_shading - Lens shading tables supplied with the
119 + * V4L2_CID_USER_BCM2835_ISP_LENS_SHADING
122 + * @enabled: Enable lens shading.
123 + * @grid_cell_size: Size of grid cells in samples (16, 32, 64, 128 or 256).
124 + * @grid_width: Width of lens shading tables in grid cells.
125 + * @grid_stride: Row to row distance (in grid cells) between grid cells
126 + * in the same horizontal location.
127 + * @grid_height: Height of lens shading tables in grid cells.
128 + * @mem_handle_table: Memory handle to the tables.
129 + * @ref_transform: Reference transform - unsupported, please pass zero.
130 + * @corner_sampled: Whether the gains are sampled at the corner points
131 + * of the grid cells or in the cell centres.
132 + * @gain_format: Format of the gains (see enum &bcm2835_isp_gain_format).
134 +struct bcm2835_isp_lens_shading {
136 + __u32 grid_cell_size;
140 + __u32 mem_handle_table;
141 + __u32 ref_transform;
142 + __u32 corner_sampled;
147 + * struct bcm2835_isp_black_level - Sensor black level set with the
148 + * V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL ctrl.
150 + * @enabled: Enable black level.
151 + * @black_level_r: Black level for red channel.
152 + * @black_level_g: Black level for green channels.
153 + * @black_level_b: Black level for blue channel.
155 +struct bcm2835_isp_black_level {
157 + __u16 black_level_r;
158 + __u16 black_level_g;
159 + __u16 black_level_b;
160 + __u8 pad_[2]; /* Unused */
164 + * struct bcm2835_isp_geq - Green equalisation parameters set with the
165 + * V4L2_CID_USER_BCM2835_ISP_GEQ ctrl.
167 + * @enabled: Enable green equalisation.
168 + * @offset: Fixed offset of the green equalisation threshold.
169 + * @slope: Slope of the green equalisation threshold.
171 +struct bcm2835_isp_geq {
174 + struct bcm2835_isp_rational slope;
177 +#define BCM2835_NUM_GAMMA_PTS 33
180 + * struct bcm2835_isp_gamma - Gamma parameters set with the
181 + * V4L2_CID_USER_BCM2835_ISP_GAMMA ctrl.
183 + * @enabled: Enable gamma adjustment.
184 + * @X: X values of the points defining the gamma curve.
185 + * Values should be scaled to 16 bits.
186 + * @Y: Y values of the points defining the gamma curve.
187 + * Values should be scaled to 16 bits.
189 +struct bcm2835_isp_gamma {
191 + __u16 x[BCM2835_NUM_GAMMA_PTS];
192 + __u16 y[BCM2835_NUM_GAMMA_PTS];
196 + * struct bcm2835_isp_denoise - Denoise parameters set with the
197 + * V4L2_CID_USER_BCM2835_ISP_DENOISE ctrl.
199 + * @enabled: Enable denoise.
200 + * @constant: Fixed offset of the noise threshold.
201 + * @slope: Slope of the noise threshold.
202 + * @strength: Denoise strength between 0.0 (off) and 1.0 (maximum).
204 +struct bcm2835_isp_denoise {
207 + struct bcm2835_isp_rational slope;
208 + struct bcm2835_isp_rational strength;
212 + * struct bcm2835_isp_sharpen - Sharpen parameters set with the
213 + * V4L2_CID_USER_BCM2835_ISP_SHARPEN ctrl.
215 + * @enabled: Enable sharpening.
216 + * @threshold: Threshold at which to start sharpening pixels.
217 + * @strength: Strength with which pixel sharpening increases.
218 + * @limit: Limit to the amount of sharpening applied.
220 +struct bcm2835_isp_sharpen {
222 + struct bcm2835_isp_rational threshold;
223 + struct bcm2835_isp_rational strength;
224 + struct bcm2835_isp_rational limit;
228 + * enum bcm2835_isp_dpc_mode - defective pixel correction (DPC) strength.
230 + * @DPC_MODE_OFF: No DPC.
231 + * @DPC_MODE_NORMAL: Normal DPC.
232 + * @DPC_MODE_STRONG: Strong DPC.
234 +enum bcm2835_isp_dpc_mode {
236 + DPC_MODE_NORMAL = 1,
237 + DPC_MODE_STRONG = 2,
241 + * struct bcm2835_isp_dpc - Defective pixel correction (DPC) parameters set
242 + * with the V4L2_CID_USER_BCM2835_ISP_DPC ctrl.
244 + * @enabled: Enable DPC.
245 + * @strength: DPC strength (see enum &bcm2835_isp_dpc_mode).
247 +struct bcm2835_isp_dpc {
253 + * ISP statistics structures.
255 + * The bcm2835_isp_stats structure is generated at the output of the
256 + * statistics node. Note that this does not directly map onto the statistics
257 + * output of the ISP HW. Instead, the MMAL firmware code maps the HW statistics
258 + * to the bcm2835_isp_stats structure.
260 +#define DEFAULT_AWB_REGIONS_X 16
261 +#define DEFAULT_AWB_REGIONS_Y 12
263 +#define NUM_HISTOGRAMS 2
264 +#define NUM_HISTOGRAM_BINS 128
265 +#define AWB_REGIONS (DEFAULT_AWB_REGIONS_X * DEFAULT_AWB_REGIONS_Y)
266 +#define FLOATING_REGIONS 16
267 +#define AGC_REGIONS 16
268 +#define FOCUS_REGIONS 12
271 + * struct bcm2835_isp_stats_hist - Histogram statistics
273 + * @r_hist: Red channel histogram.
274 + * @g_hist: Combined green channel histogram.
275 + * @b_hist: Blue channel histogram.
277 +struct bcm2835_isp_stats_hist {
278 + __u32 r_hist[NUM_HISTOGRAM_BINS];
279 + __u32 g_hist[NUM_HISTOGRAM_BINS];
280 + __u32 b_hist[NUM_HISTOGRAM_BINS];
284 + * struct bcm2835_isp_stats_region - Region sums.
286 + * @counted: The number of 2x2 bayer tiles accumulated.
287 + * @notcounted: The number of 2x2 bayer tiles not accumulated.
288 + * @r_sum: Total sum of counted pixels in the red channel for a region.
289 + * @g_sum: Total sum of counted pixels in the green channel for a region.
290 + * @b_sum: Total sum of counted pixels in the blue channel for a region.
292 +struct bcm2835_isp_stats_region {
301 + * struct bcm2835_isp_stats_focus - Focus statistics.
303 + * @contrast_val: Focus measure - accumulated output of the focus filter.
304 + * In the first dimension, index [0] counts pixels below a
305 + * preset threshold, and index [1] counts pixels above the
306 + * threshold. In the second dimension, index [0] uses the
307 + * first predefined filter, and index [1] uses the second
308 + * predefined filter.
309 + * @contrast_val_num: The number of counted pixels in the above accumulation.
311 +struct bcm2835_isp_stats_focus {
312 + __u64 contrast_val[2][2];
313 + __u32 contrast_val_num[2][2];
317 + * struct bcm2835_isp_stats - ISP statistics.
319 + * @version: Version of the bcm2835_isp_stats structure.
320 + * @size: Size of the bcm2835_isp_stats structure.
321 + * @hist: Histogram statistics for the entire image.
322 + * @awb_stats: Statistics for the regions defined for AWB calculations.
323 + * @floating_stats: Statistics for arbitrarily placed (floating) regions.
324 + * @agc_stats: Statistics for the regions defined for AGC calculations.
325 + * @focus_stats: Focus filter statistics for the focus regions.
327 +struct bcm2835_isp_stats {
330 + struct bcm2835_isp_stats_hist hist[NUM_HISTOGRAMS];
331 + struct bcm2835_isp_stats_region awb_stats[AWB_REGIONS];
332 + struct bcm2835_isp_stats_region floating_stats[FLOATING_REGIONS];
333 + struct bcm2835_isp_stats_region agc_stats[AGC_REGIONS];
334 + struct bcm2835_isp_stats_focus focus_stats[FOCUS_REGIONS];
337 +#endif /* __BCM2835_ISP_H_ */