Skip to content

Commit 0676f46

Browse files
6by9popcornmix
authored andcommitted
uapi: bcm2835-isp: Add bcm2835-isp uapi header file
This file defines the userland interface to the bcm2835-isp driver that will follow in a separate commit. Signed-off-by: Naushir Patuck <[email protected]> Signed-off-by: Dave Stevenson <[email protected]>
1 parent e3f49c7 commit 0676f46

File tree

1 file changed

+320
-0
lines changed

1 file changed

+320
-0
lines changed

include/uapi/linux/bcm2835-isp.h

Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,320 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) */
2+
/*
3+
* bcm2835-isp.h
4+
*
5+
* BCM2835 ISP driver - user space header file.
6+
*
7+
* Copyright © 2019-2020 Raspberry Pi (Trading) Ltd.
8+
*
9+
* Author: Naushir Patuck ([email protected])
10+
*
11+
*/
12+
13+
#ifndef __BCM2835_ISP_H_
14+
#define __BCM2835_ISP_H_
15+
16+
#include <linux/v4l2-controls.h>
17+
18+
#define V4L2_CID_USER_BCM2835_ISP_CC_MATRIX \
19+
(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0001)
20+
#define V4L2_CID_USER_BCM2835_ISP_LENS_SHADING \
21+
(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0002)
22+
#define V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL \
23+
(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0003)
24+
#define V4L2_CID_USER_BCM2835_ISP_GEQ \
25+
(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0004)
26+
#define V4L2_CID_USER_BCM2835_ISP_GAMMA \
27+
(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0005)
28+
#define V4L2_CID_USER_BCM2835_ISP_DENOISE \
29+
(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0006)
30+
#define V4L2_CID_USER_BCM2835_ISP_SHARPEN \
31+
(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0007)
32+
#define V4L2_CID_USER_BCM2835_ISP_DPC \
33+
(V4L2_CID_USER_BCM2835_ISP_BASE + 0x0008)
34+
35+
/*
36+
* All structs below are directly mapped onto the equivalent structs in
37+
* drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h
38+
* for convenience.
39+
*/
40+
41+
/**
42+
* struct bcm2835_isp_rational - Rational value type.
43+
*
44+
* @num: Numerator.
45+
* @den: Denominator.
46+
*/
47+
struct bcm2835_isp_rational {
48+
__s32 num;
49+
__u32 den;
50+
};
51+
52+
/**
53+
* struct bcm2835_isp_ccm - Colour correction matrix.
54+
*
55+
* @ccm: 3x3 correction matrix coefficients.
56+
* @offsets: 1x3 correction offsets.
57+
*/
58+
struct bcm2835_isp_ccm {
59+
struct bcm2835_isp_rational ccm[3][3];
60+
__s32 offsets[3];
61+
};
62+
63+
/**
64+
* struct bcm2835_isp_custom_ccm - Custom CCM applied with the
65+
* V4L2_CID_USER_BCM2835_ISP_CC_MATRIX ctrl.
66+
*
67+
* @enabled: Enable custom CCM.
68+
* @ccm: Custom CCM coefficients and offsets.
69+
*/
70+
struct bcm2835_isp_custom_ccm {
71+
__u32 enabled;
72+
struct bcm2835_isp_ccm ccm;
73+
};
74+
75+
/**
76+
* enum bcm2835_isp_gain_format - format of the gains in the lens shading
77+
* tables used with the
78+
* V4L2_CID_USER_BCM2835_ISP_LENS_SHADING ctrl.
79+
*
80+
* @GAIN_FORMAT_U0P8_1: Gains are u0.8 format, starting at 1.0
81+
* @GAIN_FORMAT_U1P7_0: Gains are u1.7 format, starting at 0.0
82+
* @GAIN_FORMAT_U1P7_1: Gains are u1.7 format, starting at 1.0
83+
* @GAIN_FORMAT_U2P6_0: Gains are u2.6 format, starting at 0.0
84+
* @GAIN_FORMAT_U2P6_1: Gains are u2.6 format, starting at 1.0
85+
* @GAIN_FORMAT_U3P5_0: Gains are u3.5 format, starting at 0.0
86+
* @GAIN_FORMAT_U3P5_1: Gains are u3.5 format, starting at 1.0
87+
* @GAIN_FORMAT_U4P10: Gains are u4.10 format, starting at 0.0
88+
*/
89+
enum bcm2835_isp_gain_format {
90+
GAIN_FORMAT_U0P8_1 = 0,
91+
GAIN_FORMAT_U1P7_0 = 1,
92+
GAIN_FORMAT_U1P7_1 = 2,
93+
GAIN_FORMAT_U2P6_0 = 3,
94+
GAIN_FORMAT_U2P6_1 = 4,
95+
GAIN_FORMAT_U3P5_0 = 5,
96+
GAIN_FORMAT_U3P5_1 = 6,
97+
GAIN_FORMAT_U4P10 = 7,
98+
};
99+
100+
/**
101+
* struct bcm2835_isp_lens_shading - Lens shading tables supplied with the
102+
* V4L2_CID_USER_BCM2835_ISP_LENS_SHADING
103+
* ctrl.
104+
*
105+
* @enabled: Enable lens shading.
106+
* @grid_cell_size: Size of grid cells in samples (16, 32, 64, 128 or 256).
107+
* @grid_width: Width of lens shading tables in grid cells.
108+
* @grid_stride: Row to row distance (in grid cells) between grid cells
109+
* in the same horizontal location.
110+
* @grid_height: Height of lens shading tables in grid cells.
111+
* @dmabuf: dmabuf file handle containing the table.
112+
* @ref_transform: Reference transform - unsupported, please pass zero.
113+
* @corner_sampled: Whether the gains are sampled at the corner points
114+
* of the grid cells or in the cell centres.
115+
* @gain_format: Format of the gains (see enum &bcm2835_isp_gain_format).
116+
*/
117+
struct bcm2835_isp_lens_shading {
118+
__u32 enabled;
119+
__u32 grid_cell_size;
120+
__u32 grid_width;
121+
__u32 grid_stride;
122+
__u32 grid_height;
123+
__s32 dmabuf;
124+
__u32 ref_transform;
125+
__u32 corner_sampled;
126+
__u32 gain_format;
127+
};
128+
129+
/**
130+
* struct bcm2835_isp_black_level - Sensor black level set with the
131+
* V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL ctrl.
132+
*
133+
* @enabled: Enable black level.
134+
* @black_level_r: Black level for red channel.
135+
* @black_level_g: Black level for green channels.
136+
* @black_level_b: Black level for blue channel.
137+
*/
138+
struct bcm2835_isp_black_level {
139+
__u32 enabled;
140+
__u16 black_level_r;
141+
__u16 black_level_g;
142+
__u16 black_level_b;
143+
__u8 padding[2]; /* Unused */
144+
};
145+
146+
/**
147+
* struct bcm2835_isp_geq - Green equalisation parameters set with the
148+
* V4L2_CID_USER_BCM2835_ISP_GEQ ctrl.
149+
*
150+
* @enabled: Enable green equalisation.
151+
* @offset: Fixed offset of the green equalisation threshold.
152+
* @slope: Slope of the green equalisation threshold.
153+
*/
154+
struct bcm2835_isp_geq {
155+
__u32 enabled;
156+
__u32 offset;
157+
struct bcm2835_isp_rational slope;
158+
};
159+
160+
#define BCM2835_NUM_GAMMA_PTS 33
161+
162+
/**
163+
* struct bcm2835_isp_gamma - Gamma parameters set with the
164+
* V4L2_CID_USER_BCM2835_ISP_GAMMA ctrl.
165+
*
166+
* @enabled: Enable gamma adjustment.
167+
* @X: X values of the points defining the gamma curve.
168+
* Values should be scaled to 16 bits.
169+
* @Y: Y values of the points defining the gamma curve.
170+
* Values should be scaled to 16 bits.
171+
*/
172+
struct bcm2835_isp_gamma {
173+
__u32 enabled;
174+
__u16 x[BCM2835_NUM_GAMMA_PTS];
175+
__u16 y[BCM2835_NUM_GAMMA_PTS];
176+
};
177+
178+
/**
179+
* struct bcm2835_isp_denoise - Denoise parameters set with the
180+
* V4L2_CID_USER_BCM2835_ISP_DENOISE ctrl.
181+
*
182+
* @enabled: Enable denoise.
183+
* @constant: Fixed offset of the noise threshold.
184+
* @slope: Slope of the noise threshold.
185+
* @strength: Denoise strength between 0.0 (off) and 1.0 (maximum).
186+
*/
187+
struct bcm2835_isp_denoise {
188+
__u32 enabled;
189+
__u32 constant;
190+
struct bcm2835_isp_rational slope;
191+
struct bcm2835_isp_rational strength;
192+
};
193+
194+
/**
195+
* struct bcm2835_isp_sharpen - Sharpen parameters set with the
196+
* V4L2_CID_USER_BCM2835_ISP_SHARPEN ctrl.
197+
*
198+
* @enabled: Enable sharpening.
199+
* @threshold: Threshold at which to start sharpening pixels.
200+
* @strength: Strength with which pixel sharpening increases.
201+
* @limit: Limit to the amount of sharpening applied.
202+
*/
203+
struct bcm2835_isp_sharpen {
204+
__u32 enabled;
205+
struct bcm2835_isp_rational threshold;
206+
struct bcm2835_isp_rational strength;
207+
struct bcm2835_isp_rational limit;
208+
};
209+
210+
/**
211+
* enum bcm2835_isp_dpc_mode - defective pixel correction (DPC) strength.
212+
*
213+
* @DPC_MODE_OFF: No DPC.
214+
* @DPC_MODE_NORMAL: Normal DPC.
215+
* @DPC_MODE_STRONG: Strong DPC.
216+
*/
217+
enum bcm2835_isp_dpc_mode {
218+
DPC_MODE_OFF = 0,
219+
DPC_MODE_NORMAL = 1,
220+
DPC_MODE_STRONG = 2,
221+
};
222+
223+
/**
224+
* struct bcm2835_isp_dpc - Defective pixel correction (DPC) parameters set
225+
* with the V4L2_CID_USER_BCM2835_ISP_DPC ctrl.
226+
*
227+
* @enabled: Enable DPC.
228+
* @strength: DPC strength (see enum &bcm2835_isp_dpc_mode).
229+
*/
230+
struct bcm2835_isp_dpc {
231+
__u32 enabled;
232+
__u32 strength;
233+
};
234+
235+
/*
236+
* ISP statistics structures.
237+
*
238+
* The bcm2835_isp_stats structure is generated at the output of the
239+
* statistics node. Note that this does not directly map onto the statistics
240+
* output of the ISP HW. Instead, the MMAL firmware code maps the HW statistics
241+
* to the bcm2835_isp_stats structure.
242+
*/
243+
#define DEFAULT_AWB_REGIONS_X 16
244+
#define DEFAULT_AWB_REGIONS_Y 12
245+
246+
#define NUM_HISTOGRAMS 2
247+
#define NUM_HISTOGRAM_BINS 128
248+
#define AWB_REGIONS (DEFAULT_AWB_REGIONS_X * DEFAULT_AWB_REGIONS_Y)
249+
#define FLOATING_REGIONS 16
250+
#define AGC_REGIONS 16
251+
#define FOCUS_REGIONS 12
252+
253+
/**
254+
* struct bcm2835_isp_stats_hist - Histogram statistics
255+
*
256+
* @r_hist: Red channel histogram.
257+
* @g_hist: Combined green channel histogram.
258+
* @b_hist: Blue channel histogram.
259+
*/
260+
struct bcm2835_isp_stats_hist {
261+
__u32 r_hist[NUM_HISTOGRAM_BINS];
262+
__u32 g_hist[NUM_HISTOGRAM_BINS];
263+
__u32 b_hist[NUM_HISTOGRAM_BINS];
264+
};
265+
266+
/**
267+
* struct bcm2835_isp_stats_region - Region sums.
268+
*
269+
* @counted: The number of 2x2 bayer tiles accumulated.
270+
* @notcounted: The number of 2x2 bayer tiles not accumulated.
271+
* @r_sum: Total sum of counted pixels in the red channel for a region.
272+
* @g_sum: Total sum of counted pixels in the green channel for a region.
273+
* @b_sum: Total sum of counted pixels in the blue channel for a region.
274+
*/
275+
struct bcm2835_isp_stats_region {
276+
__u32 counted;
277+
__u32 notcounted;
278+
__u64 r_sum;
279+
__u64 g_sum;
280+
__u64 b_sum;
281+
};
282+
283+
/**
284+
* struct bcm2835_isp_stats_focus - Focus statistics.
285+
*
286+
* @contrast_val: Focus measure - accumulated output of the focus filter.
287+
* In the first dimension, index [0] counts pixels below a
288+
* preset threshold, and index [1] counts pixels above the
289+
* threshold. In the second dimension, index [0] uses the
290+
* first predefined filter, and index [1] uses the second
291+
* predefined filter.
292+
* @contrast_val_num: The number of counted pixels in the above accumulation.
293+
*/
294+
struct bcm2835_isp_stats_focus {
295+
__u64 contrast_val[2][2];
296+
__u32 contrast_val_num[2][2];
297+
};
298+
299+
/**
300+
* struct bcm2835_isp_stats - ISP statistics.
301+
*
302+
* @version: Version of the bcm2835_isp_stats structure.
303+
* @size: Size of the bcm2835_isp_stats structure.
304+
* @hist: Histogram statistics for the entire image.
305+
* @awb_stats: Statistics for the regions defined for AWB calculations.
306+
* @floating_stats: Statistics for arbitrarily placed (floating) regions.
307+
* @agc_stats: Statistics for the regions defined for AGC calculations.
308+
* @focus_stats: Focus filter statistics for the focus regions.
309+
*/
310+
struct bcm2835_isp_stats {
311+
__u32 version;
312+
__u32 size;
313+
struct bcm2835_isp_stats_hist hist[NUM_HISTOGRAMS];
314+
struct bcm2835_isp_stats_region awb_stats[AWB_REGIONS];
315+
struct bcm2835_isp_stats_region floating_stats[FLOATING_REGIONS];
316+
struct bcm2835_isp_stats_region agc_stats[AGC_REGIONS];
317+
struct bcm2835_isp_stats_focus focus_stats[FOCUS_REGIONS];
318+
};
319+
320+
#endif /* __BCM2835_ISP_H_ */

0 commit comments

Comments
 (0)