1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  */
6 
7 #include <assert_support.h>
8 #include <ia_css_frame_public.h>
9 #include <ia_css_frame.h>
10 #include <ia_css_binary.h>
11 #define IA_CSS_INCLUDE_CONFIGURATIONS
12 #include "ia_css_isp_configs.h"
13 #include "isp.h"
14 #include "ia_css_crop.host.h"
15 
16 static const struct ia_css_crop_configuration default_config = {
17 	.info = (struct ia_css_frame_info *)NULL,
18 };
19 
20 void
ia_css_crop_encode(struct sh_css_isp_crop_isp_params * to,const struct ia_css_crop_config * from,unsigned int size)21 ia_css_crop_encode(
22     struct sh_css_isp_crop_isp_params *to,
23     const struct ia_css_crop_config *from,
24     unsigned int size)
25 {
26 	(void)size;
27 	to->crop_pos = from->crop_pos;
28 }
29 
ia_css_crop_config(struct sh_css_isp_crop_isp_config * to,const struct ia_css_crop_configuration * from,unsigned int size)30 int ia_css_crop_config(struct sh_css_isp_crop_isp_config *to,
31 		       const struct ia_css_crop_configuration *from,
32 		       unsigned int size)
33 {
34 	unsigned int elems_a = ISP_VEC_NELEMS;
35 	int ret;
36 
37 	ret = ia_css_dma_configure_from_info(&to->port_b, from->info);
38 	if (ret)
39 		return ret;
40 
41 	to->width_a_over_b = elems_a / to->port_b.elems;
42 
43 	/* Assume divisiblity here, may need to generalize to fixed point. */
44 	if (elems_a % to->port_b.elems != 0)
45 		return -EINVAL;
46 
47 	return 0;
48 }
49 
ia_css_crop_configure(const struct ia_css_binary * binary,const struct ia_css_frame_info * info)50 int ia_css_crop_configure(const struct ia_css_binary     *binary,
51 			  const struct ia_css_frame_info *info)
52 {
53 	struct ia_css_crop_configuration config = default_config;
54 
55 	config.info = info;
56 
57 	return ia_css_configure_crop(binary, &config);
58 }
59