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 #include "ia_css_debug.h"
19 #include "assert_support.h"
20 
21 #define IA_CSS_INCLUDE_CONFIGURATIONS
22 #include "ia_css_isp_configs.h"
23 
24 #include "ia_css_sc.host.h"
25 
26 void
ia_css_sc_encode(struct sh_css_isp_sc_params * to,struct ia_css_shading_table ** from,unsigned int size)27 ia_css_sc_encode(
28     struct sh_css_isp_sc_params *to,
29     struct ia_css_shading_table **from,
30     unsigned int size)
31 {
32 	(void)size;
33 	to->gain_shift = (*from)->fraction_bits;
34 }
35 
36 void
ia_css_sc_dump(const struct sh_css_isp_sc_params * sc,unsigned int level)37 ia_css_sc_dump(
38     const struct sh_css_isp_sc_params *sc,
39     unsigned int level)
40 {
41 	if (!sc) return;
42 	ia_css_debug_dtrace(level, "Shading Correction:\n");
43 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
44 			    "sc_gain_shift", sc->gain_shift);
45 }
46 
47 /* ------ deprecated(bz675) : from ------ */
48 /* It looks like @parameter{} (in *.pipe) is used to generate the process/get/set functions,
49    for parameters which should be used in the isp kernels.
50    However, the ia_css_shading_settings structure has a parameter which is used only in the css,
51    and does not have a parameter which is used in the isp kernels.
52    Then, I did not use @parameter{} to generate the get/set function
53    for the ia_css_shading_settings structure. (michie) */
54 void
sh_css_get_shading_settings(const struct ia_css_isp_parameters * params,struct ia_css_shading_settings * settings)55 sh_css_get_shading_settings(const struct ia_css_isp_parameters *params,
56 			    struct ia_css_shading_settings *settings)
57 {
58 	if (!settings)
59 		return;
60 	assert(params);
61 
62 	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
63 			    "ia_css_get_shading_settings() enter: settings=%p\n", settings);
64 
65 	*settings = params->shading_settings;
66 
67 	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
68 			    "ia_css_get_shading_settings() leave: settings.enable_shading_table_conversion=%d\n",
69 			    settings->enable_shading_table_conversion);
70 }
71 
72 void
sh_css_set_shading_settings(struct ia_css_isp_parameters * params,const struct ia_css_shading_settings * settings)73 sh_css_set_shading_settings(struct ia_css_isp_parameters *params,
74 			    const struct ia_css_shading_settings *settings)
75 {
76 	if (!settings)
77 		return;
78 	assert(params);
79 
80 	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
81 			    "ia_css_set_shading_settings() enter: settings.enable_shading_table_conversion=%d\n",
82 			    settings->enable_shading_table_conversion);
83 
84 	params->shading_settings = *settings;
85 	params->shading_settings_changed = true;
86 
87 	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
88 			    "ia_css_set_shading_settings() leave: return_void\n");
89 }
90 
91 /* ------ deprecated(bz675) : to ------ */
92