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 #ifndef __IA_CSS_UTIL_H__ 17 #define __IA_CSS_UTIL_H__ 18 19 #include <linux/errno.h> 20 21 #include <ia_css_err.h> 22 #include <type_support.h> 23 #include <ia_css_frame_public.h> 24 #include <ia_css_stream_public.h> 25 #include <ia_css_stream_format.h> 26 27 /* @brief convert "errno" error code to "ia_css_err" error code 28 * 29 * @param[in] "errno" error code 30 * @return "ia_css_err" error code 31 * 32 */ 33 int ia_css_convert_errno( 34 int in_err); 35 36 /* @brief check vf frame info. 37 * 38 * @param[in] info 39 * @return 0 or error code upon error. 40 * 41 */ 42 int ia_css_util_check_vf_info( 43 const struct ia_css_frame_info *const info); 44 45 /* @brief check input configuration. 46 * 47 * @param[in] stream_config 48 * @param[in] must_be_raw 49 * @return 0 or error code upon error. 50 * 51 */ 52 int ia_css_util_check_input( 53 const struct ia_css_stream_config *const stream_config, 54 bool must_be_raw, 55 bool must_be_yuv); 56 57 /* @brief check vf and out frame info. 58 * 59 * @param[in] out_info 60 * @param[in] vf_info 61 * @return 0 or error code upon error. 62 * 63 */ 64 int ia_css_util_check_vf_out_info( 65 const struct ia_css_frame_info *const out_info, 66 const struct ia_css_frame_info *const vf_info); 67 68 /* @brief check width and height 69 * 70 * @param[in] width 71 * @param[in] height 72 * @return 0 or error code upon error. 73 * 74 */ 75 int ia_css_util_check_res( 76 unsigned int width, 77 unsigned int height); 78 79 /* ISP2401 */ 80 /* @brief compare resolutions (less or equal) 81 * 82 * @param[in] a resolution 83 * @param[in] b resolution 84 * @return true if both dimensions of a are less or 85 * equal than those of b, false otherwise 86 * 87 */ 88 bool ia_css_util_res_leq( 89 struct ia_css_resolution a, 90 struct ia_css_resolution b); 91 92 /* ISP2401 */ 93 /** 94 * @brief Check if resolution is zero 95 * 96 * @param[in] resolution The resolution to check 97 * 98 * @returns true if resolution is zero 99 */ 100 bool ia_css_util_resolution_is_zero( 101 const struct ia_css_resolution resolution); 102 103 /* ISP2401 */ 104 /** 105 * @brief Check if resolution is even 106 * 107 * @param[in] resolution The resolution to check 108 * 109 * @returns true if resolution is even 110 */ 111 bool ia_css_util_resolution_is_even( 112 const struct ia_css_resolution resolution); 113 114 /* @brief check width and height 115 * 116 * @param[in] stream_format 117 * @param[in] two_ppc 118 * @return bits per pixel based on given parameters. 119 * 120 */ 121 unsigned int ia_css_util_input_format_bpp( 122 enum atomisp_input_format stream_format, 123 bool two_ppc); 124 125 /* @brief check if input format it raw 126 * 127 * @param[in] stream_format 128 * @return true if the input format is raw or false otherwise 129 * 130 */ 131 bool ia_css_util_is_input_format_raw( 132 enum atomisp_input_format stream_format); 133 134 /* @brief check if input format it yuv 135 * 136 * @param[in] stream_format 137 * @return true if the input format is yuv or false otherwise 138 * 139 */ 140 bool ia_css_util_is_input_format_yuv( 141 enum atomisp_input_format stream_format); 142 143 #endif /* __IA_CSS_UTIL_H__ */ 144