~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/drivers/media/video/buz.h

Version: ~ [ 2.2.5 ] ~ [ 2.4.1 ] ~ [ 2.4.9 ] ~ [ 2.6.17.10 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* 
  2    buz - Iomega Buz driver
  3 
  4    Copyright (C) 1999 Rainer Johanni <Rainer@Johanni.de>
  5 
  6    based on
  7 
  8    buz.0.0.3 Copyright (C) 1998 Dave Perks <dperks@ibm.net>
  9 
 10    and
 11 
 12    bttv - Bt848 frame grabber driver
 13    Copyright (C) 1996,97 Ralph Metzler (rjkm@thp.uni-koeln.de)
 14 
 15    This program is free software; you can redistribute it and/or modify
 16    it under the terms of the GNU General Public License as published by
 17    the Free Software Foundation; either version 2 of the License, or
 18    (at your option) any later version.
 19 
 20    This program is distributed in the hope that it will be useful,
 21    but WITHOUT ANY WARRANTY; without even the implied warranty of
 22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 23    GNU General Public License for more details.
 24 
 25    You should have received a copy of the GNU General Public License
 26    along with this program; if not, write to the Free Software
 27    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 28  */
 29 
 30 #ifndef _BUZ_H_
 31 #define _BUZ_H_
 32 
 33 /* The Buz only supports a maximum width of 720, but some V4L
 34    applications (e.g. xawtv are more happy with 768).
 35    If XAWTV_HACK is defined, we try to fake a device with bigger width */
 36 
 37 #define XAWTV_HACK
 38 
 39 #ifdef XAWTV_HACK
 40 #define   BUZ_MAX_WIDTH   768   /* never display more than 768 pixels */
 41 #else
 42 #define   BUZ_MAX_WIDTH   720   /* never display more than 720 pixels */
 43 #endif
 44 #define   BUZ_MAX_HEIGHT  576   /* never display more than 576 rows */
 45 #define   BUZ_MIN_WIDTH    32   /* never display less than 32 pixels */
 46 #define   BUZ_MIN_HEIGHT   24   /* never display less than 24 rows */
 47 
 48 struct zoran_requestbuffers {
 49         unsigned long count;    /* Number of buffers for MJPEG grabbing */
 50         unsigned long size;     /* Size PER BUFFER in bytes */
 51 };
 52 
 53 struct zoran_sync {
 54         unsigned long frame;    /* number of buffer that has been free'd */
 55         unsigned long length;   /* number of code bytes in buffer (capture only) */
 56         unsigned long seq;      /* frame sequence number */
 57         struct timeval timestamp;       /* timestamp */
 58 };
 59 
 60 struct zoran_status {
 61         int input;              /* Input channel, has to be set prior to BUZIOC_G_STATUS */
 62         int signal;             /* Returned: 1 if valid video signal detected */
 63         int norm;               /* Returned: VIDEO_MODE_PAL or VIDEO_MODE_NTSC */
 64         int color;              /* Returned: 1 if color signal detected */
 65 };
 66 
 67 struct zoran_params {
 68 
 69         /* The following parameters can only be queried */
 70 
 71         int major_version;      /* Major version number of driver */
 72         int minor_version;      /* Minor version number of driver */
 73 
 74         /* Main control parameters */
 75 
 76         int input;              /* Input channel: 0 = Composite, 1 = S-VHS */
 77         int norm;               /* Norm: VIDEO_MODE_PAL or VIDEO_MODE_NTSC */
 78         int decimation;         /* decimation of captured video,
 79                                    enlargement of video played back.
 80                                    Valid values are 1, 2, 4 or 0.
 81                                    0 is a special value where the user
 82                                    has full control over video scaling */
 83 
 84         /* The following parameters only have to be set if decimation==0,
 85            for other values of decimation they provide the data how the image is captured */
 86 
 87         int HorDcm;             /* Horizontal decimation: 1, 2 or 4 */
 88         int VerDcm;             /* Vertical decimation: 1 or 2 */
 89         int TmpDcm;             /* Temporal decimation: 1 or 2,
 90                                    if TmpDcm==2 in capture every second frame is dropped,
 91                                    in playback every frame is played twice */
 92         int field_per_buff;     /* Number of fields per buffer: 1 or 2 */
 93         int img_x;              /* start of image in x direction */
 94         int img_y;              /* start of image in y direction */
 95         int img_width;          /* image width BEFORE decimation,
 96                                    must be a multiple of HorDcm*16 */
 97         int img_height;         /* image height BEFORE decimation,
 98                                    must be a multiple of VerDcm*8 */
 99 
100         /* --- End of parameters for decimation==0 only --- */
101 
102         /* JPEG control parameters */
103 
104         int quality;            /* Measure for quality of compressed images.
105                                    Scales linearly with the size of the compressed images.
106                                    Must be beetween 0 and 100, 100 is a compression
107                                    ratio of 1:4 */
108 
109         int odd_even;           /* Which field should come first ??? */
110 
111         int APPn;               /* Number of APP segment to be written, must be 0..15 */
112         int APP_len;            /* Length of data in JPEG APPn segment */
113         char APP_data[60];      /* Data in the JPEG APPn segment. */
114 
115         int COM_len;            /* Length of data in JPEG COM segment */
116         char COM_data[60];      /* Data in JPEG COM segment */
117 
118         unsigned long jpeg_markers;     /* Which markers should go into the JPEG output.
119                                            Unless you exactly know what you do, leave them untouched.
120                                            Inluding less markers will make the resulting code
121                                            smaller, but there will be fewer aplications
122                                            which can read it.
123                                            The presence of the APP and COM marker is
124                                            influenced by APP0_len and COM_len ONLY! */
125 #define JPEG_MARKER_DHT (1<<3)  /* Define Huffman Tables */
126 #define JPEG_MARKER_DQT (1<<4)  /* Define Quantization Tables */
127 #define JPEG_MARKER_DRI (1<<5)  /* Define Restart Interval */
128 #define JPEG_MARKER_COM (1<<6)  /* Comment segment */
129 #define JPEG_MARKER_APP (1<<7)  /* App segment, driver will allways use APP0 */
130 
131         int VFIFO_FB;           /* Flag for enabling Video Fifo Feedback.
132                                    If this flag is turned on and JPEG decompressing
133                                    is going to the screen, the decompress process
134                                    is stopped every time the Video Fifo is full.
135                                    This enables a smooth decompress to the screen
136                                    but the video output signal will get scrambled */
137 
138         /* Misc */
139 
140         char reserved[312];     /* Makes 512 bytes for this structure */
141 };
142 
143 /*
144    Private IOCTL to set up for displaying MJPEG
145  */
146 #define BUZIOC_G_PARAMS       _IOR ('v', BASE_VIDIOCPRIVATE+0,  struct zoran_params)
147 #define BUZIOC_S_PARAMS       _IOWR('v', BASE_VIDIOCPRIVATE+1,  struct zoran_params)
148 #define BUZIOC_REQBUFS        _IOWR('v', BASE_VIDIOCPRIVATE+2,  struct zoran_requestbuffers)
149 #define BUZIOC_QBUF_CAPT      _IOW ('v', BASE_VIDIOCPRIVATE+3,  int)
150 #define BUZIOC_QBUF_PLAY      _IOW ('v', BASE_VIDIOCPRIVATE+4,  int)
151 #define BUZIOC_SYNC           _IOR ('v', BASE_VIDIOCPRIVATE+5,  struct zoran_sync)
152 #define BUZIOC_G_STATUS       _IOWR('v', BASE_VIDIOCPRIVATE+6,  struct zoran_status)
153 
154 
155 #ifdef __KERNEL__
156 
157 #define BUZ_NUM_STAT_COM    4
158 #define BUZ_MASK_STAT_COM   3
159 
160 #define BUZ_MAX_FRAME     256   /* Must be a power of 2 */
161 #define BUZ_MASK_FRAME    255   /* Must be BUZ_MAX_FRAME-1 */
162 
163 #if VIDEO_MAX_FRAME <= 32
164 #define   V4L_MAX_FRAME   32
165 #elif VIDEO_MAX_FRAME <= 64
166 #define   V4L_MAX_FRAME   64
167 #else
168 #error   "Too many video frame buffers to handle"
169 #endif
170 #define   V4L_MASK_FRAME   (V4L_MAX_FRAME - 1)
171 
172 
173 #include "zr36057.h"
174 
175 enum zoran_codec_mode {
176         BUZ_MODE_IDLE,          /* nothing going on */
177         BUZ_MODE_MOTION_COMPRESS,       /* grabbing frames */
178         BUZ_MODE_MOTION_DECOMPRESS,     /* playing frames */
179         BUZ_MODE_STILL_COMPRESS,        /* still frame conversion */
180         BUZ_MODE_STILL_DECOMPRESS       /* still frame conversion */
181 };
182 
183 enum zoran_buffer_state {
184         BUZ_STATE_USER,         /* buffer is owned by application */
185         BUZ_STATE_PEND,         /* buffer is queued in pend[] ready to feed to I/O */
186         BUZ_STATE_DMA,          /* buffer is queued in dma[] for I/O */
187         BUZ_STATE_DONE          /* buffer is ready to return to application */
188 };
189 
190 struct zoran_gbuffer {
191         u32 *frag_tab;          /* addresses of frag table */
192         u32 frag_tab_bus;       /* same value cached to save time in ISR */
193         enum zoran_buffer_state state;  /* non-zero if corresponding buffer is in use in grab queue */
194         struct zoran_sync bs;   /* DONE: info to return to application */
195 };
196 
197 struct v4l_gbuffer {
198         char *fbuffer;          /* virtual  address of frame buffer */
199         unsigned long fbuffer_phys;     /* physical address of frame buffer */
200         unsigned long fbuffer_bus;      /* bus      address of frame buffer */
201         enum zoran_buffer_state state;  /* state: unused/pending/done */
202 };
203 
204 struct zoran {
205         struct video_device video_dev;
206         struct i2c_bus i2c;
207 
208         int initialized;        /* flag if zoran has been correctly initalized */
209         int user;               /* number of current users (0 or 1) */
210 
211         unsigned short id;      /* number of this device */
212         char name[32];          /* name of this device */
213         struct pci_dev *pci_dev;        /* PCI device */
214         unsigned char revision;         /* revision of zr36057 */
215         int board;                      /* Board type */
216 #define BOARD_BUZ               0
217 #define BOARD_LML33             1       
218         unsigned int zr36057_adr;       /* bus address of IO mem returned by PCI BIOS */
219         unsigned char *zr36057_mem;     /* pointer to mapped IO memory */
220 
221         int map_mjpeg_buffers;  /* Flag which bufferset will map by next mmap() */
222 
223         spinlock_t lock;        /* Spinlock */
224 
225         /* Video for Linux parameters */
226 
227         struct video_picture picture;   /* Current picture params */
228         struct video_buffer buffer;     /* Current buffer params */
229         struct video_window window;     /* Current window params */
230         int buffer_set, window_set;     /* Flags if the above structures are set */
231         int video_interlace;    /* Image on screen is interlaced */
232 
233         u32 *overlay_mask;
234 
235         wait_queue_head_t v4l_capq;     /* wait here for grab to finish */
236 
237         int v4l_overlay_active; /* Overlay grab is activated */
238         int v4l_memgrab_active; /* Memory grab is activated */
239 
240         int v4l_grab_frame;     /* Frame number being currently grabbed */
241 #define NO_GRAB_ACTIVE (-1)
242         int v4l_grab_seq;       /* Number of frames grabbed */
243         int gwidth;             /* Width of current memory capture */
244         int gheight;            /* Height of current memory capture */
245         int gformat;            /* Format of ... */
246         int gbpl;               /* byte per line of ... */
247 
248         /* V4L grab queue of frames pending */
249 
250         unsigned v4l_pend_head;
251         unsigned v4l_pend_tail;
252         int v4l_pend[V4L_MAX_FRAME];
253 
254         struct v4l_gbuffer v4l_gbuf[VIDEO_MAX_FRAME];   /* V4L   buffers' info */
255 
256         /* Buz MJPEG parameters */
257 
258         unsigned long jpg_nbufs;        /* Number of buffers */
259         unsigned long jpg_bufsize;      /* Size of mjpeg buffers in bytes */
260         int jpg_buffers_allocated;      /* Flag if buffers are allocated  */
261         int need_contiguous;    /* Flag if contiguous buffers are needed */
262 
263         enum zoran_codec_mode codec_mode;               /* status of codec */
264         struct zoran_params params;     /* structure with a lot of things to play with */
265 
266         wait_queue_head_t  jpg_capq;    /* wait here for grab to finish */
267 
268         /* grab queue counts/indices, mask with BUZ_MASK_STAT_COM before using as index */
269         /* (dma_head - dma_tail) is number active in DMA, must be <= BUZ_NUM_STAT_COM */
270         /* (value & BUZ_MASK_STAT_COM) corresponds to index in stat_com table */
271         unsigned long jpg_que_head;     /* Index where to put next buffer which is queued */
272         unsigned long jpg_dma_head;     /* Index of next buffer which goes into stat_com  */
273         unsigned long jpg_dma_tail;     /* Index of last buffer in stat_com               */
274         unsigned long jpg_que_tail;     /* Index of last buffer in queue                  */
275         unsigned long jpg_seq_num;      /* count of frames since grab/play started */
276 
277         /* zr36057's code buffer table */
278         u32 *stat_com;          /* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */
279 
280         /* (value & BUZ_MASK_FRAME) corresponds to index in pend[] queue */
281         int jpg_pend[BUZ_MAX_FRAME];
282 
283         /* array indexed by frame number */
284         struct zoran_gbuffer jpg_gbuf[BUZ_MAX_FRAME];   /* MJPEG buffers' info */
285 };
286 
287 #endif
288 
289 /*The following should be done in more portable way. It depends on define
290    of _ALPHA_BUZ in the Makefile. */
291 
292 #ifdef _ALPHA_BUZ
293 #define btwrite(dat,adr)    writel((dat),(char *) (zr->zr36057_adr+(adr)))
294 #define btread(adr)         readl(zr->zr36057_adr+(adr))
295 #else
296 #define btwrite(dat,adr)    writel((dat), (char *) (zr->zr36057_mem+(adr)))
297 #define btread(adr)         readl(zr->zr36057_mem+(adr))
298 #endif
299 
300 #define btand(dat,adr)      btwrite((dat) & btread(adr), adr)
301 #define btor(dat,adr)       btwrite((dat) | btread(adr), adr)
302 #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
303 
304 #define I2C_TSA5522        0xc2
305 #define I2C_TDA9850        0xb6
306 #define I2C_HAUPEE         0xa0
307 #define I2C_STBEE          0xae
308 #define   I2C_SAA7111        0x48
309 #define   I2C_SAA7185        0x88
310 
311 #define TDA9850_CON1       0x04
312 #define TDA9850_CON2       0x05
313 #define TDA9850_CON3       0x06
314 #define TDA9850_CON4       0x07
315 #define TDA9850_ALI1       0x08
316 #define TDA9850_ALI2       0x09
317 #define TDA9850_ALI3       0x0a
318 
319 #endif
320 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.