df4cb9c362a4ef33e5893428619c2c5226786156
[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_frame.h"
16 #include "ia_css_debug.h"
17 #define IA_CSS_INCLUDE_CONFIGURATIONS
18 #include "ia_css_isp_configs.h"
19 #include "ia_css_output.host.h"
20 #include "isp.h"
21
22 #include "assert_support.h"
23
24 const struct ia_css_output_config default_output_config = {
25         0,
26         0
27 };
28
29 static const struct ia_css_output_configuration default_output_configuration = {
30         .info = (struct ia_css_frame_info *)NULL,
31 };
32
33 static const struct ia_css_output0_configuration default_output0_configuration
34         = {
35         .info = (struct ia_css_frame_info *)NULL,
36 };
37
38 static const struct ia_css_output1_configuration default_output1_configuration
39         = {
40         .info = (struct ia_css_frame_info *)NULL,
41 };
42
43 void
44 ia_css_output_encode(
45     struct sh_css_isp_output_params *to,
46     const struct ia_css_output_config *from,
47     unsigned int size)
48 {
49         (void)size;
50         to->enable_hflip = from->enable_hflip;
51         to->enable_vflip = from->enable_vflip;
52 }
53
54 void
55 ia_css_output_config(
56     struct sh_css_isp_output_isp_config *to,
57     const struct ia_css_output_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         to->height = from->info ? from->info->res.height : 0;
66         to->enable = from->info != NULL;
67         ia_css_frame_info_to_frame_sp_info(&to->info, from->info);
68
69         /* Assume divisiblity here, may need to generalize to fixed point. */
70         assert(elems_a % to->port_b.elems == 0);
71 }
72
73 void
74 ia_css_output0_config(
75     struct sh_css_isp_output_isp_config       *to,
76     const struct ia_css_output0_configuration *from,
77     unsigned int size)
78 {
79         ia_css_output_config(
80             to, (const struct ia_css_output_configuration *)from, size);
81 }
82
83 void
84 ia_css_output1_config(
85     struct sh_css_isp_output_isp_config       *to,
86     const struct ia_css_output1_configuration *from,
87     unsigned int size)
88 {
89         ia_css_output_config(
90             to, (const struct ia_css_output_configuration *)from, size);
91 }
92
93 void
94 ia_css_output_configure(
95     const struct ia_css_binary     *binary,
96     const struct ia_css_frame_info *info)
97 {
98         if (info) {
99                 struct ia_css_output_configuration config =
100                             default_output_configuration;
101
102                 config.info = info;
103
104                 ia_css_configure_output(binary, &config);
105         }
106 }
107
108 void
109 ia_css_output0_configure(
110     const struct ia_css_binary     *binary,
111     const struct ia_css_frame_info *info)
112 {
113         if (info) {
114                 struct ia_css_output0_configuration config =
115                             default_output0_configuration;
116
117                 config.info = info;
118
119                 ia_css_configure_output0(binary, &config);
120         }
121 }
122
123 void
124 ia_css_output1_configure(
125     const struct ia_css_binary     *binary,
126     const struct ia_css_frame_info *info)
127 {
128         if (info) {
129                 struct ia_css_output1_configuration config =
130                             default_output1_configuration;
131
132                 config.info = info;
133
134                 ia_css_configure_output1(binary, &config);
135         }
136 }
137
138 void
139 ia_css_output_dump(
140     const struct sh_css_isp_output_params *output,
141     unsigned int level)
142 {
143         if (!output) return;
144         ia_css_debug_dtrace(level, "Horizontal Output Flip:\n");
145         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
146                             "enable", output->enable_hflip);
147         ia_css_debug_dtrace(level, "Vertical Output Flip:\n");
148         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
149                             "enable", output->enable_vflip);
150 }
151
152 void
153 ia_css_output_debug_dtrace(
154     const struct ia_css_output_config *config,
155     unsigned int level)
156 {
157         ia_css_debug_dtrace(level,
158                             "config.enable_hflip=%d",
159                             config->enable_hflip);
160         ia_css_debug_dtrace(level,
161                             "config.enable_vflip=%d",
162                             config->enable_vflip);
163 }