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_bws_type.h
15  *
16  *  Description :   display engine 2.0 bws struct declaration
17  *
18  *  History     :   2014/03/26  vito cheng  v0.1  Initial version
19  *
20  *****************************************************************************/
21 
22 #ifndef __DE_BWS_TYPE_H__
23 #define __DE_BWS_TYPE_H__
24 
25 #include "de_rtmx.h"
26 
27 /* for hist */
28 extern unsigned int *g_hist[DE_NUM][CHN_NUM];
29 extern unsigned int *g_hist_p[DE_NUM][CHN_NUM];
30 extern unsigned int g_sum[DE_NUM][CHN_NUM];
31 extern struct __hist_status_t *g_hist_status[DE_NUM][CHN_NUM];
32 
33 #define BWS_FRAME_MASK  0x00000002
34 /*
35  * 0x0: do bws in odd frame;
36  * 0x1, do bws in even frame;
37  * 0x2, do bws in all frames
38  */
39 #define BWS_DEFAULT_SLOPE 0x100
40 
41 union BWS_CTRL_REG {
42     unsigned int dwval;
43     struct {
44         unsigned int en:1;
45         unsigned int res:30;
46         unsigned int win_en:1;
47     } bits;
48 };
49 
50 union BWS_SIZE_REG {
51     unsigned int dwval;
52     struct {
53         unsigned int width:12;
54         unsigned int res0:4;
55         unsigned int height:12;
56         unsigned int res1:4;
57     } bits;
58 };
59 
60 union BWS_WIN0_REG {
61     unsigned int dwval;
62     struct {
63         unsigned int win_left:12;
64         unsigned int res0:4;
65         unsigned int win_top:12;
66         unsigned int res1:4;
67     } bits;
68 };
69 
70 union BWS_WIN1_REG {
71     unsigned int dwval;
72     struct {
73         unsigned int win_right:12;
74         unsigned int res0:4;
75         unsigned int win_bot:12;
76         unsigned int res1:4;
77     } bits;
78 };
79 
80 union BWS_LS_THR0_REG {
81     unsigned int dwval;
82     struct {
83         unsigned int min:8;
84         unsigned int res0:8;
85         unsigned int black:8;
86         unsigned int res1:8;
87     } bits;
88 };
89 
90 union BWS_LS_THR1_REG {
91     unsigned int dwval;
92     struct {
93         unsigned int white:8;
94         unsigned int res0:8;
95         unsigned int max:8;
96         unsigned int res1:8;
97     } bits;
98 };
99 
100 union BWS_LS_SLP0_REG {
101     unsigned int dwval;
102     struct {
103         unsigned int slope0:10;
104         unsigned int res0:6;
105         unsigned int slope1:10;
106         unsigned int res1:6;
107     } bits;
108 };
109 
110 union BWS_LS_SLP1_REG {
111     unsigned int dwval;
112     struct {
113         unsigned int slope2:10;
114         unsigned int res0:6;
115         unsigned int slope3:10;
116         unsigned int res1:6;
117     } bits;
118 };
119 
120 struct __bws_reg_t {
121     union BWS_CTRL_REG ctrl;        /* 0x0000 */
122     union BWS_SIZE_REG size;        /* 0x0004 */
123     union BWS_WIN0_REG win0;        /* 0x0008 */
124     union BWS_WIN1_REG win1;        /* 0x000c */
125     unsigned int res0[4];         /* 0x0010-0x001c */
126     union BWS_LS_THR0_REG blkthr;   /* 0x0020 */
127     union BWS_LS_THR1_REG whtthr;   /* 0x0024 */
128     union BWS_LS_SLP0_REG blkslp;   /* 0x0028 */
129     union BWS_LS_SLP1_REG whtslp;   /* 0x002c */
130 };
131 
132 struct __bws_config_data {
133     /* bws */
134     unsigned int bws_en;
135     unsigned int bld_high_thr;
136     unsigned int bld_low_thr;
137     unsigned int bld_weight_lmt;
138     unsigned int present_black;
139     unsigned int present_white;
140     unsigned int slope_black_lmt;
141     unsigned int slope_white_lmt;
142     unsigned int black_prec;
143     unsigned int white_prec;
144     unsigned int lowest_black;
145     unsigned int highest_white;
146 
147     /* window */
148     unsigned int win_en;
149     struct de_rect win;
150 };
151 
152 struct __bws_status_t {
153     unsigned int isenable;       /* BWS enabled */
154     unsigned int runtime;          /* Frame number of BWS run */
155     unsigned int preslopeready;  /* Get two slope */
156     unsigned int width;
157     unsigned int height;
158     unsigned int slope_black;
159     unsigned int slope_white;
160 };
161 #endif
162