Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
saa7146_vv.h
Go to the documentation of this file.
1 #ifndef __SAA7146_VV__
2 #define __SAA7146_VV__
3 
4 #include <media/v4l2-common.h>
5 #include <media/v4l2-ioctl.h>
6 #include <media/v4l2-fh.h>
7 #include <media/saa7146.h>
9 
10 #define MAX_SAA7146_CAPTURE_BUFFERS 32 /* arbitrary */
11 #define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */
12 
13 #define WRITE_RPS0(x) do { \
14  dev->d_rps0.cpu_addr[ count++ ] = cpu_to_le32(x); \
15  } while (0);
16 
17 #define WRITE_RPS1(x) do { \
18  dev->d_rps1.cpu_addr[ count++ ] = cpu_to_le32(x); \
19  } while (0);
20 
28 };
29 
30 #define FORMAT_BYTE_SWAP 0x1
31 #define FORMAT_IS_PLANAR 0x2
32 
34  char *name;
40 };
41 
43 {
44  char *name;
46 
47  int v_offset; /* number of lines of vertical offset before processing */
48  int v_field; /* number of lines in a field for HPS to process */
49 
50  int h_offset; /* horizontal offset of processing window */
51  int h_pixels; /* number of horizontal pixels to process */
52 
53  int v_max_out;
54  int h_max_out;
55 };
56 
57 /* buffer for one video/vbi frame */
58 struct saa7146_buf {
59  /* common v4l buffer stuff -- must be first */
61 
62  /* saa7146 specific */
65  struct saa7146_buf *buf,
66  struct saa7146_buf *next);
67 
68  /* page tables */
69  struct saa7146_pgtable pt[3];
70 };
71 
73  struct saa7146_dev *dev;
74  struct saa7146_buf *curr;
75  struct list_head queue;
77 };
78 
80  struct saa7146_fh *fh;
81  struct v4l2_window win;
82  struct v4l2_clip clips[16];
83  int nclips;
84 };
85 
86 /* per open data */
87 struct saa7146_fh {
88  /* Must be the first field! */
89  struct v4l2_fh fh;
90  struct saa7146_dev *dev;
91 
92  /* video capture */
94 
95  /* vbi capture */
97 
98  unsigned int resources; /* resource management for device open */
99 };
100 
101 #define STATUS_OVERLAY 0x01
102 #define STATUS_CAPTURE 0x02
103 
105 {
106  /* vbi capture */
110  /* vbi workaround interrupt queue */
114 
117 
118  /* video overlay */
123 
124  /* video capture */
128 
129  /* common: fixme? shouldn't this be in saa7146_fh?
130  (this leads to a more complicated question: shall the driver
131  store the different settings (for example S_INPUT) for every open
132  and restore it appropriately, or should all settings be common for
133  all opens? currently, we do the latter, like all other
134  drivers do... */
136 
137  int vflip;
138  int hflip;
141 
142  struct saa7146_dma d_clipping; /* pointer to clipping memory */
143 
144  unsigned int resources; /* resource management for device */
145 };
146 
147 /* flags */
148 #define SAA7146_USE_PORT_B_FOR_VBI 0x2 /* use input port b for vbi hardware bug workaround */
149 
151 {
152  /* informations about the video capabilities of the device */
153  int inputs;
154  int audios;
156  int flags;
157 
158  /* additionally supported transmission standards */
160  int num_stds;
162 
163  /* the extension can override this */
166  /* pointer to the saa7146 core ops */
167  const struct v4l2_ioctl_ops *core_ops;
168 
170 };
171 
173  void (*init)(struct saa7146_dev *, struct saa7146_vv *);
174  int(*open)(struct saa7146_dev *, struct file *);
175  void (*release)(struct saa7146_dev *, struct file *);
176  void (*irq_done)(struct saa7146_dev *, unsigned long status);
177  ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
178 };
179 
180 /* from saa7146_fops.c */
181 int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev, char *name, int type);
183 void saa7146_buffer_finish(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, int state);
184 void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi);
185 int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf);
186 void saa7146_buffer_timeout(unsigned long data);
187 void saa7146_dma_free(struct saa7146_dev* dev,struct videobuf_queue *q,
188  struct saa7146_buf *buf);
189 
190 int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv);
191 int saa7146_vv_release(struct saa7146_dev* dev);
192 
193 /* from saa7146_hlp.c */
194 int saa7146_enable_overlay(struct saa7146_fh *fh);
195 void saa7146_disable_overlay(struct saa7146_fh *fh);
196 
197 void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next);
198 void saa7146_write_out_dma(struct saa7146_dev* dev, int which, struct saa7146_video_dma* vdma) ;
199 void saa7146_set_hps_source_and_sync(struct saa7146_dev *saa, int source, int sync);
200 void saa7146_set_gpio(struct saa7146_dev *saa, u8 pin, u8 data);
201 
202 /* from saa7146_video.c */
203 extern const struct v4l2_ioctl_ops saa7146_video_ioctl_ops;
204 extern const struct v4l2_ioctl_ops saa7146_vbi_ioctl_ops;
205 extern struct saa7146_use_ops saa7146_video_uops;
206 int saa7146_start_preview(struct saa7146_fh *fh);
207 int saa7146_stop_preview(struct saa7146_fh *fh);
208 long saa7146_video_do_ioctl(struct file *file, unsigned int cmd, void *arg);
209 int saa7146_s_ctrl(struct v4l2_ctrl *ctrl);
210 
211 /* from saa7146_vbi.c */
212 extern struct saa7146_use_ops saa7146_vbi_uops;
213 
214 /* resource management functions */
215 int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit);
216 void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits);
217 
218 #define RESOURCE_DMA1_HPS 0x1
219 #define RESOURCE_DMA2_CLP 0x2
220 #define RESOURCE_DMA3_BRS 0x4
221 
222 /* saa7146 source inputs */
223 #define SAA7146_HPS_SOURCE_PORT_A 0x00
224 #define SAA7146_HPS_SOURCE_PORT_B 0x01
225 #define SAA7146_HPS_SOURCE_YPB_CPA 0x02
226 #define SAA7146_HPS_SOURCE_YPA_CPB 0x03
227 
228 /* sync inputs */
229 #define SAA7146_HPS_SYNC_PORT_A 0x00
230 #define SAA7146_HPS_SYNC_PORT_B 0x01
231 
232 /* some memory sizes */
233 /* max. 16 clipping rectangles */
234 #define SAA7146_CLIPPING_MEM (16 * 4 * sizeof(u32))
235 
236 /* some defines for the various clipping-modes */
237 #define SAA7146_CLIPPING_RECT 0x4
238 #define SAA7146_CLIPPING_RECT_INVERTED 0x5
239 #define SAA7146_CLIPPING_MASK 0x6
240 #define SAA7146_CLIPPING_MASK_INVERTED 0x7
241 
242 /* output formats: each entry holds four informations */
243 #define RGB08_COMPOSED 0x0217 /* composed is used in the sense of "not-planar" */
244 /* this means: planar?=0, yuv2rgb-conversation-mode=2, dither=yes(=1), format-mode = 7 */
245 #define RGB15_COMPOSED 0x0213
246 #define RGB16_COMPOSED 0x0210
247 #define RGB24_COMPOSED 0x0201
248 #define RGB32_COMPOSED 0x0202
249 
250 #define Y8 0x0006
251 #define YUV411_COMPOSED 0x0003
252 #define YUV422_COMPOSED 0x0000
253 /* this means: planar?=1, yuv2rgb-conversion-mode=0, dither=no(=0), format-mode = b */
254 #define YUV411_DECOMPOSED 0x100b
255 #define YUV422_DECOMPOSED 0x1009
256 #define YUV420_DECOMPOSED 0x100a
257 
258 #define IS_PLANAR(x) (x & 0xf000)
259 
260 /* misc defines */
261 #define SAA7146_NO_SWAP (0x0)
262 #define SAA7146_TWO_BYTE_SWAP (0x1)
263 #define SAA7146_FOUR_BYTE_SWAP (0x2)
264 
265 #endif