Linux-libre 4.14.44-gnu
[librecmc/linux-libre.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / csc / csc_1.0 / ia_css_csc.host.c
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 #include "ia_css_types.h"
16 #include "sh_css_defs.h"
17 #ifndef IA_CSS_NO_DEBUG
18 /* FIXME: See BZ 4427 */
19 #include "ia_css_debug.h"
20 #endif
21
22 #include "ia_css_csc.host.h"
23
24 const struct ia_css_cc_config default_cc_config = {
25         8,
26         {255, 29, 120, 0, -374, -342, 0, -672, 301},
27 };
28
29 void
30 ia_css_encode_cc(
31         struct sh_css_isp_csc_params *to,
32         const struct ia_css_cc_config *from,
33         unsigned size)
34 {
35         (void)size;
36 #ifndef IA_CSS_NO_DEBUG
37         ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_encode_cc() enter:\n");
38 #endif
39
40         to->m_shift    = (int16_t) from->fraction_bits;
41         to->m00 = (int16_t) from->matrix[0];
42         to->m01 = (int16_t) from->matrix[1];
43         to->m02 = (int16_t) from->matrix[2];
44         to->m10 = (int16_t) from->matrix[3];
45         to->m11 = (int16_t) from->matrix[4];
46         to->m12 = (int16_t) from->matrix[5];
47         to->m20 = (int16_t) from->matrix[6];
48         to->m21 = (int16_t) from->matrix[7];
49         to->m22 = (int16_t) from->matrix[8];
50
51 #ifndef IA_CSS_NO_DEBUG
52         ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_encode_cc() leave:\n");
53 #endif
54 }
55
56 void
57 ia_css_csc_encode(
58         struct sh_css_isp_csc_params *to,
59         const struct ia_css_cc_config *from,
60         unsigned size)
61 {
62         ia_css_encode_cc(to, from, size);
63 }
64
65 #ifndef IA_CSS_NO_DEBUG
66 void
67 ia_css_cc_dump(
68         const struct sh_css_isp_csc_params *csc,
69         unsigned level,
70         const char *name)
71 {
72         if (!csc) return;
73         ia_css_debug_dtrace(level, "%s\n", name);
74         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
75                 "m_shift",
76                 csc->m_shift);
77         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
78                 "m00",
79                 csc->m00);
80         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
81                 "m01",
82                 csc->m01);
83         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
84                 "m02",
85                 csc->m02);
86         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
87                 "m10",
88                 csc->m10);
89         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
90                 "m11",
91                 csc->m11);
92         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
93                 "m12",
94                 csc->m12);
95         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
96                 "m20",
97                 csc->m20);
98         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
99                 "m21",
100                 csc->m21);
101         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
102                 "m22",
103                 csc->m22);
104 }
105
106 void
107 ia_css_csc_dump(
108         const struct sh_css_isp_csc_params *csc,
109         unsigned level)
110 {
111         ia_css_cc_dump(csc, level, "Color Space Conversion");
112 }
113
114 void
115 ia_css_cc_config_debug_dtrace(
116         const struct ia_css_cc_config *config,
117         unsigned level)
118 {
119         ia_css_debug_dtrace(level,
120                 "config.m[0]=%d, "
121                 "config.m[1]=%d, config.m[2]=%d, "
122                 "config.m[3]=%d, config.m[4]=%d, "
123                 "config.m[5]=%d, config.m[6]=%d, "
124                 "config.m[7]=%d, config.m[8]=%d\n",
125                 config->matrix[0],
126                 config->matrix[1], config->matrix[2],
127                 config->matrix[3], config->matrix[4],
128                 config->matrix[5], config->matrix[6],
129                 config->matrix[7], config->matrix[8]);
130 }
131 #endif
132