1 /* 2 *rk_aiq_types_afec_algo_prvt.h 3 * 4 * Copyright (c) 2019 Rockchip Corporation 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 */ 19 20 #ifndef _RK_AIQ_TYPES_AFEC_ALGO_PRVT_H_ 21 #define _RK_AIQ_TYPES_AFEC_ALGO_PRVT_H_ 22 23 #include "RkAiqCalibDbTypes.h" 24 #include <xcam_mutex.h> 25 #include "xcam_thread.h" 26 #include "smartptr.h" 27 #include "safe_list.h" 28 #include "xcam_log.h" 29 #include "gen_mesh/genMesh.h" 30 #include "afec/rk_aiq_types_afec_algo_int.h" 31 #include "rk_aiq_types_priv.h" 32 33 RKAIQ_BEGIN_DECLARE 34 35 using namespace XCam; 36 37 typedef enum { 38 FEC_CORRECT_LEVEL0, // 100% 39 FEC_CORRECT_LEVEL1, // 75% 40 FEC_CORRECT_LEVEL2, // 50% 41 FEC_CORRECT_LEVEL3, // 25% 42 FEC_BYPASS 43 } FECCorrectLevel; 44 45 typedef enum FECState_e { 46 FEC_STATE_INVALID = 0, /**< initialization value */ 47 FEC_STATE_INITIALIZED = 1, /**< instance is created, but not initialized */ 48 FEC_STATE_STOPPED = 2, /**< instance is confiured (ready to start) or stopped */ 49 FEC_STATE_RUNNING = 3, /**< instance is running (processes frames) */ 50 FEC_STATE_MAX /**< max */ 51 } FECState_t; 52 53 class RKAiqAfecThread; 54 55 typedef struct FECContext_s { 56 unsigned char initialized; 57 unsigned int fec_en; 58 fec_correct_mode_t mode; 59 unsigned int mesh_density; //0:16x8 1:32x16 60 unsigned int fec_mesh_h_size; 61 unsigned int fec_mesh_v_size; 62 unsigned int fec_mesh_size; 63 int correct_level; 64 fec_correct_direction_t correct_direction; 65 int src_width; 66 int src_height; 67 int dst_width; 68 int dst_height; 69 unsigned int sw_rd_vir_stride; 70 unsigned int sw_wr_yuv_format; //0:YUV420 1:YUV422 71 unsigned int sw_wr_vir_stride; 72 unsigned int sw_fec_wr_fbce_mode; //0:normal 1:fbec 73 unsigned short* meshxi; 74 unsigned char* meshxf; 75 unsigned short* meshyi; 76 unsigned char* meshyf; 77 char meshfile[256]; 78 const char* resource_path; 79 int meshSizeW; 80 int meshSizeH; 81 int meshStepW; 82 int meshStepH; 83 struct CameraCoeff camCoeff; 84 FecParams fecParams; 85 FECState_t eState; 86 87 std::atomic<bool> isAttribUpdated; 88 rk_aiq_fec_cfg_t user_config; 89 SmartPtr<RKAiqAfecThread> afecReadMeshThread; 90 isp_drv_share_mem_ops_t *share_mem_ops; 91 rk_aiq_fec_share_mem_info_t *fec_mem_info; 92 void* share_mem_ctx; 93 } FECContext_t; 94 95 typedef struct FECContext_s* FECHandle_t; 96 97 typedef struct _RkAiqAlgoContext { 98 FECHandle_t hFEC; 99 void* place_holder[0]; 100 } RkAiqAlgoContext; 101 102 RKAIQ_END_DECLARE 103 104 class RKAiqAfecThread 105 : public Thread { 106 public: RKAiqAfecThread(FECHandle_t fecHandle)107 RKAiqAfecThread(FECHandle_t fecHandle) 108 : Thread("afecThread") 109 , hFEC(fecHandle) {}; ~RKAiqAfecThread()110 ~RKAiqAfecThread() { 111 mAttrQueue.clear (); 112 }; 113 triger_stop()114 void triger_stop() { 115 mAttrQueue.pause_pop (); 116 }; 117 triger_start()118 void triger_start() { 119 mAttrQueue.resume_pop (); 120 }; 121 push_attr(const SmartPtr<rk_aiq_fec_cfg_t> buffer)122 bool push_attr (const SmartPtr<rk_aiq_fec_cfg_t> buffer) { 123 mAttrQueue.push (buffer); 124 return true; 125 }; 126 is_empty()127 bool is_empty () { 128 return mAttrQueue.is_empty(); 129 }; 130 clear_attr()131 void clear_attr () { 132 mAttrQueue.clear (); 133 }; 134 135 protected: 136 //virtual bool started (); stopped()137 virtual void stopped () { 138 mAttrQueue.clear (); 139 }; 140 virtual bool loop (); 141 private: 142 FECHandle_t hFEC; 143 SafeList<rk_aiq_fec_cfg_t> mAttrQueue; 144 }; 145 146 #endif 147 148