1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  */
6 
7 #include "ia_css_types.h"
8 #include "sh_css_defs.h"
9 #include "ia_css_debug.h"
10 #include "assert_support.h"
11 
12 #include "ia_css_ynr2.host.h"
13 
14 const struct ia_css_ynr_config default_ynr_config = {
15 	0,
16 	0,
17 	0,
18 	0,
19 };
20 
21 const struct ia_css_fc_config default_fc_config = {
22 	1,
23 	0,		/* 0 -> ineffective */
24 	0,		/* 0 -> ineffective */
25 	0,		/* 0 -> ineffective */
26 	0,		/* 0 -> ineffective */
27 	(1 << (ISP_VEC_ELEMBITS - 2)),		/* 0.5 */
28 	(1 << (ISP_VEC_ELEMBITS - 2)),		/* 0.5 */
29 	(1 << (ISP_VEC_ELEMBITS - 2)),		/* 0.5 */
30 	(1 << (ISP_VEC_ELEMBITS - 2)),		/* 0.5 */
31 	(1 << (ISP_VEC_ELEMBITS - 1)) - 1,	/* 1 */
32 	(1 << (ISP_VEC_ELEMBITS - 1)) - 1,	/* 1 */
33 	(int16_t)-(1 << (ISP_VEC_ELEMBITS - 1)),	/* -1 */
34 	(int16_t)-(1 << (ISP_VEC_ELEMBITS - 1)),	/* -1 */
35 };
36 
37 void
ia_css_ynr_encode(struct sh_css_isp_yee2_params * to,const struct ia_css_ynr_config * from,unsigned int size)38 ia_css_ynr_encode(
39     struct sh_css_isp_yee2_params *to,
40     const struct ia_css_ynr_config *from,
41     unsigned int size)
42 {
43 	(void)size;
44 	to->edge_sense_gain_0   = from->edge_sense_gain_0;
45 	to->edge_sense_gain_1   = from->edge_sense_gain_1;
46 	to->corner_sense_gain_0 = from->corner_sense_gain_0;
47 	to->corner_sense_gain_1 = from->corner_sense_gain_1;
48 }
49 
50 void
ia_css_fc_encode(struct sh_css_isp_fc_params * to,const struct ia_css_fc_config * from,unsigned int size)51 ia_css_fc_encode(
52     struct sh_css_isp_fc_params *to,
53     const struct ia_css_fc_config *from,
54     unsigned int size)
55 {
56 	(void)size;
57 	to->gain_exp   = from->gain_exp;
58 
59 	to->coring_pos_0 = from->coring_pos_0;
60 	to->coring_pos_1 = from->coring_pos_1;
61 	to->coring_neg_0 = from->coring_neg_0;
62 	to->coring_neg_1 = from->coring_neg_1;
63 
64 	to->gain_pos_0 = from->gain_pos_0;
65 	to->gain_pos_1 = from->gain_pos_1;
66 	to->gain_neg_0 = from->gain_neg_0;
67 	to->gain_neg_1 = from->gain_neg_1;
68 
69 	to->crop_pos_0 = from->crop_pos_0;
70 	to->crop_pos_1 = from->crop_pos_1;
71 	to->crop_neg_0 = from->crop_neg_0;
72 	to->crop_neg_1 = from->crop_neg_1;
73 }
74 
75 void
76 ia_css_ynr_dump(
77     const struct sh_css_isp_yee2_params *yee2,
78     unsigned int level);
79 
80 void
81 ia_css_fc_dump(
82     const struct sh_css_isp_fc_params *fc,
83     unsigned int level);
84 
85 void
ia_css_fc_debug_dtrace(const struct ia_css_fc_config * config,unsigned int level)86 ia_css_fc_debug_dtrace(
87     const struct ia_css_fc_config *config,
88     unsigned int level)
89 {
90 	ia_css_debug_dtrace(level,
91 			    "config.gain_exp=%d, config.coring_pos_0=%d, config.coring_pos_1=%d, config.coring_neg_0=%d, config.coring_neg_1=%d, config.gain_pos_0=%d, config.gain_pos_1=%d, config.gain_neg_0=%d, config.gain_neg_1=%d, config.crop_pos_0=%d, config.crop_pos_1=%d, config.crop_neg_0=%d, config.crop_neg_1=%d\n",
92 			    config->gain_exp,
93 			    config->coring_pos_0, config->coring_pos_1,
94 			    config->coring_neg_0, config->coring_neg_1,
95 			    config->gain_pos_0, config->gain_pos_1,
96 			    config->gain_neg_0, config->gain_neg_1,
97 			    config->crop_pos_0, config->crop_pos_1,
98 			    config->crop_neg_0, config->crop_neg_1);
99 }
100 
101 void
ia_css_ynr_debug_dtrace(const struct ia_css_ynr_config * config,unsigned int level)102 ia_css_ynr_debug_dtrace(
103     const struct ia_css_ynr_config *config,
104     unsigned int level)
105 {
106 	ia_css_debug_dtrace(level,
107 			    "config.edge_sense_gain_0=%d, config.edge_sense_gain_1=%d, config.corner_sense_gain_0=%d, config.corner_sense_gain_1=%d\n",
108 			    config->edge_sense_gain_0, config->edge_sense_gain_1,
109 			    config->corner_sense_gain_0, config->corner_sense_gain_1);
110 }
111