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 #ifndef IA_CSS_NO_DEBUG
10 #include "ia_css_debug.h"
11 #endif
12 #include "sh_css_frac.h"
13
14 #include "ia_css_wb.host.h"
15
16 const struct ia_css_wb_config default_wb_config = {
17 1,
18 32768,
19 32768,
20 32768,
21 32768
22 };
23
24 void
ia_css_wb_encode(struct sh_css_isp_wb_params * to,const struct ia_css_wb_config * from,unsigned int size)25 ia_css_wb_encode(
26 struct sh_css_isp_wb_params *to,
27 const struct ia_css_wb_config *from,
28 unsigned int size)
29 {
30 (void)size;
31 to->gain_shift =
32 uISP_REG_BIT - from->integer_bits;
33 to->gain_gr =
34 uDIGIT_FITTING(from->gr, 16 - from->integer_bits,
35 to->gain_shift);
36 to->gain_r =
37 uDIGIT_FITTING(from->r, 16 - from->integer_bits,
38 to->gain_shift);
39 to->gain_b =
40 uDIGIT_FITTING(from->b, 16 - from->integer_bits,
41 to->gain_shift);
42 to->gain_gb =
43 uDIGIT_FITTING(from->gb, 16 - from->integer_bits,
44 to->gain_shift);
45 }
46
47 #ifndef IA_CSS_NO_DEBUG
48 void
ia_css_wb_dump(const struct sh_css_isp_wb_params * wb,unsigned int level)49 ia_css_wb_dump(
50 const struct sh_css_isp_wb_params *wb,
51 unsigned int level)
52 {
53 if (!wb) return;
54 ia_css_debug_dtrace(level, "White Balance:\n");
55 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
56 "wb_gain_shift", wb->gain_shift);
57 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
58 "wb_gain_gr", wb->gain_gr);
59 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
60 "wb_gain_r", wb->gain_r);
61 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
62 "wb_gain_b", wb->gain_b);
63 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
64 "wb_gain_gb", wb->gain_gb);
65 }
66
67 void
ia_css_wb_debug_dtrace(const struct ia_css_wb_config * config,unsigned int level)68 ia_css_wb_debug_dtrace(
69 const struct ia_css_wb_config *config,
70 unsigned int level)
71 {
72 ia_css_debug_dtrace(level,
73 "config.integer_bits=%d, config.gr=%d, config.r=%d, config.b=%d, config.gb=%d\n",
74 config->integer_bits,
75 config->gr, config->r,
76 config->b, config->gb);
77 }
78 #endif
79