File Index
Files and directories
Sign in
FILE

mali-c55-config.h

File preview with syntax highlighting.

linux-6.19.14/include/uapi/linux/media/arm/mali-c55-config.h C
  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_block_type - Enumeration of Mali-C55 parameter blocks
199 *
200 * This enumeration defines the types of Mali-C55 parameters block. Each block
201 * configures a specific processing block of the Mali-C55 ISP. The block
202 * type allows the driver to correctly interpret the parameters block data.
203 *
204 * It is the responsibility of userspace to correctly set the type of each
205 * parameters block.
206 *
207 * @MALI_C55_PARAM_BLOCK_SENSOR_OFFS: Sensor pre-shading black level offset
208 * @MALI_C55_PARAM_BLOCK_AEXP_HIST: Auto-exposure 1024-bin histogram
209 *				    configuration
210 * @MALI_C55_PARAM_BLOCK_AEXP_IHIST: Post-Iridix auto-exposure 1024-bin
211 *				     histogram configuration
212 * @MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS: Auto-exposure 1024-bin histogram
213 *					    weighting
214 * @MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS: Post-Iridix auto-exposure 1024-bin
215 *					     histogram weighting
216 * @MALI_C55_PARAM_BLOCK_DIGITAL_GAIN: Digital gain
217 * @MALI_C55_PARAM_BLOCK_AWB_GAINS: Auto-white balance gains
218 * @MALI_C55_PARAM_BLOCK_AWB_CONFIG: Auto-white balance statistics config
219 * @MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP: Auto-white balance gains for AEXP-0 tap
220 * @MALI_C55_PARAM_MESH_SHADING_CONFIG : Mesh shading tables configuration
221 * @MALI_C55_PARAM_MESH_SHADING_SELECTION: Mesh shading table selection
222 */
223enum mali_c55_param_block_type {
224	MALI_C55_PARAM_BLOCK_SENSOR_OFFS,
225	MALI_C55_PARAM_BLOCK_AEXP_HIST,
226	MALI_C55_PARAM_BLOCK_AEXP_IHIST,
227	MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS,
228	MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS,
229	MALI_C55_PARAM_BLOCK_DIGITAL_GAIN,
230	MALI_C55_PARAM_BLOCK_AWB_GAINS,
231	MALI_C55_PARAM_BLOCK_AWB_CONFIG,
232	MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP,
233	MALI_C55_PARAM_MESH_SHADING_CONFIG,
234	MALI_C55_PARAM_MESH_SHADING_SELECTION,
235};
236
237/**
238 * struct mali_c55_params_sensor_off_preshading - offset subtraction for each
239 *						  color channel
240 *
241 * Provides removal of the sensor black level from the sensor data. Separate
242 * offsets are provided for each of the four Bayer component color channels
243 * which are defaulted to R, Gr, Gb, B.
244 *
245 * header.type should be set to MALI_C55_PARAM_BLOCK_SENSOR_OFFS from
246 * :c:type:`mali_c55_param_block_type` for this block.
247 *
248 * @header: The Mali-C55 parameters block header
249 * @chan00: Offset for color channel 00 (default: R)
250 * @chan01: Offset for color channel 01 (default: Gr)
251 * @chan10: Offset for color channel 10 (default: Gb)
252 * @chan11: Offset for color channel 11 (default: B)
253 */
254struct mali_c55_params_sensor_off_preshading {
255	struct v4l2_isp_params_block_header header;
256	__u32 chan00;
257	__u32 chan01;
258	__u32 chan10;
259	__u32 chan11;
260};
261
262/**
263 * enum mali_c55_aexp_hist_tap_points - Tap points for the AEXP histogram
264 * @MALI_C55_AEXP_HIST_TAP_WB: After static white balance
265 * @MALI_C55_AEXP_HIST_TAP_FS: After WDR Frame Stitch
266 * @MALI_C55_AEXP_HIST_TAP_TPG: After the test pattern generator
267 */
268enum mali_c55_aexp_hist_tap_points {
269	MALI_C55_AEXP_HIST_TAP_WB = 0,
270	MALI_C55_AEXP_HIST_TAP_FS,
271	MALI_C55_AEXP_HIST_TAP_TPG,
272};
273
274/**
275 * enum mali_c55_aexp_skip_x - Horizontal pixel skipping
276 * @MALI_C55_AEXP_SKIP_X_EVERY_2ND: Collect every 2nd pixel horizontally
277 * @MALI_C55_AEXP_SKIP_X_EVERY_3RD: Collect every 3rd pixel horizontally
278 * @MALI_C55_AEXP_SKIP_X_EVERY_4TH: Collect every 4th pixel horizontally
279 * @MALI_C55_AEXP_SKIP_X_EVERY_5TH: Collect every 5th pixel horizontally
280 * @MALI_C55_AEXP_SKIP_X_EVERY_8TH: Collect every 8th pixel horizontally
281 * @MALI_C55_AEXP_SKIP_X_EVERY_9TH: Collect every 9th pixel horizontally
282 */
283enum mali_c55_aexp_skip_x {
284	MALI_C55_AEXP_SKIP_X_EVERY_2ND,
285	MALI_C55_AEXP_SKIP_X_EVERY_3RD,
286	MALI_C55_AEXP_SKIP_X_EVERY_4TH,
287	MALI_C55_AEXP_SKIP_X_EVERY_5TH,
288	MALI_C55_AEXP_SKIP_X_EVERY_8TH,
289	MALI_C55_AEXP_SKIP_X_EVERY_9TH
290};
291
292/**
293 * enum mali_c55_aexp_skip_y - Vertical pixel skipping
294 * @MALI_C55_AEXP_SKIP_Y_ALL: Collect every single pixel vertically
295 * @MALI_C55_AEXP_SKIP_Y_EVERY_2ND: Collect every 2nd pixel vertically
296 * @MALI_C55_AEXP_SKIP_Y_EVERY_3RD: Collect every 3rd pixel vertically
297 * @MALI_C55_AEXP_SKIP_Y_EVERY_4TH: Collect every 4th pixel vertically
298 * @MALI_C55_AEXP_SKIP_Y_EVERY_5TH: Collect every 5th pixel vertically
299 * @MALI_C55_AEXP_SKIP_Y_EVERY_8TH: Collect every 8th pixel vertically
300 * @MALI_C55_AEXP_SKIP_Y_EVERY_9TH: Collect every 9th pixel vertically
301 */
302enum mali_c55_aexp_skip_y {
303	MALI_C55_AEXP_SKIP_Y_ALL,
304	MALI_C55_AEXP_SKIP_Y_EVERY_2ND,
305	MALI_C55_AEXP_SKIP_Y_EVERY_3RD,
306	MALI_C55_AEXP_SKIP_Y_EVERY_4TH,
307	MALI_C55_AEXP_SKIP_Y_EVERY_5TH,
308	MALI_C55_AEXP_SKIP_Y_EVERY_8TH,
309	MALI_C55_AEXP_SKIP_Y_EVERY_9TH
310};
311
312/**
313 * enum mali_c55_aexp_row_column_offset - Start from the first or second row or
314 *					  column
315 * @MALI_C55_AEXP_FIRST_ROW_OR_COL:	Start from the first row / column
316 * @MALI_C55_AEXP_SECOND_ROW_OR_COL:	Start from the second row / column
317 */
318enum mali_c55_aexp_row_column_offset {
319	MALI_C55_AEXP_FIRST_ROW_OR_COL = 1,
320	MALI_C55_AEXP_SECOND_ROW_OR_COL = 2,
321};
322
323/**
324 * enum mali_c55_aexp_hist_plane_mode - Mode for the AEXP Histograms
325 * @MALI_C55_AEXP_HIST_COMBINED: All color planes in one 1024-bin histogram
326 * @MALI_C55_AEXP_HIST_SEPARATE: Each color plane in one 256-bin histogram with a bin width of 16
327 * @MALI_C55_AEXP_HIST_FOCUS_00: Top left plane in the first bank, rest in second bank
328 * @MALI_C55_AEXP_HIST_FOCUS_01: Top right plane in the first bank, rest in second bank
329 * @MALI_C55_AEXP_HIST_FOCUS_10: Bottom left plane in the first bank, rest in second bank
330 * @MALI_C55_AEXP_HIST_FOCUS_11: Bottom right plane in the first bank, rest in second bank
331 *
332 * In the "focus" modes statistics are collected into two 512-bin histograms
333 * with a bin width of 8. One colour plane is in the first histogram with the
334 * remainder combined into the second. The four options represent which of the
335 * four positions in a bayer pattern are the focused plane.
336 */
337enum mali_c55_aexp_hist_plane_mode {
338	MALI_C55_AEXP_HIST_COMBINED = 0,
339	MALI_C55_AEXP_HIST_SEPARATE = 1,
340	MALI_C55_AEXP_HIST_FOCUS_00 = 4,
341	MALI_C55_AEXP_HIST_FOCUS_01 = 5,
342	MALI_C55_AEXP_HIST_FOCUS_10 = 6,
343	MALI_C55_AEXP_HIST_FOCUS_11 = 7,
344};
345
346/**
347 * struct mali_c55_params_aexp_hist - configuration for AEXP metering hists
348 *
349 * This struct allows users to configure the 1024-bin AEXP histograms. Broadly
350 * speaking the parameters allow you to mask particular regions of the image and
351 * to select different kinds of histogram.
352 *
353 * The skip_x, offset_x, skip_y and offset_y fields allow users to ignore or
354 * mask pixels in the frame by their position relative to the top left pixel.
355 * First, the skip_y, offset_x and offset_y fields define which of the pixels
356 * within each 2x2 region will be counted in the statistics.
357 *
358 * If skip_y == 0 then two pixels from each covered region will be counted. If
359 * both offset_x and offset_y are zero, then the two left-most pixels in each
360 * 2x2 pixel region will be counted. Setting offset_x = 1 will discount the top
361 * left pixel and count the top right pixel. Setting offset_y = 1 will discount
362 * the bottom left pixel and count the bottom right pixel.
363 *
364 * If skip_y != 0 then only a single pixel from each region covered by the
365 * pattern will be counted. In this case offset_x controls whether the pixel
366 * that's counted is in the left (if offset_x == 0) or right (if offset_x == 1)
367 * column and offset_y controls whether the pixel that's counted is in the top
368 * (if offset_y == 0) or bottom (if offset_y == 1) row.
369 *
370 * The skip_x and skip_y fields control how the 2x2 pixel region is repeated
371 * across the image data. The first instance of the region is always in the top
372 * left of the image data. The skip_x field controls how many pixels are ignored
373 * in the x direction before the pixel masking region is repeated. The skip_y
374 * field controls how many pixels are ignored in the y direction before the
375 * pixel masking region is repeated.
376 *
377 * These fields can be used to reduce the number of pixels counted for the
378 * statistics, but it's important to be careful to configure them correctly.
379 * Some combinations of values will result in colour components from the input
380 * data being ignored entirely, for example in the following configuration:
381 *
382 * skip_x = 0
383 * offset_x = 0
384 * skip_y = 0
385 * offset_y = 0
386 *
387 * Only the R and Gb components of RGGB data that was input would be collected.
388 * Similarly in the following configuration:
389 *
390 * skip_x = 0
391 * offset_x = 0
392 * skip_y = 1
393 * offset_y = 1
394 *
395 * Only the Gb component of RGGB data that was input would be collected. To
396 * correct things such that all 4 colour components were included it would be
397 * necessary to set the skip_x and skip_y fields in a way that resulted in all
398 * four colour components being collected:
399 *
400 * skip_x = 1
401 * offset_x = 0
402 * skip_y = 1
403 * offset_y = 1
404 *
405 * header.type should be set to one of either MALI_C55_PARAM_BLOCK_AEXP_HIST or
406 * MALI_C55_PARAM_BLOCK_AEXP_IHIST from :c:type:`mali_c55_param_block_type`.
407 *
408 * @header:		The Mali-C55 parameters block header
409 * @skip_x:		Horizontal decimation. See enum mali_c55_aexp_skip_x
410 * @offset_x:		Skip the first column, or not. See enum mali_c55_aexp_row_column_offset
411 * @skip_y:		Vertical decimation. See enum mali_c55_aexp_skip_y
412 * @offset_y:		Skip the first row, or not. See enum mali_c55_aexp_row_column_offset
413 * @scale_bottom:	Scale pixels in bottom half of intensity range: 0=1x ,1=2x, 2=4x, 4=8x, 4=16x
414 * @scale_top:		scale pixels in top half of intensity range: 0=1x ,1=2x, 2=4x, 4=8x, 4=16x
415 * @plane_mode:		Plane separation mode. See enum mali_c55_aexp_hist_plane_mode
416 * @tap_point:		Tap point for histogram from enum mali_c55_aexp_hist_tap_points.
417 *			This parameter is unused for the post-Iridix Histogram
418 */
419struct mali_c55_params_aexp_hist {
420	struct v4l2_isp_params_block_header header;
421	__u8 skip_x;
422	__u8 offset_x;
423	__u8 skip_y;
424	__u8 offset_y;
425	__u8 scale_bottom;
426	__u8 scale_top;
427	__u8 plane_mode;
428	__u8 tap_point;
429};
430
431/**
432 * struct mali_c55_params_aexp_weights - Array of weights for AEXP metering
433 *
434 * This struct allows users to configure the weighting for both of the 1024-bin
435 * AEXP histograms. The pixel data collected for each zone is multiplied by the
436 * corresponding weight from this array, which may be zero if the intention is
437 * to mask off the zone entirely.
438 *
439 * header.type should be set to one of either MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS
440 * or MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS from :c:type:`mali_c55_param_block_type`.
441 *
442 * @header:		The Mali-C55 parameters block header
443 * @nodes_used_horiz:	Number of active zones horizontally [0..15]
444 * @nodes_used_vert:	Number of active zones vertically [0..15]
445 * @zone_weights:	Zone weighting. Index is row*col where 0,0 is the top
446 *			left zone continuing in raster order. Each zone can be
447 *			weighted in the range [0..15]. The number of rows and
448 *			columns is defined by @nodes_used_vert and
449 *			@nodes_used_horiz
450 */
451struct mali_c55_params_aexp_weights {
452	struct v4l2_isp_params_block_header header;
453	__u8 nodes_used_horiz;
454	__u8 nodes_used_vert;
455	__u8 zone_weights[MALI_C55_MAX_ZONES];
456};
457
458/**
459 * struct mali_c55_params_digital_gain - Digital gain value
460 *
461 * This struct carries a digital gain value to set in the ISP.
462 *
463 * header.type should be set to MALI_C55_PARAM_BLOCK_DIGITAL_GAIN from
464 * :c:type:`mali_c55_param_block_type` for this block.
465 *
466 * @header:	The Mali-C55 parameters block header
467 * @gain:	The digital gain value to apply, in Q5.8 format.
468 */
469struct mali_c55_params_digital_gain {
470	struct v4l2_isp_params_block_header header;
471	__u16 gain;
472};
473
474/**
475 * enum mali_c55_awb_stats_mode - Statistics mode for AWB
476 * @MALI_C55_AWB_MODE_GRBR: Statistics collected as Green/Red and Blue/Red ratios
477 * @MALI_C55_AWB_MODE_RGBG: Statistics collected as Red/Green and Blue/Green ratios
478 */
479enum mali_c55_awb_stats_mode {
480	MALI_C55_AWB_MODE_GRBR = 0,
481	MALI_C55_AWB_MODE_RGBG,
482};
483
484/**
485 * struct mali_c55_params_awb_gains - Gain settings for auto white balance
486 *
487 * This struct allows users to configure the gains for auto-white balance. There
488 * are four gain settings corresponding to each colour channel in the bayer
489 * domain. Although named generically, the association between the gain applied
490 * and the colour channel is done automatically within the ISP depending on the
491 * input format, and so the following mapping always holds true::
492 *
493 *	gain00 = R
494 *	gain01 = Gr
495 *	gain10 = Gb
496 *	gain11 = B
497 *
498 * All of the gains are stored in Q4.8 format.
499 *
500 * header.type should be set to one of either MALI_C55_PARAM_BLOCK_AWB_GAINS or
501 * MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP from :c:type:`mali_c55_param_block_type`.
502 *
503 * @header:	The Mali-C55 parameters block header
504 * @gain00:	Multiplier for colour channel 00
505 * @gain01:	Multiplier for colour channel 01
506 * @gain10:	Multiplier for colour channel 10
507 * @gain11:	Multiplier for colour channel 11
508 */
509struct mali_c55_params_awb_gains {
510	struct v4l2_isp_params_block_header header;
511	__u16 gain00;
512	__u16 gain01;
513	__u16 gain10;
514	__u16 gain11;
515};
516
517/**
518 * enum mali_c55_params_awb_tap_points - Tap points for the AWB statistics
519 * @MALI_C55_AWB_STATS_TAP_PF: Immediately after the Purple Fringe block
520 * @MALI_C55_AWB_STATS_TAP_CNR: Immediately after the CNR block
521 */
522enum mali_c55_params_awb_tap_points {
523	MALI_C55_AWB_STATS_TAP_PF = 0,
524	MALI_C55_AWB_STATS_TAP_CNR,
525};
526
527/**
528 * struct mali_c55_params_awb_config - Stats settings for auto-white balance
529 *
530 * This struct allows the configuration of the statistics generated for auto
531 * white balance. Pixel intensity limits can be set to exclude overly bright or
532 * dark regions of an image from the statistics entirely. Colour ratio minima
533 * and maxima can be set to discount pixels who's ratios fall outside the
534 * defined boundaries; there are two sets of registers to do this - the
535 * "min/max" ratios which bound a region and the "high/low" ratios which further
536 * trim the upper and lower ratios. For example with the boundaries configured
537 * as follows, only pixels whos colour ratios falls into the region marked "A"
538 * would be counted::
539 *
540 *	                                                          cr_high
541 *	    2.0 |                                                   |
542 *	        |               cb_max --> _________________________v_____
543 *	    1.8 |                         |                         \    |
544 *	        |                         |                          \   |
545 *	    1.6 |                         |                           \  |
546 *	        |                         |                            \ |
547 *	 c  1.4 |               cb_low -->|\              A             \|<--  cb_high
548 *	 b      |                         | \                            |
549 *	    1.2 |                         |  \                           |
550 *	 r      |                         |   \                          |
551 *	 a  1.0 |              cb_min --> |____\_________________________|
552 *	 t      |                         ^    ^                         ^
553 *	 i  0.8 |                         |    |                         |
554 *	 o      |                      cr_min  |                       cr_max
555 *	 s  0.6 |                              |
556 *	        |                             cr_low
557 *	    0.4 |
558 *	        |
559 *	    0.2 |
560 *	        |
561 *	    0.0 |_______________________________________________________________
562 *	        0.0   0.2   0.4   0.6   0.8   1.0   1.2   1.4   1.6   1.8   2.0
563 *	                                   cr ratios
564 *
565 * header.type should be set to MALI_C55_PARAM_BLOCK_AWB_CONFIG from
566 * :c:type:`mali_c55_param_block_type` for this block.
567 *
568 * @header:		The Mali-C55 parameters block header
569 * @tap_point:		The tap point from enum mali_c55_params_awb_tap_points
570 * @stats_mode:		AWB statistics collection mode, see :c:type:`mali_c55_awb_stats_mode`
571 * @white_level:	Upper pixel intensity (I.E. raw pixel values) limit
572 * @black_level:	Lower pixel intensity (I.E. raw pixel values) limit
573 * @cr_max:		Maximum R/G ratio (Q4.8 format)
574 * @cr_min:		Minimum R/G ratio (Q4.8 format)
575 * @cb_max:		Maximum B/G ratio (Q4.8 format)
576 * @cb_min:		Minimum B/G ratio (Q4.8 format)
577 * @nodes_used_horiz:	Number of active zones horizontally [0..15]
578 * @nodes_used_vert:	Number of active zones vertically [0..15]
579 * @cr_high:		R/G ratio trim high (Q4.8 format)
580 * @cr_low:		R/G ratio trim low (Q4.8 format)
581 * @cb_high:		B/G ratio trim high (Q4.8 format)
582 * @cb_low:		B/G ratio trim low (Q4.8 format)
583 */
584struct mali_c55_params_awb_config {
585	struct v4l2_isp_params_block_header header;
586	__u8 tap_point;
587	__u8 stats_mode;
588	__u16 white_level;
589	__u16 black_level;
590	__u16 cr_max;
591	__u16 cr_min;
592	__u16 cb_max;
593	__u16 cb_min;
594	__u8 nodes_used_horiz;
595	__u8 nodes_used_vert;
596	__u16 cr_high;
597	__u16 cr_low;
598	__u16 cb_high;
599	__u16 cb_low;
600};
601
602#define MALI_C55_NUM_MESH_SHADING_ELEMENTS 3072
603
604/**
605 * struct mali_c55_params_mesh_shading_config - Mesh shading configuration
606 *
607 * The mesh shading correction module allows programming a separate table of
608 * either 16x16 or 32x32 node coefficients for 3 different light sources. The
609 * final correction coefficients applied are computed by blending the
610 * coefficients from two tables together.
611 *
612 * A page of 1024 32-bit integers is associated to each colour channel, with
613 * pages stored consecutively in memory. Each 32-bit integer packs 3 8-bit
614 * correction coefficients for a single node, one for each of the three light
615 * sources. The 8 most significant bits are unused. The following table
616 * describes the layout::
617 *
618 *	+----------- Page (Colour Plane) 0 -------------+
619 *	| @mesh[i]  | Mesh Point | Bits  | Light Source |
620 *	+-----------+------------+-------+--------------+
621 *	|         0 |        0,0 | 16,23 | LS2          |
622 *	|           |            | 08-15 | LS1          |
623 *	|           |            | 00-07 | LS0          |
624 *	+-----------+------------+-------+--------------+
625 *	|         1 |        0,1 | 16,23 | LS2          |
626 *	|           |            | 08-15 | LS1          |
627 *	|           |            | 00-07 | LS0          |
628 *	+-----------+------------+-------+--------------+
629 *	|       ... |        ... | ...   | ...          |
630 *	+-----------+------------+-------+--------------+
631 *	|      1023 |      31,31 | 16,23 | LS2          |
632 *	|           |            | 08-15 | LS1          |
633 *	|           |            | 00-07 | LS0          |
634 *	+----------- Page (Colour Plane) 1 -------------+
635 *	| @mesh[i]  | Mesh Point | Bits  | Light Source |
636 *	+-----------+------------+-------+--------------+
637 *	|      1024 |        0,0 | 16,23 | LS2          |
638 *	|           |            | 08-15 | LS1          |
639 *	|           |            | 00-07 | LS0          |
640 *	+-----------+------------+-------+--------------+
641 *	|      1025 |        0,1 | 16,23 | LS2          |
642 *	|           |            | 08-15 | LS1          |
643 *	|           |            | 00-07 | LS0          |
644 *	+-----------+------------+-------+--------------+
645 *	|       ... |        ... | ...   | ...          |
646 *	+-----------+------------+-------+--------------+
647 *	|      2047 |      31,31 | 16,23 | LS2          |
648 *	|           |            | 08-15 | LS1          |
649 *	|           |            | 00-07 | LS0          |
650 *	+----------- Page (Colour Plane) 2 -------------+
651 *	| @mesh[i]  | Mesh Point | Bits  | Light Source |
652 *	+-----------+------------+-------+--------------+
653 *	|      2048 |        0,0 | 16,23 | LS2          |
654 *	|           |            | 08-15 | LS1          |
655 *	|           |            | 00-07 | LS0          |
656 *	+-----------+------------+-------+--------------+
657 *	|      2049 |        0,1 | 16,23 | LS2          |
658 *	|           |            | 08-15 | LS1          |
659 *	|           |            | 00-07 | LS0          |
660 *	+-----------+------------+-------+--------------+
661 *	|       ... |        ... | ...   | ...          |
662 *	+-----------+------------+-------+--------------+
663 *	|      3071 |      31,31 | 16,23 | LS2          |
664 *	|           |            | 08-15 | LS1          |
665 *	|           |            | 00-07 | LS0          |
666 *	+-----------+------------+-------+--------------+
667 *
668 * The @mesh_scale member determines the precision and minimum and maximum gain.
669 * For example if @mesh_scale is 0 and therefore selects 0 - 2x gain, a value of
670 * 0 in a coefficient means 0.0 gain, a value of 128 means 1.0 gain and 255
671 * means 2.0 gain.
672 *
673 * header.type should be set to MALI_C55_PARAM_MESH_SHADING_CONFIG from
674 * :c:type:`mali_c55_param_block_type` for this block.
675 *
676 * @header:		The Mali-C55 parameters block header
677 * @mesh_show:		Output the mesh data rather than image data
678 * @mesh_scale:		Set the precision and maximum gain range of mesh shading
679 *				- 0 = 0-2x gain
680 *				- 1 = 0-4x gain
681 *				- 2 = 0-8x gain
682 *				- 3 = 0-16x gain
683 *				- 4 = 1-2x gain
684 *				- 5 = 1-3x gain
685 *				- 6 = 1-5x gain
686 *				- 7 = 1-9x gain
687 * @mesh_page_r:	Mesh page select for red colour plane [0..2]
688 * @mesh_page_g:	Mesh page select for green colour plane [0..2]
689 * @mesh_page_b:	Mesh page select for blue colour plane [0..2]
690 * @mesh_width:		Number of horizontal nodes minus 1 [15,31]
691 * @mesh_height:	Number of vertical nodes minus 1 [15,31]
692 * @mesh:		Mesh shading correction tables
693 */
694struct mali_c55_params_mesh_shading_config {
695	struct v4l2_isp_params_block_header header;
696	__u8 mesh_show;
697	__u8 mesh_scale;
698	__u8 mesh_page_r;
699	__u8 mesh_page_g;
700	__u8 mesh_page_b;
701	__u8 mesh_width;
702	__u8 mesh_height;
703	__u32 mesh[MALI_C55_NUM_MESH_SHADING_ELEMENTS];
704};
705
706/** enum mali_c55_params_mesh_alpha_bank - Mesh shading table bank selection
707 * @MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS1 - Select Light Sources 0 and 1
708 * @MALI_C55_MESH_ALPHA_BANK_LS1_AND_LS2 - Select Light Sources 1 and 2
709 * @MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS2 - Select Light Sources 0 and 2
710 */
711enum mali_c55_params_mesh_alpha_bank {
712	MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS1 = 0,
713	MALI_C55_MESH_ALPHA_BANK_LS1_AND_LS2 = 1,
714	MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS2 = 4
715};
716
717/**
718 * struct mali_c55_params_mesh_shading_selection - Mesh table selection
719 *
720 * The module computes the final correction coefficients by blending the ones
721 * from two light source tables, which are selected (independently for each
722 * colour channel) by the @mesh_alpha_bank_r/g/b fields.
723 *
724 * The final blended coefficients for each node are calculated using the
725 * following equation:
726 *
727 *     Final coefficient = (a * LS\ :sub:`b`\ + (256 - a) * LS\ :sub:`a`\) / 256
728 *
729 * Where a is the @mesh_alpha_r/g/b value, and LS\ :sub:`a`\ and LS\ :sub:`b`\
730 * are the node cofficients for the two tables selected by the
731 * @mesh_alpha_bank_r/g/b value.
732 *
733 * The scale of the applied correction may also be controlled by tuning the
734 * @mesh_strength member. This is a modifier to the final coefficients which can
735 * be used to globally reduce the gains applied.
736 *
737 * header.type should be set to MALI_C55_PARAM_MESH_SHADING_SELECTION from
738 * :c:type:`mali_c55_param_block_type` for this block.
739 *
740 * @header:		The Mali-C55 parameters block header
741 * @mesh_alpha_bank_r:	Red mesh table select (c:type:`enum mali_c55_params_mesh_alpha_bank`)
742 * @mesh_alpha_bank_g:	Green mesh table select (c:type:`enum mali_c55_params_mesh_alpha_bank`)
743 * @mesh_alpha_bank_b:	Blue mesh table select (c:type:`enum mali_c55_params_mesh_alpha_bank`)
744 * @mesh_alpha_r:	Blend coefficient for R [0..255]
745 * @mesh_alpha_g:	Blend coefficient for G [0..255]
746 * @mesh_alpha_b:	Blend coefficient for B [0..255]
747 * @mesh_strength:	Mesh strength in Q4.12 format [0..4096]
748 */
749struct mali_c55_params_mesh_shading_selection {
750	struct v4l2_isp_params_block_header header;
751	__u8 mesh_alpha_bank_r;
752	__u8 mesh_alpha_bank_g;
753	__u8 mesh_alpha_bank_b;
754	__u8 mesh_alpha_r;
755	__u8 mesh_alpha_g;
756	__u8 mesh_alpha_b;
757	__u16 mesh_strength;
758};
759
760/**
761 * define MALI_C55_PARAMS_MAX_SIZE - Maximum size of all Mali C55 Parameters
762 *
763 * Though the parameters for the Mali-C55 are passed as optional blocks, the
764 * driver still needs to know the absolute maximum size so that it can allocate
765 * a buffer sized appropriately to accommodate userspace attempting to set all
766 * possible parameters in a single frame.
767 *
768 * Some structs are in this list multiple times. Where that's the case, it just
769 * reflects the fact that the same struct can be used with multiple different
770 * header types from :c:type:`mali_c55_param_block_type`.
771 */
772#define MALI_C55_PARAMS_MAX_SIZE				\
773	(sizeof(struct mali_c55_params_sensor_off_preshading) +	\
774	sizeof(struct mali_c55_params_aexp_hist) +		\
775	sizeof(struct mali_c55_params_aexp_weights) +		\
776	sizeof(struct mali_c55_params_aexp_hist) +		\
777	sizeof(struct mali_c55_params_aexp_weights) +		\
778	sizeof(struct mali_c55_params_digital_gain) +		\
779	sizeof(struct mali_c55_params_awb_gains) +		\
780	sizeof(struct mali_c55_params_awb_config) +		\
781	sizeof(struct mali_c55_params_awb_gains) +		\
782	sizeof(struct mali_c55_params_mesh_shading_config) +	\
783	sizeof(struct mali_c55_params_mesh_shading_selection))
784
785#endif /* __UAPI_MALI_C55_CONFIG_H */
~/ Read-only file preview.