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