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