1
2
3
4
5
6
7
8
9
10 #ifndef FIMC_ISP_H_
11 #define FIMC_ISP_H_
12
13 #include <linux/io.h>
14 #include <linux/platform_device.h>
15 #include <linux/sched.h>
16 #include <linux/spinlock.h>
17 #include <linux/types.h>
18 #include <linux/videodev2.h>
19
20 #include <media/media-entity.h>
21 #include <media/videobuf2-v4l2.h>
22 #include <media/v4l2-device.h>
23 #include <media/v4l2-mediabus.h>
24 #include <media/drv-intf/exynos-fimc.h>
25
26 extern int fimc_isp_debug;
27
28 #define isp_dbg(level, dev, fmt, arg...) \
29 v4l2_dbg(level, fimc_isp_debug, dev, fmt, ## arg)
30
31
32 #define FIMC_ISP_SINK_WIDTH_MIN (16 + 8)
33 #define FIMC_ISP_SINK_HEIGHT_MIN (12 + 8)
34 #define FIMC_ISP_SOURCE_WIDTH_MIN 8
35 #define FIMC_ISP_SOURCE_HEIGHT_MIN 8
36 #define FIMC_ISP_CAC_MARGIN_WIDTH 16
37 #define FIMC_ISP_CAC_MARGIN_HEIGHT 12
38
39 #define FIMC_ISP_SINK_WIDTH_MAX (4000 - 16)
40 #define FIMC_ISP_SINK_HEIGHT_MAX (4000 + 12)
41 #define FIMC_ISP_SOURCE_WIDTH_MAX 4000
42 #define FIMC_ISP_SOURCE_HEIGHT_MAX 4000
43
44 #define FIMC_ISP_NUM_FORMATS 3
45 #define FIMC_ISP_REQ_BUFS_MIN 2
46 #define FIMC_ISP_REQ_BUFS_MAX 32
47
48 #define FIMC_ISP_SD_PAD_SINK 0
49 #define FIMC_ISP_SD_PAD_SRC_FIFO 1
50 #define FIMC_ISP_SD_PAD_SRC_DMA 2
51 #define FIMC_ISP_SD_PADS_NUM 3
52 #define FIMC_ISP_MAX_PLANES 1
53
54
55
56
57
58
59
60 struct fimc_isp_frame {
61 u16 width;
62 u16 height;
63 struct v4l2_rect rect;
64 };
65
66 struct fimc_isp_ctrls {
67 struct v4l2_ctrl_handler handler;
68
69
70 struct v4l2_ctrl *auto_wb;
71
72 struct {
73 struct v4l2_ctrl *auto_iso;
74 struct v4l2_ctrl *iso;
75 };
76
77 struct v4l2_ctrl *contrast;
78
79 struct v4l2_ctrl *saturation;
80
81 struct v4l2_ctrl *sharpness;
82
83 struct v4l2_ctrl *brightness;
84
85 struct v4l2_ctrl *hue;
86
87
88 struct v4l2_ctrl *auto_exp;
89
90 struct v4l2_ctrl *exposure;
91
92 struct v4l2_ctrl *aewb_lock;
93
94 struct v4l2_ctrl *exp_metering;
95
96 struct v4l2_ctrl *afc;
97
98 struct v4l2_ctrl *colorfx;
99 };
100
101 struct isp_video_buf {
102 struct vb2_v4l2_buffer vb;
103 dma_addr_t dma_addr[FIMC_ISP_MAX_PLANES];
104 unsigned int index;
105 };
106
107 #define to_isp_video_buf(_b) container_of(_b, struct isp_video_buf, vb)
108
109 #define FIMC_ISP_MAX_BUFS 4
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 struct fimc_is_video {
125 struct exynos_video_entity ve;
126 enum v4l2_buf_type type;
127 struct media_pad pad;
128 struct list_head pending_buf_q;
129 struct list_head active_buf_q;
130 struct vb2_queue vb_queue;
131 unsigned int reqbufs_count;
132 unsigned int buf_count;
133 unsigned int buf_mask;
134 unsigned int frame_count;
135 int streaming;
136 struct isp_video_buf *buffers[FIMC_ISP_MAX_BUFS];
137 const struct fimc_fmt *format;
138 struct v4l2_pix_format_mplane pixfmt;
139 };
140
141
142 #define ST_ISP_VID_CAP_BUF_PREP 0
143 #define ST_ISP_VID_CAP_STREAMING 1
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158 struct fimc_isp {
159 struct platform_device *pdev;
160 struct v4l2_subdev subdev;
161 struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM];
162 struct v4l2_mbus_framefmt src_fmt;
163 struct v4l2_mbus_framefmt sink_fmt;
164 struct v4l2_ctrl *test_pattern;
165 struct fimc_isp_ctrls ctrls;
166
167 struct mutex video_lock;
168 struct mutex subdev_lock;
169
170 unsigned int cac_margin_x;
171 unsigned int cac_margin_y;
172
173 unsigned long state;
174
175 struct fimc_is_video video_capture;
176 };
177
178 #define ctrl_to_fimc_isp(_ctrl) \
179 container_of(ctrl->handler, struct fimc_isp, ctrls.handler)
180
181 struct fimc_is;
182
183 int fimc_isp_subdev_create(struct fimc_isp *isp);
184 void fimc_isp_subdev_destroy(struct fimc_isp *isp);
185 void fimc_isp_irq_handler(struct fimc_is *is);
186 int fimc_is_create_controls(struct fimc_isp *isp);
187 int fimc_is_delete_controls(struct fimc_isp *isp);
188 const struct fimc_fmt *fimc_isp_find_format(const u32 *pixelformat,
189 const u32 *mbus_code, int index);
190 #endif