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 <assert_support.h>
17 #include <ia_css_frame_public.h>
18 #include <ia_css_frame.h>
19 #include <ia_css_binary.h>
20 #include <ia_css_types.h>
21 #include <sh_css_defs.h>
22 #include <ia_css_debug.h>
23
24 #define IA_CSS_INCLUDE_CONFIGURATIONS
25 #include "ia_css_isp_configs.h"
26 #include "isp.h"
27
28 #include "ia_css_fpn.host.h"
29
30 void
ia_css_fpn_encode(struct sh_css_isp_fpn_params * to,const struct ia_css_fpn_table * from,unsigned int size)31 ia_css_fpn_encode(
32 struct sh_css_isp_fpn_params *to,
33 const struct ia_css_fpn_table *from,
34 unsigned int size)
35 {
36 (void)size;
37 to->shift = from->shift;
38 to->enabled = from->data != NULL;
39 }
40
41 void
ia_css_fpn_dump(const struct sh_css_isp_fpn_params * fpn,unsigned int level)42 ia_css_fpn_dump(
43 const struct sh_css_isp_fpn_params *fpn,
44 unsigned int level)
45 {
46 if (!fpn) return;
47 ia_css_debug_dtrace(level, "Fixed Pattern Noise Reduction:\n");
48 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
49 "fpn_shift", fpn->shift);
50 ia_css_debug_dtrace(level, "\t%-32s = %d\n",
51 "fpn_enabled", fpn->enabled);
52 }
53
54 void
ia_css_fpn_config(struct sh_css_isp_fpn_isp_config * to,const struct ia_css_fpn_configuration * from,unsigned int size)55 ia_css_fpn_config(
56 struct sh_css_isp_fpn_isp_config *to,
57 const struct ia_css_fpn_configuration *from,
58 unsigned int size)
59 {
60 unsigned int elems_a = ISP_VEC_NELEMS;
61
62 (void)size;
63 ia_css_dma_configure_from_info(&to->port_b, from->info);
64 to->width_a_over_b = elems_a / to->port_b.elems;
65
66 /* Assume divisiblity here, may need to generalize to fixed point. */
67 assert(elems_a % to->port_b.elems == 0);
68 }
69
70 void
ia_css_fpn_configure(const struct ia_css_binary * binary,const struct ia_css_frame_info * info)71 ia_css_fpn_configure(
72 const struct ia_css_binary *binary,
73 const struct ia_css_frame_info *info)
74 {
75 struct ia_css_frame_info my_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO;
76 const struct ia_css_fpn_configuration config = {
77 &my_info
78 };
79
80 my_info.res.width = CEIL_DIV(info->res.width, 2); /* Packed by 2x */
81 my_info.res.height = info->res.height;
82 my_info.padded_width = CEIL_DIV(info->padded_width, 2); /* Packed by 2x */
83 my_info.format = info->format;
84 my_info.raw_bit_depth = FPN_BITS_PER_PIXEL;
85 my_info.raw_bayer_order = info->raw_bayer_order;
86 my_info.crop_info = info->crop_info;
87
88 ia_css_configure_fpn(binary, &config);
89 }
90