1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef OMAP3_ISP_VIDEO_H
17#define OMAP3_ISP_VIDEO_H
18
19#include <linux/v4l2-mediabus.h>
20#include <media/media-entity.h>
21#include <media/v4l2-dev.h>
22#include <media/v4l2-fh.h>
23#include <media/videobuf2-v4l2.h>
24
25#define ISP_VIDEO_DRIVER_NAME "ispvideo"
26#define ISP_VIDEO_DRIVER_VERSION "0.0.2"
27
28struct isp_device;
29struct isp_video;
30struct v4l2_mbus_framefmt;
31struct v4l2_pix_format;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46struct isp_format_info {
47 u32 code;
48 u32 truncated;
49 u32 uncompressed;
50 u32 flavor;
51 u32 pixelformat;
52 unsigned int width;
53 unsigned int bpp;
54};
55
56enum isp_pipeline_stream_state {
57 ISP_PIPELINE_STREAM_STOPPED = 0,
58 ISP_PIPELINE_STREAM_CONTINUOUS = 1,
59 ISP_PIPELINE_STREAM_SINGLESHOT = 2,
60};
61
62enum isp_pipeline_state {
63
64 ISP_PIPELINE_STREAM_INPUT = 1,
65
66 ISP_PIPELINE_STREAM_OUTPUT = 2,
67
68 ISP_PIPELINE_QUEUE_INPUT = 4,
69
70 ISP_PIPELINE_QUEUE_OUTPUT = 8,
71
72 ISP_PIPELINE_IDLE_INPUT = 16,
73
74 ISP_PIPELINE_IDLE_OUTPUT = 32,
75
76 ISP_PIPELINE_STREAM = 64,
77};
78
79
80
81
82
83
84
85struct isp_pipeline {
86 struct media_pipeline pipe;
87 spinlock_t lock;
88 unsigned int state;
89 enum isp_pipeline_stream_state stream_state;
90 struct isp_video *input;
91 struct isp_video *output;
92 u32 entities;
93 unsigned long l3_ick;
94 unsigned int max_rate;
95 enum v4l2_field field;
96 atomic_t frame_number;
97 bool do_propagation;
98 bool error;
99 struct v4l2_fract max_timeperframe;
100 struct v4l2_subdev *external;
101 unsigned int external_rate;
102 unsigned int external_width;
103};
104
105#define to_isp_pipeline(__e) \
106 container_of((__e)->pipe, struct isp_pipeline, pipe)
107
108static inline int isp_pipeline_ready(struct isp_pipeline *pipe)
109{
110 return pipe->state == (ISP_PIPELINE_STREAM_INPUT |
111 ISP_PIPELINE_STREAM_OUTPUT |
112 ISP_PIPELINE_QUEUE_INPUT |
113 ISP_PIPELINE_QUEUE_OUTPUT |
114 ISP_PIPELINE_IDLE_INPUT |
115 ISP_PIPELINE_IDLE_OUTPUT);
116}
117
118
119
120
121
122
123
124struct isp_buffer {
125 struct vb2_v4l2_buffer vb;
126 struct list_head irqlist;
127 dma_addr_t dma;
128};
129
130#define to_isp_buffer(buf) container_of(buf, struct isp_buffer, vb)
131
132enum isp_video_dmaqueue_flags {
133
134 ISP_VIDEO_DMAQUEUE_UNDERRUN = (1 << 0),
135
136 ISP_VIDEO_DMAQUEUE_QUEUED = (1 << 1),
137};
138
139#define isp_video_dmaqueue_flags_clr(video) \
140 ({ (video)->dmaqueue_flags = 0; })
141
142
143
144
145
146
147struct isp_video_operations {
148 int(*queue)(struct isp_video *video, struct isp_buffer *buffer);
149};
150
151struct isp_video {
152 struct video_device video;
153 enum v4l2_buf_type type;
154 struct media_pad pad;
155
156 struct mutex mutex;
157 atomic_t active;
158
159 struct isp_device *isp;
160
161 unsigned int capture_mem;
162 unsigned int bpl_alignment;
163 unsigned int bpl_zero_padding;
164 unsigned int bpl_max;
165 unsigned int bpl_value;
166 unsigned int bpl_padding;
167
168
169 struct isp_pipeline pipe;
170 struct mutex stream_lock;
171 bool error;
172
173
174 void *alloc_ctx;
175 struct vb2_queue *queue;
176 struct mutex queue_lock;
177 spinlock_t irqlock;
178 struct list_head dmaqueue;
179 enum isp_video_dmaqueue_flags dmaqueue_flags;
180
181 const struct isp_video_operations *ops;
182};
183
184#define to_isp_video(vdev) container_of(vdev, struct isp_video, video)
185
186struct isp_video_fh {
187 struct v4l2_fh vfh;
188 struct isp_video *video;
189 struct vb2_queue queue;
190 struct v4l2_format format;
191 struct v4l2_fract timeperframe;
192};
193
194#define to_isp_video_fh(fh) container_of(fh, struct isp_video_fh, vfh)
195#define isp_video_queue_to_isp_video_fh(q) \
196 container_of(q, struct isp_video_fh, queue)
197
198int omap3isp_video_init(struct isp_video *video, const char *name);
199void omap3isp_video_cleanup(struct isp_video *video);
200int omap3isp_video_register(struct isp_video *video,
201 struct v4l2_device *vdev);
202void omap3isp_video_unregister(struct isp_video *video);
203struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video);
204void omap3isp_video_cancel_stream(struct isp_video *video);
205void omap3isp_video_resume(struct isp_video *video, int continuous);
206struct media_pad *omap3isp_video_remote_pad(struct isp_video *video);
207
208const struct isp_format_info *
209omap3isp_video_format_info(u32 code);
210
211#endif
212