1 /* 2 * Copyright (c) 2022 Rockchip Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 #ifndef _RK_ISPFEC_API_H_ 19 #define _RK_ISPFEC_API_H_ 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 typedef struct rk_ispfec_ctx_s rk_ispfec_ctx_t; 26 27 enum rk_ispfec_update_mesh_mode { 28 RK_ISPFEC_UPDATE_MESH_ONLINE = 0, // generate lut online 29 RK_ISPFEC_UPDATE_MESH_FROM_FILE, // external file import mesh 30 }; 31 32 enum rk_ispfec_correct_direction { 33 RK_ISPFEC_CORRECT_DIRECTION_X = 0x1, 34 RK_ISPFEC_CORRECT_DIRECTION_Y, 35 RK_ISPFEC_CORRECT_DIRECTION_XY 36 }; 37 38 enum rk_ispfec_correct_style { 39 RK_ISPFEC_KEEP_ASPECT_RATIO_REDUCE_FOV = 0x1, 40 RK_ISPFEC_COMPRES_IMAGE_KEEP_FOV, 41 }; 42 43 /** 44 * the following prarams are only effective in 'RK_ISPFEC_UPDATE_MESH_ON_LINE'. 45 * 46 * @light_center: the optical center of the lens. 47 * @coefficient: the distortion coefficient of the lens. 48 * @direction: configure the correction direction of the generated mesh. 49 * @style: configure the correction style of the generated mesh. 50 * @correct_level: the distortion type of FEC. 51 */ 52 typedef struct gen_mesh_online_info_s { 53 double light_center[2]; 54 double coeff[4]; 55 enum rk_ispfec_correct_direction direction; 56 enum rk_ispfec_correct_style style; 57 58 int correct_level; 59 } gen_mesh_online_info_t; 60 61 typedef struct mesh_info_s { 62 int dmaFd; 63 void* vir_addr; 64 int size; 65 char mesh_file[64]; 66 } mesh_info_t; 67 68 typedef struct rk_ispfec_cfg_s { 69 // 输入输出的分辨率 70 int in_width; 71 int in_height; 72 int out_width; 73 int out_height; 74 // 输入输出的 v4l2 fmt 75 int in_fourcc; 76 int out_fourcc; 77 // mesh 表 buf fd,外部分配,可用 rk_ispfec_api_calFecMeshsize 计算size 78 mesh_info_t mesh_xint; 79 mesh_info_t mesh_xfra; 80 mesh_info_t mesh_yint; 81 mesh_info_t mesh_yfra; 82 83 enum rk_ispfec_update_mesh_mode mesh_upd_mode; 84 85 /** 86 * @UPDATE_MESH_ONLINE : configure the online info from fec calibration for 'mesh_file_path' 87 * @UPDATE_MESH_FROM_FILE: configure the path of mesh file for 'mesh_online' 88 */ 89 union { 90 char mesh_file_path[128]; 91 gen_mesh_online_info_t mesh_online; 92 } u; 93 } rk_ispfec_cfg_t; 94 95 rk_ispfec_ctx_t* rk_ispfec_api_init(rk_ispfec_cfg_t* cfg); 96 97 // prepare 时cfg可为 NULL,为NULL时使用 init时的。 98 // prepare 可用于 reconfig 参数 99 int rk_ispfec_api_prepare(rk_ispfec_ctx_t* ctx, rk_ispfec_cfg_t* cfg); 100 101 int rk_ispfec_api_process(rk_ispfec_ctx_t* ctx, int src_fd, int dst_fd); 102 103 void rk_ispfec_api_deinit(rk_ispfec_ctx_t* ctx); 104 105 // helper functions 106 // 用于计算 mesh buf 所需 size 107 int rk_ispfec_api_calFecMeshsize(int width, int height); 108 109 #ifdef __cplusplus 110 } 111 #endif 112 113 #endif 114