Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
434 | giacomo | 1 | #ifndef __SAA7146_VV__ |
2 | #define __SAA7146_VV__ |
||
3 | |||
4 | #include <linux/videodev2.h> |
||
5 | |||
6 | #include <media/saa7146.h> |
||
7 | #include <media/video-buf.h> |
||
8 | |||
9 | #define MAX_SAA7146_CAPTURE_BUFFERS 32 /* arbitrary */ |
||
10 | #define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */ |
||
11 | |||
12 | #define WRITE_RPS0(x) do { \ |
||
13 | dev->d_rps0.cpu_addr[ count++ ] = cpu_to_le32(x); \ |
||
14 | } while (0); |
||
15 | |||
16 | #define WRITE_RPS1(x) do { \ |
||
17 | dev->d_rps1.cpu_addr[ count++ ] = cpu_to_le32(x); \ |
||
18 | } while (0); |
||
19 | |||
20 | struct saa7146_video_dma { |
||
21 | u32 base_odd; |
||
22 | u32 base_even; |
||
23 | u32 prot_addr; |
||
24 | u32 pitch; |
||
25 | u32 base_page; |
||
26 | u32 num_line_byte; |
||
27 | }; |
||
28 | |||
29 | struct saa7146_format { |
||
30 | char *name; |
||
31 | int pixelformat; |
||
32 | u32 trans; |
||
33 | u8 depth; |
||
34 | int swap; |
||
35 | }; |
||
36 | |||
37 | struct saa7146_standard |
||
38 | { |
||
39 | char *name; |
||
40 | v4l2_std_id id; |
||
41 | |||
42 | int v_offset; /* number of lines of vertical offset before processing */ |
||
43 | int v_field; /* number of lines in a field for HPS to process */ |
||
44 | int v_calc; /* number of vertical active lines */ |
||
45 | |||
46 | int h_offset; /* horizontal offset of processing window */ |
||
47 | int h_pixels; /* number of horizontal pixels to process */ |
||
48 | int h_calc; /* number of horizontal active pixels */ |
||
49 | |||
50 | int v_max_out; |
||
51 | int h_max_out; |
||
52 | }; |
||
53 | |||
54 | /* buffer for one video/vbi frame */ |
||
55 | struct saa7146_buf { |
||
56 | /* common v4l buffer stuff -- must be first */ |
||
57 | struct videobuf_buffer vb; |
||
58 | |||
59 | /* saa7146 specific */ |
||
60 | struct v4l2_pix_format *fmt; |
||
61 | int (*activate)(struct saa7146_dev *dev, |
||
62 | struct saa7146_buf *buf, |
||
63 | struct saa7146_buf *next); |
||
64 | |||
65 | /* page tables */ |
||
66 | struct saa7146_pgtable pt[3]; |
||
67 | }; |
||
68 | |||
69 | struct saa7146_dmaqueue { |
||
70 | struct saa7146_dev *dev; |
||
71 | struct saa7146_buf *curr; |
||
72 | struct list_head queue; |
||
73 | struct timer_list timeout; |
||
74 | }; |
||
75 | |||
76 | struct saa7146_overlay { |
||
77 | struct saa7146_fh *fh; |
||
78 | struct v4l2_window win; |
||
79 | struct v4l2_clip clips[16]; |
||
80 | int nclips; |
||
81 | }; |
||
82 | |||
83 | /* per open data */ |
||
84 | struct saa7146_fh { |
||
85 | struct saa7146_dev *dev; |
||
86 | /* if this is a vbi or capture open */ |
||
87 | enum v4l2_buf_type type; |
||
88 | |||
89 | /* video overlay */ |
||
90 | struct saa7146_overlay ov; |
||
91 | |||
92 | /* video capture */ |
||
93 | struct videobuf_queue video_q; |
||
94 | struct v4l2_pix_format video_fmt; |
||
95 | |||
96 | /* vbi capture */ |
||
97 | struct videobuf_queue vbi_q; |
||
98 | struct v4l2_vbi_format vbi_fmt; |
||
99 | struct timer_list vbi_read_timeout; |
||
100 | }; |
||
101 | |||
102 | struct saa7146_vv |
||
103 | { |
||
104 | int vbi_minor; |
||
105 | |||
106 | /* vbi capture */ |
||
107 | struct saa7146_dmaqueue vbi_q; |
||
108 | /* vbi workaround interrupt queue */ |
||
109 | wait_queue_head_t vbi_wq; |
||
110 | int vbi_fieldcount; |
||
111 | struct saa7146_fh *vbi_streaming; |
||
112 | |||
113 | int video_minor; |
||
114 | |||
115 | /* video overlay */ |
||
116 | struct v4l2_framebuffer ov_fb; |
||
117 | struct saa7146_format *ov_fmt; |
||
118 | struct saa7146_overlay *ov_data; |
||
119 | |||
120 | /* video capture */ |
||
121 | struct saa7146_dmaqueue video_q; |
||
122 | struct saa7146_fh *streaming; |
||
123 | enum v4l2_field last_field; |
||
124 | |||
125 | /* common: fixme? shouldn't this be in saa7146_fh? |
||
126 | (this leads to a more complicated question: shall the driver |
||
127 | store the different settings (for example S_INPUT) for every open |
||
128 | and restore it appropriately, or should all settings be common for |
||
129 | all opens? currently, we do the latter, like all other |
||
130 | drivers do... */ |
||
131 | struct saa7146_standard *standard; |
||
132 | |||
133 | int vflip; |
||
134 | int hflip; |
||
135 | int current_hps_source; |
||
136 | int current_hps_sync; |
||
137 | |||
138 | struct saa7146_dma d_clipping; /* pointer to clipping memory */ |
||
139 | }; |
||
140 | |||
141 | #define SAA7146_EXCLUSIVE 0x1 |
||
142 | #define SAA7146_BEFORE 0x2 |
||
143 | #define SAA7146_AFTER 0x4 |
||
144 | |||
145 | struct saa7146_extension_ioctls |
||
146 | { |
||
147 | unsigned int cmd; |
||
148 | int flags; |
||
149 | }; |
||
150 | |||
151 | /* flags */ |
||
152 | #define SAA7146_EXT_SWAP_ODD_EVEN 0x1 /* needs odd/even fields swapped */ |
||
153 | #define SAA7146_USE_PORT_B_FOR_VBI 0x2 /* use input port b for vbi hardware bug workaround */ |
||
154 | |||
155 | struct saa7146_ext_vv |
||
156 | { |
||
157 | /* informations about the video capabilities of the device */ |
||
158 | int inputs; |
||
159 | int audios; |
||
160 | u32 capabilities; |
||
161 | int flags; |
||
162 | |||
163 | /* additionally supported transmission standards */ |
||
164 | struct saa7146_standard *stds; |
||
165 | int num_stds; |
||
166 | int (*std_callback)(struct saa7146_dev*, struct saa7146_standard *); |
||
167 | |||
168 | struct saa7146_extension_ioctls *ioctls; |
||
169 | int (*ioctl)(struct saa7146_fh*, unsigned int cmd, void *arg); |
||
170 | }; |
||
171 | |||
172 | struct saa7146_use_ops { |
||
173 | void (*init)(struct saa7146_dev *, struct saa7146_vv *); |
||
174 | void(*open)(struct saa7146_dev *, struct saa7146_fh *); |
||
175 | void (*release)(struct saa7146_dev *, struct saa7146_fh *,struct file *); |
||
176 | void (*irq_done)(struct saa7146_dev *, unsigned long status); |
||
177 | ssize_t (*read)(struct file *, char *, size_t, loff_t *); |
||
178 | int (*capture_begin)(struct saa7146_fh *); |
||
179 | int (*capture_end)(struct saa7146_fh *); |
||
180 | }; |
||
181 | |||
182 | /* from saa7146_fops.c */ |
||
183 | int saa7146_register_device(struct video_device *vid, struct saa7146_dev* dev, char *name, int type); |
||
184 | int saa7146_unregister_device(struct video_device *vid, struct saa7146_dev* dev); |
||
185 | void saa7146_buffer_finish(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, int state); |
||
186 | void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi); |
||
187 | int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf); |
||
188 | void saa7146_buffer_timeout(unsigned long data); |
||
189 | void saa7146_dma_free(struct saa7146_dev *dev,struct saa7146_buf *buf); |
||
190 | |||
191 | int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv); |
||
192 | int saa7146_vv_release(struct saa7146_dev* dev); |
||
193 | |||
194 | |||
195 | /* from saa7146_hlp.c */ |
||
196 | void saa7146_set_overlay(struct saa7146_dev *dev, struct saa7146_fh *fh, int v); |
||
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 struct saa7146_use_ops saa7146_video_uops; |
||
204 | int saa7146_start_preview(struct saa7146_fh *fh); |
||
205 | int saa7146_stop_preview(struct saa7146_fh *fh); |
||
206 | |||
207 | /* from saa7146_vbi.c */ |
||
208 | extern struct saa7146_use_ops saa7146_vbi_uops; |
||
209 | |||
210 | /* saa7146 source inputs */ |
||
211 | #define SAA7146_HPS_SOURCE_PORT_A 0x00 |
||
212 | #define SAA7146_HPS_SOURCE_PORT_B 0x01 |
||
213 | #define SAA7146_HPS_SOURCE_YPB_CPA 0x02 |
||
214 | #define SAA7146_HPS_SOURCE_YPA_CPB 0x03 |
||
215 | |||
216 | /* sync inputs */ |
||
217 | #define SAA7146_HPS_SYNC_PORT_A 0x00 |
||
218 | #define SAA7146_HPS_SYNC_PORT_B 0x01 |
||
219 | |||
220 | /* some memory sizes */ |
||
221 | #define SAA7146_CLIPPING_MEM (14*PAGE_SIZE) |
||
222 | |||
223 | /* some defines for the various clipping-modes */ |
||
224 | #define SAA7146_CLIPPING_RECT 0x4 |
||
225 | #define SAA7146_CLIPPING_RECT_INVERTED 0x5 |
||
226 | #define SAA7146_CLIPPING_MASK 0x6 |
||
227 | #define SAA7146_CLIPPING_MASK_INVERTED 0x7 |
||
228 | |||
229 | /* output formats: each entry holds four informations */ |
||
230 | #define RGB08_COMPOSED 0x0217 /* composed is used in the sense of "not-planar" */ |
||
231 | /* this means: planar?=0, yuv2rgb-conversation-mode=2, dither=yes(=1), format-mode = 7 */ |
||
232 | #define RGB15_COMPOSED 0x0213 |
||
233 | #define RGB16_COMPOSED 0x0210 |
||
234 | #define RGB24_COMPOSED 0x0201 |
||
235 | #define RGB32_COMPOSED 0x0202 |
||
236 | |||
237 | #define Y8 0x0006 |
||
238 | #define YUV411_COMPOSED 0x0003 |
||
239 | #define YUV422_COMPOSED 0x0000 |
||
240 | /* this means: planar?=1, yuv2rgb-conversion-mode=0, dither=no(=0), format-mode = b */ |
||
241 | #define YUV411_DECOMPOSED 0x100b |
||
242 | #define YUV422_DECOMPOSED 0x1009 |
||
243 | #define YUV420_DECOMPOSED 0x100a |
||
244 | |||
245 | #define IS_PLANAR(x) (x & 0xf000) |
||
246 | |||
247 | /* misc defines */ |
||
248 | #define SAA7146_NO_SWAP (0x0) |
||
249 | #define SAA7146_TWO_BYTE_SWAP (0x1) |
||
250 | #define SAA7146_FOUR_BYTE_SWAP (0x2) |
||
251 | |||
252 | #endif |