GNU Linux-libre 4.14.313-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / output / output_1.0 / ia_css_output.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_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 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 size)
57 {
58         unsigned 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->res.height;
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 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 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 (NULL != 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 (NULL != 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
127         if (NULL != info) {
128                 struct ia_css_output1_configuration config =
129                                 default_output1_configuration;
130
131                 config.info = info;
132
133                 ia_css_configure_output1(binary, &config);
134         }
135 }
136
137 void
138 ia_css_output_dump(
139         const struct sh_css_isp_output_params *output,
140         unsigned level)
141 {
142         if (!output) return;
143         ia_css_debug_dtrace(level, "Horizontal Output Flip:\n");
144         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
145                         "enable", output->enable_hflip);
146         ia_css_debug_dtrace(level, "Vertical Output Flip:\n");
147         ia_css_debug_dtrace(level, "\t%-32s = %d\n",
148                         "enable", output->enable_vflip);
149 }
150
151 void
152 ia_css_output_debug_dtrace(
153         const struct ia_css_output_config *config,
154         unsigned level)
155 {
156         ia_css_debug_dtrace(level,
157                 "config.enable_hflip=%d",
158                 config->enable_hflip);
159         ia_css_debug_dtrace(level,
160                 "config.enable_vflip=%d",
161                 config->enable_vflip);
162 }