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 "sh_css_frac.h"
20 #include "ia_css_de.host.h"
21 
22 const struct ia_css_de_config default_de_config = {
23 	0,
24 	0,
25 	0
26 };
27 
28 void
ia_css_de_encode(struct sh_css_isp_de_params * to,const struct ia_css_de_config * from,unsigned int size)29 ia_css_de_encode(
30     struct sh_css_isp_de_params *to,
31     const struct ia_css_de_config *from,
32     unsigned int size)
33 {
34 	(void)size;
35 	to->pixelnoise =
36 	    uDIGIT_FITTING(from->pixelnoise, 16, SH_CSS_BAYER_BITS);
37 	to->c1_coring_threshold =
38 	    uDIGIT_FITTING(from->c1_coring_threshold, 16,
39 			   SH_CSS_BAYER_BITS);
40 	to->c2_coring_threshold =
41 	    uDIGIT_FITTING(from->c2_coring_threshold, 16,
42 			   SH_CSS_BAYER_BITS);
43 }
44 
45 void
ia_css_de_dump(const struct sh_css_isp_de_params * de,unsigned int level)46 ia_css_de_dump(
47     const struct sh_css_isp_de_params *de,
48     unsigned int level)
49 {
50 	if (!de) return;
51 	ia_css_debug_dtrace(level, "Demosaic:\n");
52 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
53 			    "de_pixelnoise", de->pixelnoise);
54 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
55 			    "de_c1_coring_threshold",
56 			    de->c1_coring_threshold);
57 	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
58 			    "de_c2_coring_threshold",
59 			    de->c2_coring_threshold);
60 }
61 
62 void
ia_css_de_debug_dtrace(const struct ia_css_de_config * config,unsigned int level)63 ia_css_de_debug_dtrace(
64     const struct ia_css_de_config *config,
65     unsigned int level)
66 {
67 	ia_css_debug_dtrace(level,
68 			    "config.pixelnoise=%d, config.c1_coring_threshold=%d, config.c2_coring_threshold=%d\n",
69 			    config->pixelnoise,
70 			    config->c1_coring_threshold, config->c2_coring_threshold);
71 }
72 
73 void
ia_css_init_de_state(void * state,size_t size)74 ia_css_init_de_state(
75     void/*struct sh_css_isp_de_vmem_state*/ * state,
76     size_t size)
77 {
78 	memset(state, 0, size);
79 }
80