2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 #include "ia_css_types.h"
16 #include "sh_css_defs.h"
17 #include "ia_css_debug.h"
20 #include "ia_css_ob.host.h"
22 const struct ia_css_ob_config default_ob_config = {
32 /* TODO: include ob.isp.h to get isp knowledge and
33 add assert on platform restrictions */
37 struct sh_css_isp_ob_stream_config *config,
38 unsigned int isp_pipe_version,
39 unsigned int raw_bit_depth)
41 config->isp_pipe_version = isp_pipe_version;
42 config->raw_bit_depth = raw_bit_depth;
47 struct sh_css_isp_ob_params *to,
48 const struct ia_css_ob_config *from,
49 const struct sh_css_isp_ob_stream_config *config,
52 unsigned int ob_bit_depth
53 = config->isp_pipe_version == 2 ? SH_CSS_BAYER_BITS : config->raw_bit_depth;
54 unsigned int scale = 16 - ob_bit_depth;
58 case IA_CSS_OB_MODE_FIXED:
59 to->blacklevel_gr = from->level_gr >> scale;
60 to->blacklevel_r = from->level_r >> scale;
61 to->blacklevel_b = from->level_b >> scale;
62 to->blacklevel_gb = from->level_gb >> scale;
63 to->area_start_bq = 0;
64 to->area_length_bq = 0;
65 to->area_length_bq_inverse = 0;
67 case IA_CSS_OB_MODE_RASTER:
68 to->blacklevel_gr = 0;
71 to->blacklevel_gb = 0;
72 to->area_start_bq = from->start_position;
74 (from->end_position - from->start_position) + 1;
75 to->area_length_bq_inverse = AREA_LENGTH_UNIT / to->area_length_bq;
78 to->blacklevel_gr = 0;
81 to->blacklevel_gb = 0;
82 to->area_start_bq = 0;
83 to->area_length_bq = 0;
84 to->area_length_bq_inverse = 0;
90 ia_css_ob_vmem_encode(
91 struct sh_css_isp_ob_vmem_params *to,
92 const struct ia_css_ob_config *from,
93 const struct sh_css_isp_ob_stream_config *config,
96 struct sh_css_isp_ob_params tmp;
97 struct sh_css_isp_ob_params *ob = &tmp;
100 ia_css_ob_encode(&tmp, from, config, sizeof(tmp));
104 unsigned sp_obarea_start_bq = ob->area_start_bq;
105 unsigned sp_obarea_length_bq = ob->area_length_bq;
106 unsigned low = sp_obarea_start_bq;
107 unsigned high = low + sp_obarea_length_bq;
108 uint16_t all_ones = ~0;
110 for (i = 0; i < OBAREA_MASK_SIZE; i++) {
111 if (i >= low && i < high)
112 to->vmask[i/ISP_VEC_NELEMS][i%ISP_VEC_NELEMS] = all_ones;
114 to->vmask[i/ISP_VEC_NELEMS][i%ISP_VEC_NELEMS] = 0;
121 const struct sh_css_isp_ob_params *ob,
125 ia_css_debug_dtrace(level, "Optical Black:\n");
126 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
127 "ob_blacklevel_gr", ob->blacklevel_gr);
128 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
129 "ob_blacklevel_r", ob->blacklevel_r);
130 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
131 "ob_blacklevel_b", ob->blacklevel_b);
132 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
133 "ob_blacklevel_gb", ob->blacklevel_gb);
134 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
135 "obarea_start_bq", ob->area_start_bq);
136 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
137 "obarea_length_bq", ob->area_length_bq);
138 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
139 "obarea_length_bq_inverse",
140 ob->area_length_bq_inverse);
145 ia_css_ob_debug_dtrace(
146 const struct ia_css_ob_config *config,
149 ia_css_debug_dtrace(level,
151 "config.level_gr=%d, config.level_r=%d, "
152 "config.level_b=%d, config.level_gb=%d, "
153 "config.start_position=%d, config.end_position=%d\n",
155 config->level_gr, config->level_r,
156 config->level_b, config->level_gb,
157 config->start_position, config->end_position);