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