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_GC_TYPES_H
17 #define __IA_CSS_GC_TYPES_H
18 
19 /* @file
20 * CSS-API header file for Gamma Correction parameters.
21 */
22 
23 #include "isp/kernels/ctc/ctc_1.0/ia_css_ctc_types.h"  /* FIXME: Needed for ia_css_vamem_type */
24 
25 /* Fractional bits for GAMMA gain */
26 #define IA_CSS_GAMMA_GAIN_K_SHIFT      13
27 
28 /* Number of elements in the gamma table. */
29 #define IA_CSS_VAMEM_1_GAMMA_TABLE_SIZE_LOG2    10
30 #define IA_CSS_VAMEM_1_GAMMA_TABLE_SIZE         BIT(IA_CSS_VAMEM_1_GAMMA_TABLE_SIZE_LOG2)
31 
32 /* Number of elements in the gamma table. */
33 #define IA_CSS_VAMEM_2_GAMMA_TABLE_SIZE_LOG2    8
34 #define IA_CSS_VAMEM_2_GAMMA_TABLE_SIZE         ((1U << IA_CSS_VAMEM_2_GAMMA_TABLE_SIZE_LOG2) + 1)
35 
36 /* Gamma table, used for Y(Luma) Gamma Correction.
37  *
38  *  ISP block: GC1 (YUV Gamma Correction)
39  *  ISP1: GC1 is used.
40  * (ISP2: GC2(sRGB Gamma Correction) is used.)
41  */
42 /** IA_CSS_VAMEM_TYPE_1(ISP2300) or
43      IA_CSS_VAMEM_TYPE_2(ISP2400) */
44 union ia_css_gc_data {
45 	u16 vamem_1[IA_CSS_VAMEM_1_GAMMA_TABLE_SIZE];
46 	/** Y(Luma) Gamma table on vamem type 1. u0.8, [0,255] */
47 	u16 vamem_2[IA_CSS_VAMEM_2_GAMMA_TABLE_SIZE];
48 	/** Y(Luma) Gamma table on vamem type 2. u0.8, [0,255] */
49 };
50 
51 struct ia_css_gamma_table {
52 	enum ia_css_vamem_type vamem_type;
53 	union ia_css_gc_data data;
54 };
55 
56 /* Gamma Correction configuration (used only for YUV Gamma Correction).
57  *
58  *  ISP block: GC1 (YUV Gamma Correction)
59  *  ISP1: GC1 is used.
60  * (ISP2: GC2 (sRGB Gamma Correction) is used.)
61   */
62 struct ia_css_gc_config {
63 	u16 gain_k1; /** Gain to adjust U after YUV Gamma Correction.
64 				u0.16, [0,65535],
65 				default/ineffective 19000(0.29) */
66 	u16 gain_k2; /** Gain to adjust V after YUV Gamma Correction.
67 				u0.16, [0,65535],
68 				default/ineffective 19000(0.29) */
69 };
70 
71 /* Chroma Enhancement configuration.
72  *
73  *  This parameter specifies range of chroma output level.
74  *  The standard range is [0,255] or [16,240].
75  *
76  *  ISP block: CE1
77  *  ISP1: CE1 is used.
78  * (ISP2: CE1 is not used.)
79  */
80 struct ia_css_ce_config {
81 	u8 uv_level_min; /** Minimum of chroma output level.
82 				u0.8, [0,255], default/ineffective 0 */
83 	u8 uv_level_max; /** Maximum of chroma output level.
84 				u0.8, [0,255], default/ineffective 255 */
85 };
86 
87 /* Multi-Axes Color Correction (MACC) configuration.
88  *
89  *  ISP block: MACC2 (MACC by matrix and exponent(ia_css_macc_config))
90  * (ISP1: MACC1 (MACC by only matrix) is used.)
91  *  ISP2: MACC2 is used.
92  */
93 struct ia_css_macc_config {
94 	u8 exp;	/** Common exponent of ia_css_macc_table.
95 				u8.0, [0,13], default 1, ineffective 1 */
96 };
97 
98 #endif /* __IA_CSS_GC_TYPES_H */
99