1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #include "ia_css_frame.h"
17 #include "ia_css_types.h"
18 #include "sh_css_defs.h"
19 #include "ia_css_debug.h"
20 #include "assert_support.h"
21 #define IA_CSS_INCLUDE_CONFIGURATIONS
22 #include "ia_css_isp_configs.h"
23 #include "isp.h"
24 
25 #include "ia_css_qplane.host.h"
26 
27 static const struct ia_css_qplane_configuration default_config = {
28 	.pipe = (struct sh_css_sp_pipeline *)NULL,
29 };
30 
ia_css_qplane_config(struct sh_css_isp_qplane_isp_config * to,const struct ia_css_qplane_configuration * from,unsigned int size)31 int ia_css_qplane_config(struct sh_css_isp_qplane_isp_config *to,
32 			 const struct ia_css_qplane_configuration  *from,
33 			 unsigned int size)
34 {
35 	unsigned int elems_a = ISP_VEC_NELEMS;
36 	int ret;
37 
38 	ret = ia_css_dma_configure_from_info(&to->port_b, from->info);
39 	if (ret)
40 		return ret;
41 
42 	to->width_a_over_b = elems_a / to->port_b.elems;
43 
44 	/* Assume divisiblity here, may need to generalize to fixed point. */
45 	if (elems_a % to->port_b.elems != 0)
46 		return -EINVAL;
47 
48 	to->inout_port_config = from->pipe->inout_port_config;
49 	to->format = from->info->format;
50 
51 	return 0;
52 }
53 
ia_css_qplane_configure(const struct sh_css_sp_pipeline * pipe,const struct ia_css_binary * binary,const struct ia_css_frame_info * info)54 int ia_css_qplane_configure(const struct sh_css_sp_pipeline *pipe,
55 			    const struct ia_css_binary      *binary,
56 			    const struct ia_css_frame_info  *info)
57 {
58 	struct ia_css_qplane_configuration config = default_config;
59 
60 	config.pipe = pipe;
61 	config.info = info;
62 
63 	return ia_css_configure_qplane(binary, &config);
64 }
65