1
2
3
4
5
6
7
8
9
10
11 #ifndef _ATMEL_ISC_H_
12
13 #define ISC_MAX_SUPPORT_WIDTH 2592
14 #define ISC_MAX_SUPPORT_HEIGHT 1944
15
16 #define ISC_CLK_MAX_DIV 255
17
18 enum isc_clk_id {
19 ISC_ISPCK = 0,
20 ISC_MCK = 1,
21 };
22
23 struct isc_clk {
24 struct clk_hw hw;
25 struct clk *clk;
26 struct regmap *regmap;
27 spinlock_t lock;
28 u8 id;
29 u8 parent_id;
30 u32 div;
31 struct device *dev;
32 };
33
34 #define to_isc_clk(v) container_of(v, struct isc_clk, hw)
35
36 struct isc_buffer {
37 struct vb2_v4l2_buffer vb;
38 struct list_head list;
39 };
40
41 struct isc_subdev_entity {
42 struct v4l2_subdev *sd;
43 struct v4l2_async_subdev *asd;
44 struct v4l2_async_notifier notifier;
45
46 u32 pfe_cfg0;
47
48 struct list_head list;
49 };
50
51
52
53
54
55
56
57
58
59
60
61
62
63 struct isc_format {
64 u32 fourcc;
65 u32 mbus_code;
66 u32 cfa_baycfg;
67
68 bool sd_support;
69 u32 pfe_cfg0_bps;
70 };
71
72
73 #define WB_ENABLE BIT(0)
74 #define CFA_ENABLE BIT(1)
75 #define CC_ENABLE BIT(2)
76 #define GAM_ENABLE BIT(3)
77 #define GAM_BENABLE BIT(4)
78 #define GAM_GENABLE BIT(5)
79 #define GAM_RENABLE BIT(6)
80 #define CSC_ENABLE BIT(7)
81 #define CBC_ENABLE BIT(8)
82 #define SUB422_ENABLE BIT(9)
83 #define SUB420_ENABLE BIT(10)
84
85 #define GAM_ENABLES (GAM_RENABLE | GAM_GENABLE | GAM_BENABLE | GAM_ENABLE)
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 struct fmt_config {
102 struct isc_format *sd_format;
103
104 u32 fourcc;
105 u8 bpp;
106
107 u32 rlp_cfg_mode;
108 u32 dcfg_imode;
109 u32 dctrl_dview;
110
111 u32 bits_pipeline;
112 };
113
114 #define HIST_ENTRIES 512
115 #define HIST_BAYER (ISC_HIS_CFG_MODE_B + 1)
116
117 enum{
118 HIST_INIT = 0,
119 HIST_ENABLED,
120 HIST_DISABLED,
121 };
122
123 struct isc_ctrls {
124 struct v4l2_ctrl_handler handler;
125
126 u32 brightness;
127 u32 contrast;
128 u8 gamma_index;
129 #define ISC_WB_NONE 0
130 #define ISC_WB_AUTO 1
131 #define ISC_WB_ONETIME 2
132 u8 awb;
133
134
135 u32 gain[HIST_BAYER];
136 u32 offset[HIST_BAYER];
137
138 u32 hist_entry[HIST_ENTRIES];
139 u32 hist_count[HIST_BAYER];
140 u8 hist_id;
141 u8 hist_stat;
142 #define HIST_MIN_INDEX 0
143 #define HIST_MAX_INDEX 1
144 u32 hist_minmax[HIST_BAYER][2];
145 };
146
147 #define ISC_PIPE_LINE_NODE_NUM 11
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190 struct isc_device {
191 struct regmap *regmap;
192 struct clk *hclock;
193 struct clk *ispck;
194 struct isc_clk isc_clks[2];
195
196 struct device *dev;
197 struct v4l2_device v4l2_dev;
198 struct video_device video_dev;
199
200 struct vb2_queue vb2_vidq;
201 spinlock_t dma_queue_lock;
202 struct list_head dma_queue;
203 struct isc_buffer *cur_frm;
204 unsigned int sequence;
205 bool stop;
206 struct completion comp;
207
208 struct v4l2_format fmt;
209 struct isc_format **user_formats;
210 unsigned int num_user_formats;
211
212 struct fmt_config config;
213 struct fmt_config try_config;
214
215 struct isc_ctrls ctrls;
216 struct v4l2_ctrl *do_wb_ctrl;
217 struct work_struct awb_work;
218
219 struct mutex lock;
220 spinlock_t awb_lock;
221
222 struct regmap_field *pipeline[ISC_PIPE_LINE_NODE_NUM];
223
224 struct isc_subdev_entity *current_subdev;
225 struct list_head subdev_entities;
226 };
227
228 #define GAMMA_MAX 2
229 #define GAMMA_ENTRIES 64
230
231 #define ATMEL_ISC_NAME "atmel-isc"
232
233 extern struct isc_format formats_list[];
234 extern const struct isc_format controller_formats[];
235 extern const u32 isc_gamma_table[GAMMA_MAX + 1][GAMMA_ENTRIES];
236 extern const struct regmap_config isc_regmap_config;
237 extern const struct v4l2_async_notifier_operations isc_async_ops;
238
239 irqreturn_t isc_interrupt(int irq, void *dev_id);
240 int isc_pipeline_init(struct isc_device *isc);
241 int isc_clk_init(struct isc_device *isc);
242 void isc_subdev_cleanup(struct isc_device *isc);
243 void isc_clk_cleanup(struct isc_device *isc);
244
245 #endif