xref: /linux/drivers/staging/media/atomisp/pci/isp/kernels/ynr/ynr_2/ia_css_ynr2.host.c (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
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 #include "ia_css_ynr2.host.h"
22 
23 const struct ia_css_ynr_config default_ynr_config = {
24 	0,
25 	0,
26 	0,
27 	0,
28 };
29 
30 const struct ia_css_fc_config default_fc_config = {
31 	1,
32 	0,		/* 0 -> ineffective */
33 	0,		/* 0 -> ineffective */
34 	0,		/* 0 -> ineffective */
35 	0,		/* 0 -> ineffective */
36 	(1 << (ISP_VEC_ELEMBITS - 2)),		/* 0.5 */
37 	(1 << (ISP_VEC_ELEMBITS - 2)),		/* 0.5 */
38 	(1 << (ISP_VEC_ELEMBITS - 2)),		/* 0.5 */
39 	(1 << (ISP_VEC_ELEMBITS - 2)),		/* 0.5 */
40 	(1 << (ISP_VEC_ELEMBITS - 1)) - 1,	/* 1 */
41 	(1 << (ISP_VEC_ELEMBITS - 1)) - 1,	/* 1 */
42 	(int16_t)-(1 << (ISP_VEC_ELEMBITS - 1)),	/* -1 */
43 	(int16_t)-(1 << (ISP_VEC_ELEMBITS - 1)),	/* -1 */
44 };
45 
46 void
ia_css_ynr_encode(struct sh_css_isp_yee2_params * to,const struct ia_css_ynr_config * from,unsigned int size)47 ia_css_ynr_encode(
48     struct sh_css_isp_yee2_params *to,
49     const struct ia_css_ynr_config *from,
50     unsigned int size)
51 {
52 	(void)size;
53 	to->edge_sense_gain_0   = from->edge_sense_gain_0;
54 	to->edge_sense_gain_1   = from->edge_sense_gain_1;
55 	to->corner_sense_gain_0 = from->corner_sense_gain_0;
56 	to->corner_sense_gain_1 = from->corner_sense_gain_1;
57 }
58 
59 void
ia_css_fc_encode(struct sh_css_isp_fc_params * to,const struct ia_css_fc_config * from,unsigned int size)60 ia_css_fc_encode(
61     struct sh_css_isp_fc_params *to,
62     const struct ia_css_fc_config *from,
63     unsigned int size)
64 {
65 	(void)size;
66 	to->gain_exp   = from->gain_exp;
67 
68 	to->coring_pos_0 = from->coring_pos_0;
69 	to->coring_pos_1 = from->coring_pos_1;
70 	to->coring_neg_0 = from->coring_neg_0;
71 	to->coring_neg_1 = from->coring_neg_1;
72 
73 	to->gain_pos_0 = from->gain_pos_0;
74 	to->gain_pos_1 = from->gain_pos_1;
75 	to->gain_neg_0 = from->gain_neg_0;
76 	to->gain_neg_1 = from->gain_neg_1;
77 
78 	to->crop_pos_0 = from->crop_pos_0;
79 	to->crop_pos_1 = from->crop_pos_1;
80 	to->crop_neg_0 = from->crop_neg_0;
81 	to->crop_neg_1 = from->crop_neg_1;
82 }
83 
84 void
85 ia_css_ynr_dump(
86     const struct sh_css_isp_yee2_params *yee2,
87     unsigned int level);
88 
89 void
90 ia_css_fc_dump(
91     const struct sh_css_isp_fc_params *fc,
92     unsigned int level);
93 
94 void
ia_css_fc_debug_dtrace(const struct ia_css_fc_config * config,unsigned int level)95 ia_css_fc_debug_dtrace(
96     const struct ia_css_fc_config *config,
97     unsigned int level)
98 {
99 	ia_css_debug_dtrace(level,
100 			    "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",
101 			    config->gain_exp,
102 			    config->coring_pos_0, config->coring_pos_1,
103 			    config->coring_neg_0, config->coring_neg_1,
104 			    config->gain_pos_0, config->gain_pos_1,
105 			    config->gain_neg_0, config->gain_neg_1,
106 			    config->crop_pos_0, config->crop_pos_1,
107 			    config->crop_neg_0, config->crop_neg_1);
108 }
109 
110 void
ia_css_ynr_debug_dtrace(const struct ia_css_ynr_config * config,unsigned int level)111 ia_css_ynr_debug_dtrace(
112     const struct ia_css_ynr_config *config,
113     unsigned int level)
114 {
115 	ia_css_debug_dtrace(level,
116 			    "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",
117 			    config->edge_sense_gain_0, config->edge_sense_gain_1,
118 			    config->corner_sense_gain_0, config->corner_sense_gain_1);
119 }
120