1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Support for Intel Camera Imaging ISP subsystem.
4 * Copyright (c) 2015, Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef __IA_CSS_SC_TYPES_H
17#define __IA_CSS_SC_TYPES_H
18
19/* @file
20* CSS-API header file for Lens Shading Correction (SC) parameters.
21*/
22
23/* Number of color planes in the shading table. */
24#define IA_CSS_SC_NUM_COLORS           4
25
26/* The 4 colors that a shading table consists of.
27 *  For each color we store a grid of values.
28 */
29enum ia_css_sc_color {
30	IA_CSS_SC_COLOR_GR, /** Green on a green-red line */
31	IA_CSS_SC_COLOR_R,  /** Red */
32	IA_CSS_SC_COLOR_B,  /** Blue */
33	IA_CSS_SC_COLOR_GB  /** Green on a green-blue line */
34};
35
36/* Lens Shading Correction table.
37 *
38 *  This describes the color shading artefacts
39 *  introduced by lens imperfections. To correct artefacts,
40 *  bayer values should be multiplied by gains in this table.
41 *
42 *------------ deprecated(bz675) : from ---------------------------
43 *  When shading_settings.enable_shading_table_conversion is set as 0,
44 *  this shading table is directly sent to the isp. This table should contain
45 *  the data based on the ia_css_shading_info information filled in the css.
46 *  So, the driver needs to get the ia_css_shading_info information
47 *  from the css, prior to generating the shading table.
48 *
49 *  When shading_settings.enable_shading_table_conversion is set as 1,
50 *  this shading table is converted in the legacy way in the css
51 *  before it is sent to the isp.
52 *  The driver does not need to get the ia_css_shading_info information.
53 *
54 *  NOTE:
55 *  The shading table conversion will be removed from the css in the near future,
56 *  because it does not support the bayer scaling by sensor.
57 *  Also, we had better generate the shading table only in one place(AIC).
58 *  At the moment, to support the old driver which assumes the conversion is done in the css,
59 *  shading_settings.enable_shading_table_conversion is set as 1 by default.
60 *------------ deprecated(bz675) : to ---------------------------
61 *
62 *  ISP block: SC1
63 *  ISP1: SC1 is used.
64 *  ISP2: SC1 is used.
65 */
66struct ia_css_shading_table {
67	u32 enable; /** Set to false for no shading correction.
68			  The data field can be NULL when enable == true */
69	/* ------ deprecated(bz675) : from ------ */
70	u32 sensor_width;  /** Native sensor width in pixels. */
71	u32 sensor_height; /** Native sensor height in lines.
72		When shading_settings.enable_shading_table_conversion is set
73		as 0, sensor_width and sensor_height are NOT used.
74		These are used only in the legacy shading table conversion
75		in the css, when shading_settings.
76		enable_shading_table_conversion is set as 1. */
77	/* ------ deprecated(bz675) : to ------ */
78	u32 width;  /** Number of data points per line per color.
79				u8.0, [0,81] */
80	u32 height; /** Number of lines of data points per color.
81				u8.0, [0,61] */
82	u32 fraction_bits; /** Bits of fractional part in the data
83				points.
84				u8.0, [0,13] */
85	u16 *data[IA_CSS_SC_NUM_COLORS];
86	/** Table data, one array for each color.
87	     Use ia_css_sc_color to index this array.
88	     u[13-fraction_bits].[fraction_bits], [0,8191] */
89};
90
91/* ------ deprecated(bz675) : from ------ */
92/* Shading Correction settings.
93 *
94 *  NOTE:
95 *  This structure should be removed when the shading table conversion is
96 *  removed from the css.
97 */
98struct ia_css_shading_settings {
99	u32 enable_shading_table_conversion; /** Set to 0,
100		if the conversion of the shading table should be disabled
101		in the css. (default 1)
102		  0: The shading table is directly sent to the isp.
103		     The shading table should contain the data based on the
104		     ia_css_shading_info information filled in the css.
105		  1: The shading table is converted in the css, to be fitted
106		     to the shading table definition required in the isp.
107		NOTE:
108		Previously, the shading table was always converted in the css
109		before it was sent to the isp, and this config was not defined.
110		Currently, the driver is supposed to pass the shading table
111		which should be directly sent to the isp.
112		However, some drivers may still pass the shading table which
113		needs the conversion without setting this config as 1.
114		To support such an unexpected case for the time being,
115		enable_shading_table_conversion is set as 1 by default
116		in the css. */
117};
118
119/* ------ deprecated(bz675) : to ------ */
120
121#endif /* __IA_CSS_SC_TYPES_H */
122