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
26extern 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
60struct fimc_isp_frame {
61 u16 width;
62 u16 height;
63 struct v4l2_rect rect;
64};
65
66struct 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
101struct 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
125
126
127
128struct fimc_is_video {
129 struct exynos_video_entity ve;
130 enum v4l2_buf_type type;
131 struct media_pad pad;
132 struct list_head pending_buf_q;
133 struct list_head active_buf_q;
134 struct vb2_queue vb_queue;
135 unsigned int reqbufs_count;
136 unsigned int buf_count;
137 unsigned int buf_mask;
138 unsigned int frame_count;
139 int streaming;
140 struct isp_video_buf *buffers[FIMC_ISP_MAX_BUFS];
141 const struct fimc_fmt *format;
142 struct v4l2_pix_format_mplane pixfmt;
143};
144
145
146#define ST_ISP_VID_CAP_BUF_PREP 0
147#define ST_ISP_VID_CAP_STREAMING 1
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165struct fimc_isp {
166 struct platform_device *pdev;
167 struct v4l2_subdev subdev;
168 struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM];
169 struct v4l2_mbus_framefmt src_fmt;
170 struct v4l2_mbus_framefmt sink_fmt;
171 struct v4l2_ctrl *test_pattern;
172 struct fimc_isp_ctrls ctrls;
173
174 struct mutex video_lock;
175 struct mutex subdev_lock;
176
177 unsigned int cac_margin_x;
178 unsigned int cac_margin_y;
179
180 unsigned long state;
181
182 struct fimc_is_video video_capture;
183};
184
185#define ctrl_to_fimc_isp(_ctrl) \
186 container_of(ctrl->handler, struct fimc_isp, ctrls.handler)
187
188struct fimc_is;
189
190int fimc_isp_subdev_create(struct fimc_isp *isp);
191void fimc_isp_subdev_destroy(struct fimc_isp *isp);
192void fimc_isp_irq_handler(struct fimc_is *is);
193int fimc_is_create_controls(struct fimc_isp *isp);
194int fimc_is_delete_controls(struct fimc_isp *isp);
195const struct fimc_fmt *fimc_isp_find_format(const u32 *pixelformat,
196 const u32 *mbus_code, int index);
197#endif
198