1
2
3
4
5
6
7
8
9
10#ifndef OMAP4_ISS_VIDEO_H
11#define OMAP4_ISS_VIDEO_H
12
13#include <linux/v4l2-mediabus.h>
14#include <media/media-entity.h>
15#include <media/v4l2-dev.h>
16#include <media/v4l2-fh.h>
17#include <media/videobuf2-v4l2.h>
18#include <media/videobuf2-dma-contig.h>
19
20#define ISS_VIDEO_DRIVER_NAME "issvideo"
21#define ISS_VIDEO_DRIVER_VERSION "0.0.2"
22
23struct iss_device;
24struct iss_video;
25struct v4l2_mbus_framefmt;
26struct v4l2_pix_format;
27
28
29
30
31
32
33
34
35
36
37
38
39
40struct iss_format_info {
41 u32 code;
42 u32 truncated;
43 u32 uncompressed;
44 u32 flavor;
45 u32 pixelformat;
46 unsigned int bpp;
47};
48
49enum iss_pipeline_stream_state {
50 ISS_PIPELINE_STREAM_STOPPED = 0,
51 ISS_PIPELINE_STREAM_CONTINUOUS = 1,
52 ISS_PIPELINE_STREAM_SINGLESHOT = 2,
53};
54
55enum iss_pipeline_state {
56
57 ISS_PIPELINE_STREAM_INPUT = 1,
58
59 ISS_PIPELINE_STREAM_OUTPUT = (1 << 1),
60
61 ISS_PIPELINE_QUEUE_INPUT = (1 << 2),
62
63 ISS_PIPELINE_QUEUE_OUTPUT = (1 << 3),
64
65 ISS_PIPELINE_IDLE_INPUT = (1 << 4),
66
67 ISS_PIPELINE_IDLE_OUTPUT = (1 << 5),
68
69 ISS_PIPELINE_STREAM = (1 << 6),
70};
71
72
73
74
75
76
77struct iss_pipeline {
78 struct media_pipeline pipe;
79 spinlock_t lock;
80 unsigned int state;
81 enum iss_pipeline_stream_state stream_state;
82 struct iss_video *input;
83 struct iss_video *output;
84 struct media_entity_enum ent_enum;
85 atomic_t frame_number;
86 bool do_propagation;
87 bool error;
88 struct v4l2_fract max_timeperframe;
89 struct v4l2_subdev *external;
90 unsigned int external_rate;
91 int external_bpp;
92};
93
94#define to_iss_pipeline(__e) \
95 container_of((__e)->pipe, struct iss_pipeline, pipe)
96
97static inline int iss_pipeline_ready(struct iss_pipeline *pipe)
98{
99 return pipe->state == (ISS_PIPELINE_STREAM_INPUT |
100 ISS_PIPELINE_STREAM_OUTPUT |
101 ISS_PIPELINE_QUEUE_INPUT |
102 ISS_PIPELINE_QUEUE_OUTPUT |
103 ISS_PIPELINE_IDLE_INPUT |
104 ISS_PIPELINE_IDLE_OUTPUT);
105}
106
107
108
109
110
111
112struct iss_buffer {
113
114 struct vb2_v4l2_buffer vb;
115 struct list_head list;
116 dma_addr_t iss_addr;
117};
118
119#define to_iss_buffer(buf) container_of(buf, struct iss_buffer, vb)
120
121enum iss_video_dmaqueue_flags {
122
123 ISS_VIDEO_DMAQUEUE_UNDERRUN = (1 << 0),
124
125 ISS_VIDEO_DMAQUEUE_QUEUED = (1 << 1),
126};
127
128#define iss_video_dmaqueue_flags_clr(video) \
129 ({ (video)->dmaqueue_flags = 0; })
130
131
132
133
134
135
136struct iss_video_operations {
137 int (*queue)(struct iss_video *video, struct iss_buffer *buffer);
138};
139
140struct iss_video {
141 struct video_device video;
142 enum v4l2_buf_type type;
143 struct media_pad pad;
144
145 struct mutex mutex;
146 atomic_t active;
147
148 struct iss_device *iss;
149
150 unsigned int capture_mem;
151 unsigned int bpl_alignment;
152 unsigned int bpl_zero_padding;
153 unsigned int bpl_max;
154 unsigned int bpl_value;
155 unsigned int bpl_padding;
156
157
158 struct iss_pipeline pipe;
159 struct mutex stream_lock;
160 bool error;
161
162
163 struct vb2_queue *queue;
164 spinlock_t qlock;
165 struct list_head dmaqueue;
166 enum iss_video_dmaqueue_flags dmaqueue_flags;
167
168 const struct iss_video_operations *ops;
169};
170
171#define to_iss_video(vdev) container_of(vdev, struct iss_video, video)
172
173struct iss_video_fh {
174 struct v4l2_fh vfh;
175 struct iss_video *video;
176 struct vb2_queue queue;
177 struct v4l2_format format;
178 struct v4l2_fract timeperframe;
179};
180
181#define to_iss_video_fh(fh) container_of(fh, struct iss_video_fh, vfh)
182#define iss_video_queue_to_iss_video_fh(q) \
183 container_of(q, struct iss_video_fh, queue)
184
185int omap4iss_video_init(struct iss_video *video, const char *name);
186void omap4iss_video_cleanup(struct iss_video *video);
187int omap4iss_video_register(struct iss_video *video,
188 struct v4l2_device *vdev);
189void omap4iss_video_unregister(struct iss_video *video);
190struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video);
191void omap4iss_video_cancel_stream(struct iss_video *video);
192struct media_pad *omap4iss_video_remote_pad(struct iss_video *video);
193
194const struct iss_format_info *
195omap4iss_video_format_info(u32 code);
196
197#endif
198