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