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