1 /* 2 * Allwinner SoCs display driver. 3 * 4 * Copyright (C) 2016 Allwinner. 5 * 6 * This file is licensed under the terms of the GNU General Public 7 * License version 2. This program is licensed "as is" without any 8 * warranty of any kind, whether express or implied. 9 */ 10 11 /******************************************************************************* 12 * All Winner Tech, All Right Reserved. 2014-2015 Copyright (c) 13 * 14 * File name : de_fce_type.h 15 * 16 * Description : display engine 2.0 fce struct declaration 17 * 18 * History : 2014/04/01 vito cheng v0.1 Initial version 19 * 2014/04/29 vito cheng v0.2 Add __fce_config_data 20 ******************************************************************************/ 21 22 #ifndef __DE_FCE_TYPE_H__ 23 #define __DE_FCE_TYPE_H__ 24 25 #include "de_rtmx.h" 26 27 /* 28 * 0x0: do hist in even frame; 29 * 0x1, do hist in odd frame; 30 * 0x2, do hist in all frames 31 */ 32 #define HIST_FRAME_MASK 0x00000002 33 34 /* 35 * 0x0: do CE in even frame; 36 * 0x1, do CE in odd frame; 37 * 0x2, do CE in all frames 38 */ 39 #define CE_FRAME_MASK 0x00000002 40 41 #define LCE_PARA_NUM 2 42 #define LCE_MODE_NUM 2 43 44 #define AUTOCE_PARA_NUM 5 45 #define AUTOCE_MODE_NUM 3 46 47 #define CE_PARA_NUM 2 48 #define CE_MODE_NUM 2 49 50 #define FTC_PARA_NUM 2 51 #define FTC_MODE_NUM 2 52 53 #define AVG_NUM 8 54 55 /* for hist */ 56 extern unsigned int *g_hist[DE_NUM][CHN_NUM]; 57 extern unsigned int *g_hist_p[DE_NUM][CHN_NUM]; 58 extern unsigned int g_sum[DE_NUM][CHN_NUM]; 59 60 extern unsigned int g_format[DE_NUM]; 61 62 union FCE_GCTRL_REG { 63 unsigned int dwval; 64 struct { 65 unsigned int en:1; 66 unsigned int res0:15; 67 unsigned int hist_en:1; 68 unsigned int ce_en:1; 69 unsigned int lce_en:1; 70 unsigned int res1:1; 71 unsigned int ftc_en:1; 72 unsigned int res2:10; 73 unsigned int win_en:1; 74 } bits; 75 }; 76 77 union FCE_SIZE_REG { 78 unsigned int dwval; 79 struct { 80 unsigned int width:12; 81 unsigned int res0:4; 82 unsigned int height:12; 83 unsigned int res1:4; 84 } bits; 85 }; 86 87 union FCE_WIN0_REG { 88 unsigned int dwval; 89 struct { 90 unsigned int win_left:12; 91 unsigned int res0:4; 92 unsigned int win_top:12; 93 unsigned int res1:4; 94 } bits; 95 }; 96 97 union FCE_WIN1_REG { 98 unsigned int dwval; 99 struct { 100 unsigned int win_right:12; 101 unsigned int res0:4; 102 unsigned int win_bot:12; 103 unsigned int res1:4; 104 } bits; 105 }; 106 107 union LCE_GAIN_REG { 108 unsigned int dwval; 109 struct { 110 unsigned int lce_gain:6; 111 unsigned int res0:2; 112 unsigned int lce_blend:8; 113 unsigned int res1:16; 114 } bits; 115 }; 116 117 union HIST_SUM_REG { 118 unsigned int dwval; 119 struct { 120 unsigned int sum:32; 121 } bits; 122 }; 123 124 union HIST_STATUS_REG { 125 unsigned int dwval; 126 struct { 127 unsigned int hist_valid:1; 128 unsigned int res0:31; 129 } bits; 130 }; 131 132 union CE_STATUS_REG { 133 unsigned int dwval; 134 struct { 135 unsigned int celut_access_switch:1; 136 unsigned int res0:31; 137 } bits; 138 }; 139 140 union FTC_GAIN_REG { 141 unsigned int dwval; 142 struct { 143 unsigned int ftc_gain1:8; 144 unsigned int res0:8; 145 unsigned int ftc_gain2:8; 146 unsigned int res1:8; 147 } bits; 148 }; 149 150 union FTC_CSCBYPASS_REG { 151 unsigned int dwval; 152 struct { 153 unsigned int csc_bypass:1; 154 unsigned int res0:31; 155 } bits; 156 }; 157 158 union CE_LUT_REG { 159 unsigned int dwval; 160 struct { 161 unsigned int lut0:8; 162 unsigned int lut1:8; 163 unsigned int lut2:8; 164 unsigned int lut3:8; 165 } bits; 166 }; 167 168 union HIST_CNT_REG { 169 unsigned int dwval; 170 struct { 171 unsigned int hist:22; 172 unsigned int res0:10; 173 } bits; 174 }; 175 176 struct __fce_reg_t { 177 union FCE_GCTRL_REG ctrl; /* 0x0000 */ 178 union FCE_SIZE_REG size; /* 0x0004 */ 179 union FCE_WIN0_REG win0; /* 0x0008 */ 180 union FCE_WIN1_REG win1; /* 0x000c */ 181 union LCE_GAIN_REG lcegain; /* 0x0010 */ 182 unsigned int res0[3]; /* 0x0014-0x001c */ 183 union HIST_SUM_REG histsum; /* 0x0020 */ 184 union HIST_STATUS_REG histstauts; /* 0x0024 */ 185 union CE_STATUS_REG cestatus; /* 0x0028 */ 186 unsigned int res1; /* 0x002c */ 187 union FTC_GAIN_REG ftcgain; /* 0x0030 */ 188 unsigned int res2[3]; /* 0x0034-0x003c */ 189 union FTC_CSCBYPASS_REG cscbypass; /* 0x0040 */ 190 unsigned int res3[47]; /* 0x0044-0x00fc */ 191 union CE_LUT_REG celut[64]; /* 0x0100-0x01fc */ 192 union HIST_CNT_REG hist[256]; /* 0x0200-0x05fc */ 193 }; 194 195 struct __fce_config_data { 196 /* global */ 197 unsigned int fce_en; 198 199 /* ce */ 200 unsigned int ce_en; 201 unsigned int up_precent_thr; 202 unsigned int down_precent_thr; 203 unsigned int b_automode; 204 unsigned int update_diff_thr; 205 206 /* bws */ 207 unsigned int present_black; 208 unsigned int present_white; 209 unsigned int slope_black_lmt; 210 unsigned int slope_white_lmt; 211 unsigned int black_prec; 212 unsigned int white_prec; 213 unsigned int lowest_black; 214 unsigned int highest_white; 215 216 /* lce */ 217 unsigned int lce_en; 218 unsigned int lce_blend; 219 unsigned int lce_gain; 220 221 /* ftc */ 222 unsigned int ftc_en; 223 unsigned int ftc_gain1; 224 unsigned int ftc_gain2; 225 226 unsigned int hist_en; 227 228 unsigned int win_en; 229 struct de_rect win; 230 }; 231 232 struct __hist_status_t { 233 /* Frame number of Histogram run */ 234 unsigned int runtime; 235 /* Histogram enabled */ 236 unsigned int isenable; 237 /* Already get histogram of two frames */ 238 unsigned int twohistready; 239 }; 240 241 struct __ce_status_t { 242 unsigned int isenable; /* CE enabled */ 243 unsigned int b_automode; /* 0: Constant CE ; 1: Auto CE */ 244 unsigned int width; 245 unsigned int height; 246 /* alg */ 247 unsigned int up_precent_thr; 248 unsigned int down_precent_thr; 249 unsigned int update_diff_thr; 250 unsigned int slope_black_lmt; 251 unsigned int slope_white_lmt; 252 253 }; 254 255 struct hist_data { 256 unsigned int hist_mean; 257 unsigned int old_hist_mean; 258 int hist_mean_diff; 259 unsigned int avg_mean_saved[AVG_NUM]; 260 unsigned int avg_mean_idx; 261 unsigned int avg_mean; 262 unsigned int counter; 263 unsigned int diff_coeff; 264 265 unsigned int black_thr0; 266 unsigned int black_thr1; 267 unsigned int white_thr0; 268 unsigned int white_thr1; 269 270 unsigned int black_slp0; 271 unsigned int black_slp1; 272 unsigned int white_slp0; 273 unsigned int white_slp1; 274 275 }; 276 277 #endif 278