1 #ifndef ISP2401 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 #else 16 /** 17 Support for Intel Camera Imaging ISP subsystem. 18 Copyright (c) 2010 - 2015, Intel Corporation. 19 20 This program is free software; you can redistribute it and/or modify it 21 under the terms and conditions of the GNU General Public License, 22 version 2, as published by the Free Software Foundation. 23 24 This program is distributed in the hope it will be useful, but WITHOUT 25 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 26 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 27 more details. 28 */ 29 #endif 30 31 #ifndef __IA_CSS_FRAME_H__ 32 #define __IA_CSS_FRAME_H__ 33 34 #ifdef ISP2401 35 #include <ia_css_types.h> 36 #endif 37 #include <ia_css_frame_format.h> 38 #include <ia_css_frame_public.h> 39 #include "dma.h" 40 41 /********************************************************************* 42 **** Frame INFO APIs 43 **********************************************************************/ 44 /** @brief Sets the given width and alignment to the frame info 45 * 46 * @param 47 * @param[in] info The info to which parameters would set 48 * @param[in] width The width to be set to info 49 * @param[in] aligned The aligned to be set to info 50 * @return 51 */ 52 void ia_css_frame_info_set_width(struct ia_css_frame_info *info, 53 unsigned int width, 54 unsigned int min_padded_width); 55 56 /** @brief Sets the given format to the frame info 57 * 58 * @param 59 * @param[in] info The info to which parameters would set 60 * @param[in] format The format to be set to info 61 * @return 62 */ 63 void ia_css_frame_info_set_format(struct ia_css_frame_info *info, 64 enum ia_css_frame_format format); 65 66 /** @brief Sets the frame info with the given parameters 67 * 68 * @param 69 * @param[in] info The info to which parameters would set 70 * @param[in] width The width to be set to info 71 * @param[in] height The height to be set to info 72 * @param[in] format The format to be set to info 73 * @param[in] aligned The aligned to be set to info 74 * @return 75 */ 76 void ia_css_frame_info_init(struct ia_css_frame_info *info, 77 unsigned int width, 78 unsigned int height, 79 enum ia_css_frame_format format, 80 unsigned int aligned); 81 82 /** @brief Checks whether 2 frame infos has the same resolution 83 * 84 * @param 85 * @param[in] frame_a The first frame to be compared 86 * @param[in] frame_b The second frame to be compared 87 * @return Returns true if the frames are equal 88 */ 89 bool ia_css_frame_info_is_same_resolution( 90 const struct ia_css_frame_info *info_a, 91 const struct ia_css_frame_info *info_b); 92 93 /** @brief Check the frame info is valid 94 * 95 * @param 96 * @param[in] info The frame attributes to be initialized 97 * @return The error code. 98 */ 99 enum ia_css_err ia_css_frame_check_info(const struct ia_css_frame_info *info); 100 101 /********************************************************************* 102 **** Frame APIs 103 **********************************************************************/ 104 105 /** @brief Initialize the plane depending on the frame type 106 * 107 * @param 108 * @param[in] frame The frame attributes to be initialized 109 * @return The error code. 110 */ 111 enum ia_css_err ia_css_frame_init_planes(struct ia_css_frame *frame); 112 113 /** @brief Free an array of frames 114 * 115 * @param 116 * @param[in] num_frames The number of frames to be freed in the array 117 * @param[in] **frames_array The array of frames to be removed 118 * @return 119 */ 120 void ia_css_frame_free_multiple(unsigned int num_frames, 121 struct ia_css_frame **frames_array); 122 123 /** @brief Allocate a CSS frame structure of given size in bytes.. 124 * 125 * @param frame The allocated frame. 126 * @param[in] size_bytes The frame size in bytes. 127 * @param[in] contiguous Allocate memory physically contiguously or not. 128 * @return The error code. 129 * 130 * Allocate a frame using the given size in bytes. 131 * The frame structure is partially null initialized. 132 */ 133 enum ia_css_err ia_css_frame_allocate_with_buffer_size( 134 struct ia_css_frame **frame, 135 const unsigned int size_bytes, 136 const bool contiguous); 137 138 /** @brief Check whether 2 frames are same type 139 * 140 * @param 141 * @param[in] frame_a The first frame to be compared 142 * @param[in] frame_b The second frame to be compared 143 * @return Returns true if the frames are equal 144 */ 145 bool ia_css_frame_is_same_type( 146 const struct ia_css_frame *frame_a, 147 const struct ia_css_frame *frame_b); 148 149 /** @brief Configure a dma port from frame info 150 * 151 * @param 152 * @param[in] config The DAM port configuration 153 * @param[in] info The frame info 154 * @return 155 */ 156 void ia_css_dma_configure_from_info( 157 struct dma_port_config *config, 158 const struct ia_css_frame_info *info); 159 160 #ifdef ISP2401 161 /** @brief Finds the cropping resolution 162 * This function finds the maximum cropping resolution in an input image keeping 163 * the aspect ratio for the given output resolution.Calculates the coordinates 164 * for cropping from the center and returns the starting pixel location of the 165 * region in the input image. Also returns the dimension of the cropping 166 * resolution. 167 * 168 * @param 169 * @param[in] in_res Resolution of input image 170 * @param[in] out_res Resolution of output image 171 * @param[out] crop_res Crop resolution of input image 172 * @return Returns IA_CSS_SUCCESS or IA_CSS_ERR_INVALID_ARGUMENTS on error 173 */ 174 enum ia_css_err 175 ia_css_frame_find_crop_resolution(const struct ia_css_resolution *in_res, 176 const struct ia_css_resolution *out_res, 177 struct ia_css_resolution *crop_res); 178 179 #endif 180 #endif /* __IA_CSS_FRAME_H__ */ 181