Subversion Repositories shark

Rev

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