Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ispvideo.h
Go to the documentation of this file.
1 /*
2  * ispvideo.h
3  *
4  * TI OMAP3 ISP - Generic video node
5  *
6  * Copyright (C) 2009-2010 Nokia Corporation
7  *
8  * Contacts: Laurent Pinchart <[email protected]>
9  * Sakari Ailus <[email protected]>
10  *
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.
14  *
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.
19  *
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
24  */
25 
26 #ifndef OMAP3_ISP_VIDEO_H
27 #define OMAP3_ISP_VIDEO_H
28 
29 #include <linux/v4l2-mediabus.h>
30 #include <media/media-entity.h>
31 #include <media/v4l2-dev.h>
32 #include <media/v4l2-fh.h>
33 
34 #include "ispqueue.h"
35 
36 #define ISP_VIDEO_DRIVER_NAME "ispvideo"
37 #define ISP_VIDEO_DRIVER_VERSION "0.0.2"
38 
39 struct isp_device;
40 struct isp_video;
41 struct v4l2_mbus_framefmt;
42 struct v4l2_pix_format;
43 
44 /*
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  * @width: Bits per pixel (when transferred over a bus)
55  * @bpp: Bytes per pixel (when stored in memory)
56  */
63  unsigned int width;
64  unsigned int bpp;
65 };
66 
71 };
72 
74  /* The stream has been started on the input video node. */
76  /* The stream has been started on the output video node. */
78  /* At least one buffer is queued on the input video node. */
80  /* At least one buffer is queued on the output video node. */
82  /* The input entity is idle, ready to be started. */
84  /* The output entity is idle, ready to be started. */
86  /* The pipeline is currently streaming. */
88 };
89 
90 /*
91  * struct isp_pipeline - An ISP hardware pipeline
92  * @error: A hardware error occurred during capture
93  * @entities: Bitmask of entities in the pipeline (indexed by entity ID)
94  */
95 struct isp_pipeline {
97  spinlock_t lock; /* Pipeline state and queue flags */
98  unsigned int state;
100  struct isp_video *input;
101  struct isp_video *output;
103  unsigned long l3_ick;
104  unsigned int max_rate;
106  bool do_propagation; /* of frame number */
107  bool error;
110  unsigned int external_rate;
111  unsigned int external_width;
112 };
113 
114 #define to_isp_pipeline(__e) \
115  container_of((__e)->pipe, struct isp_pipeline, pipe)
116 
117 static inline int isp_pipeline_ready(struct isp_pipeline *pipe)
118 {
119  return pipe->state == (ISP_PIPELINE_STREAM_INPUT |
125 }
126 
127 /*
128  * struct isp_buffer - ISP buffer
129  * @buffer: ISP video buffer
130  * @isp_addr: MMU mapped address (a.k.a. device address) of the buffer.
131  */
132 struct isp_buffer {
135 };
136 
137 #define to_isp_buffer(buf) container_of(buf, struct isp_buffer, buffer)
138 
140  /* Set if DMA queue becomes empty when ISP_PIPELINE_STREAM_CONTINUOUS */
142  /* Set when queuing buffer to an empty DMA queue */
144 };
145 
146 #define isp_video_dmaqueue_flags_clr(video) \
147  ({ (video)->dmaqueue_flags = 0; })
148 
149 /*
150  * struct isp_video_operations - ISP video operations
151  * @queue: Resume streaming when a buffer is queued. Called on VIDIOC_QBUF
152  * if there was no buffer previously queued.
153  */
155  int(*queue)(struct isp_video *video, struct isp_buffer *buffer);
156 };
157 
158 struct isp_video {
161  struct media_pad pad;
162 
163  struct mutex mutex; /* format and crop settings */
165 
166  struct isp_device *isp;
167 
168  unsigned int capture_mem;
169  unsigned int bpl_alignment; /* alignment value */
170  unsigned int bpl_zero_padding; /* whether the alignment is optional */
171  unsigned int bpl_max; /* maximum bytes per line value */
172  unsigned int bpl_value; /* bytes per line value */
173  unsigned int bpl_padding; /* padding at end of line */
174 
175  /* Entity video node streaming */
176  unsigned int streaming:1;
177 
178  /* Pipeline state */
180  struct mutex stream_lock; /* pipeline and stream states */
181 
182  /* Video buffers queue */
186 
187  const struct isp_video_operations *ops;
188 };
189 
190 #define to_isp_video(vdev) container_of(vdev, struct isp_video, video)
191 
192 struct isp_video_fh {
193  struct v4l2_fh vfh;
194  struct isp_video *video;
198 };
199 
200 #define to_isp_video_fh(fh) container_of(fh, struct isp_video_fh, vfh)
201 #define isp_video_queue_to_isp_video_fh(q) \
202  container_of(q, struct isp_video_fh, queue)
203 
204 int omap3isp_video_init(struct isp_video *video, const char *name);
205 void omap3isp_video_cleanup(struct isp_video *video);
206 int omap3isp_video_register(struct isp_video *video,
207  struct v4l2_device *vdev);
208 void omap3isp_video_unregister(struct isp_video *video);
209 struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video);
210 void omap3isp_video_resume(struct isp_video *video, int continuous);
211 struct media_pad *omap3isp_video_remote_pad(struct isp_video *video);
212 
213 const struct isp_format_info *
215 
216 #endif /* OMAP3_ISP_VIDEO_H */