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_CSC_TYPES_H
17 #define __IA_CSS_CSC_TYPES_H
18 
19 /* @file
20 * CSS-API header file for Color Space Conversion parameters.
21 */
22 
23 /* Color Correction configuration.
24  *
25  *  This structure is used for 3 cases.
26  *  ("YCgCo" is the output format of Demosaic.)
27  *
28  *  1. Color Space Conversion (YCgCo to YUV) for ISP1.
29  *     ISP block: CSC1 (Color Space Conversion)
30  *     struct ia_css_cc_config   *cc_config
31  *
32  *  2. Color Correction Matrix (YCgCo to RGB) for ISP2.
33  *     ISP block: CCM2 (Color Correction Matrix)
34  *     struct ia_css_cc_config   *yuv2rgb_cc_config
35  *
36  *  3. Color Space Conversion (RGB to YUV) for ISP2.
37  *     ISP block: CSC2 (Color Space Conversion)
38  *     struct ia_css_cc_config   *rgb2yuv_cc_config
39  *
40  *  default/ineffective:
41  *  1. YCgCo -> YUV
42  *	1	0.174		0.185
43  *	0	-0.66252	-0.66874
44  *	0	-0.83738	0.58131
45  *
46  *	fraction_bits = 12
47  *	4096	713	758
48  *	0	-2714	-2739
49  *	0	-3430	2381
50  *
51  *  2. YCgCo -> RGB
52  *	1	-1	1
53  *	1	1	0
54  *	1	-1	-1
55  *
56  *	fraction_bits = 12
57  *	4096	-4096	4096
58  *	4096	4096	0
59  *	4096	-4096	-4096
60  *
61  *  3. RGB -> YUV
62  *	0.299	   0.587	0.114
63  *	-0.16874   -0.33126	0.5
64  *	0.5	   -0.41869	-0.08131
65  *
66  *	fraction_bits = 13
67  *	2449	4809	934
68  *	-1382	-2714	4096
69  *	4096	-3430	-666
70  */
71 struct ia_css_cc_config {
72 	u32 fraction_bits;/** Fractional bits of matrix.
73 					u8.0, [0,13] */
74 	s32 matrix[3 * 3]; /** Conversion matrix.
75 					s[13-fraction_bits].[fraction_bits],
76 					[-8192,8191] */
77 };
78 
79 #endif /* __IA_CSS_CSC_TYPES_H */
80