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 "sh_css_frac.h"
19#ifndef IA_CSS_NO_DEBUG
20#include "ia_css_debug.h"
21#endif
22#include "isp.h"
23#include "ia_css_ob2.host.h"
24
25const struct ia_css_ob2_config default_ob2_config = {
26	0,
27	0,
28	0,
29	0
30};
31
32void
33ia_css_ob2_encode(
34    struct sh_css_isp_ob2_params *to,
35    const struct ia_css_ob2_config *from,
36    unsigned int size)
37{
38	(void)size;
39
40	/* Blacklevels types are u0_16 */
41	to->blacklevel_gr = uDIGIT_FITTING(from->level_gr, 16, SH_CSS_BAYER_BITS);
42	to->blacklevel_r  = uDIGIT_FITTING(from->level_r,  16, SH_CSS_BAYER_BITS);
43	to->blacklevel_b  = uDIGIT_FITTING(from->level_b,  16, SH_CSS_BAYER_BITS);
44	to->blacklevel_gb = uDIGIT_FITTING(from->level_gb, 16, SH_CSS_BAYER_BITS);
45}
46
47#ifndef IA_CSS_NO_DEBUG
48void
49ia_css_ob2_dump(
50    const struct sh_css_isp_ob2_params *ob2,
51    unsigned int level)
52{
53	if (!ob2)
54		return;
55
56	ia_css_debug_dtrace(level, "Optical Black 2:\n");
57	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
58			    "ob2_blacklevel_gr", ob2->blacklevel_gr);
59	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
60			    "ob2_blacklevel_r", ob2->blacklevel_r);
61	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
62			    "ob2_blacklevel_b", ob2->blacklevel_b);
63	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
64			    "ob2_blacklevel_gb", ob2->blacklevel_gb);
65}
66
67void
68ia_css_ob2_debug_dtrace(
69    const struct ia_css_ob2_config *config,
70    unsigned int level)
71{
72	ia_css_debug_dtrace(level,
73			    "config.level_gr=%d, config.level_r=%d, config.level_b=%d,  config.level_gb=%d, ",
74			    config->level_gr, config->level_r,
75			    config->level_b, config->level_gb);
76}
77#endif
78