[media] omap3isp: Prevent pipelines that contain a crashed entity from starting
[linux-2.6/libata-dev.git] / drivers / media / video / omap3isp / ispvideo.h
blobc9187cbc355783371ec798462b4f0242dacd4bb4
1 /*
2 * ispvideo.h
4 * TI OMAP3 ISP - Generic video node
6 * Copyright (C) 2009-2010 Nokia Corporation
8 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
9 * Sakari Ailus <sakari.ailus@iki.fi>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 * 02110-1301 USA
26 #ifndef OMAP3_ISP_VIDEO_H
27 #define OMAP3_ISP_VIDEO_H
29 #include <linux/v4l2-mediabus.h>
30 #include <media/media-entity.h>
31 #include <media/v4l2-dev.h>
32 #include <media/v4l2-fh.h>
34 #include "ispqueue.h"
36 #define ISP_VIDEO_DRIVER_NAME "ispvideo"
37 #define ISP_VIDEO_DRIVER_VERSION "0.0.2"
39 struct isp_device;
40 struct isp_video;
41 struct v4l2_mbus_framefmt;
42 struct v4l2_pix_format;
45 * struct isp_format_info - ISP media bus format information
46 * @code: V4L2 media bus format code
47 * @truncated: V4L2 media bus format code for the same format truncated to 10
48 * bits. Identical to @code if the format is 10 bits wide or less.
49 * @uncompressed: V4L2 media bus format code for the corresponding uncompressed
50 * format. Identical to @code if the format is not DPCM compressed.
51 * @flavor: V4L2 media bus format code for the same pixel layout but
52 * shifted to be 8 bits per pixel. =0 if format is not shiftable.
53 * @pixelformat: V4L2 pixel format FCC identifier
54 * @bpp: Bits per pixel
56 struct isp_format_info {
57 enum v4l2_mbus_pixelcode code;
58 enum v4l2_mbus_pixelcode truncated;
59 enum v4l2_mbus_pixelcode uncompressed;
60 enum v4l2_mbus_pixelcode flavor;
61 u32 pixelformat;
62 unsigned int bpp;
65 enum isp_pipeline_stream_state {
66 ISP_PIPELINE_STREAM_STOPPED = 0,
67 ISP_PIPELINE_STREAM_CONTINUOUS = 1,
68 ISP_PIPELINE_STREAM_SINGLESHOT = 2,
71 enum isp_pipeline_state {
72 /* The stream has been started on the input video node. */
73 ISP_PIPELINE_STREAM_INPUT = 1,
74 /* The stream has been started on the output video node. */
75 ISP_PIPELINE_STREAM_OUTPUT = 2,
76 /* At least one buffer is queued on the input video node. */
77 ISP_PIPELINE_QUEUE_INPUT = 4,
78 /* At least one buffer is queued on the output video node. */
79 ISP_PIPELINE_QUEUE_OUTPUT = 8,
80 /* The input entity is idle, ready to be started. */
81 ISP_PIPELINE_IDLE_INPUT = 16,
82 /* The output entity is idle, ready to be started. */
83 ISP_PIPELINE_IDLE_OUTPUT = 32,
84 /* The pipeline is currently streaming. */
85 ISP_PIPELINE_STREAM = 64,
89 * struct isp_pipeline - An ISP hardware pipeline
90 * @error: A hardware error occurred during capture
91 * @entities: Bitmask of entities in the pipeline (indexed by entity ID)
93 struct isp_pipeline {
94 struct media_pipeline pipe;
95 spinlock_t lock; /* Pipeline state and queue flags */
96 unsigned int state;
97 enum isp_pipeline_stream_state stream_state;
98 struct isp_video *input;
99 struct isp_video *output;
100 u32 entities;
101 unsigned long l3_ick;
102 unsigned int max_rate;
103 atomic_t frame_number;
104 bool do_propagation; /* of frame number */
105 bool error;
106 struct v4l2_fract max_timeperframe;
109 #define to_isp_pipeline(__e) \
110 container_of((__e)->pipe, struct isp_pipeline, pipe)
112 static inline int isp_pipeline_ready(struct isp_pipeline *pipe)
114 return pipe->state == (ISP_PIPELINE_STREAM_INPUT |
115 ISP_PIPELINE_STREAM_OUTPUT |
116 ISP_PIPELINE_QUEUE_INPUT |
117 ISP_PIPELINE_QUEUE_OUTPUT |
118 ISP_PIPELINE_IDLE_INPUT |
119 ISP_PIPELINE_IDLE_OUTPUT);
123 * struct isp_buffer - ISP buffer
124 * @buffer: ISP video buffer
125 * @isp_addr: MMU mapped address (a.k.a. device address) of the buffer.
127 struct isp_buffer {
128 struct isp_video_buffer buffer;
129 dma_addr_t isp_addr;
132 #define to_isp_buffer(buf) container_of(buf, struct isp_buffer, buffer)
134 enum isp_video_dmaqueue_flags {
135 /* Set if DMA queue becomes empty when ISP_PIPELINE_STREAM_CONTINUOUS */
136 ISP_VIDEO_DMAQUEUE_UNDERRUN = (1 << 0),
137 /* Set when queuing buffer to an empty DMA queue */
138 ISP_VIDEO_DMAQUEUE_QUEUED = (1 << 1),
141 #define isp_video_dmaqueue_flags_clr(video) \
142 ({ (video)->dmaqueue_flags = 0; })
145 * struct isp_video_operations - ISP video operations
146 * @queue: Resume streaming when a buffer is queued. Called on VIDIOC_QBUF
147 * if there was no buffer previously queued.
149 struct isp_video_operations {
150 int(*queue)(struct isp_video *video, struct isp_buffer *buffer);
153 struct isp_video {
154 struct video_device video;
155 enum v4l2_buf_type type;
156 struct media_pad pad;
158 struct mutex mutex; /* format and crop settings */
159 atomic_t active;
161 struct isp_device *isp;
163 unsigned int capture_mem;
164 unsigned int bpl_alignment; /* alignment value */
165 unsigned int bpl_zero_padding; /* whether the alignment is optional */
166 unsigned int bpl_max; /* maximum bytes per line value */
167 unsigned int bpl_value; /* bytes per line value */
168 unsigned int bpl_padding; /* padding at end of line */
170 /* Entity video node streaming */
171 unsigned int streaming:1;
173 /* Pipeline state */
174 struct isp_pipeline pipe;
175 struct mutex stream_lock; /* pipeline and stream states */
177 /* Video buffers queue */
178 struct isp_video_queue *queue;
179 struct list_head dmaqueue;
180 enum isp_video_dmaqueue_flags dmaqueue_flags;
182 const struct isp_video_operations *ops;
185 #define to_isp_video(vdev) container_of(vdev, struct isp_video, video)
187 struct isp_video_fh {
188 struct v4l2_fh vfh;
189 struct isp_video *video;
190 struct isp_video_queue queue;
191 struct v4l2_format format;
192 struct v4l2_fract timeperframe;
195 #define to_isp_video_fh(fh) container_of(fh, struct isp_video_fh, vfh)
196 #define isp_video_queue_to_isp_video_fh(q) \
197 container_of(q, struct isp_video_fh, queue)
199 int omap3isp_video_init(struct isp_video *video, const char *name);
200 void omap3isp_video_cleanup(struct isp_video *video);
201 int omap3isp_video_register(struct isp_video *video,
202 struct v4l2_device *vdev);
203 void omap3isp_video_unregister(struct isp_video *video);
204 struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video);
205 void omap3isp_video_resume(struct isp_video *video, int continuous);
206 struct media_pad *omap3isp_video_remote_pad(struct isp_video *video);
208 const struct isp_format_info *
209 omap3isp_video_format_info(enum v4l2_mbus_pixelcode code);
211 #endif /* OMAP3_ISP_VIDEO_H */