GNU Linux-libre 4.14.332-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / iterator / iterator_1.0 / ia_css_iterator.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 "ia_css_iterator.host.h"
16 #include "ia_css_frame_public.h"
17 #include "ia_css_binary.h"
18 #include "ia_css_err.h"
19 #define IA_CSS_INCLUDE_CONFIGURATIONS
20 #include "ia_css_isp_configs.h"
21
22 static const struct ia_css_iterator_configuration default_config = {
23         .input_info = (struct ia_css_frame_info *)NULL,
24 };
25
26 void
27 ia_css_iterator_config(
28         struct sh_css_isp_iterator_isp_config *to,
29         const struct ia_css_iterator_configuration *from,
30         unsigned size)
31 {
32         (void)size;
33         ia_css_frame_info_to_frame_sp_info(&to->input_info,    from->input_info);
34         ia_css_frame_info_to_frame_sp_info(&to->internal_info, from->internal_info);
35         ia_css_frame_info_to_frame_sp_info(&to->output_info,   from->output_info);
36         ia_css_frame_info_to_frame_sp_info(&to->vf_info,       from->vf_info);
37         ia_css_resolution_to_sp_resolution(&to->dvs_envelope,  from->dvs_envelope);
38 }
39
40 enum ia_css_err
41 ia_css_iterator_configure(
42         const struct ia_css_binary *binary,
43         const struct ia_css_frame_info *in_info)
44 {
45         struct ia_css_frame_info my_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO;
46         struct ia_css_iterator_configuration config = default_config;
47
48         config.input_info    = &binary->in_frame_info;
49         config.internal_info = &binary->internal_frame_info;
50         config.output_info   = &binary->out_frame_info[0];
51         config.vf_info       = &binary->vf_frame_info;
52         config.dvs_envelope  = &binary->dvs_envelope;
53
54         /* Use in_info iso binary->in_frame_info.
55          * They can differ in padded width in case of scaling, e.g. for capture_pp.
56          * Find out why.
57         */
58         if (in_info)
59                 config.input_info = in_info;
60         if (binary->out_frame_info[0].res.width == 0)
61                 config.output_info = &binary->out_frame_info[1];
62         my_info = *config.output_info;
63         config.output_info = &my_info;
64         /* we do this only for preview pipe because in fill_binary_info function
65          * we assign vf_out res to out res, but for ISP internal processing, we need
66          * the original out res. for video pipe, it has two output pins --- out and
67          * vf_out, so it can keep these two resolutions already. */
68         if (binary->info->sp.pipeline.mode == IA_CSS_BINARY_MODE_PREVIEW &&
69             binary->vf_downscale_log2 > 0) {
70                 /* TODO: Remove this after preview output decimation is fixed
71                  * by configuring out&vf info files properly */
72                 my_info.padded_width <<= binary->vf_downscale_log2;
73                 my_info.res.width    <<= binary->vf_downscale_log2;
74                 my_info.res.height   <<= binary->vf_downscale_log2;
75         }
76
77         ia_css_configure_iterator(binary, &config);
78
79         return IA_CSS_SUCCESS;
80 }