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