GNU Linux-libre 4.14.290-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / sc / sc_1.0 / ia_css_sc_types.h
1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14
15 #ifndef __IA_CSS_SC_TYPES_H
16 #define __IA_CSS_SC_TYPES_H
17
18 /** @file
19 * CSS-API header file for Lens Shading Correction (SC) parameters.
20 */
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  */
29 enum 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  */
66 struct ia_css_shading_table {
67         uint32_t enable; /**< Set to false for no shading correction.
68                           The data field can be NULL when enable == true */
69 /* ------ deprecated(bz675) : from ------ */
70         uint32_t sensor_width;  /**< Native sensor width in pixels. */
71         uint32_t 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         uint32_t width;  /**< Number of data points per line per color.
79                                 u8.0, [0,81] */
80         uint32_t height; /**< Number of lines of data points per color.
81                                 u8.0, [0,61] */
82         uint32_t fraction_bits; /**< Bits of fractional part in the data
83                                 points.
84                                 u8.0, [0,13] */
85         uint16_t *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  */
98 struct ia_css_shading_settings {
99         uint32_t 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 /* ------ deprecated(bz675) : to ------ */
119
120 #ifdef ISP2401
121
122 /** Shading Correction configuration.
123  *
124  *  NOTE: The shading table size is larger than or equal to the internal frame size.
125  */
126 struct ia_css_sc_configuration {
127         uint32_t internal_frame_origin_x_bqs_on_sctbl; /**< Origin X (in bqs) of internal frame on shading table. */
128         uint32_t internal_frame_origin_y_bqs_on_sctbl; /**< Origin Y (in bqs) of internal frame on shading table. */
129                                                 /**< NOTE: bqs = size in BQ(Bayer Quad) unit.
130                                                         1BQ means {Gr,R,B,Gb}(2x2 pixels).
131                                                         Horizontal 1 bqs corresponds to horizontal 2 pixels.
132                                                         Vertical 1 bqs corresponds to vertical 2 pixels. */
133 };
134 #endif
135
136 #endif /* __IA_CSS_SC_TYPES_H */