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