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-core.h>
25#include <media/v4l2-device.h>
26#include <media/v4l2-mediabus.h>
27#include <media/s5p_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_SOURC_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_SOURC_HEIGHT_MAX 4000
46
47#define FIMC_ISP_NUM_FORMATS 3
48#define FIMC_ISP_REQ_BUFS_MIN 2
49
50#define FIMC_ISP_SD_PAD_SINK 0
51#define FIMC_ISP_SD_PAD_SRC_FIFO 1
52#define FIMC_ISP_SD_PAD_SRC_DMA 2
53#define FIMC_ISP_SD_PADS_NUM 3
54#define FIMC_ISP_MAX_PLANES 1
55
56
57
58
59
60
61
62struct fimc_isp_frame {
63 u16 width;
64 u16 height;
65 struct v4l2_rect rect;
66};
67
68struct fimc_isp_ctrls {
69 struct v4l2_ctrl_handler handler;
70
71
72 struct v4l2_ctrl *auto_wb;
73
74 struct {
75 struct v4l2_ctrl *auto_iso;
76 struct v4l2_ctrl *iso;
77 };
78
79 struct v4l2_ctrl *contrast;
80
81 struct v4l2_ctrl *saturation;
82
83 struct v4l2_ctrl *sharpness;
84
85 struct v4l2_ctrl *brightness;
86
87 struct v4l2_ctrl *hue;
88
89
90 struct v4l2_ctrl *auto_exp;
91
92 struct v4l2_ctrl *exposure;
93
94 struct v4l2_ctrl *aewb_lock;
95
96 struct v4l2_ctrl *exp_metering;
97
98 struct v4l2_ctrl *afc;
99
100 struct v4l2_ctrl *colorfx;
101};
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116struct fimc_is_video {
117 struct video_device vdev;
118 enum v4l2_buf_type type;
119 struct media_pad pad;
120 struct list_head pending_buf_q;
121 struct list_head active_buf_q;
122 struct vb2_queue vb_queue;
123 unsigned int frame_count;
124 unsigned int reqbufs_count;
125 int streaming;
126 const struct fimc_fmt *format;
127};
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143struct fimc_isp {
144 struct platform_device *pdev;
145 struct vb2_alloc_ctx *alloc_ctx;
146 struct v4l2_subdev subdev;
147 struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM];
148 struct v4l2_mbus_framefmt src_fmt;
149 struct v4l2_mbus_framefmt sink_fmt;
150 struct v4l2_ctrl *test_pattern;
151 struct fimc_isp_ctrls ctrls;
152
153 struct mutex video_lock;
154 struct mutex subdev_lock;
155
156 unsigned int cac_margin_x;
157 unsigned int cac_margin_y;
158
159 unsigned long state;
160
161 struct fimc_is_video video_capture;
162};
163
164#define ctrl_to_fimc_isp(_ctrl) \
165 container_of(ctrl->handler, struct fimc_isp, ctrls.handler)
166
167struct fimc_is;
168
169int fimc_isp_subdev_create(struct fimc_isp *isp);
170void fimc_isp_subdev_destroy(struct fimc_isp *isp);
171void fimc_isp_irq_handler(struct fimc_is *is);
172int fimc_is_create_controls(struct fimc_isp *isp);
173int fimc_is_delete_controls(struct fimc_isp *isp);
174const struct fimc_fmt *fimc_isp_find_format(const u32 *pixelformat,
175 const u32 *mbus_code, int index);
176#endif
177