49c1b3e3370df259a66287cace6d97c89d6cecac
[linux.git] /
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 int 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         struct ia_css_frame_info my_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO;
45         struct ia_css_iterator_configuration config = default_config;
46
47         config.input_info    = &binary->in_frame_info;
48         config.internal_info = &binary->internal_frame_info;
49         config.output_info   = &binary->out_frame_info[0];
50         config.vf_info       = &binary->vf_frame_info;
51         config.dvs_envelope  = &binary->dvs_envelope;
52
53         /* Use in_info iso binary->in_frame_info.
54          * They can differ in padded width in case of scaling, e.g. for capture_pp.
55          * Find out why.
56         */
57         if (in_info)
58                 config.input_info = in_info;
59         if (binary->out_frame_info[0].res.width == 0)
60                 config.output_info = &binary->out_frame_info[1];
61         my_info = *config.output_info;
62         config.output_info = &my_info;
63         /* we do this only for preview pipe because in fill_binary_info function
64          * we assign vf_out res to out res, but for ISP internal processing, we need
65          * the original out res. for video pipe, it has two output pins --- out and
66          * vf_out, so it can keep these two resolutions already. */
67         if (binary->info->sp.pipeline.mode == IA_CSS_BINARY_MODE_PREVIEW &&
68             binary->vf_downscale_log2 > 0)
69         {
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 }