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