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