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