GNU Linux-libre 4.14.295-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / ctc / ctc_1.0 / ia_css_ctc_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_CTC_TYPES_H
16 #define __IA_CSS_CTC_TYPES_H
17
18 /** @file
19 * CSS-API header file for Chroma Tone Control parameters.
20 */
21
22 /** Fractional bits for CTC gain (used only for ISP1).
23  *
24  *  IA_CSS_CTC_COEF_SHIFT(=13) includes not only the fractional bits
25  *  of gain(=8), but also the bits(=5) to convert chroma
26  *  from 13bit precision to 8bit precision.
27  *
28  *    Gain (struct ia_css_ctc_table) : u5.8
29  *    Input(Chorma) : s0.12 (13bit precision)
30  *    Output(Chorma): s0.7  (8bit precision)
31  *    Output = (Input * Gain) >> IA_CSS_CTC_COEF_SHIFT
32  */
33 #define IA_CSS_CTC_COEF_SHIFT          13
34
35 /** Number of elements in the CTC table. */
36 #define IA_CSS_VAMEM_1_CTC_TABLE_SIZE_LOG2      10
37 /** Number of elements in the CTC table. */
38 #define IA_CSS_VAMEM_1_CTC_TABLE_SIZE           (1U<<IA_CSS_VAMEM_1_CTC_TABLE_SIZE_LOG2)
39
40 /** Number of elements in the CTC table. */
41 #define IA_CSS_VAMEM_2_CTC_TABLE_SIZE_LOG2      8
42 /** Number of elements in the CTC table. */
43 #define IA_CSS_VAMEM_2_CTC_TABLE_SIZE           ((1U<<IA_CSS_VAMEM_2_CTC_TABLE_SIZE_LOG2) + 1)
44
45 enum ia_css_vamem_type {
46         IA_CSS_VAMEM_TYPE_1,
47         IA_CSS_VAMEM_TYPE_2
48 };
49
50 /** Chroma Tone Control configuration.
51  *
52  *  ISP block: CTC2 (CTC by polygonal line approximation)
53  * (ISP1: CTC1 (CTC by look-up table) is used.)
54  *  ISP2: CTC2 is used.
55  */
56 struct ia_css_ctc_config {
57         uint16_t y0;    /**< 1st kneepoint gain.
58                                 u[ce_gain_exp].[13-ce_gain_exp], [0,8191],
59                                 default/ineffective 4096(0.5) */
60         uint16_t y1;    /**< 2nd kneepoint gain.
61                                 u[ce_gain_exp].[13-ce_gain_exp], [0,8191],
62                                 default/ineffective 4096(0.5) */
63         uint16_t y2;    /**< 3rd kneepoint gain.
64                                 u[ce_gain_exp].[13-ce_gain_exp], [0,8191],
65                                 default/ineffective 4096(0.5) */
66         uint16_t y3;    /**< 4th kneepoint gain.
67                                 u[ce_gain_exp].[13-ce_gain_exp], [0,8191],
68                                 default/ineffective 4096(0.5) */
69         uint16_t y4;    /**< 5th kneepoint gain.
70                                 u[ce_gain_exp].[13-ce_gain_exp], [0,8191],
71                                 default/ineffective 4096(0.5) */
72         uint16_t y5;    /**< 6th kneepoint gain.
73                                 u[ce_gain_exp].[13-ce_gain_exp], [0,8191],
74                                 default/ineffective 4096(0.5) */
75         uint16_t ce_gain_exp;   /**< Common exponent of y-axis gain.
76                                 u8.0, [0,13],
77                                 default/ineffective 1 */
78         uint16_t x1;    /**< 2nd kneepoint luma.
79                                 u0.13, [0,8191], constraints: 0<x1<x2,
80                                 default/ineffective 1024 */
81         uint16_t x2;    /**< 3rd kneepoint luma.
82                                 u0.13, [0,8191], constraints: x1<x2<x3,
83                                 default/ineffective 2048 */
84         uint16_t x3;    /**< 4th kneepoint luma.
85                                 u0.13, [0,8191], constraints: x2<x3<x4,
86                                 default/ineffective 6144 */
87         uint16_t x4;    /**< 5tn kneepoint luma.
88                                 u0.13, [0,8191], constraints: x3<x4<8191,
89                                 default/ineffective 7168 */
90 };
91
92 union ia_css_ctc_data {
93         uint16_t vamem_1[IA_CSS_VAMEM_1_CTC_TABLE_SIZE];
94         uint16_t vamem_2[IA_CSS_VAMEM_2_CTC_TABLE_SIZE];
95 };
96
97 /** CTC table, used for Chroma Tone Control.
98  *
99  *  ISP block: CTC1 (CTC by look-up table)
100  *  ISP1: CTC1 is used.
101  * (ISP2: CTC2 (CTC by polygonal line approximation) is used.)
102  */
103 struct ia_css_ctc_table {
104         enum ia_css_vamem_type vamem_type;
105         union ia_css_ctc_data data;
106 };
107
108 #endif /* __IA_CSS_CTC_TYPES_H */
109
110